@btc-vision/transaction 1.2.1 → 1.2.3

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 (84) hide show
  1. package/browser/_version.d.ts +1 -1
  2. package/browser/crypto/crypto-browser.d.ts +1 -1
  3. package/browser/generators/builders/CalldataGenerator.d.ts +1 -1
  4. package/browser/generators/builders/DeploymentGenerator.d.ts +1 -1
  5. package/browser/generators/builders/MineableReward.d.ts +7 -0
  6. package/browser/index.js +1 -1
  7. package/browser/opnet.d.ts +4 -0
  8. package/browser/transaction/ContractAddress.d.ts +1 -0
  9. package/browser/transaction/TransactionFactory.d.ts +19 -4
  10. package/browser/transaction/browser/WalletConnection.d.ts +18 -0
  11. package/browser/transaction/browser/types/Xverse.d.ts +24 -10
  12. package/browser/transaction/builders/ChallengeSolutionTransaction.d.ts +18 -0
  13. package/browser/transaction/builders/DeploymentTransaction.d.ts +4 -0
  14. package/browser/transaction/builders/SharedInteractionTransaction.d.ts +5 -0
  15. package/browser/transaction/builders/TransactionBuilder.d.ts +2 -0
  16. package/browser/transaction/enums/TransactionType.d.ts +3 -4
  17. package/browser/transaction/interfaces/ITransactionParameters.d.ts +6 -0
  18. package/browser/transaction/mineable/ChallengeGenerator.d.ts +9 -0
  19. package/browser/utxo/interfaces/IUTXO.d.ts +1 -1
  20. package/browser/verification/TapscriptVerificator.d.ts +1 -1
  21. package/build/_version.d.ts +1 -1
  22. package/build/_version.js +1 -1
  23. package/build/generators/Generator.js +1 -1
  24. package/build/generators/builders/CalldataGenerator.d.ts +1 -1
  25. package/build/generators/builders/CalldataGenerator.js +7 -26
  26. package/build/generators/builders/DeploymentGenerator.d.ts +1 -1
  27. package/build/generators/builders/DeploymentGenerator.js +9 -6
  28. package/build/generators/builders/LegacyCalldataGenerator.js +5 -1
  29. package/build/generators/builders/MineableReward.d.ts +7 -0
  30. package/build/generators/builders/MineableReward.js +47 -0
  31. package/build/opnet.d.ts +4 -0
  32. package/build/opnet.js +4 -0
  33. package/build/transaction/ContractAddress.d.ts +1 -0
  34. package/build/transaction/ContractAddress.js +4 -1
  35. package/build/transaction/TransactionFactory.d.ts +19 -4
  36. package/build/transaction/TransactionFactory.js +32 -0
  37. package/build/transaction/browser/WalletConnection.d.ts +18 -0
  38. package/build/transaction/browser/WalletConnection.js +95 -0
  39. package/build/transaction/browser/extensions/UnisatSigner.js +5 -2
  40. package/build/transaction/browser/extensions/XverseSigner.js +15 -9
  41. package/build/transaction/browser/types/Xverse.d.ts +24 -10
  42. package/build/transaction/builders/ChallengeSolutionTransaction.d.ts +18 -0
  43. package/build/transaction/builders/ChallengeSolutionTransaction.js +51 -0
  44. package/build/transaction/builders/DeploymentTransaction.d.ts +4 -0
  45. package/build/transaction/builders/DeploymentTransaction.js +23 -4
  46. package/build/transaction/builders/InteractionTransaction.js +1 -1
  47. package/build/transaction/builders/SharedInteractionTransaction.d.ts +5 -0
  48. package/build/transaction/builders/SharedInteractionTransaction.js +35 -13
  49. package/build/transaction/builders/TransactionBuilder.d.ts +2 -0
  50. package/build/transaction/builders/TransactionBuilder.js +2 -0
  51. package/build/transaction/enums/TransactionType.d.ts +3 -4
  52. package/build/transaction/enums/TransactionType.js +3 -4
  53. package/build/transaction/interfaces/ITransactionParameters.d.ts +6 -0
  54. package/build/transaction/mineable/ChallengeGenerator.d.ts +9 -0
  55. package/build/transaction/mineable/ChallengeGenerator.js +28 -0
  56. package/build/transaction/shared/TweakedTransaction.js +1 -1
  57. package/build/utxo/interfaces/IUTXO.d.ts +1 -1
  58. package/build/verification/TapscriptVerificator.d.ts +1 -1
  59. package/build/verification/TapscriptVerificator.js +2 -8
  60. package/package.json +3 -3
  61. package/src/_version.ts +1 -1
  62. package/src/generators/Generator.ts +1 -1
  63. package/src/generators/builders/CalldataGenerator.ts +10 -41
  64. package/src/generators/builders/DeploymentGenerator.ts +18 -7
  65. package/src/generators/builders/LegacyCalldataGenerator.ts +5 -1
  66. package/src/generators/builders/MineableReward.ts +63 -0
  67. package/src/opnet.ts +5 -0
  68. package/src/transaction/ContractAddress.ts +5 -1
  69. package/src/transaction/TransactionFactory.ts +66 -3
  70. package/src/transaction/browser/WalletConnection.ts +110 -0
  71. package/src/transaction/browser/extensions/UnisatSigner.ts +7 -3
  72. package/src/transaction/browser/extensions/XverseSigner.ts +24 -23
  73. package/src/transaction/browser/types/Xverse.ts +50 -36
  74. package/src/transaction/builders/ChallengeSolutionTransaction.ts +88 -0
  75. package/src/transaction/builders/DeploymentTransaction.ts +46 -3
  76. package/src/transaction/builders/InteractionTransaction.ts +1 -0
  77. package/src/transaction/builders/SharedInteractionTransaction.ts +54 -14
  78. package/src/transaction/builders/TransactionBuilder.ts +3 -0
  79. package/src/transaction/enums/TransactionType.ts +3 -4
  80. package/src/transaction/interfaces/ITransactionParameters.ts +8 -15
  81. package/src/transaction/mineable/ChallengeGenerator.ts +39 -0
  82. package/src/transaction/shared/TweakedTransaction.ts +1 -1
  83. package/src/utxo/interfaces/IUTXO.ts +1 -1
  84. package/src/verification/TapscriptVerificator.ts +3 -18
package/browser/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- var t,e,r={3513:(t,e,r)=>{var n=r(8510),i=r(4967),o=r(1484);function a(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var s=a(i),u=a(o);const c=n.secp256k1.ProjectivePoint,f="Expected Private",l="Expected Point",h="Expected Tweak",p="Expected Signature",d="Expected Extra Data (32 bytes)",y="Expected Scalar",g=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),b=new Uint8Array(32),v=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]),w=BigInt(1);function m(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function _(t){return 0===m(t,b)}function E(t){return t instanceof Uint8Array&&32===t.length&&!(m(t,g)>=0)}function S(t){return t instanceof Uint8Array&&64===t.length&&m(t.subarray(0,32),g)<0&&m(t.subarray(32,64),g)<0}function k(t){return t instanceof Uint8Array&&32===t.length}function T(t){return void 0===t||t instanceof Uint8Array&&32===t.length}function O(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t&&Number.isSafeInteger(t)&&t>=0)e=BigInt(t);else if("string"==typeof t){if(64!==t.length)throw new Error("Expected 32 bytes of private scalar");e=u.hexToNumber(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private scalar");if(32!==t.length)throw new Error("Expected 32 bytes of private scalar");e=u.bytesToNumberBE(t)}if(e<0)throw new Error("Expected private scalar >= 0");return e}function x(t){return n.secp256k1.utils.normPrivateKeyToScalar(t)}function A(t,e,r){const n=B(t),i=O(e),o=c.BASE.multiplyAndAddUnsafe(n,i,w);if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)}function P(t,e){return void 0===t?void 0===e||j(e):!!t}function I(t){try{return t()}catch(t){return null}}function L(t){return n.schnorr.utils.lift_x(u.bytesToNumberBE(t))}function B(t){return 32===t.length?L(t):c.fromHex(t)}function R(t,e){if(32===t.length!==e)return!1;try{return e?!!L(t):!!c.fromHex(t)}catch(t){return!1}}function N(t){return R(t,!1)}function j(t){return R(t,!1)&&33===t.length}function U(t){return n.secp256k1.utils.isValidPrivateKey(t)}function C(t){return R(t,!0)}function F(t){if(!N(t))throw new Error(l);return t.slice(1,33)}function M(t,e){if(!U(t))throw new Error(f);return I((()=>n.secp256k1.getPublicKey(t,P(e))))}e.isPoint=N,e.isPointCompressed=j,e.isPrivate=U,e.isXOnlyPoint=C,e.pointAdd=function(t,e,r){if(!N(t)||!N(e))throw new Error(l);return I((()=>{const n=B(t),i=B(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(P(r,t))}))},e.pointAddScalar=function(t,e,r){if(!N(t))throw new Error(l);if(!E(e))throw new Error(h);return I((()=>A(t,e,P(r,t))))},e.pointCompress=function(t,e){if(!N(t))throw new Error(l);return B(t).toRawBytes(P(e,t))},e.pointFromScalar=M,e.pointMultiply=function(t,e,r){if(!N(t))throw new Error(l);if(!E(e))throw new Error(h);return I((()=>function(t,e,r){const n=B(t),i="string"==typeof e?e:u.bytesToHex(e),o=u.hexToNumber(i);return n.multiply(o).toRawBytes(r)}(t,e,P(r,t))))},e.privateAdd=function(t,e){if(!U(t))throw new Error(f);if(!E(e))throw new Error(h);return I((()=>function(t,e){const r=x(t),i=O(e),o=u.numberToBytesBE(s.mod(r+i,n.secp256k1.CURVE.n),32);return n.secp256k1.utils.isValidPrivateKey(o)?o:null}(t,e)))},e.privateNegate=function(t){if(!U(t))throw new Error(f);return function(t){const e=x(t),r=u.numberToBytesBE(n.secp256k1.CURVE.n-e,32);return n.secp256k1.utils.isValidPrivateKey(r)?r:null}(t)},e.privateSub=function(t,e){if(!U(t))throw new Error(f);if(!E(e))throw new Error(h);return I((()=>function(t,e){const r=x(t),i=O(e),o=u.numberToBytesBE(s.mod(r-i,n.secp256k1.CURVE.n),32);return n.secp256k1.utils.isValidPrivateKey(o)?o:null}(t,e)))},e.recover=function(t,e,r,i){if(!k(t))throw new Error("Expected Hash");if(!S(e)||!function(t){return!(_(t.subarray(0,32))||_(t.subarray(32,64)))}(e))throw new Error(p);if(2&r&&!function(t){return t instanceof Uint8Array&&64===t.length&&m(t.subarray(0,32),v)<0}(e))throw new Error("Bad Recovery Id");if(!C(e.subarray(0,32)))throw new Error(p);const o=n.secp256k1.Signature.fromCompact(e).addRecoveryBit(r).recoverPublicKey(t);if(!o)throw new Error(p);return o.toRawBytes(P(i))},e.sign=function(t,e,r){if(!U(e))throw new Error(f);if(!k(t))throw new Error(y);if(!T(r))throw new Error(d);return n.secp256k1.sign(t,e,{extraEntropy:r}).toCompactRawBytes()},e.signRecoverable=function(t,e,r){if(!U(e))throw new Error(f);if(!k(t))throw new Error(y);if(!T(r))throw new Error(d);const i=n.secp256k1.sign(t,e,{extraEntropy:r});return{signature:i.toCompactRawBytes(),recoveryId:i.recovery}},e.signSchnorr=function(t,e,r){if(!U(e))throw new Error(f);if(!k(t))throw new Error(y);if(!T(r))throw new Error(d);return n.schnorr.sign(t,e,r)},e.verify=function(t,e,r,i){if(!N(e))throw new Error(l);if(!S(r))throw new Error(p);if(!k(t))throw new Error(y);return n.secp256k1.verify(r,t,e,{lowS:i})},e.verifySchnorr=function(t,e,r){if(!C(e))throw new Error(l);if(!S(r))throw new Error(p);if(!k(t))throw new Error(y);return n.schnorr.verify(r,t,e)},e.xOnlyPointAddTweak=function(t,e){if(!C(t))throw new Error(l);if(!E(e))throw new Error(h);return I((()=>{const r=A(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}}))},e.xOnlyPointFromPoint=F,e.xOnlyPointFromScalar=function(t){if(!U(t))throw new Error(f);return F(M(t))}},3562:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getHash=a,e.createCurve=function(t,e){const r=e=>(0,o.weierstrass)({...t,...a(e)});return Object.freeze({...r(e),create:r})};const n=r(3788),i=r(1130),o=r(1705);function a(t){return{hash:t,hmac:(e,...r)=>(0,n.hmac)(t,e,(0,i.concatBytes)(...r)),randomBytes:i.randomBytes}}},2422:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.wNAF=function(t,e){return{constTimeNegate:s,hasPrecomputes:t=>1!==d(t),unsafeLadder(e,r,n=t.ZERO){let i=e;for(;r>o;)r&a&&(n=n.add(i)),i=i.double(),r>>=a;return n},precomputeWindow(t,r){const{windows:n,windowSize:i}=c(r,e),o=[];let a=t,s=a;for(let t=0;t<n;t++){s=a,o.push(s);for(let t=1;t<i;t++)s=s.add(a),o.push(s);a=s.double()}return o},wNAF(r,n,i){const{windows:o,windowSize:u}=c(r,e);let f=t.ZERO,l=t.BASE;const h=BigInt(2**r-1),p=2**r,d=BigInt(r);for(let t=0;t<o;t++){const e=t*u;let r=Number(i&h);i>>=d,r>u&&(r-=p,i+=a);const o=e,c=e+Math.abs(r)-1,y=t%2!=0,g=r<0;0===r?l=l.add(s(y,n[o])):f=f.add(s(g,n[c]))}return{p:f,f:l}},wNAFUnsafe(r,n,i,s=t.ZERO){const{windows:u,windowSize:f}=c(r,e),l=BigInt(2**r-1),h=2**r,p=BigInt(r);for(let t=0;t<u;t++){const e=t*f;if(i===o)break;let r=Number(i&l);if(i>>=p,r>f&&(r-=h,i+=a),0===r)continue;let u=n[e+Math.abs(r)-1];r<0&&(u=u.negate()),s=s.add(u)}return s},getPrecomputes(t,e,r){let n=h.get(e);return n||(n=this.precomputeWindow(e,t),1!==t&&h.set(e,r(n))),n},wNAFCached(t,e,r){const n=d(t);return this.wNAF(n,this.getPrecomputes(n,t,r),e)},wNAFCachedUnsafe(t,e,r,n){const i=d(t);return 1===i?this.unsafeLadder(t,e,n):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),e,n)},setWindowSize(t,r){u(r,e),p.set(t,r),h.delete(t)}}},e.pippenger=function(t,e,r,n){if(f(r,t),l(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=(0,i.bitLen)(BigInt(r.length)),s=a>12?a-3:a>4?a-2:a?2:1,u=(1<<s)-1,c=new Array(u+1).fill(o);let h=o;for(let t=Math.floor((e.BITS-1)/s)*s;t>=0;t-=s){c.fill(o);for(let e=0;e<n.length;e++){const i=n[e],o=Number(i>>BigInt(t)&BigInt(u));c[o]=c[o].add(r[e])}let e=o;for(let t=c.length-1,r=o;t>0;t--)r=r.add(c[t]),e=e.add(r);if(h=h.add(e),0!==t)for(let t=0;t<s;t++)h=h.double()}return h},e.precomputeMSMUnsafe=function(t,e,r,n){u(n,e.BITS),f(r,t);const i=t.ZERO,o=2**n-1,a=Math.ceil(e.BITS/n),s=BigInt((1<<n)-1),c=r.map((t=>{const e=[];for(let r=0,n=t;r<o;r++)e.push(n),n=n.add(t);return e}));return t=>{if(l(t,e),t.length>r.length)throw new Error("array of scalars must be smaller than array of points");let o=i;for(let e=0;e<a;e++){if(o!==i)for(let t=0;t<n;t++)o=o.double();const r=BigInt(a*n-(e+1)*n);for(let e=0;e<t.length;e++){const n=t[e],i=Number(n>>r&s);i&&(o=o.add(c[e][i-1]))}}return o}},e.validateBasic=function(t){return(0,n.validateField)(t.Fp),(0,i.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,n.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})};const n=r(4967),i=r(1484),o=BigInt(0),a=BigInt(1);function s(t,e){const r=e.negate();return t?r:e}function u(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function c(t,e){return u(t,e),{windows:Math.ceil(e/t)+1,windowSize:2**(t-1)}}function f(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach(((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)}))}function l(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach(((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)}))}const h=new WeakMap,p=new WeakMap;function d(t){return p.get(t)||1}},1761:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.expand_message_xmd=c,e.expand_message_xof=f,e.hash_to_field=l,e.isogenyMap=function(t,e){const r=e.map((t=>Array.from(t).reverse()));return(e,n)=>{const[i,o,a,s]=r.map((r=>r.reduce(((r,n)=>t.add(t.mul(r,e),n)))));return e=t.div(i,o),n=t.mul(n,t.div(a,s)),{x:e,y:n}}},e.createHasher=function(t,e,r){if("function"!=typeof e)throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){const o=l(n,2,{...r,DST:r.DST,...i}),a=t.fromAffine(e(o[0])),s=t.fromAffine(e(o[1])),u=a.add(s).clearCofactor();return u.assertValidity(),u},encodeToCurve(n,i){const o=l(n,1,{...r,DST:r.encodeDST,...i}),a=t.fromAffine(e(o[0])).clearCofactor();return a.assertValidity(),a},mapToCurve(r){if(!Array.isArray(r))throw new Error("mapToCurve: expected array of bigints");for(const t of r)if("bigint"!=typeof t)throw new Error("mapToCurve: expected array of bigints");const n=t.fromAffine(e(r)).clearCofactor();return n.assertValidity(),n}}};const n=r(4967),i=r(1484),o=i.bytesToNumberBE;function a(t,e){if(u(t),u(e),t<0||t>=1<<8*e)throw new Error("invalid I2OSP input: "+t);const r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=255&t,t>>>=8;return new Uint8Array(r)}function s(t,e){const r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function u(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function c(t,e,r,n){(0,i.abytes)(t),(0,i.abytes)(e),u(r),e.length>255&&(e=n((0,i.concatBytes)((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));const{outputLen:o,blockLen:c}=n,f=Math.ceil(r/o);if(r>65535||f>255)throw new Error("expand_message_xmd: invalid lenInBytes");const l=(0,i.concatBytes)(e,a(e.length,1)),h=a(0,c),p=a(r,2),d=new Array(f),y=n((0,i.concatBytes)(h,t,p,a(0,1),l));d[0]=n((0,i.concatBytes)(y,a(1,1),l));for(let t=1;t<=f;t++){const e=[s(y,d[t-1]),a(t+1,1),l];d[t]=n((0,i.concatBytes)(...e))}return(0,i.concatBytes)(...d).slice(0,r)}function f(t,e,r,n,o){if((0,i.abytes)(t),(0,i.abytes)(e),u(r),e.length>255){const t=Math.ceil(2*n/8);e=o.create({dkLen:t}).update((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:r}).update(t).update(a(r,2)).update(e).update(a(e.length,1)).digest()}function l(t,e,r){(0,i.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:a,k:s,m:l,hash:h,expand:p,DST:d}=r;(0,i.abytes)(t),u(e);const y="string"==typeof d?(0,i.utf8ToBytes)(d):d,g=a.toString(2).length,b=Math.ceil((g+s)/8),v=e*l*b;let w;if("xmd"===p)w=c(t,y,v,h);else if("xof"===p)w=f(t,y,v,s,h);else{if("_internal_pass"!==p)throw new Error('expand must be "xmd" or "xof"');w=t}const m=new Array(e);for(let t=0;t<e;t++){const e=new Array(l);for(let r=0;r<l;r++){const i=b*(r+t*l),s=w.subarray(i,i+b);e[r]=(0,n.mod)(o(s),a)}m[t]=e}return m}},4967:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNegativeLE=void 0,e.mod=l,e.pow=h,e.pow2=function(t,e,r){let n=t;for(;e-- >i;)n*=n,n%=r;return n},e.invert=p,e.tonelliShanks=d,e.FpSqrt=y,e.validateField=function(t){const e=g.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,n.validateObject)(t,e)},e.FpPow=b,e.FpInvertBatch=v,e.FpDiv=function(t,e,r){return t.mul(e,"bigint"==typeof r?p(r,t.ORDER):t.inv(r))},e.FpLegendre=w,e.FpIsSquare=function(t){const e=w(t.ORDER);return r=>{const n=e(t,r);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}},e.nLength=m,e.Field=function(t,e,r=!1,a={}){if(t<=i)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:u}=m(t,e);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c;const f=Object.freeze({ORDER:t,BITS:s,BYTES:u,MASK:(0,n.bitMask)(s),ZERO:i,ONE:o,create:e=>l(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return i<=e&&e<t},is0:t=>t===i,isOdd:t=>(t&o)===o,neg:e=>l(-e,t),eql:(t,e)=>t===e,sqr:e=>l(e*e,t),add:(e,r)=>l(e+r,t),sub:(e,r)=>l(e-r,t),mul:(e,r)=>l(e*r,t),pow:(t,e)=>b(f,t,e),div:(e,r)=>l(e*p(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>p(e,t),sqrt:a.sqrt||(e=>(c||(c=y(t)),c(f,e))),invertBatch:t=>v(f,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?(0,n.numberToBytesLE)(t,u):(0,n.numberToBytesBE)(t,u),fromBytes:t=>{if(t.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+t.length);return r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t)}});return Object.freeze(f)},e.FpSqrtOdd=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)},e.FpSqrtEven=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r},e.hashToPrivateScalar=function(t,e,r=!1){const i=(t=(0,n.ensureBytes)("privateHash",t)).length,a=m(e).nByteLength+8;if(a<24||i<a||i>1024)throw new Error("hashToPrivateScalar: expected "+a+"-1024 bytes of input, got "+i);return l(r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t),e-o)+o},e.getFieldBytesLength=_,e.getMinHashLength=E,e.mapHashToField=function(t,e,r=!1){const i=t.length,a=_(e),s=E(e);if(i<16||i<s||i>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+i);const u=l(r?(0,n.bytesToNumberBE)(t):(0,n.bytesToNumberLE)(t),e-o)+o;return r?(0,n.numberToBytesLE)(u,a):(0,n.numberToBytesBE)(u,a)};const n=r(1484),i=BigInt(0),o=BigInt(1),a=BigInt(2),s=BigInt(3),u=BigInt(4),c=BigInt(5),f=BigInt(8);function l(t,e){const r=t%e;return r>=i?r:e+r}function h(t,e,r){if(e<i)throw new Error("invalid exponent, negatives unsupported");if(r<=i)throw new Error("invalid modulus");if(r===o)return i;let n=o;for(;e>i;)e&o&&(n=n*t%r),t=t*t%r,e>>=o;return n}function p(t,e){if(t===i)throw new Error("invert: expected non-zero number");if(e<=i)throw new Error("invert: expected positive modulus, got "+e);let r=l(t,e),n=e,a=i,s=o,u=o,c=i;for(;r!==i;){const t=n/r,e=n%r,i=a-u*t,o=s-c*t;n=r,r=e,a=u,s=c,u=i,c=o}if(n!==o)throw new Error("invert: does not exist");return l(a,e)}function d(t){const e=(t-o)/a;let r,n,s;for(r=t-o,n=0;r%a===i;r/=a,n++);for(s=a;s<t&&h(s,e,t)!==t-o;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(1===n){const e=(t+o)/u;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 c=(r+o)/a;return function(t,i){if(t.pow(i,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=n,u=t.pow(t.mul(t.ONE,s),r),f=t.pow(i,c),l=t.pow(i,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,o<<BigInt(a-e-1));u=t.sqr(r),f=t.mul(f,r),l=t.mul(l,u),a=e}return f}}function y(t){if(t%u===s){const e=(t+o)/u;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%f===c){const e=(t-c)/f;return function(t,r){const n=t.mul(r,a),i=t.pow(n,e),o=t.mul(r,i),s=t.mul(t.mul(o,a),i),u=t.mul(o,t.sub(s,t.ONE));if(!t.eql(t.sqr(u),r))throw new Error("Cannot find square root");return u}}return d(t)}e.isNegativeLE=(t,e)=>(l(t,e)&o)===o;const g=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function b(t,e,r){if(r<i)throw new Error("invalid exponent, negatives unsupported");if(r===i)return t.ONE;if(r===o)return e;let n=t.ONE,a=e;for(;r>i;)r&o&&(n=t.mul(n,a)),a=t.sqr(a),r>>=o;return n}function v(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}function w(t){const e=(t-o)/a;return(t,r)=>t.pow(r,e)}function m(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function _(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 E(t){const e=_(t);return e+Math.ceil(e/2)}},1484:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.notImplemented=e.bitMask=void 0,e.isBytes=o,e.abytes=a,e.abool=function(t,e){if("boolean"!=typeof e)throw new Error(t+" boolean expected, got "+e)},e.bytesToHex=u,e.numberToHexUnpadded=c,e.hexToNumber=f,e.hexToBytes=p,e.bytesToNumberBE=function(t){return f(u(t))},e.bytesToNumberLE=function(t){return a(t),f(u(Uint8Array.from(t).reverse()))},e.numberToBytesBE=d,e.numberToBytesLE=function(t,e){return d(t,e).reverse()},e.numberToVarBytesBE=function(t){return p(c(t))},e.ensureBytes=function(t,e,r){let n;if("string"==typeof e)try{n=p(e)}catch(e){throw new Error(t+" must be hex string or Uint8Array, cause: "+e)}else{if(!o(e))throw new Error(t+" must be hex string or Uint8Array");n=Uint8Array.from(e)}const i=n.length;if("number"==typeof r&&i!==r)throw new Error(t+" of length "+r+" expected, got "+i);return n},e.concatBytes=y,e.equalBytes=function(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return 0===r},e.utf8ToBytes=function(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))},e.inRange=b,e.aInRange=function(t,e,r,n){if(!b(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)},e.bitLen=function(t){let e;for(e=0;t>r;t>>=n,e+=1);return e},e.bitGet=function(t,e){return t>>BigInt(e)&n},e.bitSet=function(t,e,i){return t|(i?n:r)<<BigInt(e)},e.createHmacDrbg=function(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=v(t),i=v(t),o=0;const a=()=>{n.fill(1),i.fill(0),o=0},s=(...t)=>r(i,n,...t),u=(t=v())=>{i=s(w([0]),t),n=s(),0!==t.length&&(i=s(w([1]),t),n=s())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){n=s();const e=n.slice();r.push(e),t+=n.length}return y(...r)};return(t,e)=>{let r;for(a(),u(t);!(r=e(c()));)u();return a(),r}},e.validateObject=function(t,e,r={}){const n=(e,r,n)=>{const i=m[r];if("function"!=typeof i)throw new Error("invalid validator function");const o=t[e];if(!(n&&void 0===o||i(o,t)))throw new Error("param "+String(e)+" is invalid. Expected "+r+", got "+o)};for(const[t,r]of Object.entries(e))n(t,r,!1);for(const[t,e]of Object.entries(r))n(t,e,!0);return t},e.memoized=function(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(void 0!==i)return i;const o=t(r,...n);return e.set(r,o),o}};const r=BigInt(0),n=BigInt(1),i=BigInt(2);function o(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function a(t){if(!o(t))throw new Error("Uint8Array expected")}const s=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function u(t){a(t);let e="";for(let r=0;r<t.length;r++)e+=s[t[r]];return e}function c(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function f(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?r:BigInt("0x"+t)}const l={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(t){return t>=l._0&&t<=l._9?t-l._0:t>=l.A&&t<=l.F?t-(l.A-10):t>=l.a&&t<=l.f?t-(l.a-10):void 0}function p(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,i=0;e<r;e++,i+=2){const r=h(t.charCodeAt(i)),o=h(t.charCodeAt(i+1));if(void 0===r||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+o}return n}function d(t,e){return p(t.toString(16).padStart(2*e,"0"))}function y(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];a(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}const g=t=>"bigint"==typeof t&&r<=t;function b(t,e,r){return g(t)&&g(e)&&g(r)&&e<=t&&t<r}e.bitMask=t=>(i<<BigInt(t-1))-n;const v=t=>new Uint8Array(t),w=t=>Uint8Array.from(t),m={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||o(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};e.notImplemented=()=>{throw new Error("not implemented")}},1705:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DER=void 0,e.weierstrassPoints=y,e.weierstrass=function(t){const r=function(t){const e=(0,n.validateBasic)(t);return o.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:u,n:c}=r,h=u.BYTES+1,p=2*u.BYTES+1;function d(t){return i.mod(t,c)}function g(t){return i.invert(t,c)}const{ProjectivePoint:b,normPrivateKeyToScalar:v,weierstrassEquation:w,isWithinCurveOrder:m}=y({...r,toBytes(t,e,r){const n=e.toAffine(),i=u.toBytes(n.x),s=o.concatBytes;return(0,a.abool)("isCompressed",r),r?s(Uint8Array.from([e.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,u.toBytes(n.y))},fromBytes(t){const e=t.length,r=t[0],n=t.subarray(1);if(e!==h||2!==r&&3!==r){if(e===p&&4===r)return{x:u.fromBytes(n.subarray(0,u.BYTES)),y:u.fromBytes(n.subarray(u.BYTES,2*u.BYTES))};throw new Error("invalid Point, expected length of "+h+", or uncompressed "+p+", got "+e)}{const t=o.bytesToNumberBE(n);if(!o.inRange(t,l,u.ORDER))throw new Error("Point is not on curve");const e=w(t);let i;try{i=u.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("Point is not on curve"+e)}return!(1&~r)!=((i&l)===l)&&(i=u.neg(i)),{x:t,y:i}}}}),_=t=>o.bytesToHex(o.numberToBytesBE(t,r.nByteLength));function E(t){return t>c>>l}const S=(t,e,r)=>o.bytesToNumberBE(t.slice(e,r));class k{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const e=r.nByteLength;return t=(0,a.ensureBytes)("compactSignature",t,2*e),new k(S(t,0,e),S(t,e,2*e))}static fromDER(t){const{r,s:n}=e.DER.toSig((0,a.ensureBytes)("DER",t));return new k(r,n)}assertValidity(){o.aInRange("r",this.r,l,c),o.aInRange("s",this.s,l,c)}addRecoveryBit(t){return new k(this.r,this.s,t)}recoverPublicKey(t){const{r:e,s:n,recovery:i}=this,o=A((0,a.ensureBytes)("msgHash",t));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const s=2===i||3===i?e+r.n:e;if(s>=u.ORDER)throw new Error("recovery id 2 or 3 invalid");const c=1&i?"03":"02",f=b.fromHex(c+_(s)),l=g(s),h=d(-o*l),p=d(n*l),y=b.BASE.multiplyAndAddUnsafe(f,h,p);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return E(this.s)}normalizeS(){return this.hasHighS()?new k(this.r,d(-this.s),this.recovery):this}toDERRawBytes(){return o.hexToBytes(this.toDERHex())}toDERHex(){return e.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return o.hexToBytes(this.toCompactHex())}toCompactHex(){return _(this.r)+_(this.s)}}const T={isValidPrivateKey(t){try{return v(t),!0}catch(t){return!1}},normPrivateKeyToScalar:v,randomPrivateKey:()=>{const t=i.getMinHashLength(r.n);return i.mapHashToField(r.randomBytes(t),r.n)},precompute:(t=8,e=b.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function O(t){const e=o.isBytes(t),r="string"==typeof t,n=(e||r)&&t.length;return e?n===h||n===p:r?n===2*h||n===2*p:t instanceof b}const x=r.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=o.bytesToNumberBE(t),n=8*t.length-r.nBitLength;return n>0?e>>BigInt(n):e},A=r.bits2int_modN||function(t){return d(x(t))},P=o.bitMask(r.nBitLength);function I(t){return o.aInRange("num < 2^"+r.nBitLength,t,f,P),o.numberToBytesBE(t,r.nByteLength)}const L={lowS:r.lowS,prehash:!1},B={lowS:r.lowS,prehash:!1};return b.BASE._setWindowSize(8),{CURVE:r,getPublicKey:function(t,e=!0){return b.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(O(t))throw new Error("first arg must be private key");if(!O(e))throw new Error("second arg must be public key");return b.fromHex(e).multiply(v(t)).toRawBytes(r)},sign:function(t,e,n=L){const{seed:i,k2sig:c}=function(t,e,n=L){if(["recovered","canonical"].some((t=>t in n)))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:c}=r;let{lowS:h,prehash:p,extraEntropy:y}=n;null==h&&(h=!0),t=(0,a.ensureBytes)("msgHash",t),s(n),p&&(t=(0,a.ensureBytes)("prehashed msgHash",i(t)));const w=A(t),_=v(e),S=[I(_),I(w)];if(null!=y&&!1!==y){const t=!0===y?c(u.BYTES):y;S.push((0,a.ensureBytes)("extraEntropy",t))}const T=o.concatBytes(...S),O=w;return{seed:T,k2sig:function(t){const e=x(t);if(!m(e))return;const r=g(e),n=b.BASE.multiply(e).toAffine(),i=d(n.x);if(i===f)return;const o=d(r*d(O+i*_));if(o===f)return;let a=(n.x===i?0:2)|Number(n.y&l),s=o;return h&&E(o)&&(s=function(t){return E(t)?d(-t):t}(o),a^=1),new k(i,s,a)}}}(t,e,n),h=r;return o.createHmacDrbg(h.hash.outputLen,h.nByteLength,h.hmac)(i,c)},verify:function(t,n,i,u=B){const c=t;n=(0,a.ensureBytes)("msgHash",n),i=(0,a.ensureBytes)("publicKey",i);const{lowS:f,prehash:l,format:h}=u;if(s(u),"strict"in u)throw new Error("options.strict was renamed to lowS");if(void 0!==h&&"compact"!==h&&"der"!==h)throw new Error("format must be compact or der");const p="string"==typeof c||o.isBytes(c),y=!p&&!h&&"object"==typeof c&&null!==c&&"bigint"==typeof c.r&&"bigint"==typeof c.s;if(!p&&!y)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let v,w;try{if(y&&(v=new k(c.r,c.s)),p){try{"compact"!==h&&(v=k.fromDER(c))}catch(t){if(!(t instanceof e.DER.Err))throw t}v||"der"===h||(v=k.fromCompact(c))}w=b.fromHex(i)}catch(t){return!1}if(!v)return!1;if(f&&v.hasHighS())return!1;l&&(n=r.hash(n));const{r:m,s:_}=v,E=A(n),S=g(_),T=d(E*S),O=d(m*S),x=b.BASE.multiplyAndAddUnsafe(w,T,O)?.toAffine();return!!x&&d(x.x)===m},ProjectivePoint:b,Signature:k,utils:T}},e.SWUFpSqrtRatio=g,e.mapToCurveSimpleSWU=function(t,e){if(i.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=g(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,o,a,s,u,c,f,l;i=t.sqr(n),i=t.mul(i,e.Z),o=t.sqr(i),o=t.add(o,i),a=t.add(o,t.ONE),a=t.mul(a,e.B),s=t.cmov(e.Z,t.neg(o),!t.eql(o,t.ZERO)),s=t.mul(s,e.A),o=t.sqr(a),c=t.sqr(s),u=t.mul(c,e.A),o=t.add(o,u),o=t.mul(o,a),c=t.mul(c,s),u=t.mul(c,e.B),o=t.add(o,u),f=t.mul(i,a);const{isValid:h,value:p}=r(o,c);l=t.mul(i,n),l=t.mul(l,p),f=t.cmov(f,a,h),l=t.cmov(l,p,h);const d=t.isOdd(n)===t.isOdd(l);return l=t.cmov(t.neg(l),l,d),f=t.div(f,s),{x:f,y:l}}};const n=r(2422),i=r(4967),o=r(1484),a=r(1484);function s(t){void 0!==t.lowS&&(0,a.abool)("lowS",t.lowS),void 0!==t.prehash&&(0,a.abool)("prehash",t.prehash)}const{bytesToNumberBE:u,hexToBytes:c}=o;e.DER={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(t,r)=>{const{Err:n}=e.DER;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(1&r.length)throw new n("tlv.encode: unpadded data");const i=r.length/2,a=o.numberToHexUnpadded(i);if(a.length/2&128)throw new n("tlv.encode: long form length too big");const s=i>127?o.numberToHexUnpadded(a.length/2|128):"";return o.numberToHexUnpadded(t)+s+a+r},decode(t,r){const{Err:n}=e.DER;let i=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(r.length<2||r[i++]!==t)throw new n("tlv.decode: wrong tlv");const o=r[i++];let a=0;if(128&o){const t=127&o;if(!t)throw new n("tlv.decode(long): indefinite length not supported");if(t>4)throw new n("tlv.decode(long): byte length is too big");const e=r.subarray(i,i+t);if(e.length!==t)throw new n("tlv.decode: length bytes not complete");if(0===e[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of e)a=a<<8|t;if(i+=t,a<128)throw new n("tlv.decode(long): not minimal encoding")}else a=o;const s=r.subarray(i,i+a);if(s.length!==a)throw new n("tlv.decode: wrong value length");return{v:s,l:r.subarray(i+a)}}},_int:{encode(t){const{Err:r}=e.DER;if(t<f)throw new r("integer: negative integers are not allowed");let n=o.numberToHexUnpadded(t);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new r("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:r}=e.DER;if(128&t[0])throw new r("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new r("invalid signature integer: unnecessary leading zero");return u(t)}},toSig(t){const{Err:r,_int:n,_tlv:i}=e.DER,a="string"==typeof t?c(t):t;o.abytes(a);const{v:s,l:u}=i.decode(48,a);if(u.length)throw new r("invalid signature: left bytes after parsing");const{v:f,l}=i.decode(2,s),{v:h,l:p}=i.decode(2,l);if(p.length)throw new r("invalid signature: left bytes after parsing");return{r:n.decode(f),s:n.decode(h)}},hexFromSig(t){const{_tlv:r,_int:n}=e.DER,i=r.encode(2,n.encode(t.r))+r.encode(2,n.encode(t.s));return r.encode(48,i)}};const f=BigInt(0),l=BigInt(1),h=BigInt(2),p=BigInt(3),d=BigInt(4);function y(t){const e=function(t){const e=(0,n.validateBasic)(t);o.validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:i,a}=e;if(r){if(!i.eql(a,i.ZERO))throw new Error("invalid 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("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:r}=e,s=i.Field(e.n,e.nBitLength),u=e.toBytes||((t,e,n)=>{const i=e.toAffine();return o.concatBytes(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),c=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 h(t){const{a:n,b:i}=e,o=r.sqr(t),a=r.mul(o,t);return r.add(r.add(a,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),h(e.Gx)))throw new Error("bad generator point: equation left != right");function d(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:s,n:u}=e;if(r&&"bigint"!=typeof t){if(o.isBytes(t)&&(t=o.bytesToHex(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("invalid private key");t=t.padStart(2*n,"0")}let c;try{c="bigint"==typeof t?t:o.bytesToNumberBE((0,a.ensureBytes)("private key",t,n))}catch(e){throw new Error("invalid private key, expected hex or "+n+" bytes, got "+typeof t)}return s&&(c=i.mod(c,u)),o.aInRange("private key",c,l,u),c}function y(t){if(!(t instanceof v))throw new Error("ProjectivePoint expected")}const g=(0,a.memoized)(((t,e)=>{const{px:n,py:i,pz:o}=t;if(r.eql(o,r.ONE))return{x:n,y:i};const a=t.is0();null==e&&(e=a?r.ONE:r.inv(o));const s=r.mul(n,e),u=r.mul(i,e),c=r.mul(o,e);if(a)return{x:r.ZERO,y:r.ZERO};if(!r.eql(c,r.ONE))throw new Error("invZ was invalid");return{x:s,y:u}})),b=(0,a.memoized)((t=>{if(t.is0()){if(e.allowInfinityPoint&&!r.is0(t.py))return;throw new Error("bad point: ZERO")}const{x:n,y:i}=t.toAffine();if(!r.isValid(n)||!r.isValid(i))throw new Error("bad point: x or y not FE");const o=r.sqr(i),a=h(n);if(!r.eql(o,a))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class v{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");Object.freeze(this)}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 v)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?v.ZERO:new v(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(v.fromAffine)}static fromHex(t){const e=v.fromAffine(c((0,a.ensureBytes)("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return v.BASE.multiply(d(t))}static msm(t,e){return(0,n.pippenger)(v,s,t,e)}_setWindowSize(t){m.setWindowSize(this,t)}assertValidity(){b(this)}hasEvenY(){const{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){y(t);const{px:e,py:n,pz:i}=this,{px:o,py:a,pz:s}=t,u=r.eql(r.mul(e,s),r.mul(o,i)),c=r.eql(r.mul(n,s),r.mul(a,i));return u&&c}negate(){return new v(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,p),{px:o,py:a,pz:s}=this;let u=r.ZERO,c=r.ZERO,f=r.ZERO,l=r.mul(o,o),h=r.mul(a,a),d=r.mul(s,s),y=r.mul(o,a);return y=r.add(y,y),f=r.mul(o,s),f=r.add(f,f),u=r.mul(t,f),c=r.mul(i,d),c=r.add(u,c),u=r.sub(h,c),c=r.add(h,c),c=r.mul(u,c),u=r.mul(y,u),f=r.mul(i,f),d=r.mul(t,d),y=r.sub(l,d),y=r.mul(t,y),y=r.add(y,f),f=r.add(l,l),l=r.add(f,l),l=r.add(l,d),l=r.mul(l,y),c=r.add(c,l),d=r.mul(a,s),d=r.add(d,d),l=r.mul(d,y),u=r.sub(u,l),f=r.mul(d,h),f=r.add(f,f),f=r.add(f,f),new v(u,c,f)}add(t){y(t);const{px:n,py:i,pz:o}=this,{px:a,py:s,pz:u}=t;let c=r.ZERO,f=r.ZERO,l=r.ZERO;const h=e.a,d=r.mul(e.b,p);let g=r.mul(n,a),b=r.mul(i,s),w=r.mul(o,u),m=r.add(n,i),_=r.add(a,s);m=r.mul(m,_),_=r.add(g,b),m=r.sub(m,_),_=r.add(n,o);let E=r.add(a,u);return _=r.mul(_,E),E=r.add(g,w),_=r.sub(_,E),E=r.add(i,o),c=r.add(s,u),E=r.mul(E,c),c=r.add(b,w),E=r.sub(E,c),l=r.mul(h,_),c=r.mul(d,w),l=r.add(c,l),c=r.sub(b,l),l=r.add(b,l),f=r.mul(c,l),b=r.add(g,g),b=r.add(b,g),w=r.mul(h,w),_=r.mul(d,_),b=r.add(b,w),w=r.sub(g,w),w=r.mul(h,w),_=r.add(_,w),g=r.mul(b,_),f=r.add(f,g),g=r.mul(E,_),c=r.mul(m,c),c=r.sub(c,g),g=r.mul(m,b),l=r.mul(E,l),l=r.add(l,g),new v(c,f,l)}subtract(t){return this.add(t.negate())}is0(){return this.equals(v.ZERO)}wNAF(t){return m.wNAFCached(this,t,v.normalizeZ)}multiplyUnsafe(t){const{endo:n,n:i}=e;o.aInRange("scalar",t,f,i);const a=v.ZERO;if(t===f)return a;if(this.is0()||t===l)return this;if(!n||m.hasPrecomputes(this))return m.wNAFCachedUnsafe(this,t,v.normalizeZ);let{k1neg:s,k1:u,k2neg:c,k2:h}=n.splitScalar(t),p=a,d=a,y=this;for(;u>f||h>f;)u&l&&(p=p.add(y)),h&l&&(d=d.add(y)),y=y.double(),u>>=l,h>>=l;return s&&(p=p.negate()),c&&(d=d.negate()),d=new v(r.mul(d.px,n.beta),d.py,d.pz),p.add(d)}multiply(t){const{endo:n,n:i}=e;let a,s;if(o.aInRange("scalar",t,l,i),n){const{k1neg:e,k1:i,k2neg:o,k2:u}=n.splitScalar(t);let{p:c,f}=this.wNAF(i),{p:l,f:h}=this.wNAF(u);c=m.constTimeNegate(e,c),l=m.constTimeNegate(o,l),l=new v(r.mul(l.px,n.beta),l.py,l.pz),a=c.add(l),s=f.add(h)}else{const{p:e,f:r}=this.wNAF(t);a=e,s=r}return v.normalizeZ([a,s])[0]}multiplyAndAddUnsafe(t,e,r){const n=v.BASE,i=(t,e)=>e!==f&&e!==l&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),o=i(this,e).add(i(t,r));return o.is0()?void 0:o}toAffine(t){return g(this,t)}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===l)return!0;if(r)return r(v,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===l?this:r?r(v,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return(0,a.abool)("isCompressed",t),this.assertValidity(),u(v,this,t)}toHex(t=!0){return(0,a.abool)("isCompressed",t),o.bytesToHex(this.toRawBytes(t))}}v.BASE=new v(e.Gx,e.Gy,r.ONE),v.ZERO=new v(r.ZERO,r.ONE,r.ZERO);const w=e.nBitLength,m=(0,n.wNAF)(v,e.endo?Math.ceil(w/2):w);return{CURVE:e,ProjectivePoint:v,normPrivateKeyToScalar:d,weierstrassEquation:h,isWithinCurveOrder:function(t){return o.inRange(t,l,e.n)}}}function g(t,e){const r=t.ORDER;let n=f;for(let t=r-l;t%h===f;t/=h)n+=l;const i=n,o=h<<i-l-l,a=o*h,s=(r-l)/a,u=(s-l)/h,c=a-l,y=o,g=t.pow(e,s),b=t.pow(e,(s+l)/h);let v=(e,r)=>{let n=g,o=t.pow(r,c),a=t.sqr(o);a=t.mul(a,r);let s=t.mul(e,a);s=t.pow(s,u),s=t.mul(s,o),o=t.mul(s,r),a=t.mul(s,e);let f=t.mul(a,o);s=t.pow(f,y);let p=t.eql(s,t.ONE);o=t.mul(a,b),s=t.mul(f,n),a=t.cmov(o,a,p),f=t.cmov(s,f,p);for(let e=i;e>l;e--){let r=e-h;r=h<<r-l;let i=t.pow(f,r);const s=t.eql(i,t.ONE);o=t.mul(a,n),n=t.mul(n,n),i=t.mul(f,n),a=t.cmov(o,a,s),f=t.cmov(i,f,s)}return{isValid:p,value:a}};if(t.ORDER%d===p){const r=(t.ORDER-p)/d,n=t.sqrt(t.neg(e));v=(e,i)=>{let o=t.sqr(i);const a=t.mul(e,i);o=t.mul(o,a);let s=t.pow(o,r);s=t.mul(s,a);const u=t.mul(s,n),c=t.mul(t.sqr(s),i),f=t.eql(c,e);return{isValid:f,value:t.cmov(u,s,f)}}}return v}},3764:(t,e)=>{function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function n(t,...e){if(!function(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function i(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 o(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 a(t,e){n(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.anumber=r,e.number=r,e.abytes=n,e.bytes=n,e.ahash=i,e.aexists=o,e.aoutput=a;const s={number:r,bytes:n,hash:i,exists:o,output:a};e.default=s},5311:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(3764),i=r(1130);e.Chi=(t,e,r)=>t&e^~t&r,e.Maj=(t,e,r)=>t&e^t&r^e&r;class o 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.aexists)(this);const{view:e,buffer:r,blockLen:o}=this,a=(t=(0,i.toBytes)(t)).length;for(let n=0;n<a;){const s=Math.min(o-this.pos,a-n);if(s!==o)r.set(t.subarray(n,n+s),this.pos),this.pos+=s,n+=s,this.pos===o&&(this.process(e,0),this.pos=0);else{const e=(0,i.createView)(t);for(;o<=a-n;n+=o)this.process(e,n)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,n.aexists)(this),(0,n.aoutput)(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:o,isLE:a}=this;let{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let t=s;t<o;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+c,s,n)}(r,o-8,BigInt(8*this.length),a),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 f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<f;t++)u.setUint32(4*t,l[t],a)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}e.HashMD=o},5510:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},3788:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(3764),i=r(1130);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.ahash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,a=new Uint8Array(o);a.set(r.length>o?t.create().update(r).digest():r);for(let t=0;t<a.length;t++)a[t]^=54;this.iHash.update(a),this.oHash=t.create();for(let t=0;t<a.length;t++)a[t]^=106;this.oHash.update(a),a.fill(0)}update(t){return(0,n.aexists)(this),this.iHash.update(t),this}digestInto(t){(0,n.aexists)(this),(0,n.abytes)(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=o,e.hmac=(t,e,r)=>new o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},1696:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=e.SHA256=void 0;const n=r(5311),i=r(1130),o=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]),a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=new Uint32Array(64);class u extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3],this.E=0|a[4],this.F=0|a[5],this.G=0|a[6],this.H=0|a[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)s[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=s[t-15],r=s[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;s[t]=o+s[t-7]+n+s[t-16]|0}let{A:r,B:a,C:u,D:c,E:f,F:l,G:h,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,l,h)+o[t]+s[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,a,u)|0;p=h,h=l,l=f,f=c+e|0,c=u,u=a,a=r,r=e+d|0}r=r+this.A|0,a=a+this.B|0,u=u+this.C|0,c=c+this.D|0,f=f+this.E|0,l=l+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(r,a,u,c,f,l,h,p)}roundClean(){s.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}e.SHA256=u;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))},1130:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name},e.byteSwap32=function(t){for(let r=0;r<t.length;r++)t[r]=(0,e.byteSwap)(t[r])},e.bytesToHex=function(t){(0,i.abytes)(t);let e="";for(let r=0;r<t.length;r++)e+=o[t[r]];return e},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=s(t.charCodeAt(i)),o=s(t.charCodeAt(i+1));if(void 0===r||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+o}return n},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o<t;o++){n(o);const t=Date.now()-i;t>=0&&t<r||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=u,e.toBytes=c,e.concatBytes=function(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];(0,i.abytes)(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r},e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!=={}.toString.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(c(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(c(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(c(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));if(n.crypto&&"function"==typeof n.crypto.randomBytes)return n.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")};const n=r(5510),i=r(3764);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);const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0"))),a={_0:48,_9:57,A:65,F:70,a:97,f:102};function s(t){return t>=a._0&&t<=a._9?t-a._0:t>=a.A&&t<=a.F?t-(a.A-10):t>=a.a&&t<=a.f?t-(a.a-10):void 0}function u(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function c(t){return"string"==typeof t&&(t=u(t)),(0,i.abytes)(t),t}e.nextTick=async()=>{},e.Hash=class{clone(){return this._cloneInto()}}},8510:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.schnorr=e.secp256k1=void 0;const n=r(1696),i=r(1130),o=r(3562),a=r(1761),s=r(4967),u=r(1484),c=r(1705),f=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),l=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h=BigInt(1),p=BigInt(2),d=(t,e)=>(t+e/p)/e;function y(t){const e=f,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),a=BigInt(23),u=BigInt(44),c=BigInt(88),l=t*t*t%e,h=l*l*t%e,d=(0,s.pow2)(h,r,e)*h%e,y=(0,s.pow2)(d,r,e)*h%e,b=(0,s.pow2)(y,p,e)*l%e,v=(0,s.pow2)(b,i,e)*b%e,w=(0,s.pow2)(v,o,e)*v%e,m=(0,s.pow2)(w,u,e)*w%e,_=(0,s.pow2)(m,c,e)*m%e,E=(0,s.pow2)(_,u,e)*w%e,S=(0,s.pow2)(E,r,e)*h%e,k=(0,s.pow2)(S,a,e)*v%e,T=(0,s.pow2)(k,n,e)*l%e,O=(0,s.pow2)(T,p,e);if(!g.eql(g.sqr(O),t))throw new Error("Cannot find square root");return O}const g=(0,s.Field)(f,void 0,void 0,{sqrt:y});e.secp256k1=(0,o.createCurve)({a:BigInt(0),b:BigInt(7),Fp:g,n:l,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=l,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-h*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,a=BigInt("0x100000000000000000000000000000000"),u=d(o*t,e),c=d(-n*t,e);let f=(0,s.mod)(t-u*r-c*i,e),p=(0,s.mod)(-u*n-c*o,e);const y=f>a,g=p>a;if(y&&(f=e-f),g&&(p=e-p),f>a||p>a)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:y,k1:f,k2neg:g,k2:p}}}},n.sha256);const b=BigInt(0),v={};function w(t,...e){let r=v[t];if(void 0===r){const e=(0,n.sha256)(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=(0,u.concatBytes)(e,e),v[t]=r}return(0,n.sha256)((0,u.concatBytes)(r,...e))}const m=t=>t.toRawBytes(!0).slice(1),_=t=>(0,u.numberToBytesBE)(t,32),E=t=>(0,s.mod)(t,f),S=t=>(0,s.mod)(t,l),k=e.secp256k1.ProjectivePoint;function T(t){let r=e.secp256k1.utils.normPrivateKeyToScalar(t),n=k.fromPrivateKey(r);return{scalar:n.hasEvenY()?r:S(-r),bytes:m(n)}}function O(t){(0,u.aInRange)("x",t,h,f);const e=E(t*t);let r=y(E(e*t+BigInt(7)));r%p!==b&&(r=E(-r));const n=new k(t,r,h);return n.assertValidity(),n}const x=u.bytesToNumberBE;function A(...t){return S(x(w("BIP0340/challenge",...t)))}function P(t,e,r){const n=(0,u.ensureBytes)("signature",t,64),i=(0,u.ensureBytes)("message",e),o=(0,u.ensureBytes)("publicKey",r,32);try{const t=O(x(o)),e=x(n.subarray(0,32));if(!(0,u.inRange)(e,h,f))return!1;const r=x(n.subarray(32,64));if(!(0,u.inRange)(r,h,l))return!1;const a=A(_(e),m(t),i),s=((t,e,r)=>k.BASE.multiplyAndAddUnsafe(t,e,r))(t,r,S(-a));return!(!s||!s.hasEvenY()||s.toAffine().x!==e)}catch(t){return!1}}e.schnorr={getPublicKey:function(t){return T(t).bytes},sign:function(t,e,r=(0,i.randomBytes)(32)){const n=(0,u.ensureBytes)("message",t),{bytes:o,scalar:a}=T(e),s=(0,u.ensureBytes)("auxRand",r,32),c=_(a^x(w("BIP0340/aux",s))),f=w("BIP0340/nonce",c,o,n),l=S(x(f));if(l===b)throw new Error("sign failed: k is zero");const{bytes:h,scalar:p}=T(l),d=A(h,o,n),y=new Uint8Array(64);if(y.set(h,0),y.set(_(S(p+d*a)),32),!P(y,n,o))throw new Error("sign: Invalid signature produced");return y},verify:P,utils:{randomPrivateKey:e.secp256k1.utils.randomPrivateKey,lift_x:O,pointToBytes:m,numberToBytesBE:u.numberToBytesBE,bytesToNumberBE:u.bytesToNumberBE,taggedHash:w,mod:s.mod}};const I=(()=>(0,a.isogenyMap)(g,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((t=>t.map((t=>BigInt(t)))))))(),L=(()=>(0,c.mapToCurveSimpleSWU)(g,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:g.create(BigInt("-11"))}))(),B=(()=>(0,a.createHasher)(e.secp256k1.ProjectivePoint,(t=>{const{x:e,y:r}=L(g.create(t[0]));return I(e,r)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:g.ORDER,m:1,k:128,expand:"xmd",hash:n.sha256}))();e.hashToCurve=B.hashToCurve,e.encodeToCurve=B.encodeToCurve},4148:(t,e,r)=>{var n=r(5606);function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,o=function(t){if("object"!==i(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key),"symbol"===i(o)?o:String(o)),n)}var o}function a(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}var s,u,c=r(9597).codes,f=c.ERR_AMBIGUOUS_ARGUMENT,l=c.ERR_INVALID_ARG_TYPE,h=c.ERR_INVALID_ARG_VALUE,p=c.ERR_INVALID_RETURN_VALUE,d=c.ERR_MISSING_ARGS,y=r(3918),g=r(537).inspect,b=r(537).types,v=b.isPromise,w=b.isRegExp,m=r(9133)(),_=r(9394)(),E=r(8075)("RegExp.prototype.test");function S(){var t=r(2299);s=t.isDeepEqual,u=t.isDeepStrictEqual}new Map;var k=!1,T=t.exports=P,O={};function x(t){if(t.message instanceof Error)throw t.message;throw new y(t)}function A(t,e,r,n){if(!r){var i=!1;if(0===e)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new y({actual:r,expected:!0,message:n,operator:"==",stackStartFn:t});throw o.generatedMessage=i,o}}function P(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];A.apply(void 0,[P,e.length].concat(e))}T.fail=function t(e,r,i,o,a){var s,u=arguments.length;if(0===u?s="Failed":1===u?(i=e,e=void 0):(!1===k&&(k=!0,(n.emitWarning?n.emitWarning:console.warn.bind(console))("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")),2===u&&(o="!=")),i instanceof Error)throw i;var c={actual:e,expected:r,operator:void 0===o?"fail":o,stackStartFn:a||t};void 0!==i&&(c.message=i);var f=new y(c);throw s&&(f.message=s,f.generatedMessage=!0),f},T.AssertionError=y,T.ok=P,T.equal=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");e!=r&&x({actual:e,expected:r,message:n,operator:"==",stackStartFn:t})},T.notEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");e==r&&x({actual:e,expected:r,message:n,operator:"!=",stackStartFn:t})},T.deepEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===s&&S(),s(e,r)||x({actual:e,expected:r,message:n,operator:"deepEqual",stackStartFn:t})},T.notDeepEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===s&&S(),s(e,r)&&x({actual:e,expected:r,message:n,operator:"notDeepEqual",stackStartFn:t})},T.deepStrictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===s&&S(),u(e,r)||x({actual:e,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:t})},T.notDeepStrictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===s&&S(),u(e,r)&&x({actual:e,expected:r,message:n,operator:"notDeepStrictEqual",stackStartFn:t})},T.strictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");_(e,r)||x({actual:e,expected:r,message:n,operator:"strictEqual",stackStartFn:t})},T.notStrictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");_(e,r)&&x({actual:e,expected:r,message:n,operator:"notStrictEqual",stackStartFn:t})};var I=a((function t(e,r,n){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r.forEach((function(t){t in e&&(void 0!==n&&"string"==typeof n[t]&&w(e[t])&&E(e[t],n[t])?i[t]=n[t]:i[t]=e[t])}))}));function L(t,e,r,n){if("function"!=typeof e){if(w(e))return E(e,t);if(2===arguments.length)throw new l("expected",["Function","RegExp"],e);if("object"!==i(t)||null===t){var o=new y({actual:t,expected:e,message:r,operator:"deepStrictEqual",stackStartFn:n});throw o.operator=n.name,o}var a=Object.keys(e);if(e instanceof Error)a.push("name","message");else if(0===a.length)throw new h("error",e,"may not be an empty object");return void 0===s&&S(),a.forEach((function(i){"string"==typeof t[i]&&w(e[i])&&E(e[i],t[i])||function(t,e,r,n,i,o){if(!(r in t)||!u(t[r],e[r])){if(!n){var a=new I(t,i),s=new I(e,i,t),c=new y({actual:a,expected:s,operator:"deepStrictEqual",stackStartFn:o});throw c.actual=t,c.expected=e,c.operator=o.name,c}x({actual:t,expected:e,message:n,operator:o.name,stackStartFn:o})}}(t,e,i,r,a,n)})),!0}return void 0!==e.prototype&&t instanceof e||!Error.isPrototypeOf(e)&&!0===e.call({},t)}function B(t){if("function"!=typeof t)throw new l("fn","Function",t);try{t()}catch(t){return t}return O}function R(t){return v(t)||null!==t&&"object"===i(t)&&"function"==typeof t.then&&"function"==typeof t.catch}function N(t){return Promise.resolve().then((function(){var e;if("function"==typeof t){if(!R(e=t()))throw new p("instance of Promise","promiseFn",e)}else{if(!R(t))throw new l("promiseFn",["Function","Promise"],t);e=t}return Promise.resolve().then((function(){return e})).then((function(){return O})).catch((function(t){return t}))}))}function j(t,e,r,n){if("string"==typeof r){if(4===arguments.length)throw new l("error",["Object","Error","Function","RegExp"],r);if("object"===i(e)&&null!==e){if(e.message===r)throw new f("error/message",'The error message "'.concat(e.message,'" is identical to the message.'))}else if(e===r)throw new f("error/message",'The error "'.concat(e,'" is identical to the message.'));n=r,r=void 0}else if(null!=r&&"object"!==i(r)&&"function"!=typeof r)throw new l("error",["Object","Error","Function","RegExp"],r);if(e===O){var o="";r&&r.name&&(o+=" (".concat(r.name,")")),o+=n?": ".concat(n):".";var a="rejects"===t.name?"rejection":"exception";x({actual:void 0,expected:r,operator:t.name,message:"Missing expected ".concat(a).concat(o),stackStartFn:t})}if(r&&!L(e,r,n,t))throw e}function U(t,e,r,n){if(e!==O){if("string"==typeof r&&(n=r,r=void 0),!r||L(e,r)){var i=n?": ".concat(n):".",o="doesNotReject"===t.name?"rejection":"exception";x({actual:e,expected:r,operator:t.name,message:"Got unwanted ".concat(o).concat(i,"\n")+'Actual message: "'.concat(e&&e.message,'"'),stackStartFn:t})}throw e}}function C(t,e,r,n,o){if(!w(e))throw new l("regexp","RegExp",e);var a="match"===o;if("string"!=typeof t||E(e,t)!==a){if(r instanceof Error)throw r;var s=!r;r=r||("string"!=typeof t?'The "string" argument must be of type string. Received type '+"".concat(i(t)," (").concat(g(t),")"):(a?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(g(e),". Input:\n\n").concat(g(t),"\n"));var u=new y({actual:t,expected:e,message:r,operator:o,stackStartFn:n});throw u.generatedMessage=s,u}}function F(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];A.apply(void 0,[F,e.length].concat(e))}T.throws=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];j.apply(void 0,[t,B(e)].concat(n))},T.rejects=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return N(e).then((function(e){return j.apply(void 0,[t,e].concat(n))}))},T.doesNotThrow=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];U.apply(void 0,[t,B(e)].concat(n))},T.doesNotReject=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return N(e).then((function(e){return U.apply(void 0,[t,e].concat(n))}))},T.ifError=function t(e){if(null!=e){var r="ifError got unwanted exception: ";"object"===i(e)&&"string"==typeof e.message?0===e.message.length&&e.constructor?r+=e.constructor.name:r+=e.message:r+=g(e);var n=new y({actual:e,expected:null,operator:"ifError",message:r,stackStartFn:t}),o=e.stack;if("string"==typeof o){var a=o.split("\n");a.shift();for(var s=n.stack.split("\n"),u=0;u<a.length;u++){var c=s.indexOf(a[u]);if(-1!==c){s=s.slice(0,c);break}}n.stack="".concat(s.join("\n"),"\n").concat(a.join("\n"))}throw n}},T.match=function t(e,r,n){C(e,r,n,t,"match")},T.doesNotMatch=function t(e,r,n){C(e,r,n,t,"doesNotMatch")},T.strict=m(F,T,{equal:T.strictEqual,deepEqual:T.deepStrictEqual,notEqual:T.notStrictEqual,notDeepEqual:T.notDeepStrictEqual}),T.strict.strict=T.strict},3918:(t,e,r)=>{var n=r(5606);function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function o(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){var n,i,o;n=t,i=e,o=r[e],(i=s(i))in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var e=function(t){if("object"!==y(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===y(e)?e:String(e)}function u(t,e){if(e&&("object"===y(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return c(t)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t){var e="function"==typeof Map?new Map:void 0;return f=function(t){if(null===t||!function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return l(t,arguments,d(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),p(r,t)},f(t)}function l(t,e,r){return l=h()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&p(i,r.prototype),i},l.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function y(t){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(t)}var g=r(537).inspect,b=r(9597).codes.ERR_INVALID_ARG_TYPE;function v(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}var w="",m="",_="",E="",S={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"};function k(t){var e=Object.keys(t),r=Object.create(Object.getPrototypeOf(t));return e.forEach((function(e){r[e]=t[e]})),Object.defineProperty(r,"message",{value:t.message}),r}function T(t){return g(t,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}var O=function(t,e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&p(t,e)}(O,t);var r,i,s,f,l=(r=O,i=h(),function(){var t,e=d(r);if(i){var n=d(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return u(this,t)});function O(t){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,O),"object"!==y(t)||null===t)throw new b("options","Object",t);var r=t.message,i=t.operator,o=t.stackStartFn,a=t.actual,s=t.expected,f=Error.stackTraceLimit;if(Error.stackTraceLimit=0,null!=r)e=l.call(this,String(r));else if(n.stderr&&n.stderr.isTTY&&(n.stderr&&n.stderr.getColorDepth&&1!==n.stderr.getColorDepth()?(w="",m="",E="",_=""):(w="",m="",E="",_="")),"object"===y(a)&&null!==a&&"object"===y(s)&&null!==s&&"stack"in a&&a instanceof Error&&"stack"in s&&s instanceof Error&&(a=k(a),s=k(s)),"deepStrictEqual"===i||"strictEqual"===i)e=l.call(this,function(t,e,r){var i="",o="",a=0,s="",u=!1,c=T(t),f=c.split("\n"),l=T(e).split("\n"),h=0,p="";if("strictEqual"===r&&"object"===y(t)&&"object"===y(e)&&null!==t&&null!==e&&(r="strictEqualObject"),1===f.length&&1===l.length&&f[0]!==l[0]){var d=f[0].length+l[0].length;if(d<=10){if(!("object"===y(t)&&null!==t||"object"===y(e)&&null!==e||0===t&&0===e))return"".concat(S[r],"\n\n")+"".concat(f[0]," !== ").concat(l[0],"\n")}else if("strictEqualObject"!==r&&d<(n.stderr&&n.stderr.isTTY?n.stderr.columns:80)){for(;f[0][h]===l[0][h];)h++;h>2&&(p="\n ".concat(function(t,e){if(e=Math.floor(e),0==t.length||0==e)return"";var r=t.length*e;for(e=Math.floor(Math.log(e)/Math.log(2));e;)t+=t,e--;return t+t.substring(0,r-t.length)}(" ",h),"^"),h=0)}}for(var g=f[f.length-1],b=l[l.length-1];g===b&&(h++<2?s="\n ".concat(g).concat(s):i=g,f.pop(),l.pop(),0!==f.length&&0!==l.length);)g=f[f.length-1],b=l[l.length-1];var k=Math.max(f.length,l.length);if(0===k){var O=c.split("\n");if(O.length>30)for(O[26]="".concat(w,"...").concat(E);O.length>27;)O.pop();return"".concat(S.notIdentical,"\n\n").concat(O.join("\n"),"\n")}h>3&&(s="\n".concat(w,"...").concat(E).concat(s),u=!0),""!==i&&(s="\n ".concat(i).concat(s),i="");var x=0,A=S[r]+"\n".concat(m,"+ actual").concat(E," ").concat(_,"- expected").concat(E),P=" ".concat(w,"...").concat(E," Lines skipped");for(h=0;h<k;h++){var I=h-a;if(f.length<h+1)I>1&&h>2&&(I>4?(o+="\n".concat(w,"...").concat(E),u=!0):I>3&&(o+="\n ".concat(l[h-2]),x++),o+="\n ".concat(l[h-1]),x++),a=h,i+="\n".concat(_,"-").concat(E," ").concat(l[h]),x++;else if(l.length<h+1)I>1&&h>2&&(I>4?(o+="\n".concat(w,"...").concat(E),u=!0):I>3&&(o+="\n ".concat(f[h-2]),x++),o+="\n ".concat(f[h-1]),x++),a=h,o+="\n".concat(m,"+").concat(E," ").concat(f[h]),x++;else{var L=l[h],B=f[h],R=B!==L&&(!v(B,",")||B.slice(0,-1)!==L);R&&v(L,",")&&L.slice(0,-1)===B&&(R=!1,B+=","),R?(I>1&&h>2&&(I>4?(o+="\n".concat(w,"...").concat(E),u=!0):I>3&&(o+="\n ".concat(f[h-2]),x++),o+="\n ".concat(f[h-1]),x++),a=h,o+="\n".concat(m,"+").concat(E," ").concat(B),i+="\n".concat(_,"-").concat(E," ").concat(L),x+=2):(o+=i,i="",1!==I&&0!==h||(o+="\n ".concat(B),x++))}if(x>20&&h<k-2)return"".concat(A).concat(P,"\n").concat(o,"\n").concat(w,"...").concat(E).concat(i,"\n")+"".concat(w,"...").concat(E)}return"".concat(A).concat(u?P:"","\n").concat(o).concat(i).concat(s).concat(p)}(a,s,i));else if("notDeepStrictEqual"===i||"notStrictEqual"===i){var h=S[i],p=T(a).split("\n");if("notStrictEqual"===i&&"object"===y(a)&&null!==a&&(h=S.notStrictEqualObject),p.length>30)for(p[26]="".concat(w,"...").concat(E);p.length>27;)p.pop();e=1===p.length?l.call(this,"".concat(h," ").concat(p[0])):l.call(this,"".concat(h,"\n\n").concat(p.join("\n"),"\n"))}else{var d=T(a),g="",x=S[i];"notDeepEqual"===i||"notEqual"===i?(d="".concat(S[i],"\n\n").concat(d)).length>1024&&(d="".concat(d.slice(0,1021),"...")):(g="".concat(T(s)),d.length>512&&(d="".concat(d.slice(0,509),"...")),g.length>512&&(g="".concat(g.slice(0,509),"...")),"deepEqual"===i||"equal"===i?d="".concat(x,"\n\n").concat(d,"\n\nshould equal\n\n"):g=" ".concat(i," ").concat(g)),e=l.call(this,"".concat(d).concat(g))}return Error.stackTraceLimit=f,e.generatedMessage=!r,Object.defineProperty(c(e),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),e.code="ERR_ASSERTION",e.actual=a,e.expected=s,e.operator=i,Error.captureStackTrace&&Error.captureStackTrace(c(e),o),e.stack,e.name="AssertionError",u(e)}return s=O,(f=[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:e,value:function(t,e){return g(this,o(o({},e),{},{customInspect:!1,depth:0}))}}])&&a(s.prototype,f),Object.defineProperty(s,"prototype",{writable:!1}),O}(f(Error),g.custom);t.exports=O},9597:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}var a,s,u={};function c(t,e,r){r||(r=Error);var a=function(r){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(f,r);var a,s,u,c=(s=f,u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=o(s);if(u){var r=o(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function f(r,n,i){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,f),o=c.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i)),o.code=t,o}return a=f,Object.defineProperty(a,"prototype",{writable:!1}),a}(r);u[t]=a}function f(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}c("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),c("ERR_INVALID_ARG_TYPE",(function(t,e,i){var o,s,u;if(void 0===a&&(a=r(4148)),a("string"==typeof t,"'name' must be a string"),"string"==typeof e&&(u="not ",e.substr(0,4)===u)?(o="must not be",e=e.replace(/^not /,"")):o="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))s="The ".concat(t," ").concat(o," ").concat(f(e,"type"));else{var c=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+1>t.length)&&-1!==t.indexOf(".",r)}(t)?"property":"argument";s='The "'.concat(t,'" ').concat(c," ").concat(o," ").concat(f(e,"type"))}return s+". Received type ".concat(n(i))}),TypeError),c("ERR_INVALID_ARG_VALUE",(function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"is invalid";void 0===s&&(s=r(537));var i=s.inspect(e);return i.length>128&&(i="".concat(i.slice(0,128),"...")),"The argument '".concat(t,"' ").concat(n,". Received ").concat(i)}),TypeError,RangeError),c("ERR_INVALID_RETURN_VALUE",(function(t,e,r){var i;return i=r&&r.constructor&&r.constructor.name?"instance of ".concat(r.constructor.name):"type ".concat(n(r)),"Expected ".concat(t,' to be returned from the "').concat(e,'"')+" function but got ".concat(i,".")}),TypeError),c("ERR_MISSING_ARGS",(function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];void 0===a&&(a=r(4148)),a(e.length>0,"At least one arg needs to be specified");var i="The ",o=e.length;switch(e=e.map((function(t){return'"'.concat(t,'"')})),o){case 1:i+="".concat(e[0]," argument");break;case 2:i+="".concat(e[0]," and ").concat(e[1]," arguments");break;default:i+=e.slice(0,o-1).join(", "),i+=", and ".concat(e[o-1]," arguments")}return"".concat(i," must be specified")}),TypeError),t.exports.codes=u},2299:(t,e,r)=>{function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,c=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var a=void 0!==/a/g.flags,s=function(t){var e=[];return t.forEach((function(t){return e.push(t)})),e},u=function(t){var e=[];return t.forEach((function(t,r){return e.push([r,t])})),e},c=Object.is?Object.is:r(7653),f=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},l=Number.isNaN?Number.isNaN:r(4133);function h(t){return t.call.bind(t)}var p=h(Object.prototype.hasOwnProperty),d=h(Object.prototype.propertyIsEnumerable),y=h(Object.prototype.toString),g=r(537).types,b=g.isAnyArrayBuffer,v=g.isArrayBufferView,w=g.isDate,m=g.isMap,_=g.isRegExp,E=g.isSet,S=g.isNativeError,k=g.isBoxedPrimitive,T=g.isNumberObject,O=g.isStringObject,x=g.isBooleanObject,A=g.isBigIntObject,P=g.isSymbolObject,I=g.isFloat32Array,L=g.isFloat64Array;function B(t){if(0===t.length||t.length>10)return!0;for(var e=0;e<t.length;e++){var r=t.charCodeAt(e);if(r<48||r>57)return!0}return 10===t.length&&t>=Math.pow(2,32)}function R(t){return Object.keys(t).filter(B).concat(f(t).filter(Object.prototype.propertyIsEnumerable.bind(t)))}function N(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0}function j(t,e,r,n){if(t===e)return 0!==t||!r||c(t,e);if(r){if("object"!==o(t))return"number"==typeof t&&l(t)&&l(e);if("object"!==o(e)||null===t||null===e)return!1;if(Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1}else{if(null===t||"object"!==o(t))return(null===e||"object"!==o(e))&&t==e;if(null===e||"object"!==o(e))return!1}var i,s,u=y(t);if(u!==y(e))return!1;if(Array.isArray(t)){if(t.length!==e.length)return!1;var f=R(t),h=R(e);return f.length===h.length&&C(t,e,r,n,1,f)}if("[object Object]"===u&&(!m(t)&&m(e)||!E(t)&&E(e)))return!1;if(w(t)){if(!w(e)||Date.prototype.getTime.call(t)!==Date.prototype.getTime.call(e))return!1}else if(_(t)){if(!_(e)||!function(t,e){return a?t.source===e.source&&t.flags===e.flags:RegExp.prototype.toString.call(t)===RegExp.prototype.toString.call(e)}(t,e))return!1}else if(S(t)||t instanceof Error){if(t.message!==e.message||t.name!==e.name)return!1}else{if(v(t)){if(r||!I(t)&&!L(t)){if(!function(t,e){return t.byteLength===e.byteLength&&0===N(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}(t,e))return!1}else if(!function(t,e){if(t.byteLength!==e.byteLength)return!1;for(var r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}(t,e))return!1;var p=R(t),d=R(e);return p.length===d.length&&C(t,e,r,n,0,p)}if(E(t))return!(!E(e)||t.size!==e.size)&&C(t,e,r,n,2);if(m(t))return!(!m(e)||t.size!==e.size)&&C(t,e,r,n,3);if(b(t)){if(s=e,(i=t).byteLength!==s.byteLength||0!==N(new Uint8Array(i),new Uint8Array(s)))return!1}else if(k(t)&&!function(t,e){return T(t)?T(e)&&c(Number.prototype.valueOf.call(t),Number.prototype.valueOf.call(e)):O(t)?O(e)&&String.prototype.valueOf.call(t)===String.prototype.valueOf.call(e):x(t)?x(e)&&Boolean.prototype.valueOf.call(t)===Boolean.prototype.valueOf.call(e):A(t)?A(e)&&BigInt.prototype.valueOf.call(t)===BigInt.prototype.valueOf.call(e):P(e)&&Symbol.prototype.valueOf.call(t)===Symbol.prototype.valueOf.call(e)}(t,e))return!1}return C(t,e,r,n,0)}function U(t,e){return e.filter((function(e){return d(t,e)}))}function C(t,e,r,i,a,c){if(5===arguments.length){c=Object.keys(t);var l=Object.keys(e);if(c.length!==l.length)return!1}for(var h=0;h<c.length;h++)if(!p(e,c[h]))return!1;if(r&&5===arguments.length){var y=f(t);if(0!==y.length){var g=0;for(h=0;h<y.length;h++){var b=y[h];if(d(t,b)){if(!d(e,b))return!1;c.push(b),g++}else if(d(e,b))return!1}var v=f(e);if(y.length!==v.length&&U(e,v).length!==g)return!1}else{var w=f(e);if(0!==w.length&&0!==U(e,w).length)return!1}}if(0===c.length&&(0===a||1===a&&0===t.length||0===t.size))return!0;if(void 0===i)i={val1:new Map,val2:new Map,position:0};else{var m=i.val1.get(t);if(void 0!==m){var _=i.val2.get(e);if(void 0!==_)return m===_}i.position++}i.val1.set(t,i.position),i.val2.set(e,i.position);var E=function(t,e,r,i,a,c){var f=0;if(2===c){if(!function(t,e,r,n){for(var i=null,a=s(t),u=0;u<a.length;u++){var c=a[u];if("object"===o(c)&&null!==c)null===i&&(i=new Set),i.add(c);else if(!e.has(c)){if(r)return!1;if(!D(t,e,c))return!1;null===i&&(i=new Set),i.add(c)}}if(null!==i){for(var f=s(e),l=0;l<f.length;l++){var h=f[l];if("object"===o(h)&&null!==h){if(!F(i,h,r,n))return!1}else if(!r&&!t.has(h)&&!F(i,h,r,n))return!1}return 0===i.size}return!0}(t,e,r,a))return!1}else if(3===c){if(!function(t,e,r,i){for(var a=null,s=u(t),c=0;c<s.length;c++){var f=n(s[c],2),l=f[0],h=f[1];if("object"===o(l)&&null!==l)null===a&&(a=new Set),a.add(l);else{var p=e.get(l);if(void 0===p&&!e.has(l)||!j(h,p,r,i)){if(r)return!1;if(!H(t,e,l,h,i))return!1;null===a&&(a=new Set),a.add(l)}}}if(null!==a){for(var d=u(e),y=0;y<d.length;y++){var g=n(d[y],2),b=g[0],v=g[1];if("object"===o(b)&&null!==b){if(!K(a,t,b,v,r,i))return!1}else if(!(r||t.has(b)&&j(t.get(b),v,!1,i)||K(a,t,b,v,!1,i)))return!1}return 0===a.size}return!0}(t,e,r,a))return!1}else if(1===c)for(;f<t.length;f++){if(!p(t,f)){if(p(e,f))return!1;for(var l=Object.keys(t);f<l.length;f++){var h=l[f];if(!p(e,h)||!j(t[h],e[h],r,a))return!1}return l.length===Object.keys(e).length}if(!p(e,f)||!j(t[f],e[f],r,a))return!1}for(f=0;f<i.length;f++){var d=i[f];if(!j(t[d],e[d],r,a))return!1}return!0}(t,e,r,c,i,a);return i.val1.delete(t),i.val2.delete(e),E}function F(t,e,r,n){for(var i=s(t),o=0;o<i.length;o++){var a=i[o];if(j(e,a,r,n))return t.delete(a),!0}return!1}function M(t){switch(o(t)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":t=+t;case"number":if(l(t))return!1}return!0}function D(t,e,r){var n=M(r);return null!=n?n:e.has(n)&&!t.has(n)}function H(t,e,r,n,i){var o=M(r);if(null!=o)return o;var a=e.get(o);return!(void 0===a&&!e.has(o)||!j(n,a,!1,i))&&!t.has(o)&&j(n,a,!1,i)}function K(t,e,r,n,i,o){for(var a=s(t),u=0;u<a.length;u++){var c=a[u];if(j(r,c,i,o)&&j(n,e.get(c),i,o))return t.delete(c),!0}return!1}t.exports={isDeepEqual:function(t,e){return j(t,e,!1)},isDeepStrictEqual:function(t,e){return j(t,e,!0)}}},7526:(t,e)=>{e.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=s(t),a=o[0],u=o[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,u)),f=0,l=u>0?a-4:a;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],c[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[f++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,c=n-i;s<c;s+=a)o.push(u(t,s,s+a>c?c:s+a));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var i,o,a=[],s=e;s<n;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},2343:(t,e)=>{e.p2=e.I=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(1&e)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=i(e)^n>>5}e=i(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=i(e)^31&n}return e}function a(t,e,r,n){let i=0,o=0;const a=(1<<r)-1,s=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],o+=e;o>=r;)o-=r,s.push(i>>o&a);if(n)o>0&&s.push(i<<r-o&a);else{if(o>=e)return"Excess padding";if(i<<r-o&a)return"Non-zero padding"}return s}function s(t){return a(t,8,5,!0)}function u(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e}function c(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function f(t){let e;function a(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const a=t.toLowerCase(),s=t.toUpperCase();if(t!==a&&t!==s)return"Mixed-case string "+t;const u=(t=a).lastIndexOf("1");if(-1===u)return"No separator character for "+t;if(0===u)return"Missing prefix for "+t;const c=t.slice(0,u),f=t.slice(u+1);if(f.length<6)return"Data too short";let l=o(c);if("string"==typeof l)return l;const h=[];for(let t=0;t<f.length;++t){const e=f.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;l=i(l)^r,t+6>=f.length||h.push(r)}return l!==e?"Invalid checksum for "+t:{prefix:c,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=a(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=a(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,a){if(a=a||90,t.length+7+n.length>a)throw new TypeError("Exceeds length limit");let s=o(t=t.toLowerCase());if("string"==typeof s)throw new Error(s);let u=t+"1";for(let t=0;t<n.length;++t){const e=n[t];if(e>>5)throw new Error("Non 5-bit word");s=i(s)^e,u+=r.charAt(e)}for(let t=0;t<6;++t)s=i(s);s^=e;for(let t=0;t<6;++t)u+=r.charAt(s>>5*(5-t)&31);return u},toWords:s,fromWordsUnsafe:u,fromWords:c}}e.I=f("bech32"),e.p2=f("bech32m")},5974:(t,e,r)=>{var n=r(8287).Buffer,i=r(5606),o=r(4148),a=r(4442),s=r(8411),u=r(1447),c=r(9681);for(var f in c)e[f]=c[f];function l(t){if("number"!=typeof t||t<e.DEFLATE||t>e.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=t,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}e.NONE=0,e.DEFLATE=1,e.INFLATE=2,e.GZIP=3,e.GUNZIP=4,e.DEFLATERAW=5,e.INFLATERAW=6,e.UNZIP=7,l.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,o(this.init_done,"close before init"),o(this.mode<=e.UNZIP),this.mode===e.DEFLATE||this.mode===e.GZIP||this.mode===e.DEFLATERAW?s.deflateEnd(this.strm):this.mode!==e.INFLATE&&this.mode!==e.GUNZIP&&this.mode!==e.INFLATERAW&&this.mode!==e.UNZIP||u.inflateEnd(this.strm),this.mode=e.NONE,this.dictionary=null)},l.prototype.write=function(t,e,r,n,i,o,a){return this._write(!0,t,e,r,n,i,o,a)},l.prototype.writeSync=function(t,e,r,n,i,o,a){return this._write(!1,t,e,r,n,i,o,a)},l.prototype._write=function(t,r,a,s,u,c,f,l){if(o.equal(arguments.length,8),o(this.init_done,"write before init"),o(this.mode!==e.NONE,"already finalized"),o.equal(!1,this.write_in_progress,"write already in progress"),o.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,o.equal(!1,void 0===r,"must provide flush value"),this.write_in_progress=!0,r!==e.Z_NO_FLUSH&&r!==e.Z_PARTIAL_FLUSH&&r!==e.Z_SYNC_FLUSH&&r!==e.Z_FULL_FLUSH&&r!==e.Z_FINISH&&r!==e.Z_BLOCK)throw new Error("Invalid flush value");if(null==a&&(a=n.alloc(0),u=0,s=0),this.strm.avail_in=u,this.strm.input=a,this.strm.next_in=s,this.strm.avail_out=l,this.strm.output=c,this.strm.next_out=f,this.flush=r,!t)return this._process(),this._checkError()?this._afterSync():void 0;var h=this;return i.nextTick((function(){h._process(),h._after()})),this},l.prototype._afterSync=function(){var t=this.strm.avail_out,e=this.strm.avail_in;return this.write_in_progress=!1,[e,t]},l.prototype._process=function(){var t=null;switch(this.mode){case e.DEFLATE:case e.GZIP:case e.DEFLATERAW:this.err=s.deflate(this.strm,this.flush);break;case e.UNZIP:switch(this.strm.avail_in>0&&(t=this.strm.next_in),this.gzip_id_bytes_read){case 0:if(null===t)break;if(31!==this.strm.input[t]){this.mode=e.INFLATE;break}if(this.gzip_id_bytes_read=1,t++,1===this.strm.avail_in)break;case 1:if(null===t)break;139===this.strm.input[t]?(this.gzip_id_bytes_read=2,this.mode=e.GUNZIP):this.mode=e.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case e.INFLATE:case e.GUNZIP:case e.INFLATERAW:for(this.err=u.inflate(this.strm,this.flush),this.err===e.Z_NEED_DICT&&this.dictionary&&(this.err=u.inflateSetDictionary(this.strm,this.dictionary),this.err===e.Z_OK?this.err=u.inflate(this.strm,this.flush):this.err===e.Z_DATA_ERROR&&(this.err=e.Z_NEED_DICT));this.strm.avail_in>0&&this.mode===e.GUNZIP&&this.err===e.Z_STREAM_END&&0!==this.strm.next_in[0];)this.reset(),this.err=u.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},l.prototype._checkError=function(){switch(this.err){case e.Z_OK:case e.Z_BUF_ERROR:if(0!==this.strm.avail_out&&this.flush===e.Z_FINISH)return this._error("unexpected end of file"),!1;break;case e.Z_STREAM_END:break;case e.Z_NEED_DICT:return null==this.dictionary?this._error("Missing dictionary"):this._error("Bad dictionary"),!1;default:return this._error("Zlib error"),!1}return!0},l.prototype._after=function(){if(this._checkError()){var t=this.strm.avail_out,e=this.strm.avail_in;this.write_in_progress=!1,this.callback(e,t),this.pending_close&&this.close()}},l.prototype._error=function(t){this.strm.msg&&(t=this.strm.msg),this.onerror(t,this.err),this.write_in_progress=!1,this.pending_close&&this.close()},l.prototype.init=function(t,r,n,i,a){o(4===arguments.length||5===arguments.length,"init(windowBits, level, memLevel, strategy, [dictionary])"),o(t>=8&&t<=15,"invalid windowBits"),o(r>=-1&&r<=9,"invalid compression level"),o(n>=1&&n<=9,"invalid memlevel"),o(i===e.Z_FILTERED||i===e.Z_HUFFMAN_ONLY||i===e.Z_RLE||i===e.Z_FIXED||i===e.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(r,t,n,i,a),this._setDictionary()},l.prototype.params=function(){throw new Error("deflateParams Not supported")},l.prototype.reset=function(){this._reset(),this._setDictionary()},l.prototype._init=function(t,r,n,i,o){switch(this.level=t,this.windowBits=r,this.memLevel=n,this.strategy=i,this.flush=e.Z_NO_FLUSH,this.err=e.Z_OK,this.mode!==e.GZIP&&this.mode!==e.GUNZIP||(this.windowBits+=16),this.mode===e.UNZIP&&(this.windowBits+=32),this.mode!==e.DEFLATERAW&&this.mode!==e.INFLATERAW||(this.windowBits=-1*this.windowBits),this.strm=new a,this.mode){case e.DEFLATE:case e.GZIP:case e.DEFLATERAW:this.err=s.deflateInit2(this.strm,this.level,e.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case e.INFLATE:case e.GUNZIP:case e.INFLATERAW:case e.UNZIP:this.err=u.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}this.err!==e.Z_OK&&this._error("Init error"),this.dictionary=o,this.write_in_progress=!1,this.init_done=!0},l.prototype._setDictionary=function(){if(null!=this.dictionary){switch(this.err=e.Z_OK,this.mode){case e.DEFLATE:case e.DEFLATERAW:this.err=s.deflateSetDictionary(this.strm,this.dictionary)}this.err!==e.Z_OK&&this._error("Failed to set dictionary")}},l.prototype._reset=function(){switch(this.err=e.Z_OK,this.mode){case e.DEFLATE:case e.DEFLATERAW:case e.GZIP:this.err=s.deflateReset(this.strm);break;case e.INFLATE:case e.INFLATERAW:case e.GUNZIP:this.err=u.inflateReset(this.strm)}this.err!==e.Z_OK&&this._error("Failed to reset stream")},e.Zlib=l},8559:(t,e,r)=>{var n=r(5606),i=r(8287).Buffer,o=r(8310).Transform,a=r(5974),s=r(537),u=r(4148).ok,c=r(8287).kMaxLength,f="Cannot create final Buffer. It would be larger than 0x"+c.toString(16)+" bytes";a.Z_MIN_WINDOWBITS=8,a.Z_MAX_WINDOWBITS=15,a.Z_DEFAULT_WINDOWBITS=15,a.Z_MIN_CHUNK=64,a.Z_MAX_CHUNK=1/0,a.Z_DEFAULT_CHUNK=16384,a.Z_MIN_MEMLEVEL=1,a.Z_MAX_MEMLEVEL=9,a.Z_DEFAULT_MEMLEVEL=8,a.Z_MIN_LEVEL=-1,a.Z_MAX_LEVEL=9,a.Z_DEFAULT_LEVEL=a.Z_DEFAULT_COMPRESSION;for(var l=Object.keys(a),h=0;h<l.length;h++){var p=l[h];p.match(/^Z/)&&Object.defineProperty(e,p,{enumerable:!0,value:a[p],writable:!1})}for(var d={Z_OK:a.Z_OK,Z_STREAM_END:a.Z_STREAM_END,Z_NEED_DICT:a.Z_NEED_DICT,Z_ERRNO:a.Z_ERRNO,Z_STREAM_ERROR:a.Z_STREAM_ERROR,Z_DATA_ERROR:a.Z_DATA_ERROR,Z_MEM_ERROR:a.Z_MEM_ERROR,Z_BUF_ERROR:a.Z_BUF_ERROR,Z_VERSION_ERROR:a.Z_VERSION_ERROR},y=Object.keys(d),g=0;g<y.length;g++){var b=y[g];d[d[b]]=b}function v(t,e,r){var n=[],o=0;function a(){for(var e;null!==(e=t.read());)n.push(e),o+=e.length;t.once("readable",a)}function s(){var e,a=null;o>=c?a=new RangeError(f):e=i.concat(n,o),n=[],t.close(),r(a,e)}t.on("error",(function(e){t.removeListener("end",s),t.removeListener("readable",a),r(e)})),t.on("end",s),t.end(e),a()}function w(t,e){if("string"==typeof e&&(e=i.from(e)),!i.isBuffer(e))throw new TypeError("Not a string or buffer");var r=t._finishFlushFlag;return t._processChunk(e,r)}function m(t){if(!(this instanceof m))return new m(t);A.call(this,t,a.DEFLATE)}function _(t){if(!(this instanceof _))return new _(t);A.call(this,t,a.INFLATE)}function E(t){if(!(this instanceof E))return new E(t);A.call(this,t,a.GZIP)}function S(t){if(!(this instanceof S))return new S(t);A.call(this,t,a.GUNZIP)}function k(t){if(!(this instanceof k))return new k(t);A.call(this,t,a.DEFLATERAW)}function T(t){if(!(this instanceof T))return new T(t);A.call(this,t,a.INFLATERAW)}function O(t){if(!(this instanceof O))return new O(t);A.call(this,t,a.UNZIP)}function x(t){return t===a.Z_NO_FLUSH||t===a.Z_PARTIAL_FLUSH||t===a.Z_SYNC_FLUSH||t===a.Z_FULL_FLUSH||t===a.Z_FINISH||t===a.Z_BLOCK}function A(t,r){var n=this;if(this._opts=t=t||{},this._chunkSize=t.chunkSize||e.Z_DEFAULT_CHUNK,o.call(this,t),t.flush&&!x(t.flush))throw new Error("Invalid flush flag: "+t.flush);if(t.finishFlush&&!x(t.finishFlush))throw new Error("Invalid flush flag: "+t.finishFlush);if(this._flushFlag=t.flush||a.Z_NO_FLUSH,this._finishFlushFlag=void 0!==t.finishFlush?t.finishFlush:a.Z_FINISH,t.chunkSize&&(t.chunkSize<e.Z_MIN_CHUNK||t.chunkSize>e.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+t.chunkSize);if(t.windowBits&&(t.windowBits<e.Z_MIN_WINDOWBITS||t.windowBits>e.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+t.windowBits);if(t.level&&(t.level<e.Z_MIN_LEVEL||t.level>e.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+t.level);if(t.memLevel&&(t.memLevel<e.Z_MIN_MEMLEVEL||t.memLevel>e.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+t.memLevel);if(t.strategy&&t.strategy!=e.Z_FILTERED&&t.strategy!=e.Z_HUFFMAN_ONLY&&t.strategy!=e.Z_RLE&&t.strategy!=e.Z_FIXED&&t.strategy!=e.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+t.strategy);if(t.dictionary&&!i.isBuffer(t.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new a.Zlib(r);var s=this;this._hadError=!1,this._handle.onerror=function(t,r){P(s),s._hadError=!0;var n=new Error(t);n.errno=r,n.code=e.codes[r],s.emit("error",n)};var u=e.Z_DEFAULT_COMPRESSION;"number"==typeof t.level&&(u=t.level);var c=e.Z_DEFAULT_STRATEGY;"number"==typeof t.strategy&&(c=t.strategy),this._handle.init(t.windowBits||e.Z_DEFAULT_WINDOWBITS,u,t.memLevel||e.Z_DEFAULT_MEMLEVEL,c,t.dictionary),this._buffer=i.allocUnsafe(this._chunkSize),this._offset=0,this._level=u,this._strategy=c,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!n._handle},configurable:!0,enumerable:!0})}function P(t,e){e&&n.nextTick(e),t._handle&&(t._handle.close(),t._handle=null)}function I(t){t.emit("close")}Object.defineProperty(e,"codes",{enumerable:!0,value:Object.freeze(d),writable:!1}),e.Deflate=m,e.Inflate=_,e.Gzip=E,e.Gunzip=S,e.DeflateRaw=k,e.InflateRaw=T,e.Unzip=O,e.createDeflate=function(t){return new m(t)},e.createInflate=function(t){return new _(t)},e.createDeflateRaw=function(t){return new k(t)},e.createInflateRaw=function(t){return new T(t)},e.createGzip=function(t){return new E(t)},e.createGunzip=function(t){return new S(t)},e.createUnzip=function(t){return new O(t)},e.deflate=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new m(e),t,r)},e.deflateSync=function(t,e){return w(new m(e),t)},e.gzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new E(e),t,r)},e.gzipSync=function(t,e){return w(new E(e),t)},e.deflateRaw=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new k(e),t,r)},e.deflateRawSync=function(t,e){return w(new k(e),t)},e.unzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new O(e),t,r)},e.unzipSync=function(t,e){return w(new O(e),t)},e.inflate=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new _(e),t,r)},e.inflateSync=function(t,e){return w(new _(e),t)},e.gunzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new S(e),t,r)},e.gunzipSync=function(t,e){return w(new S(e),t)},e.inflateRaw=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new T(e),t,r)},e.inflateRawSync=function(t,e){return w(new T(e),t)},s.inherits(A,o),A.prototype.params=function(t,r,i){if(t<e.Z_MIN_LEVEL||t>e.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+t);if(r!=e.Z_FILTERED&&r!=e.Z_HUFFMAN_ONLY&&r!=e.Z_RLE&&r!=e.Z_FIXED&&r!=e.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+r);if(this._level!==t||this._strategy!==r){var o=this;this.flush(a.Z_SYNC_FLUSH,(function(){u(o._handle,"zlib binding closed"),o._handle.params(t,r),o._hadError||(o._level=t,o._strategy=r,i&&i())}))}else n.nextTick(i)},A.prototype.reset=function(){return u(this._handle,"zlib binding closed"),this._handle.reset()},A.prototype._flush=function(t){this._transform(i.alloc(0),"",t)},A.prototype.flush=function(t,e){var r=this,o=this._writableState;("function"==typeof t||void 0===t&&!e)&&(e=t,t=a.Z_FULL_FLUSH),o.ended?e&&n.nextTick(e):o.ending?e&&this.once("end",e):o.needDrain?e&&this.once("drain",(function(){return r.flush(t,e)})):(this._flushFlag=t,this.write(i.alloc(0),"",e))},A.prototype.close=function(t){P(this,t),n.nextTick(I,this)},A.prototype._transform=function(t,e,r){var n,o=this._writableState,s=(o.ending||o.ended)&&(!t||o.length===t.length);return null===t||i.isBuffer(t)?this._handle?(s?n=this._finishFlushFlag:(n=this._flushFlag,t.length>=o.length&&(this._flushFlag=this._opts.flush||a.Z_NO_FLUSH)),void this._processChunk(t,n,r)):r(new Error("zlib binding closed")):r(new Error("invalid input"))},A.prototype._processChunk=function(t,e,r){var n=t&&t.length,o=this._chunkSize-this._offset,a=0,s=this,l="function"==typeof r;if(!l){var h,p=[],d=0;this.on("error",(function(t){h=t})),u(this._handle,"zlib binding closed");do{var y=this._handle.writeSync(e,t,a,n,this._buffer,this._offset,o)}while(!this._hadError&&v(y[0],y[1]));if(this._hadError)throw h;if(d>=c)throw P(this),new RangeError(f);var g=i.concat(p,d);return P(this),g}u(this._handle,"zlib binding closed");var b=this._handle.write(e,t,a,n,this._buffer,this._offset,o);function v(c,f){if(this&&(this.buffer=null,this.callback=null),!s._hadError){var h=o-f;if(u(h>=0,"have should not go down"),h>0){var y=s._buffer.slice(s._offset,s._offset+h);s._offset+=h,l?s.push(y):(p.push(y),d+=y.length)}if((0===f||s._offset>=s._chunkSize)&&(o=s._chunkSize,s._offset=0,s._buffer=i.allocUnsafe(s._chunkSize)),0===f){if(a+=n-c,n=c,!l)return!0;var g=s._handle.write(e,t,a,n,s._buffer,s._offset,s._chunkSize);return g.callback=v,void(g.buffer=t)}if(!l)return!1;r()}}b.buffer=t,b.callback=v},s.inherits(m,A),s.inherits(_,A),s.inherits(E,A),s.inherits(S,A),s.inherits(k,A),s.inherits(T,A),s.inherits(O,A)},8287:(t,e,r)=>{const n=r(7526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50;const a=2147483647;function s(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return c(t,e,r)}function c(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Z(t.length)?s(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return f(t),s(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function d(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return z(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function g(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 I(this,e,r);case"utf8":case"utf-8":return O(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Z(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){let o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(Z(n))return a;t[r+a]=n}return a}function _(t,e,r,n){return Y(q(e,t.length-r),t,r,n)}function E(t,e,r,n){return Y(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 Y(z(e),t,r,n)}function k(t,e,r,n){return Y(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function O(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,u;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=x));return r}(n)}e.kMaxLength=a,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return c(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return f(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},u.allocUnsafe=function(t){return l(t)},u.allocUnsafeSlow=function(t){return l(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(X(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)b(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)b(this,e,e+3),b(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)b(this,e,e+7),b(this,e+1,e+6),b(this,e+2,e+5),b(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?O(this,0,t):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const s=Math.min(o,a),c=this.slice(n,i),f=t.slice(e,r);for(let t=0;t<s;++t)if(c[t]!==f[t]){o=c[t],a=f[t];break}return o<a?-1:a<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":case"latin1":case"binary":return E(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const x=4096;function A(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function P(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function I(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=$[t[n]];return i}function L(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 B(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 R(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function N(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function j(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||U(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||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(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||B(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||B(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||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),u.prototype.readBigUInt64BE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||B(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||B(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||B(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||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),u.prototype.readBigInt64BE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||B(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||R(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||R(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||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||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||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||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||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=J((function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=J((function(t,e=0){return j(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);R(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);R(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||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||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||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||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||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=J((function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=J((function(t,e=0){return j(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=u.isBuffer(t)?t:u.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const M={};function D(t,e,r){M[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 H(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function K(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new M.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||W(e,t.length-(r+1))}(n,i,o)}function G(t,e){if("number"!=typeof t)throw new M.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,r){if(Math.floor(t)!==t)throw G(t,r),new M.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}D("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),D("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),D("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=H(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=H(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const V=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function z(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Z(t){return t!=t}const $=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},3144:(t,e,r)=>{var n=r(6743),i=r(1002),o=r(76),a=r(7119);t.exports=a||n.call(o,i)},2205:(t,e,r)=>{var n=r(6743),i=r(1002),o=r(3144);t.exports=function(){return o(n,i,arguments)}},1002:t=>{t.exports=Function.prototype.apply},76:t=>{t.exports=Function.prototype.call},3126:(t,e,r)=>{var n=r(6743),i=r(9675),o=r(76),a=r(3144);t.exports=function(t){if(t.length<1||"function"!=typeof t[0])throw new i("a function is required");return a(n,o,t)}},7119:t=>{t.exports="undefined"!=typeof Reflect&&Reflect&&Reflect.apply},8075:(t,e,r)=>{var n=r(453),i=r(487),o=i(n("String.prototype.indexOf"));t.exports=function(t,e){var r=n(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?i(r):r}},487:(t,e,r)=>{var n=r(6897),i=r(655),o=r(3126),a=r(2205);t.exports=function(t){var e=o(arguments),r=t.length-(arguments.length-1);return n(e,1+(r>0?r:0),!0)},i?i(t.exports,"apply",{value:a}):t.exports.apply=a},6556:(t,e,r)=>{var n=r(453),i=r(3126),o=i([n("%String.prototype.indexOf%")]);t.exports=function(t,e){var r=n(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?i([r]):r}},6168:(t,e,r)=>{var n=r(2861).Buffer,i=r(8310).Transform,o=r(9579).I;function a(t){i.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(6698)(a,i);var s="undefined"!=typeof Uint8Array,u="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&ArrayBuffer.isView&&(n.prototype instanceof Uint8Array||n.TYPED_ARRAY_SUPPORT);a.prototype.update=function(t,e,r){var i=function(t,e){if(t instanceof n)return t;if("string"==typeof t)return n.from(t,e);if(u&&ArrayBuffer.isView(t)){if(0===t.byteLength)return n.alloc(0);var r=n.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}if(s&&t instanceof Uint8Array)return n.from(t);if(n.isBuffer(t)&&t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t))return n.from(t);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}(t,e),o=this._update(i);return this.hashMode?this:(r&&(o=this._toString(o,r)),o)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},a.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},a.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},a.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error("can’t switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},t.exports=a},7108:(t,e,r)=>{var n=r(6698),i=r(320),o=r(6011),a=r(2802),s=r(6168);function u(t){s.call(this,"digest"),this._hash=t}n(u,s),u.prototype._update=function(t){this._hash.update(t)},u.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return"md5"===(t=t.toLowerCase())?new i:"rmd160"===t||"ripemd160"===t?new o:new u(a(t))}},320:(t,e,r)=>{var n=r(320);t.exports=function(t){return(new n).update(t).digest()}},41:(t,e,r)=>{var n=r(655),i=r(8068),o=r(9675),a=r(5795);t.exports=function(t,e,r){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new o("`obj` must be an object or a function`");if("string"!=typeof e&&"symbol"!=typeof e)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,c=arguments.length>5?arguments[5]:null,f=arguments.length>6&&arguments[6],l=!!a&&a(t,e);if(n)n(t,e,{configurable:null===c&&l?l.configurable:!c,enumerable:null===s&&l?l.enumerable:!s,value:r,writable:null===u&&l?l.writable:!u});else{if(!f&&(s||u||c))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");t[e]=r}}},8452:(t,e,r)=>{var n=r(1189),i="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),o=Object.prototype.toString,a=Array.prototype.concat,s=r(41),u=r(592)(),c=function(t,e,r,n){if(e in t)if(!0===n){if(t[e]===r)return}else if(!function(t){return"function"==typeof t&&"[object Function]"===o.call(t)}(n)||!n())return;u?s(t,e,r,!0):s(t,e,r)},f=function(t,e){var r=arguments.length>2?arguments[2]:{},o=n(e);i&&(o=a.call(o,Object.getOwnPropertySymbols(e)));for(var s=0;s<o.length;s+=1)c(t,o[s],e[o[s]],r[o[s]])};f.supportsDescriptors=!!u,t.exports=f},7176:(t,e,r)=>{var n,i=r(3126),o=r(5795);try{n=[].__proto__===Array.prototype}catch(t){if(!t||"object"!=typeof t||!("code"in t)||"ERR_PROTO_ACCESS"!==t.code)throw t}var a=!!n&&o&&o(Object.prototype,"__proto__"),s=Object,u=s.getPrototypeOf;t.exports=a&&"function"==typeof a.get?i([a.get]):"function"==typeof u&&function(t){return u(null==t?t:s(t))}},9284:(t,e,r)=>{var n=r(2861).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),a=o.charCodeAt(0);if(255!==e[a])throw new TypeError(o+" is ambiguous");e[a]=i}var s=t.length,u=t.charAt(0),c=Math.log(s)/Math.log(256),f=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return n.alloc(0);for(var r=0,i=0,o=0;t[r]===u;)i++,r++;for(var a=(t.length-r)*c+1>>>0,f=new Uint8Array(a);r<t.length;){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,p=a-1;(0!==l||h<o)&&-1!==p;p--,h++)l+=s*f[p]>>>0,f[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}for(var d=a-o;d!==a&&0===f[d];)d++;var y=n.allocUnsafe(i+(a-d));y.fill(0,0,i);for(var g=i;d!==a;)y[g++]=f[d++];return y}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var c=(a-o)*f+1>>>0,l=new Uint8Array(c);o!==a;){for(var h=e[o],p=0,d=c-1;(0!==h||p<i)&&-1!==d;d--,p++)h+=256*l[d]>>>0,l[d]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,o++}for(var y=c-i;y!==c&&0===l[y];)y++;for(var g=u.repeat(r);y<c;++y)g+=t.charAt(l[y]);return g},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}},3835:(t,e,r)=>{var n=r(9284);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},8212:(t,e,r)=>{var n=r(3835),i=r(2861).Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=t(e);return n.encode(i.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},2577:(t,e,r)=>{var n=r(7108),i=r(8212);t.exports=i((function(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}))},8377:(t,e,r)=>{var n=r(8287).Buffer,i=r(2577);function o(t,e){if(void 0!==e&&t[0]!==e)throw new Error("Invalid network version");if(33===t.length)return{version:t[0],privateKey:t.slice(1,33),compressed:!1};if(34!==t.length)throw new Error("Invalid WIF length");if(1!==t[33])throw new Error("Invalid compression flag");return{version:t[0],privateKey:t.slice(1,33),compressed:!0}}function a(t,e,r){var i=new n(r?34:33);return i.writeUInt8(t,0),e.copy(i,1),r&&(i[33]=1),i}t.exports={decode:function(t,e){return o(i.decode(t),e)},decodeRaw:o,encode:function(t,e,r){return"number"==typeof t?i.encode(a(t,e,r)):i.encode(a(t.version,t.privateKey,t.compressed))},encodeRaw:a}},5170:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.ECPairFactory=e.networks=void 0;const i=r(5249);e.networks=i;const o=r(953),a=r(3209),s=r(8377),u=r(709),c=o.typeforce.maybe(o.typeforce.compile({compressed:o.maybe(o.Boolean),network:o.maybe(o.Network)}));e.ECPairFactory=function(t){function e(e,r){if(o.typeforce(o.Buffer256bit,e),!t.isPrivate(e))throw new TypeError("Private key not in range [1, n)");return o.typeforce(c,r),new f(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(c,r),new f(void 0,e,r)}(0,u.testEcc)(t);class f{__D;__Q;compressed;network;lowR;constructor(e,r,o){this.__D=e,this.__Q=r,this.lowR=!1,void 0===o&&(o={}),this.compressed=void 0===o.compressed||o.compressed,this.network=o.network||i.bitcoin,void 0!==r&&(this.__Q=n.from(t.pointCompress(r,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const e=t.pointFromScalar(this.__D,this.compressed);this.__Q=n.from(e)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return s.encode(this.network.wif,this.__D,this.compressed)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}sign(e,r){if(!this.__D)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.__D));{let r=t.sign(e,this.__D);const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=t.sign(e,this.__D,i);return n.from(r)}}signSchnorr(e){if(!this.privateKey)throw new Error("Missing private key");if(!t.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}tweakFromPublicKey(e){const i=32===(o=this.publicKey).length?o:o.slice(1,33);var o;const a=t.xOnlyPointAddTweak(i,e);if(!a||null===a.xOnlyPubkey)throw new Error("Cannot tweak public key!");const s=n.from([0===a.parity?2:3]);return r(n.concat([s,a.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(r){const i=3!==this.publicKey[0]&&(4!==this.publicKey[0]||1&~this.publicKey[64])?this.privateKey:t.privateNegate(this.privateKey),o=t.privateAdd(i,r);if(!o)throw new Error("Invalid tweaked private key!");return e(n.from(o),{network:this.network,compressed:this.compressed})}}return{isPoint:function(e){return t.isPoint(e)},fromPrivateKey:e,fromPublicKey:r,fromWIF:function(t,r){const n=s.decode(t),a=n.version;if(o.Array(r)){if(r=r.filter((t=>a===t.wif)).pop(),!r)throw new Error("Unknown network version")}else if(r=r||i.bitcoin,a!==r.wif)throw new Error("Invalid network version");return e(n.privateKey,{compressed:n.compressed,network:r})},makeRandom:function(r){o.typeforce(c,r),void 0===r&&(r={});const n=r.rng||a;let i;do{i=n(32),o.typeforce(o.Buffer256bit,i)}while(!t.isPrivate(i));return e(i,r)}}}},8700:(t,e,r)=>{e.dg=void 0;var n=r(5170);Object.defineProperty(e,"dg",{enumerable:!0,get:function(){return n.ECPairFactory}})},5249:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.testnet=e.bitcoin=void 0,e.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},709:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,"hex");function o(t){if(!t)throw new Error("ecc library invalid")}e.testEcc=function(t){o(t.isPoint(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(!t.isPoint(i("030000000000000000000000000000000000000000000000000000000000000005"))),o(t.isPrivate(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(!t.isPrivate(i("0000000000000000000000000000000000000000000000000000000000000000"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),o(n.from(t.privateAdd(i("0000000000000000000000000000000000000000000000000000000000000001"),i("0000000000000000000000000000000000000000000000000000000000000000"))).equals(i("0000000000000000000000000000000000000000000000000000000000000001"))),o(null===t.privateAdd(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateAdd(i("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),i("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(i("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),o(n.from(t.privateNegate(i("0000000000000000000000000000000000000000000000000000000000000001"))).equals(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(n.from(t.privateNegate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateNegate(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointFromScalar(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),o(null===t.xOnlyPointAddTweak(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")));let e=t.xOnlyPointAddTweak(i("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),i("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));o(n.from(e.xOnlyPubkey).equals(i("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&1===e.parity),e=t.xOnlyPointAddTweak(i("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),i("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),o(n.from(e.xOnlyPubkey).equals(i("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&0===e.parity),o(n.from(t.sign(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),o(t.verify(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),t.signSchnorr&&o(n.from(t.signSchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),i("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),t.verifySchnorr&&o(t.verifySchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}},953:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=r(8676),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe},655:t=>{var e=Object.defineProperty||!1;if(e)try{e({},"a",{value:1})}catch(t){e=!1}t.exports=e},1237:t=>{t.exports=EvalError},9383:t=>{t.exports=Error},9290:t=>{t.exports=RangeError},9538:t=>{t.exports=ReferenceError},8068:t=>{t.exports=SyntaxError},9675:t=>{t.exports=TypeError},5345:t=>{t.exports=URIError},9612:t=>{t.exports=Object},7007:t=>{var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function c(t,e,r,n){var i,o,a,c;if(s(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),a=o[e]),void 0===a)a=o[e]=r,++t._eventsCount;else if("function"==typeof a?a=o[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=u(t))>0&&a.length>i&&!a.warned){a.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=t,f.type=e,f.count=a.length,c=f,console&&console.warn&&console.warn(c)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=f.bind(n);return i.listener=r,n.wrapFn=i,i}function h(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):d(i,i.length)}function p(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function y(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function i(o){n.once&&t.removeEventListener(e,i),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i="error"===t,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=o[t];if(void 0===u)return!1;if("function"==typeof u)n(u,this,e);else{var c=u.length,f=d(u,c);for(r=0;r<c;++r)n(f[r],this,e)}return!0},o.prototype.addListener=function(t,e){return c(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return c(this,t,e,!0)},o.prototype.once=function(t,e){return s(e),this.on(t,l(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return s(e),this.prependListener(t,l(this,t,e)),this},o.prototype.removeListener=function(t,e){var r,n,i,o,a;if(s(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,a||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},2682:(t,e,r)=>{var n=r(9600),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(t,e,r){if(!n(e))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),"[object Array]"===i.call(t)?function(t,e,r){for(var n=0,i=t.length;n<i;n++)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,a):"string"==typeof t?function(t,e,r){for(var n=0,i=t.length;n<i;n++)null==r?e(t.charAt(n),n,t):e.call(r,t.charAt(n),n,t)}(t,e,a):function(t,e,r){for(var n in t)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,a)}},9353:t=>{var e=Object.prototype.toString,r=Math.max,n=function(t,e){for(var r=[],n=0;n<t.length;n+=1)r[n]=t[n];for(var i=0;i<e.length;i+=1)r[i+t.length]=e[i];return r};t.exports=function(t){var i=this;if("function"!=typeof i||"[object Function]"!==e.apply(i))throw new TypeError("Function.prototype.bind called on incompatible "+i);for(var o,a=function(t){for(var e=[],r=1,n=0;r<t.length;r+=1,n+=1)e[n]=t[r];return e}(arguments),s=r(0,i.length-a.length),u=[],c=0;c<s;c++)u[c]="$"+c;if(o=Function("binder","return function ("+function(t){for(var e="",r=0;r<t.length;r+=1)e+=t[r],r+1<t.length&&(e+=",");return e}(u)+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof o){var e=i.apply(this,n(a,arguments));return Object(e)===e?e:this}return i.apply(t,n(a,arguments))})),i.prototype){var f=function(){};f.prototype=i.prototype,o.prototype=new f,f.prototype=null}return o}},6743:(t,e,r)=>{var n=r(9353);t.exports=Function.prototype.bind||n},453:(t,e,r)=>{var n,i=r(9612),o=r(9383),a=r(1237),s=r(9290),u=r(9538),c=r(8068),f=r(9675),l=r(5345),h=r(1514),p=r(8968),d=r(6188),y=r(8002),g=r(5880),b=Function,v=function(t){try{return b('"use strict"; return ('+t+").constructor;")()}catch(t){}},w=r(5795),m=r(655),_=function(){throw new f},E=w?function(){try{return _}catch(t){try{return w(arguments,"callee").get}catch(t){return _}}}():_,S=r(4039)(),k=r(7176),T="function"==typeof Reflect&&Reflect.getPrototypeOf||i.getPrototypeOf||k,O=r(1002),x=r(76),A={},P="undefined"!=typeof Uint8Array&&T?T(Uint8Array):n,I={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"%ArrayIteratorPrototype%":S&&T?T([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":A,"%AsyncGenerator%":A,"%AsyncGeneratorFunction%":A,"%AsyncIteratorPrototype%":A,"%Atomics%":"undefined"==typeof Atomics?n:Atomics,"%BigInt%":"undefined"==typeof BigInt?n:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?n:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":o,"%eval%":eval,"%EvalError%":a,"%Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?n:FinalizationRegistry,"%Function%":b,"%GeneratorFunction%":A,"%Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":S&&T?T(T([][Symbol.iterator]())):n,"%JSON%":"object"==typeof JSON?JSON:n,"%Map%":"undefined"==typeof Map?n:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&S&&T?T((new Map)[Symbol.iterator]()):n,"%Math%":Math,"%Number%":Number,"%Object%":i,"%Object.getOwnPropertyDescriptor%":w,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?n:Promise,"%Proxy%":"undefined"==typeof Proxy?n:Proxy,"%RangeError%":s,"%ReferenceError%":u,"%Reflect%":"undefined"==typeof Reflect?n:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?n:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&S&&T?T((new Set)[Symbol.iterator]()):n,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":S&&T?T(""[Symbol.iterator]()):n,"%Symbol%":S?Symbol:n,"%SyntaxError%":c,"%ThrowTypeError%":E,"%TypedArray%":P,"%TypeError%":f,"%Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"%URIError%":l,"%WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?n:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?n:WeakSet,"%Function.prototype.call%":x,"%Function.prototype.apply%":O,"%Object.defineProperty%":m,"%Math.abs%":h,"%Math.floor%":p,"%Math.max%":d,"%Math.min%":y,"%Math.pow%":g};if(T)try{null.error}catch(t){var L=T(T(t));I["%Error.prototype%"]=L}var B=function t(e){var r;if("%AsyncFunction%"===e)r=v("async function () {}");else if("%GeneratorFunction%"===e)r=v("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=v("async function* () {}");else if("%AsyncGenerator%"===e){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===e){var i=t("%AsyncGenerator%");i&&T&&(r=T(i.prototype))}return I[e]=r,r},R={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},N=r(6743),j=r(9957),U=N.call(x,Array.prototype.concat),C=N.call(O,Array.prototype.splice),F=N.call(x,String.prototype.replace),M=N.call(x,String.prototype.slice),D=N.call(x,RegExp.prototype.exec),H=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,K=/\\(\\)?/g,G=function(t,e){var r,n=t;if(j(R,n)&&(n="%"+(r=R[n])[0]+"%"),j(I,n)){var i=I[n];if(i===A&&(i=B(n)),void 0===i&&!e)throw new f("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new c("intrinsic "+t+" does not exist!")};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new f("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new f('"allowMissing" argument must be a boolean');if(null===D(/^%?[^%]*%?$/,t))throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=M(t,0,1),r=M(t,-1);if("%"===e&&"%"!==r)throw new c("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new c("invalid intrinsic syntax, expected opening `%`");var n=[];return F(t,H,(function(t,e,r,i){n[n.length]=r?F(i,K,"$1"):e||t})),n}(t),n=r.length>0?r[0]:"",i=G("%"+n+"%",e),o=i.name,a=i.value,s=!1,u=i.alias;u&&(n=u[0],C(r,U([0,1],u)));for(var l=1,h=!0;l<r.length;l+=1){var p=r[l],d=M(p,0,1),y=M(p,-1);if(('"'===d||"'"===d||"`"===d||'"'===y||"'"===y||"`"===y)&&d!==y)throw new c("property names with quotes must have matching quotes");if("constructor"!==p&&h||(s=!0),j(I,o="%"+(n+="."+p)+"%"))a=I[o];else if(null!=a){if(!(p in a)){if(!e)throw new f("base intrinsic for "+t+" exists, but the property is not available.");return}if(w&&l+1>=r.length){var g=w(a,p);a=(h=!!g)&&"get"in g&&!("originalValue"in g.get)?g.get:a[p]}else h=j(a,p),a=a[p];h&&!s&&(I[o]=a)}}return a}},6549:t=>{t.exports=Object.getOwnPropertyDescriptor},5795:(t,e,r)=>{var n=r(6549);if(n)try{n([],"length")}catch(t){n=null}t.exports=n},592:(t,e,r)=>{var n=r(655),i=function(){return!!n};i.hasArrayLengthDefineBug=function(){if(!n)return null;try{return 1!==n([],"length",{value:1}).length}catch(t){return!0}},t.exports=i},4039:(t,e,r)=>{var n="undefined"!=typeof Symbol&&Symbol,i=r(1333);t.exports=function(){return"function"==typeof n&&"function"==typeof Symbol&&"symbol"==typeof n("foo")&&"symbol"==typeof Symbol("bar")&&i()}},1333:t=>{t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var n in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var i=Object.getOwnPropertySymbols(t);if(1!==i.length||i[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(t,e);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},9092:(t,e,r)=>{var n=r(1333);t.exports=function(){return n()&&!!Symbol.toStringTag}},4729:(t,e,r)=>{var n=r(2861).Buffer,i=r(1603).Transform;function o(t){i.call(this),this._block=n.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(6698)(o,i),o.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},o.prototype.update=function(t,e){if(function(t){if(!n.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer")}(t),this._finalized)throw new Error("Digest already called");n.isBuffer(t)||(t=n.from(t,e));for(var r=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)r[o++]=t[i++];this._update(),this._blockOffset=0}for(;i<t.length;)r[this._blockOffset++]=t[i++];for(var a=0,s=8*t.length;s>0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},2260:t=>{var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(t,e,r){var i,o,a;if("string"==typeof e&&(a="not ",e.substr(0,4)===a)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))o="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var s=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+1>t.length)&&-1!==t.indexOf(".",r)}(t)?"property":"argument";o='The "'.concat(t,'" ').concat(s," ").concat(i," ").concat(n(e,"type"))}return o+". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},2818:(t,e,r)=>{var n=r(5606),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var o=r(6736),a=r(2192);r(6698)(f,o);for(var s=i(a.prototype),u=0;u<s.length;u++){var c=s[u];f.prototype[c]||(f.prototype[c]=a.prototype[c])}function f(t){if(!(this instanceof f))return new f(t);o.call(this,t),a.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},5860:(t,e,r)=>{t.exports=i;var n=r(3054);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(6698)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},6736:(t,e,r)=>{var n,i=r(5606);t.exports=T,T.ReadableState=k,r(7007).EventEmitter;var o,a=function(t,e){return t.listeners(e).length},s=r(1181),u=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(2382);o=f&&f.debuglog?f.debuglog("stream"):function(){};var l,h,p,d=r(2389),y=r(1468),g=r(8775).getHighWaterMark,b=r(2260).F,v=b.ERR_INVALID_ARG_TYPE,w=b.ERR_STREAM_PUSH_AFTER_EOF,m=b.ERR_METHOD_NOT_IMPLEMENTED,_=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(T,s);var E=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function k(t,e,i){n=n||r(2818),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",i),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=r(7137).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function T(t){if(n=n||r(2818),!(this instanceof T))return new T(t);var e=this instanceof n;this._readableState=new k(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function O(t,e,r,n,i){o("readableAddChunk",e);var a,s=t._readableState;if(null===e)s.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?I(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,L(t)))}}(t,s);else if(i||(a=function(t,e){var r,n;return n=e,u.isBuffer(n)||n instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],e)),r}(s,e)),a)E(t,a);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)s.endEmitted?E(t,new _):x(t,s,e,!0);else if(s.ended)E(t,new w);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?x(t,s,e,!1):B(t,s)):x(t,s,e,!1)}else n||(s.reading=!1,B(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function x(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&I(t)),B(t,e)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),T.prototype.destroy=y.destroy,T.prototype._undestroy=y.undestroy,T.prototype._destroy=function(t,e){e(t)},T.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=u.from(t,e),e=""),r=!0),O(this,t,e,!1,r)},T.prototype.unshift=function(t){return O(this,t,null,!0,!1)},T.prototype.isPaused=function(){return!1===this._readableState.flowing},T.prototype.setEncoding=function(t){l||(l=r(7137).I);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var A=1073741824;function P(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=A?t=A:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function I(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(L,t))}function L(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,C(t)}function B(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(R,t,e))}function R(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function N(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){o("readable nexttick read 0"),t.read(0)}function U(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function F(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function M(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}T.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):I(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&M(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=P(r,e))),null===(n=t>0?F(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&M(this)),null!==n&&this.emit("data",n),n},T.prototype._read=function(t){E(this,new m("_read()"))},T.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o("pipe count=%d opts=%j",n.pipesCount,e);var s=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(s):r.once("end",s),t.on("unpipe",(function e(i,a){o("onunpipe"),i===r&&a&&!1===a.hasUnpiped&&(a.hasUnpiped=!0,o("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",l),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||c())}));var c=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",c);var f=!1;function l(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==H(n.pipes,t))&&!f&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===a(t,"error")&&E(t,e)}function p(){t.removeListener("finish",d),y()}function d(){o("onfinish"),t.removeListener("close",p),y()}function y(){o("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),t},T.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=H(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},T.prototype.on=function(t,e){var r=s.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,o("on readable",n.length,n.reading),n.length?I(this):n.reading||i.nextTick(j,this))),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(N,this),r},T.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(N,this),e},T.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(U,t,e))}(this,t)),t.paused=!1,this},T.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",(function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<S.length;a++)t.on(S[a],this.emit.bind(this,S[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(T.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(4743)),h(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),T._fromList=F,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(T.from=function(t,e){return void 0===p&&(p=r(5049)),p(T,t,e)})},3054:(t,e,r)=>{t.exports=f;var n=r(2260).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(2818);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function f(t){if(!(this instanceof f))return new f(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush((function(e,r){h(t,e,r)}))}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new s;if(t._transformState.transforming)throw new a;return t.push(null)}r(6698)(f,u),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,r){r(new i("_transform()"))},f.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},f.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},f.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},2192:(t,e,r)=>{var n,i=r(5606);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=T,T.WritableState=k;var a,s={deprecate:r(4643)},u=r(1181),c=r(8287).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(1468),h=r(8775).getHighWaterMark,p=r(2260).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,g=p.ERR_MULTIPLE_CALLBACK,b=p.ERR_STREAM_CANNOT_PIPE,v=p.ERR_STREAM_DESTROYED,w=p.ERR_STREAM_NULL_VALUES,m=p.ERR_STREAM_WRITE_AFTER_END,_=p.ERR_UNKNOWN_ENCODING,E=l.errorOrDestroy;function S(){}function k(t,e,a){n=n||r(2818),t=t||{},"boolean"!=typeof a&&(a=e instanceof n),this.objectMode=!!t.objectMode,a&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",a),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,o){--e.pendingcb,r?(i.nextTick(o,n),i.nextTick(L,t,e),t._writableState.errorEmitted=!0,E(t,n)):(o(n),t._writableState.errorEmitted=!0,E(t,n),L(t,e))}(t,r,n,e,o);else{var a=P(r)||t.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||A(t,r),n?i.nextTick(x,t,r,a,o):x(t,r,a,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function T(t){var e=this instanceof(n=n||r(2818));if(!e&&!a.call(T,this))return new T(t);this._writableState=new k(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),u.call(this)}function O(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new v("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function x(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),L(t,e)}function A(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),a=e.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,O(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,l=r.callback;if(O(t,e,!1,e.objectMode?1:c.length,c,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function P(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function I(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit("prefinish"),L(t,e)}))}function L(t,e){var r=P(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(I,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(6698)(T,u),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===T&&t&&t._writableState instanceof k}})):a=function(t){return t instanceof this},T.prototype.pipe=function(){E(this,new b)},T.prototype.write=function(t,e,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof f);return s&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),s?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(t,e){var r=new m;E(t,r),i.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var o;return null===r?o=new w:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(E(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,a=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=e.objectMode?1:n.length;e.length+=s;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else O(t,e,!1,s,n,i,o);return u}(this,o,s,t,e,r)),a},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||A(this,t))},T.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new _(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(t,e,r){r(new y("_write()"))},T.prototype._writev=null,T.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,L(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),T.prototype.destroy=l.destroy,T.prototype._undestroy=l.undestroy,T.prototype._destroy=function(t,e){e(t)}},4743:(t,e,r)=>{var n,i=r(5606);function o(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var a=r(5826),s=Symbol("lastResolve"),u=Symbol("lastReject"),c=Symbol("error"),f=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[s];if(null!==e){var r=t[p].read();null!==r&&(t[l]=null,t[s]=null,t[u]=null,e(d(r,!1)))}}function g(t){i.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[f])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise((function(e,r){i.nextTick((function(){t[c]?r(t[c]):e(d(void 0,!0))}))}));var r,n=this[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[f]?r(d(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[h])}return this[l]=r,r}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var t=this;return new Promise((function(e,r){t[p].destroy(null,(function(t){t?r(t):e(d(void 0,!0))}))}))})),n),b);t.exports=function(t){var e,r=Object.create(v,(o(e={},p,{value:t,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,f,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[l]=null,r[s]=null,r[u]=null,t(d(n,!1))):(r[s]=t,r[u]=e)},writable:!0}),e));return r[l]=null,a(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[l]=null,r[s]=null,r[u]=null,e(t)),void(r[c]=t)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[u]=null,n(d(void 0,!0))),r[f]=!0})),t.on("readable",g.bind(null,r)),r}},2389:(t,e,r)=>{function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e,r){return(e=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var u=r(8287).Buffer,c=r(8460).inspect,f=c&&c.custom||"inspect";function l(t,e,r){u.prototype.copy.call(t,e,r)}t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r;return e=t,r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return u.alloc(0);for(var e=u.allocUnsafe(t>>>0),r=this.head,n=0;r;)l(r.data,e,n),n+=r.data.length,r=r.next;return e}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=u.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:f,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},1468:(t,e,r)=>{var n=r(5606);function i(t,e){a(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(a,this,t)):n.nextTick(a,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,t)):n.nextTick(i,r,t):e?(n.nextTick(o,r),e(t)):n.nextTick(o,r)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},5826:(t,e,r)=>{var n=r(2260).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var a=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||f()},c=e._writableState&&e._writableState.finished,f=function(){s=!1,c=!0,a||o.call(e)},l=e._readableState&&e._readableState.endEmitted,h=function(){a=!1,l=!0,s||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!l?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):s&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",f),e.on("abort",d),e.req?y():e.on("request",y)):s&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",f),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",f),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",f),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},5049:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},9434:(t,e,r)=>{var n,i=r(2260).F,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function s(t){if(t)throw t}function u(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var f,l=function(t){return t.length?"function"!=typeof t[t.length-1]?s:t.pop():s}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var h=e.map((function(t,i){var o=i<e.length-1;return function(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var s=!1;t.on("close",(function(){s=!0})),void 0===n&&(n=r(5826)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);s=!0,o()}));var u=!1;return function(e){if(!s&&!u)return u=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new a("pipe"))}}(t,o,i>0,(function(t){f||(f=t),t&&h.forEach(u),o||(h.forEach(u),l(f))}))}));return e.reduce(c)}},8775:(t,e,r)=>{var n=r(2260).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},1181:(t,e,r)=>{t.exports=r(7007).EventEmitter},1603:(t,e,r)=>{(e=t.exports=r(6736)).Stream=e,e.Readable=e,e.Writable=r(2192),e.Duplex=r(2818),e.Transform=r(3054),e.PassThrough=r(5860),e.finished=r(5826),e.pipeline=r(9434)},7137:(t,e,r)=>{var n=r(2861).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=c,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=f,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.I=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},o.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var i=a(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},9957:(t,e,r)=>{var n=Function.prototype.call,i=Object.prototype.hasOwnProperty,o=r(6743);t.exports=o.call(n,i)},251:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<<s)-1,c=u>>1,f=-7,l=r?i-1:0,h=r?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=s;f>0;o=256*o+t[e+l],l+=h,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,c+=i;c>0;t[r+p]=255&a,p+=d,a/=256,c-=8);t[r+p-d]|=128*y}},6698:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},7244:(t,e,r)=>{var n=r(9092)(),i=r(6556)("Object.prototype.toString"),o=function(t){return!(n&&t&&"object"==typeof t&&Symbol.toStringTag in t)&&"[object Arguments]"===i(t)},a=function(t){return!!o(t)||null!==t&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&t.length>=0&&"[object Array]"!==i(t)&&"callee"in t&&"[object Function]"===i(t.callee)},s=function(){return o(arguments)}();o.isLegacyArguments=a,t.exports=s?o:a},9600:t=>{var e,r,n=Function.prototype.toString,i="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof i&&"function"==typeof Object.defineProperty)try{e=Object.defineProperty({},"length",{get:function(){throw r}}),r={},i((function(){throw 42}),null,e)}catch(t){t!==r&&(i=null)}else i=null;var o=/^\s*class\b/,a=function(t){try{var e=n.call(t);return o.test(e)}catch(t){return!1}},s=function(t){try{return!a(t)&&(n.call(t),!0)}catch(t){return!1}},u=Object.prototype.toString,c="function"==typeof Symbol&&!!Symbol.toStringTag,f=!(0 in[,]),l=function(){return!1};if("object"==typeof document){var h=document.all;u.call(h)===u.call(document.all)&&(l=function(t){if((f||!t)&&(void 0===t||"object"==typeof t))try{var e=u.call(t);return("[object HTMLAllCollection]"===e||"[object HTML document.all class]"===e||"[object HTMLCollection]"===e||"[object Object]"===e)&&null==t("")}catch(t){}return!1})}t.exports=i?function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;try{i(t,null,e)}catch(t){if(t!==r)return!1}return!a(t)&&s(t)}:function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if(c)return s(t);if(a(t))return!1;var e=u.call(t);return!("[object Function]"!==e&&"[object GeneratorFunction]"!==e&&!/^\[object HTML/.test(e))&&s(t)}},8184:(t,e,r)=>{var n,i=Object.prototype.toString,o=Function.prototype.toString,a=/^\s*(?:function)?\*/,s=r(9092)(),u=Object.getPrototypeOf;t.exports=function(t){if("function"!=typeof t)return!1;if(a.test(o.call(t)))return!0;if(!s)return"[object GeneratorFunction]"===i.call(t);if(!u)return!1;if(void 0===n){var e=function(){if(!s)return!1;try{return Function("return function*() {}")()}catch(t){}}();n=!!e&&u(e)}return u(t)===n}},3003:t=>{t.exports=function(t){return t!=t}},4133:(t,e,r)=>{var n=r(487),i=r(8452),o=r(3003),a=r(6642),s=r(2464),u=n(a(),Number);i(u,{getPolyfill:a,implementation:o,shim:s}),t.exports=u},6642:(t,e,r)=>{var n=r(3003);t.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:n}},2464:(t,e,r)=>{var n=r(8452),i=r(6642);t.exports=function(){var t=i();return n(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}},5680:(t,e,r)=>{var n=r(5767);t.exports=function(t){return!!n(t)}},1514:t=>{t.exports=Math.abs},8968:t=>{t.exports=Math.floor},6188:t=>{t.exports=Math.max},8002:t=>{t.exports=Math.min},5880:t=>{t.exports=Math.pow},9211:t=>{var e=function(t){return t!=t};t.exports=function(t,r){return 0===t&&0===r?1/t==1/r:t===r||!(!e(t)||!e(r))}},7653:(t,e,r)=>{var n=r(8452),i=r(487),o=r(9211),a=r(9394),s=r(6576),u=i(a(),Object);n(u,{getPolyfill:a,implementation:o,shim:s}),t.exports=u},9394:(t,e,r)=>{var n=r(9211);t.exports=function(){return"function"==typeof Object.is?Object.is:n}},6576:(t,e,r)=>{var n=r(9394),i=r(8452);t.exports=function(){var t=n();return i(Object,{is:t},{is:function(){return Object.is!==t}}),t}},8875:(t,e,r)=>{var n;if(!Object.keys){var i=Object.prototype.hasOwnProperty,o=Object.prototype.toString,a=r(1093),s=Object.prototype.propertyIsEnumerable,u=!s.call({toString:null},"toString"),c=s.call((function(){}),"prototype"),f=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(t){var e=t.constructor;return e&&e.prototype===t},h={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},p=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!h["$"+t]&&i.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{l(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();n=function(t){var e=null!==t&&"object"==typeof t,r="[object Function]"===o.call(t),n=a(t),s=e&&"[object String]"===o.call(t),h=[];if(!e&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var d=c&&r;if(s&&t.length>0&&!i.call(t,0))for(var y=0;y<t.length;++y)h.push(String(y));if(n&&t.length>0)for(var g=0;g<t.length;++g)h.push(String(g));else for(var b in t)d&&"prototype"===b||!i.call(t,b)||h.push(String(b));if(u)for(var v=function(t){if("undefined"==typeof window||!p)return l(t);try{return l(t)}catch(t){return!1}}(t),w=0;w<f.length;++w)v&&"constructor"===f[w]||!i.call(t,f[w])||h.push(f[w]);return h}}t.exports=n},1189:(t,e,r)=>{var n=Array.prototype.slice,i=r(1093),o=Object.keys,a=o?function(t){return o(t)}:r(8875),s=Object.keys;a.shim=function(){if(Object.keys){var t=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);t||(Object.keys=function(t){return i(t)?s(n.call(t)):s(t)})}else Object.keys=a;return Object.keys||a},t.exports=a},1093:t=>{var e=Object.prototype.toString;t.exports=function(t){var r=e.call(t),n="[object Arguments]"===r;return n||(n="[object Array]"!==r&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===e.call(t.callee)),n}},8403:(t,e,r)=>{var n=r(1189),i=r(1333)(),o=r(6556),a=r(9612),s=o("Array.prototype.push"),u=o("Object.prototype.propertyIsEnumerable"),c=i?a.getOwnPropertySymbols:null;t.exports=function(t,e){if(null==t)throw new TypeError("target must be an object");var r=a(t);if(1===arguments.length)return r;for(var o=1;o<arguments.length;++o){var f=a(arguments[o]),l=n(f),h=i&&(a.getOwnPropertySymbols||c);if(h)for(var p=h(f),d=0;d<p.length;++d){var y=p[d];u(f,y)&&s(l,y)}for(var g=0;g<l.length;++g){var b=l[g];if(u(f,b)){var v=f[b];r[b]=v}}}return r}},9133:(t,e,r)=>{var n=r(8403);t.exports=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var t="abcdefghijklmnopqrst",e=t.split(""),r={},n=0;n<e.length;++n)r[e[n]]=e[n];var i=Object.assign({},r),o="";for(var a in i)o+=a;return t!==o}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var t=Object.preventExtensions({1:2});try{Object.assign(t,"xy")}catch(e){return"y"===t[1]}return!1}()?n:Object.assign:n}},9805:(t,e)=>{var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)n(r,i)&&(t[i]=r[i])}}return t},e.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var i={arraySet:function(t,e,r,n,i){if(e.subarray&&t.subarray)t.set(e.subarray(r,r+n),i);else for(var o=0;o<n;o++)t[i+o]=e[r+o]},flattenChunks:function(t){var e,r,n,i,o,a;for(n=0,e=0,r=t.length;e<r;e++)n+=t[e].length;for(a=new Uint8Array(n),i=0,e=0,r=t.length;e<r;e++)o=t[e],a.set(o,i),i+=o.length;return a}},o={arraySet:function(t,e,r,n,i){for(var o=0;o<n;o++)t[i+o]=e[r+o]},flattenChunks:function(t){return[].concat.apply([],t)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,i)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,o))},e.setTyped(r)},3269:t=>{t.exports=function(t,e,r,n){for(var i=65535&t,o=t>>>16&65535,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+e[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16}},9681:t=>{t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},4823:t=>{var e=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();t.exports=function(t,r,n,i){var o=e,a=i+n;t^=-1;for(var s=i;s<a;s++)t=t>>>8^o[255&(t^r[s])];return~t}},8411:(t,e,r)=>{var n,i=r(9805),o=r(3665),a=r(3269),s=r(4823),u=r(4674),c=-2,f=258,l=262,h=103,p=113,d=666;function y(t,e){return t.msg=u[e],e}function g(t){return(t<<1)-(t>4?9:0)}function b(t){for(var e=t.length;--e>=0;)t[e]=0}function v(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(i.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))}function w(t,e){o._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,v(t.strm)}function m(t,e){t.pending_buf[t.pending++]=e}function _(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function E(t,e){var r,n,i=t.max_chain_length,o=t.strstart,a=t.prev_length,s=t.nice_match,u=t.strstart>t.w_size-l?t.strstart-(t.w_size-l):0,c=t.window,h=t.w_mask,p=t.prev,d=t.strstart+f,y=c[o+a-1],g=c[o+a];t.prev_length>=t.good_match&&(i>>=2),s>t.lookahead&&(s=t.lookahead);do{if(c[(r=e)+a]===g&&c[r+a-1]===y&&c[r]===c[o]&&c[++r]===c[o+1]){o+=2,r++;do{}while(c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&o<d);if(n=f-(d-o),o=d-f,n>a){if(t.match_start=e,a=n,n>=s)break;y=c[o+a-1],g=c[o+a]}}}while((e=p[e&h])>u&&0!=--i);return a<=t.lookahead?a:t.lookahead}function S(t){var e,r,n,o,u,c,f,h,p,d,y=t.w_size;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=y+(y-l)){i.arraySet(t.window,t.window,y,y,0),t.match_start-=y,t.strstart-=y,t.block_start-=y,e=r=t.hash_size;do{n=t.head[--e],t.head[e]=n>=y?n-y:0}while(--r);e=r=y;do{n=t.prev[--e],t.prev[e]=n>=y?n-y:0}while(--r);o+=y}if(0===t.strm.avail_in)break;if(c=t.strm,f=t.window,h=t.strstart+t.lookahead,p=o,d=void 0,(d=c.avail_in)>p&&(d=p),r=0===d?0:(c.avail_in-=d,i.arraySet(f,c.input,c.next_in,d,h),1===c.state.wrap?c.adler=a(c.adler,f,d,h):2===c.state.wrap&&(c.adler=s(c.adler,f,d,h)),c.next_in+=d,c.total_in+=d,d),t.lookahead+=r,t.lookahead+t.insert>=3)for(u=t.strstart-t.insert,t.ins_h=t.window[u],t.ins_h=(t.ins_h<<t.hash_shift^t.window[u+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[u+3-1])&t.hash_mask,t.prev[u&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=u,u++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<l&&0!==t.strm.avail_in)}function k(t,e){for(var r,n;;){if(t.lookahead<l){if(S(t),t.lookahead<l&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-l&&(t.match_length=E(t,r)),t.match_length>=3)if(n=o._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else n=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}function T(t,e){for(var r,n,i;;){if(t.lookahead<l){if(S(t),t.lookahead<l&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-l&&(t.match_length=E(t,r),t.match_length<=5&&(1===t.strategy||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=o._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(w(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=o._tr_tally(t,0,t.window[t.strstart-1]))&&w(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=o._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}function O(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}function x(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),b(this.dyn_ltree),b(this.dyn_dtree),b(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),b(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),b(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function A(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=2,(e=t.state).pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:p,t.adler=2===e.wrap?0:1,e.last_flush=0,o._tr_init(e),0):y(t,c)}function P(t){var e=A(t);return 0===e&&function(t){t.window_size=2*t.w_size,b(t.head),t.max_lazy_match=n[t.level].max_lazy,t.good_match=n[t.level].good_length,t.nice_match=n[t.level].nice_length,t.max_chain_length=n[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0}(t.state),e}function I(t,e,r,n,o,a){if(!t)return c;var s=1;if(-1===e&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),o<1||o>9||8!==r||n<8||n>15||e<0||e>9||a<0||a>4)return y(t,c);8===n&&(n=9);var u=new x;return t.state=u,u.strm=t,u.wrap=s,u.gzhead=null,u.w_bits=n,u.w_size=1<<u.w_bits,u.w_mask=u.w_size-1,u.hash_bits=o+7,u.hash_size=1<<u.hash_bits,u.hash_mask=u.hash_size-1,u.hash_shift=~~((u.hash_bits+3-1)/3),u.window=new i.Buf8(2*u.w_size),u.head=new i.Buf16(u.hash_size),u.prev=new i.Buf16(u.w_size),u.lit_bufsize=1<<o+6,u.pending_buf_size=4*u.lit_bufsize,u.pending_buf=new i.Buf8(u.pending_buf_size),u.d_buf=1*u.lit_bufsize,u.l_buf=3*u.lit_bufsize,u.level=e,u.strategy=a,u.method=r,P(t)}n=[new O(0,0,0,0,(function(t,e){var r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(S(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,w(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-l&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(w(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(w(t,!1),t.strm.avail_out),1)})),new O(4,4,8,4,k),new O(4,5,16,8,k),new O(4,6,32,32,k),new O(4,4,16,16,T),new O(8,16,32,32,T),new O(8,16,128,128,T),new O(8,32,128,256,T),new O(32,128,258,1024,T),new O(32,258,258,4096,T)],e.deflateInit=function(t,e){return I(t,e,8,15,8,0)},e.deflateInit2=I,e.deflateReset=P,e.deflateResetKeep=A,e.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?c:(t.state.gzhead=e,0):c},e.deflate=function(t,e){var r,i,a,u;if(!t||!t.state||e>5||e<0)return t?y(t,c):c;if(i=t.state,!t.output||!t.input&&0!==t.avail_in||i.status===d&&4!==e)return y(t,0===t.avail_out?-5:c);if(i.strm=t,r=i.last_flush,i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,m(i,31),m(i,139),m(i,8),i.gzhead?(m(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),m(i,255&i.gzhead.time),m(i,i.gzhead.time>>8&255),m(i,i.gzhead.time>>16&255),m(i,i.gzhead.time>>24&255),m(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),m(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(m(i,255&i.gzhead.extra.length),m(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=s(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(m(i,0),m(i,0),m(i,0),m(i,0),m(i,0),m(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),m(i,3),i.status=p);else{var l=8+(i.w_bits-8<<4)<<8;l|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(l|=32),l+=31-l%31,i.status=p,_(i,l),0!==i.strstart&&(_(i,t.adler>>>16),_(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(a=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),v(t),a=i.pending,i.pending!==i.pending_buf_size));)m(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),v(t),a=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,m(i,u)}while(0!==u);i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),0===u&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),v(t),a=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,m(i,u)}while(0!==u);i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),0===u&&(i.status=h)}else i.status=h;if(i.status===h&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&v(t),i.pending+2<=i.pending_buf_size&&(m(i,255&t.adler),m(i,t.adler>>8&255),t.adler=0,i.status=p)):i.status=p),0!==i.pending){if(v(t),0===t.avail_out)return i.last_flush=-1,0}else if(0===t.avail_in&&g(e)<=g(r)&&4!==e)return y(t,-5);if(i.status===d&&0!==t.avail_in)return y(t,-5);if(0!==t.avail_in||0!==i.lookahead||0!==e&&i.status!==d){var E=2===i.strategy?function(t,e){for(var r;;){if(0===t.lookahead&&(S(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,r=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}(i,e):3===i.strategy?function(t,e){for(var r,n,i,a,s=t.window;;){if(t.lookahead<=f){if(S(t),t.lookahead<=f&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=s[i=t.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){a=t.strstart+f;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a);t.match_length=f-(a-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=o._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}(i,e):n[i.level].func(i,e);if(3!==E&&4!==E||(i.status=d),1===E||3===E)return 0===t.avail_out&&(i.last_flush=-1),0;if(2===E&&(1===e?o._tr_align(i):5!==e&&(o._tr_stored_block(i,0,0,!1),3===e&&(b(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),v(t),0===t.avail_out))return i.last_flush=-1,0}return 4!==e?0:i.wrap<=0?1:(2===i.wrap?(m(i,255&t.adler),m(i,t.adler>>8&255),m(i,t.adler>>16&255),m(i,t.adler>>24&255),m(i,255&t.total_in),m(i,t.total_in>>8&255),m(i,t.total_in>>16&255),m(i,t.total_in>>24&255)):(_(i,t.adler>>>16),_(i,65535&t.adler)),v(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)},e.deflateEnd=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&e!==h&&e!==p&&e!==d?y(t,c):(t.state=null,e===p?y(t,-3):0):c},e.deflateSetDictionary=function(t,e){var r,n,o,s,u,f,l,h,p=e.length;if(!t||!t.state)return c;if(2===(s=(r=t.state).wrap)||1===s&&42!==r.status||r.lookahead)return c;for(1===s&&(t.adler=a(t.adler,e,p,0)),r.wrap=0,p>=r.w_size&&(0===s&&(b(r.head),r.strstart=0,r.block_start=0,r.insert=0),h=new i.Buf8(r.w_size),i.arraySet(h,e,p-r.w_size,r.w_size,0),e=h,p=r.w_size),u=t.avail_in,f=t.next_in,l=t.input,t.avail_in=p,t.next_in=0,t.input=e,S(r);r.lookahead>=3;){n=r.strstart,o=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--o);r.strstart=n,r.lookahead=2,S(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=f,t.input=l,t.avail_in=u,r.wrap=s,0},e.deflateInfo="pako deflate (from Nodeca project)"},7293:t=>{t.exports=function(t,e){var r,n,i,o,a,s,u,c,f,l,h,p,d,y,g,b,v,w,m,_,E,S,k,T,O;r=t.state,n=t.next_in,T=t.input,i=n+(t.avail_in-5),o=t.next_out,O=t.output,a=o-(e-t.avail_out),s=o+(t.avail_out-257),u=r.dmax,c=r.wsize,f=r.whave,l=r.wnext,h=r.window,p=r.hold,d=r.bits,y=r.lencode,g=r.distcode,b=(1<<r.lenbits)-1,v=(1<<r.distbits)-1;t:do{d<15&&(p+=T[n++]<<d,d+=8,p+=T[n++]<<d,d+=8),w=y[p&b];e:for(;;){if(p>>>=m=w>>>24,d-=m,0==(m=w>>>16&255))O[o++]=65535&w;else{if(!(16&m)){if(64&m){if(32&m){r.mode=12;break t}t.msg="invalid literal/length code",r.mode=30;break t}w=y[(65535&w)+(p&(1<<m)-1)];continue e}for(_=65535&w,(m&=15)&&(d<m&&(p+=T[n++]<<d,d+=8),_+=p&(1<<m)-1,p>>>=m,d-=m),d<15&&(p+=T[n++]<<d,d+=8,p+=T[n++]<<d,d+=8),w=g[p&v];;){if(p>>>=m=w>>>24,d-=m,16&(m=w>>>16&255)){if(E=65535&w,d<(m&=15)&&(p+=T[n++]<<d,(d+=8)<m&&(p+=T[n++]<<d,d+=8)),(E+=p&(1<<m)-1)>u){t.msg="invalid distance too far back",r.mode=30;break t}if(p>>>=m,d-=m,E>(m=o-a)){if((m=E-m)>f&&r.sane){t.msg="invalid distance too far back",r.mode=30;break t}if(S=0,k=h,0===l){if(S+=c-m,m<_){_-=m;do{O[o++]=h[S++]}while(--m);S=o-E,k=O}}else if(l<m){if(S+=c+l-m,(m-=l)<_){_-=m;do{O[o++]=h[S++]}while(--m);if(S=0,l<_){_-=m=l;do{O[o++]=h[S++]}while(--m);S=o-E,k=O}}}else if(S+=l-m,m<_){_-=m;do{O[o++]=h[S++]}while(--m);S=o-E,k=O}for(;_>2;)O[o++]=k[S++],O[o++]=k[S++],O[o++]=k[S++],_-=3;_&&(O[o++]=k[S++],_>1&&(O[o++]=k[S++]))}else{S=o-E;do{O[o++]=O[S++],O[o++]=O[S++],O[o++]=O[S++],_-=3}while(_>2);_&&(O[o++]=O[S++],_>1&&(O[o++]=O[S++]))}break}if(64&m){t.msg="invalid distance code",r.mode=30;break t}w=g[(65535&w)+(p&(1<<m)-1)]}}break}}while(n<i&&o<s);n-=_=d>>3,p&=(1<<(d-=_<<3))-1,t.next_in=n,t.next_out=o,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=o<s?s-o+257:257-(o-s),r.hold=p,r.bits=d}},1447:(t,e,r)=>{var n=r(9805),i=r(3269),o=r(4823),a=r(7293),s=r(1998),u=-2,c=12,f=30;function l(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function h(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function p(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new n.Buf32(852),e.distcode=e.distdyn=new n.Buf32(592),e.sane=1,e.back=-1,0):u}function d(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,p(t)):u}function y(t,e){var r,n;return t&&t.state?(n=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?u:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,d(t))):u}function g(t,e){var r,n;return t?(n=new h,t.state=n,n.window=null,0!==(r=y(t,e))&&(t.state=null),r):u}var b,v,w=!0;function m(t){if(w){var e;for(b=new n.Buf32(512),v=new n.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(s(1,t.lens,0,288,b,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;s(2,t.lens,0,32,v,0,t.work,{bits:5}),w=!1}t.lencode=b,t.lenbits=9,t.distcode=v,t.distbits=5}function _(t,e,r,i){var o,a=t.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new n.Buf8(a.wsize)),i>=a.wsize?(n.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((o=a.wsize-a.wnext)>i&&(o=i),n.arraySet(a.window,e,r-i,o,a.wnext),(i-=o)?(n.arraySet(a.window,e,r-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=o,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=o))),0}e.inflateReset=d,e.inflateReset2=y,e.inflateResetKeep=p,e.inflateInit=function(t){return g(t,15)},e.inflateInit2=g,e.inflate=function(t,e){var r,h,p,d,y,g,b,v,w,E,S,k,T,O,x,A,P,I,L,B,R,N,j,U,C=0,F=new n.Buf8(4),M=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return u;(r=t.state).mode===c&&(r.mode=13),y=t.next_out,p=t.output,b=t.avail_out,d=t.next_in,h=t.input,g=t.avail_in,v=r.hold,w=r.bits,E=g,S=b,N=0;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;w<16;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(2&r.wrap&&35615===v){r.check=0,F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0),v=0,w=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&v)<<8)+(v>>8))%31){t.msg="incorrect header check",r.mode=f;break}if(8!=(15&v)){t.msg="unknown compression method",r.mode=f;break}if(w-=4,R=8+(15&(v>>>=4)),0===r.wbits)r.wbits=R;else if(R>r.wbits){t.msg="invalid window size",r.mode=f;break}r.dmax=1<<R,t.adler=r.check=1,r.mode=512&v?10:c,v=0,w=0;break;case 2:for(;w<16;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(r.flags=v,8!=(255&r.flags)){t.msg="unknown compression method",r.mode=f;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=f;break}r.head&&(r.head.text=v>>8&1),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0)),v=0,w=0,r.mode=3;case 3:for(;w<32;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}r.head&&(r.head.time=v),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,F[2]=v>>>16&255,F[3]=v>>>24&255,r.check=o(r.check,F,4,0)),v=0,w=0,r.mode=4;case 4:for(;w<16;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}r.head&&(r.head.xflags=255&v,r.head.os=v>>8),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0)),v=0,w=0,r.mode=5;case 5:if(1024&r.flags){for(;w<16;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}r.length=v,r.head&&(r.head.extra_len=v),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0)),v=0,w=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((k=r.length)>g&&(k=g),k&&(r.head&&(R=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),n.arraySet(r.head.extra,h,d,k,R)),512&r.flags&&(r.check=o(r.check,h,k,d)),g-=k,d+=k,r.length-=k),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===g)break t;k=0;do{R=h[d+k++],r.head&&R&&r.length<65536&&(r.head.name+=String.fromCharCode(R))}while(R&&k<g);if(512&r.flags&&(r.check=o(r.check,h,k,d)),g-=k,d+=k,R)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===g)break t;k=0;do{R=h[d+k++],r.head&&R&&r.length<65536&&(r.head.comment+=String.fromCharCode(R))}while(R&&k<g);if(512&r.flags&&(r.check=o(r.check,h,k,d)),g-=k,d+=k,R)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;w<16;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(v!==(65535&r.check)){t.msg="header crc mismatch",r.mode=f;break}v=0,w=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=c;break;case 10:for(;w<32;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}t.adler=r.check=l(v),v=0,w=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=y,t.avail_out=b,t.next_in=d,t.avail_in=g,r.hold=v,r.bits=w,2;t.adler=r.check=1,r.mode=c;case c:if(5===e||6===e)break t;case 13:if(r.last){v>>>=7&w,w-=7&w,r.mode=27;break}for(;w<3;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}switch(r.last=1&v,w-=1,3&(v>>>=1)){case 0:r.mode=14;break;case 1:if(m(r),r.mode=20,6===e){v>>>=2,w-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=f}v>>>=2,w-=2;break;case 14:for(v>>>=7&w,w-=7&w;w<32;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if((65535&v)!=(v>>>16^65535)){t.msg="invalid stored block lengths",r.mode=f;break}if(r.length=65535&v,v=0,w=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(k=r.length){if(k>g&&(k=g),k>b&&(k=b),0===k)break t;n.arraySet(p,h,d,k,y),g-=k,d+=k,b-=k,y+=k,r.length-=k;break}r.mode=c;break;case 17:for(;w<14;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(r.nlen=257+(31&v),v>>>=5,w-=5,r.ndist=1+(31&v),v>>>=5,w-=5,r.ncode=4+(15&v),v>>>=4,w-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=f;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;w<3;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}r.lens[M[r.have++]]=7&v,v>>>=3,w-=3}for(;r.have<19;)r.lens[M[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,j={bits:r.lenbits},N=s(0,r.lens,0,19,r.lencode,0,r.work,j),r.lenbits=j.bits,N){t.msg="invalid code lengths set",r.mode=f;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;A=(C=r.lencode[v&(1<<r.lenbits)-1])>>>16&255,P=65535&C,!((x=C>>>24)<=w);){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(P<16)v>>>=x,w-=x,r.lens[r.have++]=P;else{if(16===P){for(U=x+2;w<U;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(v>>>=x,w-=x,0===r.have){t.msg="invalid bit length repeat",r.mode=f;break}R=r.lens[r.have-1],k=3+(3&v),v>>>=2,w-=2}else if(17===P){for(U=x+3;w<U;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}w-=x,R=0,k=3+(7&(v>>>=x)),v>>>=3,w-=3}else{for(U=x+7;w<U;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}w-=x,R=0,k=11+(127&(v>>>=x)),v>>>=7,w-=7}if(r.have+k>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=f;break}for(;k--;)r.lens[r.have++]=R}}if(r.mode===f)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=f;break}if(r.lenbits=9,j={bits:r.lenbits},N=s(1,r.lens,0,r.nlen,r.lencode,0,r.work,j),r.lenbits=j.bits,N){t.msg="invalid literal/lengths set",r.mode=f;break}if(r.distbits=6,r.distcode=r.distdyn,j={bits:r.distbits},N=s(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,j),r.distbits=j.bits,N){t.msg="invalid distances set",r.mode=f;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(g>=6&&b>=258){t.next_out=y,t.avail_out=b,t.next_in=d,t.avail_in=g,r.hold=v,r.bits=w,a(t,S),y=t.next_out,p=t.output,b=t.avail_out,d=t.next_in,h=t.input,g=t.avail_in,v=r.hold,w=r.bits,r.mode===c&&(r.back=-1);break}for(r.back=0;A=(C=r.lencode[v&(1<<r.lenbits)-1])>>>16&255,P=65535&C,!((x=C>>>24)<=w);){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(A&&!(240&A)){for(I=x,L=A,B=P;A=(C=r.lencode[B+((v&(1<<I+L)-1)>>I)])>>>16&255,P=65535&C,!(I+(x=C>>>24)<=w);){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}v>>>=I,w-=I,r.back+=I}if(v>>>=x,w-=x,r.back+=x,r.length=P,0===A){r.mode=26;break}if(32&A){r.back=-1,r.mode=c;break}if(64&A){t.msg="invalid literal/length code",r.mode=f;break}r.extra=15&A,r.mode=22;case 22:if(r.extra){for(U=r.extra;w<U;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}r.length+=v&(1<<r.extra)-1,v>>>=r.extra,w-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;A=(C=r.distcode[v&(1<<r.distbits)-1])>>>16&255,P=65535&C,!((x=C>>>24)<=w);){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(!(240&A)){for(I=x,L=A,B=P;A=(C=r.distcode[B+((v&(1<<I+L)-1)>>I)])>>>16&255,P=65535&C,!(I+(x=C>>>24)<=w);){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}v>>>=I,w-=I,r.back+=I}if(v>>>=x,w-=x,r.back+=x,64&A){t.msg="invalid distance code",r.mode=f;break}r.offset=P,r.extra=15&A,r.mode=24;case 24:if(r.extra){for(U=r.extra;w<U;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}r.offset+=v&(1<<r.extra)-1,v>>>=r.extra,w-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=f;break}r.mode=25;case 25:if(0===b)break t;if(k=S-b,r.offset>k){if((k=r.offset-k)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=f;break}k>r.wnext?(k-=r.wnext,T=r.wsize-k):T=r.wnext-k,k>r.length&&(k=r.length),O=r.window}else O=p,T=y-r.offset,k=r.length;k>b&&(k=b),b-=k,r.length-=k;do{p[y++]=O[T++]}while(--k);0===r.length&&(r.mode=21);break;case 26:if(0===b)break t;p[y++]=r.length,b--,r.mode=21;break;case 27:if(r.wrap){for(;w<32;){if(0===g)break t;g--,v|=h[d++]<<w,w+=8}if(S-=b,t.total_out+=S,r.total+=S,S&&(t.adler=r.check=r.flags?o(r.check,p,S,y-S):i(r.check,p,S,y-S)),S=b,(r.flags?v:l(v))!==r.check){t.msg="incorrect data check",r.mode=f;break}v=0,w=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;w<32;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(v!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=f;break}v=0,w=0}r.mode=29;case 29:N=1;break t;case f:N=-3;break t;case 31:return-4;default:return u}return t.next_out=y,t.avail_out=b,t.next_in=d,t.avail_in=g,r.hold=v,r.bits=w,(r.wsize||S!==t.avail_out&&r.mode<f&&(r.mode<27||4!==e))&&_(t,t.output,t.next_out,S-t.avail_out)?(r.mode=31,-4):(E-=t.avail_in,S-=t.avail_out,t.total_in+=E,t.total_out+=S,r.total+=S,r.wrap&&S&&(t.adler=r.check=r.flags?o(r.check,p,S,t.next_out-S):i(r.check,p,S,t.next_out-S)),t.data_type=r.bits+(r.last?64:0)+(r.mode===c?128:0)+(20===r.mode||15===r.mode?256:0),(0===E&&0===S||4===e)&&0===N&&(N=-5),N)},e.inflateEnd=function(t){if(!t||!t.state)return u;var e=t.state;return e.window&&(e.window=null),t.state=null,0},e.inflateGetHeader=function(t,e){var r;return t&&t.state&&2&(r=t.state).wrap?(r.head=e,e.done=!1,0):u},e.inflateSetDictionary=function(t,e){var r,n=e.length;return t&&t.state?0!==(r=t.state).wrap&&11!==r.mode?u:11===r.mode&&i(1,e,n,0)!==r.check?-3:_(t,e,n,n)?(r.mode=31,-4):(r.havedict=1,0):u},e.inflateInfo="pako inflate (from Nodeca project)"},1998:(t,e,r)=>{var n=r(9805),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],a=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],s=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(t,e,r,u,c,f,l,h){var p,d,y,g,b,v,w,m,_,E=h.bits,S=0,k=0,T=0,O=0,x=0,A=0,P=0,I=0,L=0,B=0,R=null,N=0,j=new n.Buf16(16),U=new n.Buf16(16),C=null,F=0;for(S=0;S<=15;S++)j[S]=0;for(k=0;k<u;k++)j[e[r+k]]++;for(x=E,O=15;O>=1&&0===j[O];O--);if(x>O&&(x=O),0===O)return c[f++]=20971520,c[f++]=20971520,h.bits=1,0;for(T=1;T<O&&0===j[T];T++);for(x<T&&(x=T),I=1,S=1;S<=15;S++)if(I<<=1,(I-=j[S])<0)return-1;if(I>0&&(0===t||1!==O))return-1;for(U[1]=0,S=1;S<15;S++)U[S+1]=U[S]+j[S];for(k=0;k<u;k++)0!==e[r+k]&&(l[U[e[r+k]]++]=k);if(0===t?(R=C=l,v=19):1===t?(R=i,N-=257,C=o,F-=257,v=256):(R=a,C=s,v=-1),B=0,k=0,S=T,b=f,A=x,P=0,y=-1,g=(L=1<<x)-1,1===t&&L>852||2===t&&L>592)return 1;for(;;){w=S-P,l[k]<v?(m=0,_=l[k]):l[k]>v?(m=C[F+l[k]],_=R[N+l[k]]):(m=96,_=0),p=1<<S-P,T=d=1<<A;do{c[b+(B>>P)+(d-=p)]=w<<24|m<<16|_}while(0!==d);for(p=1<<S-1;B&p;)p>>=1;if(0!==p?(B&=p-1,B+=p):B=0,k++,0==--j[S]){if(S===O)break;S=e[r+l[k]]}if(S>x&&(B&g)!==y){for(0===P&&(P=x),b+=T,I=1<<(A=S-P);A+P<O&&!((I-=j[A+P])<=0);)A++,I<<=1;if(L+=1<<A,1===t&&L>852||2===t&&L>592)return 1;c[y=B&g]=x<<24|A<<16|b-f}}return 0!==B&&(c[b+B]=S-P<<24|64<<16),h.bits=x,0}},4674:t=>{t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},3665:(t,e,r)=>{var n=r(9805);function i(t){for(var e=t.length;--e>=0;)t[e]=0}var o=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],a=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],u=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],c=new Array(576);i(c);var f=new Array(60);i(f);var l=new Array(512);i(l);var h=new Array(256);i(h);var p=new Array(29);i(p);var d,y,g,b=new Array(30);function v(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}function w(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function m(t){return t<256?l[t]:l[256+(t>>>7)]}function _(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function E(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,_(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)}function S(t,e,r){E(t,r[2*e],r[2*e+1])}function k(t,e){var r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1}function T(t,e,r){var n,i,o=new Array(16),a=0;for(n=1;n<=15;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=e;i++){var s=t[2*i+1];0!==s&&(t[2*i]=k(o[s]++,s))}}function O(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function x(t){t.bi_valid>8?_(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function A(t,e,r,n){var i=2*e,o=2*r;return t[i]<t[o]||t[i]===t[o]&&n[e]<=n[r]}function P(t,e,r){for(var n=t.heap[r],i=r<<1;i<=t.heap_len&&(i<t.heap_len&&A(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!A(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n}function I(t,e,r){var n,i,s,u,c=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*c]<<8|t.pending_buf[t.d_buf+2*c+1],i=t.pending_buf[t.l_buf+c],c++,0===n?S(t,i,e):(S(t,(s=h[i])+256+1,e),0!==(u=o[s])&&E(t,i-=p[s],u),S(t,s=m(--n),r),0!==(u=a[s])&&E(t,n-=b[s],u))}while(c<t.last_lit);S(t,256,e)}function L(t,e){var r,n,i,o=e.dyn_tree,a=e.stat_desc.static_tree,s=e.stat_desc.has_stree,u=e.stat_desc.elems,c=-1;for(t.heap_len=0,t.heap_max=573,r=0;r<u;r++)0!==o[2*r]?(t.heap[++t.heap_len]=c=r,t.depth[r]=0):o[2*r+1]=0;for(;t.heap_len<2;)o[2*(i=t.heap[++t.heap_len]=c<2?++c:0)]=1,t.depth[i]=0,t.opt_len--,s&&(t.static_len-=a[2*i+1]);for(e.max_code=c,r=t.heap_len>>1;r>=1;r--)P(t,o,r);i=u;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],P(t,o,1),n=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=n,o[2*i]=o[2*r]+o[2*n],t.depth[i]=(t.depth[r]>=t.depth[n]?t.depth[r]:t.depth[n])+1,o[2*r+1]=o[2*n+1]=i,t.heap[1]=i++,P(t,o,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,n,i,o,a,s,u=e.dyn_tree,c=e.max_code,f=e.stat_desc.static_tree,l=e.stat_desc.has_stree,h=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,d=e.stat_desc.max_length,y=0;for(o=0;o<=15;o++)t.bl_count[o]=0;for(u[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)(o=u[2*u[2*(n=t.heap[r])+1]+1]+1)>d&&(o=d,y++),u[2*n+1]=o,n>c||(t.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=u[2*n],t.opt_len+=s*(o+a),l&&(t.static_len+=s*(f[2*n+1]+a)));if(0!==y){do{for(o=d-1;0===t.bl_count[o];)o--;t.bl_count[o]--,t.bl_count[o+1]+=2,t.bl_count[d]--,y-=2}while(y>0);for(o=d;0!==o;o--)for(n=t.bl_count[o];0!==n;)(i=t.heap[--r])>c||(u[2*i+1]!==o&&(t.opt_len+=(o-u[2*i+1])*u[2*i],u[2*i+1]=o),n--)}}(t,e),T(o,c,t.bl_count)}function B(t,e,r){var n,i,o=-1,a=e[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=e[2*(n+1)+1],++s<u&&i===a||(s<c?t.bl_tree[2*i]+=s:0!==i?(i!==o&&t.bl_tree[2*i]++,t.bl_tree[32]++):s<=10?t.bl_tree[34]++:t.bl_tree[36]++,s=0,o=i,0===a?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4))}function R(t,e,r){var n,i,o=-1,a=e[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),n=0;n<=r;n++)if(i=a,a=e[2*(n+1)+1],!(++s<u&&i===a)){if(s<c)do{S(t,i,t.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(S(t,i,t.bl_tree),s--),S(t,16,t.bl_tree),E(t,s-3,2)):s<=10?(S(t,17,t.bl_tree),E(t,s-3,3)):(S(t,18,t.bl_tree),E(t,s-11,7));s=0,o=i,0===a?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4)}}i(b);var N=!1;function j(t,e,r,i){E(t,0+(i?1:0),3),function(t,e,r){x(t),_(t,r),_(t,~r),n.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}(t,e,r)}e._tr_init=function(t){N||(function(){var t,e,r,n,i,u=new Array(16);for(r=0,n=0;n<28;n++)for(p[n]=r,t=0;t<1<<o[n];t++)h[r++]=n;for(h[r-1]=n,i=0,n=0;n<16;n++)for(b[n]=i,t=0;t<1<<a[n];t++)l[i++]=n;for(i>>=7;n<30;n++)for(b[n]=i<<7,t=0;t<1<<a[n]-7;t++)l[256+i++]=n;for(e=0;e<=15;e++)u[e]=0;for(t=0;t<=143;)c[2*t+1]=8,t++,u[8]++;for(;t<=255;)c[2*t+1]=9,t++,u[9]++;for(;t<=279;)c[2*t+1]=7,t++,u[7]++;for(;t<=287;)c[2*t+1]=8,t++,u[8]++;for(T(c,287,u),t=0;t<30;t++)f[2*t+1]=5,f[2*t]=k(t,5);d=new v(c,o,257,286,15),y=new v(f,a,0,30,15),g=new v(new Array(0),s,0,19,7)}(),N=!0),t.l_desc=new w(t.dyn_ltree,d),t.d_desc=new w(t.dyn_dtree,y),t.bl_desc=new w(t.bl_tree,g),t.bi_buf=0,t.bi_valid=0,O(t)},e._tr_stored_block=j,e._tr_flush_block=function(t,e,r,n){var i,o,a=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),L(t,t.l_desc),L(t,t.d_desc),a=function(t){var e;for(B(t,t.dyn_ltree,t.l_desc.max_code),B(t,t.dyn_dtree,t.d_desc.max_code),L(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*u[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),i=t.opt_len+3+7>>>3,(o=t.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==e?j(t,e,r,n):4===t.strategy||o===i?(E(t,2+(n?1:0),3),I(t,c,f)):(E(t,4+(n?1:0),3),function(t,e,r,n){var i;for(E(t,e-257,5),E(t,r-1,5),E(t,n-4,4),i=0;i<n;i++)E(t,t.bl_tree[2*u[i]+1],3);R(t,t.dyn_ltree,e-1),R(t,t.dyn_dtree,r-1)}(t,t.l_desc.max_code+1,t.d_desc.max_code+1,a+1),I(t,t.dyn_ltree,t.dyn_dtree)),O(t),n&&x(t)},e._tr_tally=function(t,e,r){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(h[r]+256+1)]++,t.dyn_dtree[2*m(e)]++),t.last_lit===t.lit_bufsize-1},e._tr_align=function(t){E(t,2,3),S(t,256,c),function(t){16===t.bi_valid?(_(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},4442:t=>{t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},6578:t=>{t.exports=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]},5606:t=>{var e,r,n=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(r){try{return e.call(null,t,0)}catch(r){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var s,u=[],c=!1,f=-1;function l(){c&&s&&(c=!1,s.length?u=s.concat(u):f=-1,u.length&&h())}function h(){if(!c){var t=a(l);c=!0;for(var e=u.length;e;){for(s=u,u=[];++f<e;)s&&s[f].run();f=-1,e=u.length}s=null,c=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{return r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function d(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];u.push(new p(t,e)),1!==u.length||c||a(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=d,n.addListener=d,n.once=d,n.off=d,n.removeListener=d,n.removeAllListeners=d,n.emit=d,n.prependListener=d,n.prependOnceListener=d,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},3209:(t,e,r)=>{var n=r(5606),i=65536,o=r(2861).Buffer,a=r.g.crypto||r.g.msCrypto;a&&a.getRandomValues?t.exports=function(t,e){if(t>4294967295)throw new RangeError("requested too many random bytes");var r=o.allocUnsafe(t);if(t>0)if(t>i)for(var s=0;s<t;s+=i)a.getRandomValues(r.slice(s,s+i));else a.getRandomValues(r);return"function"==typeof e?n.nextTick((function(){e(null,r)})):r}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}},6011:(t,e,r)=>{var n=r(8287).Buffer,i=r(6698),o=r(4729),a=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],u=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],c=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],l=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<<e|t>>>32-e}function y(t,e,r,n,i,o,a,s){return d(t+(e^r^n)+o+a|0,s)+i|0}function g(t,e,r,n,i,o,a,s){return d(t+(e&r|~e&n)+o+a|0,s)+i|0}function b(t,e,r,n,i,o,a,s){return d(t+((e|~r)^n)+o+a|0,s)+i|0}function v(t,e,r,n,i,o,a,s){return d(t+(e&n|r&~n)+o+a|0,s)+i|0}function w(t,e,r,n,i,o,a,s){return d(t+(e^(r|~n))+o+a|0,s)+i|0}i(p,o),p.prototype._update=function(){for(var t=a,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,p=0|this._e,m=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,T=0;T<80;T+=1){var O,x;T<16?(O=y(r,n,i,o,p,t[s[T]],l[0],c[T]),x=w(m,_,E,S,k,t[u[T]],h[0],f[T])):T<32?(O=g(r,n,i,o,p,t[s[T]],l[1],c[T]),x=v(m,_,E,S,k,t[u[T]],h[1],f[T])):T<48?(O=b(r,n,i,o,p,t[s[T]],l[2],c[T]),x=b(m,_,E,S,k,t[u[T]],h[2],f[T])):T<64?(O=v(r,n,i,o,p,t[s[T]],l[3],c[T]),x=g(m,_,E,S,k,t[u[T]],h[3],f[T])):(O=w(r,n,i,o,p,t[s[T]],l[4],c[T]),x=y(m,_,E,S,k,t[u[T]],h[4],f[T])),r=p,p=o,o=d(i,10),i=n,n=O,m=k,k=S,S=d(E,10),E=_,_=x}var A=this._b+i+S|0;this._b=this._c+o+k|0,this._c=this._d+p+m|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=A},p.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=n.alloc?n.alloc(20):new n(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=p},2861:(t,e,r)=>{var n=r(8287),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function a(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},a.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},6897:(t,e,r)=>{var n=r(453),i=r(41),o=r(592)(),a=r(5795),s=r(9675),u=n("%Math.floor%");t.exports=function(t,e){if("function"!=typeof t)throw new s("`fn` is not a function");if("number"!=typeof e||e<0||e>4294967295||u(e)!==e)throw new s("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],n=!0,c=!0;if("length"in t&&a){var f=a(t,"length");f&&!f.configurable&&(n=!1),f&&!f.writable&&(c=!1)}return(n||c||!r)&&(o?i(t,"length",e,!0,!0):i(t,"length",e)),t}},392:(t,e,r)=>{var n=r(2861).Buffer;function i(t,e){this._block=n.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}i.prototype.update=function(t,e){"string"==typeof t&&(e=e||"utf8",t=n.from(t,e));for(var r=this._block,i=this._blockSize,o=t.length,a=this._len,s=0;s<o;){for(var u=a%i,c=Math.min(o-s,i-u),f=0;f<c;f++)r[u+f]=t[s+f];s+=c,(a+=c)%i==0&&this._update(r)}return this._len+=o,this},i.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},2802:(t,e,r)=>{var n=t.exports=function(t){t=t.toLowerCase();var e=n[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e};n.sha=r(7816),n.sha1=r(3737),n.sha224=r(6710),n.sha256=r(4107),n.sha384=r(2827),n.sha512=r(2890)},7816:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=r[l-3]^r[l-8]^r[l-14]^r[l-16];for(var h=0;h<80;++h){var p=~~(h/20),d=0|((e=n)<<5|e>>>27)+f(p,i,o,s)+u+r[h]+a[p];u=s,s=o,o=c(i),i=n,n=d}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},3737:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(t){return t<<5|t>>>27}function f(t){return t<<30|t>>>2}function l(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=(e=r[h-3]^r[h-8]^r[h-14]^r[h-16])<<1|e>>>31;for(var p=0;p<80;++p){var d=~~(p/20),y=c(n)+l(d,i,o,s)+u+r[p]+a[d]|0;u=s,s=o,o=f(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},6710:(t,e,r)=>{var n=r(6698),i=r(4107),o=r(392),a=r(2861).Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var t=a.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=u},4107:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function l(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function d(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(t){for(var e=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,s=0|this._e,u=0|this._f,y=0|this._g,g=0|this._h,b=0;b<16;++b)e[b]=t.readInt32BE(4*b);for(;b<64;++b)e[b]=d(e[b-2])+e[b-7]+p(e[b-15])+e[b-16]|0;for(var v=0;v<64;++v){var w=g+h(s)+c(s,u,y)+a[v]+e[v]|0,m=l(r)+f(r,n,i)|0;g=y,y=u,u=s,s=o+w|0,o=i,i=n,n=r,r=w+m|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=u+this._f|0,this._g=y+this._g|0,this._h=g+this._h|0},u.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=u},2827:(t,e,r)=>{var n=r(6698),i=r(2890),o=r(392),a=r(2861).Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var t=a.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=u},2890:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function l(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function g(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function b(t,e){return t>>>0<e>>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,v=0|this._gh,w=0|this._hh,m=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,T=0|this._fl,O=0|this._gl,x=0|this._hl,A=0;A<32;A+=2)e[A]=t.readInt32BE(4*A),e[A+1]=t.readInt32BE(4*A+4);for(;A<160;A+=2){var P=e[A-30],I=e[A-30+1],L=p(P,I),B=d(I,P),R=y(P=e[A-4],I=e[A-4+1]),N=g(I,P),j=e[A-14],U=e[A-14+1],C=e[A-32],F=e[A-32+1],M=B+U|0,D=L+j+b(M,B)|0;D=(D=D+R+b(M=M+N|0,N)|0)+C+b(M=M+F|0,F)|0,e[A]=D,e[A+1]=M}for(var H=0;H<160;H+=2){D=e[H],M=e[H+1];var K=f(r,n,i),G=f(m,_,E),W=l(r,m),V=l(m,r),q=h(s,k),z=h(k,s),Y=a[H],X=a[H+1],Z=c(s,u,v),$=c(k,T,O),J=x+z|0,Q=w+q+b(J,x)|0;Q=(Q=(Q=Q+Z+b(J=J+$|0,$)|0)+Y+b(J=J+X|0,X)|0)+D+b(J=J+M|0,M)|0;var tt=V+G|0,et=W+K+b(tt,V)|0;w=v,x=O,v=u,O=T,u=s,T=k,s=o+Q+b(k=S+J|0,S)|0,o=i,S=E,i=n,E=_,n=r,_=m,r=Q+et+b(m=J+tt|0,J)|0}this._al=this._al+m|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+T|0,this._gl=this._gl+O|0,this._hl=this._hl+x|0,this._ah=this._ah+r+b(this._al,m)|0,this._bh=this._bh+n+b(this._bl,_)|0,this._ch=this._ch+i+b(this._cl,E)|0,this._dh=this._dh+o+b(this._dl,S)|0,this._eh=this._eh+s+b(this._el,k)|0,this._fh=this._fh+u+b(this._fl,T)|0,this._gh=this._gh+v+b(this._gl,O)|0,this._hh=this._hh+w+b(this._hl,x)|0},u.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=u},8310:(t,e,r)=>{t.exports=i;var n=r(7007).EventEmitter;function i(){n.call(this)}r(6698)(i,n),i.Readable=r(6891),i.Writable=r(1999),i.Duplex=r(8101),i.Transform=r(9083),i.PassThrough=r(3681),i.finished=r(4257),i.pipeline=r(5267),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,t.end())}function u(){a||(a=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",c),t.on("error",c),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t}},2463:t=>{var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(t,e,r){var i,o,a;if("string"==typeof e&&(a="not ",e.substr(0,4)===a)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))o="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var s=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+1>t.length)&&-1!==t.indexOf(".",r)}(t)?"property":"argument";o='The "'.concat(t,'" ').concat(s," ").concat(i," ").concat(n(e,"type"))}return o+". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},8101:(t,e,r)=>{var n=r(5606),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var o=r(6891),a=r(1999);r(6698)(f,o);for(var s=i(a.prototype),u=0;u<s.length;u++){var c=s[u];f.prototype[c]||(f.prototype[c]=a.prototype[c])}function f(t){if(!(this instanceof f))return new f(t);o.call(this,t),a.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},3681:(t,e,r)=>{t.exports=i;var n=r(9083);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(6698)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},6891:(t,e,r)=>{var n,i=r(5606);t.exports=T,T.ReadableState=k,r(7007).EventEmitter;var o,a=function(t,e){return t.listeners(e).length},s=r(1396),u=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(7199);o=f&&f.debuglog?f.debuglog("stream"):function(){};var l,h,p,d=r(1766),y=r(4347),g=r(6644).getHighWaterMark,b=r(2463).F,v=b.ERR_INVALID_ARG_TYPE,w=b.ERR_STREAM_PUSH_AFTER_EOF,m=b.ERR_METHOD_NOT_IMPLEMENTED,_=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(T,s);var E=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function k(t,e,i){n=n||r(8101),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",i),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=r(3516).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function T(t){if(n=n||r(8101),!(this instanceof T))return new T(t);var e=this instanceof n;this._readableState=new k(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function O(t,e,r,n,i){o("readableAddChunk",e);var a,s=t._readableState;if(null===e)s.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?I(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,L(t)))}}(t,s);else if(i||(a=function(t,e){var r,n;return n=e,u.isBuffer(n)||n instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],e)),r}(s,e)),a)E(t,a);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)s.endEmitted?E(t,new _):x(t,s,e,!0);else if(s.ended)E(t,new w);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?x(t,s,e,!1):B(t,s)):x(t,s,e,!1)}else n||(s.reading=!1,B(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function x(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&I(t)),B(t,e)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),T.prototype.destroy=y.destroy,T.prototype._undestroy=y.undestroy,T.prototype._destroy=function(t,e){e(t)},T.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=u.from(t,e),e=""),r=!0),O(this,t,e,!1,r)},T.prototype.unshift=function(t){return O(this,t,null,!0,!1)},T.prototype.isPaused=function(){return!1===this._readableState.flowing},T.prototype.setEncoding=function(t){l||(l=r(3516).I);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var A=1073741824;function P(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=A?t=A:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function I(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(L,t))}function L(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,C(t)}function B(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(R,t,e))}function R(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function N(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){o("readable nexttick read 0"),t.read(0)}function U(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function F(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function M(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}T.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):I(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&M(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=P(r,e))),null===(n=t>0?F(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&M(this)),null!==n&&this.emit("data",n),n},T.prototype._read=function(t){E(this,new m("_read()"))},T.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o("pipe count=%d opts=%j",n.pipesCount,e);var s=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(s):r.once("end",s),t.on("unpipe",(function e(i,a){o("onunpipe"),i===r&&a&&!1===a.hasUnpiped&&(a.hasUnpiped=!0,o("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",l),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||c())}));var c=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",c);var f=!1;function l(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==H(n.pipes,t))&&!f&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===a(t,"error")&&E(t,e)}function p(){t.removeListener("finish",d),y()}function d(){o("onfinish"),t.removeListener("close",p),y()}function y(){o("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),t},T.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=H(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},T.prototype.on=function(t,e){var r=s.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,o("on readable",n.length,n.reading),n.length?I(this):n.reading||i.nextTick(j,this))),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(N,this),r},T.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(N,this),e},T.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(U,t,e))}(this,t)),t.paused=!1,this},T.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",(function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<S.length;a++)t.on(S[a],this.emit.bind(this,S[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(T.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(5034)),h(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),T._fromList=F,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(T.from=function(t,e){return void 0===p&&(p=r(968)),p(T,t,e)})},9083:(t,e,r)=>{t.exports=f;var n=r(2463).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(8101);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function f(t){if(!(this instanceof f))return new f(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush((function(e,r){h(t,e,r)}))}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new s;if(t._transformState.transforming)throw new a;return t.push(null)}r(6698)(f,u),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,r){r(new i("_transform()"))},f.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},f.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},f.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},1999:(t,e,r)=>{var n,i=r(5606);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=T,T.WritableState=k;var a,s={deprecate:r(4643)},u=r(1396),c=r(8287).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(4347),h=r(6644).getHighWaterMark,p=r(2463).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,g=p.ERR_MULTIPLE_CALLBACK,b=p.ERR_STREAM_CANNOT_PIPE,v=p.ERR_STREAM_DESTROYED,w=p.ERR_STREAM_NULL_VALUES,m=p.ERR_STREAM_WRITE_AFTER_END,_=p.ERR_UNKNOWN_ENCODING,E=l.errorOrDestroy;function S(){}function k(t,e,a){n=n||r(8101),t=t||{},"boolean"!=typeof a&&(a=e instanceof n),this.objectMode=!!t.objectMode,a&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",a),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,o){--e.pendingcb,r?(i.nextTick(o,n),i.nextTick(L,t,e),t._writableState.errorEmitted=!0,E(t,n)):(o(n),t._writableState.errorEmitted=!0,E(t,n),L(t,e))}(t,r,n,e,o);else{var a=P(r)||t.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||A(t,r),n?i.nextTick(x,t,r,a,o):x(t,r,a,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function T(t){var e=this instanceof(n=n||r(8101));if(!e&&!a.call(T,this))return new T(t);this._writableState=new k(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),u.call(this)}function O(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new v("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function x(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),L(t,e)}function A(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),a=e.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,O(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,l=r.callback;if(O(t,e,!1,e.objectMode?1:c.length,c,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function P(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function I(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit("prefinish"),L(t,e)}))}function L(t,e){var r=P(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(I,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(6698)(T,u),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===T&&t&&t._writableState instanceof k}})):a=function(t){return t instanceof this},T.prototype.pipe=function(){E(this,new b)},T.prototype.write=function(t,e,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof f);return s&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),s?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(t,e){var r=new m;E(t,r),i.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var o;return null===r?o=new w:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(E(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,a=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=e.objectMode?1:n.length;e.length+=s;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else O(t,e,!1,s,n,i,o);return u}(this,o,s,t,e,r)),a},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||A(this,t))},T.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new _(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(t,e,r){r(new y("_write()"))},T.prototype._writev=null,T.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,L(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),T.prototype.destroy=l.destroy,T.prototype._undestroy=l.undestroy,T.prototype._destroy=function(t,e){e(t)}},5034:(t,e,r)=>{var n,i=r(5606);function o(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var a=r(4257),s=Symbol("lastResolve"),u=Symbol("lastReject"),c=Symbol("error"),f=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[s];if(null!==e){var r=t[p].read();null!==r&&(t[l]=null,t[s]=null,t[u]=null,e(d(r,!1)))}}function g(t){i.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[f])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise((function(e,r){i.nextTick((function(){t[c]?r(t[c]):e(d(void 0,!0))}))}));var r,n=this[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[f]?r(d(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[h])}return this[l]=r,r}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var t=this;return new Promise((function(e,r){t[p].destroy(null,(function(t){t?r(t):e(d(void 0,!0))}))}))})),n),b);t.exports=function(t){var e,r=Object.create(v,(o(e={},p,{value:t,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,f,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[l]=null,r[s]=null,r[u]=null,t(d(n,!1))):(r[s]=t,r[u]=e)},writable:!0}),e));return r[l]=null,a(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[l]=null,r[s]=null,r[u]=null,e(t)),void(r[c]=t)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[u]=null,n(d(void 0,!0))),r[f]=!0})),t.on("readable",g.bind(null,r)),r}},1766:(t,e,r)=>{function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e,r){return(e=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var u=r(8287).Buffer,c=r(3779).inspect,f=c&&c.custom||"inspect";function l(t,e,r){u.prototype.copy.call(t,e,r)}t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r;return e=t,r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return u.alloc(0);for(var e=u.allocUnsafe(t>>>0),r=this.head,n=0;r;)l(r.data,e,n),n+=r.data.length,r=r.next;return e}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=u.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:f,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},4347:(t,e,r)=>{var n=r(5606);function i(t,e){a(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(a,this,t)):n.nextTick(a,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,t)):n.nextTick(i,r,t):e?(n.nextTick(o,r),e(t)):n.nextTick(o,r)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},4257:(t,e,r)=>{var n=r(2463).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var a=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||f()},c=e._writableState&&e._writableState.finished,f=function(){s=!1,c=!0,a||o.call(e)},l=e._readableState&&e._readableState.endEmitted,h=function(){a=!1,l=!0,s||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!l?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):s&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",f),e.on("abort",d),e.req?y():e.on("request",y)):s&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",f),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",f),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",f),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},968:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},5267:(t,e,r)=>{var n,i=r(2463).F,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function s(t){if(t)throw t}function u(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var f,l=function(t){return t.length?"function"!=typeof t[t.length-1]?s:t.pop():s}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var h=e.map((function(t,i){var o=i<e.length-1;return function(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var s=!1;t.on("close",(function(){s=!0})),void 0===n&&(n=r(4257)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);s=!0,o()}));var u=!1;return function(e){if(!s&&!u)return u=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new a("pipe"))}}(t,o,i>0,(function(t){f||(f=t),t&&h.forEach(u),o||(h.forEach(u),l(f))}))}));return e.reduce(c)}},6644:(t,e,r)=>{var n=r(2463).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},1396:(t,e,r)=>{t.exports=r(7007).EventEmitter},3516:(t,e,r)=>{var n=r(2861).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=c,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=f,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.I=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},o.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var i=a(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},9579:(t,e,r)=>{var n=r(8287).Buffer,i=n.isEncoding||function(t){switch(t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},o=e.I=function(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),function(t){if(t&&!i(t))throw new Error("Unknown encoding: "+t)}(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=s;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=u;break;default:return void(this.write=a)}this.charBuffer=new n(6),this.charReceived=0,this.charLength=0};function a(t){return t.toString(this.encoding)}function s(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function u(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}o.prototype.write=function(t){for(var e="";this.charLength;){var r=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";if(t=t.slice(r,t.length),!((n=(e=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(e.length-1))>=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var n,i=t.length;if(this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),i=(e+=t.toString(this.encoding,0,i)).length-1,(n=e.charCodeAt(i))>=55296&&n<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,i)}return e},o.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var r=t[t.length-e];if(1==e&&r>>5==6){this.charLength=2;break}if(e<=2&&r>>4==14){this.charLength=3;break}if(e<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=e},o.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;e+=n.slice(0,r).toString(i)}return e}},1061:(t,e,r)=>{var n=r(2113);function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function a(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function s(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?"Array":t&&n.Object(t)?"Object":void 0!==t?t:""}function u(t,e,r){var i=function(t){return n.Function(t)?"":n.String(t)?JSON.stringify(t):t&&n.Object(t)?"":t}(e);return"Expected "+s(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function c(t,e,r){r=r||o(e),this.message=u(t,e,r),a(this,c),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),u('property "'+s(r)+o+s(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',a(this,c),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,f.prototype=Object.create(Error.prototype),f.prototype.constructor=c,t.exports={TfTypeError:c,TfPropertyTypeError:f,tfCustomError:function(t,e){return new c(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+"."+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof c&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),a(t),t},tfJSON:s,getValueTypeName:o}},9542:(t,e,r)=>{var n=r(8287).Buffer,i=r(2113),o=r(1061);function a(t){return n.isBuffer(t)}function s(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function u(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var c=u.bind(null,i.Array),f=u.bind(null,a),l=u.bind(null,s),h=u.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:c,Buffer:a,BufferN:f,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:s,HexN:l,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n<e}return r=r||i.Number,n.toJSON=function(){return`${r.toJSON()} between [${t}, ${e}]`},n},StringN:h,UInt8:function(t){return(255&t)===t},UInt16:function(t){return(65535&t)===t},UInt32:function(t){return t>>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},8676:(t,e,r)=>{var n=r(1061),i=r(2113),o=n.tfJSON,a=n.TfTypeError,s=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==e.minLength&&r.length<e.minLength)&&!(void 0!==e.maxLength&&r.length>e.maxLength)&&(void 0===e.length||r.length===e.length)&&r.every((function(e,r){try{return h(t,e,n)}catch(t){throw u(t,r)}}))}return t=l(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=l(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&h(e,o,n)}catch(t){throw u(t,o,"key")}try{var a=r[o];h(t,a,n)}catch(t){throw u(t,o)}}return!0}return t=l(t),e&&(e=l(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=l(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e)h(e[n],t[n],r)}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new s(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.some((function(t){try{return h(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.every((function(t){try{return h(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return!i.Nil(e)&&!i.Nil(e.length)&&(!r||e.length===t.length)&&t.every((function(t,n){try{return h(t,e[n],r)}catch(t){throw u(t,n)}}))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function l(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new a(n||t,e)}return h(l(t),e,r)}for(var p in f.oneOf=f.anyOf,i)h[p]=i[p];for(p in f)h[p]=f[p];var d=r(9542);for(p in d)h[p]=d[p];h.compile=l,h.TfTypeError=a,h.TfPropertyTypeError=s,t.exports=h},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},4643:(t,e,r)=>{function n(t){try{if(!r.g.localStorage)return!1}catch(t){return!1}var e=r.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}},1135:t=>{t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},9032:(t,e,r)=>{var n=r(7244),i=r(8184),o=r(5767),a=r(5680);function s(t){return t.call.bind(t)}var u="undefined"!=typeof BigInt,c="undefined"!=typeof Symbol,f=s(Object.prototype.toString),l=s(Number.prototype.valueOf),h=s(String.prototype.valueOf),p=s(Boolean.prototype.valueOf);if(u)var d=s(BigInt.prototype.valueOf);if(c)var y=s(Symbol.prototype.valueOf);function g(t,e){if("object"!=typeof t)return!1;try{return e(t),!0}catch(t){return!1}}function b(t){return"[object Map]"===f(t)}function v(t){return"[object Set]"===f(t)}function w(t){return"[object WeakMap]"===f(t)}function m(t){return"[object WeakSet]"===f(t)}function _(t){return"[object ArrayBuffer]"===f(t)}function E(t){return"undefined"!=typeof ArrayBuffer&&(_.working?_(t):t instanceof ArrayBuffer)}function S(t){return"[object DataView]"===f(t)}function k(t){return"undefined"!=typeof DataView&&(S.working?S(t):t instanceof DataView)}e.isArgumentsObject=n,e.isGeneratorFunction=i,e.isTypedArray=a,e.isPromise=function(t){return"undefined"!=typeof Promise&&t instanceof Promise||null!==t&&"object"==typeof t&&"function"==typeof t.then&&"function"==typeof t.catch},e.isArrayBufferView=function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):a(t)||k(t)},e.isUint8Array=function(t){return"Uint8Array"===o(t)},e.isUint8ClampedArray=function(t){return"Uint8ClampedArray"===o(t)},e.isUint16Array=function(t){return"Uint16Array"===o(t)},e.isUint32Array=function(t){return"Uint32Array"===o(t)},e.isInt8Array=function(t){return"Int8Array"===o(t)},e.isInt16Array=function(t){return"Int16Array"===o(t)},e.isInt32Array=function(t){return"Int32Array"===o(t)},e.isFloat32Array=function(t){return"Float32Array"===o(t)},e.isFloat64Array=function(t){return"Float64Array"===o(t)},e.isBigInt64Array=function(t){return"BigInt64Array"===o(t)},e.isBigUint64Array=function(t){return"BigUint64Array"===o(t)},b.working="undefined"!=typeof Map&&b(new Map),e.isMap=function(t){return"undefined"!=typeof Map&&(b.working?b(t):t instanceof Map)},v.working="undefined"!=typeof Set&&v(new Set),e.isSet=function(t){return"undefined"!=typeof Set&&(v.working?v(t):t instanceof Set)},w.working="undefined"!=typeof WeakMap&&w(new WeakMap),e.isWeakMap=function(t){return"undefined"!=typeof WeakMap&&(w.working?w(t):t instanceof WeakMap)},m.working="undefined"!=typeof WeakSet&&m(new WeakSet),e.isWeakSet=function(t){return m(t)},_.working="undefined"!=typeof ArrayBuffer&&_(new ArrayBuffer),e.isArrayBuffer=E,S.working="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView&&S(new DataView(new ArrayBuffer(1),0,1)),e.isDataView=k;var T="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:void 0;function O(t){return"[object SharedArrayBuffer]"===f(t)}function x(t){return void 0!==T&&(void 0===O.working&&(O.working=O(new T)),O.working?O(t):t instanceof T)}function A(t){return g(t,l)}function P(t){return g(t,h)}function I(t){return g(t,p)}function L(t){return u&&g(t,d)}function B(t){return c&&g(t,y)}e.isSharedArrayBuffer=x,e.isAsyncFunction=function(t){return"[object AsyncFunction]"===f(t)},e.isMapIterator=function(t){return"[object Map Iterator]"===f(t)},e.isSetIterator=function(t){return"[object Set Iterator]"===f(t)},e.isGeneratorObject=function(t){return"[object Generator]"===f(t)},e.isWebAssemblyCompiledModule=function(t){return"[object WebAssembly.Module]"===f(t)},e.isNumberObject=A,e.isStringObject=P,e.isBooleanObject=I,e.isBigIntObject=L,e.isSymbolObject=B,e.isBoxedPrimitive=function(t){return A(t)||P(t)||I(t)||L(t)||B(t)},e.isAnyArrayBuffer=function(t){return"undefined"!=typeof Uint8Array&&(E(t)||x(t))},["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(t){Object.defineProperty(e,t,{enumerable:!1,value:function(){throw new Error(t+" is not supported in userland")}})}))},537:(t,e,r)=>{var n=r(5606),i=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n<e.length;n++)r[e[n]]=Object.getOwnPropertyDescriptor(t,e[n]);return r},o=/%[sdj%]/g;e.format=function(t){if(!w(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(c(arguments[r]));return e.join(" ")}r=1;for(var n=arguments,i=n.length,a=String(t).replace(o,(function(t){if("%%"===t)return"%";if(r>=i)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}})),s=n[r];r<i;s=n[++r])b(s)||!E(s)?a+=" "+s:a+=" "+c(s);return a},e.deprecate=function(t,r){if(void 0!==n&&!0===n.noDeprecation)return t;if(void 0===n)return function(){return e.deprecate(t,r).apply(this,arguments)};var i=!1;return function(){if(!i){if(n.throwDeprecation)throw new Error(r);n.traceDeprecation?console.trace(r):console.error(r),i=!0}return t.apply(this,arguments)}};var a={},s=/^$/;if(n.env.NODE_DEBUG){var u=n.env.NODE_DEBUG;u=u.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+u+"$","i")}function c(t,r){var n={seen:[],stylize:l};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(r)?n.showHidden=r:r&&e._extend(n,r),m(n.showHidden)&&(n.showHidden=!1),m(n.depth)&&(n.depth=2),m(n.colors)&&(n.colors=!1),m(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=f),h(n,t,n.depth)}function f(t,e){var r=c.styles[e];return r?"["+c.colors[r][0]+"m"+t+"["+c.colors[r][1]+"m":t}function l(t,e){return t}function h(t,r,n){if(t.customInspect&&r&&T(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return w(i)||(i=h(t,i,n)),i}var o=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(w(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return v(e)?t.stylize(""+e,"number"):g(e)?t.stylize(""+e,"boolean"):b(e)?t.stylize("null","null"):void 0}(t,r);if(o)return o;var a=Object.keys(r),s=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(r)),k(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return p(r);if(0===a.length){if(T(r)){var u=r.name?": "+r.name:"";return t.stylize("[Function"+u+"]","special")}if(_(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(S(r))return t.stylize(Date.prototype.toString.call(r),"date");if(k(r))return p(r)}var c,f="",l=!1,E=["{","}"];return y(r)&&(l=!0,E=["[","]"]),T(r)&&(f=" [Function"+(r.name?": "+r.name:"")+"]"),_(r)&&(f=" "+RegExp.prototype.toString.call(r)),S(r)&&(f=" "+Date.prototype.toUTCString.call(r)),k(r)&&(f=" "+p(r)),0!==a.length||l&&0!=r.length?n<0?_(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),c=l?function(t,e,r,n,i){for(var o=[],a=0,s=e.length;a<s;++a)P(e,String(a))?o.push(d(t,e,r,n,String(a),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(d(t,e,r,n,i,!0))})),o}(t,r,n,s,a):a.map((function(e){return d(t,r,n,s,e,l)})),t.seen.pop(),function(t,e,r){return t.reduce((function(t,e){return e.indexOf("\n"),t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}(c,f,E)):E[0]+f+E[1]}function p(t){return"["+Error.prototype.toString.call(t)+"]"}function d(t,e,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(s=t.stylize("[Setter]","special")),P(n,i)||(a="["+i+"]"),s||(t.seen.indexOf(u.value)<0?(s=b(r)?h(t,u.value,null):h(t,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map((function(t){return" "+t})).join("\n").slice(2):"\n"+s.split("\n").map((function(t){return" "+t})).join("\n")):s=t.stylize("[Circular]","special")),m(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.slice(1,-1),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+s}function y(t){return Array.isArray(t)}function g(t){return"boolean"==typeof t}function b(t){return null===t}function v(t){return"number"==typeof t}function w(t){return"string"==typeof t}function m(t){return void 0===t}function _(t){return E(t)&&"[object RegExp]"===O(t)}function E(t){return"object"==typeof t&&null!==t}function S(t){return E(t)&&"[object Date]"===O(t)}function k(t){return E(t)&&("[object Error]"===O(t)||t instanceof Error)}function T(t){return"function"==typeof t}function O(t){return Object.prototype.toString.call(t)}function x(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(t=t.toUpperCase(),!a[t])if(s.test(t)){var r=n.pid;a[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else a[t]=function(){};return a[t]},e.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.types=r(9032),e.isArray=y,e.isBoolean=g,e.isNull=b,e.isNullOrUndefined=function(t){return null==t},e.isNumber=v,e.isString=w,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=_,e.types.isRegExp=_,e.isObject=E,e.isDate=S,e.types.isDate=S,e.isError=k,e.types.isNativeError=k,e.isFunction=T,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(1135);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",function(){var t=new Date,e=[x(t.getHours()),x(t.getMinutes()),x(t.getSeconds())].join(":");return[t.getDate(),A[t.getMonth()],e].join(" ")}(),e.format.apply(e,arguments))},e.inherits=r(6698),e._extend=function(t,e){if(!e||!E(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var I="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function L(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(I&&t[I]){var e;if("function"!=typeof(e=t[I]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,I,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise((function(t,n){e=t,r=n})),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push((function(t,n){t?r(t):e(n)}));try{t.apply(this,i)}catch(t){r(t)}return n}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),I&&Object.defineProperty(e,I,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,i(t))},e.promisify.custom=I,e.callbackify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');function e(){for(var e=[],r=0;r<arguments.length;r++)e.push(arguments[r]);var i=e.pop();if("function"!=typeof i)throw new TypeError("The last argument must be of type Function");var o=this,a=function(){return i.apply(o,arguments)};t.apply(this,e).then((function(t){n.nextTick(a.bind(null,null,t))}),(function(t){n.nextTick(L.bind(null,t,a))}))}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),Object.defineProperties(e,i(t)),e}},5767:(t,e,r)=>{var n=r(2682),i=r(9209),o=r(487),a=r(6556),s=r(5795),u=a("Object.prototype.toString"),c=r(9092)(),f="undefined"==typeof globalThis?r.g:globalThis,l=i(),h=a("String.prototype.slice"),p=Object.getPrototypeOf,d=a("Array.prototype.indexOf",!0)||function(t,e){for(var r=0;r<t.length;r+=1)if(t[r]===e)return r;return-1},y={__proto__:null};n(l,c&&s&&p?function(t){var e=new f[t];if(Symbol.toStringTag in e){var r=p(e),n=s(r,Symbol.toStringTag);if(!n){var i=p(r);n=s(i,Symbol.toStringTag)}y["$"+t]=o(n.get)}}:function(t){var e=new f[t],r=e.slice||e.set;r&&(y["$"+t]=o(r))}),t.exports=function(t){if(!t||"object"!=typeof t)return!1;if(!c){var e=h(u(t),8,-1);return d(l,e)>-1?e:"Object"===e&&function(t){var e=!1;return n(y,(function(r,n){if(!e)try{r(t),e=h(n,1)}catch(t){}})),e}(t)}return s?function(t){var e=!1;return n(y,(function(r,n){if(!e)try{"$"+r(t)===n&&(e=h(n,1))}catch(t){}})),e}(t):null}},8460:()=>{},2382:()=>{},3779:()=>{},7199:()=>{},9209:(t,e,r)=>{var n=r(6578),i="undefined"==typeof globalThis?r.g:globalThis;t.exports=function(){for(var t=[],e=0;e<n.length;e++)"function"==typeof i[n[e]]&&(t[t.length]=n[e]);return t}}},n={};function i(t){var e=n[t];if(void 0!==e)return e.exports;var o=n[t]={exports:{}};return r[t](o,o.exports,i),o.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var o=Object.create(null);i.r(o);var a={};t=t||[null,e({}),e([]),e(e)];for(var s=2&n&&r;"object"==typeof s&&!~t.indexOf(s);s=e(s))Object.getOwnPropertyNames(s).forEach((t=>a[t]=()=>r[t]));return a.default=()=>r,i.d(o,a),o},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};i.d(o,{_v:()=>Hg,y3:()=>Ug,Z1:()=>Oh,pV:()=>_p,iy:()=>xf,vU:()=>xg,dy:()=>Zg,gd:()=>Of,z2:()=>Bf,LC:()=>Dh,V5:()=>Lg,fI:()=>Vg,G7:()=>rd,p9:()=>Cg,GF:()=>Hc,nU:()=>Dp,wf:()=>p,gf:()=>Kp,rt:()=>Jh,P8:()=>Gp,vg:()=>Yc,nr:()=>Pb,ry:()=>gd,z4:()=>nf,qT:()=>Wd,t0:()=>cb,Jf:()=>gb,kd:()=>Ec,eA:()=>wv,no:()=>cv,o4:()=>dv,YV:()=>kc,O5:()=>_c,cC:()=>ty,Wj:()=>Ic,Z4:()=>jh,pp:()=>Fh,d6:()=>Nh,p6:()=>Ch,iV:()=>Uh,gh:()=>Mh,Bc:()=>sy,TG:()=>yf,LL:()=>Ev,gK:()=>hv,PE:()=>bv,ev:()=>Bp,Go:()=>Ab,IB:()=>_f,rl:()=>Uy,c1:()=>_b,Y_:()=>qp,yo:()=>Xy,Ko:()=>Tv,pe:()=>uv,ho:()=>kv,_l:()=>fg,QS:()=>mv,Bm:()=>fv,W_:()=>yv,Hu:()=>og,Mg:()=>ag,$v:()=>Sv,mt:()=>pv,lJ:()=>vv,ih:()=>Wp,AT:()=>xh,AS:()=>qh,aw:()=>Id,tm:()=>Op,Qc:()=>Th,dF:()=>my,Wb:()=>zl,D_:()=>Hp,aS:()=>Gl,_3:()=>ch,p0:()=>Ph,Rt:()=>Bh,ZO:()=>Ah,BI:()=>Lh,MS:()=>Ih,ct:()=>Rh,A9:()=>xb,V$:()=>Ob,xc:()=>Kb,Gc:()=>_v,zM:()=>lv,c:()=>gv,uW:()=>Up,OH:()=>ev,sG:()=>rv,jz:()=>zp,hL:()=>Yp,$7:()=>a,rE:()=>s});var a={};i.r(a),i.d(a,{ABICoder:()=>Hg,ABIDataTypes:()=>Ug,ADDRESS_BYTE_LENGTH:()=>Oh,Address:()=>_p,AddressGenerator:()=>xf,AddressMap:()=>xg,AddressSet:()=>Zg,AddressTypes:()=>Of,AddressVerificator:()=>Bf,BOOLEAN_BYTE_LENGTH:()=>Dh,BinaryReader:()=>Lg,BinaryWriter:()=>Vg,BitcoinUtils:()=>rd,BufferHelper:()=>Cg,CalldataGenerator:()=>Hc,ChainId:()=>Dp,Compressor:()=>p,Consensus:()=>Kp,ContractAddress:()=>Jh,ContractBaseMetadata:()=>Gp,CustomGenerator:()=>Yc,CustomKeypair:()=>Pb,CustomScriptTransaction:()=>gd,DeploymentGenerator:()=>nf,DeploymentTransaction:()=>Wd,DeterministicMap:()=>cb,DeterministicSet:()=>gb,EcKeyPair:()=>Ec,FACTORY_ADDRESS_FRACTAL:()=>wv,FACTORY_ADDRESS_REGTEST:()=>cv,FACTORY_ADDRESS_TESTNET:()=>dv,FeatureOpCodes:()=>kc,Features:()=>_c,FundingTransaction:()=>ty,Generator:()=>Ic,I128_BYTE_LENGTH:()=>jh,I16_BYTE_LENGTH:()=>Fh,I256_BYTE_LENGTH:()=>Nh,I32_BYTE_LENGTH:()=>Ch,I64_BYTE_LENGTH:()=>Uh,I8_BYTE_LENGTH:()=>Mh,InteractionTransaction:()=>sy,LegacyCalldataGenerator:()=>yf,MOTO_ADDRESS_FRACTAL:()=>Ev,MOTO_ADDRESS_REGTEST:()=>hv,MOTO_ADDRESS_TESTNET:()=>bv,MessageSigner:()=>Bp,MessageType:()=>Ab,MultiSignGenerator:()=>_f,MultiSignTransaction:()=>Uy,NetEvent:()=>_b,OPNetConsensusConfig:()=>qp,OPNetLimitedProvider:()=>Xy,OPNetMetadata:()=>Tv,OPNetNetwork:()=>uv,OPNetTokenAddressManager:()=>kv,P2TR_MS:()=>fg,POOL_ADDRESS_FRACTAL:()=>mv,POOL_ADDRESS_REGTEST:()=>fv,POOL_ADDRESS_TESTNET:()=>yv,PSBTTypes:()=>og,PsbtTransaction:()=>ag,ROUTER_ADDRESS_FRACTAL:()=>Sv,ROUTER_ADDRESS_REGTEST:()=>pv,ROUTER_ADDRESS_TESTNET:()=>vv,RoswellConsensus:()=>Wp,SELECTOR_BYTE_LENGTH:()=>xh,Secp256k1PointDeriver:()=>qh,SharedInteractionTransaction:()=>Id,TapscriptVerificator:()=>Op,TransactionBuilder:()=>Th,TransactionFactory:()=>my,TransactionSequence:()=>zl,TransactionType:()=>Hp,TweakedSigner:()=>Gl,TweakedTransaction:()=>ch,U128_BYTE_LENGTH:()=>Ph,U16_BYTE_LENGTH:()=>Bh,U256_BYTE_LENGTH:()=>Ah,U32_BYTE_LENGTH:()=>Lh,U64_BYTE_LENGTH:()=>Ih,U8_BYTE_LENGTH:()=>Rh,UnisatChainType:()=>xb,UnisatNetwork:()=>Ob,UnisatSigner:()=>Kb,WBTC_ADDRESS_FRACTAL:()=>_v,WBTC_ADDRESS_REGTEST:()=>lv,WBTC_ADDRESS_TESTNET:()=>gv,Wallet:()=>Up,XverseNetwork:()=>ev,XverseSigner:()=>rv,currentConsensus:()=>zp,currentConsensusConfig:()=>Yp,version:()=>s});var s="1.2.1",u=i(8559),c=i.n(u);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 l(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,h(n.key),n)}}function h(t){var e=function(t){if("object"!=f(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==f(e)?e:e+""}var p=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&l(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"compress",value:function(e){return c().gzipSync(e,t.zlibOptions)}},{key:"decompress",value:function(e){return c().gunzipSync(e,t.zlibOptions)}}])}();!function(t,e,r){(e=h(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(p,"zlibOptions",{level:9,maxOutputLength:16777216});var d={526:(t,e)=>{e.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=s(t),a=o[0],u=o[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,u)),f=0,l=u>0?a-4:a;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],c[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[f++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,c=n-i;s<c;s+=a)o.push(u(t,s,s+a>c?c:s+a));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var i,o,a=[],s=e;s<n;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},343:(t,e)=>{e.p2=e.I=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(1&e)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=i(e)^n>>5}e=i(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=i(e)^31&n}return e}function a(t,e,r,n){let i=0,o=0;const a=(1<<r)-1,s=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],o+=e;o>=r;)o-=r,s.push(i>>o&a);if(n)o>0&&s.push(i<<r-o&a);else{if(o>=e)return"Excess padding";if(i<<r-o&a)return"Non-zero padding"}return s}function s(t){return a(t,8,5,!0)}function u(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e}function c(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function f(t){let e;function a(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const a=t.toLowerCase(),s=t.toUpperCase();if(t!==a&&t!==s)return"Mixed-case string "+t;const u=(t=a).lastIndexOf("1");if(-1===u)return"No separator character for "+t;if(0===u)return"Missing prefix for "+t;const c=t.slice(0,u),f=t.slice(u+1);if(f.length<6)return"Data too short";let l=o(c);if("string"==typeof l)return l;const h=[];for(let t=0;t<f.length;++t){const e=f.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;l=i(l)^r,t+6>=f.length||h.push(r)}return l!==e?"Invalid checksum for "+t:{prefix:c,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=a(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=a(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,a){if(a=a||90,t.length+7+n.length>a)throw new TypeError("Exceeds length limit");let s=o(t=t.toLowerCase());if("string"==typeof s)throw new Error(s);let u=t+"1";for(let t=0;t<n.length;++t){const e=n[t];if(e>>5)throw new Error("Non 5-bit word");s=i(s)^e,u+=r.charAt(e)}for(let t=0;t<6;++t)s=i(s);s^=e;for(let t=0;t<6;++t)u+=r.charAt(s>>5*(5-t)&31);return u},toWords:s,fromWordsUnsafe:u,fromWords:c}}e.I=f("bech32"),e.p2=f("bech32m")},863:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(457);function i(t,e,r){return n=>{if(t.has(n))return;const i=r.filter((t=>t.key.toString("hex")===n))[0];e.push(i),t.add(n)}}function o(t){return t.globalMap.unsignedTx}function a(t){const e=new Set;return t.forEach((t=>{const r=t.key.toString("hex");if(e.has(r))throw new Error("Combine: KeyValue Map keys should be unique");e.add(r)})),e}e.combine=function(t){const e=t[0],r=n.psbtToKeyVals(e),s=t.slice(1);if(0===s.length)throw new Error("Combine: Nothing to combine");const u=o(e);if(void 0===u)throw new Error("Combine: Self missing transaction");const c=a(r.globalKeyVals),f=r.inputKeyVals.map(a),l=r.outputKeyVals.map(a);for(const t of s){const e=o(t);if(void 0===e||!e.toBuffer().equals(u.toBuffer()))throw new Error("Combine: One of the Psbts does not have the same transaction.");const s=n.psbtToKeyVals(t);a(s.globalKeyVals).forEach(i(c,r.globalKeyVals,s.globalKeyVals)),s.inputKeyVals.map(a).forEach(((t,e)=>t.forEach(i(f[e],r.inputKeyVals[e],s.inputKeyVals[e])))),s.outputKeyVals.map(a).forEach(((t,e)=>t.forEach(i(l[e],r.outputKeyVals[e],s.outputKeyVals[e]))))}return n.psbtFromKeyVals(u,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},834:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.GlobalTypes.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+t.key.toString("hex"));if(79!==t.key.length||![2,3].includes(t.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+t.key.toString("hex"));if(t.value.length/4%1!=0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const e=t.key.slice(1),r={masterFingerprint:t.value.slice(0,4),extendedPubkey:e,path:"m"};for(const e of(n=t.value.length/4-1,[...Array(n).keys()])){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+="/"+o.toString(10)+(i?"'":"")}var n;return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split("/"),a=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(a,0);let s=4;return o.slice(1).forEach((t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),a.writeUInt32LE(r,s),s+=4})),{key:r,value:a}},e.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",e.check=function(t){const e=t.extendedPubkey,r=t.masterFingerprint,i=t.path;return n.isBuffer(e)&&78===e.length&&[2,3].indexOf(e[45])>-1&&n.isBuffer(r)&&4===r.length&&"string"==typeof i&&!!i.match(/^m(\/\d+'?)*$/)},e.canAddToArray=function(t,e,r){const n=e.extendedPubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.extendedPubkey.equals(e.extendedPubkey))).length)}},213:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.encode=function(t){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}}},706:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(80),i=r(834),o=r(213),a=r(605),s=r(795),u=r(431),c=r(907),f=r(949),l=r(344),h=r(760),p=r(695),d=r(454),y=r(34),g=r(926),b=r(851),v=r(545),w=r(412),m=r(307),_=r(636),E=r(223),S=r(578),k={unsignedTx:o,globalXpub:i,checkPubkey:w.makeChecker([])};e.globals=k;const T={nonWitnessUtxo:u,partialSig:c,sighashType:l,finalScriptSig:a,finalScriptWitness:s,porCommitment:f,witnessUtxo:g,bip32Derivation:v.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:w.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:h,tapScriptSig:y,tapLeafScript:p,tapBip32Derivation:_.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:E.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=T;const O={bip32Derivation:v.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:w.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:_.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:b,tapInternalKey:E.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=O},605:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTSIG]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptSig}},795:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptWitness}},431:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.NON_WITNESS_UTXO]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.nonWitnessUtxo}},907:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+t.key.toString("hex"));if(34!==t.key.length&&66!==t.key.length||![2,3,4].includes(t.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.PARTIAL_SIG]);return{key:n.concat([e,t.pubkey]),value:t.signature}},e.expected="{ pubkey: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.signature)&&[33,65].includes(t.pubkey.length)&&[2,3,4].includes(t.pubkey[0])&&function(t){if(!n.isBuffer(t)||t.length<9)return!1;if(48!==t[0])return!1;if(t.length!==t[1]+3)return!1;if(2!==t[2])return!1;const e=t[3];if(e>33||e<1)return!1;if(2!==t[3+e+1])return!1;const r=t[3+e+2];return!(r>33||r<1)&&t.length===3+e+2+r+2}(t.signature)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}},949:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+t.key.toString("hex"));return t.value.toString("utf8")},e.encode=function(t){return{key:n.from([i.InputTypes.POR_COMMITMENT]),value:n.from(t,"utf8")}},e.expected="string",e.check=function(t){return"string"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.porCommitment}},344:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+t.key.toString("hex"));return t.value.readUInt32LE(0)},e.encode=function(t){const e=n.from([i.InputTypes.SIGHASH_TYPE]),r=n.allocUnsafe(4);return r.writeUInt32LE(t,0),{key:e,value:r}},e.expected="number",e.check=function(t){return"number"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.sighashType}},760:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);function o(t){return n.isBuffer(t)&&(64===t.length||65===t.length)}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_KEY_SIG||1!==t.key.length)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_KEY_SIG]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapKeySig}},695:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+t.key.toString("hex"));if((t.key.length-2)%32!=0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+t.key.toString("hex"));const e=t.value[t.value.length-1];if((254&t.key[1])!==e)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+t.key.toString("hex"));const r=t.value.slice(0,-1);return{controlBlock:t.key.slice(1),script:r,leafVersion:e}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_LEAF_SCRIPT]),r=n.from([t.leafVersion]);return{key:n.concat([e,t.controlBlock]),value:n.concat([t.script,r])}},e.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",e.check=function(t){return n.isBuffer(t.controlBlock)&&(t.controlBlock.length-1)%32==0&&(254&t.controlBlock[0])===t.leafVersion&&n.isBuffer(t.script)},e.canAddToArray=function(t,e,r){const n=e.controlBlock.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.controlBlock.equals(e.controlBlock))).length)}},454:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);function o(t){return n.isBuffer(t)&&32===t.length}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_MERKLE_ROOT||1!==t.key.length)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_MERKLE_ROOT]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapMerkleRoot}},34:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+t.key.toString("hex"));if(65!==t.key.length)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+t.key.toString("hex"));if(64!==t.value.length&&65!==t.value.length)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1,33),leafHash:t.key.slice(33),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_SCRIPT_SIG]);return{key:n.concat([e,t.pubkey,t.leafHash]),value:t.signature}},e.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.leafHash)&&n.isBuffer(t.signature)&&32===t.pubkey.length&&32===t.leafHash.length&&(64===t.signature.length||65===t.signature.length)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex")+e.leafHash.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey)&&t.leafHash.equals(e.leafHash))).length)}},926:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80),o=r(133),a=r(394);e.decode=function(t){if(t.key[0]!==i.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+t.key.toString("hex"));const e=o.readUInt64LE(t.value,0);let r=8;const n=a.decode(t.value,r);r+=a.encodingLength(n);const s=t.value.slice(r);if(s.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:s,value:e}},e.encode=function(t){const{script:e,value:r}=t,s=a.encodingLength(e.length),u=n.allocUnsafe(8+s+e.length);return o.writeUInt64LE(u,r,0),a.encode(e.length,u,8),e.copy(u,8+s),{key:n.from([i.InputTypes.WITNESS_UTXO]),value:u}},e.expected="{ script: Buffer; value: number; }",e.check=function(t){return n.isBuffer(t.script)&&"number"==typeof t.value},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.witnessUtxo}},851:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80),o=r(394);e.decode=function(t){if(t.key[0]!==i.OutputTypes.TAP_TREE||1!==t.key.length)throw new Error("Decode Error: could not decode tapTree with key 0x"+t.key.toString("hex"));let e=0;const r=[];for(;e<t.value.length;){const n=t.value[e++],i=t.value[e++],a=o.decode(t.value,e);e+=o.encodingLength(a),r.push({depth:n,leafVersion:i,script:t.value.slice(e,e+a)}),e+=a}return{leaves:r}},e.encode=function(t){const e=n.from([i.OutputTypes.TAP_TREE]),r=[].concat(...t.leaves.map((t=>[n.of(t.depth,t.leafVersion),o.encode(t.script.length),t.script])));return{key:e,value:n.concat(r)}},e.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",e.check=function(t){return Array.isArray(t.leaves)&&t.leaves.every((t=>t.depth>=0&&t.depth<=128&&(254&t.leafVersion)===t.leafVersion&&n.isBuffer(t.script)))},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapTree}},545:(t,e,r)=>{var n=r(287).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(o=r.value.length/4-1,[...Array(o).keys()])){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+="/"+o.toString(10)+(n?"'":"")}var o;return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split("/"),a=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(a,0);let s=4;return o.slice(1).forEach((t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),a.writeUInt32LE(r,s),s+=4})),{key:i,value:a}},check:function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.masterFingerprint)&&"string"==typeof t.path&&e(t.pubkey)&&4===t.masterFingerprint.length},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }",canAddToArray:function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}}}},412:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.makeChecker=function(t){return function(e){let r;if(t.includes(e.key[0])&&(r=e.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error("Format Error: invalid pubkey in key 0x"+e.key.toString("hex"));return r}}},307:(t,e,r)=>{var n=r(287).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}}}},636:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394),o=r(545),a=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,a);return{decode:function(t){const r=i.decode(t.value),n=i.encodingLength(r),o=e.decode({key:t.key,value:t.value.slice(n+32*r)}),a=new Array(r);for(let e=0,i=n;e<r;e++,i+=32)a[e]=t.value.slice(i,i+32);return Object.assign({},o,{leafHashes:a})},encode:function(t){const r=e.encode(t),o=i.encodingLength(t.leafHashes.length),a=n.allocUnsafe(o);i.encode(t.leafHashes.length,a);const s=n.concat([a,...t.leafHashes,r.value]);return Object.assign({},r,{value:s})},check:function(t){return Array.isArray(t.leafHashes)&&t.leafHashes.every((t=>n.isBuffer(t)&&32===t.length))&&e.check(t)},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }",canAddToArray:e.canAddToArray}}},223:(t,e,r)=>{var n=r(287).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}}}},578:(t,e,r)=>{var n=r(287).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}}}},133:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394);function o(t){const e=t.key.length,r=t.value.length,o=i.encodingLength(e),a=i.encodingLength(r),s=n.allocUnsafe(o+e+a+r);return i.encode(e,s,0),t.key.copy(s,o),i.encode(r,s,o+e),t.value.copy(s,o+e+a),s}function a(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.range=t=>[...Array(t).keys()],e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n<t.length/2;n++)r=t[n],t[n]=t[e],t[e]=r,e--;return t},e.keyValsToBuffer=function(t){const e=t.map(o);return e.push(n.from([0])),n.concat(e)},e.keyValToBuffer=o,e.readUInt64LE=function(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,a(n+r,9007199254740991),n+r},e.writeUInt64LE=function(t,e,r){return a(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}},394:(t,e,r)=>{var n=r(287).Buffer;function i(t){if(t<0||t>9007199254740991||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}Object.defineProperty(e,"__esModule",{value:!0}),e.encode=function t(e,r,a){if(i(e),r||(r=n.allocUnsafe(o(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return a||(a=0),e<253?(r.writeUInt8(e,a),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,a),r.writeUInt16LE(e,a+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,a),r.writeUInt32LE(e,a+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,a),r.writeUInt32LE(e>>>0,a+1),r.writeUInt32LE(e/4294967296|0,a+5),Object.assign(t,{bytes:9})),r},e.decode=function t(e,r){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);const o=e.readUInt8(r);if(o<253)return Object.assign(t,{bytes:1}),o;if(253===o)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===o)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),o=4294967296*e.readUInt32LE(r+5)+n;return i(o),o}},e.encodingLength=o},263:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(706),o=r(133),a=r(394),s=r(80);function u(t,e,r){if(!e.equals(n.from([r])))throw new Error(`Format Error: Invalid ${t} key: ${e.toString("hex")}`)}function c(t,{globalMapKeyVals:e,inputKeyVals:r,outputKeyVals:n}){const a={unsignedTx:t};let c=0;for(const t of e)switch(t.key[0]){case s.GlobalTypes.UNSIGNED_TX:if(u("global",t.key,s.GlobalTypes.UNSIGNED_TX),c>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");c++;break;case s.GlobalTypes.GLOBAL_XPUB:void 0===a.globalXpub&&(a.globalXpub=[]),a.globalXpub.push(i.globals.globalXpub.decode(t));break;default:a.unknownKeyVals||(a.unknownKeyVals=[]),a.unknownKeyVals.push(t)}const f=r.length,l=n.length,h=[],p=[];for(const t of o.range(f)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case s.InputTypes.NON_WITNESS_UTXO:if(u("input",n.key,s.InputTypes.NON_WITNESS_UTXO),void 0!==e.nonWitnessUtxo)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");e.nonWitnessUtxo=i.inputs.nonWitnessUtxo.decode(n);break;case s.InputTypes.WITNESS_UTXO:if(u("input",n.key,s.InputTypes.WITNESS_UTXO),void 0!==e.witnessUtxo)throw new Error("Format Error: Input has multiple WITNESS_UTXO");e.witnessUtxo=i.inputs.witnessUtxo.decode(n);break;case s.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case s.InputTypes.SIGHASH_TYPE:if(u("input",n.key,s.InputTypes.SIGHASH_TYPE),void 0!==e.sighashType)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");e.sighashType=i.inputs.sighashType.decode(n);break;case s.InputTypes.REDEEM_SCRIPT:if(u("input",n.key,s.InputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");e.redeemScript=i.inputs.redeemScript.decode(n);break;case s.InputTypes.WITNESS_SCRIPT:if(u("input",n.key,s.InputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");e.witnessScript=i.inputs.witnessScript.decode(n);break;case s.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case s.InputTypes.FINAL_SCRIPTSIG:u("input",n.key,s.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case s.InputTypes.FINAL_SCRIPTWITNESS:u("input",n.key,s.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case s.InputTypes.POR_COMMITMENT:u("input",n.key,s.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case s.InputTypes.TAP_KEY_SIG:u("input",n.key,s.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case s.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case s.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case s.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case s.InputTypes.TAP_INTERNAL_KEY:u("input",n.key,s.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case s.InputTypes.TAP_MERKLE_ROOT:u("input",n.key,s.InputTypes.TAP_MERKLE_ROOT),e.tapMerkleRoot=i.inputs.tapMerkleRoot.decode(n);break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(n)}h.push(e)}for(const t of o.range(l)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case s.OutputTypes.REDEEM_SCRIPT:if(u("output",r.key,s.OutputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");e.redeemScript=i.outputs.redeemScript.decode(r);break;case s.OutputTypes.WITNESS_SCRIPT:if(u("output",r.key,s.OutputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");e.witnessScript=i.outputs.witnessScript.decode(r);break;case s.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case s.OutputTypes.TAP_INTERNAL_KEY:u("output",r.key,s.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case s.OutputTypes.TAP_TREE:u("output",r.key,s.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case s.OutputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.outputs.tapBip32Derivation.decode(r));break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(r)}p.push(e)}return{globalMap:a,inputs:h,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=a.decode(t,r);r+=a.encodingLength(e);const n=t.slice(r,r+e);return r+=e,n}function i(){return{key:n(),value:n()}}function u(){if(r>=t.length)throw new Error("Format Error: Unexpected End of PSBT");const e=0===t.readUInt8(r);return e&&r++,e}if(1886610036!==function(){const e=t.readUInt32BE(r);return r+=4,e}())throw new Error("Format Error: Invalid Magic Number");if(255!==function(){const e=t.readUInt8(r);return r+=1,e}())throw new Error("Format Error: Magic Number must be followed by 0xff separator");const f=[],l={};for(;!u();){const t=i(),e=t.key.toString("hex");if(l[e])throw new Error("Format Error: Keys must be unique for global keymap: key "+e);l[e]=1,f.push(t)}const h=f.filter((t=>t.key[0]===s.GlobalTypes.UNSIGNED_TX));if(1!==h.length)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const p=e(h[0].value),{inputCount:d,outputCount:y}=p.getInputOutputCounts(),g=[],b=[];for(const t of o.range(d)){const e={},r=[];for(;!u();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each input: input index "+t+" key "+o);e[o]=1,r.push(n)}g.push(r)}for(const t of o.range(y)){const e={},r=[];for(;!u();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each output: output index "+t+" key "+o);e[o]=1,r.push(n)}b.push(r)}return c(p,{globalMapKeyVals:f,inputKeyVals:g,outputKeyVals:b})},e.checkKeyBuffer=u,e.psbtFromKeyVals=c},457:(t,e,r)=>{function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),n(r(263)),n(r(238))},238:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(706),o=r(133);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:i,inputKeyVals:a,outputKeyVals:s}=u({globalMap:t,inputs:e,outputs:r}),c=o.keyValsToBuffer(i),f=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),l=f(a),h=f(s),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,c].concat(l,h))};const a=(t,e)=>t.key.compare(e.key);function s(t,e){const r=new Set,n=Object.entries(t).reduce(((t,[n,i])=>{if("unknownKeyVals"===n)return t;const o=e[n];if(void 0===o)return t;const a=(Array.isArray(i)?i:[i]).map(o.encode);return a.map((t=>t.key.toString("hex"))).forEach((t=>{if(r.has(t))throw new Error("Serialize Error: Duplicate key: "+t);r.add(t)})),t.concat(a)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString("hex")))):[];return n.concat(i).sort(a)}function u({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:s(t,i.globals),inputKeyVals:e.map((t=>s(t,i.inputs))),outputKeyVals:r.map((t=>s(t,i.outputs)))}}e.psbtToKeyVals=u},614:(t,e,r)=>{var n=r(287).Buffer;const i=r(863),o=r(457),a=r(80),s=r(699);e.i=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,e){const r=n.from(t,"base64");return this.fromBuffer(r,e)}static fromHex(t,e){const r=n.from(t,"hex");return this.fromBuffer(r,e)}static fromBuffer(t,e){const r=o.psbtFromBuffer(t,e),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString("base64")}toHex(){return this.toBuffer().toString("hex")}toBuffer(){return o.psbtToBuffer(this)}updateGlobal(t){return s.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=s.checkForInput(this.inputs,t);return s.updateInput(e,r),this}updateOutput(t,e){const r=s.checkForOutput(this.outputs,t);return s.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return s.checkHasKey(t,this.globalMap.unknownKeyVals,s.getEnumLength(a.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=s.checkForInput(this.inputs,t);return s.checkHasKey(e,r.unknownKeyVals,s.getEnumLength(a.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=s.checkForOutput(this.outputs,t);return s.checkHasKey(e,r.unknownKeyVals,s.getEnumLength(a.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach((t=>this.addUnknownKeyValToInput(r,t))),s.addInputAttributes(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach((t=>this.addUnknownKeyValToOutput(r,t))),s.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=s.checkForInput(this.inputs,t);s.inputCheckUncleanFinalized(t,e);for(const t of Object.keys(e))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(t)||delete e[t];return this}combine(...t){const e=i.combine([this].concat(t));return Object.assign(this,e),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}}},80:(t,e)=>{var r,n,i;Object.defineProperty(e,"__esModule",{value:!0}),(i=e.GlobalTypes||(e.GlobalTypes={}))[i.UNSIGNED_TX=0]="UNSIGNED_TX",i[i.GLOBAL_XPUB=1]="GLOBAL_XPUB",e.GLOBAL_TYPE_NAMES=["unsignedTx","globalXpub"],(n=e.InputTypes||(e.InputTypes={}))[n.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",n[n.WITNESS_UTXO=1]="WITNESS_UTXO",n[n.PARTIAL_SIG=2]="PARTIAL_SIG",n[n.SIGHASH_TYPE=3]="SIGHASH_TYPE",n[n.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",n[n.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",n[n.BIP32_DERIVATION=6]="BIP32_DERIVATION",n[n.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",n[n.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",n[n.POR_COMMITMENT=9]="POR_COMMITMENT",n[n.TAP_KEY_SIG=19]="TAP_KEY_SIG",n[n.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",n[n.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",n[n.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",n[n.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",n[n.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT",e.INPUT_TYPE_NAMES=["nonWitnessUtxo","witnessUtxo","partialSig","sighashType","redeemScript","witnessScript","bip32Derivation","finalScriptSig","finalScriptWitness","porCommitment","tapKeySig","tapScriptSig","tapLeafScript","tapBip32Derivation","tapInternalKey","tapMerkleRoot"],(r=e.OutputTypes||(e.OutputTypes={}))[r.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",r[r.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",r[r.BIP32_DERIVATION=2]="BIP32_DERIVATION",r[r.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",r[r.TAP_TREE=6]="TAP_TREE",r[r.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION",e.OUTPUT_TYPE_NAMES=["redeemScript","witnessScript","bip32Derivation","tapInternalKey","tapTree","tapBip32Derivation"]},699:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(706);function o(t,e){const r=t[e];if(void 0===r)throw new Error(`No input #${e}`);return r}function a(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function s(t,e,r,n){throw new Error(`Data for ${t} key ${e} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function u(t){return(e,r)=>{for(const n of Object.keys(e)){const o=e[n],{canAdd:a,canAddToArray:u,check:c,expected:f}=i[t+"s"][n]||{};if(c)if(u){if(!Array.isArray(o)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);o.every(c)||s(t,n,f,o);const e=r[n]||[],i=new Set;if(!o.every((t=>u(e,t,i))))throw new Error("Can not add duplicate data to array");r[n]=e.concat(o)}else{if(c(o)||s(t,n,f,o),!a(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=a,e.checkHasKey=function(t,e,r){if(t.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(e&&0!==e.filter((e=>e.key.equals(t.key))).length)throw new Error(`Duplicate Key: ${t.key.toString("hex")}`)},e.getEnumLength=function(t){let e=0;return Object.keys(t).forEach((t=>{Number(isNaN(Number(t)))&&e++})),e},e.inputCheckUncleanFinalized=function(t,e){let r=!1;if(e.nonWitnessUtxo||e.witnessUtxo){const t=!!e.redeemScript,n=!!e.witnessScript,i=!t||!!e.finalScriptSig,o=!n||!!e.finalScriptWitness,a=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&a}if(!1===r)throw new Error(`Input #${t} has too much or too little data to clean`)},e.updateGlobal=u("global"),e.updateInput=u("input"),e.updateOutput=u("output"),e.addInputAttributes=function(t,r){const n=o(t,t.length-1);e.updateInput(r,n)},e.addOutputAttributes=function(t,r){const n=a(t,t.length-1);e.updateOutput(r,n)},e.defaultVersionSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Version: Invalid Transaction");return e.writeUInt32LE(t,0),e},e.defaultLocktimeSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Locktime: Invalid Transaction");return e.writeUInt32LE(t,e.length-4),e}},287:(t,e,r)=>{const n=r(526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50;const a=2147483647;function s(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return c(t,e,r)}function c(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Z(t.length)?s(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return f(t),s(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function d(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return z(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function g(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 I(this,e,r);case"utf8":case"utf-8":return O(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Z(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){let o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(Z(n))return a;t[r+a]=n}return a}function _(t,e,r,n){return Y(q(e,t.length-r),t,r,n)}function E(t,e,r,n){return Y(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 Y(z(e),t,r,n)}function k(t,e,r,n){return Y(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function O(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,u;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=x));return r}(n)}e.kMaxLength=a,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return c(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return f(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},u.allocUnsafe=function(t){return l(t)},u.allocUnsafeSlow=function(t){return l(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(X(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)b(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)b(this,e,e+3),b(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)b(this,e,e+7),b(this,e+1,e+6),b(this,e+2,e+5),b(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?O(this,0,t):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const s=Math.min(o,a),c=this.slice(n,i),f=t.slice(e,r);for(let t=0;t<s;++t)if(c[t]!==f[t]){o=c[t],a=f[t];break}return o<a?-1:a<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":case"latin1":case"binary":return E(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const x=4096;function A(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function P(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function I(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=$[t[n]];return i}function L(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 B(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 R(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function N(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function j(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||U(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||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(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||B(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||B(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||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),u.prototype.readBigUInt64BE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||B(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||B(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||B(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||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),u.prototype.readBigInt64BE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||B(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||R(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||R(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||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||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||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||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||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=J((function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=J((function(t,e=0){return j(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);R(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);R(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||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||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||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||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||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=J((function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=J((function(t,e=0){return j(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=u.isBuffer(t)?t:u.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const M={};function D(t,e,r){M[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 H(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function K(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new M.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||W(e,t.length-(r+1))}(n,i,o)}function G(t,e){if("number"!=typeof t)throw new M.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,r){if(Math.floor(t)!==t)throw G(t,r),new M.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}D("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),D("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),D("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=H(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=H(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const V=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function z(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Z(t){return t!=t}const $=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},251:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<<s)-1,c=u>>1,f=-7,l=r?i-1:0,h=r?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=s;f>0;o=256*o+t[e+l],l+=h,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,c+=i;c>0;t[r+p]=255&a,p+=d,a/=256,c-=8);t[r+p-d]|=128*y}},861:(t,e,r)=>{var n=r(287),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function a(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},a.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},61:(t,e,r)=>{var n=r(113);function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function a(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function s(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?"Array":t&&n.Object(t)?"Object":void 0!==t?t:""}function u(t,e,r){var i=function(t){return n.Function(t)?"":n.String(t)?JSON.stringify(t):t&&n.Object(t)?"":t}(e);return"Expected "+s(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function c(t,e,r){r=r||o(e),this.message=u(t,e,r),a(this,c),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),u('property "'+s(r)+o+s(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',a(this,c),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,f.prototype=Object.create(Error.prototype),f.prototype.constructor=c,t.exports={TfTypeError:c,TfPropertyTypeError:f,tfCustomError:function(t,e){return new c(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+"."+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof c&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),a(t),t},tfJSON:s,getValueTypeName:o}},542:(t,e,r)=>{var n=r(287).Buffer,i=r(113),o=r(61);function a(t){return n.isBuffer(t)}function s(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function u(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var c=u.bind(null,i.Array),f=u.bind(null,a),l=u.bind(null,s),h=u.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:c,Buffer:a,BufferN:f,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:s,HexN:l,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n<e}return r=r||i.Number,n.toJSON=function(){return`${r.toJSON()} between [${t}, ${e}]`},n},StringN:h,UInt8:function(t){return(255&t)===t},UInt16:function(t){return(65535&t)===t},UInt32:function(t){return t>>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},676:(t,e,r)=>{var n=r(61),i=r(113),o=n.tfJSON,a=n.TfTypeError,s=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==e.minLength&&r.length<e.minLength)&&!(void 0!==e.maxLength&&r.length>e.maxLength)&&(void 0===e.length||r.length===e.length)&&r.every((function(e,r){try{return h(t,e,n)}catch(t){throw u(t,r)}}))}return t=l(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=l(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&h(e,o,n)}catch(t){throw u(t,o,"key")}try{var a=r[o];h(t,a,n)}catch(t){throw u(t,o)}}return!0}return t=l(t),e&&(e=l(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=l(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e)h(e[n],t[n],r)}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new s(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.some((function(t){try{return h(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.every((function(t){try{return h(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return!i.Nil(e)&&!i.Nil(e.length)&&(!r||e.length===t.length)&&t.every((function(t,n){try{return h(t,e[n],r)}catch(t){throw u(t,n)}}))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function l(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new a(n||t,e)}return h(l(t),e,r)}for(var p in f.oneOf=f.anyOf,i)h[p]=i[p];for(p in f)h[p]=f[p];var d=r(542);for(p in d)h[p]=d[p];h.compile=l,h.TfTypeError=a,h.TfPropertyTypeError=s,t.exports=h},113:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return null==t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},469:(t,e,r)=>{var n=r(861).Buffer;function i(t){if(t<0||t>9007199254740991||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}t.exports={encode:function t(e,r,a){if(i(e),r||(r=n.allocUnsafe(o(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return a||(a=0),e<253?(r.writeUInt8(e,a),t.bytes=1):e<=65535?(r.writeUInt8(253,a),r.writeUInt16LE(e,a+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,a),r.writeUInt32LE(e,a+1),t.bytes=5):(r.writeUInt8(255,a),r.writeUInt32LE(e>>>0,a+1),r.writeUInt32LE(e/4294967296|0,a+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 o=e.readUInt8(r);if(o<253)return t.bytes=1,o;if(253===o)return t.bytes=3,e.readUInt16LE(r+1);if(254===o)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var a=e.readUInt32LE(r+1),s=4294967296*e.readUInt32LE(r+5)+a;return i(s),s},encodingLength:o}}},y={};function g(t){var e=y[t];if(void 0!==e)return e.exports;var r=y[t]={exports:{}};return d[t](r,r.exports,g),r.exports}g.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return g.d(e,{a:e}),e},g.d=(t,e)=>{for(var r in e)g.o(e,r)&&!g.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},g.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),g.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var b={};g.d(b,{eB:()=>Pn,Oo:()=>vr,ac:()=>br,ri:()=>_r,RY:()=>Er,iL:()=>Ao,PW:()=>Xe,gp:()=>Ye,gM:()=>St,ZX:()=>wn,hl:()=>E,p2:()=>Di,XL:()=>Wi,R0:()=>eo,vJ:()=>ao,em:()=>ro,Eb:()=>gr,Et:()=>S,m$:()=>Mi,Ay:()=>ca,CB:()=>Or,VL:()=>we,ow:()=>me,hP:()=>Se,Dk:()=>Go,Ln:()=>qi,BL:()=>uo,A0:()=>qe,CX:()=>ze,f0:()=>Qe,Bh:()=>Li,Q2:()=>Bi,C5:()=>Ri,n0:()=>Ui,NI:()=>Ci,fQ:()=>Ni,mG:()=>ji,AM:()=>Qi,Zh:()=>to,o8:()=>v,Ez:()=>it,KT:()=>k,KS:()=>Wo,AI:()=>Gi,k1:()=>Ki,pM:()=>Hi,Qf:()=>pr,Fl:()=>yr,HE:()=>Ge,WH:()=>kr,K$:()=>_,C2:()=>Ji,e8:()=>We,sc:()=>Ve,XN:()=>Vi,VQ:()=>Ze,LE:()=>$i,_T:()=>oo,zm:()=>io,qR:()=>Ar,o4:()=>xr,Og:()=>_e,FT:()=>Ee,uu:()=>Tr,I:()=>ke,gU:()=>Zi,wn:()=>no,Kn:()=>Pr,Uu:()=>ir,du:()=>Fi,tO:()=>dr});var v={};g.r(v),g.d(v,{bitcoin:()=>O,bitcoinCash:()=>R,bitcoinCashTestnet:()=>N,dash:()=>j,dashTestnet:()=>U,dogecoin:()=>P,dogecoinTestnet:()=>I,litecoin:()=>L,litecoinTestnet:()=>B,regtest:()=>x,testnet:()=>A});var w={};g.r(w),g.d(w,{decode:()=>pt,encode:()=>dt});var m={};g.r(m),g.d(m,{decode:()=>Vt,encode:()=>qt});var _={};g.r(_),g.d(_,{OPS:()=>it,compile:()=>re,countNonPushOnlyOPs:()=>Jt,decompile:()=>ne,fromASM:()=>oe,isCanonicalPubKey:()=>se,isCanonicalScriptSignature:()=>ce,isDefinedHashType:()=>ue,isPushOnly:()=>$t,number:()=>fe,signature:()=>le,toASM:()=>ie,toStack:()=>ae});var E={};g.r(E),g.d(E,{fromBase58Check:()=>we,fromBech32:()=>me,fromOutputScript:()=>Se,toBase58Check:()=>_e,toBech32:()=>Ee,toOutputScript:()=>ke});var S={};g.r(S),g.d(S,{TAGGED_HASH_PREFIXES:()=>Xe,TAGS:()=>Ye,hash160:()=>qe,hash256:()=>ze,ripemd160:()=>Ge,sha1:()=>We,sha256:()=>Ve,taggedHash:()=>Ze});var k={};g.r(k),g.d(k,{LEAF_VERSION_TAPSCRIPT:()=>_r,MAX_TAPTREE_DEPTH:()=>Er,findScriptPath:()=>Or,p2data:()=>Nr,p2ms:()=>Cr,p2pk:()=>Mr,p2pkh:()=>Kr,p2sh:()=>Vr,p2tr:()=>Xr,p2wpkh:()=>Qr,p2wsh:()=>on,prop:()=>Lr,rootHashFromPath:()=>kr,tapTweakHash:()=>Ar,tapleafHash:()=>xr,toHashTree:()=>Tr,tweakKey:()=>Pr,value:()=>Br});var T={};g.r(T),g.d(T,{Transaction:()=>wn});var O={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},x={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},A={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},P={messagePrefix:"Dogecoin Signed Message:\n",bech32:"",bip32:{public:49990397,private:49988504},pubKeyHash:30,scriptHash:22,wif:158},I={messagePrefix:"Dogecoin Signed Message:\n",bech32:"",bip32:{public:70429096,private:70427203},pubKeyHash:113,scriptHash:196,wif:241},L={messagePrefix:"Litecoin Signed Message:\n",bech32:"ltc",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176},B={messagePrefix:"Litecoin Signed Message:\n",bech32:"tltc",bip32:{public:70709117,private:70711009},pubKeyHash:111,scriptHash:58,wif:239},R={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bitcoincash",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},N={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bchtest",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},j={messagePrefix:"DarkCoin Signed Message:\n",bech32:"",bip32:{public:50221772,private:50221816},pubKeyHash:76,scriptHash:16,wif:204},U={messagePrefix:"DarkCoin Signed Message:\n",bech32:"",bip32:{public:981492128,private:981489719},pubKeyHash:140,scriptHash:19,wif:239},C=g(343);function F(t,...e){if(!((r=t)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function M(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 D=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),H=(t,e)=>t<<32-e|t>>>e,K=(t,e)=>t<<e|t>>>32-e>>>0;function G(t){return"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)),F(t),t}class W{clone(){return this._cloneInto()}}function V(t){const e=e=>t().update(G(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}const q=(t,e,r)=>t&e^~t&r,z=(t,e,r)=>t&e^t&r^e&r;class Y extends W{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=D(this.buffer)}update(t){M(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=G(t)).length;for(let o=0;o<i;){const a=Math.min(n-this.pos,i-o);if(a!==n)r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=D(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){M(this),function(t,e){F(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+c,s,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=D(t),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=s/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)a.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const X=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]),Z=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$=new Uint32Array(64);class J extends Y{constructor(){super(64,32,8,!1),this.A=0|Z[0],this.B=0|Z[1],this.C=0|Z[2],this.D=0|Z[3],this.E=0|Z[4],this.F=0|Z[5],this.G=0|Z[6],this.H=0|Z[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)$[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=$[t-15],r=$[t-2],n=H(e,7)^H(e,18)^e>>>3,i=H(r,17)^H(r,19)^r>>>10;$[t]=i+$[t-7]+n+$[t-16]|0}let{A:r,B:n,C:i,D:o,E:a,F:s,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(H(a,6)^H(a,11)^H(a,25))+q(a,s,u)+X[t]+$[t]|0,f=(H(r,2)^H(r,13)^H(r,22))+z(r,n,i)|0;c=u,u=s,s=a,a=o+e|0,o=i,i=n,n=r,r=e+f|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,s=s+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,a,s,u,c)}roundClean(){$.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Q=V((()=>new J)),tt=function(t){const e=new Uint8Array(256);for(let t=0;t<e.length;t++)e[t]=255;for(let r=0;r<58;r++){const n=t.charAt(r),i=n.charCodeAt(0);if(255!==e[i])throw new TypeError(n+" is ambiguous");e[i]=r}const r=t.charAt(0),n=Math.log(58)/Math.log(256),i=Math.log(256)/Math.log(58);function o(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;let i=0,o=0,a=0;for(;t[i]===r;)o++,i++;const s=(t.length-i)*n+1>>>0,u=new Uint8Array(s);for(;t[i];){let r=e[t.charCodeAt(i)];if(255===r)return;let n=0;for(let t=s-1;(0!==r||n<a)&&-1!==t;t--,n++)r+=58*u[t]>>>0,u[t]=r%256>>>0,r=r/256>>>0;if(0!==r)throw new Error("Non-zero carry");a=n,i++}let c=s-a;for(;c!==s&&0===u[c];)c++;const f=new Uint8Array(o+(s-c));let l=o;for(;c!==s;)f[l++]=u[c++];return f}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";let n=0,o=0,a=0;const s=e.length;for(;a!==s&&0===e[a];)a++,n++;const u=(s-a)*i+1>>>0,c=new Uint8Array(u);for(;a!==s;){let t=e[a],r=0;for(let e=u-1;(0!==t||r<o)&&-1!==e;e--,r++)t+=256*c[e]>>>0,c[e]=t%58>>>0,t=t/58>>>0;if(0!==t)throw new Error("Non-zero carry");o=r,a++}let f=u-o;for(;f!==u&&0===c[f];)f++;let l=r.repeat(n);for(;f<u;++f)l+=t.charAt(c[f]);return l},decodeUnsafe:o,decode:function(t){const e=o(t);if(e)return e;throw new Error("Non-base58 character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),et=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),n=t(r),i=r.length+4,o=new Uint8Array(i);return o.set(r,0),o.set(n.subarray(0,4),r.length),tt.encode(o)},decode:function(t){var r=e(tt.decode(t));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=tt.decodeUnsafe(t);if(null!=r)return e(r)}}}((function(t){return Q(Q(t))}));var rt=g(287).Buffer;function nt(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=rt.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}for(var it={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},ot={},at=0,st=Object.keys(it);at<st.length;at++){var ut=st[at],ct=it[ut];ot[ct]=ut}function ft(t){return t<it.OP_PUSHDATA1?1:t<=255?2:t<=65535?3:5}function lt(t,e){var r,n,i=t.readUInt8(e);if(i<it.OP_PUSHDATA1)r=i,n=1;else if(i===it.OP_PUSHDATA1){if(e+2>t.length)return null;r=t.readUInt8(e+1),n=2}else if(i===it.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),n=3}else{if(e+5>t.length)return null;if(i!==it.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),n=5}return{opcode:i,number:r,size:n}}var ht=g(287).Buffer;function pt(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&!(127&t[n-1]||!(n<=1)&&128&t[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var a=0,s=0;s<n;++s)a|=t[s]<<8*s;return 128&t[n-1]?-(a&~(128<<8*(n-1))):a}function dt(t){for(var e=Math.abs(t),r=function(t){return t>2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=ht.allocUnsafe(r),i=t<0,o=0;o<r;++o)n.writeUInt8(255&e,o),e>>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}var yt=g(287),gt=g(676),bt=g.n(gt)(),vt=yt.Buffer.alloc(32,0),wt=yt.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");function mt(t,e){return t.length===e.length&&t.every((function(t,r){return t.equals(e[r])}))}function _t(t){if(!yt.Buffer.isBuffer(t))return!1;if(t.length<33)return!1;var e=t[0],r=t.slice(1,33);if(0===r.compare(vt))return!1;if(r.compare(wt)>=0)return!1;if((2===e||3===e)&&33===t.length)return!0;if(65!==t.length)return!1;var n=t.slice(33);return!(0===n.compare(vt)||n.compare(wt)>=0||4!==e&&6!==e&&7!==e)}function Et(t){return bt.UInt53(t)&&t<=21e14}var St=254;function kt(t){return!(!t||!("output"in t)||!yt.Buffer.isBuffer(t.output)||void 0!==t.version&&(t.version&St)!==t.version)}function Tt(t){return Pt(t)?2===t.length&&t.every((function(t){return Tt(t)})):kt(t)}bt.BufferN(32);var Ot=bt.BufferN(20),xt=bt.BufferN(32),At=bt.Number,Pt=bt.Array,It=(bt.Boolean,bt.String),Lt=bt.Buffer,Bt=bt.Hex,Rt=bt.maybe,Nt=bt.tuple,jt=bt.UInt8,Ut=bt.UInt32,Ct=bt.Function,Ft=bt.BufferN,Mt=bt.Null,Dt=(bt.oneOf,g(287).Buffer),Ht=bt,Kt=Dt.alloc(1,0);function Gt(t){for(var e=0;0===t[e];)++e;return e===t.length?Kt:128&(t=t.slice(e))[0]?Dt.concat([Kt,t],1+t.length):t}function Wt(t){0===t[0]&&(t=t.slice(1));var e=Dt.alloc(32,0),r=Math.max(0,32-t.length);return t.copy(e,r),e}function Vt(t){var e=t.readUInt8(t.length-1);if(!ue(e))throw new Error("Invalid hashType "+e);var r=function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}}(t.slice(0,-1)),n=Wt(r.r),i=Wt(r.s);return{signature:Dt.concat([n,i],64),hashType:e}}function qt(t,e){if(Ht({signature:Ft(64),hashType:jt},{signature:t,hashType:e}),!ue(e))throw new Error("Invalid hashType "+e);var r=Dt.allocUnsafe(1);r.writeUInt8(e,0);var n=Gt(t.slice(0,32)),i=Gt(t.slice(32,64));return Dt.concat([nt(n,i),r])}var zt=g(287).Buffer,Yt=bt,Xt=it.OP_RESERVED;function Zt(t){return Lt(t)||function(t){return At(t)&&(t===it.OP_0||t>=it.OP_1&&t<=it.OP_16||t===it.OP_1NEGATE)}(t)}function $t(t){return Pt(t)&&t.every(Zt)}function Jt(t){return t.length-t.filter(Zt).length}function Qt(t){return 0===t.length?it.OP_0:1===t.length?t[0]>=1&&t[0]<=16?Xt+t[0]:129===t[0]?it.OP_1NEGATE:void 0:void 0}function te(t){return zt.isBuffer(t)}function ee(t){return zt.isBuffer(t)}function re(t){if(te(t))return t;Yt(Pt,t);var e=t.reduce((function(t,e){return ee(e)?1===e.length&&void 0!==Qt(e)?t+1:t+ft(e.length)+e.length:t+1}),0),r=zt.allocUnsafe(e),n=0;if(t.forEach((function(t){if(ee(t)){var e=Qt(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=function(t,e,r){var n=ft(e);return 1===n?t.writeUInt8(e,r):2===n?(t.writeUInt8(it.OP_PUSHDATA1,r),t.writeUInt8(e,r+1)):3===n?(t.writeUInt8(it.OP_PUSHDATA2,r),t.writeUInt16LE(e,r+1)):(t.writeUInt8(it.OP_PUSHDATA4,r),t.writeUInt32LE(e,r+1)),n}(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1})),n!==r.length)throw new Error("Could not decode chunks");return r}function ne(t){if(Pt(t))return t;Yt(Lt,t);for(var e=[],r=0;r<t.length;){var n=t[r];if(n>it.OP_0&&n<=it.OP_PUSHDATA4){var i=lt(t,r);if(null===i)return null;if((r+=i.size)+i.number>t.length)return null;var o=t.slice(r,r+i.number);r+=i.number;var a=Qt(o);void 0!==a?e.push(a):e.push(o)}else e.push(n),r+=1}return e}function ie(t){if(te(t)&&(t=ne(t)),!t)throw new Error("Could not convert invalid chunks to ASM");return t.map((function(t){if(ee(t)){var e=Qt(t);if(void 0===e)return t.toString("hex");t=e}return ot[t]})).join(" ")}function oe(t){return Yt(It,t),re(t.split(" ").map((function(t){return void 0!==it[t]?it[t]:(Yt(Bt,t),zt.from(t,"hex"))})))}function ae(t){return t=ne(t),Yt($t,t),t.map((function(t){return ee(t)?t:t===it.OP_0?zt.allocUnsafe(0):dt(t-Xt)}))}function se(t){return _t(t)}function ue(t){var e=-129&t;return e>0&&e<4}function ce(t){return!!zt.isBuffer(t)&&!!ue(t[t.length-1])&&function(t){if(t.length<8)return!1;if(t.length>72)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))}(t.slice(0,-1))}var fe=w,le=m,he=g(287).Buffer,pe=40,de=2,ye=16,ge=2,be=80,ve="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 we(t){var e=he.from(et.decode(t));if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function me(t){var e,r;try{e=C.I.decode(t)}catch(t){}if(e){if(0!==(r=e.words[0]))throw new TypeError(t+" uses wrong encoding")}else if(0===(r=(e=C.p2.decode(t)).words[0]))throw new TypeError(t+" uses wrong encoding");var n=C.I.fromWords(e.words.slice(1));return{version:r,prefix:e.prefix,data:he.from(n)}}function _e(t,e){bt(Nt(Ot,jt),arguments);var r=he.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),et.encode(r)}function Ee(t,e,r){var n=C.I.toWords(t);return n.unshift(e),0===e?C.I.encode(r,n):C.p2.encode(r,n)}function Se(t,e){e=e||O;try{return Kr({output:t,network:e}).address}catch(t){}try{return Vr({output:t,network:e}).address}catch(t){}try{return Qr({output:t,network:e}).address}catch(t){}try{return on({output:t,network:e}).address}catch(t){}try{return Xr({output:t,network:e}).address}catch(t){}try{return function(t,e){var r=t.slice(2);if(r.length<de||r.length>pe)throw new TypeError("Invalid program length for segwit address");var n=t[0]-be;if(n<ge||n>ye)throw new TypeError("Invalid version for segwit address");if(t[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(ve),Ee(r,n,e.bech32)}(t,e)}catch(t){}throw new Error(ie(t)+" has no matching Address")}function ke(t,e){var r,n;e=e||O;try{r=we(t)}catch(t){}if(r){if(r.version===e.pubKeyHash)return Kr({hash:r.hash}).output;if(r.version===e.scriptHash)return Vr({hash:r.hash}).output}else{try{n=me(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 Qr({hash:n.data}).output;if(32===n.data.length)return on({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return Xr({pubkey:n.data}).output}else if(n.version>=ge&&n.version<=ye&&n.data.length>=de&&n.data.length<=pe)return console.warn(ve),re([n.version+be,n.data])}}return he.from(t,"hex")}const Te=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Oe=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e)));let xe=[Oe],Ae=[Oe.map((t=>(9*t+5)%16))];for(let t=0;t<4;t++)for(let e of[xe,Ae])e.push(e[t].map((t=>Te[t])));const Pe=[[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))),Ie=xe.map(((t,e)=>t.map((t=>Pe[e][t])))),Le=Ae.map(((t,e)=>t.map((t=>Pe[e][t])))),Be=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Re=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function Ne(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 je=new Uint32Array(16);class Ue extends Y{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)je[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,i=0|this.h1,o=i,a=0|this.h2,s=a,u=0|this.h3,c=u,f=0|this.h4,l=f;for(let t=0;t<5;t++){const e=4-t,h=Be[t],p=Re[t],d=xe[t],y=Ae[t],g=Ie[t],b=Le[t];for(let e=0;e<16;e++){const n=K(r+Ne(t,i,a,u)+je[d[e]]+h,g[e])+f|0;r=f,f=u,u=0|K(a,10),a=i,i=n}for(let t=0;t<16;t++){const r=K(n+Ne(e,o,s,c)+je[y[t]]+p,b[t])+l|0;n=l,l=c,c=0|K(s,10),s=o,o=r}}this.set(this.h1+a+c|0,this.h2+u+l|0,this.h3+f+n|0,this.h4+r+o|0,this.h0+i+s|0)}roundClean(){je.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const Ce=V((()=>new Ue)),Fe=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),Me=new Uint32Array(80);class De extends Y{constructor(){super(64,20,8,!1),this.A=0|Fe[0],this.B=0|Fe[1],this.C=0|Fe[2],this.D=0|Fe[3],this.E=0|Fe[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)Me[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)Me[t]=K(Me[t-3]^Me[t-8]^Me[t-14]^Me[t-16],1);let{A:r,B:n,C:i,D:o,E:a}=this;for(let t=0;t<80;t++){let e,s;t<20?(e=q(n,i,o),s=1518500249):t<40?(e=n^i^o,s=1859775393):t<60?(e=z(n,i,o),s=2400959708):(e=n^i^o,s=3395469782);const u=K(r,5)+e+a+s+Me[t]|0;a=o,o=i,i=K(n,30),n=r,r=u}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,this.set(r,n,i,o,a)}roundClean(){Me.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}const He=V((()=>new De));var Ke=g(287).Buffer;function Ge(t){return Ke.from(Ce(Uint8Array.from(t)))}function We(t){return Ke.from(He(Uint8Array.from(t)))}function Ve(t){return Ke.from(Q(Uint8Array.from(t)))}function qe(t){return Ke.from(Ce(Q(Uint8Array.from(t))))}function ze(t){return Ke.from(Q(Q(Uint8Array.from(t))))}var Ye=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],Xe={"BIP0340/challenge":Ke.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":Ke.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":Ke.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:Ke.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:Ke.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:Ke.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:Ke.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":Ke.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":Ke.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])};function Ze(t,e){return Ve(Ke.concat([Xe[t],e]))}var $e=g(287).Buffer,Je={};function Qe(t){var e;t?t!==Je.eccLib&&(rr("function"==typeof(e=t).isXOnlyPoint),rr(e.isXOnlyPoint(er("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),rr(e.isXOnlyPoint(er("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),rr(e.isXOnlyPoint(er("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),rr(e.isXOnlyPoint(er("0000000000000000000000000000000000000000000000000000000000000001"))),rr(!e.isXOnlyPoint(er("0000000000000000000000000000000000000000000000000000000000000000"))),rr(!e.isXOnlyPoint(er("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),rr("function"==typeof e.xOnlyPointAddTweak),nr.forEach((function(t){var r=e.xOnlyPointAddTweak(er(t.pubkey),er(t.tweak));null===t.result?rr(null===r):(rr(null!==r),rr(r.parity===t.parity),rr($e.from(r.xOnlyPubkey).equals(er(t.result))))})),Je.eccLib=t):Je.eccLib=t}function tr(){if(!Je.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return Je.eccLib}var er=function(t){return $e.from(t,"hex")};function rr(t){if(!t)throw new Error("ecc library invalid")}var nr=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}],ir=g(469),or=g(287).Buffer;function ar(t){return ar="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},ar(t)}function sr(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ur(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,fr(n.key),n)}}function cr(t,e,r){return e&&ur(t.prototype,e),r&&ur(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function fr(t){var e=function(t){if("object"!=ar(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ar(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ar(e)?e:e+""}var lr=bt;function hr(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 pr(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return hr((n*=4294967296)+r,9007199254740991),n+r}function dr(t,e,r){return hr(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}function yr(t){if(t.length<1)return t;for(var e=t.length-1,r=0,n=0;n<t.length/2;n++)r=t[n],t[n]=t[e],t[e]=r,e--;return t}function gr(t){var e=or.allocUnsafe(t.length);return t.copy(e),e}var br=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;sr(this,t),this.buffer=e,this.offset=r,lr(Nt(Lt,Ut),[e,r])}return cr(t,[{key:"writeUInt8",value:function(t){this.offset=this.buffer.writeUInt8(t,this.offset)}},{key:"writeInt32",value:function(t){this.offset=this.buffer.writeInt32LE(t,this.offset)}},{key:"writeUInt32",value:function(t){this.offset=this.buffer.writeUInt32LE(t,this.offset)}},{key:"writeUInt64",value:function(t){this.offset=dr(this.buffer,t,this.offset)}},{key:"writeVarInt",value:function(t){ir.encode(t,this.buffer,this.offset),this.offset+=ir.encode.bytes}},{key:"writeSlice",value:function(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.offset+=t.copy(this.buffer,this.offset)}},{key:"writeVarSlice",value:function(t){this.writeVarInt(t.length),this.writeSlice(t)}},{key:"writeVector",value:function(t){var e=this;this.writeVarInt(t.length),t.forEach((function(t){return e.writeVarSlice(t)}))}},{key:"end",value:function(){if(this.buffer.length===this.offset)return this.buffer;throw new Error("buffer size ".concat(this.buffer.length,", offset ").concat(this.offset))}}],[{key:"withCapacity",value:function(e){return new t(or.alloc(e))}}])}(),vr=cr((function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;sr(this,t),this.buffer=e,this.offset=r,lr(Nt(Lt,Ut),[e,r])}),[{key:"readUInt8",value:function(){var t=this.buffer.readUInt8(this.offset);return this.offset++,t}},{key:"readInt32",value:function(){var t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}},{key:"readUInt32",value:function(){var t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}},{key:"readUInt64",value:function(){var t=pr(this.buffer,this.offset);return this.offset+=8,t}},{key:"readVarInt",value:function(){var t=ir.decode(this.buffer,this.offset);return this.offset+=ir.decode.bytes,t}},{key:"readSlice",value:function(t){if(this.buffer.length<this.offset+t)throw new Error("Cannot read slice out of bounds");var e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}},{key:"readVarSlice",value:function(){return this.readSlice(this.readVarInt())}},{key:"readVector",value:function(){for(var t=this.readVarInt(),e=[],r=0;r<t;r++)e.push(this.readVarSlice());return e}}]);function wr(t){return function(t){if(Array.isArray(t))return mr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return mr(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?mr(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function mr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var _r=192,Er=128,Sr=function(t){return"left"in t&&"right"in t};function kr(t,e){if(t.length<33)throw new TypeError("The control-block length is too small. Got ".concat(t.length,", expected min 33."));for(var r=(t.length-33)/32,n=e,i=0;i<r;i++){var o=t.slice(33+32*i,65+32*i);n=n.compare(o)<0?Ir(n,o):Ir(o,n)}return n}function Tr(t){if(kt(t))return{hash:xr(t)};var e=[Tr(t[0]),Tr(t[1])];e.sort((function(t,e){return t.hash.compare(e.hash)}));var r=e[0],n=e[1];return{hash:Ir(r.hash,n.hash),left:r,right:n}}function Or(t,e){if(Sr(t)){var r=Or(t.left,e);if(void 0!==r)return[].concat(wr(r),[t.right.hash]);var n=Or(t.right,e);if(void 0!==n)return[].concat(wr(n),[t.left.hash])}else if(t.hash.equals(e))return[]}function xr(t){var e,r,n,i=t.version||_r;return Ze("TapLeaf",yt.Buffer.concat([yt.Buffer.from([i]),(e=t.output,r=ir.encodingLength(e.length),n=yt.Buffer.allocUnsafe(r),ir.encode(e.length,n),yt.Buffer.concat([n,e]))]))}function Ar(t,e){return Ze("TapTweak",yt.Buffer.concat(e?[t,e]:[t]))}function Pr(t,e){if(!yt.Buffer.isBuffer(t))return null;if(32!==t.length)return null;if(e&&32!==e.length)return null;var r=Ar(t,e),n=tr().xOnlyPointAddTweak(t,r);return n&&null!==n.xOnlyPubkey?{parity:n.parity,x:yt.Buffer.from(n.xOnlyPubkey)}:null}function Ir(t,e){return Ze("TapBranch",yt.Buffer.concat([t,e]))}function Lr(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:function(){var t=r.call(this);return this[e]=t,t},set:function(t){Object.defineProperty(this,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}})}function Br(t){var e;return function(){return void 0!==e?e:e=t()}}var Rr=it;function Nr(t,e){if(!t.data&&!t.output)throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),bt({network:bt.maybe(bt.Object),output:bt.maybe(bt.Buffer),data:bt.maybe(bt.arrayOf(bt.Buffer))},t);var r={name:"embed",network:t.network||O};if(Lr(r,"output",(function(){if(t.data)return re([Rr.OP_RETURN].concat(t.data))})),Lr(r,"data",(function(){if(t.output)return ne(t.output).slice(1)})),e.validate&&t.output){var n=ne(t.output);if(n[0]!==Rr.OP_RETURN)throw new TypeError("Output is invalid");if(!n.slice(1).every(bt.Buffer))throw new TypeError("Output is invalid");if(t.data&&!mt(t.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,t)}var jr=it,Ur=jr.OP_RESERVED;function Cr(t,e){if(!(t.input||t.output||t.pubkeys&&void 0!==t.m||t.signatures))throw new TypeError("Not enough data");function r(t){return ce(t)||void 0!==(e.allowIncomplete&&t===jr.OP_0)}e=Object.assign({validate:!0},e||{}),bt({network:bt.maybe(bt.Object),m:bt.maybe(bt.Number),n:bt.maybe(bt.Number),output:bt.maybe(bt.Buffer),pubkeys:bt.maybe(bt.arrayOf(_t)),signatures:bt.maybe(bt.arrayOf(r)),input:bt.maybe(bt.Buffer)},t);var n={network:t.network||O},i=[],o=!1;function a(t){o||(o=!0,i=ne(t),n.m=i[0]-Ur,n.n=i[i.length-2]-Ur,n.pubkeys=i.slice(1,-2))}if(Lr(n,"output",(function(){if(t.m&&n.n&&t.pubkeys)return re([].concat(Ur+t.m,t.pubkeys,Ur+n.n,jr.OP_CHECKMULTISIG))})),Lr(n,"m",(function(){if(n.output)return a(n.output),n.m})),Lr(n,"n",(function(){if(n.pubkeys)return n.pubkeys.length})),Lr(n,"pubkeys",(function(){if(t.output)return a(t.output),n.pubkeys})),Lr(n,"signatures",(function(){if(t.input)return ne(t.input).slice(1)})),Lr(n,"input",(function(){if(t.signatures)return re([jr.OP_0].concat(t.signatures))})),Lr(n,"witness",(function(){if(n.input)return[]})),Lr(n,"name",(function(){if(n.m&&n.n)return"p2ms(".concat(n.m," of ").concat(n.n,")")})),e.validate){if(t.output){if(a(t.output),!bt.Number(i[0]))throw new TypeError("Output is invalid");if(!bt.Number(i[i.length-2]))throw new TypeError("Output is invalid");if(i[i.length-1]!==jr.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every((function(t){return _t(t)})))throw new TypeError("Output is invalid");if(void 0!==t.m&&t.m!==n.m)throw new TypeError("m mismatch");if(void 0!==t.n&&t.n!==n.n)throw new TypeError("n mismatch");if(t.pubkeys&&!mt(t.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(t.pubkeys){if(void 0!==t.n&&t.n!==t.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=t.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(t.signatures){if(t.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(t.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(t.input){if(t.input[0]!==jr.OP_0)throw new TypeError("Input is invalid");if(0===n.signatures.length||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(t.signatures&&!mt(t.signatures,n.signatures))throw new TypeError("Signature mismatch");if(void 0!==t.m&&t.m!==t.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,t)}var Fr=it;function Mr(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||{}),bt({network:bt.maybe(bt.Object),output:bt.maybe(bt.Buffer),pubkey:bt.maybe(_t),signature:bt.maybe(ce),input:bt.maybe(bt.Buffer)},t);var r=Br((function(){return ne(t.input)})),n={name:"p2pk",network:t.network||O};if(Lr(n,"output",(function(){if(t.pubkey)return re([t.pubkey,Fr.OP_CHECKSIG])})),Lr(n,"pubkey",(function(){if(t.output)return t.output.slice(1,-1)})),Lr(n,"signature",(function(){if(t.input)return r()[0]})),Lr(n,"input",(function(){if(t.signature)return re([t.signature])})),Lr(n,"witness",(function(){if(n.input)return[]})),e.validate){if(t.output){if(t.output[t.output.length-1]!==Fr.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!_t(n.pubkey))throw new TypeError("Output pubkey is invalid");if(t.pubkey&&!t.pubkey.equals(n.pubkey))throw new TypeError("Pubkey mismatch")}if(t.signature&&t.input&&!t.input.equals(n.input))throw new TypeError("Signature mismatch");if(t.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!ce(n.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(n,t)}var Dr=g(287).Buffer,Hr=it;function Kr(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||{}),bt({network:bt.maybe(bt.Object),address:bt.maybe(bt.String),hash:bt.maybe(bt.BufferN(20)),output:bt.maybe(bt.BufferN(25)),pubkey:bt.maybe(_t),signature:bt.maybe(ce),input:bt.maybe(bt.Buffer)},t);var r=Br((function(){var e=Dr.from(et.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),n=Br((function(){return ne(t.input)})),i=t.network||O,o={name:"p2pkh",network:i};if(Lr(o,"address",(function(){if(o.hash){var t=Dr.allocUnsafe(21);return t.writeUInt8(i.pubKeyHash,0),o.hash.copy(t,1),et.encode(t)}})),Lr(o,"hash",(function(){return t.output?t.output.slice(3,23):t.address?r().hash:t.pubkey||o.pubkey?qe(t.pubkey||o.pubkey):void 0})),Lr(o,"output",(function(){if(o.hash)return re([Hr.OP_DUP,Hr.OP_HASH160,o.hash,Hr.OP_EQUALVERIFY,Hr.OP_CHECKSIG])})),Lr(o,"pubkey",(function(){if(t.input)return n()[1]})),Lr(o,"signature",(function(){if(t.input)return n()[0]})),Lr(o,"input",(function(){if(t.pubkey&&t.signature)return re([t.signature,t.pubkey])})),Lr(o,"witness",(function(){if(o.input)return[]})),e.validate){var a=Dr.from([]);if(t.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==r().hash.length)throw new TypeError("Invalid address");a=r().hash}if(t.hash){if(a.length>0&&!a.equals(t.hash))throw new TypeError("Hash mismatch");a=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==Hr.OP_DUP||t.output[1]!==Hr.OP_HASH160||20!==t.output[2]||t.output[23]!==Hr.OP_EQUALVERIFY||t.output[24]!==Hr.OP_CHECKSIG)throw new TypeError("Output is invalid");var s=t.output.slice(3,23);if(a.length>0&&!a.equals(s))throw new TypeError("Hash mismatch");a=s}if(t.pubkey){var u=qe(t.pubkey);if(a.length>0&&!a.equals(u))throw new TypeError("Hash mismatch");a=u}if(t.input){var c=n();if(2!==c.length)throw new TypeError("Input is invalid");if(!ce(c[0]))throw new TypeError("Input has invalid signature");if(!_t(c[1]))throw new TypeError("Input has invalid pubkey");if(t.signature&&!t.signature.equals(c[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(c[1]))throw new TypeError("Pubkey mismatch");var f=qe(c[1]);if(a.length>0&&!a.equals(f))throw new TypeError("Hash mismatch")}}return Object.assign(o,t)}var Gr=g(287).Buffer,Wr=it;function Vr(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||{}),bt({network:bt.maybe(bt.Object),address:bt.maybe(bt.String),hash:bt.maybe(bt.BufferN(20)),output:bt.maybe(bt.BufferN(23)),redeem:bt.maybe({network:bt.maybe(bt.Object),output:bt.maybe(bt.Buffer),input:bt.maybe(bt.Buffer),witness:bt.maybe(bt.arrayOf(bt.Buffer))}),input:bt.maybe(bt.Buffer),witness:bt.maybe(bt.arrayOf(bt.Buffer))},t);var r=t.network;r||(r=t.redeem&&t.redeem.network||O);var n={network:r},i=Br((function(){var e=Gr.from(et.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),o=Br((function(){return ne(t.input)})),a=Br((function(){var e=o(),n=e[e.length-1];return{network:r,output:n===Wr.OP_FALSE?Gr.from([]):n,input:re(e.slice(0,-1)),witness:t.witness||[]}}));if(Lr(n,"address",(function(){if(n.hash){var t=Gr.allocUnsafe(21);return t.writeUInt8(n.network.scriptHash,0),n.hash.copy(t,1),et.encode(t)}})),Lr(n,"hash",(function(){return t.output?t.output.slice(2,22):t.address?i().hash:n.redeem&&n.redeem.output?qe(n.redeem.output):void 0})),Lr(n,"output",(function(){if(n.hash)return re([Wr.OP_HASH160,n.hash,Wr.OP_EQUAL])})),Lr(n,"redeem",(function(){if(t.input)return a()})),Lr(n,"input",(function(){if(t.redeem&&t.redeem.input&&t.redeem.output)return re([].concat(ne(t.redeem.input),t.redeem.output))})),Lr(n,"witness",(function(){return n.redeem&&n.redeem.witness?n.redeem.witness:n.input?[]:void 0})),Lr(n,"name",(function(){var t=["p2sh"];return void 0!==n.redeem&&void 0!==n.redeem.name&&t.push(n.redeem.name),t.join("-")})),e.validate){var s=Gr.from([]);if(t.address){if(i().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==i().hash.length)throw new TypeError("Invalid address");s=i().hash}if(t.hash){if(s.length>0&&!s.equals(t.hash))throw new TypeError("Hash mismatch");s=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==Wr.OP_HASH160||20!==t.output[1]||t.output[22]!==Wr.OP_EQUAL)throw new TypeError("Output is invalid");var u=t.output.slice(2,22);if(s.length>0&&!s.equals(u))throw new TypeError("Hash mismatch");s=u}var c=function(t){if(t.output){var e=ne(t.output);if(!e||e.length<1)throw new TypeError("Redeem.output too short");if(t.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(Jt(e)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");var r=qe(t.output);if(s.length>0&&!s.equals(r))throw new TypeError("Hash mismatch");s=r}if(t.input){var n=t.input.length>0,i=t.witness&&t.witness.length>0;if(!n&&!i)throw new TypeError("Empty input");if(n&&i)throw new TypeError("Input and witness provided");if(n&&!$t(ne(t.input)))throw new TypeError("Non push-only scriptSig")}};if(t.input){var f=o();if(!f||f.length<1)throw new TypeError("Input too short");if(!Gr.isBuffer(a().output))throw new TypeError("Input is invalid");c(a())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==r)throw new TypeError("Network mismatch");if(t.input){var l=a();if(t.redeem.output&&!t.redeem.output.equals(l.output))throw new TypeError("Redeem.output mismatch");if(t.redeem.input&&!t.redeem.input.equals(l.input))throw new TypeError("Redeem.input mismatch")}c(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!mt(t.redeem.witness,t.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(n,t)}var qr=it,zr=1,Yr=80;function Xr(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||{}),bt({address:bt.maybe(bt.String),input:bt.maybe(bt.BufferN(0)),network:bt.maybe(bt.Object),output:bt.maybe(bt.BufferN(34)),internalPubkey:bt.maybe(bt.BufferN(32)),hash:bt.maybe(bt.BufferN(32)),pubkey:bt.maybe(bt.BufferN(32)),signature:bt.maybe(bt.anyOf(bt.BufferN(64),bt.BufferN(65))),witness:bt.maybe(bt.arrayOf(bt.Buffer)),scriptTree:bt.maybe(Tt),redeem:bt.maybe({output:bt.maybe(bt.Buffer),redeemVersion:bt.maybe(bt.Number),witness:bt.maybe(bt.arrayOf(bt.Buffer))}),redeemVersion:bt.maybe(bt.Number)},t);var r=Br((function(){return me(t.address)})),n=Br((function(){if(t.witness&&t.witness.length)return t.witness.length>=2&&t.witness[t.witness.length-1][0]===Yr?t.witness.slice(0,-1):t.witness.slice()})),i=Br((function(){return t.scriptTree?Tr(t.scriptTree):t.hash?{hash:t.hash}:void 0})),o=t.network||O,a={name:"p2tr",network:o};if(Lr(a,"address",(function(){if(a.pubkey){var t=C.p2.toWords(a.pubkey);return t.unshift(zr),C.p2.encode(o.bech32,t)}})),Lr(a,"hash",(function(){var t=i();if(t)return t.hash;var e=n();if(e&&e.length>1){var r=e[e.length-1],o=r[0]&St;return kr(r,xr({output:e[e.length-2],version:o}))}return null})),Lr(a,"output",(function(){if(a.pubkey)return re([qr.OP_1,a.pubkey])})),Lr(a,"redeemVersion",(function(){return t.redeemVersion?t.redeemVersion:t.redeem&&void 0!==t.redeem.redeemVersion&&null!==t.redeem.redeemVersion?t.redeem.redeemVersion:_r})),Lr(a,"redeem",(function(){var t=n();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&St}})),Lr(a,"pubkey",(function(){if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(a.internalPubkey){var e=Pr(a.internalPubkey,a.hash);if(e)return e.x}})),Lr(a,"internalPubkey",(function(){if(t.internalPubkey)return t.internalPubkey;var e=n();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),Lr(a,"signature",(function(){if(t.signature)return t.signature;var e=n();return e&&1===e.length?e[0]:void 0})),Lr(a,"witness",(function(){if(t.witness)return t.witness;var e=i();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){var r=Or(e,xr({output:t.redeem.output,version:a.redeemVersion}));if(!r)return;var n=Pr(t.internalPubkey,e.hash);if(!n)return;var o=yt.Buffer.concat([yt.Buffer.from([a.redeemVersion|n.parity]),t.internalPubkey].concat(r));return[t.redeem.output,o]}return t.signature?[t.signature]:void 0})),e.validate){var s=yt.Buffer.from([]);if(t.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==zr)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");s=r().data}if(t.pubkey){if(s.length>0&&!s.equals(t.pubkey))throw new TypeError("Pubkey mismatch");s=t.pubkey}if(t.output){if(34!==t.output.length||t.output[0]!==qr.OP_1||32!==t.output[1])throw new TypeError("Output is invalid");if(s.length>0&&!s.equals(t.output.slice(2)))throw new TypeError("Pubkey mismatch");s=t.output.slice(2)}if(t.internalPubkey){var u=Pr(t.internalPubkey,a.hash);if(s.length>0&&!s.equals(u.x))throw new TypeError("Pubkey mismatch");s=u.x}var c=i();if(t.hash&&c&&!t.hash.equals(c.hash))throw new TypeError("Hash mismatch");if(t.redeem&&t.redeem.output&&c&&!Or(c,xr({output:t.redeem.output,version:a.redeemVersion})))throw new TypeError("Redeem script not in tree");var f=n();if(t.redeem&&a.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==a.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(t.redeem.output){if(0===ne(t.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(a.redeem.output&&!t.redeem.output.equals(a.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(t.redeem.witness&&a.redeem.witness&&!mt(t.redeem.witness,a.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(f&&f.length)if(1===f.length){if(t.signature&&!t.signature.equals(f[0]))throw new TypeError("Signature mismatch")}else{var l=f[f.length-1];if(l.length<33)throw new TypeError("The control-block length is too small. Got ".concat(l.length,", expected min 33."));if((l.length-33)%32!=0)throw new TypeError("The control-block length of ".concat(l.length," is incorrect!"));var h=(l.length-33)/32;if(h>128)throw new TypeError("The script path is too long. Got ".concat(h,", expected max 128."));var p=l.slice(1,33);if(t.internalPubkey&&!t.internalPubkey.equals(p))throw new TypeError("Internal pubkey mismatch");if(!tr().isXOnlyPoint(p))throw new TypeError("Invalid internalPubkey for p2tr witness");var d=l[0]&St,y=Pr(p,kr(l,xr({output:f[f.length-2],version:d})));if(!y)throw new TypeError("Invalid outputKey for p2tr witness");if(s.length&&!s.equals(y.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(y.parity!==(1&l[0]))throw new Error("Incorrect parity")}}return Object.assign(a,t)}var Zr=g(287).Buffer,$r=it,Jr=Zr.alloc(0);function Qr(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||{}),bt({address:bt.maybe(bt.String),hash:bt.maybe(bt.BufferN(20)),input:bt.maybe(bt.BufferN(0)),network:bt.maybe(bt.Object),output:bt.maybe(bt.BufferN(22)),pubkey:bt.maybe(_t),signature:bt.maybe(ce),witness:bt.maybe(bt.arrayOf(bt.Buffer))},t);var r=Br((function(){var e=C.I.decode(t.address),r=e.words.shift(),n=C.I.fromWords(e.words);return{version:r,prefix:e.prefix,data:Zr.from(n)}})),n=t.network||O,i={name:"p2wpkh",network:n};if(Lr(i,"address",(function(){if(i.hash){var t=C.I.toWords(i.hash);return t.unshift(0),C.I.encode(n.bech32,t)}})),Lr(i,"hash",(function(){return t.output?t.output.slice(2,22):t.address?r().data:t.pubkey||i.pubkey?qe(t.pubkey||i.pubkey):void 0})),Lr(i,"output",(function(){if(i.hash)return re([$r.OP_0,i.hash])})),Lr(i,"pubkey",(function(){return t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0})),Lr(i,"signature",(function(){if(t.witness)return t.witness[0]})),Lr(i,"input",(function(){if(i.witness)return Jr})),Lr(i,"witness",(function(){if(t.pubkey&&t.signature)return[t.signature,t.pubkey]})),e.validate){var o=Zr.from([]);if(t.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(20!==r().data.length)throw new TypeError("Invalid address data");o=r().data}if(t.hash){if(o.length>0&&!o.equals(t.hash))throw new TypeError("Hash mismatch");o=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==$r.OP_0||20!==t.output[1])throw new TypeError("Output is invalid");if(o.length>0&&!o.equals(t.output.slice(2)))throw new TypeError("Hash mismatch");o=t.output.slice(2)}if(t.pubkey){var a=qe(t.pubkey);if(o.length>0&&!o.equals(a))throw new TypeError("Hash mismatch");if(o=a,!_t(t.pubkey)||33!==t.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(t.witness){if(2!==t.witness.length)throw new TypeError("Witness is invalid");if(!ce(t.witness[0]))throw new TypeError("Witness has invalid signature");if(!_t(t.witness[1])||33!==t.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError("Pubkey mismatch");var s=qe(t.witness[1]);if(o.length>0&&!o.equals(s))throw new TypeError("Hash mismatch")}}return Object.assign(i,t)}var tn=g(287).Buffer,en=it,rn=tn.alloc(0);function nn(t){return!(!tn.isBuffer(t)||65!==t.length||4!==t[0]||!_t(t))}function on(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||{}),bt({network:bt.maybe(bt.Object),address:bt.maybe(bt.String),hash:bt.maybe(bt.BufferN(32)),output:bt.maybe(bt.BufferN(34)),redeem:bt.maybe({input:bt.maybe(bt.Buffer),network:bt.maybe(bt.Object),output:bt.maybe(bt.Buffer),witness:bt.maybe(bt.arrayOf(bt.Buffer))}),input:bt.maybe(bt.BufferN(0)),witness:bt.maybe(bt.arrayOf(bt.Buffer))},t);var r=Br((function(){var e=C.I.decode(t.address),r=e.words.shift(),n=C.I.fromWords(e.words);return{version:r,prefix:e.prefix,data:tn.from(n)}})),n=Br((function(){return ne(t.redeem.input)})),i=t.network;i||(i=t.redeem&&t.redeem.network||O);var o={network:i};if(Lr(o,"address",(function(){if(o.hash){var t=C.I.toWords(o.hash);return t.unshift(0),C.I.encode(i.bech32,t)}})),Lr(o,"hash",(function(){return t.output?t.output.slice(2):t.address?r().data:o.redeem&&o.redeem.output?Ve(o.redeem.output):void 0})),Lr(o,"output",(function(){if(o.hash)return re([en.OP_0,o.hash])})),Lr(o,"redeem",(function(){if(t.witness)return{output:t.witness[t.witness.length-1],input:rn,witness:t.witness.slice(0,-1)}})),Lr(o,"input",(function(){if(o.witness)return rn})),Lr(o,"witness",(function(){if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){var e=ae(n());return o.redeem=Object.assign({witness:e},t.redeem),o.redeem.input=rn,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)})),Lr(o,"name",(function(){var t=["p2wsh"];return void 0!==o.redeem&&void 0!==o.redeem.name&&t.push(o.redeem.name),t.join("-")})),e.validate){var a=tn.from([]);if(t.address){if(r().prefix!==i.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");a=r().data}if(t.hash){if(a.length>0&&!a.equals(t.hash))throw new TypeError("Hash mismatch");a=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==en.OP_0||32!==t.output[1])throw new TypeError("Output is invalid");var s=t.output.slice(2);if(a.length>0&&!a.equals(s))throw new TypeError("Hash mismatch");a=s}if(t.redeem){if(t.redeem.network&&t.redeem.network!==i)throw new TypeError("Network mismatch");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(t.redeem.output){var u=ne(t.redeem.output);if(!u||u.length<1)throw new TypeError("Redeem.output is invalid");if(t.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(Jt(u)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");var c=Ve(t.redeem.output);if(a.length>0&&!a.equals(c))throw new TypeError("Hash mismatch");a=c}if(t.redeem.input&&!$t(n()))throw new TypeError("Non push-only scriptSig");if(t.witness&&t.redeem.witness&&!mt(t.witness,t.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(t.redeem.input&&n().some(nn)||t.redeem.output&&(ne(t.redeem.output)||[]).some(nn))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(t.witness&&t.witness.length>0){var f=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(f))throw new TypeError("Witness and redeem.output mismatch");if(t.witness.some(nn)||(ne(f)||[]).some(nn))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,t)}var an=g(287).Buffer;function sn(t){return sn="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},sn(t)}function un(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,fn(n.key),n)}}function cn(t,e,r){return(e=fn(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function fn(t){var e=function(t){if("object"!=sn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sn(e)?e:e+""}var ln=bt;function hn(t){var e=t.length;return ir.encodingLength(e)+e}var pn=an.allocUnsafe(0),dn=[],yn=an.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),gn=an.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),bn=an.from("ffffffffffffffff","hex"),vn={script:pn,valueBuffer:bn},wn=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),cn(this,"version",1),cn(this,"locktime",0),cn(this,"ins",[]),cn(this,"outs",[])}return e=t,r=[{key:"isCoinbase",value:function(){return 1===this.ins.length&&t.isCoinbaseHash(this.ins[0].hash)}},{key:"addInput",value:function(e,r,n,i){return ln(Nt(xt,Ut,Rt(Ut),Rt(Lt)),arguments),Mt(n)&&(n=t.DEFAULT_SEQUENCE),this.ins.push({hash:e,index:r,script:i||pn,sequence:n,witness:dn})-1}},{key:"addOutput",value:function(t,e){return ln(Nt(Lt,Et),arguments),this.outs.push({script:t,value:e})-1}},{key:"hasWitnesses",value:function(){return this.ins.some((function(t){return 0!==t.witness.length}))}},{key:"weight",value:function(){return 3*this.byteLength(!1)+this.byteLength(!0)}},{key:"virtualSize",value:function(){return Math.ceil(this.weight()/4)}},{key:"byteLength",value:function(){var t=(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&this.hasWitnesses();return(t?10:8)+ir.encodingLength(this.ins.length)+ir.encodingLength(this.outs.length)+this.ins.reduce((function(t,e){return t+40+hn(e.script)}),0)+this.outs.reduce((function(t,e){return t+8+hn(e.script)}),0)+(t?this.ins.reduce((function(t,e){return t+(n=(r=e.witness).length,ir.encodingLength(n)+r.reduce((function(t,e){return t+hn(e)}),0));var r,n}),0):0)}},{key:"clone",value:function(){var e=new t;return e.version=this.version,e.locktime=this.locktime,e.ins=this.ins.map((function(t){return{hash:t.hash,index:t.index,script:t.script,sequence:t.sequence,witness:t.witness}})),e.outs=this.outs.map((function(t){return{script:t.script,value:t.value}})),e}},{key:"hashForSignature",value:function(e,r,n){if(ln(Nt(Ut,Lt,At),arguments),e>=this.ins.length)return gn;var i=re(ne(r).filter((function(t){return t!==it.OP_CODESEPARATOR}))),o=this.clone();if((31&n)===t.SIGHASH_NONE)o.outs=[],o.ins.forEach((function(t,r){r!==e&&(t.sequence=0)}));else if((31&n)===t.SIGHASH_SINGLE){if(e>=this.outs.length)return gn;o.outs.length=e+1;for(var a=0;a<e;a++)o.outs[a]=vn;o.ins.forEach((function(t,r){r!==e&&(t.sequence=0)}))}n&t.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[e]],o.ins[0].script=i):(o.ins.forEach((function(t){t.script=pn})),o.ins[e].script=i);var s=an.allocUnsafe(o.byteLength(!1)+4);return s.writeInt32LE(n,s.length-4),o.__toBuffer(s,0,!1),ze(s)}},{key:"hashForWitnessV1",value:function(e,r,n,i,o,a){if(ln(Nt(Ut,ln.arrayOf(Lt),ln.arrayOf(Et),Ut),arguments),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");var s=i===t.SIGHASH_DEFAULT?t.SIGHASH_ALL:i&t.SIGHASH_OUTPUT_MASK,u=(i&t.SIGHASH_INPUT_MASK)===t.SIGHASH_ANYONECANPAY,c=s===t.SIGHASH_NONE,f=s===t.SIGHASH_SINGLE,l=pn,h=pn,p=pn,d=pn,y=pn;if(!u){var g=br.withCapacity(36*this.ins.length);this.ins.forEach((function(t){g.writeSlice(t.hash),g.writeUInt32(t.index)})),l=Ve(g.end()),g=br.withCapacity(8*this.ins.length),n.forEach((function(t){return g.writeUInt64(t)})),h=Ve(g.end()),g=br.withCapacity(r.map(hn).reduce((function(t,e){return t+e}))),r.forEach((function(t){return g.writeVarSlice(t)})),p=Ve(g.end()),g=br.withCapacity(4*this.ins.length),this.ins.forEach((function(t){return g.writeUInt32(t.sequence)})),d=Ve(g.end())}if(c||f){if(f&&e<this.outs.length){var b=this.outs[e],v=br.withCapacity(8+hn(b.script));v.writeUInt64(b.value),v.writeVarSlice(b.script),y=Ve(v.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");var w=this.outs.map((function(t){return 8+hn(t.script)})).reduce((function(t,e){return t+e})),m=br.withCapacity(w);this.outs.forEach((function(t){m.writeUInt64(t.value),m.writeVarSlice(t.script)})),y=Ve(m.end())}var _=(o?2:0)+(a?1:0),E=174-(u?49:0)-(c?32:0)+(a?32:0)+(o?37:0),S=br.withCapacity(E);if(S.writeUInt8(i),S.writeInt32(this.version),S.writeUInt32(this.locktime),S.writeSlice(l),S.writeSlice(h),S.writeSlice(p),S.writeSlice(d),c||f||S.writeSlice(y),S.writeUInt8(_),u){var k=this.ins[e];S.writeSlice(k.hash),S.writeUInt32(k.index),S.writeUInt64(n[e]),S.writeVarSlice(r[e]),S.writeUInt32(k.sequence)}else S.writeUInt32(e);if(a){var T=br.withCapacity(hn(a));T.writeVarSlice(a),S.writeSlice(Ve(T.end()))}return f&&S.writeSlice(y),o&&(S.writeSlice(o),S.writeUInt8(0),S.writeUInt32(4294967295)),Ze("TapSighash",an.concat([an.from([0]),S.end()]))}},{key:"hashForWitnessV0",value:function(e,r,n,i){ln(Nt(Ut,Lt,Et,Ut),arguments);var o,a=an.from([]),s=yn,u=yn,c=yn;if(i&t.SIGHASH_ANYONECANPAY||(a=an.allocUnsafe(36*this.ins.length),o=new br(a,0),this.ins.forEach((function(t){o.writeSlice(t.hash),o.writeUInt32(t.index)})),u=ze(a)),i&t.SIGHASH_ANYONECANPAY||(31&i)===t.SIGHASH_SINGLE||(31&i)===t.SIGHASH_NONE||(a=an.allocUnsafe(4*this.ins.length),o=new br(a,0),this.ins.forEach((function(t){o.writeUInt32(t.sequence)})),c=ze(a)),(31&i)!==t.SIGHASH_SINGLE&&(31&i)!==t.SIGHASH_NONE){var f=this.outs.reduce((function(t,e){return t+8+hn(e.script)}),0);a=an.allocUnsafe(f),o=new br(a,0),this.outs.forEach((function(t){o.writeUInt64(t.value),o.writeVarSlice(t.script)})),s=ze(a)}else if((31&i)===t.SIGHASH_SINGLE&&e<this.outs.length){var l=this.outs[e];a=an.allocUnsafe(8+hn(l.script)),(o=new br(a,0)).writeUInt64(l.value),o.writeVarSlice(l.script),s=ze(a)}a=an.allocUnsafe(156+hn(r)),o=new br(a,0);var h=this.ins[e];return o.writeInt32(this.version),o.writeSlice(u),o.writeSlice(c),o.writeSlice(h.hash),o.writeUInt32(h.index),o.writeVarSlice(r),o.writeUInt64(n),o.writeUInt32(h.sequence),o.writeSlice(s),o.writeUInt32(this.locktime),o.writeUInt32(i),ze(a)}},{key:"getHash",value:function(t){return t&&this.isCoinbase()?an.alloc(32,0):ze(this.__toBuffer(void 0,void 0,t))}},{key:"getId",value:function(){return yr(this.getHash(!1)).toString("hex")}},{key:"toBuffer",value:function(t,e){return this.__toBuffer(t,e,!0)}},{key:"toHex",value:function(){return this.toBuffer(void 0,void 0).toString("hex")}},{key:"setInputScript",value:function(t,e){ln(Nt(At,Lt),arguments),this.ins[t].script=e}},{key:"setWitness",value:function(t,e){ln(Nt(At,[Lt]),arguments),this.ins[t].witness=e}},{key:"__toBuffer",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e||(e=an.allocUnsafe(this.byteLength(n)));var i=new br(e,r||0);i.writeInt32(this.version);var o=n&&this.hasWitnesses();return o&&(i.writeUInt8(t.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(t.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach((function(t){i.writeSlice(t.hash),i.writeUInt32(t.index),i.writeVarSlice(t.script),i.writeUInt32(t.sequence)})),i.writeVarInt(this.outs.length),this.outs.forEach((function(t){void 0!==t.value?i.writeUInt64(t.value):i.writeSlice(t.valueBuffer),i.writeVarSlice(t.script)})),o&&this.ins.forEach((function(t){i.writeVector(t.witness)})),i.writeUInt32(this.locktime),void 0!==r?e.slice(r,i.offset):e}}],n=[{key:"fromBuffer",value:function(e,r){var n=new vr(e),i=new t;i.version=n.readInt32();var o=n.readUInt8(),a=n.readUInt8(),s=!1;o===t.ADVANCED_TRANSACTION_MARKER&&a===t.ADVANCED_TRANSACTION_FLAG?s=!0:n.offset-=2;for(var u=n.readVarInt(),c=0;c<u;++c){var f=n.readSlice(32),l=n.readUInt32(),h=n.readVarSlice(),p=n.readUInt32();i.ins.push({hash:f,index:l,script:h,sequence:p,witness:dn})}for(var d=n.readVarInt(),y=0;y<d;++y)i.outs.push({value:n.readUInt64(),script:n.readVarSlice()});if(s){for(var g=0;g<u;++g)i.ins[g].witness=n.readVector();if(!i.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(i.locktime=n.readUInt32(),r)return i;if(n.offset!==e.length)throw new Error("Transaction has unexpected data");return i}},{key:"fromHex",value:function(e){return t.fromBuffer(an.from(e,"hex"),!1)}},{key:"isCoinbaseHash",value:function(t){ln(xt,t);for(var e=0;e<32;++e)if(0!==t[e])return!1;return!0}}],r&&un(e.prototype,r),n&&un(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}();cn(wn,"DEFAULT_SEQUENCE",4294967295),cn(wn,"SIGHASH_DEFAULT",0),cn(wn,"SIGHASH_ALL",1),cn(wn,"SIGHASH_NONE",2),cn(wn,"SIGHASH_SINGLE",3),cn(wn,"SIGHASH_ANYONECANPAY",128),cn(wn,"SIGHASH_OUTPUT_MASK",3),cn(wn,"SIGHASH_INPUT_MASK",128),cn(wn,"ADVANCED_TRANSACTION_MARKER",0),cn(wn,"ADVANCED_TRANSACTION_FLAG",1);var mn=g(287).Buffer,_n=g(287).Buffer;function En(t){return En="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},En(t)}function Sn(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,Tn(n.key),n)}}function kn(t,e,r){return(e=Tn(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Tn(t){var e=function(t){if("object"!=En(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=En(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==En(e)?e:e+""}var On=bt,xn=new TypeError("Cannot compute merkle root for zero transactions"),An=new TypeError("Cannot compute witness commit for non-segwit block"),Pn=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),kn(this,"version",1),kn(this,"prevHash",void 0),kn(this,"merkleRoot",void 0),kn(this,"timestamp",0),kn(this,"witnessCommit",void 0),kn(this,"bits",0),kn(this,"nonce",0),kn(this,"transactions",void 0)}return e=t,r=[{key:"getWitnessCommit",value:function(){if(!In(this.transactions))return null;var t=this.transactions[0].outs.filter((function(t){return t.script.slice(0,6).equals(_n.from("6a24aa21a9ed","hex"))})).map((function(t){return t.script.slice(6,38)}));if(0===t.length)return null;var e=t[t.length-1];return e instanceof _n&&32===e.length?e:null}},{key:"hasWitnessCommit",value:function(){return this.witnessCommit instanceof _n&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}},{key:"hasWitness",value:function(){return(t=this.transactions)instanceof Array&&t.some((function(t){return"object"===En(t)&&t.ins instanceof Array&&t.ins.some((function(t){return"object"===En(t)&&t.witness instanceof Array&&t.witness.length>0}))}));var t}},{key:"weight",value:function(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}},{key:"byteLength",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t||!this.transactions?80:80+ir.encodingLength(this.transactions.length)+this.transactions.reduce((function(t,r){return t+r.byteLength(e)}),0)}},{key:"getHash",value:function(){return ze(this.toBuffer(!0))}},{key:"getId",value:function(){return yr(this.getHash()).toString("hex")}},{key:"getUTCDate",value:function(){var t=new Date(0);return t.setUTCSeconds(this.timestamp),t}},{key:"toBuffer",value:function(t){var e=_n.allocUnsafe(this.byteLength(t)),r=new br(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||(ir.encode(this.transactions.length,e,r.offset),r.offset+=ir.encode.bytes,this.transactions.forEach((function(t){var n=t.byteLength();t.toBuffer(e,r.offset),r.offset+=n}))),e}},{key:"toHex",value:function(t){return this.toBuffer(t).toString("hex")}},{key:"checkTxRoots",value:function(){var t=this.hasWitnessCommit();return!(!t&&this.hasWitness())&&this.__checkMerkleRoot()&&(!t||this.__checkWitnessCommit())}},{key:"checkProofOfWork",value:function(){var e=yr(this.getHash()),r=t.calculateTarget(this.bits);return e.compare(r)<=0}},{key:"__checkMerkleRoot",value:function(){if(!this.transactions)throw xn;var e=t.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)}},{key:"__checkWitnessCommit",value:function(){if(!this.transactions)throw xn;if(!this.hasWitnessCommit())throw An;var e=t.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(e)}}],n=[{key:"fromBuffer",value:function(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");var r=new vr(e),n=new t;if(n.version=r.readInt32(),n.prevHash=r.readSlice(32),n.merkleRoot=r.readSlice(32),n.timestamp=r.readUInt32(),n.bits=r.readUInt32(),n.nonce=r.readUInt32(),80===e.length)return n;var i=function(){var t=wn.fromBuffer(r.buffer.slice(r.offset),!0);return r.offset+=t.byteLength(),t},o=r.readVarInt();n.transactions=[];for(var a=0;a<o;++a){var s=i();n.transactions.push(s)}var u=n.getWitnessCommit();return u&&(n.witnessCommit=u),n}},{key:"fromHex",value:function(e){return t.fromBuffer(_n.from(e,"hex"))}},{key:"calculateTarget",value:function(t){var e=((4278190080&t)>>24)-3,r=8388607&t,n=_n.alloc(32,0);return n.writeUIntBE(r,29-e,3),n}},{key:"calculateMerkleRoot",value:function(t,e){if(On([{getHash:Ct}],t),0===t.length)throw xn;if(e&&!In(t))throw An;var r=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o<r;o+=2,++i){var a=n[o],s=o+1===r?a:n[o+1],u=mn.concat([a,s]);n[i]=e(u)}r=i}return n[0]}(t.map((function(t){return t.getHash(e)})),ze);return e?ze(_n.concat([r,t[0].ins[0].witness[0]])):r}}],r&&Sn(e.prototype,r),n&&Sn(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}();function In(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}var Ln=g(614),Bn=g(394),Rn=g(699);function Nn(t){return Nn="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},Nn(t)}function jn(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Un(t){var e=function(t){if("object"!=Nn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Nn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Nn(e)?e:e+""}var Cn=function(){return t=function t(){var e,r,n,i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,r="cacheByLength",n=new Map,(r=Un(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,this.registry=new FinalizationRegistry((function(t){var e=i.cacheByLength.get(t.length);e&&(e.delete(t),0===e.size&&i.cacheByLength.delete(t.length))}))},e=[{key:"addSignature",value:function(t,e){var r=t.length,n={length:r,dataRef:new WeakRef(t),signature:e};return this.cacheByLength.has(r)||this.cacheByLength.set(r,new Set),this.cacheByLength.get(r).add(n),this.registry.register(t,n),e}},{key:"getSignature",value:function(t){var e=t.length,r=this.cacheByLength.get(e);if(r){var n,i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return jn(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?jn(t,e):void 0}}(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(r);try{for(i.s();!(n=i.n()).done;){var o=n.value,a=o.dataRef.deref();if(a&&a.equals(t))return o.signature}}catch(t){i.e(t)}finally{i.f()}}}},{key:"clearCache",value:function(){this.cacheByLength.clear()}}],e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Un(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Fn(t){return Fn="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},Fn(t)}function Mn(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Dn(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,Hn(n.key),n)}}function Hn(t){var e=function(t){if("object"!=Fn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Fn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Fn(e)?e:e+""}var Kn=function(){function t(){var e,r,n,i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,r="cacheBySigner",n=new Map,(r=Hn(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,this.registry=new FinalizationRegistry((function(t){var e=i.cacheBySigner.get(t.pubKey);e&&(e.delete(t),0===e.size&&i.cacheBySigner.delete(t.pubKey))}))}return e=t,r=[{key:"addSignature",value:function(t,e,r){var n={pubKey:t,dataRef:new WeakRef(e),signature:r};return this.cacheBySigner.has(t)||this.cacheBySigner.set(t,new Set),this.cacheBySigner.get(t).add(n),this.registry.register(e,n),r}},{key:"getSignature",value:function(t,e){var r=this.cacheBySigner.get(t);if(r){var n,i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return Mn(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Mn(t,e):void 0}}(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(r);try{for(i.s();!(n=i.n()).done;){var o=n.value,a=o.dataRef.deref();if(a&&a.equals(e))return o.signature}}catch(t){i.e(t)}finally{i.f()}}}},{key:"clearCache",value:function(){this.cacheBySigner.clear()}},{key:"clearCacheForSigner",value:function(t){this.cacheBySigner.delete(t)}}],n=[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}}],r&&Dn(e.prototype,r),n&&Dn(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}(),Gn=g(287).Buffer,Wn=Kn.getInstance();function Vn(t){if(t.publicKey&&Gn.isBuffer(t.publicKey))return t.publicKey.toString("hex")}function qn(t){var e=t;e.hasHook||(e.hasHook=!0,e.signatureManager=new Cn,function(t){var e=t.sign;e&&(t.sign=new Proxy(e,{apply:function(e,r,n){var i=Vn(t),o=n[0];if(i){var a=Wn.getSignature(i,o);return a||(a=Wn.addSignature(i,o,Reflect.apply(e,r,n))),a}var s=t.signatureManager.getSignature(o);return s||(s=t.signatureManager.addSignature(o,Reflect.apply(e,r,n))),s}}));var r=t.signSchnorr;r&&(t.signSchnorr=new Proxy(r,{apply:function(e,r,n){var i=Vn(t),o=n[0];if(i){var a=Wn.getSignature(i,o);return a||(a=Wn.addSignature(i,o,Reflect.apply(e,r,n))),a}var s=t.signatureManager.getSignature(o);return s||(s=t.signatureManager.addSignature(o,Reflect.apply(e,r,n))),s}}))}(e))}const zn=2n**256n,Yn=zn-0x1000003d1n,Xn=zn-0x14551231950b75fc4402da1732fc9bebfn,Zn=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,$n=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,Jn={p:Yn,n:Xn,a:0n,b:7n,Gx:Zn,Gy:$n},Qn=t=>ui(ui(t*t)*t+Jn.b),ti=(t="")=>{throw new Error(t)},ei=t=>"bigint"==typeof t,ri=t=>"string"==typeof t,ni=t=>ei(t)&&0n<t&&t<Yn,ii=t=>ei(t)&&0n<t&&t<Xn,oi=(t,e)=>!(t=>t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name)(t)||"number"==typeof e&&e>0&&t.length!==e?ti("Uint8Array expected"):t,ai=t=>new Uint8Array(t),si=(t,e)=>oi(ri(t)?yi(t):ai(oi(t)),e),ui=(t,e=Yn)=>{let r=t%e;return r>=0n?r:e+r},ci=t=>t instanceof fi?t:ti("Point expected");class fi{constructor(t,e,r){this.px=t,this.py=e,this.pz=r}static fromAffine(t){return 0n===t.x&&0n===t.y?fi.ZERO:new fi(t.x,t.y,1n)}static fromHex(t){let e;const r=(t=si(t))[0],n=t.subarray(1),i=bi(n,0,32),o=t.length;if(33===o&&[2,3].includes(r)){ni(i)||ti("Point hex invalid: x not FE");let t=Ei(Qn(i));!(1&~r)!=(1n===(1n&t))&&(t=ui(-t)),e=new fi(i,t,1n)}return 65===o&&4===r&&(e=new fi(i,bi(n,32,64),1n)),e?e.ok():ti("Point is not on curve")}static fromPrivateKey(t){return li.mul(Si(t))}get x(){return this.aff().x}get y(){return this.aff().y}equals(t){const{px:e,py:r,pz:n}=this,{px:i,py:o,pz:a}=ci(t),s=ui(e*a),u=ui(i*n),c=ui(r*a),f=ui(o*n);return s===u&&c===f}negate(){return new fi(this.px,ui(-this.py),this.pz)}double(){return this.add(this)}add(t){const{px:e,py:r,pz:n}=this,{px:i,py:o,pz:a}=ci(t),{a:s,b:u}=Jn;let c=0n,f=0n,l=0n;const h=ui(3n*u);let p=ui(e*i),d=ui(r*o),y=ui(n*a),g=ui(e+r),b=ui(i+o);g=ui(g*b),b=ui(p+d),g=ui(g-b),b=ui(e+n);let v=ui(i+a);return b=ui(b*v),v=ui(p+y),b=ui(b-v),v=ui(r+n),c=ui(o+a),v=ui(v*c),c=ui(d+y),v=ui(v-c),l=ui(s*b),c=ui(h*y),l=ui(c+l),c=ui(d-l),l=ui(d+l),f=ui(c*l),d=ui(p+p),d=ui(d+p),y=ui(s*y),b=ui(h*b),d=ui(d+y),y=ui(p-y),y=ui(s*y),b=ui(b+y),p=ui(d*b),f=ui(f+p),p=ui(v*b),c=ui(g*c),c=ui(c-p),p=ui(g*d),l=ui(v*l),l=ui(l+p),new fi(c,f,l)}mul(t,e=!0){if(!e&&0n===t)return hi;if(ii(t)||ti("invalid scalar"),this.equals(li))return Ai(t).p;let r=hi,n=li;for(let i=this;t>0n;i=i.double(),t>>=1n)1n&t?r=r.add(i):e&&(n=n.add(i));return r}mulAddQUns(t,e,r){return this.mul(e,!1).add(t.mul(r,!1)).ok()}toAffine(){const{px:t,py:e,pz:r}=this;if(this.equals(hi))return{x:0n,y:0n};if(1n===r)return{x:t,y:e};const n=_i(r);return 1n!==ui(r*n)&&ti("invalid inverse"),{x:ui(t*n),y:ui(e*n)}}assertValidity(){const{x:t,y:e}=this.aff();return ni(t)&&ni(e)||ti("Point invalid: x or y"),ui(e*e)===Qn(t)?this:ti("Point invalid: not on curve")}multiply(t){return this.mul(t)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(t=!0){const{x:e,y:r}=this.aff();return(t?0n===(1n&r)?"02":"03":"04")+wi(e)+(t?"":wi(r))}toRawBytes(t=!0){return yi(this.toHex(t))}}fi.BASE=new fi(Zn,$n,1n),fi.ZERO=new fi(0n,1n,0n);const{BASE:li,ZERO:hi}=fi,pi=(t,e)=>t.toString(16).padStart(e,"0"),di=t=>Array.from(t).map((t=>pi(t,2))).join(""),yi=t=>{const e=t.length;(!ri(t)||e%2)&&ti("hex invalid 1");const r=ai(e/2);for(let e=0;e<r.length;e++){const n=2*e,i=t.slice(n,n+2),o=Number.parseInt(i,16);(Number.isNaN(o)||o<0)&&ti("hex invalid 2"),r[e]=o}return r},gi=t=>BigInt("0x"+(di(t)||"0")),bi=(t,e,r)=>gi(t.slice(e,r)),vi=t=>ei(t)&&t>=0n&&t<zn?yi(pi(t,64)):ti("bigint expected"),wi=t=>di(vi(t)),mi=(...t)=>{const e=ai(t.reduce(((t,e)=>t+oi(e).length),0));let r=0;return t.forEach((t=>{e.set(t,r),r+=t.length})),e},_i=(t,e=Yn)=>{(0n===t||e<=0n)&&ti("no inverse n="+t+" mod="+e);let r=ui(t,e),n=e,i=0n,o=1n,a=1n,s=0n;for(;0n!==r;){const t=n/r,e=n%r,u=i-a*t,c=o-s*t;n=r,r=e,i=a,o=s,a=u,s=c}return 1n===n?ui(i,e):ti("no inverse")},Ei=t=>{let e=1n;for(let r=t,n=(Yn+1n)/4n;n>0n;n>>=1n)1n&n&&(e=e*r%Yn),r=r*r%Yn;return ui(e*e)===t?e:ti("sqrt invalid")},Si=t=>(ei(t)||(t=gi(si(t,32))),ii(t)?t:ti("private key out of range")),ki=()=>"object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;let Ti;const Oi={hexToBytes:yi,bytesToHex:di,concatBytes:mi,bytesToNumberBE:gi,numberToBytesBE:vi,mod:ui,invert:_i,hmacSha256Async:async(t,...e)=>{const r=ki(),n=r&&r.subtle;if(!n)return ti("etc.hmacSha256Async not set");const i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return ai(await n.sign("HMAC",i,mi(...e)))},hmacSha256Sync:Ti,hashToPrivateKey:t=>{((t=si(t)).length<40||t.length>1024)&&ti("expected proper params");const e=ui(gi(t),Xn-1n)+1n;return vi(e)},randomBytes:(t=32)=>{const e=ki();return e&&e.getRandomValues||ti("crypto.getRandomValues must be defined"),e.getRandomValues(ai(t))}};let xi;Object.defineProperties(Oi,{hmacSha256Sync:{configurable:!1,get:()=>Ti,set(t){Ti||(Ti=t)}}});const Ai=t=>{const e=xi||(xi=(()=>{const t=[];let e=li,r=e;for(let n=0;n<33;n++){r=e,t.push(r);for(let n=1;n<128;n++)r=r.add(e),t.push(r);e=r.double()}return t})()),r=(t,e)=>{let r=e.negate();return t?r:e};let n=hi,i=li;const o=BigInt(255),a=BigInt(8);for(let s=0;s<33;s++){const u=128*s;let c=Number(t&o);t>>=a,c>128&&(c-=256,t+=1n);const f=u,l=u+Math.abs(c)-1,h=s%2!=0,p=c<0;0===c?i=i.add(r(h,e[f])):n=n.add(r(p,e[l]))}return{p:n,f:i}};var Pi=g(287).Buffer;function Ii(t){return function(e){try{return t({output:e}),!0}catch(t){return!1}}}var Li=Ii(Cr),Bi=Ii(Mr),Ri=Ii(Kr),Ni=Ii(Qr),ji=Ii(on),Ui=Ii(Vr),Ci=Ii(Xr);function Fi(t){var e,r=Pi.allocUnsafe(0);function n(t){var e=r.length,n=Bn.encodingLength(t);r=Pi.concat([r,Pi.allocUnsafe(n)]),Bn.encode(t,r,e)}return n((e=t).length),e.forEach((function(t){n(t.length),function(t){r=Pi.concat([r,Pi.from(t)])}(t)})),r}function Mi(t){if(![33,65].includes(t.length))throw new Error("Unsupported key length=".concat(t.length,". Must be 33 (compressed) or 65 (uncompressed)."));var e;try{e=fi.fromHex(t)}catch(t){throw new Error("Invalid secp256k1 public key bytes. Cannot parse.")}var r=Di(e.x),n=Di(e.y),i=e.y%2n===0n?6:7,o=Pi.alloc(65);return o[0]=i,r.copy(o,1),n.copy(o,33),{hybrid:o,uncompressed:Pi.concat([Pi.from([4]),r,n])}}function Di(t){var e=t.toString(16);return(e=e.padStart(64,"0")).length>64&&(e=e.slice(-64)),Pi.from(e,"hex")}function Hi(t,e){if(t.equals(e))return!0;if(65===t.length&&65===e.length){var r=Pi.from(t),n=Pi.from(e);return 6!==r[0]&&7!==r[0]||(r[0]=4),6!==n[0]&&7!==n[0]||(n[0]=4),r.equals(n)}return!1}function Ki(t,e){var r=qe(t),n=Zi(t),i=Mi(t),o=ne(e);if(null===o)throw new Error("Unknown script error");return o.findIndex((function(e){return"number"!=typeof e&&(!!Hi(e,t)||!!Hi(e,n)||!!Hi(e,i.uncompressed)||!!Hi(e,i.hybrid)||e.equals(r))}))}function Gi(t,e){return-1!==Ki(t,e)}function Wi(t,e){var r=function(t){var e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=qi(t)}else e=t.partialSig;return e.map((function(t){return t.signature}))}(t);return r.some((function(t){return Vi(t,le.decode,e)}))}function Vi(t,e,r){var n=e(t).hashType,i=[];switch(n&wn.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case wn.SIGHASH_ALL:break;case wn.SIGHASH_SINGLE:case wn.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}function qi(t){var e=t.finalScriptSig&&ne(t.finalScriptSig)||[],r=t.finalScriptWitness&&ne(t.finalScriptWitness)||[];return e.concat(r).filter((function(t){return Pi.isBuffer(t)&&ce(t)})).map((function(t){return{signature:t}}))}var zi=g(287).Buffer;function Yi(t,e){if(t){if("string"==typeof t)return Xi(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Xi(t,e):void 0}}function Xi(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Zi=function(t){var e=32===t.length?t:t.slice(1,33);return zi.isBuffer(e)?e:zi.from(e)};function $i(t,e,r){var n=function(t,e,r){if(!t.tapScriptSig||!t.tapScriptSig.length)throw new Error("Can not finalize taproot input #".concat(e,". No tapleaf script signature provided."));var n=(t.tapLeafScript||[]).sort((function(t,e){return t.controlBlock.length-e.controlBlock.length})).find((function(e){return function(t,e,r){var n=xr({output:t.script,version:t.leafVersion});return(!r||r.equals(n))&&void 0!==e.find((function(t){return t.leafHash.equals(n)}))}(e,t.tapScriptSig,r)}));if(!n)throw new Error("Can not finalize taproot input #".concat(e,". Signature for tapleaf script not found."));return n}(e,t,r);try{var i=function(t,e){var r=xr({output:e.script,version:e.leafVersion});return(t.tapScriptSig||[]).filter((function(t){return t.leafHash.equals(r)})).map((function(t){return function(t,e){return Object.assign({positionInScript:Ki(e.pubkey,t)},e)}(e.script,t)})).sort((function(t,e){return e.positionInScript-t.positionInScript})).map((function(t){return t.signature}))}(e,n);return{finalScriptWitness:Fi(i.concat(n.script).concat(n.controlBlock))}}catch(e){throw new Error("Can not finalize taproot input #".concat(t,": ").concat(e))}}function Ji(t,e){var r=e?zi.from([e]):zi.from([]);return zi.concat([t,r])}function Qi(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&Ci(t.witnessUtxo.script))}function to(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&Ci(e))}function eo(t,e,r){!function(t,e,r){var n=Qi(t)&&ho(e),i=ho(t)&&Qi(e),o=t===e&&Qi(e)&&ho(e);if(n||i||o)throw new Error("Invalid arguments for Psbt.".concat(r,". ")+"Cannot use both taproot and non-taproot fields.")}(t,e,r),function(t,e,r){if(e.tapMerkleRoot){var n=(e.tapLeafScript||[]).every((function(t){return lo(t,e.tapMerkleRoot)})),i=(t.tapLeafScript||[]).every((function(t){return lo(t,e.tapMerkleRoot)}));if(!n||!i)throw new Error("Invalid arguments for Psbt.".concat(r,". Tapleaf not part of taptree."))}else if(t.tapMerkleRoot&&!(e.tapLeafScript||[]).every((function(e){return lo(e,t.tapMerkleRoot)})))throw new Error("Invalid arguments for Psbt.".concat(r,". Tapleaf not part of taptree."))}(t,e,r)}function ro(t,e,r){!function(t,e,r){var n=to(t)&&ho(e),i=ho(t)&&to(e),o=t===e&&to(e)&&ho(e);if(n||i||o)throw new Error("Invalid arguments for Psbt.".concat(r,". ")+"Cannot use both taproot and non-taproot fields.")}(t,e,r),function(t,e){if(e.tapTree||e.tapInternalKey){var r=e.tapInternalKey||t.tapInternalKey,n=e.tapTree||t.tapTree;if(r){var i=t.script,o=function(t,e){return Xr({internalPubkey:t,scriptTree:e&&oo(e.leaves)}).output}(r,n);if(i&&!i.equals(o))throw new Error("Error adding output. Script or address missmatch.")}}}(t,e)}function no(t,e){var r=e.tapInternalKey,n=r&&Pr(r,e.tapMerkleRoot);if(!n)throw new Error("Cannot tweak tap internal key for input #".concat(t,". Public key: ").concat(r&&r.toString("hex")));return n.x}function io(t){if(!Tt(t))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return co(t)}function oo(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return 1===t.length&&0===t[0].depth?{output:t[0].script,version:t[0].leafVersion}:function(t){var e,r,n=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Yi(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(n.s();!(r=n.n()).done;)if(!(e=fo(r.value,e)))throw new Error("No room left to insert tapleaf in tree")}catch(t){n.e(t)}finally{n.f()}return e}(t)}function ao(t,e){var r=function(t){var e,r=[];if(t.tapKeySig&&r.push(t.tapKeySig),t.tapScriptSig&&r.push.apply(r,function(t){if(Array.isArray(t))return Xi(t)}(e=t.tapScriptSig.map((function(t){return t.signature})))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||Yi(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),!r.length){var n=uo(t.finalScriptWitness);n&&r.push(n)}return r}(t);return r.some((function(t){return Vi(t,so,e)}))}function so(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||wn.SIGHASH_DEFAULT}}function uo(t){if(t){var e=t.slice(2);return 64===e.length||65===e.length?e:void 0}}function co(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(r>Er)throw new Error("Max taptree depth exceeded.");return t?kt(t)?(e.push({depth:r,leafVersion:t.version||_r,script:t.output}),e):(t[0]&&co(t[0],e,r+1),t[1]&&co(t[1],e,r+1),e):[]}function fo(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(r>Er)throw new Error("Max taptree depth exceeded.");if(t.depth===r)return e?void 0:{output:t.script,version:t.leafVersion};if(!kt(e)){var n=fo(t,e&&e[0],r+1);if(n)return[n,e&&e[1]];var i=fo(t,e&&e[1],r+1);return i?[e&&e[0],i]:void 0}}function lo(t,e){if(!e)return!0;var r=xr({output:t.script,version:t.leafVersion});return kr(t.controlBlock,r).equals(e)}function ho(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}var po=g(287).Buffer;function yo(t){return yo="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},yo(t)}function go(){go=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==yo(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(yo(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function bo(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function vo(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){bo(o,n,i,a,s,"next",t)}function s(t){bo(o,n,i,a,s,"throw",t)}a(void 0)}))}}function wo(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=_o(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function mo(t){return function(t){if(Array.isArray(t))return Eo(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_o(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _o(t,e){if(t){if("string"==typeof t)return Eo(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Eo(t,e):void 0}}function Eo(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function So(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ko(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Oo(n.key),n)}}function To(t,e,r){return e&&ko(t.prototype,e),r&&ko(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Oo(t){var e=function(t){if("object"!=yo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=yo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yo(e)?e:e+""}var xo={network:O,maximumFeeRate:5e3},Ao=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Ln.i(new Io);So(this,t),this.data=r,this.opts=Object.assign({},xo,e),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);var n=function(t,e,r,n){Object.defineProperty(t,e,{enumerable:r,writable:n})};n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}return To(t,[{key:"inputCount",get:function(){return this.data.inputs.length}},{key:"version",get:function(){return this.__CACHE.__TX.version},set:function(t){this.setVersion(t)}},{key:"locktime",get:function(){return this.__CACHE.__TX.locktime},set:function(t){this.setLocktime(t)}},{key:"txInputs",get:function(){return this.__CACHE.__TX.ins.map((function(t){return{hash:gr(t.hash),index:t.index,sequence:t.sequence}}))}},{key:"txOutputs",get:function(){var t=this;return this.__CACHE.__TX.outs.map((function(e){var r;try{r=Se(e.script,t.opts.network)}catch(t){}return{script:gr(e.script),value:e.value,address:r}}))}},{key:"combine",value:function(){for(var t,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return(t=this.data).combine.apply(t,mo(r.map((function(t){return t.data})))),this}},{key:"clone",value:function(){return t.fromBuffer(this.data.toBuffer(),JSON.parse(JSON.stringify(this.opts)))}},{key:"setMaximumFeeRate",value:function(t){jo(t),this.opts.maximumFeeRate=t}},{key:"setVersion",value:function(t){jo(t),Uo(this.data.inputs,"setVersion");var e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}},{key:"setLocktime",value:function(t){jo(t),Uo(this.data.inputs,"setLocktime");var e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}},{key:"setInputSequence",value:function(t,e){jo(e),Uo(this.data.inputs,"setInputSequence");var r=this.__CACHE;if(r.__TX.ins.length<=t)throw new Error("Input index too high");return r.__TX.ins[t].sequence=e,r.__EXTRACTED_TX=void 0,this}},{key:"addInputs",value:function(t){var e=this,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.forEach((function(t){return e.addInput(t,r)})),this}},{key:"addInput",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!t||void 0===t.hash||void 0===t.index)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");eo(t,t,"addInput"),e&&Uo(this.data.inputs,"addInput"),t.witnessScript&&aa(t.witnessScript);var r=this.__CACHE;this.data.addInput(t),Fo(r,r.__TX.ins[r.__TX.ins.length-1]);var n=this.data.inputs.length-1,i=this.data.inputs[n];return i.nonWitnessUtxo&&Qo(this.__CACHE,i,n),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}},{key:"addOutputs",value:function(t){var e=this;return t.forEach((function(t){return e.addOutput(t)})),this}},{key:"addOutput",value:function(t){if(arguments.length>1||!t||void 0===t.value||void 0===t.address&&void 0===t.script)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");Uo(this.data.inputs,"addOutput");var e=t.address;if("string"==typeof e){var r=ke(e,this.opts.network);t=Object.assign({},t,{script:r})}ro(t,t,"addOutput");var n=this.__CACHE;return this.data.addOutput(t),n.__FEE=void 0,n.__FEE_RATE=void 0,n.__EXTRACTED_TX=void 0,this}},{key:"extractTransaction",value:function(t,e){if(e&&(this.data.inputs=this.data.inputs.filter((function(t){return!t.partialSig}))),!this.data.inputs.every(Ro))throw new Error("Not finalized");var r=this.__CACHE;if(t||function(t,e,r){var n=e.__FEE_RATE||t.getFeeRate(),i=e.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error("Warning: You are paying around ".concat((o/1e8).toFixed(8)," in ")+"fees, which is ".concat(n," satoshi per byte for a transaction ")+"with a VSize of ".concat(i," bytes (segwit counted as 0.25 byte per ")+"byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.")}(this,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;var n=r.__TX.clone();return ta(this.data.inputs,n,r,!0,e),n}},{key:"getFeeRate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Ko("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE,t)}},{key:"getFee",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Ko("__FEE","fee",this.data.inputs,this.__CACHE,t)}},{key:"finalizeAllInputs",value:function(){var t=this;return(0,Rn.checkForInput)(this.data.inputs,0),ua(this.data.inputs.length).forEach((function(e){return t.finalizeInput(e)})),this}},{key:"finalizeInput",value:function(t,e){var r=(0,Rn.checkForInput)(this.data.inputs,t);return Qi(r)?this._finalizeTaprootInput(t,r,void 0,e):this._finalizeInput(t,r,e)}},{key:"finalizeTaprootInput",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$i,n=(0,Rn.checkForInput)(this.data.inputs,t);if(Qi(n))return this._finalizeTaprootInput(t,n,e,r);throw new Error("Cannot finalize input #".concat(t,". Not Taproot."))}},{key:"getInputType",value:function(t){var e=(0,Rn.checkForInput)(this.data.inputs,t),r=oa(ra(t,e,this.__CACHE),t,"input",e.redeemScript||function(t){if(t){var e=ne(t);if(e){var r=e[e.length-1];if(po.isBuffer(r)&&!ia(r)&&!ce(r)&&ne(r))return r}}}(e.finalScriptSig),e.witnessScript||function(t){if(t){var e=Jo(t),r=e[e.length-1];if(!ia(r)&&ne(r))return r}}(e.finalScriptWitness));return("raw"===r.type?"":r.type+"-")+sa(r.meaningfulScript)}},{key:"inputHasPubkey",value:function(t,e){return function(t,e,r,n){return Gi(t,oa(ra(r,e,n),r,"input",e.redeemScript,e.witnessScript).meaningfulScript)}(e,(0,Rn.checkForInput)(this.data.inputs,t),t,this.__CACHE)}},{key:"inputHasHDKey",value:function(t,e){var r=(0,Rn.checkForInput)(this.data.inputs,t),n=No(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}},{key:"outputHasPubkey",value:function(t,e){return function(t,e,r,n){return Gi(t,oa(n.__TX.outs[r].script,r,"output",e.redeemScript,e.witnessScript).meaningfulScript)}(e,(0,Rn.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}},{key:"outputHasHDKey",value:function(t,e){var r=(0,Rn.checkForOutput)(this.data.outputs,t),n=No(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}},{key:"validateSignaturesOfAllInputs",value:function(t){var e=this;return(0,Rn.checkForInput)(this.data.inputs,0),ua(this.data.inputs.length).map((function(r){return e.validateSignaturesOfInput(r,t)})).reduce((function(t,e){return!0===e&&t}),!0)}},{key:"validateSignaturesOfInput",value:function(t,e,r){return Qi(this.data.inputs[t])?this.validateSignaturesOfTaprootInput(t,e,r):this._validateSignaturesOfInput(t,e,r)}},{key:"signAllInputsHD",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[wn.SIGHASH_ALL];if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");var r,n=[],i=wo(ua(this.data.inputs.length));try{for(i.s();!(r=i.n()).done;){var o=r.value;try{this.signInputHD(o,t,e),n.push(!0)}catch(t){n.push(!1)}}}catch(t){i.e(t)}finally{i.f()}if(n.every((function(t){return!1===t})))throw new Error("No inputs were signed");return this}},{key:"signAllInputsHDAsync",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[wn.SIGHASH_ALL];return new Promise((function(n,i){if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));var o,a=[],s=[],u=wo(ua(e.data.inputs.length));try{for(u.s();!(o=u.n()).done;){var c=o.value;s.push(e.signInputHDAsync(c,t,r).then((function(){a.push(!0)}),(function(){a.push(!1)})))}}catch(t){u.e(t)}finally{u.f()}return Promise.all(s).then((function(){if(a.every((function(t){return!1===t})))return i(new Error("No inputs were signed"));n()}))}))}},{key:"signInputHD",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[wn.SIGHASH_ALL];if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");return $o(t,this.data.inputs,e).forEach((function(e){return r.signInput(t,e,n)})),this}},{key:"signInputHDAsync",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[wn.SIGHASH_ALL];return new Promise((function(i,o){if(!e||!e.publicKey||!e.fingerprint)return o(new Error("Need HDSigner to sign input"));var a=$o(t,r.data.inputs,e).map((function(e){return r.signInputAsync(t,e,n)}));return Promise.all(a).then((function(){i()})).catch(o)}))}},{key:"signAllInputs",value:function(t,e){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");var r,n=[],i=wo(ua(this.data.inputs.length));try{for(i.s();!(r=i.n()).done;){var o=r.value;try{this.signInput(o,t,e),n.push(!0)}catch(t){n.push(!1)}}}catch(t){i.e(t)}finally{i.f()}if(n.every((function(t){return!1===t})))throw new Error("No inputs were signed");return this}},{key:"signAllInputsAsync",value:function(t,e){var r=this;return new Promise((function(n,i){if(!t||!t.publicKey)return i(new Error("Need Signer to sign input"));var o,a,s=[],u=[],c=wo(r.data.inputs.entries());try{for(c.s();!(o=c.n()).done;){var f=(a=o.value,function(t){if(Array.isArray(t))return t}(a)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,n,i,o,a=[],s=!0,u=!1;try{for(i=(e=e.call(t)).next;!(s=(r=i.call(e)).done)&&(a.push(r.value),1!==a.length);s=!0);}catch(t){u=!0,n=t}finally{try{if(!s&&null!=e.return&&(o=e.return(),Object(o)!==o))return}finally{if(u)throw n}}return a}}(a)||_o(a,1)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];u.push(r.signInputAsync(f,t,e).then((function(){s.push(!0)}),(function(){s.push(!1)})))}}catch(t){c.e(t)}finally{c.f()}return Promise.all(u).then((function(){if(s.every((function(t){return!1===t})))return i(new Error("No inputs were signed"));n()}))}))}},{key:"signInput",value:function(t,e,r){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var n=(0,Rn.checkForInput)(this.data.inputs,t);return Qi(n)?this._signTaprootInput(t,n,e,void 0,r):this._signInput(t,e,r)}},{key:"signTaprootInput",value:function(t,e,r,n){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var i=(0,Rn.checkForInput)(this.data.inputs,t);if(Qi(i))return this._signTaprootInput(t,i,e,r,n);throw new Error("Input #".concat(t," is not of type Taproot."))}},{key:"signInputAsync",value:function(t,e,r){var n=this;return Promise.resolve().then((function(){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var i=(0,Rn.checkForInput)(n.data.inputs,t);return Qi(i)?n._signTaprootInputAsync(t,i,e,void 0,r):n._signInputAsync(t,e,r)}))}},{key:"signTaprootInputAsync",value:function(t,e,r,n){var i=this;return Promise.resolve().then((function(){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var o=(0,Rn.checkForInput)(i.data.inputs,t);if(Qi(o))return i._signTaprootInputAsync(t,o,e,r,n);throw new Error("Input #".concat(t," is not of type Taproot."))}))}},{key:"toBuffer",value:function(){return Lo(this.__CACHE),this.data.toBuffer()}},{key:"toHex",value:function(){return Lo(this.__CACHE),this.data.toHex()}},{key:"toBase64",value:function(){return Lo(this.__CACHE),this.data.toBase64()}},{key:"updateGlobal",value:function(t){return this.data.updateGlobal(t),this}},{key:"updateInput",value:function(t,e){return e.witnessScript&&aa(e.witnessScript),eo(this.data.inputs[t],e,"updateInput"),this.data.updateInput(t,e),e.nonWitnessUtxo&&Qo(this.__CACHE,this.data.inputs[t],t),this}},{key:"updateOutput",value:function(t,e){return ro(this.data.outputs[t],e,"updateOutput"),this.data.updateOutput(t,e),this}},{key:"addUnknownKeyValToGlobal",value:function(t){return this.data.addUnknownKeyValToGlobal(t),this}},{key:"addUnknownKeyValToInput",value:function(t,e){return this.data.addUnknownKeyValToInput(t,e),this}},{key:"addUnknownKeyValToOutput",value:function(t,e){return this.data.addUnknownKeyValToOutput(t,e),this}},{key:"clearFinalizedInput",value:function(t){return this.data.clearFinalizedInput(t),this}},{key:"checkTaprootHashesForSig",value:function(t,e,r,n,i){if("function"!=typeof r.signSchnorr)throw new Error("Need Schnorr Signer to sign taproot input #".concat(t,"."));var o=Xo(t,e,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error("Can not sign for input #".concat(t," with the key ").concat(r.publicKey.toString("hex")));return o}},{key:"_finalizeInput",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Go,n=function(t,e,r){var n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!e.redeemScript,i.isP2WSH=!!e.witnessScript,e.witnessScript)i.script=e.witnessScript;else if(e.redeemScript)i.script=e.redeemScript;else if(e.nonWitnessUtxo){var o=ea(r,e,t),a=n.ins[t].index;i.script=o.outs[a].script}else e.witnessUtxo&&(i.script=e.witnessUtxo.script);return(e.witnessScript||Ni(i.script))&&(i.isSegwit=!0),i}(t,e,this.__CACHE),i=n.script,o=n.isP2SH,a=n.isP2WSH,s=n.isSegwit;if(!i)throw new Error("No script found for input #".concat(t));!function(t){if(t.sighashType&&t.partialSig){var e=t.partialSig,r=t.sighashType;e.forEach((function(t){var e=le.decode(t.signature).hashType;if(r!==e)throw new Error("Signature sighash does not match input sighash type")}))}}(e);var u=r(t,e,i,s,o,a),c=u.finalScriptSig,f=u.finalScriptWitness;if(c&&this.data.updateInput(t,{finalScriptSig:c}),f&&this.data.updateInput(t,{finalScriptWitness:f}),!c&&!f)throw new Error("Unknown error finalizing input #".concat(t));return this.data.clearFinalizedInput(t),this}},{key:"_finalizeTaprootInput",value:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:$i;if(!e.witnessUtxo)throw new Error("Cannot finalize input #".concat(t,". Missing witness utxo."));if(e.tapKeySig){var i=Fi(Xr({output:e.witnessUtxo.script,signature:e.tapKeySig}).witness);this.data.updateInput(t,{finalScriptWitness:i})}else{var o=n(t,e,r).finalScriptWitness;this.data.updateInput(t,{finalScriptWitness:o})}return this.data.clearFinalizedInput(t),this}},{key:"_validateSignaturesOfInput",value:function(t,e,r){var n=this.data.inputs[t],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");var o=r?i.filter((function(t){return t.pubkey.equals(r)})):i;if(o.length<1)throw new Error("No signatures for this pubkey");var a,s,u,c,f=[],l=wo(o);try{for(l.s();!(c=l.n()).done;){var h=c.value,p=le.decode(h.signature),d=u!==p.hashType?qo(t,Object.assign({},n,{sighashType:p.hashType}),this.__CACHE,!0):{hash:a,script:s},y=d.hash,g=d.script;u=p.hashType,a=y,s=g,Co(h.pubkey,g,"verify"),f.push(e(h.pubkey,y,p.signature))}}catch(t){l.e(t)}finally{l.f()}return f.every((function(t){return!0===t}))}},{key:"validateSignaturesOfTaprootInput",value:function(t,e,r){var n=this.data.inputs[t],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");var a=(r=r&&Zi(r))?Xo(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){var i=[];if(e.tapInternalKey){var o=zo(t,e,n);o&&i.push(o)}if(e.tapScriptSig){var a=e.tapScriptSig.map((function(t){return t.pubkey}));i.push.apply(i,mo(a))}return i.map((function(i){return Xo(t,e,r,i,n)})).flat()}(t,n,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");var s=a.find((function(t){return!t.leafHash})),u=0;if(i&&s){if(!e(s.pubkey,s.hash,Yo(i)))return!1;u++}if(o){var c,f=wo(o);try{var l,h=function(){var t=c.value,r=a.find((function(e){return t.pubkey.equals(e.pubkey)}));if(r){if(!e(t.pubkey,r.hash,Yo(t.signature)))return{v:!1};u++}};for(f.s();!(c=f.n()).done;)if(l=h())return l.v}catch(t){f.e(t)}finally{f.f()}}return u>0}},{key:"_signInput",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[wn.SIGHASH_ALL];qn(e);var n=Vo(this.data.inputs,t,e.publicKey,this.__CACHE,r),i=n.hash,o=n.sighashType,a=[{pubkey:e.publicKey,signature:le.encode(e.sign(i),o)}];return this.data.updateInput(t,{partialSig:a}),this}},{key:"_signTaprootInput",value:function(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[wn.SIGHASH_DEFAULT];qn(r);var o=this.checkTaprootHashesForSig(t,e,r,n,i),a=o.filter((function(t){return!t.leafHash})).map((function(t){return Ji(r.signSchnorr(t.hash),e.sighashType)}))[0],s=o.filter((function(t){return!!t.leafHash})).map((function(t){return{pubkey:Zi(r.publicKey),signature:Ji(r.signSchnorr(t.hash),e.sighashType),leafHash:t.leafHash}}));return a&&this.data.updateInput(t,{tapKeySig:a}),s.length&&this.data.updateInput(t,{tapScriptSig:s}),this}},{key:"_signInputAsync",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[wn.SIGHASH_ALL];qn(e);var i=Vo(this.data.inputs,t,e.publicKey,this.__CACHE,n),o=i.hash,a=i.sighashType;return Promise.resolve(e.sign(o)).then((function(n){var i=[{pubkey:e.publicKey,signature:le.encode(n,a)}];r.data.updateInput(t,{partialSig:i})}))}},{key:"_signTaprootInputAsync",value:(e=vo(go().mark((function t(e,r,n,i){var o,a,s,u,c,f,l,h,p,d,y,g=arguments;return go().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=g.length>4&&void 0!==g[4]?g[4]:[wn.SIGHASH_DEFAULT],qn(n),a=this.checkTaprootHashesForSig(e,r,n,i,o),s=[],u=a.filter((function(t){return!t.leafHash}))[0],u&&(c=Promise.resolve(n.signSchnorr(u.hash)).then((function(t){return{tapKeySig:Ji(t,r.sighashType)}})),s.push(c)),f=a.filter((function(t){return!!t.leafHash})),f.length&&(l=f.map(function(){var t=vo(go().mark((function t(e){var i,o;return go().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.signSchnorr(e.hash);case 2:return i=t.sent,o=[{pubkey:Zi(n.publicKey),signature:Ji(i,r.sighashType),leafHash:e.leafHash}],t.abrupt("return",{tapScriptSig:o});case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),s.push.apply(s,mo(l))),t.next=10,Promise.all(s);case 10:h=t.sent,p=wo(h);try{for(p.s();!(d=p.n()).done;)y=d.value,this.data.updateInput(e,y)}catch(t){p.e(t)}finally{p.f()}case 13:case"end":return t.stop()}}),t,this)}))),function(t,r,n,i){return e.apply(this,arguments)})}],[{key:"fromBase64",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=po.from(t,"base64");return this.fromBuffer(r,e)}},{key:"fromHex",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=po.from(t,"hex");return this.fromBuffer(r,e)}},{key:"fromBuffer",value:function(e){var r,n,i=new t(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},Ln.i.fromBuffer(e,Po));return r=i.__CACHE.__TX,n=i.__CACHE,r.ins.forEach((function(t){Fo(n,t)})),i}}]);var e}(),Po=function(t){return new Io(t)},Io=To((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:po.from([2,0,0,0,0,0,0,0,0,0]);So(this,t),this.tx=wn.fromBuffer(e),function(t){if(!t.ins.every((function(t){return t.script&&0===t.script.length&&t.witness&&0===t.witness.length})))throw new Error("Format Error: Transaction ScriptSigs are not empty")}(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}),[{key:"getInputOutputCounts",value:function(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}},{key:"addInput",value:function(t){if(void 0===t.hash||void 0===t.index||!po.isBuffer(t.hash)&&"string"!=typeof t.hash||"number"!=typeof t.index)throw new Error("Error adding input.");var e="string"==typeof t.hash?yr(po.from(t.hash,"hex")):t.hash;this.tx.addInput(e,t.index,t.sequence)}},{key:"addOutput",value:function(t){if(void 0===t.script||void 0===t.value||!po.isBuffer(t.script)||"number"!=typeof t.value)throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}},{key:"toBuffer",value:function(){return this.tx.toBuffer()}}]);function Lo(t){if(!1!==t.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function Bo(t,e,r){if(!e)return!1;var n;if((n=r?r.map((function(t){var r=function(t){if(65===t.length){var e=1&t[64],r=t.slice(0,33);return r[0]=2|e,r}return t.slice()}(t);return e.find((function(t){return t.pubkey.equals(r)}))})).filter((function(t){return!!t})):e).length>t)throw new Error("Too many signatures");return n.length===t}function Ro(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function No(t){return function(e){return!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}}function jo(t){if("number"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error("Invalid 32 bit integer")}function Uo(t,e){t.forEach((function(t){if(Qi(t)?ao(t,e):Wi(t,e))throw new Error("Can not modify transaction, signatures exist.")}))}function Co(t,e,r){if(!Gi(t,e))throw new Error("Can not ".concat(r," for this input with the key ").concat(t.toString("hex")))}function Fo(t,e){var r=yr(po.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 Mo(t,e){return function(r,n,i,o){var a=t({redeem:{output:i}}).output;if(!n.equals(a))throw new Error("".concat(e," for ").concat(o," #").concat(r," doesn't match the scriptPubKey in the prevout"))}}var Do=Mo(Vr,"Redeem script"),Ho=Mo(on,"Witness script");function Ko(t,e,r,n){var i,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(!r.every(Ro))throw new Error("PSBT must be finalized to calculate ".concat(e));if("__FEE_RATE"===t&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===t&&n.__FEE)return n.__FEE;var a=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,a=!1):i=n.__TX.clone(),ta(r,i,n,a,o),"__FEE_RATE"===t?n.__FEE_RATE:"__FEE"===t?n.__FEE:void 0}function Go(t,e,r,n,i,o){var a=sa(r);if(!function(t,e,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return Bo(1,t.partialSig);case"multisig":var n=Cr({output:e});return Bo(n.m,t.partialSig,n.pubkeys);default:return!1}}(e,r,a))throw new Error("Can not finalize input #".concat(t));return Wo(r,a,e.partialSig,n,i,o)}function Wo(t,e,r,n,i,o){var a,s,u=function(t,e,r){var n;switch(e){case"multisig":var i=function(t,e){return Cr({output:t}).pubkeys.map((function(t){return(e.filter((function(e){return e.pubkey.equals(t)}))[0]||{}).signature})).filter((function(t){return!!t}))}(t,r);n=Cr({output:t,signatures:i});break;case"pubkey":n=Mr({output:t,signature:r[0].signature});break;case"pubkeyhash":n=Kr({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=Qr({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),c=o?on({redeem:u}):null,f=i?Vr({redeem:c||u}):null;return n?(s=Fi(c?c.witness:u.witness),f&&(a=f.input)):a=f?f.input:u.input,{finalScriptSig:a,finalScriptWitness:s}}function Vo(t,e,r,n,i){var o=qo(e,(0,Rn.checkForInput)(t,e),n,!1,i),a=o.hash,s=o.sighashType;return Co(r,o.script,"sign"),{hash:a,sighashType:s}}function qo(t,e,r,n,i){var o,a,s=r.__TX,u=e.sighashType||wn.SIGHASH_ALL;if(Zo(u,i),e.nonWitnessUtxo){var c=ea(r,e,t),f=s.ins[t].hash,l=c.getHash();if(!f.equals(l))throw new Error("Non-witness UTXO hash for input #".concat(t," doesn't match the hash specified in the prevout"));var h=s.ins[t].index;a=c.outs[h]}else{if(!e.witnessUtxo)throw new Error("Need a Utxo input item for signing");a=e.witnessUtxo}var p=oa(a.script,t,"input",e.redeemScript,e.witnessScript),d=p.meaningfulScript,y=p.type;if(["p2sh-p2wsh","p2wsh"].indexOf(y)>=0)o=s.hashForWitnessV0(t,d,a.value,u);else if(Ni(d)){var g=Kr({hash:d.slice(2)}).output;o=s.hashForWitnessV0(t,g,a.value,u)}else{if(void 0===e.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Input #".concat(t," has witnessUtxo but non-segwit script: ")+"".concat(d.toString("hex")));n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn("Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecessor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n*********************"),o=s.hashForSignature(t,d,u)}return{script:d,sighashType:u,hash:o}}function zo(t,e,r){var n=na(t,e,r).script;return Ci(n)?n.subarray(2,34):null}function Yo(t){return 64===t.length?t:t.subarray(0,64)}function Xo(t,e,r,n,i,o,a){var s=i.__TX,u=e.sighashType||wn.SIGHASH_DEFAULT;Zo(u,a);var c=r.map((function(t,e){return na(e,t,i)})),f=c.map((function(t){return t.script})),l=c.map((function(t){return t.value})),h=[];if(e.tapInternalKey&&!o){var p=zo(t,e,i)||po.from([]);if(Zi(n).equals(p)){var d=s.hashForWitnessV1(t,f,l,u);h.push({pubkey:n,hash:d})}}var y=(e.tapLeafScript||[]).filter((function(t){return Gi(n,t.script)})).map((function(t){var e=xr({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)})).filter((function(t){return!o||o.equals(t.hash)})).map((function(e){var r=s.hashForWitnessV1(t,f,l,u,e.hash);return{pubkey:n,hash:r,leafHash:e.hash}}));return h.concat(y)}function Zo(t,e){if(e&&e.indexOf(t)<0){var r=function(t){var e=t&wn.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&t){case wn.SIGHASH_ALL:e+="SIGHASH_ALL";break;case wn.SIGHASH_SINGLE:e+="SIGHASH_SINGLE";break;case wn.SIGHASH_NONE:e+="SIGHASH_NONE"}return e}(t);throw new Error("Sighash type is not allowed. Retry the sign method passing the "+"sighashTypes array of whitelisted types. Sighash type: ".concat(r))}}function $o(t,e,r){var n=(0,Rn.checkForInput)(e,t);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");var i=n.bip32Derivation.map((function(t){return t.masterFingerprint.equals(r.fingerprint)?t:void 0})).filter((function(t){return!!t}));if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map((function(t){var e=r.derivePath(t.path);if(!t.pubkey.equals(e.publicKey))throw new Error("pubkey did not match bip32Derivation");return e}))}function Jo(t){var e=0;function r(){var r=Bn.decode(t,e);return e+=Bn.decode.bytes,r}return function(){for(var n=r(),i=[],o=0;o<n;o++)i.push((a=r(),e+=a,t.slice(e-a,e)));var a;return i}()}function Qo(t,e,r){t.__NON_WITNESS_UTXO_BUF_CACHE[r]=e.nonWitnessUtxo,t.__NON_WITNESS_UTXO_TX_CACHE[r]=wn.fromBuffer(e.nonWitnessUtxo);var n=t,i=r;delete e.nonWitnessUtxo,Object.defineProperty(e,"nonWitnessUtxo",{enumerable:!0,get:function(){var t=n.__NON_WITNESS_UTXO_BUF_CACHE[i],e=n.__NON_WITNESS_UTXO_TX_CACHE[i];if(void 0!==t)return t;var r=e.toBuffer();return n.__NON_WITNESS_UTXO_BUF_CACHE[i]=r,r},set:function(t){n.__NON_WITNESS_UTXO_BUF_CACHE[i]=t}})}function ta(t,e,r,n,i){var o=0;t.forEach((function(t,i){if(n&&t.finalScriptSig&&(e.ins[i].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[i].witness=Jo(t.finalScriptWitness)),t.witnessUtxo)o+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){var a=ea(r,t,i),s=e.ins[i].index,u=a.outs[s];o+=u.value}}));var a=e.outs.reduce((function(t,e){return t+e.value}),0),s=o-a;if(!i&&s<0)throw new Error("Outputs are spending more than Inputs");var u=e.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(s/u)}function ea(t,e,r){var n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||Qo(t,e,r),n[r]}function ra(t,e,r){return na(t,e,r).script}function na(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){var n=ea(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 ia(t){return 33===t.length&&se(t)}function oa(t,e,r,n,i){var o,a=Ui(t),s=a&&n&&ji(n),u=ji(t);if(a&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((u||s)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");return s?(o=i,Do(e,t,n,r),Ho(e,n,i,r),aa(o)):u?(o=i,Ho(e,t,i,r),aa(o)):a?(o=n,Do(e,t,n,r)):o=t,{meaningfulScript:o,type:s?"p2sh-p2wsh":a?"p2sh":u?"p2wsh":"raw"}}function aa(t){if(Ni(t)||Ui(t))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function sa(t){return Ni(t)?"witnesspubkeyhash":Ri(t)?"pubkeyhash":Li(t)?"multisig":Bi(t)?"pubkey":"nonstandard"}function ua(t){return mo(Array(t).keys())}const ca={networks:v,address:E,payments:k,script:_,crypto:S,Transaction:T};var fa=b.iL,la=b.ZX,ha=b.hl,pa=b.Et,da=b.m$,ya=b.Dk,ga=b.f0,ba=b.Bh,va=b.Q2,wa=b.C5,ma=b.n0,_a=b.NI,Ea=b.fQ,Sa=b.mG,ka=b.o8,Ta=b.Ez,Oa=b.KT,xa=b.k1,Aa=b.HE,Pa=b.K$,Ia=b.VQ,La=b.qR,Ba=b.gU,Ra=b.Uu,Na=i(3513),ja=i.t(Na,2);function Ua(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Ca(t,...e){if(!function(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Fa(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 Ma=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Da=(t,e)=>t<<32-e|t>>>e,Ha=(t,e)=>t<<e|t>>>32-e>>>0;function Ka(t){return"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)),Ca(t),t}class Ga{clone(){return this._cloneInto()}}function Wa(t){const e=e=>t().update(Ka(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}class Va extends Ga{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");Ua(t.outputLen),Ua(t.blockLen)}(t);const r=Ka(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 Fa(this),this.iHash.update(t),this}digestInto(t){Fa(this),Ca(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const qa=(t,e,r)=>new Va(t,e).update(r).digest();qa.create=(t,e)=>new Va(t,e);const za=(t,e,r)=>t&e^~t&r,Ya=(t,e,r)=>t&e^t&r^e&r;class Xa extends Ga{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=Ma(this.buffer)}update(t){Fa(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=Ka(t)).length;for(let o=0;o<i;){const a=Math.min(n-this.pos,i-o);if(a!==n)r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=Ma(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){Fa(this),function(t,e){Ca(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+c,s,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=Ma(t),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=s/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)a.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const Za=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),$a=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e))),Ja=$a.map((t=>(9*t+5)%16));let Qa=[$a],ts=[Ja];for(let t=0;t<4;t++)for(let e of[Qa,ts])e.push(e[t].map((t=>Za[t])));const es=[[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))),rs=Qa.map(((t,e)=>t.map((t=>es[e][t])))),ns=ts.map(((t,e)=>t.map((t=>es[e][t])))),is=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),os=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function as(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 ss=new Uint32Array(16);class us extends Xa{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)ss[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,i=0|this.h1,o=i,a=0|this.h2,s=a,u=0|this.h3,c=u,f=0|this.h4,l=f;for(let t=0;t<5;t++){const e=4-t,h=is[t],p=os[t],d=Qa[t],y=ts[t],g=rs[t],b=ns[t];for(let e=0;e<16;e++){const n=Ha(r+as(t,i,a,u)+ss[d[e]]+h,g[e])+f|0;r=f,f=u,u=0|Ha(a,10),a=i,i=n}for(let t=0;t<16;t++){const r=Ha(n+as(e,o,s,c)+ss[y[t]]+p,b[t])+l|0;n=l,l=c,c=0|Ha(s,10),s=o,o=r}}this.set(this.h1+a+c|0,this.h2+u+l|0,this.h3+f+n|0,this.h4+r+o|0,this.h0+i+s|0)}roundClean(){ss.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const cs=Wa((()=>new us)),fs=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]),ls=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),hs=new Uint32Array(64);class ps extends Xa{constructor(){super(64,32,8,!1),this.A=0|ls[0],this.B=0|ls[1],this.C=0|ls[2],this.D=0|ls[3],this.E=0|ls[4],this.F=0|ls[5],this.G=0|ls[6],this.H=0|ls[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)hs[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=hs[t-15],r=hs[t-2],n=Da(e,7)^Da(e,18)^e>>>3,i=Da(r,17)^Da(r,19)^r>>>10;hs[t]=i+hs[t-7]+n+hs[t-16]|0}let{A:r,B:n,C:i,D:o,E:a,F:s,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(Da(a,6)^Da(a,11)^Da(a,25))+za(a,s,u)+fs[t]+hs[t]|0,f=(Da(r,2)^Da(r,13)^Da(r,22))+Ya(r,n,i)|0;c=u,u=s,s=a,a=o+e|0,o=i,i=n,n=r,r=e+f|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,s=s+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,a,s,u,c)}roundClean(){hs.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ds=Wa((()=>new ps)),ys=BigInt(2**32-1),gs=BigInt(32);function bs(t,e=!1){return e?{h:Number(t&ys),l:Number(t>>gs&ys)}:{h:0|Number(t>>gs&ys),l:0|Number(t&ys)}}const vs={fromBig:bs,split:function(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:a}=bs(t[i],e);[r[i],n[i]]=[o,a]}return[r,n]},toBig:(t,e)=>BigInt(t>>>0)<<gs|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:(t,e,r)=>t<<r|e>>>32-r,rotlSL:(t,e,r)=>e<<r|t>>>32-r,rotlBH:(t,e,r)=>e<<r-32|t>>>64-r,rotlBL:(t,e,r)=>t<<r-32|e>>>64-r,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,o)=>e+r+n+i+o+(t/2**32|0)|0,add5L:(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},ws=vs,[ms,_s]=(()=>ws.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)))))(),Es=new Uint32Array(80),Ss=new Uint32Array(80);class ks extends Xa{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:o,Dh:a,Dl:s,Eh:u,El:c,Fh:f,Fl:l,Gh:h,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,a,s,u,c,f,l,h,p,d,y]}set(t,e,r,n,i,o,a,s,u,c,f,l,h,p,d,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|a,this.Dl=0|s,this.Eh=0|u,this.El=0|c,this.Fh=0|f,this.Fl=0|l,this.Gh=0|h,this.Gl=0|p,this.Hh=0|d,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)Es[r]=t.getUint32(e),Ss[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|Es[t-15],r=0|Ss[t-15],n=ws.rotrSH(e,r,1)^ws.rotrSH(e,r,8)^ws.shrSH(e,r,7),i=ws.rotrSL(e,r,1)^ws.rotrSL(e,r,8)^ws.shrSL(e,r,7),o=0|Es[t-2],a=0|Ss[t-2],s=ws.rotrSH(o,a,19)^ws.rotrBH(o,a,61)^ws.shrSH(o,a,6),u=ws.rotrSL(o,a,19)^ws.rotrBL(o,a,61)^ws.shrSL(o,a,6),c=ws.add4L(i,u,Ss[t-7],Ss[t-16]),f=ws.add4H(c,n,s,Es[t-7],Es[t-16]);Es[t]=0|f,Ss[t]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:a,Cl:s,Dh:u,Dl:c,Eh:f,El:l,Fh:h,Fl:p,Gh:d,Gl:y,Hh:g,Hl:b}=this;for(let t=0;t<80;t++){const e=ws.rotrSH(f,l,14)^ws.rotrSH(f,l,18)^ws.rotrBH(f,l,41),v=ws.rotrSL(f,l,14)^ws.rotrSL(f,l,18)^ws.rotrBL(f,l,41),w=f&h^~f&d,m=l&p^~l&y,_=ws.add5L(b,v,m,_s[t],Ss[t]),E=ws.add5H(_,g,e,w,ms[t],Es[t]),S=0|_,k=ws.rotrSH(r,n,28)^ws.rotrBH(r,n,34)^ws.rotrBH(r,n,39),T=ws.rotrSL(r,n,28)^ws.rotrBL(r,n,34)^ws.rotrBL(r,n,39),O=r&i^r&a^i&a,x=n&o^n&s^o&s;g=0|d,b=0|y,d=0|h,y=0|p,h=0|f,p=0|l,({h:f,l}=ws.add(0|u,0|c,0|E,0|S)),u=0|a,c=0|s,a=0|i,s=0|o,i=0|r,o=0|n;const A=ws.add3L(S,T,x);r=ws.add3H(A,E,k,O),n=0|A}({h:r,l:n}=ws.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=ws.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:a,l:s}=ws.add(0|this.Ch,0|this.Cl,0|a,0|s)),({h:u,l:c}=ws.add(0|this.Dh,0|this.Dl,0|u,0|c)),({h:f,l}=ws.add(0|this.Eh,0|this.El,0|f,0|l)),({h,l:p}=ws.add(0|this.Fh,0|this.Fl,0|h,0|p)),({h:d,l:y}=ws.add(0|this.Gh,0|this.Gl,0|d,0|y)),({h:g,l:b}=ws.add(0|this.Hh,0|this.Hl,0|g,0|b)),this.set(r,n,i,o,a,s,u,c,f,l,h,p,d,y,g,b)}roundClean(){Es.fill(0),Ss.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 Ts=Wa((()=>new ks));function Os(t,e){return qa(Ts,t,e)}const xs="0123456789abcdefABCDEF",As=(xs.split("").map((t=>t.codePointAt(0))),Array(256).fill(!0).map(((t,e)=>{const r=String.fromCodePoint(e),n=xs.indexOf(r);return n<0?void 0:n<16?n:n-6}))),Ps=new TextEncoder;function Is(t,e){const r=Math.min(t.length,e.length);for(let n=0;n<r;++n)if(t[n]!==e[n])return t[n]<e[n]?-1:1;return t.length===e.length?0:t.length>e.length?1:-1}function Ls(t,e,r){if(e+1>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);t[e]=r}function Bs(t,e,r,n){if(e+4>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received ${r}`);"LE"===n?(t[e]=255&r,t[e+1]=r>>8&255,t[e+2]=r>>16&255,t[e+3]=r>>24&255):(t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r)}function Rs(t,e,r){if(e+4>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0;return r=(r<<8)+t[e+3]>>>0,r=(r<<8)+t[e+2]>>>0,r=(r<<8)+t[e+1]>>>0,r=(r<<8)+t[e]>>>0,r}{let r=0;return r=(r<<8)+t[e]>>>0,r=(r<<8)+t[e+1]>>>0,r=(r<<8)+t[e+2]>>>0,r=(r<<8)+t[e+3]>>>0,r}}new TextDecoder;const Ns=t=>function(t){const e=Ps.encode(t||""),r=new Uint8Array(Math.floor(e.length/2));let n;for(n=0;n<r.length;n++){const t=As[e[2*n]],i=As[e[2*n+1]];if(void 0===t||void 0===i)break;r[n]=t<<4|i}return n===r.length?r:r.slice(0,n)}(t);function js(t){if(!t)throw new Error("ecc library invalid")}function Us(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function Cs(t,e){return!!Array.isArray(e)&&(0===e.length||(t?e.every((t=>"string"==typeof t)):e.every((t=>Number.isSafeInteger(t)))))}function Fs(t){if("function"!=typeof t)throw new Error("function expected");return!0}function Ms(t,e){if("string"!=typeof e)throw new Error(`${t}: string expected`);return!0}function Ds(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Hs(t){if(!Array.isArray(t))throw new Error("array expected")}function Ks(t,e){if(!Cs(!0,e))throw new Error(`${t}: array of strings expected`)}function Gs(t,e){if(!Cs(!1,e))throw new Error(`${t}: array of numbers expected`)}function Ws(...t){const e=t=>t,r=(t,e)=>r=>t(e(r)),n=t.map((t=>t.encode)).reduceRight(r,e),i=t.map((t=>t.decode)).reduce(r,e);return{encode:n,decode:i}}function Vs(t){const e="string"==typeof t?t.split(""):t,r=e.length;Ks("alphabet",e);const n=new Map(e.map(((t,e)=>[t,e])));return{encode:n=>(Hs(n),n.map((n=>{if(!Number.isSafeInteger(n)||n<0||n>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${n}". Allowed: ${t}`);return e[n]}))),decode:e=>(Hs(e),e.map((e=>{Ms("alphabet.decode",e);const r=n.get(e);if(void 0===r)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return r})))}}function qs(t=""){return Ms("join",t),{encode:e=>(Ks("join.decode",e),e.join(t)),decode:e=>(Ms("join.decode",e),e.split(t))}}function zs(t,e="="){return Ds(t),Ms("padding",e),{encode(r){for(Ks("padding.encode",r);r.length*t%8;)r.push(e);return r},decode(r){Ks("padding.decode",r);let n=r.length;if(n*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if((n-1)*t%8==0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,n)}}}function Ys(t){return Fs(t),{encode:t=>t,decode:e=>t(e)}}function Xs(t,e,r){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Hs(t),!t.length)return[];let n=0;const i=[],o=Array.from(t,(t=>{if(Ds(t),t<0||t>=e)throw new Error(`invalid integer: ${t}`);return t})),a=o.length;for(;;){let t=0,s=!0;for(let i=n;i<a;i++){const a=o[i],u=e*t,c=u+a;if(!Number.isSafeInteger(c)||u/e!==t||c-a!==u)throw new Error("convertRadix: carry overflow");const f=c/r;t=c%r;const l=Math.floor(f);if(o[i]=l,!Number.isSafeInteger(l)||l*r+t!==c)throw new Error("convertRadix: carry overflow");s&&(l?s=!1:n=i)}if(i.push(t),s)break}for(let e=0;e<t.length-1&&0===t[e];e++)i.push(0);return i.reverse()}const Zs=(t,e)=>0===e?t:Zs(e,t%e),$s=(t,e)=>t+(e-Zs(t,e)),Js=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function Qs(t,e,r,n){if(Hs(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if($s(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${$s(e,r)}`);let i=0,o=0;const a=Js[e],s=Js[r]-1,u=[];for(const n of t){if(Ds(n),n>=a)throw new Error(`convertRadix2: invalid data word=${n} from=${e}`);if(i=i<<e|n,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=r;o-=r)u.push((i>>o-r&s)>>>0);const t=Js[o];if(void 0===t)throw new Error("invalid carry");i&=t-1}if(i=i<<r-o&s,!n&&o>=e)throw new Error("Excess padding");if(!n&&i>0)throw new Error(`Non-zero padding: ${i}`);return n&&o>0&&u.push(i>>>0),u}function tu(t,e=!1){if(Ds(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if($s(8,t)>32||$s(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Us(r))throw new Error("radix2.encode input should be Uint8Array");return Qs(Array.from(r),8,t,!e)},decode:r=>(Gs("radix2.decode",r),Uint8Array.from(Qs(r,t,8,e)))}}function eu(t){return Fs(t),function(...e){try{return t.apply(null,e)}catch(t){}}}Ws(tu(4),Vs("0123456789ABCDEF"),qs("")),Ws(tu(5),Vs("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),zs(5),qs("")),Ws(tu(5),Vs("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),qs("")),Ws(tu(5),Vs("0123456789ABCDEFGHIJKLMNOPQRSTUV"),zs(5),qs("")),Ws(tu(5),Vs("0123456789ABCDEFGHIJKLMNOPQRSTUV"),qs("")),Ws(tu(5),Vs("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),qs(""),Ys((t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),Ws(tu(6),Vs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),zs(6),qs("")),Ws(tu(6),Vs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),qs("")),Ws(tu(6),Vs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),zs(6),qs("")),Ws(tu(6),Vs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),qs(""));const ru=t=>{return Ws((Ds(e=58),{encode:t=>{if(!Us(t))throw new Error("radix.encode input should be Uint8Array");return Xs(Array.from(t),256,e)},decode:t=>(Gs("radix.decode",t),Uint8Array.from(Xs(t,e,256)))}),Vs(t),qs(""));var e},nu=ru("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),iu=(ru("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),ru("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),t=>Ws(function(t,e){return Ds(t),Fs(e),{encode(r){if(!Us(r))throw new Error("checksum.encode: input should be Uint8Array");const n=e(r).slice(0,t),i=new Uint8Array(r.length+t);return i.set(r),i.set(n,r.length),i},decode(r){if(!Us(r))throw new Error("checksum.decode: input should be Uint8Array");const n=r.slice(0,-t),i=r.slice(-t),o=e(n).slice(0,t);for(let e=0;e<t;e++)if(o[e]!==i[e])throw new Error("Invalid checksum");return n}}}(4,(e=>t(t(e)))),nu)),ou=Ws(Vs("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),qs("")),au=[996825010,642813549,513874426,1027748829,705979059];function su(t){const e=t>>25;let r=(33554431&t)<<5;for(let t=0;t<au.length;t++)1==(e>>t&1)&&(r^=au[t]);return r}function uu(t,e,r=1){const n=t.length;let i=1;for(let e=0;e<n;e++){const r=t.charCodeAt(e);if(r<33||r>126)throw new Error(`Invalid prefix (${t})`);i=su(i)^r>>5}i=su(i);for(let e=0;e<n;e++)i=su(i)^31&t.charCodeAt(e);for(let t of e)i=su(i)^t;for(let t=0;t<6;t++)i=su(i);return i^=r,ou.encode(Qs([i%Js[30]],30,5,!1))}function cu(t){const e="bech32"===t?1:734539939,r=tu(5),n=r.decode,i=r.encode,o=eu(n);function a(t,r,n=90){Ms("bech32.encode prefix",t),Us(r)&&(r=Array.from(r)),Gs("bech32.encode",r);const i=t.length;if(0===i)throw new TypeError(`Invalid prefix length ${i}`);const o=i+7+r.length;if(!1!==n&&o>n)throw new TypeError(`Length ${o} exceeds limit ${n}`);const a=t.toLowerCase(),s=uu(a,r,e);return`${a}1${ou.encode(r)}${s}`}function s(t,r=90){Ms("bech32.decode input",t);const n=t.length;if(n<8||!1!==r&&n>r)throw new TypeError(`invalid string length: ${n} (${t}). Expected (8..${r})`);const i=t.toLowerCase();if(t!==i&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=i.lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const a=i.slice(0,o),s=i.slice(o+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const u=ou.decode(s).slice(0,-6),c=uu(a,u,e);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected "${c}"`);return{prefix:a,words:u}}return{encode:a,decode:s,encodeFromBytes:function(t,e){return a(t,i(e))},decodeToBytes:function(t){const{prefix:e,words:r}=s(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:eu(s),fromWords:n,fromWordsUnsafe:o,toWords:i}}function fu(t){const e=typeof t;return"string"===e?`"${t}"`:"number"===e||"bigint"===e||"boolean"===e?`${t}`:"object"===e||"function"===e?(t&&Object.getPrototypeOf(t)?.constructor?.name)??"null":e}function lu(t,e,r,n,i){const o=i&&"input"in i?i.input:r.value,a=i?.expected??t.expects??null,s=i?.received??fu(o),u={kind:t.kind,type:t.type,input:o,expected:a,received:s,message:`Invalid ${e}: ${a?`Expected ${a} but r`:"R"}eceived ${s}`,requirement:t.requirement,path:i?.path,issues:i?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},c="schema"===t.kind,f=i?.message??t.message??(t.reference,void u.lang)??(c?void u.lang:null)??n.message??void u.lang;f&&(u.message="function"==typeof f?f(u):f),c&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}cu("bech32"),cu("bech32m"),Ws(tu(4),Vs("0123456789abcdef"),qs(""),Ys((t=>{if("string"!=typeof t||t.length%2!=0)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})));var hu=class extends Error{issues;constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function pu(t){return{kind:"validation",type:"integer",reference:pu,async:!1,expects:null,requirement:Number.isInteger,message:t,_run(t,e){return t.typed&&!this.requirement(t.value)&&lu(this,"integer",t,e),t}}}function du(t,e){return{kind:"validation",type:"length",reference:du,async:!1,expects:`${t}`,requirement:t,message:e,_run(t,e){return t.typed&&t.value.length!==this.requirement&&lu(this,"length",t,e,{received:`${t.value.length}`}),t}}}function yu(t,e){return{kind:"validation",type:"max_value",reference:yu,async:!1,expects:`<=${t instanceof Date?t.toJSON():fu(t)}`,requirement:t,message:e,_run(t,e){return t.typed&&t.value>this.requirement&&lu(this,"value",t,e,{received:t.value instanceof Date?t.value.toJSON():fu(t.value)}),t}}}function gu(t,e){return{kind:"validation",type:"min_value",reference:gu,async:!1,expects:`>=${t instanceof Date?t.toJSON():fu(t)}`,requirement:t,message:e,_run(t,e){return t.typed&&t.value<this.requirement&&lu(this,"value",t,e,{received:t.value instanceof Date?t.value.toJSON():fu(t.value)}),t}}}function bu(t,e){return{kind:"schema",type:"instance",reference:bu,expects:t.name,async:!1,class:t,message:e,_run(t,e){return t.value instanceof this.class?t.typed=!0:lu(this,"type",t,e),t}}}function vu(t){return{kind:"schema",type:"number",reference:vu,expects:"number",async:!1,message:t,_run(t,e){return"number"!=typeof t.value||isNaN(t.value)?lu(this,"type",t,e):t.typed=!0,t}}}function wu(t,e){return{kind:"schema",type:"object",reference:wu,expects:"Object",async:!1,entries:t,message:e,_run(t,e){const r=t.value;if(r&&"object"==typeof r){t.typed=!0,t.value={};for(const n in this.entries){const i=r[n],o=this.entries[n]._run({typed:!1,value:i},e);if(o.issues){const a={type:"object",origin:"value",input:r,key:n,value:i};for(const e of o.issues)e.path?e.path.unshift(a):e.path=[a],t.issues?.push(e);if(t.issues||(t.issues=o.issues),e.abortEarly){t.typed=!1;break}}o.typed||(t.typed=!1),(void 0!==o.value||n in r)&&(t.value[n]=o.value)}}else lu(this,"type",t,e);return t}}}function mu(t,e,r){const n=t._run({typed:!1,value:e},function(t){return{lang:t?.lang??void 0,message:t?.message,abortEarly:t?.abortEarly??void 0,abortPipeEarly:t?.abortPipeEarly??void 0}}(r));if(n.issues)throw new hu(n.issues);return n.value}function _u(...t){return{...t[0],pipe:t,_run(e,r){for(const n of t)if("metadata"!==n.kind){if(e.issues&&("schema"===n.kind||"transformation"===n.kind)){e.typed=!1;break}e.issues&&(r.abortEarly||r.abortPipeEarly)||(e=n._run(e,r))}return e}}}const Eu=_u(vu(),pu(),gu(0),yu(4294967295)),Su=_u(vu(),pu(),gu(0),yu(2147483647)),ku=_u(vu(),pu(),gu(0),yu(255)),Tu=_u(bu(Uint8Array),du(32)),Ou=_u(bu(Uint8Array),du(33)),xu=wu({wif:ku,bip32:wu({public:Eu,private:Eu})}),Au=_u(function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,_run(t,e){return"string"==typeof t.value?t.typed=!0:lu(this,"type",t,e),t}}}(),function t(e,r){return{kind:"validation",type:"regex",reference:t,async:!1,expects:`${e}`,requirement:e,message:r,_run(t,e){return t.typed&&!this.requirement.test(t.value)&&lu(this,"format",t,e),t}}}(/^(m\/)?(\d+'?\/)*\d+'?$/)),Pu=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let t=0;t<e.length;t++)e[t]=255;for(let r=0;r<t.length;r++){const n=t.charAt(r),i=n.charCodeAt(0);if(255!==e[i])throw new TypeError(n+" is ambiguous");e[i]=r}const r=t.length,n=t.charAt(0),i=Math.log(r)/Math.log(256),o=Math.log(256)/Math.log(r);function a(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;let o=0,a=0,s=0;for(;t[o]===n;)a++,o++;const u=(t.length-o)*i+1>>>0,c=new Uint8Array(u);for(;t[o];){let n=e[t.charCodeAt(o)];if(255===n)return;let i=0;for(let t=u-1;(0!==n||i<s)&&-1!==t;t--,i++)n+=r*c[t]>>>0,c[t]=n%256>>>0,n=n/256>>>0;if(0!==n)throw new Error("Non-zero carry");s=i,o++}let f=u-s;for(;f!==u&&0===c[f];)f++;const l=new Uint8Array(a+(u-f));let h=a;for(;f!==u;)l[h++]=c[f++];return l}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";let i=0,a=0,s=0;const u=e.length;for(;s!==u&&0===e[s];)s++,i++;const c=(u-s)*o+1>>>0,f=new Uint8Array(c);for(;s!==u;){let t=e[s],n=0;for(let e=c-1;(0!==t||n<a)&&-1!==e;e--,n++)t+=256*f[e]>>>0,f[e]=t%r>>>0,t=t/r>>>0;if(0!==t)throw new Error("Non-zero carry");a=n,s++}let l=c-a;for(;l!==c&&0===f[l];)l++;let h=n.repeat(i);for(;l<c;++l)h+=t.charAt(f[l]);return h},decodeUnsafe:a,decode:function(t){const e=a(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Iu=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),n=t(r),i=r.length+4,o=new Uint8Array(i);return o.set(r,0),o.set(n.subarray(0,4),r.length),Pu.encode(o)},decode:function(t){var r=e(Pu.decode(t));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=Pu.decodeUnsafe(t);if(null!=r)return e(r)}}}((function(t){return ds(ds(t))}));const Lu=iu(ds);var Bu=i(8700);const Ru=2n**256n,Nu=Ru-0x1000003d1n,ju=Ru-0x14551231950b75fc4402da1732fc9bebfn,Uu=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Cu=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,Fu={p:Nu,n:ju,a:0n,b:7n,Gx:Uu,Gy:Cu},Mu=t=>Yu(Yu(t*t)*t+Fu.b),Du=(t="")=>{throw new Error(t)},Hu=t=>"bigint"==typeof t,Ku=t=>"string"==typeof t,Gu=t=>Hu(t)&&0n<t&&t<Nu,Wu=t=>Hu(t)&&0n<t&&t<ju,Vu=(t,e)=>!(t=>t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name)(t)||"number"==typeof e&&e>0&&t.length!==e?Du("Uint8Array expected"):t,qu=t=>new Uint8Array(t),zu=(t,e)=>Vu(Ku(t)?ec(t):qu(Vu(t)),e),Yu=(t,e=Nu)=>{let r=t%e;return r>=0n?r:e+r},Xu=t=>t instanceof Zu?t:Du("Point expected");class Zu{constructor(t,e,r){this.px=t,this.py=e,this.pz=r}static fromAffine(t){return 0n===t.x&&0n===t.y?Zu.ZERO:new Zu(t.x,t.y,1n)}static fromHex(t){let e;const r=(t=zu(t))[0],n=t.subarray(1),i=nc(n,0,32),o=t.length;if(33===o&&[2,3].includes(r)){Gu(i)||Du("Point hex invalid: x not FE");let t=uc(Mu(i));!(1&~r)!=(1n===(1n&t))&&(t=Yu(-t)),e=new Zu(i,t,1n)}return 65===o&&4===r&&(e=new Zu(i,nc(n,32,64),1n)),e?e.ok():Du("Point is not on curve")}static fromPrivateKey(t){return $u.mul(cc(t))}get x(){return this.aff().x}get y(){return this.aff().y}equals(t){const{px:e,py:r,pz:n}=this,{px:i,py:o,pz:a}=Xu(t),s=Yu(e*a),u=Yu(i*n),c=Yu(r*a),f=Yu(o*n);return s===u&&c===f}negate(){return new Zu(this.px,Yu(-this.py),this.pz)}double(){return this.add(this)}add(t){const{px:e,py:r,pz:n}=this,{px:i,py:o,pz:a}=Xu(t),{a:s,b:u}=Fu;let c=0n,f=0n,l=0n;const h=Yu(3n*u);let p=Yu(e*i),d=Yu(r*o),y=Yu(n*a),g=Yu(e+r),b=Yu(i+o);g=Yu(g*b),b=Yu(p+d),g=Yu(g-b),b=Yu(e+n);let v=Yu(i+a);return b=Yu(b*v),v=Yu(p+y),b=Yu(b-v),v=Yu(r+n),c=Yu(o+a),v=Yu(v*c),c=Yu(d+y),v=Yu(v-c),l=Yu(s*b),c=Yu(h*y),l=Yu(c+l),c=Yu(d-l),l=Yu(d+l),f=Yu(c*l),d=Yu(p+p),d=Yu(d+p),y=Yu(s*y),b=Yu(h*b),d=Yu(d+y),y=Yu(p-y),y=Yu(s*y),b=Yu(b+y),p=Yu(d*b),f=Yu(f+p),p=Yu(v*b),c=Yu(g*c),c=Yu(c-p),p=Yu(g*d),l=Yu(v*l),l=Yu(l+p),new Zu(c,f,l)}mul(t,e=!0){if(!e&&0n===t)return Ju;if(Wu(t)||Du("invalid scalar"),this.equals($u))return dc(t).p;let r=Ju,n=$u;for(let i=this;t>0n;i=i.double(),t>>=1n)1n&t?r=r.add(i):e&&(n=n.add(i));return r}mulAddQUns(t,e,r){return this.mul(e,!1).add(t.mul(r,!1)).ok()}toAffine(){const{px:t,py:e,pz:r}=this;if(this.equals(Ju))return{x:0n,y:0n};if(1n===r)return{x:t,y:e};const n=sc(r);return 1n!==Yu(r*n)&&Du("invalid inverse"),{x:Yu(t*n),y:Yu(e*n)}}assertValidity(){const{x:t,y:e}=this.aff();return Gu(t)&&Gu(e)||Du("Point invalid: x or y"),Yu(e*e)===Mu(t)?this:Du("Point invalid: not on curve")}multiply(t){return this.mul(t)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(t=!0){const{x:e,y:r}=this.aff();return(t?0n===(1n&r)?"02":"03":"04")+oc(e)+(t?"":oc(r))}toRawBytes(t=!0){return ec(this.toHex(t))}}Zu.BASE=new Zu(Uu,Cu,1n),Zu.ZERO=new Zu(0n,1n,0n);const{BASE:$u,ZERO:Ju}=Zu,Qu=(t,e)=>t.toString(16).padStart(e,"0"),tc=t=>Array.from(t).map((t=>Qu(t,2))).join(""),ec=t=>{const e=t.length;(!Ku(t)||e%2)&&Du("hex invalid 1");const r=qu(e/2);for(let e=0;e<r.length;e++){const n=2*e,i=t.slice(n,n+2),o=Number.parseInt(i,16);(Number.isNaN(o)||o<0)&&Du("hex invalid 2"),r[e]=o}return r},rc=t=>BigInt("0x"+(tc(t)||"0")),nc=(t,e,r)=>rc(t.slice(e,r)),ic=t=>Hu(t)&&t>=0n&&t<Ru?ec(Qu(t,64)):Du("bigint expected"),oc=t=>tc(ic(t)),ac=(...t)=>{const e=qu(t.reduce(((t,e)=>t+Vu(e).length),0));let r=0;return t.forEach((t=>{e.set(t,r),r+=t.length})),e},sc=(t,e=Nu)=>{(0n===t||e<=0n)&&Du("no inverse n="+t+" mod="+e);let r=Yu(t,e),n=e,i=0n,o=1n,a=1n,s=0n;for(;0n!==r;){const t=n/r,e=n%r,u=i-a*t,c=o-s*t;n=r,r=e,i=a,o=s,a=u,s=c}return 1n===n?Yu(i,e):Du("no inverse")},uc=t=>{let e=1n;for(let r=t,n=(Nu+1n)/4n;n>0n;n>>=1n)1n&n&&(e=e*r%Nu),r=r*r%Nu;return Yu(e*e)===t?e:Du("sqrt invalid")},cc=t=>(Hu(t)||(t=rc(zu(t,32))),Wu(t)?t:Du("private key out of range")),fc=()=>"object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;let lc;const hc={hexToBytes:ec,bytesToHex:tc,concatBytes:ac,bytesToNumberBE:rc,numberToBytesBE:ic,mod:Yu,invert:sc,hmacSha256Async:async(t,...e)=>{const r=fc(),n=r&&r.subtle;if(!n)return Du("etc.hmacSha256Async not set");const i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return qu(await n.sign("HMAC",i,ac(...e)))},hmacSha256Sync:lc,hashToPrivateKey:t=>{((t=zu(t)).length<40||t.length>1024)&&Du("expected proper params");const e=Yu(rc(t),ju-1n)+1n;return ic(e)},randomBytes:(t=32)=>{const e=fc();return e&&e.getRandomValues||Du("crypto.getRandomValues must be defined"),e.getRandomValues(qu(t))}};let pc;Object.defineProperties(hc,{hmacSha256Sync:{configurable:!1,get:()=>lc,set(t){lc||(lc=t)}}});const dc=t=>{const e=pc||(pc=(()=>{const t=[];let e=$u,r=e;for(let n=0;n<33;n++){r=e,t.push(r);for(let n=1;n<128;n++)r=r.add(e),t.push(r);e=r.double()}return t})()),r=(t,e)=>{let r=e.negate();return t?r:e};let n=Ju,i=$u;const o=BigInt(255),a=BigInt(8);for(let s=0;s<33;s++){const u=128*s;let c=Number(t&o);t>>=a,c>128&&(c-=256,t+=1n);const f=u,l=u+Math.abs(c)-1,h=s%2!=0,p=c<0;0===c?i=i.add(r(h,e[f])):n=n.add(r(p,e[l]))}return{p:n,f:i}};var yc=i(8287).Buffer;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 bc(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,wc(n.key),n)}}function vc(t,e,r){return(e=wc(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function wc(t){var e=function(t){if("object"!=gc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=gc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gc(e)?e:e+""}ga(ja);var mc=function(t){!function(t){if(js(t.isPoint(Ns("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),js(!t.isPoint(Ns("030000000000000000000000000000000000000000000000000000000000000005"))),js(t.isPrivate(Ns("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),js(t.isPrivate(Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),js(!t.isPrivate(Ns("0000000000000000000000000000000000000000000000000000000000000000"))),js(!t.isPrivate(Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),js(!t.isPrivate(Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),js(0===Is(t.pointFromScalar(Ns("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")),Ns("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),t.xOnlyPointAddTweak){js(null===t.xOnlyPointAddTweak(Ns("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")));let e=t.xOnlyPointAddTweak(Ns("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),Ns("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));js(0===Is(e.xOnlyPubkey,Ns("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&1===e.parity),e=t.xOnlyPointAddTweak(Ns("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),Ns("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47"))}js(0===Is(t.pointAddScalar(Ns("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Ns("0000000000000000000000000000000000000000000000000000000000000003")),Ns("02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"))),js(0===Is(t.privateAdd(Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),Ns("0000000000000000000000000000000000000000000000000000000000000002")),Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),t.privateNegate&&(js(0===Is(t.privateNegate(Ns("0000000000000000000000000000000000000000000000000000000000000001")),Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),js(0===Is(t.privateNegate(Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e")),Ns("0000000000000000000000000000000000000000000000000000000000000003"))),js(0===Is(t.privateNegate(Ns("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")),Ns("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")))),js(0===Is(t.sign(Ns("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),Ns("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")),Ns("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),js(t.verify(Ns("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),Ns("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Ns("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),t.signSchnorr&&js(0===Is(t.signSchnorr(Ns("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),Ns("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),Ns("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906")),Ns("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),t.verifySchnorr&&js(t.verifySchnorr(Ns("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),Ns("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),Ns("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}(t);const e={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},r=2147483648;class n{__D;__Q;lowR=!1;constructor(t,e){this.__D=t,this.__Q=e}get publicKey(){return void 0===this.__Q&&(this.__Q=t.pointFromScalar(this.__D,!0)),this.__Q}get privateKey(){return this.__D}sign(e,r){if(!this.privateKey)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return t.sign(e,this.privateKey);{let r=t.sign(e,this.privateKey);const n=new Uint8Array(32);let i=0;for(;r[0]>127;)i++,Bs(n,0,i,"LE"),r=t.sign(e,this.privateKey,n);return r}}signSchnorr(e){if(!this.privateKey)throw new Error("Missing private key");if(!t.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return t.signSchnorr(e,this.privateKey)}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}}class i extends n{chainCode;network;__DEPTH;__INDEX;__PARENT_FINGERPRINT;constructor(t,e,r,n,i=0,o=0,a=0){super(t,e),this.chainCode=r,this.network=n,this.__DEPTH=i,this.__INDEX=o,this.__PARENT_FINGERPRINT=a,mu(xu,n)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return t=this.publicKey,cs(ds(t));var t}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return void 0===this.__D}neutered(){return s(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const t=this.network,e=this.isNeutered()?t.bip32.public:t.bip32.private,r=new Uint8Array(78);return Bs(r,0,e,"BE"),Ls(r,4,this.depth),Bs(r,5,this.parentFingerprint,"BE"),Bs(r,9,this.index,"BE"),r.set(this.chainCode,13),this.isNeutered()?r.set(this.publicKey,45):(Ls(r,45,0),r.set(this.privateKey,46)),n=r,Lu.encode(n);var n}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return t={version:this.network.wif,privateKey:this.privateKey,compressed:!0},Iu.encode(function(t,e,r){if(32!==e.length)throw new TypeError("Invalid privateKey length");var n=new Uint8Array(r?34:33);return new DataView(n.buffer).setUint8(0,t),n.set(e,1),r&&(n[33]=1),n}(t.version,t.privateKey,t.compressed));var t}derive(e){mu(Eu,e);const n=e>=r,i=new Uint8Array(37);if(n){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");i[0]=0,i.set(this.privateKey,1),Bs(i,33,e,"BE")}else i.set(this.publicKey,0),Bs(i,33,e,"BE");const o=Os(this.chainCode,i),u=o.slice(0,32),c=o.slice(32);if(!t.isPrivate(u))return this.derive(e+1);let f;if(this.isNeutered()){const r=t.pointAddScalar(this.publicKey,u,!0);if(null===r)return this.derive(e+1);f=s(r,c,this.network,this.depth+1,e,Rs(this.fingerprint,0,"BE"))}else{const r=t.privateAdd(this.privateKey,u);if(null==r)return this.derive(e+1);f=a(r,c,this.network,this.depth+1,e,Rs(this.fingerprint,0,"BE"))}return f}deriveHardened(t){if("number"==typeof mu(Su,t))return this.derive(t+r);throw new TypeError("Expected UInt31, got "+t)}derivePath(t){mu(Au,t);let e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new TypeError("Expected master, got child");e=e.slice(1)}return e.reduce(((t,e)=>{let r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))}),this)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}tweakFromPublicKey(e){const r=32===(i=this.publicKey).length?i:i.slice(1,33);var i;if(!t.xOnlyPointAddTweak)throw new Error("xOnlyPointAddTweak not supported by ecc library");const o=t.xOnlyPointAddTweak(r,e);if(!o||null===o.xOnlyPubkey)throw new Error("Cannot tweak public key!");const a=function(t){const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);let n=0;for(const e of t)r.set(e,n),n+=e.length;return r}([Uint8Array.from([0===o.parity?2:3]),o.xOnlyPubkey]);return new n(void 0,a)}tweakFromPrivateKey(e){const r=3===this.publicKey[0]||4===this.publicKey[0]&&!(1&~this.publicKey[64]),i=(()=>{if(r){if(t.privateNegate)return t.privateNegate(this.privateKey);throw new Error("privateNegate not supported by ecc library")}return this.privateKey})(),o=t.privateAdd(i,e);if(!o)throw new Error("Invalid tweaked private key!");return new n(o,void 0)}}function o(t,e,r){return a(t,e,r)}function a(r,n,o,a,s,u){if(mu(Tu,r),mu(Tu,n),o=o||e,!t.isPrivate(r))throw new TypeError("Private key not in range [1, n)");return new i(r,void 0,n,o,a,s,u)}function s(r,n,o,a,s,u){if(mu(Ou,r),mu(Tu,n),o=o||e,!t.isPoint(r))throw new TypeError("Point is not on the curve");return new i(void 0,r,n,o,a,s,u)}return{fromSeed:function(t,r){if(mu(bu(Uint8Array),t),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");r=r||e;const n=Os(Ps.encode("Bitcoin seed"),t);return o(n.slice(0,32),n.slice(32),r)},fromBase58:function(t,r){const n=(i=t,Lu.decode(i));var i;if(78!==n.length)throw new TypeError("Invalid buffer length");r=r||e;const o=Rs(n,0,"BE");if(o!==r.bip32.private&&o!==r.bip32.public)throw new TypeError("Invalid network version");const u=n[4],c=Rs(n,5,"BE");if(0===u&&0!==c)throw new TypeError("Invalid parent fingerprint");const f=Rs(n,9,"BE");if(0===u&&0!==f)throw new TypeError("Invalid index");const l=n.slice(13,45);let h;if(o===r.bip32.private){if(0!==n[45])throw new TypeError("Invalid private key");h=a(n.slice(46,78),l,r,u,f,c)}else h=s(n.slice(45,78),l,r,u,f,c);return h},fromPublicKey:function(t,e,r){return s(t,e,r)},fromPrivateKey:o}};if(!mc)throw new Error("Failed to load BIP32 library");var _c,Ec=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&bc(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"fromWIF",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin;return this.ECPair.fromWIF(t,e)}},{key:"fromPrivateKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin;return this.ECPair.fromPrivateKey(yc.isBuffer(t)?t:yc.from(t),{network:e})}},{key:"fromPublicKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin,r=yc.isBuffer(t)?t:yc.from(t);return this.ECPair.fromPublicKey(r,{network:e})}},{key:"generateMultiSigAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ka.bitcoin,n=this.verifyPubKeys(t,r);if(n.length!==t.length)throw new Error("Contains invalid public keys");var i=Oa.p2ms({m:e,pubkeys:n,network:r}),o=Oa.p2wsh({redeem:i,network:r}).address;if(!o)throw new Error("Failed to generate address");return o}},{key:"verifyPubKeys",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin;return e.map((function(e){var n=t.fromPublicKey(e,r);if(!n)throw new Error("Failed to regenerate key");return yc.from(n.publicKey)}))}},{key:"getP2WPKHAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin,r=Oa.p2wpkh({pubkey:yc.from(t.publicKey),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"tweakedPubKeyToAddress",value:function(e,r){e.startsWith("0x")&&(e=e.slice(2));var n=yc.from(e,"hex");return 32!==n.length&&(n=Ba(n)),t.tweakedPubKeyBufferToAddress(n,r)}},{key:"tweakedPubKeyBufferToAddress",value:function(t,e){var r=Oa.p2tr({pubkey:yc.isBuffer(t)?t:yc.from(t),network:e}).address;if(!r)throw new Error("Failed to generate Taproot address");return r}},{key:"xOnlyTweakedPubKeyToAddress",value:function(t,e){t.startsWith("0x")&&(t=t.slice(2));var r=yc.from(t,"hex"),n=Oa.p2tr({pubkey:r,network:e}).address;if(!n)throw new Error("Failed to generate Taproot address");return n}},{key:"tweakPublicKey",value:function(t){"string"==typeof t&&t.startsWith("0x")&&(t=t.slice(2)),"string"!=typeof t&&(t=t.toString("hex"));var e=Zu.fromHex(t);0n!==(1n&e.y)&&(e=e.negate());var r=e.toRawBytes(!0).slice(1),n=Ia("TapTweak",yc.from(r)),i=function(t,e){var r=t%e;return r>=0n?r:r+e}(BigInt("0x"+yc.from(n).toString("hex")),Fu.n),o=e.add(Zu.BASE.mul(i));return yc.from(o.toRawBytes(!0))}},{key:"generateWallet",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ka.bitcoin,e=this.ECPair.makeRandom({network:t}),r=this.getP2WPKHAddress(e,t);if(!r)throw new Error("Failed to generate wallet");return{address:r,privateKey:e.toWIF(),publicKey:yc.from(e.publicKey).toString("hex")}}},{key:"verifyContractAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin;return!!ha.toOutputScript(t,e)}},{key:"getLegacySegwitAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin,r=Oa.p2sh({redeem:Oa.p2wpkh({pubkey:yc.from(t.publicKey),network:e}),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"getLegacyAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin,r=Oa.p2pkh({pubkey:yc.from(t.publicKey),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"getP2PKAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin,r=Oa.p2pk({pubkey:yc.from(t.publicKey),network:e});if(!r.output)throw new Error("Failed to generate wallet");return"0x"+r.output.toString("hex")}},{key:"generateRandomKeyPair",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ka.bitcoin;return this.ECPair.makeRandom({network:t})}},{key:"fromSeed",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin;return this.BIP32.fromSeed(t,e)}},{key:"getTaprootAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin,r=Oa.p2tr({internalPubkey:Ba(yc.from(t.publicKey)),network:e}).address;if(!r)throw new Error("Failed to generate sender address for transaction");return r}},{key:"getTaprootAddressFromAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin,r=Oa.p2tr({address:t,network:e}).address;if(!r)throw new Error("Failed to generate sender address for transaction");return r}},{key:"fromSeedKeyPair",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin,r=this.BIP32.fromSeed(t,e).privateKey;if(!r)throw new Error("Failed to generate key pair");return this.ECPair.fromPrivateKey(yc.from(r),{network:e})}}])}();function Sc(t){return Sc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Sc(t)}vc(Ec,"BIP32",mc(ja)),vc(Ec,"ECPair",(0,Bu.dg)(ja)),function(t){t[t.UNWRAP=0]="UNWRAP"}(_c||(_c={}));var kc=function(t,e,r){return(e=function(t){var e=function(t){if("object"!=Sc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Sc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Sc(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},_c.UNWRAP,Ta.OP_16),Tc=i(8287).Buffer;function Oc(t){return Oc="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},Oc(t)}function xc(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,Pc(n.key),n)}}function Ac(t,e,r){return(e=Pc(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Pc(t){var e=function(t){if("object"!=Oc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Oc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Oc(e)?e:e+""}var Ic=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ka.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ac(this,"network",ka.bitcoin),this.senderPubKey=e,this.contractSaltPubKey=r,this.network=n,this.xSenderPubKey=Ba(e)}return function(t,e){return e&&xc(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"senderFirstByte",get:function(){return Tc.from([this.senderPubKey[0],0,0,0])}},{key:"splitBufferIntoChunks",value:function(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.DATA_CHUNK_SIZE,n=[],i=0;i<e.length;i+=r){for(var o=Math.min(r,e.length-i),a=Tc.alloc(o),s=0;s<o;s++)a.writeUInt8(e[i+s],s);n.push([a])}return n}}])}();Ac(Ic,"DATA_CHUNK_SIZE",512),Ac(Ic,"MAGIC",Tc.from("bsi","utf-8"));var Lc=i(8287).Buffer;function Bc(t){return Bc="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},Bc(t)}function Rc(t){return function(t){if(Array.isArray(t))return jc(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Nc(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Nc(t,e){if(t){if("string"==typeof t)return jc(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?jc(t,e):void 0}}function jc(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Uc(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Cc(n.key),n)}}function Cc(t){var e=function(t){if("object"!=Bc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Bc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bc(e)?e:e+""}function Fc(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Fc=function(){return!!t})()}function Mc(t){return Mc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Mc(t)}function Dc(t,e){return Dc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Dc(t,e)}var Hc=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ka.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Mc(e),function(t,e){if(e&&("object"==Bc(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,Fc()?Reflect.construct(e,r||[],Mc(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Dc(t,e)}(t,Ic),function(t,e,r){return e&&Uc(t.prototype,e),r&&Uc(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");var s=this.splitBufferIntoChunks(e);if(!s.length)throw new Error("No data chunks found");var u=[this.senderFirstByte,Ta.OP_TOALTSTACK,this.xSenderPubKey,Ta.OP_CHECKSIGVERIFY,this.contractSaltPubKey,Ta.OP_CHECKSIGVERIFY,Ta.OP_HASH160,pa.hash160(this.xSenderPubKey),Ta.OP_EQUALVERIFY,Ta.OP_HASH160,pa.hash160(r),Ta.OP_EQUALVERIFY,Ta.OP_DEPTH,Ta.OP_1,Ta.OP_NUMEQUAL,Ta.OP_IF,Ic.MAGIC];if(o.length>0){var c,f,l=t.getPubKeyAsBuffer(o,this.network),h=this.splitBufferIntoChunks(l);if(u=(c=u).concat.apply(c,[Ta.OP_0].concat(Rc(h))),!a)throw new Error("Minimum signatures must be provided");if(a>255)throw new Error("Minimum signatures cannot exceed 255");var p=Lc.alloc(2);p.writeUint16LE(a,0),u=(f=u).concat.apply(f,[Ta.OP_1,p])}var d=i.map((function(t){return kc[t]})),y=(u=(n=u).concat.apply(n,Rc(d).concat([Ta.OP_1NEGATE].concat(Rc(s),[Ta.OP_ELSE,Ta.OP_1,Ta.OP_ENDIF])))).flat(),g=Pa.compile(y);if(!Pa.decompile(g))throw new Error("Failed to decompile script??");return g}}],[{key:"getPubKeyAsBuffer",value:function(t,e){var r,n=Lc.alloc(0),i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Nc(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(!Ec.fromPublicKey(o,e).compressed)throw new Error("Public key must be compressed");if(33!==o.byteLength)throw new Error("Public key must be 33 bytes, got ".concat(o.byteLength," bytes."));n=Lc.concat([n,o])}}catch(t){i.e(t)}finally{i.f()}var a=p.compress(n);return a.byteLength>=n.byteLength?n:a}}])}();function Kc(t){return Kc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kc(t)}function Gc(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,Wc(n.key),n)}}function Wc(t){var e=function(t){if("object"!=Kc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Kc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kc(e)?e:e+""}function Vc(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Vc=function(){return!!t})()}function qc(t){return qc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},qc(t)}function zc(t,e){return zc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},zc(t,e)}var Yc=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=qc(e),function(t,e){if(e&&("object"==Kc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Vc()?Reflect.construct(e,r||[],qc(t).constructor):e.apply(t,r))}(this,t,[e,void 0,r])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&zc(t,e)}(t,Ic),function(t,e){return e&&Gc(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t){var e=t.flat(),r=Pa.compile(e);if(!Pa.decompile(r))throw new Error("Failed to decompile script??");return r}}])}();function Xc(t){return Xc="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},Xc(t)}function Zc(t){return function(t){if(Array.isArray(t))return $c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return $c(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$c(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Jc(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,Qc(n.key),n)}}function Qc(t){var e=function(t){if("object"!=Xc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Xc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xc(e)?e:e+""}function tf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(tf=function(){return!!t})()}function ef(t){return ef=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ef(t)}function rf(t,e){return rf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},rf(t,e)}var nf=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ka.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=ef(e),function(t,e){if(e&&("object"==Xc(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,tf()?Reflect.construct(e,r||[],ef(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&rf(t,e)}(t,Ic),function(t,e){return e&&Jc(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t,e,r){var n=this.getAsm(t,e,r),i=Pa.compile(n);if(!Pa.decompile(i))throw new Error("Failed to decompile script??");return i}},{key:"getAsm",value:function(t,e,r){if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");var n=this.splitBufferIntoChunks(t),i=r?this.splitBufferIntoChunks(r):[];return[this.senderFirstByte,Ta.OP_TOALTSTACK,this.xSenderPubKey,Ta.OP_CHECKSIGVERIFY,this.contractSaltPubKey,Ta.OP_CHECKSIGVERIFY,Ta.OP_HASH160,pa.hash160(this.xSenderPubKey),Ta.OP_EQUALVERIFY,Ta.OP_HASH256,pa.hash256(e),Ta.OP_EQUALVERIFY,Ta.OP_DEPTH,Ta.OP_1,Ta.OP_NUMEQUAL,Ta.OP_IF,Ic.MAGIC,Ta.OP_0].concat(Zc(i),[Ta.OP_1NEGATE],Zc(n),[Ta.OP_ELSE,Ta.OP_1,Ta.OP_ENDIF]).flat()}}])}(),of=i(8287).Buffer;function af(t){return af="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},af(t)}function sf(t){return function(t){if(Array.isArray(t))return cf(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||uf(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function uf(t,e){if(t){if("string"==typeof t)return cf(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?cf(t,e):void 0}}function cf(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ff(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,lf(n.key),n)}}function lf(t){var e=function(t){if("object"!=af(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=af(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==af(e)?e:e+""}function hf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(hf=function(){return!!t})()}function pf(t){return pf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},pf(t)}function df(t,e){return df=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},df(t,e)}var yf=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=pf(e),function(t,e){if(e&&("object"==af(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,hf()?Reflect.construct(e,r||[],pf(t).constructor):e.apply(t,r))}(this,t,[e,of.alloc(0),r])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&df(t,e)}(t,Ic),function(t,e,r){return e&&ff(t.prototype,e),r&&ff(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=this.splitBufferIntoChunks(e);if(!s.length)throw new Error("No data chunks found");var u=[this.senderPubKey,Ta.OP_CHECKSIGVERIFY,r,Ta.OP_TOALTSTACK,Ta.OP_DEPTH,Ta.OP_1,Ta.OP_NUMEQUAL,Ta.OP_IF,Ic.MAGIC];if(o.length>0){var c,f,l=t.getPubKeyAsBuffer(o,this.network),h=this.splitBufferIntoChunks(l);if(u=(c=u).concat.apply(c,[Ta.OP_0].concat(sf(h))),!a)throw new Error("Minimum signatures must be provided");if(a>255)throw new Error("Minimum signatures cannot exceed 255");var p=of.alloc(2);p.writeUint16LE(a,0),u=(f=u).concat.apply(f,[Ta.OP_1,p])}var d=i.map((function(t){return kc[t]})),y=(u=(n=u).concat.apply(n,sf(d).concat([Ta.OP_1NEGATE].concat(sf(s),[Ta.OP_ELSE,Ta.OP_1,Ta.OP_ENDIF])))).flat(),g=Pa.compile(y);if(!Pa.decompile(g))throw new Error("Failed to decompile script??");return g}}],[{key:"getPubKeyAsBuffer",value:function(t,e){var r,n=of.alloc(0),i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=uf(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(!Ec.fromPublicKey(o,e).compressed)throw new Error("Public key must be compressed");if(33!==o.byteLength)throw new Error("Public key must be 33 bytes, got ".concat(o.byteLength," bytes."));n=of.concat([n,o])}}catch(t){i.e(t)}finally{i.f()}var a=p.compress(n);return a.byteLength>=n.byteLength?n:a}}])}(),gf=i(8287).Buffer;function bf(t){return bf="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},bf(t)}function vf(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function wf(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,mf(n.key),n)}}function mf(t){var e=function(t){if("object"!=bf(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=bf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==bf(e)?e:e+""}var _f=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&wf(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"compile",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;if(r<2)throw new Error("Minimum signatures must be greater than 1");if(e.length<r)throw new Error("The amount of public keys is lower than the minimum required");if(r>t.MAXIMUM_SUPPORTED_SIGNATURE)throw new Error("The maximum amount of signatures is ".concat(t.MAXIMUM_SUPPORTED_SIGNATURE));var i=gf.alloc(1);i.writeUInt8(r),e=(e=e.filter((function(t,e,r){return e===r.findIndex((function(e){return t.equals(e)}))}))).sort((function(t,e){return t.compare(e)}));var o=!1,a=e.map((function(t){var e=Ba(t);return n&&!o&&(o=n.equals(e)),e}));n&&!o&&a.push(n);var s=[Ta.OP_0].concat(function(t){return function(t){if(Array.isArray(t))return vf(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return vf(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vf(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(a.flatMap((function(t){return[t,Ta.OP_CHECKSIGADD]}))),[i,Ta.OP_NUMEQUAL]).flat(),u=Pa.compile(s);if(!Pa.decompile(u))throw new Error("Failed to decompile script.");return u}}])}();!function(t,e){(e=mf(e))in t?Object.defineProperty(t,e,{value:255,enumerable:!0,configurable:!0,writable:!0}):t[e]=255}(_f,"MAXIMUM_SUPPORTED_SIGNATURE");var Ef=i(2343);function Sf(t){return Sf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Sf(t)}function kf(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,Tf(n.key),n)}}function Tf(t){var e=function(t){if("object"!=Sf(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Sf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Sf(e)?e:e+""}ga(ja);var Of,xf=function(){return function(t,e,r){return r&&kf(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"generatePKSH",value:function(t,e){if(32!==t.length)throw new Error("Invalid hash length");var r=Aa(t);return this.toSegwitAddress(r,e)}},{key:"generateTaprootAddress",value:function(t,e){if(32!==t.length)throw new Error("Invalid public key length");var r=Ef.p2.toWords(t);return r.unshift(1),Ef.p2.encode(e.bech32,r)}},{key:"toSegwitAddress",value:function(t,e){var r=Ef.I.toWords(t);return r.unshift(0),Ef.I.encode(e.bech32,r)}}])}(),Af=i(8287).Buffer;function Pf(t){return Pf="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},Pf(t)}function If(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,Lf(n.key),n)}}function Lf(t){var e=function(t){if("object"!=Pf(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Pf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Pf(e)?e:e+""}ga(ja),function(t){t.P2PKH="P2PKH",t.P2SH_OR_P2SH_P2WPKH="P2SH_OR_P2SH-P2WPKH",t.P2PK="P2PK",t.P2TR="P2TR",t.P2WPKH="P2WPKH"}(Of||(Of={}));var Bf=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&If(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"isValidP2TRAddress",value:function(t,e){if(!t||t.length<50)return!1;var r=!1;try{ha.toOutputScript(t,e),r=1===ha.fromBech32(t).version}catch(t){}return r}},{key:"isP2WPKHAddress",value:function(t,e){if(!t||t.length<20||t.length>50)return!1;var r=!1;try{var n=ha.fromBech32(t);ha.toOutputScript(t,e),r=0===n.version&&20===n.data.length}catch(t){}return r}},{key:"isP2PKHOrP2SH",value:function(t,e){try{var r=ha.fromBase58Check(t);return r.version===e.pubKeyHash||r.version===e.scriptHash}catch(t){return!1}}},{key:"isValidPublicKey",value:function(t,e){try{if(t.startsWith("0x")&&(t=t.slice(2)),!/^[0-9a-fA-F]+$/.test(t))return!1;if(64===t.length)return!0;var r=Af.from(t,"hex");if(130===t.length&&6===r[0]||7===r[0])return!0;if(66===t.length||130===t.length)return Ec.fromPublicKey(r,e),!0}catch(t){return!1}return!1}},{key:"requireRedeemScript",value:function(t,e){try{var r=ha.fromBase58Check(t);return r.version!==e.pubKeyHash&&r.version===e.scriptHash}catch(t){return!1}}},{key:"detectAddressType",value:function(e,r){if(t.isValidPublicKey(e,r))return Of.P2PK;try{var n=ha.fromBase58Check(e);if(n.version===r.pubKeyHash)return Of.P2PKH;if(n.version===r.scriptHash)return Of.P2SH_OR_P2SH_P2WPKH}catch(t){}try{var i=ha.fromBech32(e);if(i.prefix===r.bech32){if(0===i.version&&20===i.data.length)return Of.P2WPKH;if(1===i.version&&32===i.data.length)return Of.P2TR}}catch(t){}return null}}])}(),Rf={d:(t,e)=>{for(var r in e)Rf.o(e,r)&&!Rf.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},Nf={};Rf.d(Nf,{q$:()=>Ul,Vy:()=>Cl,$7:()=>jf,rE:()=>Uf});var jf={};Rf.r(jf),Rf.d(jf,{DebugLevel:()=>Ul,Logger:()=>Cl,version:()=>Uf});var Uf="1.0.2";function Cf(t,e){t=t.replace("#","");var r=parseInt(t,16),n=Math.round(2.55*e),i=(r>>16)+n,o=(r>>8&255)+n,a=(255&r)+n;return(16777216+65536*(i<255?i<1?0:i:255)+256*(o<255?o<1?0:o:255)+(a<255?a<1?0:a:255)).toString(16).slice(1)}const Ff=(t=0)=>e=>`[${e+t}m`,Mf=(t=0)=>e=>`[${38+t};5;${e}m`,Df=(t=0)=>(e,r,n)=>`[${38+t};2;${e};${r};${n}m`,Hf={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(Hf.modifier),Object.keys(Hf.color),Object.keys(Hf.bgColor);const Kf=function(){const t=new Map;for(const[e,r]of Object.entries(Hf)){for(const[e,n]of Object.entries(r))Hf[e]={open:`[${n[0]}m`,close:`[${n[1]}m`},r[e]=Hf[e],t.set(n[0],n[1]);Object.defineProperty(Hf,e,{value:r,enumerable:!1})}return Object.defineProperty(Hf,"codes",{value:t,enumerable:!1}),Hf.color.close="",Hf.bgColor.close="",Hf.color.ansi=Ff(),Hf.color.ansi256=Mf(),Hf.color.ansi16m=Df(),Hf.bgColor.ansi=Ff(10),Hf.bgColor.ansi256=Mf(10),Hf.bgColor.ansi16m=Df(10),Object.defineProperties(Hf,{rgbToAnsi256:{value:(t,e,r)=>t===e&&e===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(e/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(t){const e=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!e)return[0,0,0];let[r]=e;3===r.length&&(r=[...r].map((t=>t+t)).join(""));const n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:t=>Hf.rgbToAnsi256(...Hf.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return t-8+90;let e,r,n;if(t>=232)e=(10*(t-232)+8)/255,r=e,n=e;else{const i=(t-=16)%36;e=Math.floor(t/36)/5,r=Math.floor(i/6)/5,n=i%6/5}const i=2*Math.max(e,r,n);if(0===i)return 30;let o=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(e));return 2===i&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(t,e,r)=>Hf.ansi256ToAnsi(Hf.rgbToAnsi256(t,e,r)),enumerable:!1},hexToAnsi:{value:t=>Hf.ansi256ToAnsi(Hf.hexToAnsi256(t)),enumerable:!1}}),Hf}(),Gf=(()=>{if(navigator.userAgentData){const t=navigator.userAgentData.brands.find((({brand:t})=>"Chromium"===t));if(t&&t.version>93)return 3}return/\b(Chrome|Chromium)\//.test(navigator.userAgent)?1:0})(),Wf=0!==Gf&&{level:Gf,hasBasic:!0,has256:Gf>=2,has16m:Gf>=3},Vf={stdout:Wf,stderr:Wf};function qf(t,e,r){let n=t.indexOf(e);if(-1===n)return t;const i=e.length;let o=0,a="";do{a+=t.slice(o,n)+e+r,o=n+i,n=t.indexOf(e,o)}while(-1!==n);return a+=t.slice(o),a}const{stdout:zf,stderr:Yf}=Vf,Xf=Symbol("GENERATOR"),Zf=Symbol("STYLER"),$f=Symbol("IS_EMPTY"),Jf=["ansi","ansi","ansi256","ansi16m"],Qf=Object.create(null);class tl{constructor(t){return el(t)}}const el=t=>{const e=(...t)=>t.join(" ");return((t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=zf?zf.level:0;t.level=void 0===e.level?r:e.level})(e,t),Object.setPrototypeOf(e,rl.prototype),e};function rl(t){return el(t)}Object.setPrototypeOf(rl.prototype,Function.prototype);for(const[t,e]of Object.entries(Kf))Qf[t]={get(){const r=sl(this,al(e.open,e.close,this[Zf]),this[$f]);return Object.defineProperty(this,t,{value:r}),r}};Qf.visible={get(){const t=sl(this,this[Zf],!0);return Object.defineProperty(this,"visible",{value:t}),t}};const nl=(t,e,r,...n)=>"rgb"===t?"ansi16m"===e?Kf[r].ansi16m(...n):"ansi256"===e?Kf[r].ansi256(Kf.rgbToAnsi256(...n)):Kf[r].ansi(Kf.rgbToAnsi(...n)):"hex"===t?nl("rgb",e,r,...Kf.hexToRgb(...n)):Kf[r][t](...n),il=["rgb","hex","ansi256"];for(const t of il)Qf[t]={get(){const{level:e}=this;return function(...r){const n=al(nl(t,Jf[e],"color",...r),Kf.color.close,this[Zf]);return sl(this,n,this[$f])}}},Qf["bg"+t[0].toUpperCase()+t.slice(1)]={get(){const{level:e}=this;return function(...r){const n=al(nl(t,Jf[e],"bgColor",...r),Kf.bgColor.close,this[Zf]);return sl(this,n,this[$f])}}};const ol=Object.defineProperties((()=>{}),{...Qf,level:{enumerable:!0,get(){return this[Xf].level},set(t){this[Xf].level=t}}}),al=(t,e,r)=>{let n,i;return void 0===r?(n=t,i=e):(n=r.openAll+t,i=e+r.closeAll),{open:t,close:e,openAll:n,closeAll:i,parent:r}},sl=(t,e,r)=>{const n=(...t)=>ul(n,1===t.length?""+t[0]:t.join(" "));return Object.setPrototypeOf(n,ol),n[Xf]=t,n[Zf]=e,n[$f]=r,n},ul=(t,e)=>{if(t.level<=0||!e)return t[$f]?"":e;let r=t[Zf];if(void 0===r)return e;const{openAll:n,closeAll:i}=r;if(e.includes(""))for(;void 0!==r;)e=qf(e,r.close,r.open),r=r.parent;const o=e.indexOf("\n");return-1!==o&&(e=function(t,e,r,n){let i=0,o="";do{const a="\r"===t[n-1];o+=t.slice(i,a?n-1:n)+e+(a?"\r\n":"\n")+r,i=n+1,n=t.indexOf("\n",i)}while(-1!==n);return o+=t.slice(i),o}(e,i,n,o)),n+e+i};function cl(t){return cl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},cl(t)}function fl(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}function ll(t,e,r){return(e=hl(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function hl(t){var e=function(t){if("object"!=cl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=cl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==cl(e)?e:e+""}function pl(t,e){return t.get(function(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}(t,e))}Object.defineProperties(rl.prototype,Qf),rl(),rl({level:Yf?Yf.level:0});var dl=new WeakMap,yl=new WeakMap,gl=new WeakMap,bl=new WeakMap,vl=new WeakMap,wl=new WeakMap,ml=new WeakMap,_l=new WeakMap,El=new WeakMap,Sl=new WeakMap,kl=new WeakMap,Tl=new WeakMap,Ol=new WeakMap,xl=new WeakMap,Al=new WeakMap,Pl=new WeakMap,Il=new WeakMap,Ll=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new tl;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ll(this,"moduleName",""),ll(this,"logColor","#00bfff"),ll(this,"enableLogs",!0),ll(this,"hideLogs",!1),fl(this,dl,"#ff00ff"),fl(this,yl,Cf(pl(dl,this),75)),fl(this,gl,"#9400d3"),fl(this,bl,Cf(pl(gl,this),15)),fl(this,vl,Cf(pl(bl,this),15)),fl(this,wl,"#7cfc00"),fl(this,ml,Cf(pl(wl,this),15)),fl(this,_l,"#ffdead"),fl(this,El,Cf(pl(_l,this),15)),fl(this,Sl,"#ff8c00"),fl(this,kl,Cf(pl(Sl,this),15)),fl(this,Tl,"#ff4500"),fl(this,Ol,Cf(pl(Tl,this),15)),fl(this,xl,"#ffffff"),fl(this,Al,Cf(pl(xl,this),15)),fl(this,Pl,"#8b0000"),fl(this,Il,Cf(pl(Pl,this),15)),ll(this,"prefix",""),this.chalk=e,this.moduleName=this.constructor.name},e=[{key:"setLogPrefix",value:function(t){this.prefix=t}},{key:"getStartPrefix",value:function(){return this.prefix}},{key:"disable",value:function(){this.enableLogs=!1}},{key:"enable",value:function(){this.enableLogs=!0}},{key:"fancyLog",value:function(t,e,r,n,i){this.enableLogs&&console.log(this.chalk.hex(pl(dl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," INFO]: "))+this.chalk.hex(pl(xl,this))(t)+" "+this.chalk.hex(pl(kl,this))(e)+" "+this.chalk.hex(pl(xl,this))(r)+" "+this.chalk.hex(pl(vl,this))(n)+" "+this.chalk.hex(pl(xl,this))(i))}},{key:"log",value:function(){if(this.enableLogs&&!this.hideLogs){var t=Cf(this.logColor,15);console.log(this.chalk.hex(this.logColor)("".concat(this.getStartPrefix(),"[").concat(this.moduleName," LOG]: "))+this.chalk.hex(t).apply(void 0,arguments))}}},{key:"lightOrangeLog",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(pl(kl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," LOG]: "))+this.chalk.hex(pl(xl,this)).apply(void 0,arguments)))}},{key:"error",value:function(){this.enableLogs&&console.log(this.chalk.hex(pl(Tl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," ERROR]: "))+this.chalk.hex(pl(Ol,this)).apply(void 0,arguments))}},{key:"warn",value:function(){this.enableLogs&&console.log(this.chalk.hex(pl(Sl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," WARN]: "))+this.chalk.hex(pl(kl,this)).apply(void 0,arguments))}},{key:"debug",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(pl(_l,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," DEBUG]: "))+this.chalk.hex(pl(El,this)).apply(void 0,arguments)))}},{key:"success",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(pl(wl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," SUCCESS]: "))+this.chalk.hex(pl(ml,this)).apply(void 0,arguments)))}},{key:"fail",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(pl(Tl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," FAIL]: "))+this.chalk.hex(pl(Ol,this)).apply(void 0,arguments)))}},{key:"debugBright",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(pl(gl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," DEBUG]: "))+this.chalk.hex(pl(bl,this)).apply(void 0,arguments)))}},{key:"important",value:function(){this.enableLogs&&console.log(this.chalk.hex(pl(dl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," IMPORTANT]: "))+this.chalk.hex(pl(yl,this)).apply(void 0,arguments))}},{key:"panic",value:function(){this.enableLogs&&console.log(this.chalk.hex(pl(Pl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," HELP PANIC]: "))+this.chalk.hex(pl(Il,this)).apply(void 0,arguments))}},{key:"info",value:function(){this.enableLogs&&console.log(this.chalk.hex(pl(dl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," INFO]: "))+this.chalk.hex(pl(xl,this)).apply(void 0,arguments))}},{key:"securityNotice",value:function(){this.enableLogs&&console.log(this.chalk.hex("#22d8e6")("".concat(this.getStartPrefix(),"[").concat(this.moduleName," SECURITY NOTICE]: "))+this.chalk.hex("#22e3e6").apply(void 0,arguments))}},{key:"traceLog",value:function(){this.enableLogs&&console.log(this.chalk.hex("#ffffff")("".concat(this.getStartPrefix(),"[").concat(this.moduleName," TRACE LOG]: "))+this.chalk.hex(pl(Al,this)).apply(void 0,arguments))}}],e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,hl(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Bl(t){return Bl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bl(t)}function Rl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Rl=function(){return!!t})()}function Nl(t){return Nl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Nl(t)}function jl(t,e){return jl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},jl(t,e)}var Ul,Cl=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){return e=Nl(e),function(t,e){if(e&&("object"==Bl(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,Rl()?Reflect.construct(e,[],Nl(t).constructor):e.apply(t,void 0))}(this,t)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&jl(t,e)}(t,Ll),e=t,Object.defineProperty(e,"prototype",{writable:!1}),e;var e}();!function(t){t[t.NONE=0]="NONE",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.DEBUG=4]="DEBUG",t[t.TRACE=5]="TRACE",t[t.ALL=6]="ALL"}(Ul||(Ul={}));var Fl=Nf.Vy,Ml=i(8287).Buffer;function Dl(t){return Dl="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},Dl(t)}function Hl(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,Kl(n.key),n)}}function Kl(t){var e=function(t){if("object"!=Dl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Dl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Dl(e)?e:e+""}ga(ja);var Gl=function(){return function(t,e,r){return r&&Hl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"tweakSigner",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.privateKey;if(!r)throw new Error("Private key is required for tweaking signer!");3===t.publicKey[0]&&(r=Na.privateNegate(r));var n=Na.privateAdd(r,La(Ba(Ml.from(t.publicKey)),e.tweakHash));if(!n)throw new Error("Invalid tweaked private key!");return Ec.fromPrivateKey(Ml.from(n),e.network)}}])}();function Wl(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&_a(t.witnessUtxo.script))}function Vl(t,e){if(t.nonWitnessUtxo&&!t.redeemScript&&!t.witnessScript&&!t.witnessUtxo||t.redeemScript)return!0;var r=function(t){return t.redeemScript?t.redeemScript:t.witnessScript?t.witnessScript:t.witnessUtxo?t.witnessUtxo.script:(t.nonWitnessUtxo,null)}(t);return!!r&&ql(e,r)}function ql(t,e){return-1!==xa(t,e)}var zl,Yl=i(8287).Buffer;function Xl(t){return Xl="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},Xl(t)}function Zl(){Zl=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Xl(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Xl(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function $l(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Jl(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){$l(o,n,i,a,s,"next",t)}function s(t){$l(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Ql(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=eh(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function th(t){return function(t){if(Array.isArray(t))return rh(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||eh(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eh(t,e){if(t){if("string"==typeof t)return rh(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?rh(t,e):void 0}}function rh(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function nh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,uh(n.key),n)}}function ih(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ih=function(){return!!t})()}function oh(t){return oh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},oh(t)}function ah(t,e){return ah=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ah(t,e)}function sh(t,e,r){return(e=uh(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function uh(t){var e=function(t){if("object"!=Xl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Xl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xl(e)?e:e+""}!function(t){t[t.REPLACE_BY_FEE=4294967293]="REPLACE_BY_FEE",t[t.FINAL=4294967295]="FINAL"}(zl||(zl={}));var ch=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),sh(r=function(t,e,r){return e=oh(e),function(t,e){if(e&&("object"==Xl(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,ih()?Reflect.construct(e,r||[],oh(t).constructor):e.apply(t,r))}(this,t),"logColor","#00ffe1"),sh(r,"finalized",!1),sh(r,"signed",!1),sh(r,"scriptData",null),sh(r,"tapData",null),sh(r,"inputs",[]),sh(r,"sequence",zl.REPLACE_BY_FEE),sh(r,"tapLeafScript",null),sh(r,"isBrowser",!1),sh(r,"regenerated",!1),sh(r,"ignoreSignatureErrors",!1),sh(r,"customFinalizerP2SH",(function(t,e,n,i,o,a){var s=r.inputs[t];if(o&&e.partialSig&&s&&s.redeemScript){var u=e.partialSig.map((function(t){return t.signature}));return{finalScriptSig:Pa.compile([].concat(th(u),[s.redeemScript])),finalScriptWitness:void 0}}return ya(t,e,n,i,o,a)})),r.signer=e.signer,r.network=e.network,r.nonWitnessUtxo=e.nonWitnessUtxo,r.isBrowser="undefined"!=typeof window,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&&ah(t,e)}(t,Fl),function(t,e,r){return e&&nh(t.prototype,e),r&&nh(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"ignoreSignatureError",value:function(){this.ignoreSignatureErrors=!0}},{key:"getScriptAddress",value:function(){if(!this.scriptData||!this.scriptData.address)throw new Error("Tap data is required");return this.scriptData.address}},{key:"getTransaction",value:function(){return this.transaction.extractTransaction(!1)}},{key:"getTapAddress",value:function(){if(!this.tapData||!this.tapData.address)throw new Error("Tap data is required");return this.tapData.address}},{key:"disableRBF",value:function(){if(this.signed)throw new Error("Transaction is already signed");this.sequence=zl.FINAL;var t,e=Ql(this.inputs);try{for(e.s();!(t=e.n()).done;)t.value.sequence=zl.FINAL}catch(t){e.e(t)}finally{e.f()}}},{key:"getTweakerHash",value:function(){var t;return null===(t=this.tapData)||void 0===t?void 0:t.hash}},{key:"preEstimateTransactionFees",value:function(t,e,r,n,i){var o=10n+41n*e+68n*r;return(3n*o+(o+(144n*n+34n*i+(1n+35n*i+1n+n))))/4n*t}},{key:"generateTapData",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network}}},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network}}},{key:"getSignerKey",value:function(){return this.signer}},{key:"signInput",value:(a=Jl(Zl().mark((function t(e,r,n,i){var o,a,s,u,c,f,l=arguments;return Zl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=l.length>4&&void 0!==l[4]&&l[4],a=l.length>5&&void 0!==l[5]&&l[5],s=i.publicKey,u=Wl(r),o&&(u=!u),c=!1,f=!1,!u){t.next=20;break}return t.prev=8,t.next=11,this.attemptSignTaproot(e,r,n,i,s);case 11:c=!0,t.next=18;break;case 14:t.prev=14,t.t0=t.catch(8),this.error("Failed to sign Taproot script path input ".concat(n," (reverse: ").concat(o,"): ").concat(t.t0.message)),f=!0;case 18:t.next=31;break;case 20:if(!o&&!Vl(r,s)){t.next=31;break}return t.prev=21,t.next=24,this.signNonTaprootInput(i,e,n);case 24:c=!0,t.next=31;break;case 27:t.prev=27,t.t1=t.catch(21),this.error("Failed to sign non-Taproot input ".concat(n,": ").concat(t.t1.stack)),f=!0;case 31:if(c){t.next=42;break}if(!f||!a){t.next=34;break}throw new Error("Failed to sign input ".concat(n," with the provided signer."));case 34:return t.prev=34,t.next=37,this.signInput(e,r,n,i,!0,f);case 37:t.next=42;break;case 39:throw t.prev=39,t.t2=t.catch(34),new Error("Cannot sign input ".concat(n," with the provided signer."));case 42:case"end":return t.stop()}}),t,this,[[8,14],[21,27],[34,39]])}))),function(t,e,r,n){return a.apply(this,arguments)})},{key:"splitArray",value:function(t,e){if(e<=0)throw new Error("Chunk size must be greater than 0.");for(var r=[],n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r}},{key:"signInputs",value:(o=Jl(Zl().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h;return Zl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!("multiSignPsbt"in this.signer)){t.next=4;break}return t.next=3,this.signInputsWalletBased(e);case 3:return t.abrupt("return");case 4:r=e.data.inputs,n=20,i=this.splitArray(r,n),o=0;case 8:if(!(o<i.length)){t.next=18;break}for(a=i[o],s=[],u=o*n,c=0;c<a.length;c++){f=u+c,l=a[c];try{s.push(this.signInput(e,l,f,this.signer))}catch(t){this.log("Failed to sign input ".concat(f,": ").concat(t.stack))}}return t.next=15,Promise.all(s);case 15:o++,t.next=8;break;case 18:for(h=0;h<e.data.inputs.length;h++)e.finalizeInput(h,this.customFinalizerP2SH);this.finalized=!0;case 20:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"internalPubKeyToXOnly",value:function(){return Ba(Yl.from(this.signer.publicKey))}},{key:"internalInit",value:function(){this.scriptData=Oa.p2tr(this.generateScriptAddress()),this.tapData=Oa.p2tr(this.generateTapData())}},{key:"tweakSigner",value:function(){this.tweakedSigner||(this.tweakedSigner=this.getTweakedSigner(!0))}},{key:"getTweakedSigner",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.signer,r={network:this.network};if(t&&(r.tweakHash=this.getTweakerHash()),"privateKey"in e)return Gl.tweakSigner(e,r)}},{key:"generateP2SHRedeemScript",value:function(t){var e=Oa.p2wsh({redeem:{output:t},network:this.network});return Oa.p2sh({redeem:e,network:this.network}).output}},{key:"generateP2SHRedeemScriptLegacy",value:function(t){var e=pa.hash160(this.signer.publicKey),r=Pa.compile([Ta.OP_DUP,Ta.OP_HASH160,e,Ta.OP_EQUALVERIFY,Ta.OP_CHECKSIG]),n=pa.hash160(r),i=Pa.compile([Ta.OP_HASH160,n,Ta.OP_EQUAL]),o=Oa.p2wsh({redeem:{output:r},network:this.network}),a=Oa.p2sh({redeem:o,network:this.network});if(ha.fromOutputScript(i,this.network)===t&&a.redeem&&a.redeem.output)return{redeemScript:r,outputScript:a.redeem.output}}},{key:"generateP2SHP2PKHRedeemScript",value:function(t){var e,r=Yl.isBuffer(this.signer.publicKey)?this.signer.publicKey:Yl.from(this.signer.publicKey,"hex"),n=Oa.p2wpkh({pubkey:r,network:this.network}),i=Oa.p2sh({redeem:n,network:this.network}),o=i.address;if(!(null===(e=i.redeem)||void 0===e?void 0:e.output))throw new Error("Failed to generate P2SH-P2WPKH redeem script");if(o===t&&i.redeem&&i.redeem.output&&i.output)return{redeemScript:i.redeem.output,outputScript:i.output}}},{key:"generatePsbtInputExtended",value:function(e,r){var n=Yl.from(e.scriptPubKey.hex,"hex"),i={hash:e.transactionId,index:e.outputIndex,sequence:this.sequence,witnessUtxo:{value:Number(e.value),script:n}};if(wa(n)){if(!e.nonWitnessUtxo)throw new Error("Missing nonWitnessUtxo for P2PKH UTXO");i.nonWitnessUtxo=Yl.isBuffer(e.nonWitnessUtxo)?e.nonWitnessUtxo:Yl.from(e.nonWitnessUtxo,"hex")}else if(Ea(n));else if(Sa(n)){if(!e.witnessScript)throw new Error("Missing witnessScript for P2WSH UTXO");i.witnessScript=Yl.isBuffer(e.witnessScript)?e.witnessScript:Yl.from(e.witnessScript,"hex")}else if(ma(n)){var o;if(e.redeemScript)o=Yl.isBuffer(e.redeemScript)?e.redeemScript:Yl.from(e.redeemScript,"hex");else{if(!e.scriptPubKey.address)throw new Error("Missing redeemScript and no address to regenerate it for P2SH UTXO");var a=this.generateP2SHP2PKHRedeemScript(e.scriptPubKey.address);if(!a)throw new Error("Missing redeemScript for P2SH UTXO and unable to regenerate");o=a.redeemScript}i.redeemScript=o;var s=Oa.p2sh({redeem:{output:i.redeemScript}});if(!s.redeem)throw new Error("Failed to extract redeem script from P2SH UTXO");var u=s.redeem.output;if(!u)throw new Error("Failed to extract redeem output from P2SH UTXO");if(e.nonWitnessUtxo&&(i.nonWitnessUtxo=Yl.isBuffer(e.nonWitnessUtxo)?e.nonWitnessUtxo:Yl.from(e.nonWitnessUtxo,"hex")),Ea(u))delete i.nonWitnessUtxo;else if(Sa(u)){if(delete i.nonWitnessUtxo,!i.witnessScript)throw new Error("Missing witnessScript for P2SH-P2WSH UTXO")}else delete i.witnessUtxo}else if(_a(n)){if(this.sighashTypes){var c=t.calculateSignHash(this.sighashTypes);c&&(i.sighashType=c)}this.tweakSigner(),i.tapInternalKey=this.internalPubKeyToXOnly()}else if(va(n)||ba(n)){if(!e.nonWitnessUtxo)throw new Error("Missing nonWitnessUtxo for P2PK or P2MS UTXO");i.nonWitnessUtxo=Yl.isBuffer(e.nonWitnessUtxo)?e.nonWitnessUtxo:Yl.from(e.nonWitnessUtxo,"hex")}else this.error("Unknown or unsupported script type for output: ".concat(e.scriptPubKey.hex));return this.tapLeafScript&&(i.tapLeafScript=[this.tapLeafScript]),0===r&&this.nonWitnessUtxo&&(i.nonWitnessUtxo=this.nonWitnessUtxo),i}},{key:"signInputsWalletBased",value:(i=Jl(Zl().mark((function t(e){var r,n;return Zl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.signer,t.next=3,r.multiSignPsbt([e]);case 3:for(n=0;n<e.data.inputs.length;n++)e.finalizeInput(n,this.customFinalizerP2SH);this.finalized=!0;case 5:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"attemptSignTaproot",value:(n=Jl(Zl().mark((function t(e,r,n,i,o){var a;return Zl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isTaprootScriptSpend(r,o)){t.next=6;break}return t.next=4,this.signTaprootInput(i,e,n);case 4:t.next=13;break;case 6:if(i!==this.signer?a=this.getTweakedSigner(!0,i):(this.tweakedSigner||this.tweakSigner(),a=this.tweakedSigner),!a){t.next=12;break}return t.next=10,this.signTaprootInput(a,e,n);case 10:t.next=13;break;case 12:this.error("Failed to obtain tweaked signer for input ".concat(n,"."));case 13:case"end":return t.stop()}}),t,this)}))),function(t,e,r,i,o){return n.apply(this,arguments)})},{key:"isTaprootScriptSpend",value:function(t,e){if(t.tapLeafScript&&t.tapLeafScript.length>0){var r,n=Ql(t.tapLeafScript);try{for(n.s();!(r=n.n()).done;)if(ql(e,r.value.script))return!0}catch(t){n.e(t)}finally{n.f()}}return!1}},{key:"signTaprootInput",value:(r=Jl(Zl().mark((function t(e,r,n,i){return Zl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!("signTaprootInput"in e)){t.next=11;break}return t.prev=1,t.next=4,e.signTaprootInput(r,n,i);case 4:t.next=9;break;case 6:throw t.prev=6,t.t0=t.catch(1),new Error("Failed to sign Taproot input with provided signer.");case 9:t.next=12;break;case 11:r.signTaprootInput(n,e);case 12:case"end":return t.stop()}}),t,null,[[1,6]])}))),function(t,e,n,i){return r.apply(this,arguments)})},{key:"signNonTaprootInput",value:(e=Jl(Zl().mark((function t(e,r,n){return Zl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!("signInput"in e)){t.next=5;break}return t.next=3,e.signInput(r,n);case 3:t.next=6;break;case 5:r.signInput(n,e);case 6:case"end":return t.stop()}}),t)}))),function(t,r,n){return e.apply(this,arguments)})}],[{key:"readScriptWitnessToWitnessStack",value:function(t){var e=0;function r(){var r=Ra.decode(t,e);return e+=Ra.decode.bytes,r}return function(){for(var n=r(),i=[],o=0;o<n;o++)i.push(function(r){var n=t.subarray(e,e+r);return e+=r,n}(r()));return i}()}},{key:"preEstimateTaprootTransactionFees",value:function(t,e,r,n,i,o){var a=10n+41n*e+68n*r;return(3n*a+(a+(1n*e+n*i+(arguments.length>6&&void 0!==arguments[6]?arguments[6]:32n)*e+(arguments.length>7&&void 0!==arguments[7]?arguments[7]:139n)*e+o)))/4n*t}},{key:"signInput",value:function(t,e,r,n,i){i&&i[0]&&(e.sighashType=i[0]),t.signInput(r,n,i.length?i:void 0)}},{key:"calculateSignHash",value:function(t){if(!t)throw new Error("Sighash types are required");var e,r=0,n=Ql(t);try{for(n.s();!(e=n.n()).done;)r|=e.value}catch(t){n.e(t)}finally{n.f()}return r||0}}]);var e,r,n,i,o,a}(),fh=i(8287).Buffer;function lh(t){return lh="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},lh(t)}function hh(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ph(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function ph(t,e){if(t){if("string"==typeof t)return dh(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?dh(t,e):void 0}}function dh(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function yh(){yh=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==lh(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(lh(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function gh(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function bh(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){gh(o,n,i,a,s,"next",t)}function s(t){gh(o,n,i,a,s,"throw",t)}a(void 0)}))}}function vh(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,kh(n.key),n)}}function wh(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(wh=function(){return!!t})()}function mh(){return mh="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=_h(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},mh.apply(null,arguments)}function _h(t){return _h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_h(t)}function Eh(t,e){return Eh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Eh(t,e)}function Sh(t,e,r){return(e=kh(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function kh(t){var e=function(t){if("object"!=lh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=lh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==lh(e)?e:e+""}ga(ja);var Th=function(){function t(e){var r,n;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Sh(n=function(t,e,r){return e=_h(e),function(t,e){if(e&&("object"==lh(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,wh()?Reflect.construct(e,r||[],_h(t).constructor):e.apply(t,r))}(this,t,[e]),"logColor","#785def"),Sh(n,"overflowFees",0n),Sh(n,"transactionFee",0n),Sh(n,"estimatedFees",0n),Sh(n,"updateInputs",[]),Sh(n,"outputs",[]),Sh(n,"feeOutput",null),Sh(n,"_maximumFeeRate",1e8),e.estimatedFees&&(n.estimatedFees=e.estimatedFees),n.signer=e.signer,n.network=e.network,n.feeRate=e.feeRate,n.priorityFee=null!==(r=e.priorityFee)&&void 0!==r?r:0n,n.utxos=e.utxos,n.to=e.to||void 0,n.isPubKeyDestination=!!n.to&&Bf.isValidPublicKey(n.to,n.network),n.optionalOutputs=e.optionalOutputs,n.from=t.getFrom(e.from,n.signer,n.network),n.totalInputAmount=n.calculateTotalUTXOAmount(),n.calculateTotalVOutAmount()<n.totalInputAmount)throw new Error("Vout value is less than the value to send");return n.transaction=new fa({network:n.network}),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Eh(t,e)}(t,ch),function(t,e,r){return e&&vh(t.prototype,e),r&&vh(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"getFundingTransactionParameters",value:(c=bh(yh().mark((function t(){var e;return yh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.estimatedFees){t.next=4;break}return t.next=3,this.estimateTransactionFees();case 3:this.estimatedFees=t.sent;case 4:return t.abrupt("return",{utxos:this.utxos,to:this.getScriptAddress(),signer:this.signer,network:this.network,feeRate:this.feeRate,priorityFee:null!==(e=this.priorityFee)&&void 0!==e?e:0n,from:this.from,amount:this.estimatedFees,optionalOutputs:this.optionalOutputs});case 5:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"setDestinationAddress",value:function(t){this.to=t}},{key:"setMaximumFeeRate",value:function(t){this._maximumFeeRate=t}},{key:"signTransaction",value:(u=bh(yh().mark((function t(){return yh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.utxos.length){t.next=2;break}throw new Error("No UTXOs specified");case 2:if(!this.to||this.isPubKeyDestination||Ec.verifyContractAddress(this.to,this.network)){t.next=4;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 4:if(!this.signed){t.next=6;break}throw new Error("Transaction is already signed");case 6:return this.signed=!0,t.next=9,this.buildTransaction();case 9:return t.next=11,this.internalBuildTransaction(this.transaction);case 11:if(!t.sent){t.next=16;break}if(!this.regenerated){t.next=15;break}throw new Error("Transaction was regenerated");case 15:return t.abrupt("return",this.transaction.extractTransaction(!0,!0));case 16:throw new Error("Could not sign transaction");case 17:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"generateTransactionMinimalSignatures",value:(s=bh(yh().mark((function t(){var e,r,n,i,o=arguments;return yh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=o.length>0&&void 0!==o[0]&&o[0],!this.to||this.isPubKeyDestination||Ec.verifyContractAddress(this.to,this.network)){t.next=3;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 3:return t.next=5,this.buildTransaction();case 5:if(0===this.transaction.data.inputs.length){for(r=this.getInputs(),n=this.getOutputs(),this.transaction.setMaximumFeeRate(this._maximumFeeRate),this.transaction.addInputs(r,e),i=0;i<this.updateInputs.length;i++)this.transaction.updateInput(i,this.updateInputs[i]);this.transaction.addOutputs(n)}case 6:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"signPSBT",value:(a=bh(yh().mark((function t(){return yh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signTransaction();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.transaction);case 4:throw new Error("Could not sign transaction");case 5:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"addInput",value:function(t){this.inputs.push(t)}},{key:"addOutput",value:function(e){if(0!==e.value){if(e.value<t.MINIMUM_DUST)throw new Error("Output value is less than the minimum dust ".concat(e.value," < ").concat(t.MINIMUM_DUST));this.outputs.push(e)}}},{key:"toAddress",value:function(){return this.to}},{key:"address",value:function(){var t;return null===(t=this.tapData)||void 0===t?void 0:t.address}},{key:"estimateTransactionFees",value:(o=bh(yh().mark((function t(){var e,r,n,i;return yh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.utxos.length){t.next=2;break}throw new Error("No UTXOs specified");case 2:if(!this.estimatedFees){t.next=4;break}return t.abrupt("return",this.estimatedFees);case 4:return e=new fa({network:this.network}),t.next=7,this.internalBuildTransaction(e);case 7:if(!t.sent){t.next=16;break}return r=e.extractTransaction(!0,!0),n=r.virtualSize(),i=this.feeRate*n,this.estimatedFees=BigInt(Math.ceil(i)+1),t.abrupt("return",this.estimatedFees);case 16:throw new Error("Could not build transaction to estimate fee. Something went wrong while building the transaction.");case 17:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"rebuildFromBase64",value:(i=bh(yh().mark((function t(e){return yh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.transaction=fa.fromBase64(e,{network:this.network}),this.signed=!1,this.sighashTypes=[la.SIGHASH_ANYONECANPAY,la.SIGHASH_ALL],t.next=5,this.signPSBT();case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"setPSBT",value:function(t){this.transaction=t}},{key:"getInputs",value:function(){return this.inputs}},{key:"getOutputs",value:function(){var t=function(t){return function(t){if(Array.isArray(t))return dh(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ph(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this.outputs);return this.feeOutput&&t.push(this.feeOutput),t}},{key:"getOptionalOutputValue",value:function(){if(!this.optionalOutputs)return 0n;for(var t=0n,e=0;e<this.optionalOutputs.length;e++)t+=BigInt(this.optionalOutputs[e].value);return t}},{key:"addRefundOutput",value:(n=bh(yh().mark((function e(r){var n,i;return yh().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((n=this.totalInputAmount-r)>=t.MINIMUM_DUST)){e.next=16;break}if(!Bf.isValidP2TRAddress(this.from,this.network)){e.next=7;break}return e.next=5,this.setFeeOutput({value:Number(n),address:this.from,tapInternalKey:this.internalPubKeyToXOnly()});case 5:e.next=15;break;case 7:if(!Bf.isValidPublicKey(this.from,this.network)){e.next=13;break}return i=Pa.compile([fh.from(this.from.replace("0x",""),"hex"),Ta.OP_CHECKSIG]),e.next=11,this.setFeeOutput({value:Number(n),script:i});case 11:e.next=15;break;case 13:return e.next=15,this.setFeeOutput({value:Number(n),address:this.from});case 15:return e.abrupt("return");case 16:this.warn("Amount to send back (".concat(n," sat) is less than the minimum dust (").concat(t.MINIMUM_DUST," sat), it will be consumed in fees instead."));case 17:case"end":return e.stop()}}),e,this)}))),function(t){return n.apply(this,arguments)})},{key:"addValueToToOutput",value:function(e){if(e<t.MINIMUM_DUST)throw new Error("Value to send is less than the minimum dust ".concat(e," < ").concat(t.MINIMUM_DUST));var r,n=hh(this.outputs);try{for(n.s();!(r=n.n()).done;){var i=r.value;if("address"in i&&i.address===this.to)return void(i.value+=Number(e))}}catch(t){n.e(t)}finally{n.f()}throw new Error("Output not found")}},{key:"getTransactionOPNetFee",value:function(){return this.priorityFee>t.MINIMUM_DUST?this.priorityFee:t.MINIMUM_DUST}},{key:"calculateTotalUTXOAmount",value:function(){var t,e=0n,r=hh(this.utxos);try{for(r.s();!(t=r.n()).done;)e+=t.value.value}catch(t){r.e(t)}finally{r.f()}return e}},{key:"calculateTotalVOutAmount",value:function(){var t,e=0n,r=hh(this.utxos);try{for(r.s();!(t=r.n()).done;)e+=t.value.value}catch(t){r.e(t)}finally{r.f()}return e}},{key:"addOptionalOutputsAndGetAmount",value:function(){if(!this.optionalOutputs)return 0n;for(var t=0n,e=0;e<this.optionalOutputs.length;e++)this.addOutput(this.optionalOutputs[e]),t+=BigInt(this.optionalOutputs[e].value);return t}},{key:"addInputsFromUTXO",value:function(){if(this.utxos.length){if(this.totalInputAmount<t.MINIMUM_DUST)throw new Error("Total input amount is ".concat(this.totalInputAmount," sat which is less than the minimum dust ").concat(t.MINIMUM_DUST," sat."));for(var e=0;e<this.utxos.length;e++){var r=this.utxos[e],n=this.generatePsbtInputExtended(r,e);this.addInput(n)}}}},{key:"internalInit",value:function(){this.verifyUTXOValidity(),function(t,e,r){var n=mh(_h(t.prototype),"internalInit",r);return"function"==typeof n?function(t){return n.apply(r,t)}:n}(t,0,this)([])}},{key:"updateInput",value:function(t){this.updateInputs.push(t)}},{key:"getWitness",value:function(){if(!this.tapData||!this.tapData.witness)throw new Error("Witness is required");if(0===this.tapData.witness.length)throw new Error("Witness is empty");return this.tapData.witness[this.tapData.witness.length-1]}},{key:"getTapOutput",value:function(){if(!this.tapData||!this.tapData.output)throw new Error("Tap data is required");return this.tapData.output}},{key:"verifyUTXOValidity",value:function(){var t,e=hh(this.utxos);try{for(e.s();!(t=e.n()).done;)if(!t.value.scriptPubKey)throw new Error("Address is required")}catch(t){e.e(t)}finally{e.f()}}},{key:"setFeeOutput",value:(r=bh(yh().mark((function e(r){var n,i,o,a;return yh().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.value,e.next=3,this.estimateTransactionFees();case 3:if(i=e.sent,r.value=n-Number(i),!(r.value<t.MINIMUM_DUST)){e.next=11;break}if(this.feeOutput=null,!(r.value<0)){e.next=9;break}throw new Error("setFeeOutput: Insufficient funds to pay the fees. Fee: ".concat(i," < Value: ").concat(n,". Total input: ").concat(this.totalInputAmount," sat"));case 9:e.next=20;break;case 11:return this.feeOutput=r,e.next=14,this.estimateTransactionFees();case 14:if(!((o=e.sent)>BigInt(n))){e.next=17;break}throw new Error("estimateTransactionFees: Insufficient funds to pay the fees. Fee: ".concat(o," > Value: ").concat(n,". Total input: ").concat(this.totalInputAmount," sat"));case 17:(a=n-Number(o))<t.MINIMUM_DUST?this.feeOutput=null:this.feeOutput.value=a,this.overflowFees=BigInt(a);case 20:case"end":return e.stop()}}),e,this)}))),function(t){return r.apply(this,arguments)})},{key:"internalBuildTransaction",value:(e=bh(yh().mark((function t(e){var r,n,i,o,a,s=arguments;return yh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=s.length>1&&void 0!==s[1]&&s[1],0===e.data.inputs.length){for(n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);e.addOutputs(i)}return t.prev=2,t.next=5,this.signInputs(e);case 5:return this.finalized&&(this.transactionFee=BigInt(e.getFee())),t.abrupt("return",!0);case 9:t.prev=9,t.t0=t.catch(2),a=t.t0,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack));case 13:return t.abrupt("return",!1);case 14:case"end":return t.stop()}}),t,this,[[2,9]])}))),function(t){return e.apply(this,arguments)})}],[{key:"getFrom",value:function(t,e,r){return t||Ec.getTaprootAddress(e,r)}},{key:"witnessStackToScriptWitness",value:function(t){var e,r=fh.allocUnsafe(0);function n(t){var e=r.length,n=Ra.encodingLength(t);r=fh.concat([r,fh.allocUnsafe(n)]),Ra.encode(t,r,e)}return n((e=t).length),e.forEach((function(t){n(t.length),function(t){r=fh.concat([r,fh.from(t)])}(t)})),r}}]);var e,r,n,i,o,a,s,u,c}();Sh(Th,"LOCK_LEAF_SCRIPT",Pa.compile([Ta.OP_0])),Sh(Th,"MINIMUM_DUST",50n);var Oh=32,xh=4,Ah=32,Ph=16,Ih=8,Lh=4,Bh=2,Rh=1,Nh=32,jh=16,Uh=8,Ch=4,Fh=2,Mh=1,Dh=1;function Hh(t){return Hh="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},Hh(t)}function Kh(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Gh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Wh(n.key),n)}}function Wh(t){var e=function(t){if("object"!=Hh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Hh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Hh(e)?e:e+""}var Vh=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,qh=function(){return function(t,e){return e&&Gh(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.maxTries=e}),[{key:"findOrDeriveValidPoint",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.maxTries;if(32!==t.length)throw new Error("xBytes must be exactly 32 bytes.");var n=this.bytesToBigInt(t)%Vh,i=this.isValidX(n);if(e&&null===i)throw new Error("The given x is not a valid curve point.");for(var o=0;null===i;)if(n=(n+1n)%Vh,i=this.isValidX(n),++o>r)throw new Error("Could not find a valid X point within ".concat(r," increments."));return{x:n,y1:i,y2:(Vh-i)%Vh}}},{key:"getCanonicalY",value:function(t,e){return t<e?t:e}},{key:"getHybridPublicKey",value:function(t,e){var r=e%2n===0n?6:7,n=this.bigIntTo32Bytes(t),i=this.bigIntTo32Bytes(e),o=new Uint8Array(65);return o[0]=r,o.set(n,1),o.set(i,33),o}},{key:"isValidX",value:function(t){var e=(this.modPow(t,3n,Vh)+7n)%Vh;return this.sqrtModP(e,Vh)}},{key:"modPow",value:function(t,e,r){for(var n=1n,i=t%r,o=e;o>0;)1n===(1n&o)&&(n=n*i%r),i=i*i%r,o>>=1n;return n}},{key:"sqrtModP",value:function(t,e){var r=this.modPow(t,e+1n>>2n,e);return r*r%e!=t%e?null:r}},{key:"bytesToBigInt",value:function(t){var e,r=0n,n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Kh(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Kh(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r=r<<8n|BigInt(i)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"bigIntTo32Bytes",value:function(t){for(var e=new Uint8Array(32),r=31;r>=0;r--)e[r]=Number(0xffn&t),t>>=8n;return e}}])}(),zh=i(8287).Buffer;function Yh(t){return Yh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yh(t)}function Xh(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,Zh(n.key),n)}}function Zh(t){var e=function(t){if("object"!=Yh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Yh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Yh(e)?e:e+""}var $h=function(){return function(t,e){return e&&Xh(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=Zh(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(this,"deriver",new qh)}),[{key:"generateHybridKeyFromHash",value:function(t){var e=this.deriver.findOrDeriveValidPoint(zh.copyBytesFrom(t),!1),r=this.deriver.getCanonicalY(e.y1,e.y2);return zh.from(this.deriver.getHybridPublicKey(e.x,r))}}])}(),Jh=new $h,Qh=i(8287).Buffer;function tp(t){return tp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tp(t)}function ep(t,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,rp(n.key),n)}}function rp(t){var e=function(t){if("object"!=tp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=tp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==tp(e)?e:e+""}function np(t,e){if(e&&("object"==tp(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function ip(t,e,r,n){var i=op(cp(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function op(){return op="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=cp(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},op.apply(null,arguments)}function ap(t){var e="function"==typeof Map?new Map:void 0;return ap=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(sp())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&up(i,r.prototype),i}(t,arguments,cp(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),up(r,t)},ap(t)}function sp(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(sp=function(){return!!t})()}function up(t,e){return up=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},up(t,e)}function cp(t){return cp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},cp(t)}function fp(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}function lp(t,e,r){return t.set(pp(t,e),r),r}function hp(t,e){return t.get(pp(t,e))}function pp(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}var dp=/^[0-9a-fA-F]+$/,yp=new WeakMap,gp=new WeakMap,bp=new WeakMap,vp=new WeakMap,wp=new WeakMap,mp=new WeakMap,_p=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r=function(t,e,r){return e=cp(e),np(t,sp()?Reflect.construct(e,r||[],cp(t).constructor):e.apply(t,r))}(this,t,[Oh]),fp(r,yp,void 0),fp(r,gp,void 0),fp(r,bp,void 0),fp(r,vp,void 0),fp(r,wp,void 0),fp(r,mp,void 0),e?(r.set(e),r):np(r)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&up(t,e)}(t,ap(Uint8Array)),function(t,e,r){return e&&ep(t.prototype,e),r&&ep(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"originalPublicKey",get:function(){return hp(bp,this)}},{key:"keyPair",get:function(){if(!hp(vp,this))throw new Error("Public key not set for address");return hp(vp,this)}},{key:"toHex",value:function(){return"0x"+Qh.from(this).toString("hex")}},{key:"toBuffer",value:function(){return Qh.from(this)}},{key:"toUncompressedHex",value:function(){if(!hp(wp,this))throw new Error("Public key not set");return"0x"+hp(wp,this).uncompressed.toString("hex")}},{key:"toUncompressedBuffer",value:function(){if(!hp(wp,this))throw new Error("Public key not set");return hp(wp,this).uncompressed}},{key:"toHybridPublicKeyHex",value:function(){if(!hp(wp,this))throw new Error("Public key not set");return"0x"+hp(wp,this).hybrid.toString("hex")}},{key:"toHybridPublicKeyBuffer",value:function(){if(!hp(wp,this))throw new Error("Public key not set");return hp(wp,this).hybrid}},{key:"originalPublicKeyBuffer",value:function(){if(!hp(bp,this))throw new Error("Public key not set");return Qh.from(hp(bp,this))}},{key:"equals",value:function(t){var e=this;if(t.length!==e.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}},{key:"lessThan",value:function(t){for(var e=0;e<Oh;e++){var r=this[e],n=t[e];if(r<n)return!0;if(r>n)return!1}return!1}},{key:"greaterThan",value:function(t){for(var e=0;e<Oh;e++){var r=this[e],n=t[e];if(r>n)return!0;if(r<n)return!1}return!1}},{key:"set",value:function(e){if(![Oh,33,65].includes(e.length))throw new Error("Invalid public key length ".concat(e.length));if(e.length===Oh){var r=Qh.alloc(Oh);r.set(e),lp(mp,this,Jh.generateHybridKeyFromHash(r)),ip(t,"set",this,3)([e])}else this.autoFormat(e)}},{key:"isValid",value:function(t){return Bf.isValidPublicKey(Qh.from(this).toString("hex"),t)}},{key:"p2pk",value:function(){return this.toHex()}},{key:"p2wpkh",value:function(t){return Ec.getP2WPKHAddress(this.keyPair,t)}},{key:"p2pkh",value:function(t){return Ec.getLegacyAddress(this.keyPair,t)}},{key:"p2shp2wpkh",value:function(t){return Ec.getLegacySegwitAddress(this.keyPair,t)}},{key:"toString",value:function(){return this.toHex()}},{key:"toJSON",value:function(){return this.toHex()}},{key:"p2tr",value:function(t){if(hp(yp,this)&&hp(gp,this)===t)return hp(yp,this);var e=Ec.tweakedPubKeyBufferToAddress(this,t);if(e)return lp(gp,this,t),lp(yp,this,e),e;throw new Error("Public key not set")}},{key:"toTweakedHybridPublicKeyHex",value:function(){if(!hp(mp,this))throw new Error("Public key not set");return"0x"+hp(mp,this).toString("hex")}},{key:"toTweakedHybridPublicKeyBuffer",value:function(){if(!hp(mp,this))throw new Error("Public key not set");return hp(mp,this)}},{key:"autoFormat",value:function(e){var r=e[0];3===r||2===r||4!==r&&6!==r&&7!==r||(e=t.uncompressedToCompressed(e)),lp(bp,this,Uint8Array.from(e)),lp(vp,this,Ec.fromPublicKey(hp(bp,this))),lp(wp,this,da(hp(bp,this)));var n=Ba(Ec.tweakPublicKey(Qh.from(hp(bp,this))));lp(mp,this,Jh.generateHybridKeyFromHash(n)),ip(t,"set",this,3)([n])}}],[{key:"dead",value:function(){return t.fromString("0x04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f")}},{key:"fromString",value:function(e){if(!e)throw new Error("Invalid public key");if(e.startsWith("0x")&&(e=e.slice(2)),r=e,!dp.test(r))throw new Error('You must only pass public keys in hexadecimal format. If you have an address such as bc1q... you must convert it to a public key first. Please refer to await provider.getPublicKeyInfo("bc1q..."). If the public key associated with the address is not found, you must force the user to enter the destination public key. It looks like: 0x020373626d317ae8788ce3280b491068610d840c23ecb64c14075bbb9f670af52c.');var r;return new t(Qh.from(e,"hex"))}},{key:"wrap",value:function(e){return new t(e)}},{key:"uncompressedToCompressed",value:function(t){var e=Uint8Array.from(t),r=e.slice(1,33),n=e.slice(33),i=Qh.alloc(33);return i[0]=2+(1&n[n.length-1]),i.set(r,1),i}}])}(),Ep=i(8287).Buffer;function Sp(t){return Sp="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},Sp(t)}function kp(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,Tp(n.key),n)}}function Tp(t){var e=function(t){if("object"!=Sp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Sp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Sp(e)?e:e+""}var Op=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&kp(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"getContractAddress",value:function(e){var r=e.network||ka.bitcoin,n=[{output:new nf(e.deployerPubKey,Ba(e.contractSaltPubKey),r).compile(e.bytecode,e.originalSalt,e.calldata),version:t.TAP_SCRIPT_VERSION},{output:Th.LOCK_LEAF_SCRIPT,version:t.TAP_SCRIPT_VERSION}];return t.generateAddressFromScript(e,n)}},{key:"verifyControlBlock",value:function(e,r){var n=e.network||ka.bitcoin,i=new nf(e.deployerPubKey,Ba(e.contractSaltPubKey),n).compile(e.bytecode,e.originalSalt,e.calldata),o=[{output:i,version:t.TAP_SCRIPT_VERSION},{output:Th.LOCK_LEAF_SCRIPT,version:t.TAP_SCRIPT_VERSION}],a=Oa.p2tr({internalPubkey:Ba(e.deployerPubKey),network:n,scriptTree:o,redeem:{pubkeys:[e.deployerPubKey,e.contractSaltPubKey],output:i,redeemVersion:t.TAP_SCRIPT_VERSION}}).witness;return!(!a||0===a.length)&&a[a.length-1].equals(r)}},{key:"getContractSeed",value:function(t,e,r){var n=pa.hash256(e),i=Ep.concat([t,r,n]);return pa.hash256(i)}},{key:"generateContractVirtualAddress",value:function(e,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:ka.bitcoin,o=t.getContractSeed(e,r,n);return new _p(o).p2tr(i)}},{key:"generateAddressFromScript",value:function(t,e){var r=t.network||ka.bitcoin,n={internalPubkey:Ba(t.deployerPubKey),network:r,scriptTree:e};return Oa.p2tr(n).address}}])}();!function(t,e){(e=Tp(e))in t?Object.defineProperty(t,e,{value:192,enumerable:!0,configurable:!0,writable:!0}):t[e]=192}(Op,"TAP_SCRIPT_VERSION");var xp=i(8287).Buffer;function Ap(t){return Ap="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ap(t)}function Pp(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ip(n.key),n)}}function Ip(t){var e=function(t){if("object"!=Ap(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ap(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ap(e)?e:e+""}var Lp=function(){return function(t,e){return e&&Pp(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),[{key:"sha256",value:function(t){return pa.sha256(xp.from(t))}},{key:"tweakAndSignMessage",value:function(t,e,r){var n=Gl.tweakSigner(t,{network:r});return this.signMessage(n,e)}},{key:"signMessage",value:function(t,e){if("string"==typeof e&&(e=xp.from(e,"utf-8")),!t.privateKey)throw new Error("Private key not found in keypair.");var r=this.sha256(e);return{signature:Na.signSchnorr(r,t.privateKey),message:r}}},{key:"verifySignature",value:function(t,e,r){if("string"==typeof e&&(e=xp.from(e,"utf-8")),64!==r.length)throw new Error("Invalid signature length.");var n=this.sha256(e);return Na.verifySchnorr(n,Ba(xp.from(t)),r)}},{key:"tweakAndVerifySignature",value:function(t,e,r){var n=Ec.tweakPublicKey(xp.from(t));return this.verifySignature(n,e,r)}}])}(),Bp=new Lp;function Rp(t){return Rp="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},Rp(t)}function Np(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,jp(n.key),n)}}function jp(t){var e=function(t){if("object"!=Rp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Rp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Rp(e)?e:e+""}var Up=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.network=r,this._keypair=Ec.fromWIF(e.privateKey,this.network),this._p2wpkh=Ec.getP2WPKHAddress(this._keypair,this.network),this._p2tr=Ec.getTaprootAddress(this._keypair,this.network),this._legacy=Ec.getLegacyAddress(this._keypair,this.network),this._segwitLegacy=Ec.getLegacySegwitAddress(this._keypair,this.network),this._tweakedKey=Ec.tweakPublicKey(this._keypair.publicKey.toString("hex")),this._bufferPubKey=this._keypair.publicKey,this._address=new _p(this._keypair.publicKey)}return function(t,e,r){return e&&Np(t.prototype,e),r&&Np(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"address",get:function(){return this._address}},{key:"tweakedPubKeyKey",get:function(){return this._tweakedKey}},{key:"keypair",get:function(){if(!this._keypair)throw new Error("Keypair not set");return this._keypair}},{key:"p2wpkh",get:function(){return this._p2wpkh}},{key:"p2tr",get:function(){return this._p2tr}},{key:"legacy",get:function(){return this._legacy}},{key:"addresses",get:function(){return[this.p2wpkh,this.p2tr,this.legacy,this.segwitLegacy]}},{key:"segwitLegacy",get:function(){return this._segwitLegacy}},{key:"publicKey",get:function(){if(!this._bufferPubKey)throw new Error("Public key not set");return this._bufferPubKey}},{key:"xOnly",get:function(){if(!this.keypair)throw new Error("Keypair not set");return Ba(this._bufferPubKey)}}],[{key:"fromWif",value:function(e){return new t({privateKey:e,address:"",publicKey:""},arguments.length>1&&void 0!==arguments[1]?arguments[1]:ka.bitcoin)}}])}();function Cp(t){return Cp="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},Cp(t)}function Fp(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,Mp(n.key),n)}}function Mp(t){var e=function(t){if("object"!=Cp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Cp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Cp(e)?e:e+""}var Dp,Hp,Kp,Gp=function(){return function(t,e,r){return e&&Fp(t.prototype,e),r&&Fp(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ka.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.network=e}),[{key:"getAddress",value:function(){return this.address}}],[{key:"getAddress",value:function(){throw arguments.length>0&&void 0!==arguments[0]||ka.bitcoin,new Error("Method not implemented.")}}])}();!function(t){t[t.Bitcoin=0]="Bitcoin",t[t.Fractal=1]="Fractal"}(Dp||(Dp={})),function(t){t[t.GENERIC=0]="GENERIC",t[t.FUNDING=1]="FUNDING",t[t.DEPLOYMENT=2]="DEPLOYMENT",t[t.INTERACTION=3]="INTERACTION",t[t.WBTC_WRAP=4]="WBTC_WRAP",t[t.WBTC_UNWRAP=5]="WBTC_UNWRAP",t[t.MULTI_SIG=6]="MULTI_SIG",t[t.CUSTOM_CODE=7]="CUSTOM_CODE"}(Hp||(Hp={})),function(t){t[t.Roswell=0]="Roswell",t[t.Rachel=1]="Rachel",t[t.Kecksburg=2]="Kecksburg",t[t.Phoenix=3]="Phoenix",t[t.Aurora=4]="Aurora",t[t.Rendlesham=5]="Rendlesham",t[t.Lazar=6]="Lazar",t[t.ShagHarbor=7]="ShagHarbor",t[t.Exeter=8]="Exeter",t[t.Stephenville=9]="Stephenville",t[t.Valensole=10]="Valensole",t[t.Socorro=11]="Socorro",t[t.Pascagoula=12]="Pascagoula",t[t.Tehran=13]="Tehran",t[t.Westall=14]="Westall",t[t.Hopkinsville=15]="Hopkinsville",t[t.Belgium=16]="Belgium",t[t.Breeze=17]="Breeze",t[t.Flatwoods=18]="Flatwoods",t[t.Maury=20]="Maury",t[t.Varginha=21]="Varginha",t[t.Trindade=22]="Trindade",t[t.Levelland=23]="Levelland",t[t.Wanaque=24]="Wanaque",t[t.Coyame=25]="Coyame",t[t.Delphos=26]="Delphos"}(Kp||(Kp={}));var Wp={CONSENSUS:Kp.Roswell,CONSENSUS_NAME:"Roswell",ENABLED_AT_BLOCK:0n};function Vp(t){return Vp="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},Vp(t)}var qp=function(t,e,r){return(e=function(t){var e=function(t){if("object"!=Vp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Vp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Vp(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},Kp.Roswell,Wp),zp=Kp.Roswell,Yp=qp[zp],Xp=i(4148);var Zp=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 $p(t){switch(t){case"sha256":return ds.create();case"sha512":return Ts.create()}Xp(!1,"invalid hashing algorithm name","INVALID_ARGUMENT",{argument:"algorithm",value:t})}Zp.crypto||Zp.msCrypto;var Jp=i(8287).Buffer;function Qp(t){return Qp="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},Qp(t)}function td(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,ed(n.key),n)}}function ed(t){var e=function(t){if("object"!=Qp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Qp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Qp(e)?e:e+""}var rd=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&td(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"btcToSatoshi",value:function(t){return BigInt(1e8*t)}},{key:"rndBytes",value:function(){var e=t.getSafeRandomValues(64);return Jp.from(e)}},{key:"getSafeRandomValues",value:function(t){if(void 0!==globalThis.window&&globalThis.window.crypto&&"function"==typeof globalThis.window.crypto.getRandomValues){var e=new Uint8Array(t);return window.crypto.getRandomValues(e),Jp.from(e)}if(globalThis.crypto&&"function"==typeof globalThis.crypto.getRandomValues){var r=new Uint8Array(t);return globalThis.crypto.getRandomValues(r),Jp.from(r)}throw console.log("No secure random number generator available. Please upgrade your environment.",globalThis.window.crypto,globalThis.crypto),new Error("No secure random number generator available. Please upgrade your environment.")}},{key:"opnetHash",value:function(t){var e=$p("sha512");e.update(t);var r=e.digest();return"0x".concat(Jp.from(r).toString("hex"))}}])}(),nd=i(8287).Buffer;function id(t){return id="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},id(t)}function od(){od=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==id(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(id(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function ad(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function sd(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){ad(o,n,i,a,s,"next",t)}function s(t){ad(o,n,i,a,s,"throw",t)}a(void 0)}))}}function ud(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,yd(n.key),n)}}function cd(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(cd=function(){return!!t})()}function fd(t,e,r,n){var i=ld(hd(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function ld(){return ld="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=hd(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},ld.apply(null,arguments)}function hd(t){return hd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},hd(t)}function pd(t,e){return pd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},pd(t,e)}function dd(t,e,r){return(e=yd(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function yd(t){var e=function(t){if("object"!=id(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=id(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==id(e)?e:e+""}var gd=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),dd(r=function(t,e,r){return e=hd(e),function(t,e){if(e&&("object"==id(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,cd()?Reflect.construct(e,r||[],hd(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Hp.CUSTOM_CODE),dd(r,"tapLeafScript",null),dd(r,"targetScriptRedeem",null),dd(r,"leftOverFundsScriptRedeem",null),dd(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");var n=r.witnesses.concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:Th.witnessStackToScriptWitness(n)}})),!e.script)throw new Error("Bitcoin script is required");if(!e.witnesses)throw new Error("Witness(es) are required");return r.witnesses=e.witnesses,r.randomBytes=e.randomBytes||rd.rndBytes(),r.scriptSeed=r.getContractSeed(),r.contractSigner=Ec.fromSeedKeyPair(r.scriptSeed,r.network),r.generator=new Yc(r.internalPubKeyToXOnly(),r.network),r.compiledTargetScript=r.generator.compile(e.script),r.scriptTree=r.getScriptTree(),r.internalInit(),r._scriptAddress=xf.generatePKSH(r.scriptSeed,r.network),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&pd(t,e)}(t,Th),function(t,e){return e&&ud(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"scriptAddress",get:function(){return this._scriptAddress}},{key:"p2trAddress",get:function(){return this.to||this.getScriptAddress()}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"contractSignerXOnlyPubKey",value:function(){return Ba(nd.from(this.contractSigner.publicKey))}},{key:"buildTransaction",value:(r=sd(od().mark((function t(){var e,r;return od().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to||(this.to=this.getScriptAddress()),e=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=4;break}throw new Error("Left over funds script redeem is required");case 4:if(e.redeemVersion){t.next=6;break}throw new Error("Left over funds script redeem version is required");case 6:if(e.output){t.next=8;break}throw new Error("Left over funds script redeem output is required");case 8:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),t.next=14,this.addRefundOutput(r+this.addOptionalOutputsAndGetAmount());case 14:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"signInputs",value:(e=sd(od().mark((function e(r){var n;return od().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.contractSigner){e.next=4;break}return e.next=3,fd(t,"signInputs",this,3)([r]);case 3:return e.abrupt("return");case 4:for(n=0;n<r.data.inputs.length;n++)0===n?(r.signInput(0,this.contractSigner),r.signInput(0,this.getSignerKey()),r.finalizeInput(0,this.customFinalizer)):(r.signInput(n,this.getSignerKey()),r.finalizeInput(n));case 5:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"getContractSeed",value:function(){return pa.hash256(this.randomBytes)}},{key:"getPubKeys",value:function(){var t=[nd.from(this.signer.publicKey)];return this.contractSigner&&t.push(nd.from(this.contractSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={pubkeys:this.getPubKeys(),output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={pubkeys:this.getPubKeys(),output:this.getLeafScript(),redeemVersion:192}}},{key:"getLeafScript",value:function(){return Th.LOCK_LEAF_SCRIPT}},{key:"getScriptTree",value:function(){return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:this.getLeafScript(),version:192}]}}]);var e,r}(),bd=i(8287).Buffer;function vd(t){return vd="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},vd(t)}function wd(){wd=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==vd(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(vd(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function md(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function _d(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){md(o,n,i,a,s,"next",t)}function s(t){md(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Ed(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,Pd(n.key),n)}}function Sd(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Sd=function(){return!!t})()}function kd(t,e,r,n){var i=Td(Od(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function Td(){return Td="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Od(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Td.apply(null,arguments)}function Od(t){return Od=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Od(t)}function xd(t,e){return xd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},xd(t,e)}function Ad(t,e,r){return(e=Pd(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Pd(t){var e=function(t){if("object"!=vd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=vd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==vd(e)?e:e+""}var Id=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ad(r=function(t,e,r){return e=Od(e),function(t,e){if(e&&("object"==vd(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,Sd()?Reflect.construct(e,r||[],Od(t).constructor):e.apply(t,r))}(this,t,[e]),"targetScriptRedeem",null),Ad(r,"leftOverFundsScriptRedeem",null),Ad(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");if(!r.contractSecret)throw new Error("Contract secret is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:Th.witnessStackToScriptWitness(n)}})),!e.calldata)throw new Error("Calldata is required");return r.disableAutoRefund=e.disableAutoRefund||!1,r.calldata=p.compress(e.calldata),r.randomBytes=e.randomBytes||rd.rndBytes(),r.scriptSigner=r.generateKeyPairFromSeed(),r.calldataGenerator=new Hc(bd.from(r.signer.publicKey),r.scriptSignerXOnlyPubKey(),r.network),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&xd(t,e)}(t,Th),function(t,e){return e&&Ed(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"getContractSecret",value:function(){return this.contractSecret}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"generateSecret",value:function(){if(!this.to)throw new Error("To address is required");return ha.fromBech32(this.to).data}},{key:"scriptSignerXOnlyPubKey",value:function(){return Ba(bd.from(this.scriptSigner.publicKey))}},{key:"generateKeyPairFromSeed",value:function(){return Ec.fromSeedKeyPair(this.randomBytes,this.network)}},{key:"buildTransaction",value:(i=_d(wd().mark((function t(){var e,r,n;return wd().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to){t.next=2;break}throw new Error("To address is required");case 2:if(e=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=5;break}throw new Error("Left over funds script redeem is required");case 5:if(e.redeemVersion){t.next=7;break}throw new Error("Left over funds script redeem version is required");case 7:if(e.output){t.next=9;break}throw new Error("Left over funds script redeem output is required");case 9:if(this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.regenerated||this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),n=this.addOptionalOutputsAndGetAmount(),this.disableAutoRefund){t.next=17;break}return t.next=17,this.addRefundOutput(r+n);case 17:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"signInputs",value:(n=_d(wd().mark((function e(r){return wd().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.scriptSigner){e.next=4;break}return e.next=3,kd(t,"signInputs",this,3)([r]);case 3:return e.abrupt("return");case 4:if(!("multiSignPsbt"in this.signer)){e.next=9;break}return e.next=7,this.signInputsWalletBased(r);case 7:e.next=11;break;case 9:return e.next=11,this.signInputsNonWalletBased(r);case 11:case"end":return e.stop()}}),e,this)}))),function(t){return n.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"getScriptSolution",value:function(t){if(!t.tapScriptSig)throw new Error("Tap script signature is required");return[this.contractSecret,this.internalPubKeyToXOnly(),t.tapScriptSig[0].signature,t.tapScriptSig[1].signature]}},{key:"getScriptTree",value:function(){if(!this.calldata)throw new Error("Calldata is required");return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:t.LOCK_LEAF_SCRIPT,version:192}]}},{key:"signInputsWalletBased",value:(r=_d(wd().mark((function t(e){var r,n;return wd().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.signer,t.next=3,this.signInput(e,e.data.inputs[0],0,this.scriptSigner);case 3:return t.next=5,r.multiSignPsbt([e]);case 5:for(n=0;n<e.data.inputs.length;n++)0===n?e.finalizeInput(n,this.customFinalizer):e.finalizeInput(n);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"signInputsNonWalletBased",value:(e=_d(wd().mark((function t(e){var r;return wd().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=0;case 1:if(!(r<e.data.inputs.length)){t.next=16;break}if(0!==r){t.next=10;break}return t.next=5,this.signInput(e,e.data.inputs[r],r,this.scriptSigner);case 5:return t.next=7,this.signInput(e,e.data.inputs[r],r,this.getSignerKey());case 7:e.finalizeInput(r,this.customFinalizer),t.next=13;break;case 10:return t.next=12,this.signInput(e,e.data.inputs[r],r,this.getSignerKey());case 12:e.finalizeInput(r);case 13:r++,t.next=1;break;case 16:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"getPubKeys",value:function(){var t=[bd.from(this.signer.publicKey)];return this.scriptSigner&&t.push(bd.from(this.scriptSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={output:t.LOCK_LEAF_SCRIPT,redeemVersion:192}}}]);var e,r,n,i}();Ad(Id,"MAXIMUM_CALLDATA_SIZE",1048576);var Ld=i(8287).Buffer;function Bd(t){return Bd="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},Bd(t)}function Rd(){Rd=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Bd(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Bd(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Nd(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function jd(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Nd(o,n,i,a,s,"next",t)}function s(t){Nd(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Ud(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,Gd(n.key),n)}}function Cd(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Cd=function(){return!!t})()}function Fd(t,e,r,n){var i=Md(Dd(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function Md(){return Md="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Dd(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Md.apply(null,arguments)}function Dd(t){return Dd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Dd(t)}function Hd(t,e){return Hd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Hd(t,e)}function Kd(t,e,r){return(e=Gd(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Gd(t){var e=function(t){if("object"!=Bd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Bd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bd(e)?e:e+""}var Wd=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Kd(r=function(t,e,r){return e=Dd(e),function(t,e){if(e&&("object"==Bd(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,Cd()?Reflect.construct(e,r||[],Dd(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Hp.DEPLOYMENT),Kd(r,"tapLeafScript",null),Kd(r,"targetScriptRedeem",null),Kd(r,"leftOverFundsScriptRedeem",null),Kd(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");if(!e.tapScriptSig)throw new Error("Tap script signature is required");var n=[r.randomBytes,r.internalPubKeyToXOnly(),e.tapScriptSig[0].signature,e.tapScriptSig[1].signature].concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:Th.witnessStackToScriptWitness(n)}})),r.bytecode=p.compress(e.bytecode),r.verifyBytecode(),e.calldata&&(r.calldata=e.calldata,r.verifyCalldata()),r.randomBytes=e.randomBytes||rd.rndBytes(),r.contractSeed=r.getContractSeed(),r.contractSigner=Ec.fromSeedKeyPair(r.contractSeed,r.network),r.deploymentGenerator=new nf(Ld.from(r.signer.publicKey),r.contractSignerXOnlyPubKey(),r.network),r.compiledTargetScript=r.deploymentGenerator.compile(r.bytecode,r.randomBytes,r.calldata),r.scriptTree=r.getScriptTree(),r.internalInit(),r._contractPubKey="0x"+r.contractSeed.toString("hex"),r._contractAddress=new _p(r.contractSeed),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Hd(t,e)}(t,Th),function(t,e){return e&&Ud(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"contractPubKey",get:function(){return this._contractPubKey}},{key:"contractAddress",get:function(){return this._contractAddress}},{key:"p2trAddress",get:function(){return this.to||this.getScriptAddress()}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"contractSignerXOnlyPubKey",value:function(){return Ba(Ld.from(this.contractSigner.publicKey))}},{key:"buildTransaction",value:(n=jd(Rd().mark((function t(){var e,r;return Rd().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to||(this.to=this.getScriptAddress()),e=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=4;break}throw new Error("Left over funds script redeem is required");case 4:if(e.redeemVersion){t.next=6;break}throw new Error("Left over funds script redeem version is required");case 6:if(e.output){t.next=8;break}throw new Error("Left over funds script redeem output is required");case 8:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.contractAddress.p2tr(this.network)}),t.next=14,this.addRefundOutput(r+this.addOptionalOutputsAndGetAmount());case 14:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"signInputsWalletBased",value:(r=jd(Rd().mark((function t(e){var r,n;return Rd().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.signer,t.next=3,this.signInput(e,e.data.inputs[0],0,this.contractSigner);case 3:return t.next=5,r.multiSignPsbt([e]);case 5:for(n=0;n<e.data.inputs.length;n++)0===n?e.finalizeInput(n,this.customFinalizer):e.finalizeInput(n);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"signInputs",value:(e=jd(Rd().mark((function e(r){var n;return Rd().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.contractSigner){e.next=4;break}return e.next=3,Fd(t,"signInputs",this,3)([r]);case 3:return e.abrupt("return");case 4:if(!("multiSignPsbt"in this.signer)){e.next=8;break}return e.next=7,this.signInputsWalletBased(r);case 7:return e.abrupt("return");case 8:for(n=0;n<r.data.inputs.length;n++)0===n?(r.signInput(0,this.contractSigner),r.signInput(0,this.getSignerKey()),r.finalizeInput(0,this.customFinalizer)):(r.signInput(n,this.getSignerKey()),r.finalizeInput(n));case 9:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"verifyCalldata",value:function(){if(this.calldata&&this.calldata.length>Id.MAXIMUM_CALLDATA_SIZE)throw new Error("Calldata size overflow.")}},{key:"verifyBytecode",value:function(){if(!this.bytecode)throw new Error("Bytecode is required");if(this.bytecode.length>t.MAXIMUM_CONTRACT_SIZE)throw new Error("Contract size overflow.")}},{key:"getContractSeed",value:function(){if(!this.bytecode)throw new Error("Bytecode is required");var t=this.internalPubKeyToXOnly(),e=pa.hash256(this.randomBytes),r=pa.hash256(this.bytecode),n=Ld.concat([t,e,r]);return pa.hash256(n)}},{key:"getPubKeys",value:function(){var t=[Ld.from(this.signer.publicKey)];return this.contractSigner&&t.push(Ld.from(this.contractSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={pubkeys:this.getPubKeys(),output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={pubkeys:this.getPubKeys(),output:this.getLeafScript(),redeemVersion:192}}},{key:"getLeafScript",value:function(){return Th.LOCK_LEAF_SCRIPT}},{key:"getScriptTree",value:function(){if(!this.bytecode)throw new Error("Contract bytecode is required");return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:this.getLeafScript(),version:192}]}}]);var e,r,n}();Kd(Wd,"MAXIMUM_CONTRACT_SIZE",131072);var Vd=i(8287).Buffer;function qd(t){return qd="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},qd(t)}function zd(){zd=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==qd(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(qd(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Yd(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Xd(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,Qd(n.key),n)}}function Zd(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Zd=function(){return!!t})()}function $d(t){return $d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},$d(t)}function Jd(t,e){return Jd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jd(t,e)}function Qd(t){var e=function(t){if("object"!=qd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=qd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qd(e)?e:e+""}var ty=function(){function t(e){var r,n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=Qd(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(n=function(t,e,r){return e=$d(e),function(t,e){if(e&&("object"==qd(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,Zd()?Reflect.construct(e,r||[],$d(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Hp.FUNDING),n.amount=e.amount,n.splitInputsInto=null!==(r=e.splitInputsInto)&&void 0!==r?r:1,n.internalInit(),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Jd(t,e)}(t,Th),function(t,e){return e&&Xd(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"buildTransaction",value:(e=function(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Yd(o,n,i,a,s,"next",t)}function s(t){Yd(o,n,i,a,s,"throw",t)}a(void 0)}))}}(zd().mark((function t(){var e;return zd().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to){t.next=2;break}throw new Error("Recipient address is required");case 2:return this.addInputsFromUTXO(),this.splitInputsInto>1?this.splitInputs(this.amount):this.isPubKeyDestination?(e=Pa.compile([Vd.from(this.to.replace("0x",""),"hex"),Ta.OP_CHECKSIG]),this.addOutput({value:Number(this.amount),script:e})):this.addOutput({value:Number(this.amount),address:this.to}),t.next=6,this.addRefundOutput(this.amount+this.addOptionalOutputsAndGetAmount());case 6:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"splitInputs",value:function(t){if(!this.to)throw new Error("Recipient address is required");for(var e=t/BigInt(this.splitInputsInto),r=0;r<this.splitInputsInto;r++)this.isPubKeyDestination?this.addOutput({value:Number(e),script:Vd.from(this.to.slice(2),"hex")}):this.addOutput({value:Number(e),address:this.to})}},{key:"getSignerKey",value:function(){return this.signer}}]);var e}();function ey(t){return ey="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},ey(t)}function ry(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ry=function(){return!!t})()}function ny(t){return ny=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ny(t)}function iy(t,e){return iy=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},iy(t,e)}function oy(t,e,r){return(e=ay(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ay(t){var e=function(t){if("object"!=ey(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ey(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ey(e)?e:e+""}var sy=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),oy(r=function(t,e,r){return e=ny(e),function(t,e){if(e&&("object"==ey(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,ry()?Reflect.construct(e,r||[],ny(t).constructor):e.apply(t,r))}(this,t,[e]),"type",Hp.INTERACTION),oy(r,"tapLeafScript",null),r.contractSecret=r.generateSecret(),r.compiledTargetScript=r.calldataGenerator.compile(r.calldata,r.contractSecret),r.scriptTree=r.getScriptTree(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&iy(t,e)}(t,Id),function(t){return Object.defineProperty(t,"prototype",{writable:!1}),t}(t)}(),uy=i(8287).Buffer;function cy(t){return cy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},cy(t)}function fy(t){return function(t){if(Array.isArray(t))return ly(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return ly(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ly(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ly(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function hy(){hy=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==cy(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(cy(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function py(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function dy(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?py(Object(r),!0).forEach((function(e){yy(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):py(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function yy(t,e,r){return(e=wy(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function gy(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function by(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){gy(o,n,i,a,s,"next",t)}function s(t){gy(o,n,i,a,s,"throw",t)}a(void 0)}))}}function vy(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,wy(n.key),n)}}function wy(t){var e=function(t){if("object"!=cy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=cy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==cy(e)?e:e+""}var my=function(){return function(t,e){return e&&vy(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),[{key:"createCustomScriptTransaction",value:(i=by(hy().mark((function t(e){var r,n,i,o,a,s,u;return hy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:if(e.from){t.next=4;break}throw new Error('Field "from" not provided.');case 4:return r=new gd(dy(dy({},e),{},{utxos:[e.utxos[0]]})),t.next=7,r.generateTransactionMinimalSignatures();case 7:return t.next=9,r.getFundingTransactionParameters();case 9:return(n=t.sent).utxos=e.utxos,t.next=13,r.estimateTransactionFees();case 13:return t.t0=t.sent,t.t1=this.getPriorityFee(e),t.t2=t.t0+t.t1,t.t3=r.getOptionalOutputValue(),n.amount=t.t2+t.t3,t.next=20,this.createFundTransaction(dy({},n));case 20:if(i=t.sent){t.next=23;break}throw new Error("Could not sign funding transaction.");case 23:return n.estimatedFees=i.estimatedFees,t.next=26,this.createFundTransaction(n);case 26:if(o=t.sent){t.next=29;break}throw new Error("Could not sign funding transaction.");case 29:return e.utxos=this.getUTXOAsTransaction(o.tx,e.to,0),a=dy(dy({},e),{},{utxos:this.getUTXOAsTransaction(o.tx,e.to,0),randomBytes:r.getRndBytes(),nonWitnessUtxo:o.tx.toBuffer(),estimatedFees:r.estimatedFees}),s=new gd(a),t.next=34,s.signTransaction();case 34:return u=t.sent,t.abrupt("return",[o.tx.toHex(),u.toHex(),this.getUTXOAsTransaction(o.tx,e.from,1)]);case 36:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"signInteraction",value:(n=by(hy().mark((function t(e){var r,n,i,o,a,s,u;return hy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:if(e.from){t.next=4;break}throw new Error('Field "from" not provided.');case 4:if(e.utxos[0]){t.next=6;break}throw new Error("Missing at least one UTXO.");case 6:return r=new sy(dy(dy({},e),{},{utxos:[e.utxos[0]]})),t.next=9,r.generateTransactionMinimalSignatures();case 9:return t.next=11,r.getFundingTransactionParameters();case 11:return(n=t.sent).utxos=e.utxos,t.next=15,r.estimateTransactionFees();case 15:return t.t0=t.sent,t.t1=this.getPriorityFee(e),t.t2=t.t0+t.t1,t.t3=r.getOptionalOutputValue(),n.amount=t.t2+t.t3,t.next=22,this.createFundTransaction(dy(dy({},n),{},{optionalOutputs:[]}));case 22:if(i=t.sent){t.next=25;break}throw new Error("Could not sign funding transaction.");case 25:return n.estimatedFees=i.estimatedFees,t.next=28,this.createFundTransaction(dy(dy({},n),{},{optionalOutputs:[]}));case 28:if(o=t.sent){t.next=31;break}throw new Error("Could not sign funding transaction.");case 31:return e.utxos=this.getUTXOAsTransaction(o.tx,e.to,0),a=dy(dy({},e),{},{utxos:this.getUTXOAsTransaction(o.tx,e.to,0),randomBytes:r.getRndBytes(),nonWitnessUtxo:o.tx.toBuffer(),estimatedFees:r.estimatedFees}),s=new sy(a),t.next=36,s.signTransaction();case 36:return u=t.sent,t.abrupt("return",[o.tx.toHex(),u.toHex(),this.getUTXOAsTransaction(o.tx,e.from,1)]);case 38:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"signDeployment",value:(r=by(hy().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h;return hy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Wd(e),t.next=3,r.signTransaction();case 3:return t.next=5,r.getFundingTransactionParameters();case 5:return n=t.sent,t.next=8,r.estimateTransactionFees();case 8:return t.t0=t.sent,t.t1=this.getPriorityFee(e),t.t2=t.t0+t.t1,t.t3=r.getOptionalOutputValue(),n.amount=t.t2+t.t3,i=new ty(n),t.next=16,i.signTransaction();case 16:if(o=t.sent){t.next=19;break}throw new Error("Could not sign funding transaction.");case 19:return a=o.outs[0],s={transactionId:o.getId(),outputIndex:0,scriptPubKey:{hex:a.script.toString("hex"),address:r.getScriptAddress()},value:BigInt(a.value)},u=dy(dy({},e),{},{utxos:[s],randomBytes:r.getRndBytes(),nonWitnessUtxo:o.toBuffer(),optionalOutputs:[]}),c=new Wd(u),t.next=25,c.signTransaction();case 25:return f=t.sent,l=o.outs[1],h={transactionId:o.getId(),outputIndex:1,scriptPubKey:{hex:l.script.toString("hex"),address:e.from},value:BigInt(l.value)},t.abrupt("return",{transaction:[o.toHex(),f.toHex()],contractAddress:c.contractAddress.p2tr(e.network),contractPubKey:c.contractPubKey,p2trAddress:c.p2trAddress,utxos:[h]});case 29:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"createBTCTransfer",value:(e=by(hy().mark((function t(e){var r;return hy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.from){t.next=2;break}throw new Error('Field "from" not provided.');case 2:return t.next=4,this.createFundTransaction(e);case 4:return r=t.sent,t.abrupt("return",{estimatedFees:r.estimatedFees,original:r.original,tx:r.tx.toHex(),nextUTXOs:this.getAllNewUTXOs(r.original,r.tx,e.from)});case 6:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"getAllNewUTXOs",value:function(t,e,r){for(var n=t.getOutputs(),i=[],o=0;o<e.outs.length;o++){var a=n[o];"address"in a&&a.address===r&&i.push.apply(i,fy(this.getUTXOAsTransaction(e,r,o)))}return i}},{key:"createFundTransaction",value:(t=by(hy().mark((function t(e){var r,n;return hy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:return r=new ty(e),t.next=5,r.signTransaction();case 5:if(n=t.sent){t.next=8;break}throw new Error("Could not sign funding transaction.");case 8:return t.abrupt("return",{tx:n,original:r,estimatedFees:r.estimatedFees,nextUTXOs:this.getUTXOAsTransaction(n,e.to,0)});case 9:case"end":return t.stop()}}),t,this)}))),function(e){return t.apply(this,arguments)})},{key:"writePSBTHeader",value:function(t,e){var r=uy.from(e,"base64"),n=uy.alloc(2);return n.writeUInt8(t,0),n.writeUInt8(zp,1),uy.concat([n,r]).toString("hex")}},{key:"getPriorityFee",value:function(t){return t.priorityFee<Th.MINIMUM_DUST?Th.MINIMUM_DUST:t.priorityFee}},{key:"getUTXOAsTransaction",value:function(t,e,r){if(!t.outs[r])return[];var n=t.outs[r];return[{transactionId:t.getId(),outputIndex:r,scriptPubKey:{hex:n.script.toString("hex"),address:e},value:BigInt(n.value)}]}}]);var t,e,r,n,i}(),_y=i(8287).Buffer;function Ey(t){return Ey="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},Ey(t)}function Sy(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 ky(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ky(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function ky(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ty(){Ty=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Ey(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Ey(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Oy(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function xy(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Oy(o,n,i,a,s,"next",t)}function s(t){Oy(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Ay(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Py(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Ay(Object(r),!0).forEach((function(e){Ny(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ay(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Iy(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,jy(n.key),n)}}function Ly(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Ly=function(){return!!t})()}function By(t){return By=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},By(t)}function Ry(t,e){return Ry=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ry(t,e)}function Ny(t,e,r){return(e=jy(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function jy(t){var e=function(t){if("object"!=Ey(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ey(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ey(e)?e:e+""}var Uy=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e.refundVault)throw new Error("Refund vault is required");if(!e.requestedAmount)throw new Error("Requested amount is required");if(!e.receiver)throw new Error("Receiver is required");if(Ny(r=function(t,e,r){return e=By(e),function(t,e){if(e&&("object"==Ey(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,Ly()?Reflect.construct(e,r||[],By(t).constructor):e.apply(t,r))}(this,t,[Py(Py({},e),{},{signer:Ec.fromPrivateKey(pa.sha256(_y.from("aaaaaaaa","utf-8"))),priorityFee:0n})]),"type",Hp.MULTI_SIG),Ny(r,"targetScriptRedeem",null),Ny(r,"leftOverFundsScriptRedeem",null),Ny(r,"originalInputCount",0),Ny(r,"sighashTypes",t.signHashTypesArray),Ny(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:Th.witnessStackToScriptWitness(n)}})),!e.pubkeys)throw new Error("Pubkeys are required");return e.psbt&&(r.log("Using provided PSBT."),r.transaction=e.psbt,r.originalInputCount=r.transaction.data.inputs.length),r.refundVault=e.refundVault,r.requestedAmount=e.requestedAmount,r.receiver=e.receiver,r.publicKeys=e.pubkeys,r.minimumSignatures=e.minimumSignatures,r.compiledTargetScript=_f.compile(e.pubkeys,r.minimumSignatures),r.scriptTree=r.getScriptTree(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ry(t,e)}(t,Th),function(t,e,r){return e&&Iy(t.prototype,e),r&&Iy(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"finalizeTransactionInputs",value:function(){var t=!1;try{for(var e=this.originalInputCount;e<this.transaction.data.inputs.length;e++)this.transaction.finalizeInput(e,this.customFinalizer.bind(this));t=!0}catch(t){this.error("Error finalizing transaction inputs: ".concat(t.stack))}return t}},{key:"signPSBT",value:(i=xy(Ty().mark((function t(){return Ty().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signTransaction();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.transaction);case 4:throw new Error("Could not sign transaction");case 5:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"buildTransaction",value:(n=xy(Ty().mark((function t(){var e,r;return Ty().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=this.targetScriptRedeem){t.next=3;break}throw new Error("Left over funds script redeem is required");case 3:if(e.redeemVersion){t.next=5;break}throw new Error("Left over funds script redeem version is required");case 5:if(e.output){t.next=7;break}throw new Error("Left over funds script redeem output is required");case 7:if(this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),!((r=this.calculateOutputLeftAmountFromVaults(this.utxos))<0)){t.next=12;break}throw new Error("Output value left is negative ".concat(r,"."));case 12:this.addOutput({address:this.refundVault,value:Number(r)}),this.addOutput({address:this.receiver,value:Number(this.requestedAmount)});case 14:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"internalBuildTransaction",value:(r=xy(Ty().mark((function t(e){var r,n,i,o,a,s=arguments;return Ty().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=s.length>1&&void 0!==s[1]&&s[1],n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);return e.addOutputs(i),t.prev=7,t.next=10,this.signInputs(e);case 10:return t.abrupt("return",this.finalizeTransactionInputs());case 13:t.prev=13,t.t0=t.catch(7),a=t.t0,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack));case 17:return t.abrupt("return",!1);case 18:case"end":return t.stop()}}),t,this,[[7,13]])}))),function(t){return r.apply(this,arguments)})},{key:"signInputs",value:(e=xy(Ty().mark((function t(e){return Ty().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:Ba(t.numsPoint),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var e=this.targetScriptRedeem;if(!e)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:Ba(t.numsPoint),network:this.network,scriptTree:this.scriptTree,redeem:e}}},{key:"getScriptSolution",value:function(t){return t.tapScriptSig?t.tapScriptSig.map((function(t){return t.signature})):[]}},{key:"getScriptTree",value:function(){return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:t.LOCK_LEAF_SCRIPT,version:192}]}},{key:"getTotalOutputAmount",value:function(t){var e,r=BigInt(0),n=Sy(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.value)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"calculateOutputLeftAmountFromVaults",value:function(t){return this.getTotalOutputAmount(t)-this.requestedAmount}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={output:t.LOCK_LEAF_SCRIPT,redeemVersion:192}}}],[{key:"fromBase64",value:function(e){var r=fa.fromBase64(e.psbt,{network:e.network});return new t(Py(Py({},e),{},{psbt:r}))}},{key:"verifyIfSigned",value:function(t,e){for(var r=!1,n=1;n<t.data.inputs.length;n++){var i=t.data.inputs[n];if(i.finalScriptWitness){var o=Th.readScriptWitnessToWitnessStack(i.finalScriptWitness);if(!(o.length<3))for(var a=0;a<o.length-2;a+=3)if(o[a+2].equals(e)){r=!0;break}}}return r}},{key:"signPartial",value:function(e,r,n,i){for(var o=!1,a=!0,s=n;s<e.data.inputs.length;s++){var u=e.data.inputs[s];u.tapInternalKey||(u.tapInternalKey=Ba(t.numsPoint));var c=[];if(u.finalScriptWitness){var f=Th.readScriptWitnessToWitnessStack(u.finalScriptWitness);u.tapLeafScript=[{leafVersion:192,script:f[f.length-2],controlBlock:f[f.length-1]}];for(var l=0;l<f.length-2;l+=3)c.push({signature:f[l],leafHash:f[l+1],pubkey:f[l+2]});u.tapScriptSig=(u.tapScriptSig||[]).concat(c)}delete u.finalScriptWitness;var h=t.signHashTypesArray?[t.calculateSignHash(t.signHashTypesArray)]:[];try{t.signInput(e,u,s,r,h),o=!0}catch(t){console.log(t)}if(o){if(!u.tapScriptSig)throw new Error("No new signatures for input");u.tapScriptSig.length!==i[s-n]&&(a=!1)}}return{signed:o,final:!!o&&a}}},{key:"dedupeSignatures",value:function(t,e){var r,n=new Map,i=Sy(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;n.set(o.pubkey.toString("hex"),o)}}catch(t){i.e(t)}finally{i.f()}var a,s=Sy(e);try{for(s.s();!(a=s.n()).done;){var u=a.value;n.has(u.pubkey.toString("hex"))||n.set(u.pubkey.toString("hex"),u)}}catch(t){s.e(t)}finally{s.f()}return Array.from(n.values())}},{key:"attemptFinalizeInputs",value:function(e,r,n,i){for(var o=0,a=function(a){try{var s=e.data.inputs[a];s.tapInternalKey||(s.tapInternalKey=Ba(t.numsPoint));var u=[];if(s.finalScriptWitness){for(var c=Th.readScriptWitnessToWitnessStack(s.finalScriptWitness),f=0;f<c.length-2;f+=3)u.push({signature:c[f],leafHash:c[f+1],pubkey:c[f+2]});s.tapLeafScript=[{leafVersion:192,script:c[c.length-2],controlBlock:c[c.length-1]}],s.tapScriptSig=t.dedupeSignatures(s.tapScriptSig||[],u)}delete s.finalScriptWitness,e.finalizeInput(a,(function(e,o){return t.partialFinalizer(e,o,[],n[a-r],i)})),o++}catch(t){}},s=r;s<e.data.inputs.length;s++)a(s);return o===e.data.inputs.length-r}}]);var e,r,n,i}();Ny(Uy,"LOCK_LEAF_SCRIPT",Pa.compile([Ta.OP_XOR,Ta.OP_NOP,Ta.OP_CODESEPARATOR])),Ny(Uy,"signHashTypesArray",[]),Ny(Uy,"numsPoint",_y.from("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex")),Ny(Uy,"partialFinalizer",(function(t,e,r,n,i){if(!e.tapLeafScript||!e.tapLeafScript[0].script||!e.tapLeafScript[0].controlBlock)throw new Error("Tap leaf script is required");if(!e.tapScriptSig)throw new Error("No new signatures for input ".concat(t,"."));var o=[];if(i){var a,s=Sy(n);try{for(s.s();!(a=s.n()).done;){var u,c=a.value,f=!1,l=Sy(e.tapScriptSig);try{for(l.s();!(u=l.n()).done;){var h=u.value;h.pubkey.equals(Ba(c))&&(o.push(h.signature),f=!0)}}catch(t){l.e(t)}finally{l.f()}f||o.push(_y.alloc(0))}}catch(t){s.e(t)}finally{s.f()}o=o.reverse()}else o=e.tapScriptSig.map((function(t){return[t.signature,t.leafHash,t.pubkey]})).flat();r.length>0&&(o=o.concat(r));var p=o.concat(e.tapLeafScript[0].script).concat(e.tapLeafScript[0].controlBlock);return{finalScriptWitness:Th.witnessStackToScriptWitness(p)}}));var Cy=i(8287).Buffer;function Fy(t){return Fy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fy(t)}function My(){My=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Fy(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Fy(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Dy(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ky(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Hy(t){return function(t){if(Array.isArray(t))return Gy(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ky(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ky(t,e){if(t){if("string"==typeof t)return Gy(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Gy(t,e):void 0}}function Gy(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Wy(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Vy(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Wy(o,n,i,a,s,"next",t)}function s(t){Wy(o,n,i,a,s,"throw",t)}a(void 0)}))}}function qy(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Yy(n.key),n)}}function zy(t,e,r){return(e=Yy(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Yy(t){var e=function(t){if("object"!=Fy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Fy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Fy(e)?e:e+""}var Xy=function(){return function(t,e){return e&&qy(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),zy(this,"utxoPath","address/utxos"),zy(this,"rpc","json-rpc"),this.opnetAPIUrl=e}),[{key:"fetchUTXO",value:(i=Vy(My().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h,p,d,y,g,b,v,w;return My().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e.usePendingUTXO&&(e.usePendingUTXO=!0),void 0===e.optimized&&(e.optimized=!0),n={method:"GET",headers:{"Content-Type":"application/json"}},i="".concat(this.opnetAPIUrl,"/api/v1/").concat(this.utxoPath,"?address=").concat(e.address,"&optimize=").concat(null!==(r=e.optimized)&&void 0!==r&&r),t.next=6,fetch(i,n);case 6:if((o=t.sent).ok){t.next=9;break}throw new Error("Failed to fetch UTXO data: ".concat(o.statusText));case 9:return t.next=11,o.json();case 11:a=t.sent,s=e.usePendingUTXO?[].concat(Hy(a.confirmed),Hy(a.pending)):a.confirmed,u=[],c=Dy(s),t.prev=15,l=My().mark((function t(){var e;return My().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=f.value,!a.spentTransactions.some((function(t){return t.transactionId===e.transactionId&&t.outputIndex===e.outputIndex}))){t.next=3;break}return t.abrupt("return",1);case 3:u.push(e);case 4:case"end":return t.stop()}}),t)})),c.s();case 18:if((f=c.n()).done){t.next=24;break}return t.delegateYield(l(),"t0",20);case 20:if(!t.t0){t.next=22;break}return t.abrupt("continue",22);case 22:t.next=18;break;case 24:t.next=29;break;case 26:t.prev=26,t.t1=t.catch(15),c.e(t.t1);case 29:return t.prev=29,c.f(),t.finish(29);case 32:if(0!==u.length){t.next=34;break}throw new Error("No UTXO found");case 34:if(h=u.filter((function(t){return BigInt(t.value)>=e.minAmount})),0!==h.length){t.next=37;break}throw new Error("No UTXO found (minAmount)");case 37:p=[],d=0n,y=e.requestedAmount,g=Dy(h),t.prev=41,g.s();case 43:if((b=g.n()).done){t.next=54;break}if(v=b.value,!((w=BigInt(v.value))<=0n)){t.next=48;break}return t.abrupt("continue",52);case 48:if(d+=w,p.push({transactionId:v.transactionId,outputIndex:v.outputIndex,value:w,scriptPubKey:v.scriptPubKey,nonWitnessUtxo:Cy.from(v.raw,"base64")}),!(d>y)){t.next=52;break}return t.abrupt("break",54);case 52:t.next=43;break;case 54:t.next=59;break;case 56:t.prev=56,t.t2=t.catch(41),g.e(t.t2);case 59:return t.prev=59,g.f(),t.finish(59);case 62:return t.abrupt("return",p);case 63:case"end":return t.stop()}}),t,this,[[15,26,29,32],[41,56,59,62]])}))),function(t){return i.apply(this,arguments)})},{key:"fetchUTXOMultiAddr",value:(n=Vy(My().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h,p;return My().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=[],n=Dy(e.addresses);try{for(n.s();!(i=n.n()).done;)o=i.value,a={address:o,minAmount:e.minAmount,requestedAmount:e.requestedAmount,optimized:e.optimized,usePendingUTXO:e.usePendingUTXO},s=this.fetchUTXO(a).catch((function(){return[]})),r.push(s)}catch(t){n.e(t)}finally{n.f()}return t.next=5,Promise.all(r);case 5:u=t.sent,c=u.flat(),f=[],l=0n,h=0;case 10:if(!(h<c.length)){t.next=19;break}if(p=c[h],!(l>=e.requestedAmount)){t.next=14;break}return t.abrupt("break",19);case 14:l+=p.value,f.push(p);case 16:h++,t.next=10;break;case 19:return t.abrupt("return",f);case 20:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"broadcastTransaction",value:(r=Vy(My().mark((function t(e,r){var n,i;return My().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[e,r],t.next=3,this.rpcMethod("btc_sendRawTransaction",n);case 3:if(i=t.sent){t.next=6;break}return t.abrupt("return");case 6:return t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e){return r.apply(this,arguments)})},{key:"splitUTXOs",value:(e=Vy(My().mark((function t(e,r,n,i){var o,a,s,u,c,f,l;return My().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o={addresses:[e.p2wpkh,e.p2tr],minAmount:330n,requestedAmount:1000000000000000n},t.next=3,this.fetchUTXOMultiAddr(o);case 3:if((a=t.sent)&&a.length){t.next=6;break}return t.abrupt("return",{error:"No UTXOs found"});case 6:return s=BigInt(n)*i,u={amount:s,feeRate:500,from:e.p2tr,utxos:a,signer:e.keypair,network:r,to:e.p2tr,splitInputsInto:n,priorityFee:330n},c=new my,t.next=11,c.createBTCTransfer(u);case 11:return f=t.sent,t.next=14,this.broadcastTransaction(f.tx,!1);case 14:if(l=t.sent){t.next=17;break}return t.abrupt("return",{error:"Could not broadcast transaction"});case 17:return t.abrupt("return",l);case 18:case"end":return t.stop()}}),t,this)}))),function(t,r,n,i){return e.apply(this,arguments)})},{key:"rpcMethod",value:(t=Vy(My().mark((function t(e,r){var n,i,o,a,s;return My().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:e,params:r,id:1})},i="".concat(this.opnetAPIUrl,"/api/v1/").concat(this.rpc),t.next=4,fetch(i,n);case 4:if((o=t.sent).ok){t.next=7;break}throw new Error("Failed to fetch to rpc: ".concat(o.statusText));case 7:return t.next=9,o.json();case 9:if(a=t.sent){t.next=12;break}throw new Error("No data fetched");case 12:if(s=a.result){t.next=15;break}throw new Error("No rpc parameters found");case 15:if(!("error"in s)){t.next=17;break}throw new Error("Error in fetching to rpc ".concat(s.error));case 17:return t.abrupt("return",s);case 18:case"end":return t.stop()}}),t,this)}))),function(e,r){return t.apply(this,arguments)})}]);var t,e,r,n,i}();function Zy(t){return Zy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Zy(t)}function $y(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Jy(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?$y(Object(r),!0).forEach((function(e){ng(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$y(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Qy(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ig(n.key),n)}}function tg(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(tg=function(){return!!t})()}function eg(t){return eg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},eg(t)}function rg(t,e){return rg=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},rg(t,e)}function ng(t,e,r){return(e=ig(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ig(t){var e=function(t){if("object"!=Zy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Zy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Zy(e)?e:e+""}var og,ag=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ng(r=function(t,e,r){return e=eg(e),function(t,e){if(e&&("object"==Zy(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,tg()?Reflect.construct(e,r||[],eg(t).constructor):e.apply(t,r))}(this,t,[e]),"logColor","#00ffe1"),ng(r,"feesAddition",10000n),ng(r,"sighashTypes",[]),r.signer=e.signer,r.network=e.network,r.transaction=e.psbt,r.ignoreSignatureError(),r.tweakSigner(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&rg(t,e)}(t,ch),function(t,e,r){return e&&Qy(t.prototype,e),r&&Qy(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"extractTransaction",value:function(){return this.transaction.extractTransaction()}},{key:"final",value:function(){return this.extractTransaction().toHex()}},{key:"toHex",value:function(){return this.transaction.toHex()}},{key:"addInput",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.transaction.addInput(t,e)}},{key:"addOutput",value:function(t){t.value&&this.transaction.addOutput(t)}},{key:"attemptFinalizeInputs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;try{for(var e=this.transaction.data.inputs,r=t;r<e.length;r++){var n=e[r];n.finalScriptWitness?this.transaction.finalizeTaprootInput(r,n.finalScriptWitness):this.transaction.finalizeInput(r)}return!0}catch(t){return this.warn(t.stack||"Couldn't finalize inputs"),!1}}},{key:"getPSBT",value:function(){return this.transaction}}],[{key:"fromBase64",value:function(e,r){var n=fa.fromBase64(e,{network:r.network});return new t(Jy(Jy({},r),{},{psbt:n}))}},{key:"fromHex",value:function(e,r){var n=fa.fromHex(e,{network:r.network});return new t(Jy(Jy({},r),{},{psbt:n}))}},{key:"from",value:function(e){var r=new fa({network:e.network});return new t(Jy(Jy({},e),{},{psbt:r}))}}])}();function sg(t){return sg="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},sg(t)}function ug(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,cg(n.key),n)}}function cg(t){var e=function(t){if("object"!=sg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sg(e)?e:e+""}!function(t){t[t.UNWRAP=0]="UNWRAP"}(og||(og={}));var fg=function(){return function(t,e,r){return r&&ug(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"generateMultiSigAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ka.bitcoin;if(Ec.verifyPubKeys(t,r).length!==t.length)throw new Error("Contains invalid public keys");var n=new Uy({network:r,utxos:[],pubkeys:t,minimumSignatures:e,feeRate:100,receiver:"a",requestedAmount:1n,refundVault:"a"}).getScriptAddress();if(!n)throw new Error("Failed to generate address");return n}}])}(),lg=i(2802),hg=i.n(lg);function pg(t){return pg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pg(t)}function dg(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,gg(n.key),n)}}function yg(t,e,r){return(e=gg(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function gg(t){var e=function(t){if("object"!=pg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=pg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pg(e)?e:e+""}var bg=function(){return function(t,e){return e&&dg(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),yg(this,"_keys",[]),yg(this,"_values",[])}),[{key:"size",get:function(){return this._keys.length}},{key:"keys",value:function(){return this._keys}},{key:"values",value:function(){return this._values}},{key:"entires",value:function(){for(var t=[],e=0;e<this._keys.length;e++)t.push([this._keys[e],this._values[e]]);return t}},{key:"set",value:function(t,e){var r=this.indexOf(t);-1==r?(this._keys.push(t),this._values.push(e)):this._values[r]=e}},{key:"indexOf",value:function(t){for(var e=0;e<this._keys.length;e++)if(this._keys[e]==t)return e;return-1}},{key:"get",value:function(t){var e=this.indexOf(t);if(-1!=e)return this._values[e]}},{key:"has",value:function(t){return-1!=this.indexOf(t)}},{key:"delete",value:function(t){var e=this.indexOf(t);return-1!=e&&(this._keys.splice(e,1),this._values.splice(e,1),!0)}},{key:"clear",value:function(){this._keys=[],this._values=[]}}])}();function vg(t){return vg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vg(t)}function wg(){wg=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==vg(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(vg(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function mg(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 _g(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_g(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Eg(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Sg(n.key),n)}}function Sg(t){var e=function(t){if("object"!=vg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=vg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==vg(e)?e:e+""}function kg(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(kg=function(){return!!t})()}function Tg(t){return Tg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Tg(t)}function Og(t,e){return Og=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Og(t,e)}var xg=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Tg(e),function(t,e){if(e&&("object"==vg(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,kg()?Reflect.construct(e,r||[],Tg(t).constructor):e.apply(t,r))}(this,t,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Og(t,e)}(t,bg),function(t,e){return e&&Eg(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"set",value:function(t,e){var r=this.indexOf(t);-1==r?(this._keys.push(t),this._values.push(e)):this._values[r]=e}},{key:"indexOf",value:function(t){for(var e=0;e<this._keys.length;e++){var r=this._keys[e];if(t.equals(r))return e}return-1}},{key:"has",value:function(t){for(var e=0;e<this._keys.length;e++)if(t.equals(this._keys[e]))return!0;return!1}},{key:"get",value:function(t){var e=this.indexOf(t);if(-1!=e)return this._values[e]}},{key:"delete",value:function(t){var e=this.indexOf(t);return-1!=e&&(this._keys.splice(e,1),this._values.splice(e,1),!0)}},{key:Symbol.iterator,value:wg().mark((function t(){var e,r,n;return wg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=mg(this._keys),t.prev=1,e.s();case 3:if((r=e.n()).done){t.next=9;break}return n=r.value,t.next=7,[n,this.get(n)];case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),e.e(t.t0);case 14:return t.prev=14,e.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])}))}])}();function Ag(t){return Ag="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},Ag(t)}function Pg(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,Ig(n.key),n)}}function Ig(t){var e=function(t){if("object"!=Ag(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ag(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ag(e)?e:e+""}var Lg=function(){return function(t,e,r){return e&&Pg(t.prototype,e),r&&Pg(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){(e=Ig(e))in t?Object.defineProperty(t,e,{value:0,enumerable:!0,configurable:!0,writable:!0}):t[e]=0}(this,"currentOffset"),this.buffer=new DataView(e.buffer,e.byteOffset,e.byteLength)}),[{key:"setBuffer",value:function(t){this.buffer=new DataView(t.buffer,t.byteOffset,t.byteLength),this.currentOffset=0}},{key:"readAddressArray",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readAddress();return e}},{key:"readU256Array",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU256();return e}},{key:"readU128Array",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU128();return e}},{key:"readU64Array",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU64();return e}},{key:"readU32Array",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU32();return e}},{key:"readU16Array",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU16();return e}},{key:"readU8Array",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU8();return e}},{key:"readStringArray",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readStringWithLength();return e}},{key:"readBytesArray",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readBytesWithLength();return e}},{key:"readBytesWithLength",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=this.readU32();if(t>0&&e>t)throw new Error("Data length exceeds maximum length.");return this.readBytes(e)}},{key:"readTuple",value:function(){for(var t=this.readU32(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU256();return e}},{key:"readU8",value:function(){this.verifyEnd(this.currentOffset+Rh);var t=this.buffer.getUint8(this.currentOffset);return this.currentOffset+=Rh,t}},{key:"readU16",value:function(){this.verifyEnd(this.currentOffset+Bh);var t=this.buffer.getUint16(this.currentOffset,!0);return this.currentOffset+=Bh,t}},{key:"readU32",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.verifyEnd(this.currentOffset+Lh);var e=this.buffer.getUint32(this.currentOffset,t);return this.currentOffset+=Lh,e}},{key:"readU64",value:function(){this.verifyEnd(this.currentOffset+Ih);var t=this.buffer.getBigUint64(this.currentOffset,!0);return this.currentOffset+=Ih,t}},{key:"readAddressValueTuple",value:function(){for(var t=this.readU16(),e=new xg,r=0;r<t;r++){var n=this.readAddress(),i=this.readU256();if(e.has(n))throw new Error("Duplicate address found in map");e.set(n,i)}return e}},{key:"readU128",value:function(){var t=this.readBytes(Ph);return BigInt("0x"+t.reduce((function(t,e){return t+e.toString(16).padStart(2,"0")}),""))}},{key:"readU256",value:function(){var t=this.readBytes(Ah);return BigInt("0x"+t.reduce((function(t,e){return t+e.toString(16).padStart(2,"0")}),""))}},{key:"readBytes",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new Uint8Array(t),n=0;n<t;n++){var i=this.readU8();if(e&&0===i){r=r.slice(0,n);break}r[n]=i}return r}},{key:"readString",value:function(t){var e=new TextDecoder,r=this.readBytes(t,!0);return e.decode(r)}},{key:"readSelector",value:function(){return this.readU32(!1)}},{key:"readStringWithLength",value:function(){var t=this.readU16();return this.readString(t)}},{key:"readBoolean",value:function(){return 0!==this.readU8()}},{key:"readAddress",value:function(){for(var t=new Array(Oh),e=0;e<Oh;e++)t[e]=this.readU8();return new _p(t)}},{key:"getOffset",value:function(){return this.currentOffset}},{key:"setOffset",value:function(t){this.currentOffset=t}},{key:"verifyEnd",value:function(t){if(this.currentOffset>this.buffer.byteLength)throw new Error("Expected to read ".concat(t," bytes but read ").concat(this.currentOffset," bytes"))}}],[{key:"stringCompare",value:function(t,e){return t.localeCompare(e)}},{key:"bigintCompare",value:function(t,e){return t<e?-1:t>e?1:0}},{key:"numberCompare",value:function(t,e){return t<e?-1:t>e?1:0}}])}(),Bg=i(8287).Buffer;function Rg(t){return Rg="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},Rg(t)}function Ng(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jg(n.key),n)}}function jg(t){var e=function(t){if("object"!=Rg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Rg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Rg(e)?e:e+""}var Ug,Cg=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&Ng(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"bufferToUint8Array",value:function(t){if(Bg.isBuffer(t)){for(var e=t.byteLength,r=new ArrayBuffer(e),n=new Uint8Array(r),i=0;i<e;++i)n[i]=t[i];return n}return t}},{key:"uint8ArrayToHex",value:function(t){return Bg.from(t.buffer,0,t.byteLength).toString("hex")}},{key:"hexToUint8Array",value:function(t){t.startsWith("0x")&&(t=t.substring(2)),t.length%2!=0&&(t="0"+t);for(var e=t.length/2,r=new Uint8Array(e),n=0;n<e;n++)r[n]=parseInt(t.substring(2*n,2*n+2),16);return r}},{key:"pointerToUint8Array",value:function(e){var r=e.toString(16).padStart(64,"0");return t.hexToUint8Array(r)}},{key:"uint8ArrayToPointer",value:function(e){var r=t.uint8ArrayToHex(e);return BigInt("0x"+r)}},{key:"valueToUint8Array",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ah,n=e.toString(16).padStart(2*r,"0");return t.hexToUint8Array(n)}},{key:"uint8ArrayToValue",value:function(e){var r=t.uint8ArrayToHex(e);return r?BigInt("0x"+r):BigInt(0)}}])}();function Fg(t){return Fg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fg(t)}function Mg(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Dg(n.key),n)}}function Dg(t){var e=function(t){if("object"!=Fg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Fg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Fg(e)?e:e+""}!function(t,e){(e=jg(e))in t?Object.defineProperty(t,e,{value:32,enumerable:!0,configurable:!0,writable:!0}):t[e]=32}(Cg,"EXPECTED_BUFFER_LENGTH"),function(t){t.UINT8="UINT8",t.UINT16="UINT16",t.UINT32="UINT32",t.UINT64="UINT64",t.UINT128="UINT128",t.UINT256="UINT256",t.BOOL="BOOL",t.ADDRESS="ADDRESS",t.STRING="STRING",t.BYTES32="BYTES32",t.TUPLE="TUPLE",t.BYTES="BYTES",t.ADDRESS_UINT256_TUPLE="ADDRESS_UINT256_TUPLE",t.ARRAY_OF_ADDRESSES="ARRAY_OF_ADDRESSES",t.ARRAY_OF_UINT256="ARRAY_OF_UINT256",t.ARRAY_OF_UINT128="ARRAY_OF_UINT128",t.ARRAY_OF_UINT64="ARRAY_OF_UINT64",t.ARRAY_OF_UINT32="ARRAY_OF_UINT32",t.ARRAY_OF_UINT16="ARRAY_OF_UINT16",t.ARRAY_OF_UINT8="ARRAY_OF_UINT8",t.ARRAY_OF_STRING="ARRAY_OF_STRING",t.ARRAY_OF_BYTES="ARRAY_OF_BYTES"}(Ug||(Ug={}));var Hg=function(){return function(t,e){return e&&Mg(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),[{key:"decodeData",value:function(t,e){for(var r=new Lg(t),n=[],i=0;i<e.length;i++)switch(e[i]){case Ug.UINT8:n.push(r.readU8());break;case Ug.UINT16:n.push(r.readU16());break;case Ug.UINT32:n.push(r.readU32());break;case Ug.BYTES32:n.push(r.readBytes(32));break;case Ug.BOOL:n.push(r.readBoolean());break;case Ug.ADDRESS:n.push(r.readAddress());break;case Ug.STRING:n.push(r.readStringWithLength());break;case Ug.UINT128:n.push(r.readU128());break;case Ug.UINT256:n.push(r.readU256());break;case Ug.TUPLE:n.push(r.readTuple());break;case Ug.ADDRESS_UINT256_TUPLE:n.push(r.readAddressValueTuple());break;case Ug.BYTES:n.push(r.readBytesWithLength());break;case Ug.UINT64:n.push(r.readU64());break;case Ug.ARRAY_OF_ADDRESSES:n.push(r.readAddressArray());break;case Ug.ARRAY_OF_UINT256:n.push(r.readU256Array());break;case Ug.ARRAY_OF_UINT128:n.push(r.readU128Array());break;case Ug.ARRAY_OF_UINT64:n.push(r.readU64Array());break;case Ug.ARRAY_OF_UINT32:n.push(r.readU32Array());break;case Ug.ARRAY_OF_UINT16:n.push(r.readU16Array());break;case Ug.ARRAY_OF_UINT8:n.push(r.readU8Array());break;case Ug.ARRAY_OF_STRING:n.push(r.readStringArray());break;case Ug.ARRAY_OF_BYTES:n.push(r.readBytesArray())}return n}},{key:"encodeSelector",value:function(t){return this.sha256(t).subarray(0,4).toString("hex")}},{key:"numericSelectorToHex",value:function(t){return t.toString(16)}},{key:"bigIntToUint8Array",value:function(t,e){for(var r=new Uint8Array(e),n=Cg.valueToUint8Array(t),i=0;i<e;i++)r[i]=n[i]||0;return r}},{key:"sha256",value:function(t){return(new(hg().sha256)).update(t).digest()}}])}();function Kg(t){return Kg="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},Kg(t)}function Gg(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,Wg(n.key),n)}}function Wg(t){var e=function(t){if("object"!=Kg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Kg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kg(e)?e:e+""}var Vg=function(){return function(t,e){return e&&Gg(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){(e=Wg(e))in t?Object.defineProperty(t,e,{value:0,enumerable:!0,configurable:!0,writable:!0}):t[e]=0}(this,"currentOffset"),this.buffer=this.getDefaultBuffer(e)}),[{key:"writeU8",value:function(t){if(t>255)throw new Error("Value is too large.");this.allocSafe(Rh),this.buffer.setUint8(this.currentOffset++,t)}},{key:"writeU16",value:function(t){if(t>65535)throw new Error("Value is too large.");this.allocSafe(Bh),this.buffer.setUint16(this.currentOffset,t,!0),this.currentOffset+=2}},{key:"writeU32",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>4294967295)throw new Error("Value is too large.");this.allocSafe(Lh),this.buffer.setUint32(this.currentOffset,t,e),this.currentOffset+=4}},{key:"writeU64",value:function(t){if(t>18446744073709551615n)throw new Error("Value is too large.");this.allocSafe(Ih),this.buffer.setBigUint64(this.currentOffset,t,!0),this.currentOffset+=8}},{key:"writeSelector",value:function(t){this.writeU32(t,!1)}},{key:"writeBoolean",value:function(t){this.writeU8(t?1:0)}},{key:"writeU256",value:function(t){if(t>115792089237316195423570985008687907853269984665640564039457584007913129639935n)throw new Error("Value is too large.");this.allocSafe(Ah);var e=Cg.valueToUint8Array(t);if(e.byteLength!==Ah)throw new Error("Invalid u256 value: ".concat(t));for(var r=0;r<e.byteLength;r++)this.writeU8(e[r])}},{key:"writeU128",value:function(t){if(t>340282366920938463463374607431768211455n)throw new Error("Value is too large.");this.allocSafe(Ph);var e=Cg.valueToUint8Array(t,Ph);if(e.byteLength!==Ph)throw new Error("Invalid u128 value: ".concat(t));for(var r=0;r<e.byteLength;r++)this.writeU8(e[r])}},{key:"writeBytes",value:function(t){this.allocSafe(t.byteLength);for(var e=0;e<t.byteLength;e++)this.writeU8(t[e])}},{key:"writeString",value:function(t){this.allocSafe(t.length);for(var e=0;e<t.length;e++)this.writeU8(t.charCodeAt(e))}},{key:"writeAddress",value:function(t){this.verifyAddress(t),this.writeBytes(t)}},{key:"writeStringWithLength",value:function(t){this.allocSafe(Bh+t.length),this.writeU16(t.length),this.writeString(t)}},{key:"getBuffer",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=new Uint8Array(this.buffer.byteLength),r=0;r<this.buffer.byteLength;r++)e[r]=this.buffer.getUint8(r);return t&&this.clear(),e}},{key:"reset",value:function(){this.currentOffset=0,this.buffer=this.getDefaultBuffer(4)}},{key:"writeTuple",value:function(t){this.allocSafe(Lh+t.length*Ah),this.writeU32(t.length);for(var e=0;e<t.length;e++)this.writeU256(t[e])}},{key:"toBytesReader",value:function(){return new Lg(this.getBuffer())}},{key:"getOffset",value:function(){return this.currentOffset}},{key:"setOffset",value:function(t){this.currentOffset=t}},{key:"clear",value:function(){this.currentOffset=0,this.buffer=this.getDefaultBuffer()}},{key:"allocSafe",value:function(t){this.currentOffset+t>this.buffer.byteLength&&this.resize(t)}},{key:"writeABISelector",value:function(t,e){this.writeStringWithLength(t),this.writeSelector(e)}},{key:"writeAddressValueTupleMap",value:function(t){if(t.size>65535)throw new Error("Map size is too large");this.writeU16(t.size);for(var e=Array.from(t.keys()),r=0;r<e.length;r++){var n=e[r],i=t.get(n);if(null==i)throw new Error("Value not found");this.writeAddress(n),this.writeU256(i)}}},{key:"writeLimitedAddressBytesMap",value:function(t){if(t.size>8)throw new Error("Too many contract calls");this.writeU8(t.size);for(var e=Array.from(t.keys()),r=0;r<e.length;r++){var n=e[r],i=t.get(n);if(!i)throw new Error("Calls not found");if(i.length>10)throw new Error("Too many calls.");this.writeAddress(n),this.writeU8(i.length);for(var o=0;o<i.length;o++)this.writeBytesWithLength(i[o])}}},{key:"writeBytesWithLength",value:function(t){this.writeU32(t.length),this.writeBytes(t)}},{key:"writeAddressArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeAddress(t[e])}},{key:"writeU32Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU32(t[e])}},{key:"writeU256Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU256(t[e])}},{key:"writeU128Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU128(t[e])}},{key:"writeStringArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeStringWithLength(t[e])}},{key:"writeU16Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU16(t[e])}},{key:"writeU8Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU8(t[e])}},{key:"writeU64Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU64(t[e])}},{key:"writeBytesArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeBytesWithLength(t[e])}},{key:"writeSelectorArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeSelector(t[e])}},{key:"getChecksum",value:function(){for(var t=0,e=0;e<this.buffer.byteLength;e++)t+=this.buffer.getUint8(e);return t%Math.pow(2,32)}},{key:"writeMethodSelectorMap",value:function(t){var e=this;this.writeU16(t.size),t.forEach((function(t,r,n){e.writeSelector(t)}))}},{key:"verifyAddress",value:function(t){if(t.byteLength>Oh)throw new Error("Address is too long ".concat(t.byteLength," > ").concat(Oh," bytes"))}},{key:"resize",value:function(t){for(var e=new Uint8Array(this.buffer.byteLength+t),r=0;r<this.buffer.byteLength;r++)e[r]=this.buffer.getUint8(r);this.buffer=new DataView(e.buffer,e.byteOffset,e.byteLength)}},{key:"getDefaultBuffer",value:function(){return new DataView(new ArrayBuffer(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0))}}])}();function qg(t){return qg="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},qg(t)}function zg(){zg=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==qg(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(qg(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Yg(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,Xg(n.key),n)}}function Xg(t){var e=function(t){if("object"!=qg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=qg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qg(e)?e:e+""}var Zg=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.keys=e}return function(t,e){return e&&Yg(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"size",get:function(){return this.keys.length}},{key:"add",value:function(t){this.has(t)||this.keys.push(t)}},{key:"has",value:function(t){for(var e=0;e<this.keys.length;e++)if(this.keys[e].equals(t))return!0;return!1}},{key:"remove",value:function(t){var e=this.keys.findIndex((function(e){return e.equals(t)}));-1!==e&&this.keys.splice(e,1)}},{key:"clone",value:function(){for(var e=new t,r=0;r<this.keys.length;r++)e.add(this.keys[r]);return e}},{key:"clear",value:function(){this.keys=[]}},{key:"combine",value:function(t){for(var e=this.clone(),r=0;r<t.keys.length;r++)e.add(t.keys[r]);return e}},{key:Symbol.iterator,value:zg().mark((function t(){var e;return zg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=0;case 1:if(!(e<this.keys.length)){t.next=7;break}return t.next=4,this.keys[e];case 4:e++,t.next=1;break;case 7:case"end":return t.stop()}}),t,this)}))}])}();function $g(t){return $g="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},$g(t)}function Jg(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,c=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||eb(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qg(){Qg=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==$g(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError($g(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function tb(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=eb(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function eb(t,e){if(t){if("string"==typeof t)return rb(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?rb(t,e):void 0}}function rb(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function nb(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,ib(n.key),n)}}function ib(t){var e=function(t){if("object"!=$g(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=$g(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$g(e)?e:e+""}function ob(t,e){return t.get(sb(t,e))}function ab(t,e,r){return t.set(sb(t,e),r),r}function sb(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}var ub=new WeakMap,cb=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}(this,ub,void 0),this.compareFn=e,this.map=new Map,ab(ub,this,[])}return function(t,e,r){return e&&nb(t.prototype,e),r&&nb(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"size",get:function(){return this.map.size}},{key:"set",value:function(t,e){this.map.has(t)||(ob(ub,this).push(t),ob(ub,this).sort(this.compareFn)),this.map.set(t,e)}},{key:"get",value:function(t){return this.map.get(t)}},{key:"keys",value:function(){return ob(ub,this).values()}},{key:"values",value:function(){for(var t=[],e=0;e<ob(ub,this).length;e++){var r=ob(ub,this)[e],n=this.map.get(r);if(!n)throw new Error("Value not found");t.push(n)}return t.values()}},{key:"has",value:function(t){return this.map.has(t)}},{key:"delete",value:function(t){return!!this.map.has(t)&&(this.map.delete(t),ab(ub,this,ob(ub,this).filter((function(e){return e!==t}))),!0)}},{key:"clear",value:function(){this.map.clear(),ab(ub,this,[])}},{key:"forEach",value:function(t){var e,r=tb(ob(ub,this));try{for(r.s();!(e=r.n()).done;){var n=e.value;t(this.map.get(n),n,this)}}catch(t){r.e(t)}finally{r.f()}}},{key:Symbol.iterator,value:Qg().mark((function t(){var e,r,n;return Qg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=tb(ob(ub,this)),t.prev=1,e.s();case 3:if((r=e.n()).done){t.next=9;break}return n=r.value,t.next=7,[n,this.map.get(n)];case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),e.e(t.t0);case 14:return t.prev=14,e.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])}))}],[{key:"fromMap",value:function(e,r){var n,i=new t(r),o=tb(e);try{for(o.s();!(n=o.n()).done;){var a=Jg(n.value,2),s=a[0],u=a[1];i.set(s,u)}}catch(t){o.e(t)}finally{o.f()}return i}}])}();function fb(t){return fb="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},fb(t)}function lb(){lb=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==fb(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(fb(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function hb(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 pb(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?pb(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function pb(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function db(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,yb(n.key),n)}}function yb(t){var e=function(t){if("object"!=fb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=fb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fb(e)?e:e+""}var gb=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.compareFn=e,this.elements=[]}return function(t,e,r){return e&&db(t.prototype,e),r&&db(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"add",value:function(t){this.elements.includes(t)||(this.elements.push(t),this.elements.sort(this.compareFn))}},{key:"delete",value:function(t){var e=this.elements.indexOf(t);return-1!==e&&(this.elements.splice(e,1),!0)}},{key:"has",value:function(t){return this.elements.includes(t)}},{key:"clear",value:function(){this.elements=[]}},{key:"forEach",value:function(t){var e,r=hb(this.elements);try{for(r.s();!(e=r.n()).done;)t(e.value,this)}catch(t){r.e(t)}finally{r.f()}}},{key:"size",get:function(){return this.elements.length}},{key:Symbol.iterator,value:lb().mark((function(){var t,e,r;return lb().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:t=hb(this.elements),n.prev=1,t.s();case 3:if((e=t.n()).done){n.next=9;break}return r=e.value,n.next=7,r;case 7:n.next=3;break;case 9:n.next=14;break;case 11:n.prev=11,n.t0=n.catch(1),t.e(n.t0);case 14:return n.prev=14,t.f(),n.finish(14);case 17:case"end":return n.stop()}}),r,this,[[1,11,14,17]])}))}],[{key:"fromSet",value:function(e,r){var n,i=new t(r),o=hb(e);try{for(o.s();!(n=o.n()).done;){var a=n.value;i.add(a)}}catch(t){o.e(t)}finally{o.f()}return i}}])}();function bb(t){return bb="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},bb(t)}function vb(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,mb(n.key),n)}}function wb(t,e,r){return e&&vb(t.prototype,e),r&&vb(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function mb(t){var e=function(t){if("object"!=bb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=bb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==bb(e)?e:e+""}var _b=wb((function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.type=e,this.data=r}));function Eb(t){return Eb="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},Eb(t)}function Sb(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,Tb(n.key),n)}}function kb(t,e,r){return e&&Sb(t.prototype,e),r&&Sb(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Tb(t){var e=function(t){if("object"!=Eb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Eb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Eb(e)?e:e+""}var Ob,xb,Ab,Pb=kb((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}));!function(t){t.testnet="testnet",t.mainnet="livenet",t.regtest="regtest"}(Ob||(Ob={})),function(t){t.BITCOIN_MAINNET="BITCOIN_MAINNET",t.BITCOIN_TESTNET="BITCOIN_TESTNET",t.BITCOIN_TESTNET4="BITCOIN_TESTNET4",t.BITCOIN_REGTEST="BITCOIN_REGTEST",t.BITCOIN_SIGNET="BITCOIN_SIGNET",t.FRACTAL_BITCOIN_MAINNET="FRACTAL_BITCOIN_MAINNET",t.FRACTAL_BITCOIN_TESTNET="FRACTAL_BITCOIN_TESTNET"}(xb||(xb={})),function(t){t.ecdsa="ecdsa",t.bip322="bip322-simple"}(Ab||(Ab={}));var Ib=i(8287).Buffer;function Lb(t){return Lb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lb(t)}function Bb(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 Rb(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rb(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Rb(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Nb(){Nb=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Lb(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Lb(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function jb(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ub(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){jb(o,n,i,a,s,"next",t)}function s(t){jb(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Cb(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,Hb(n.key),n)}}function Fb(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Fb=function(){return!!t})()}function Mb(t){return Mb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Mb(t)}function Db(t,e){return Db=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Db(t,e)}function Hb(t){var e=function(t){if("object"!=Lb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Lb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lb(e)?e:e+""}var Kb=function(){function t(){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=Hb(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(e=function(t,e,r){return e=Mb(e),function(t,e){if(e&&("object"==Lb(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Fb()?Reflect.construct(e,r||[],Mb(t).constructor):e.apply(t,r))}(this,t),"isInitialized",!1),!window)throw new Error("UnisatSigner can only be used in a browser environment");return e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Db(t,e)}(t,Pb),function(t,e){return e&&Cb(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"p2tr",get:function(){if(!this._p2tr)throw new Error("P2TR address not set");return this._p2tr}},{key:"p2wpkh",get:function(){if(!this._p2wpkh)throw new Error("P2PKH address not set");return this._p2wpkh}},{key:"addresses",get:function(){if(!this._addresses)throw new Error("Addresses not set");return this._addresses}},{key:"publicKey",get:function(){if(!this._publicKey)throw new Error("Public key not set");return this._publicKey}},{key:"network",get:function(){if(!this._network)throw new Error("Network not set");return this._network}},{key:"unisat",get:function(){var t=window.opnet||window.unisat;if(!t)throw new Error("OPWallet extension not found");return t}},{key:"init",value:(o=Ub(Nb().mark((function t(){var e,r;return Nb().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isInitialized){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this.unisat.getNetwork();case 4:e=t.sent,t.t0=e,t.next=t.t0===Ob.mainnet?8:t.t0===Ob.testnet?10:t.t0===Ob.regtest?12:14;break;case 8:return this._network=ka.bitcoin,t.abrupt("break",15);case 10:return this._network=ka.testnet,t.abrupt("break",15);case 12:return this._network=ka.regtest,t.abrupt("break",15);case 14:throw new Error("Invalid network: ".concat(e));case 15:return t.next=17,this.unisat.getPublicKey();case 17:r=t.sent,this._publicKey=Ib.from(r,"hex"),this._p2wpkh=Ec.getP2WPKHAddress(this,this.network),this._p2tr=Ec.getTaprootAddress(this,this.network),this._addresses=[this._p2wpkh,this._p2tr],this.isInitialized=!0;case 23:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"getPublicKey",value:function(){if(!this.isInitialized)throw new Error("UnisatSigner not initialized");return this.publicKey}},{key:"sign",value:function(t,e){throw new Error("Not implemented: sign")}},{key:"signSchnorr",value:function(t){throw new Error("Not implemented: signSchnorr")}},{key:"verify",value:function(t,e){throw new Error("Not implemented: verify")}},{key:"signTaprootInput",value:(i=Ub(Nb().mark((function t(e,r,n){var i,o;return Nb().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,this.signAllTweaked(e,n,!1);case 5:o=t.sent,this.combine(e,o,r);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return i.apply(this,arguments)})},{key:"signInput",value:(n=Ub(Nb().mark((function t(e,r,n){var i,o;return Nb().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,this.signAllTweaked(e,n,!0);case 5:o=t.sent,this.combine(e,o,r);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return n.apply(this,arguments)})},{key:"multiSignPsbt",value:(r=Ub(Nb().mark((function t(e){var r,n,i,o,a,s,u,c,f,l=this;return Nb().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=[],n=[],i=Bb(e);try{for(i.s();!(o=i.n()).done;)a=o.value,s=a.toHex(),r.push(s),u=a.data.inputs.map((function(t,e){var r=!1,n=!1;if(Wl(t)){if(t.tapLeafScript&&t.tapLeafScript.length>0){var i,o=Bb(t.tapLeafScript);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(-1!==function(t,e){var r=pa.hash160(t),n=Ba(t),i=Pa.decompile(e);if(null===i)throw new Error("Unknown script error");return i.findIndex((function(e){return"number"!=typeof e&&Ib.isBuffer(e)&&(e.equals(t)||e.equals(r)||e.equals(n))}))}(l.publicKey,a.script)){r=!0,n=!1;break}}}catch(t){o.e(t)}finally{o.f()}}if(!r&&t.tapInternalKey){var s=t.tapInternalKey,u=Ba(l.publicKey);s.equals(u)&&(r=!0,n=!0)}}else Vl(t,l.publicKey)&&(r=!0,n=!1);return r?{index:e,publicKey:l.publicKey.toString("hex"),disableTweakSigner:!n}:null})).filter((function(t){return null!==t})),n.push({autoFinalized:!1,toSignInputs:u})}catch(t){i.e(t)}finally{i.f()}return t.next=6,this.unisat.signPsbt(r[0],n[0]);case 6:c=t.sent,f=fa.fromHex(c),e[0].combine(f);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"hasAlreadySignedTapScriptSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(Ib.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"hasAlreadyPartialSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(Ib.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"combine",value:function(t,e,r){var n,i=e.data.inputs[r],o=t.data.inputs[r];if(i.partialSig&&t.updateInput(r,{partialSig:i.partialSig}),i.tapKeySig&&!o.tapKeySig&&t.updateInput(r,{tapKeySig:i.tapKeySig}),null!==(n=i.tapScriptSig)&&void 0!==n&&n.length){var a=o.tapScriptSig;if(a){var s=this.getNonDuplicateScriptSig(a,i.tapScriptSig);s.length&&t.updateInput(r,{tapScriptSig:s})}else t.updateInput(r,{tapScriptSig:i.tapScriptSig})}}},{key:"signAllTweaked",value:(e=Ub(Nb().mark((function t(e,r){var n,i,o,a,s,u,c=arguments;return Nb().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.length>2&&void 0!==c[2]&&c[2],i=this.publicKey.toString("hex"),o=e.data.inputs.map((function(t,e){return[{index:e,publicKey:i,sighashTypes:r,disableTweakSigner:n}]})),a={autoFinalized:!1,toSignInputs:o.flat()},s=e.toHex(),t.next=7,this.unisat.signPsbt(s,a);case 7:return u=t.sent,t.abrupt("return",fa.fromHex(u));case 9:case"end":return t.stop()}}),t,this)}))),function(t,r){return e.apply(this,arguments)})},{key:"getNonDuplicateScriptSig",value:function(t,e){for(var r=[],n=function(n){t.find((function(t){return t.pubkey.equals(e[n].pubkey)}))||r.push(e[n])},i=0;i<e.length;i++)n(i);return r}}]);var e,r,n,i,o}(),Gb=i(8287).Buffer;function Wb(t){return Wb="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},Wb(t)}function Vb(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 qb(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qb(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function qb(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function zb(){zb=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Wb(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Wb(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Yb(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Xb(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Yb(o,n,i,a,s,"next",t)}function s(t){Yb(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Zb(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,tv(n.key),n)}}function $b(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return($b=function(){return!!t})()}function Jb(t){return Jb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Jb(t)}function Qb(t,e){return Qb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Qb(t,e)}function tv(t){var e=function(t){if("object"!=Wb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Wb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Wb(e)?e:e+""}var ev,rv=function(){function t(){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=tv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(e=function(t,e,r){return e=Jb(e),function(t,e){if(e&&("object"==Wb(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,$b()?Reflect.construct(e,r||[],Jb(t).constructor):e.apply(t,r))}(this,t),"isInitialized",!1),!window)throw new Error("XverseSigner can only be used in a browser environment");return e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Qb(t,e)}(t,Pb),function(t,e){return e&&Zb(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"p2tr",get:function(){if(!this._p2tr)throw new Error("P2TR address not set");return this._p2tr}},{key:"p2wpkh",get:function(){if(!this._p2wpkh)throw new Error("P2PKH address not set");return this._p2wpkh}},{key:"addresses",get:function(){if(!this._addresses)throw new Error("Addresses not set");return this._addresses}},{key:"publicKey",get:function(){if(!this._publicKey)throw new Error("Public key not set");return this._publicKey}},{key:"network",get:function(){if(!this._network)throw new Error("Network not set");return this._network}},{key:"BitcoinProvider",get:function(){var t=window.BitcoinProvider;if(!t)throw new Error("Xverse Wallet extension not found");return t}},{key:"init",value:(o=Xb(zb().mark((function t(){var e,r,n;return zb().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isInitialized){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this.BitcoinProvider.request("wallet_connect",null);case 4:if(!("error"in(e=t.sent))){t.next=7;break}throw new Error(e.error.message);case 7:if(r=e.result.addresses.find((function(t){return"payment"===t.purpose}))){t.next=10;break}throw new Error("Payment address not found");case 10:if(n=r.address.startsWith("tb")?ka.testnet:r.address.startsWith("bc")?ka.bitcoin:null){t.next=13;break}throw new Error("Network not supported");case 13:this._network=n,this._publicKey=Gb.from(r.publicKey,"hex"),this._p2wpkh=Ec.getP2WPKHAddress(this,this.network),this._p2tr=Ec.getTaprootAddress(this,this.network),this._addresses=[this._p2wpkh,this._p2tr],this.isInitialized=!0;case 19:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"getPublicKey",value:function(){if(!this.isInitialized)throw new Error("UnisatSigner not initialized");return this.publicKey}},{key:"sign",value:function(t,e){throw new Error("Not implemented: sign")}},{key:"signSchnorr",value:function(t){throw new Error("Not implemented: signSchnorr")}},{key:"verify",value:function(t,e){throw new Error("Not implemented: verify")}},{key:"signTaprootInput",value:(i=Xb(zb().mark((function t(e,r,n){var i,o;return zb().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,this.signAllTweaked(e,n,!1);case 5:o=t.sent,this.combine(e,o,r);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return i.apply(this,arguments)})},{key:"signInput",value:(n=Xb(zb().mark((function t(e,r,n){var i,o;return zb().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,this.signAllTweaked(e,n,!0);case 5:o=t.sent,this.combine(e,o,r);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return n.apply(this,arguments)})},{key:"multiSignPsbt",value:(r=Xb(zb().mark((function t(e){var r,n,i,o,a,s,u,c,f,l=this;return zb().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=[],n=[],i=Vb(e);try{for(i.s();!(o=i.n()).done;)a=o.value,s=a.toHex(),r.push(s),u=a.data.inputs.map((function(t,e){var r=!1,n=!1;if(Wl(t)){if(t.tapLeafScript&&t.tapLeafScript.length>0){var i,o=Vb(t.tapLeafScript);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(ql(l.publicKey,a.script)){r=!0,n=!1;break}}}catch(t){o.e(t)}finally{o.f()}}if(!r&&t.tapInternalKey){var s=t.tapInternalKey,u=Ba(l.publicKey);s.equals(u)&&(r=!0,n=!0)}}else Vl(t,l.publicKey)&&(r=!0,n=!1);return r?{index:e,publicKey:l.publicKey.toString("hex"),disableTweakSigner:!n}:null})).filter((function(t){return null!==t})),n.push({autoFinalized:!1,toSignInputs:u})}catch(t){i.e(t)}finally{i.f()}return t.next=6,this.BitcoinProvider.request("signPsbt",{psbt:r[0],signInputs:n[0].toSignInputs});case 6:if(!("error"in(c=t.sent))){t.next=9;break}throw new Error(c.error.message);case 9:f=fa.fromBase64(c.result.psbt),e[0].combine(f);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"hasAlreadySignedTapScriptSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(Gb.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"hasAlreadyPartialSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(Gb.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"combine",value:function(t,e,r){var n,i=e.data.inputs[r],o=t.data.inputs[r];if(i.partialSig&&t.updateInput(r,{partialSig:i.partialSig}),i.tapKeySig&&!o.tapKeySig&&t.updateInput(r,{tapKeySig:i.tapKeySig}),null!==(n=i.tapScriptSig)&&void 0!==n&&n.length){var a=o.tapScriptSig;if(a){var s=this.getNonDuplicateScriptSig(a,i.tapScriptSig);s.length&&t.updateInput(r,{tapScriptSig:s})}else t.updateInput(r,{tapScriptSig:i.tapScriptSig})}}},{key:"signAllTweaked",value:(e=Xb(zb().mark((function t(e,r){var n,i,o,a,s,u,c=arguments;return zb().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.length>2&&void 0!==c[2]&&c[2],i=this.publicKey.toString("hex"),o=e.data.inputs.map((function(t,e){return[{index:e,publicKey:i,sighashTypes:r,disableTweakSigner:n}]})),a={autoFinalized:!1,toSignInputs:o.flat()},s=e.toBase64(),t.next=7,this.BitcoinProvider.request("signPsbt",{psbt:s,signInputs:a.toSignInputs});case 7:if(!("error"in(u=t.sent))){t.next=10;break}throw new Error(u.error.message);case 10:return t.abrupt("return",fa.fromBase64(u.result.psbt));case 11:case"end":return t.stop()}}),t,this)}))),function(t,r){return e.apply(this,arguments)})},{key:"getNonDuplicateScriptSig",value:function(t,e){for(var r=[],n=function(n){t.find((function(t){return t.pubkey.equals(e[n].pubkey)}))||r.push(e[n])},i=0;i<e.length;i++)n(i);return r}}]);var e,r,n,i,o}();function nv(t){return nv="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},nv(t)}function iv(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,av(n.key),n)}}function ov(t,e,r){return(e=av(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function av(t){var e=function(t){if("object"!=nv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=nv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==nv(e)?e:e+""}function sv(){return _p.dead()}!function(t){t.mainnet="mainnet",t.testnet="testnet",t.signet="Signet"}(ev||(ev={}));var uv,cv=sv(),fv=sv(),lv=sv(),hv=sv(),pv=sv(),dv=sv(),yv=sv(),gv=sv(),bv=sv(),vv=sv(),wv=sv(),mv=sv(),_v=sv(),Ev=sv(),Sv=sv();!function(t){t.Mainnet="mainnet",t.Testnet="testnet",t.Regtest="regtest"}(uv||(uv={}));var kv=function(){return function(t,e){return e&&iv(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ov(this,"metadata",ov(ov({},Dp.Bitcoin,ov(ov({},uv.Testnet,{factory:dv,pool:yv,wbtc:gv,moto:bv,router:vv}),uv.Regtest,{factory:cv,pool:fv,wbtc:lv,moto:hv,router:pv})),Dp.Fractal,ov({},uv.Mainnet,{factory:wv,pool:mv,wbtc:_v,moto:Ev,router:Sv})))}),[{key:"getFactoryAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.factory;if(!n)throw new Error("Factory address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getPoolAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.pool;if(!n)throw new Error("Pool address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getWBTCAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.wbtc;if(!n)throw new Error("WBTC address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getMOTOAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.moto;if(!n)throw new Error("MOTO address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getRouterAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.router;if(!n)throw new Error("Router address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getAddresses",value:function(t,e){var r=this.metadata[e][t];if(!r)throw new Error("Metadata not found for network ".concat(t," and chainId ").concat(e));return r}}])}(),Tv=new kv,Ov=o._v,xv=o.y3,Av=o.Z1,Pv=o.pV,Iv=o.iy,Lv=o.vU,Bv=o.dy,Rv=o.gd,Nv=o.z2,jv=o.LC,Uv=o.V5,Cv=o.fI,Fv=o.G7,Mv=o.p9,Dv=o.GF,Hv=o.nU,Kv=o.wf,Gv=o.gf,Wv=o.rt,Vv=o.P8,qv=o.vg,zv=o.nr,Yv=o.ry,Xv=o.z4,Zv=o.qT,$v=o.t0,Jv=o.Jf,Qv=o.kd,tw=o.eA,ew=o.no,rw=o.o4,nw=o.YV,iw=o.O5,ow=o.cC,aw=o.Wj,sw=o.Z4,uw=o.pp,cw=o.d6,fw=o.p6,lw=o.iV,hw=o.gh,pw=o.Bc,dw=o.TG,yw=o.LL,gw=o.gK,bw=o.PE,vw=o.ev,ww=o.Go,mw=o.IB,_w=o.rl,Ew=o.c1,Sw=o.Y_,kw=o.yo,Tw=o.Ko,Ow=o.pe,xw=o.ho,Aw=o._l,Pw=o.QS,Iw=o.Bm,Lw=o.W_,Bw=o.Hu,Rw=o.Mg,Nw=o.$v,jw=o.mt,Uw=o.lJ,Cw=o.ih,Fw=o.AT,Mw=o.AS,Dw=o.aw,Hw=o.tm,Kw=o.Qc,Gw=o.dF,Ww=o.Wb,Vw=o.D_,qw=o.aS,zw=o._3,Yw=o.p0,Xw=o.Rt,Zw=o.ZO,$w=o.BI,Jw=o.MS,Qw=o.ct,tm=o.A9,em=o.V$,rm=o.xc,nm=o.Gc,im=o.zM,om=o.c,am=o.uW,sm=o.OH,um=o.sG,cm=o.jz,fm=o.hL,lm=o.$7,hm=o.rE;export{Ov as ABICoder,xv as ABIDataTypes,Av as ADDRESS_BYTE_LENGTH,Pv as Address,Iv as AddressGenerator,Lv as AddressMap,Bv as AddressSet,Rv as AddressTypes,Nv as AddressVerificator,jv as BOOLEAN_BYTE_LENGTH,Uv as BinaryReader,Cv as BinaryWriter,Fv as BitcoinUtils,Mv as BufferHelper,Dv as CalldataGenerator,Hv as ChainId,Kv as Compressor,Gv as Consensus,Wv as ContractAddress,Vv as ContractBaseMetadata,qv as CustomGenerator,zv as CustomKeypair,Yv as CustomScriptTransaction,Xv as DeploymentGenerator,Zv as DeploymentTransaction,$v as DeterministicMap,Jv as DeterministicSet,Qv as EcKeyPair,tw as FACTORY_ADDRESS_FRACTAL,ew as FACTORY_ADDRESS_REGTEST,rw as FACTORY_ADDRESS_TESTNET,nw as FeatureOpCodes,iw as Features,ow as FundingTransaction,aw as Generator,sw as I128_BYTE_LENGTH,uw as I16_BYTE_LENGTH,cw as I256_BYTE_LENGTH,fw as I32_BYTE_LENGTH,lw as I64_BYTE_LENGTH,hw as I8_BYTE_LENGTH,pw as InteractionTransaction,dw as LegacyCalldataGenerator,yw as MOTO_ADDRESS_FRACTAL,gw as MOTO_ADDRESS_REGTEST,bw as MOTO_ADDRESS_TESTNET,vw as MessageSigner,ww as MessageType,mw as MultiSignGenerator,_w as MultiSignTransaction,Ew as NetEvent,Sw as OPNetConsensusConfig,kw as OPNetLimitedProvider,Tw as OPNetMetadata,Ow as OPNetNetwork,xw as OPNetTokenAddressManager,Aw as P2TR_MS,Pw as POOL_ADDRESS_FRACTAL,Iw as POOL_ADDRESS_REGTEST,Lw as POOL_ADDRESS_TESTNET,Bw as PSBTTypes,Rw as PsbtTransaction,Nw as ROUTER_ADDRESS_FRACTAL,jw as ROUTER_ADDRESS_REGTEST,Uw as ROUTER_ADDRESS_TESTNET,Cw as RoswellConsensus,Fw as SELECTOR_BYTE_LENGTH,Mw as Secp256k1PointDeriver,Dw as SharedInteractionTransaction,Hw as TapscriptVerificator,Kw as TransactionBuilder,Gw as TransactionFactory,Ww as TransactionSequence,Vw as TransactionType,qw as TweakedSigner,zw as TweakedTransaction,Yw as U128_BYTE_LENGTH,Xw as U16_BYTE_LENGTH,Zw as U256_BYTE_LENGTH,$w as U32_BYTE_LENGTH,Jw as U64_BYTE_LENGTH,Qw as U8_BYTE_LENGTH,tm as UnisatChainType,em as UnisatNetwork,rm as UnisatSigner,nm as WBTC_ADDRESS_FRACTAL,im as WBTC_ADDRESS_REGTEST,om as WBTC_ADDRESS_TESTNET,am as Wallet,sm as XverseNetwork,um as XverseSigner,cm as currentConsensus,fm as currentConsensusConfig,lm as opnet,hm as version};
2
+ var t,e,r={3513:(t,e,r)=>{var n=r(8510),i=r(4967),o=r(1484);function a(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var u=a(i),s=a(o);const c=n.secp256k1.ProjectivePoint,f="Expected Private",l="Expected Point",h="Expected Tweak",p="Expected Signature",d="Expected Extra Data (32 bytes)",y="Expected Scalar",g=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),b=new Uint8Array(32),v=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]),w=BigInt(1);function m(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function _(t){return 0===m(t,b)}function E(t){return t instanceof Uint8Array&&32===t.length&&!(m(t,g)>=0)}function S(t){return t instanceof Uint8Array&&64===t.length&&m(t.subarray(0,32),g)<0&&m(t.subarray(32,64),g)<0}function k(t){return t instanceof Uint8Array&&32===t.length}function O(t){return void 0===t||t instanceof Uint8Array&&32===t.length}function T(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t&&Number.isSafeInteger(t)&&t>=0)e=BigInt(t);else if("string"==typeof t){if(64!==t.length)throw new Error("Expected 32 bytes of private scalar");e=s.hexToNumber(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private scalar");if(32!==t.length)throw new Error("Expected 32 bytes of private scalar");e=s.bytesToNumberBE(t)}if(e<0)throw new Error("Expected private scalar >= 0");return e}function x(t){return n.secp256k1.utils.normPrivateKeyToScalar(t)}function A(t,e,r){const n=B(t),i=T(e),o=c.BASE.multiplyAndAddUnsafe(n,i,w);if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)}function P(t,e){return void 0===t?void 0===e||N(e):!!t}function I(t){try{return t()}catch(t){return null}}function L(t){return n.schnorr.utils.lift_x(s.bytesToNumberBE(t))}function B(t){return 32===t.length?L(t):c.fromHex(t)}function R(t,e){if(32===t.length!==e)return!1;try{return e?!!L(t):!!c.fromHex(t)}catch(t){return!1}}function j(t){return R(t,!1)}function N(t){return R(t,!1)&&33===t.length}function U(t){return n.secp256k1.utils.isValidPrivateKey(t)}function C(t){return R(t,!0)}function F(t){if(!j(t))throw new Error(l);return t.slice(1,33)}function M(t,e){if(!U(t))throw new Error(f);return I((()=>n.secp256k1.getPublicKey(t,P(e))))}e.isPoint=j,e.isPointCompressed=N,e.isPrivate=U,e.isXOnlyPoint=C,e.pointAdd=function(t,e,r){if(!j(t)||!j(e))throw new Error(l);return I((()=>{const n=B(t),i=B(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(P(r,t))}))},e.pointAddScalar=function(t,e,r){if(!j(t))throw new Error(l);if(!E(e))throw new Error(h);return I((()=>A(t,e,P(r,t))))},e.pointCompress=function(t,e){if(!j(t))throw new Error(l);return B(t).toRawBytes(P(e,t))},e.pointFromScalar=M,e.pointMultiply=function(t,e,r){if(!j(t))throw new Error(l);if(!E(e))throw new Error(h);return I((()=>function(t,e,r){const n=B(t),i="string"==typeof e?e:s.bytesToHex(e),o=s.hexToNumber(i);return n.multiply(o).toRawBytes(r)}(t,e,P(r,t))))},e.privateAdd=function(t,e){if(!U(t))throw new Error(f);if(!E(e))throw new Error(h);return I((()=>function(t,e){const r=x(t),i=T(e),o=s.numberToBytesBE(u.mod(r+i,n.secp256k1.CURVE.n),32);return n.secp256k1.utils.isValidPrivateKey(o)?o:null}(t,e)))},e.privateNegate=function(t){if(!U(t))throw new Error(f);return function(t){const e=x(t),r=s.numberToBytesBE(n.secp256k1.CURVE.n-e,32);return n.secp256k1.utils.isValidPrivateKey(r)?r:null}(t)},e.privateSub=function(t,e){if(!U(t))throw new Error(f);if(!E(e))throw new Error(h);return I((()=>function(t,e){const r=x(t),i=T(e),o=s.numberToBytesBE(u.mod(r-i,n.secp256k1.CURVE.n),32);return n.secp256k1.utils.isValidPrivateKey(o)?o:null}(t,e)))},e.recover=function(t,e,r,i){if(!k(t))throw new Error("Expected Hash");if(!S(e)||!function(t){return!(_(t.subarray(0,32))||_(t.subarray(32,64)))}(e))throw new Error(p);if(2&r&&!function(t){return t instanceof Uint8Array&&64===t.length&&m(t.subarray(0,32),v)<0}(e))throw new Error("Bad Recovery Id");if(!C(e.subarray(0,32)))throw new Error(p);const o=n.secp256k1.Signature.fromCompact(e).addRecoveryBit(r).recoverPublicKey(t);if(!o)throw new Error(p);return o.toRawBytes(P(i))},e.sign=function(t,e,r){if(!U(e))throw new Error(f);if(!k(t))throw new Error(y);if(!O(r))throw new Error(d);return n.secp256k1.sign(t,e,{extraEntropy:r}).toCompactRawBytes()},e.signRecoverable=function(t,e,r){if(!U(e))throw new Error(f);if(!k(t))throw new Error(y);if(!O(r))throw new Error(d);const i=n.secp256k1.sign(t,e,{extraEntropy:r});return{signature:i.toCompactRawBytes(),recoveryId:i.recovery}},e.signSchnorr=function(t,e,r){if(!U(e))throw new Error(f);if(!k(t))throw new Error(y);if(!O(r))throw new Error(d);return n.schnorr.sign(t,e,r)},e.verify=function(t,e,r,i){if(!j(e))throw new Error(l);if(!S(r))throw new Error(p);if(!k(t))throw new Error(y);return n.secp256k1.verify(r,t,e,{lowS:i})},e.verifySchnorr=function(t,e,r){if(!C(e))throw new Error(l);if(!S(r))throw new Error(p);if(!k(t))throw new Error(y);return n.schnorr.verify(r,t,e)},e.xOnlyPointAddTweak=function(t,e){if(!C(t))throw new Error(l);if(!E(e))throw new Error(h);return I((()=>{const r=A(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}}))},e.xOnlyPointFromPoint=F,e.xOnlyPointFromScalar=function(t){if(!U(t))throw new Error(f);return F(M(t))}},3562:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getHash=a,e.createCurve=function(t,e){const r=e=>(0,o.weierstrass)({...t,...a(e)});return{...r(e),create:r}};const n=r(9615),i=r(9175),o=r(1705);function a(t){return{hash:t,hmac:(e,...r)=>(0,n.hmac)(t,e,(0,i.concatBytes)(...r)),randomBytes:i.randomBytes}}},2422:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.wNAF=function(t,e){return{constTimeNegate:u,hasPrecomputes:t=>1!==d(t),unsafeLadder(e,r,n=t.ZERO){let i=e;for(;r>o;)r&a&&(n=n.add(i)),i=i.double(),r>>=a;return n},precomputeWindow(t,r){const{windows:n,windowSize:i}=c(r,e),o=[];let a=t,u=a;for(let t=0;t<n;t++){u=a,o.push(u);for(let t=1;t<i;t++)u=u.add(a),o.push(u);a=u.double()}return o},wNAF(r,n,i){const{windows:o,windowSize:s}=c(r,e);let f=t.ZERO,l=t.BASE;const h=BigInt(2**r-1),p=2**r,d=BigInt(r);for(let t=0;t<o;t++){const e=t*s;let r=Number(i&h);i>>=d,r>s&&(r-=p,i+=a);const o=e,c=e+Math.abs(r)-1,y=t%2!=0,g=r<0;0===r?l=l.add(u(y,n[o])):f=f.add(u(g,n[c]))}return{p:f,f:l}},wNAFUnsafe(r,n,i,u=t.ZERO){const{windows:s,windowSize:f}=c(r,e),l=BigInt(2**r-1),h=2**r,p=BigInt(r);for(let t=0;t<s;t++){const e=t*f;if(i===o)break;let r=Number(i&l);if(i>>=p,r>f&&(r-=h,i+=a),0===r)continue;let s=n[e+Math.abs(r)-1];r<0&&(s=s.negate()),u=u.add(s)}return u},getPrecomputes(t,e,r){let n=h.get(e);return n||(n=this.precomputeWindow(e,t),1!==t&&h.set(e,r(n))),n},wNAFCached(t,e,r){const n=d(t);return this.wNAF(n,this.getPrecomputes(n,t,r),e)},wNAFCachedUnsafe(t,e,r,n){const i=d(t);return 1===i?this.unsafeLadder(t,e,n):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),e,n)},setWindowSize(t,r){s(r,e),p.set(t,r),h.delete(t)}}},e.pippenger=function(t,e,r,n){if(f(r,t),l(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=(0,i.bitLen)(BigInt(r.length)),u=a>12?a-3:a>4?a-2:a?2:1,s=(1<<u)-1,c=new Array(s+1).fill(o);let h=o;for(let t=Math.floor((e.BITS-1)/u)*u;t>=0;t-=u){c.fill(o);for(let e=0;e<n.length;e++){const i=n[e],o=Number(i>>BigInt(t)&BigInt(s));c[o]=c[o].add(r[e])}let e=o;for(let t=c.length-1,r=o;t>0;t--)r=r.add(c[t]),e=e.add(r);if(h=h.add(e),0!==t)for(let t=0;t<u;t++)h=h.double()}return h},e.precomputeMSMUnsafe=function(t,e,r,n){s(n,e.BITS),f(r,t);const i=t.ZERO,o=2**n-1,a=Math.ceil(e.BITS/n),u=BigInt((1<<n)-1),c=r.map((t=>{const e=[];for(let r=0,n=t;r<o;r++)e.push(n),n=n.add(t);return e}));return t=>{if(l(t,e),t.length>r.length)throw new Error("array of scalars must be smaller than array of points");let o=i;for(let e=0;e<a;e++){if(o!==i)for(let t=0;t<n;t++)o=o.double();const r=BigInt(a*n-(e+1)*n);for(let e=0;e<t.length;e++){const n=t[e],i=Number(n>>r&u);i&&(o=o.add(c[e][i-1]))}}return o}},e.validateBasic=function(t){return(0,n.validateField)(t.Fp),(0,i.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,n.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})};const n=r(4967),i=r(1484),o=BigInt(0),a=BigInt(1);function u(t,e){const r=e.negate();return t?r:e}function s(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function c(t,e){return s(t,e),{windows:Math.ceil(e/t)+1,windowSize:2**(t-1)}}function f(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach(((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)}))}function l(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach(((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)}))}const h=new WeakMap,p=new WeakMap;function d(t){return p.get(t)||1}},1761:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.expand_message_xmd=c,e.expand_message_xof=f,e.hash_to_field=l,e.isogenyMap=function(t,e){const r=e.map((t=>Array.from(t).reverse()));return(e,n)=>{const[i,o,a,u]=r.map((r=>r.reduce(((r,n)=>t.add(t.mul(r,e),n)))));return e=t.div(i,o),n=t.mul(n,t.div(a,u)),{x:e,y:n}}},e.createHasher=function(t,e,r){if("function"!=typeof e)throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){const o=l(n,2,{...r,DST:r.DST,...i}),a=t.fromAffine(e(o[0])),u=t.fromAffine(e(o[1])),s=a.add(u).clearCofactor();return s.assertValidity(),s},encodeToCurve(n,i){const o=l(n,1,{...r,DST:r.encodeDST,...i}),a=t.fromAffine(e(o[0])).clearCofactor();return a.assertValidity(),a},mapToCurve(r){if(!Array.isArray(r))throw new Error("mapToCurve: expected array of bigints");for(const t of r)if("bigint"!=typeof t)throw new Error("mapToCurve: expected array of bigints");const n=t.fromAffine(e(r)).clearCofactor();return n.assertValidity(),n}}};const n=r(4967),i=r(1484),o=i.bytesToNumberBE;function a(t,e){if(s(t),s(e),t<0||t>=1<<8*e)throw new Error("invalid I2OSP input: "+t);const r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=255&t,t>>>=8;return new Uint8Array(r)}function u(t,e){const r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function s(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function c(t,e,r,n){(0,i.abytes)(t),(0,i.abytes)(e),s(r),e.length>255&&(e=n((0,i.concatBytes)((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));const{outputLen:o,blockLen:c}=n,f=Math.ceil(r/o);if(r>65535||f>255)throw new Error("expand_message_xmd: invalid lenInBytes");const l=(0,i.concatBytes)(e,a(e.length,1)),h=a(0,c),p=a(r,2),d=new Array(f),y=n((0,i.concatBytes)(h,t,p,a(0,1),l));d[0]=n((0,i.concatBytes)(y,a(1,1),l));for(let t=1;t<=f;t++){const e=[u(y,d[t-1]),a(t+1,1),l];d[t]=n((0,i.concatBytes)(...e))}return(0,i.concatBytes)(...d).slice(0,r)}function f(t,e,r,n,o){if((0,i.abytes)(t),(0,i.abytes)(e),s(r),e.length>255){const t=Math.ceil(2*n/8);e=o.create({dkLen:t}).update((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:r}).update(t).update(a(r,2)).update(e).update(a(e.length,1)).digest()}function l(t,e,r){(0,i.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:a,k:u,m:l,hash:h,expand:p,DST:d}=r;(0,i.abytes)(t),s(e);const y="string"==typeof d?(0,i.utf8ToBytes)(d):d,g=a.toString(2).length,b=Math.ceil((g+u)/8),v=e*l*b;let w;if("xmd"===p)w=c(t,y,v,h);else if("xof"===p)w=f(t,y,v,u,h);else{if("_internal_pass"!==p)throw new Error('expand must be "xmd" or "xof"');w=t}const m=new Array(e);for(let t=0;t<e;t++){const e=new Array(l);for(let r=0;r<l;r++){const i=b*(r+t*l),u=w.subarray(i,i+b);e[r]=(0,n.mod)(o(u),a)}m[t]=e}return m}},4967:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNegativeLE=void 0,e.mod=l,e.pow=h,e.pow2=function(t,e,r){let n=t;for(;e-- >i;)n*=n,n%=r;return n},e.invert=p,e.tonelliShanks=d,e.FpSqrt=y,e.validateField=function(t){const e=g.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,n.validateObject)(t,e)},e.FpPow=b,e.FpInvertBatch=v,e.FpDiv=function(t,e,r){return t.mul(e,"bigint"==typeof r?p(r,t.ORDER):t.inv(r))},e.FpLegendre=w,e.FpIsSquare=function(t){const e=w(t.ORDER);return r=>{const n=e(t,r);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}},e.nLength=m,e.Field=function(t,e,r=!1,a={}){if(t<=i)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:u,nByteLength:s}=m(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c;const f=Object.freeze({ORDER:t,isLE:r,BITS:u,BYTES:s,MASK:(0,n.bitMask)(u),ZERO:i,ONE:o,create:e=>l(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return i<=e&&e<t},is0:t=>t===i,isOdd:t=>(t&o)===o,neg:e=>l(-e,t),eql:(t,e)=>t===e,sqr:e=>l(e*e,t),add:(e,r)=>l(e+r,t),sub:(e,r)=>l(e-r,t),mul:(e,r)=>l(e*r,t),pow:(t,e)=>b(f,t,e),div:(e,r)=>l(e*p(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>p(e,t),sqrt:a.sqrt||(e=>(c||(c=y(t)),c(f,e))),invertBatch:t=>v(f,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?(0,n.numberToBytesLE)(t,s):(0,n.numberToBytesBE)(t,s),fromBytes:t=>{if(t.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+t.length);return r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t)}});return Object.freeze(f)},e.FpSqrtOdd=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)},e.FpSqrtEven=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r},e.hashToPrivateScalar=function(t,e,r=!1){const i=(t=(0,n.ensureBytes)("privateHash",t)).length,a=m(e).nByteLength+8;if(a<24||i<a||i>1024)throw new Error("hashToPrivateScalar: expected "+a+"-1024 bytes of input, got "+i);return l(r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t),e-o)+o},e.getFieldBytesLength=_,e.getMinHashLength=E,e.mapHashToField=function(t,e,r=!1){const i=t.length,a=_(e),u=E(e);if(i<16||i<u||i>1024)throw new Error("expected "+u+"-1024 bytes of input, got "+i);const s=l(r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t),e-o)+o;return r?(0,n.numberToBytesLE)(s,a):(0,n.numberToBytesBE)(s,a)};const n=r(1484),i=BigInt(0),o=BigInt(1),a=BigInt(2),u=BigInt(3),s=BigInt(4),c=BigInt(5),f=BigInt(8);function l(t,e){const r=t%e;return r>=i?r:e+r}function h(t,e,r){if(e<i)throw new Error("invalid exponent, negatives unsupported");if(r<=i)throw new Error("invalid modulus");if(r===o)return i;let n=o;for(;e>i;)e&o&&(n=n*t%r),t=t*t%r,e>>=o;return n}function p(t,e){if(t===i)throw new Error("invert: expected non-zero number");if(e<=i)throw new Error("invert: expected positive modulus, got "+e);let r=l(t,e),n=e,a=i,u=o,s=o,c=i;for(;r!==i;){const t=n/r,e=n%r,i=a-s*t,o=u-c*t;n=r,r=e,a=s,u=c,s=i,c=o}if(n!==o)throw new Error("invert: does not exist");return l(a,e)}function d(t){const e=(t-o)/a;let r,n,u;for(r=t-o,n=0;r%a===i;r/=a,n++);for(u=a;u<t&&h(u,e,t)!==t-o;u++)if(u>1e3)throw new Error("Cannot find square root: likely non-prime P");if(1===n){const e=(t+o)/s;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 c=(r+o)/a;return function(t,i){if(t.pow(i,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=n,s=t.pow(t.mul(t.ONE,u),r),f=t.pow(i,c),l=t.pow(i,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(s,o<<BigInt(a-e-1));s=t.sqr(r),f=t.mul(f,r),l=t.mul(l,s),a=e}return f}}function y(t){if(t%s===u){const e=(t+o)/s;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%f===c){const e=(t-c)/f;return function(t,r){const n=t.mul(r,a),i=t.pow(n,e),o=t.mul(r,i),u=t.mul(t.mul(o,a),i),s=t.mul(o,t.sub(u,t.ONE));if(!t.eql(t.sqr(s),r))throw new Error("Cannot find square root");return s}}return d(t)}e.isNegativeLE=(t,e)=>(l(t,e)&o)===o;const g=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function b(t,e,r){if(r<i)throw new Error("invalid exponent, negatives unsupported");if(r===i)return t.ONE;if(r===o)return e;let n=t.ONE,a=e;for(;r>i;)r&o&&(n=t.mul(n,a)),a=t.sqr(a),r>>=o;return n}function v(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}function w(t){const e=(t-o)/a;return(t,r)=>t.pow(r,e)}function m(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function _(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 E(t){const e=_(t);return e+Math.ceil(e/2)}},1484:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.notImplemented=e.bitMask=void 0,e.isBytes=o,e.abytes=a,e.abool=function(t,e){if("boolean"!=typeof e)throw new Error(t+" boolean expected, got "+e)},e.bytesToHex=s,e.numberToHexUnpadded=c,e.hexToNumber=f,e.hexToBytes=p,e.bytesToNumberBE=function(t){return f(s(t))},e.bytesToNumberLE=function(t){return a(t),f(s(Uint8Array.from(t).reverse()))},e.numberToBytesBE=d,e.numberToBytesLE=function(t,e){return d(t,e).reverse()},e.numberToVarBytesBE=function(t){return p(c(t))},e.ensureBytes=function(t,e,r){let n;if("string"==typeof e)try{n=p(e)}catch(e){throw new Error(t+" must be hex string or Uint8Array, cause: "+e)}else{if(!o(e))throw new Error(t+" must be hex string or Uint8Array");n=Uint8Array.from(e)}const i=n.length;if("number"==typeof r&&i!==r)throw new Error(t+" of length "+r+" expected, got "+i);return n},e.concatBytes=y,e.equalBytes=function(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return 0===r},e.utf8ToBytes=function(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))},e.inRange=b,e.aInRange=function(t,e,r,n){if(!b(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)},e.bitLen=function(t){let e;for(e=0;t>r;t>>=n,e+=1);return e},e.bitGet=function(t,e){return t>>BigInt(e)&n},e.bitSet=function(t,e,i){return t|(i?n:r)<<BigInt(e)},e.createHmacDrbg=function(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=v(t),i=v(t),o=0;const a=()=>{n.fill(1),i.fill(0),o=0},u=(...t)=>r(i,n,...t),s=(t=v())=>{i=u(w([0]),t),n=u(),0!==t.length&&(i=u(w([1]),t),n=u())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){n=u();const e=n.slice();r.push(e),t+=n.length}return y(...r)};return(t,e)=>{let r;for(a(),s(t);!(r=e(c()));)s();return a(),r}},e.validateObject=function(t,e,r={}){const n=(e,r,n)=>{const i=m[r];if("function"!=typeof i)throw new Error("invalid validator function");const o=t[e];if(!(n&&void 0===o||i(o,t)))throw new Error("param "+String(e)+" is invalid. Expected "+r+", got "+o)};for(const[t,r]of Object.entries(e))n(t,r,!1);for(const[t,e]of Object.entries(r))n(t,e,!0);return t},e.memoized=function(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(void 0!==i)return i;const o=t(r,...n);return e.set(r,o),o}};const r=BigInt(0),n=BigInt(1),i=BigInt(2);function o(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function a(t){if(!o(t))throw new Error("Uint8Array expected")}const u=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function s(t){a(t);let e="";for(let r=0;r<t.length;r++)e+=u[t[r]];return e}function c(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function f(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?r:BigInt("0x"+t)}const l={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(t){return t>=l._0&&t<=l._9?t-l._0:t>=l.A&&t<=l.F?t-(l.A-10):t>=l.a&&t<=l.f?t-(l.a-10):void 0}function p(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,i=0;e<r;e++,i+=2){const r=h(t.charCodeAt(i)),o=h(t.charCodeAt(i+1));if(void 0===r||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+o}return n}function d(t,e){return p(t.toString(16).padStart(2*e,"0"))}function y(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];a(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}const g=t=>"bigint"==typeof t&&r<=t;function b(t,e,r){return g(t)&&g(e)&&g(r)&&e<=t&&t<r}e.bitMask=t=>(i<<BigInt(t-1))-n;const v=t=>new Uint8Array(t),w=t=>Uint8Array.from(t),m={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||o(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};e.notImplemented=()=>{throw new Error("not implemented")}},1705:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DER=e.DERErr=void 0,e.weierstrassPoints=g,e.weierstrass=function(t){const r=function(t){const e=(0,n.validateBasic)(t);return o.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:s,n:c}=r,f=s.BYTES+1,p=2*s.BYTES+1;function d(t){return i.mod(t,c)}function y(t){return i.invert(t,c)}const{ProjectivePoint:b,normPrivateKeyToScalar:v,weierstrassEquation:w,isWithinCurveOrder:m}=g({...r,toBytes(t,e,r){const n=e.toAffine(),i=s.toBytes(n.x),u=o.concatBytes;return(0,a.abool)("isCompressed",r),r?u(Uint8Array.from([e.hasEvenY()?2:3]),i):u(Uint8Array.from([4]),i,s.toBytes(n.y))},fromBytes(t){const e=t.length,r=t[0],n=t.subarray(1);if(e!==f||2!==r&&3!==r){if(e===p&&4===r)return{x:s.fromBytes(n.subarray(0,s.BYTES)),y:s.fromBytes(n.subarray(s.BYTES,2*s.BYTES))};throw new Error("invalid Point, expected length of "+f+", or uncompressed "+p+", got "+e)}{const t=o.bytesToNumberBE(n);if(!o.inRange(t,h,s.ORDER))throw new Error("Point is not on curve");const e=w(t);let i;try{i=s.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("Point is not on curve"+e)}return!(1&~r)!=((i&h)===h)&&(i=s.neg(i)),{x:t,y:i}}}}),_=t=>o.bytesToHex(o.numberToBytesBE(t,r.nByteLength));function E(t){return t>c>>h}const S=(t,e,r)=>o.bytesToNumberBE(t.slice(e,r));class k{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const e=r.nByteLength;return t=(0,a.ensureBytes)("compactSignature",t,2*e),new k(S(t,0,e),S(t,e,2*e))}static fromDER(t){const{r,s:n}=e.DER.toSig((0,a.ensureBytes)("DER",t));return new k(r,n)}assertValidity(){o.aInRange("r",this.r,h,c),o.aInRange("s",this.s,h,c)}addRecoveryBit(t){return new k(this.r,this.s,t)}recoverPublicKey(t){const{r:e,s:n,recovery:i}=this,o=A((0,a.ensureBytes)("msgHash",t));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const u=2===i||3===i?e+r.n:e;if(u>=s.ORDER)throw new Error("recovery id 2 or 3 invalid");const c=1&i?"03":"02",f=b.fromHex(c+_(u)),l=y(u),h=d(-o*l),p=d(n*l),g=b.BASE.multiplyAndAddUnsafe(f,h,p);if(!g)throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return E(this.s)}normalizeS(){return this.hasHighS()?new k(this.r,d(-this.s),this.recovery):this}toDERRawBytes(){return o.hexToBytes(this.toDERHex())}toDERHex(){return e.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return o.hexToBytes(this.toCompactHex())}toCompactHex(){return _(this.r)+_(this.s)}}const O={isValidPrivateKey(t){try{return v(t),!0}catch(t){return!1}},normPrivateKeyToScalar:v,randomPrivateKey:()=>{const t=i.getMinHashLength(r.n);return i.mapHashToField(r.randomBytes(t),r.n)},precompute:(t=8,e=b.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function T(t){const e=o.isBytes(t),r="string"==typeof t,n=(e||r)&&t.length;return e?n===f||n===p:r?n===2*f||n===2*p:t instanceof b}const x=r.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=o.bytesToNumberBE(t),n=8*t.length-r.nBitLength;return n>0?e>>BigInt(n):e},A=r.bits2int_modN||function(t){return d(x(t))},P=o.bitMask(r.nBitLength);function I(t){return o.aInRange("num < 2^"+r.nBitLength,t,l,P),o.numberToBytesBE(t,r.nByteLength)}const L={lowS:r.lowS,prehash:!1},B={lowS:r.lowS,prehash:!1};return b.BASE._setWindowSize(8),{CURVE:r,getPublicKey:function(t,e=!0){return b.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(T(t))throw new Error("first arg must be private key");if(!T(e))throw new Error("second arg must be public key");return b.fromHex(e).multiply(v(t)).toRawBytes(r)},sign:function(t,e,n=L){const{seed:i,k2sig:c}=function(t,e,n=L){if(["recovered","canonical"].some((t=>t in n)))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:c}=r;let{lowS:f,prehash:p,extraEntropy:g}=n;null==f&&(f=!0),t=(0,a.ensureBytes)("msgHash",t),u(n),p&&(t=(0,a.ensureBytes)("prehashed msgHash",i(t)));const w=A(t),_=v(e),S=[I(_),I(w)];if(null!=g&&!1!==g){const t=!0===g?c(s.BYTES):g;S.push((0,a.ensureBytes)("extraEntropy",t))}const O=o.concatBytes(...S),T=w;return{seed:O,k2sig:function(t){const e=x(t);if(!m(e))return;const r=y(e),n=b.BASE.multiply(e).toAffine(),i=d(n.x);if(i===l)return;const o=d(r*d(T+i*_));if(o===l)return;let a=(n.x===i?0:2)|Number(n.y&h),u=o;return f&&E(o)&&(u=function(t){return E(t)?d(-t):t}(o),a^=1),new k(i,u,a)}}}(t,e,n),f=r;return o.createHmacDrbg(f.hash.outputLen,f.nByteLength,f.hmac)(i,c)},verify:function(t,n,i,s=B){const c=t;n=(0,a.ensureBytes)("msgHash",n),i=(0,a.ensureBytes)("publicKey",i);const{lowS:f,prehash:l,format:h}=s;if(u(s),"strict"in s)throw new Error("options.strict was renamed to lowS");if(void 0!==h&&"compact"!==h&&"der"!==h)throw new Error("format must be compact or der");const p="string"==typeof c||o.isBytes(c),g=!p&&!h&&"object"==typeof c&&null!==c&&"bigint"==typeof c.r&&"bigint"==typeof c.s;if(!p&&!g)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let v,w;try{if(g&&(v=new k(c.r,c.s)),p){try{"compact"!==h&&(v=k.fromDER(c))}catch(t){if(!(t instanceof e.DER.Err))throw t}v||"der"===h||(v=k.fromCompact(c))}w=b.fromHex(i)}catch(t){return!1}if(!v)return!1;if(f&&v.hasHighS())return!1;l&&(n=r.hash(n));const{r:m,s:_}=v,E=A(n),S=y(_),O=d(E*S),T=d(m*S),x=b.BASE.multiplyAndAddUnsafe(w,O,T)?.toAffine();return!!x&&d(x.x)===m},ProjectivePoint:b,Signature:k,utils:O}},e.SWUFpSqrtRatio=b,e.mapToCurveSimpleSWU=function(t,e){if(i.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=b(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,o,a,u,s,c,f,l;i=t.sqr(n),i=t.mul(i,e.Z),o=t.sqr(i),o=t.add(o,i),a=t.add(o,t.ONE),a=t.mul(a,e.B),u=t.cmov(e.Z,t.neg(o),!t.eql(o,t.ZERO)),u=t.mul(u,e.A),o=t.sqr(a),c=t.sqr(u),s=t.mul(c,e.A),o=t.add(o,s),o=t.mul(o,a),c=t.mul(c,u),s=t.mul(c,e.B),o=t.add(o,s),f=t.mul(i,a);const{isValid:h,value:p}=r(o,c);l=t.mul(i,n),l=t.mul(l,p),f=t.cmov(f,a,h),l=t.cmov(l,p,h);const d=t.isOdd(n)===t.isOdd(l);return l=t.cmov(t.neg(l),l,d),f=t.div(f,u),{x:f,y:l}}};const n=r(2422),i=r(4967),o=r(1484),a=r(1484);function u(t){void 0!==t.lowS&&(0,a.abool)("lowS",t.lowS),void 0!==t.prehash&&(0,a.abool)("prehash",t.prehash)}const{bytesToNumberBE:s,hexToBytes:c}=o;class f extends Error{constructor(t=""){super(t)}}e.DERErr=f,e.DER={Err:f,_tlv:{encode:(t,r)=>{const{Err:n}=e.DER;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(1&r.length)throw new n("tlv.encode: unpadded data");const i=r.length/2,a=o.numberToHexUnpadded(i);if(a.length/2&128)throw new n("tlv.encode: long form length too big");const u=i>127?o.numberToHexUnpadded(a.length/2|128):"";return o.numberToHexUnpadded(t)+u+a+r},decode(t,r){const{Err:n}=e.DER;let i=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(r.length<2||r[i++]!==t)throw new n("tlv.decode: wrong tlv");const o=r[i++];let a=0;if(128&o){const t=127&o;if(!t)throw new n("tlv.decode(long): indefinite length not supported");if(t>4)throw new n("tlv.decode(long): byte length is too big");const e=r.subarray(i,i+t);if(e.length!==t)throw new n("tlv.decode: length bytes not complete");if(0===e[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of e)a=a<<8|t;if(i+=t,a<128)throw new n("tlv.decode(long): not minimal encoding")}else a=o;const u=r.subarray(i,i+a);if(u.length!==a)throw new n("tlv.decode: wrong value length");return{v:u,l:r.subarray(i+a)}}},_int:{encode(t){const{Err:r}=e.DER;if(t<l)throw new r("integer: negative integers are not allowed");let n=o.numberToHexUnpadded(t);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new r("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:r}=e.DER;if(128&t[0])throw new r("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new r("invalid signature integer: unnecessary leading zero");return s(t)}},toSig(t){const{Err:r,_int:n,_tlv:i}=e.DER,a="string"==typeof t?c(t):t;o.abytes(a);const{v:u,l:s}=i.decode(48,a);if(s.length)throw new r("invalid signature: left bytes after parsing");const{v:f,l}=i.decode(2,u),{v:h,l:p}=i.decode(2,l);if(p.length)throw new r("invalid signature: left bytes after parsing");return{r:n.decode(f),s:n.decode(h)}},hexFromSig(t){const{_tlv:r,_int:n}=e.DER,i=r.encode(2,n.encode(t.r))+r.encode(2,n.encode(t.s));return r.encode(48,i)}};const l=BigInt(0),h=BigInt(1),p=BigInt(2),d=BigInt(3),y=BigInt(4);function g(t){const e=function(t){const e=(0,n.validateBasic)(t);o.validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:i,a}=e;if(r){if(!i.eql(a,i.ZERO))throw new Error("invalid 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("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:r}=e,u=i.Field(e.n,e.nBitLength),s=e.toBytes||((t,e,n)=>{const i=e.toAffine();return o.concatBytes(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),c=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 f(t){const{a:n,b:i}=e,o=r.sqr(t),a=r.mul(o,t);return r.add(r.add(a,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),f(e.Gx)))throw new Error("bad generator point: equation left != right");function p(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:u,n:s}=e;if(r&&"bigint"!=typeof t){if(o.isBytes(t)&&(t=o.bytesToHex(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("invalid private key");t=t.padStart(2*n,"0")}let c;try{c="bigint"==typeof t?t:o.bytesToNumberBE((0,a.ensureBytes)("private key",t,n))}catch(e){throw new Error("invalid private key, expected hex or "+n+" bytes, got "+typeof t)}return u&&(c=i.mod(c,s)),o.aInRange("private key",c,h,s),c}function y(t){if(!(t instanceof v))throw new Error("ProjectivePoint expected")}const g=(0,a.memoized)(((t,e)=>{const{px:n,py:i,pz:o}=t;if(r.eql(o,r.ONE))return{x:n,y:i};const a=t.is0();null==e&&(e=a?r.ONE:r.inv(o));const u=r.mul(n,e),s=r.mul(i,e),c=r.mul(o,e);if(a)return{x:r.ZERO,y:r.ZERO};if(!r.eql(c,r.ONE))throw new Error("invZ was invalid");return{x:u,y:s}})),b=(0,a.memoized)((t=>{if(t.is0()){if(e.allowInfinityPoint&&!r.is0(t.py))return;throw new Error("bad point: ZERO")}const{x:n,y:i}=t.toAffine();if(!r.isValid(n)||!r.isValid(i))throw new Error("bad point: x or y not FE");const o=r.sqr(i),a=f(n);if(!r.eql(o,a))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class v{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");Object.freeze(this)}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 v)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?v.ZERO:new v(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(v.fromAffine)}static fromHex(t){const e=v.fromAffine(c((0,a.ensureBytes)("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return v.BASE.multiply(p(t))}static msm(t,e){return(0,n.pippenger)(v,u,t,e)}_setWindowSize(t){m.setWindowSize(this,t)}assertValidity(){b(this)}hasEvenY(){const{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){y(t);const{px:e,py:n,pz:i}=this,{px:o,py:a,pz:u}=t,s=r.eql(r.mul(e,u),r.mul(o,i)),c=r.eql(r.mul(n,u),r.mul(a,i));return s&&c}negate(){return new v(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,d),{px:o,py:a,pz:u}=this;let s=r.ZERO,c=r.ZERO,f=r.ZERO,l=r.mul(o,o),h=r.mul(a,a),p=r.mul(u,u),y=r.mul(o,a);return y=r.add(y,y),f=r.mul(o,u),f=r.add(f,f),s=r.mul(t,f),c=r.mul(i,p),c=r.add(s,c),s=r.sub(h,c),c=r.add(h,c),c=r.mul(s,c),s=r.mul(y,s),f=r.mul(i,f),p=r.mul(t,p),y=r.sub(l,p),y=r.mul(t,y),y=r.add(y,f),f=r.add(l,l),l=r.add(f,l),l=r.add(l,p),l=r.mul(l,y),c=r.add(c,l),p=r.mul(a,u),p=r.add(p,p),l=r.mul(p,y),s=r.sub(s,l),f=r.mul(p,h),f=r.add(f,f),f=r.add(f,f),new v(s,c,f)}add(t){y(t);const{px:n,py:i,pz:o}=this,{px:a,py:u,pz:s}=t;let c=r.ZERO,f=r.ZERO,l=r.ZERO;const h=e.a,p=r.mul(e.b,d);let g=r.mul(n,a),b=r.mul(i,u),w=r.mul(o,s),m=r.add(n,i),_=r.add(a,u);m=r.mul(m,_),_=r.add(g,b),m=r.sub(m,_),_=r.add(n,o);let E=r.add(a,s);return _=r.mul(_,E),E=r.add(g,w),_=r.sub(_,E),E=r.add(i,o),c=r.add(u,s),E=r.mul(E,c),c=r.add(b,w),E=r.sub(E,c),l=r.mul(h,_),c=r.mul(p,w),l=r.add(c,l),c=r.sub(b,l),l=r.add(b,l),f=r.mul(c,l),b=r.add(g,g),b=r.add(b,g),w=r.mul(h,w),_=r.mul(p,_),b=r.add(b,w),w=r.sub(g,w),w=r.mul(h,w),_=r.add(_,w),g=r.mul(b,_),f=r.add(f,g),g=r.mul(E,_),c=r.mul(m,c),c=r.sub(c,g),g=r.mul(m,b),l=r.mul(E,l),l=r.add(l,g),new v(c,f,l)}subtract(t){return this.add(t.negate())}is0(){return this.equals(v.ZERO)}wNAF(t){return m.wNAFCached(this,t,v.normalizeZ)}multiplyUnsafe(t){const{endo:n,n:i}=e;o.aInRange("scalar",t,l,i);const a=v.ZERO;if(t===l)return a;if(this.is0()||t===h)return this;if(!n||m.hasPrecomputes(this))return m.wNAFCachedUnsafe(this,t,v.normalizeZ);let{k1neg:u,k1:s,k2neg:c,k2:f}=n.splitScalar(t),p=a,d=a,y=this;for(;s>l||f>l;)s&h&&(p=p.add(y)),f&h&&(d=d.add(y)),y=y.double(),s>>=h,f>>=h;return u&&(p=p.negate()),c&&(d=d.negate()),d=new v(r.mul(d.px,n.beta),d.py,d.pz),p.add(d)}multiply(t){const{endo:n,n:i}=e;let a,u;if(o.aInRange("scalar",t,h,i),n){const{k1neg:e,k1:i,k2neg:o,k2:s}=n.splitScalar(t);let{p:c,f}=this.wNAF(i),{p:l,f:h}=this.wNAF(s);c=m.constTimeNegate(e,c),l=m.constTimeNegate(o,l),l=new v(r.mul(l.px,n.beta),l.py,l.pz),a=c.add(l),u=f.add(h)}else{const{p:e,f:r}=this.wNAF(t);a=e,u=r}return v.normalizeZ([a,u])[0]}multiplyAndAddUnsafe(t,e,r){const n=v.BASE,i=(t,e)=>e!==l&&e!==h&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),o=i(this,e).add(i(t,r));return o.is0()?void 0:o}toAffine(t){return g(this,t)}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===h)return!0;if(r)return r(v,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===h?this:r?r(v,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return(0,a.abool)("isCompressed",t),this.assertValidity(),s(v,this,t)}toHex(t=!0){return(0,a.abool)("isCompressed",t),o.bytesToHex(this.toRawBytes(t))}}v.BASE=new v(e.Gx,e.Gy,r.ONE),v.ZERO=new v(r.ZERO,r.ONE,r.ZERO);const w=e.nBitLength,m=(0,n.wNAF)(v,e.endo?Math.ceil(w/2):w);return{CURVE:e,ProjectivePoint:v,normPrivateKeyToScalar:p,weierstrassEquation:f,isWithinCurveOrder:function(t){return o.inRange(t,h,e.n)}}}function b(t,e){const r=t.ORDER;let n=l;for(let t=r-h;t%p===l;t/=p)n+=h;const i=n,o=p<<i-h-h,a=o*p,u=(r-h)/a,s=(u-h)/p,c=a-h,f=o,g=t.pow(e,u),b=t.pow(e,(u+h)/p);let v=(e,r)=>{let n=g,o=t.pow(r,c),a=t.sqr(o);a=t.mul(a,r);let u=t.mul(e,a);u=t.pow(u,s),u=t.mul(u,o),o=t.mul(u,r),a=t.mul(u,e);let l=t.mul(a,o);u=t.pow(l,f);let d=t.eql(u,t.ONE);o=t.mul(a,b),u=t.mul(l,n),a=t.cmov(o,a,d),l=t.cmov(u,l,d);for(let e=i;e>h;e--){let r=e-p;r=p<<r-h;let i=t.pow(l,r);const u=t.eql(i,t.ONE);o=t.mul(a,n),n=t.mul(n,n),i=t.mul(l,n),a=t.cmov(o,a,u),l=t.cmov(i,l,u)}return{isValid:d,value:a}};if(t.ORDER%y===d){const r=(t.ORDER-d)/y,n=t.sqrt(t.neg(e));v=(e,i)=>{let o=t.sqr(i);const a=t.mul(e,i);o=t.mul(o,a);let u=t.pow(o,r);u=t.mul(u,a);const s=t.mul(u,n),c=t.mul(t.sqr(u),i),f=t.eql(c,e);return{isValid:f,value:t.cmov(s,u,f)}}}return v}},8510:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.schnorr=e.secp256k1=void 0;const n=r(2623),i=r(9175),o=r(3562),a=r(1761),u=r(4967),s=r(1484),c=r(1705),f=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),l=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h=BigInt(1),p=BigInt(2),d=(t,e)=>(t+e/p)/e;function y(t){const e=f,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),a=BigInt(23),s=BigInt(44),c=BigInt(88),l=t*t*t%e,h=l*l*t%e,d=(0,u.pow2)(h,r,e)*h%e,y=(0,u.pow2)(d,r,e)*h%e,b=(0,u.pow2)(y,p,e)*l%e,v=(0,u.pow2)(b,i,e)*b%e,w=(0,u.pow2)(v,o,e)*v%e,m=(0,u.pow2)(w,s,e)*w%e,_=(0,u.pow2)(m,c,e)*m%e,E=(0,u.pow2)(_,s,e)*w%e,S=(0,u.pow2)(E,r,e)*h%e,k=(0,u.pow2)(S,a,e)*v%e,O=(0,u.pow2)(k,n,e)*l%e,T=(0,u.pow2)(O,p,e);if(!g.eql(g.sqr(T),t))throw new Error("Cannot find square root");return T}const g=(0,u.Field)(f,void 0,void 0,{sqrt:y});e.secp256k1=(0,o.createCurve)({a:BigInt(0),b:BigInt(7),Fp:g,n:l,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=l,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-h*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,a=BigInt("0x100000000000000000000000000000000"),s=d(o*t,e),c=d(-n*t,e);let f=(0,u.mod)(t-s*r-c*i,e),p=(0,u.mod)(-s*n-c*o,e);const y=f>a,g=p>a;if(y&&(f=e-f),g&&(p=e-p),f>a||p>a)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:y,k1:f,k2neg:g,k2:p}}}},n.sha256);const b=BigInt(0),v={};function w(t,...e){let r=v[t];if(void 0===r){const e=(0,n.sha256)(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=(0,s.concatBytes)(e,e),v[t]=r}return(0,n.sha256)((0,s.concatBytes)(r,...e))}const m=t=>t.toRawBytes(!0).slice(1),_=t=>(0,s.numberToBytesBE)(t,32),E=t=>(0,u.mod)(t,f),S=t=>(0,u.mod)(t,l),k=e.secp256k1.ProjectivePoint;function O(t){let r=e.secp256k1.utils.normPrivateKeyToScalar(t),n=k.fromPrivateKey(r);return{scalar:n.hasEvenY()?r:S(-r),bytes:m(n)}}function T(t){(0,s.aInRange)("x",t,h,f);const e=E(t*t);let r=y(E(e*t+BigInt(7)));r%p!==b&&(r=E(-r));const n=new k(t,r,h);return n.assertValidity(),n}const x=s.bytesToNumberBE;function A(...t){return S(x(w("BIP0340/challenge",...t)))}function P(t,e,r){const n=(0,s.ensureBytes)("signature",t,64),i=(0,s.ensureBytes)("message",e),o=(0,s.ensureBytes)("publicKey",r,32);try{const t=T(x(o)),e=x(n.subarray(0,32));if(!(0,s.inRange)(e,h,f))return!1;const r=x(n.subarray(32,64));if(!(0,s.inRange)(r,h,l))return!1;const a=A(_(e),m(t),i),u=((t,e,r)=>k.BASE.multiplyAndAddUnsafe(t,e,r))(t,r,S(-a));return!(!u||!u.hasEvenY()||u.toAffine().x!==e)}catch(t){return!1}}e.schnorr={getPublicKey:function(t){return O(t).bytes},sign:function(t,e,r=(0,i.randomBytes)(32)){const n=(0,s.ensureBytes)("message",t),{bytes:o,scalar:a}=O(e),u=(0,s.ensureBytes)("auxRand",r,32),c=_(a^x(w("BIP0340/aux",u))),f=w("BIP0340/nonce",c,o,n),l=S(x(f));if(l===b)throw new Error("sign failed: k is zero");const{bytes:h,scalar:p}=O(l),d=A(h,o,n),y=new Uint8Array(64);if(y.set(h,0),y.set(_(S(p+d*a)),32),!P(y,n,o))throw new Error("sign: Invalid signature produced");return y},verify:P,utils:{randomPrivateKey:e.secp256k1.utils.randomPrivateKey,lift_x:T,pointToBytes:m,numberToBytesBE:s.numberToBytesBE,bytesToNumberBE:s.bytesToNumberBE,taggedHash:w,mod:u.mod}};const I=(()=>(0,a.isogenyMap)(g,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((t=>t.map((t=>BigInt(t)))))))(),L=(()=>(0,c.mapToCurveSimpleSWU)(g,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:g.create(BigInt("-11"))}))(),B=(()=>(0,a.createHasher)(e.secp256k1.ProjectivePoint,(t=>{const{x:e,y:r}=L(g.create(t[0]));return I(e,r)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:g.ORDER,m:1,k:128,expand:"xmd",hash:n.sha256}))();e.hashToCurve=B.hashToCurve,e.encodeToCurve=B.encodeToCurve},7557:(t,e)=>{function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function n(t,...e){if(!function(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}Object.defineProperty(e,"__esModule",{value:!0}),e.anumber=r,e.abytes=n,e.ahash=function(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)},e.aexists=function(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")},e.aoutput=function(t,e){n(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}},7202:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0,e.setBigUint64=o;const n=r(7557),i=r(9175);function o(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),u=Number(r&o),s=n?4:0,c=n?0:4;t.setUint32(e+s,a,n),t.setUint32(e+c,u,n)}e.Chi=(t,e,r)=>t&e^~t&r,e.Maj=(t,e,r)=>t&e^t&r^e&r;class a 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.aexists)(this);const{view:e,buffer:r,blockLen:o}=this,a=(t=(0,i.toBytes)(t)).length;for(let n=0;n<a;){const u=Math.min(o-this.pos,a-n);if(u!==o)r.set(t.subarray(n,n+u),this.pos),this.pos+=u,n+=u,this.pos===o&&(this.process(e,0),this.pos=0);else{const e=(0,i.createView)(t);for(;o<=a-n;n+=o)this.process(e,n)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,n.aexists)(this),(0,n.aoutput)(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:a,isLE:u}=this;let{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>a-s&&(this.process(r,0),s=0);for(let t=s;t<a;t++)e[t]=0;o(r,a-8,BigInt(8*this.length),u),this.process(r,0);const c=(0,i.createView)(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=f/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<l;t++)c.setUint32(4*t,h[t],u)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}e.HashMD=a},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},9615:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(7557),i=r(9175);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.ahash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,a=new Uint8Array(o);a.set(r.length>o?t.create().update(r).digest():r);for(let t=0;t<a.length;t++)a[t]^=54;this.iHash.update(a),this.oHash=t.create();for(let t=0;t<a.length;t++)a[t]^=106;this.oHash.update(a),a.fill(0)}update(t){return(0,n.aexists)(this),this.iHash.update(t),this}digestInto(t){(0,n.aexists)(this),(0,n.abytes)(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=o,e.hmac=(t,e,r)=>new o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},2623:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=e.SHA256=void 0;const n=r(7202),i=r(9175),o=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]),a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64);class s extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3],this.E=0|a[4],this.F=0|a[5],this.G=0|a[6],this.H=0|a[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:u}=this;return[t,e,r,n,i,o,a,u]}set(t,e,r,n,i,o,a,u){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|u}process(t,e){for(let r=0;r<16;r++,e+=4)u[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=u[t-15],r=u[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;u[t]=o+u[t-7]+n+u[t-16]|0}let{A:r,B:a,C:s,D:c,E:f,F:l,G:h,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,l,h)+o[t]+u[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,a,s)|0;p=h,h=l,l=f,f=c+e|0,c=s,s=a,a=r,r=e+d|0}r=r+this.A|0,a=a+this.B|0,s=s+this.C|0,c=c+this.D|0,f=f+this.E|0,l=l+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(r,a,s,c,f,l,h,p)}roundClean(){u.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}e.SHA256=s;class c extends s{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 s)),e.sha224=(0,i.wrapConstructor)((()=>new c))},9175:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name},e.byteSwap32=function(t){for(let r=0;r<t.length;r++)t[r]=(0,e.byteSwap)(t[r])},e.bytesToHex=function(t){(0,i.abytes)(t);let e="";for(let r=0;r<t.length;r++)e+=o[t[r]];return e},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("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=u(t.charCodeAt(i)),o=u(t.charCodeAt(i+1));if(void 0===r||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+o}return n},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o<t;o++){n(o);const t=Date.now()-i;t>=0&&t<r||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=s,e.toBytes=c,e.concatBytes=function(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];(0,i.abytes)(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r},e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!=={}.toString.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(c(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(c(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(c(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));if(n.crypto&&"function"==typeof n.crypto.randomBytes)return n.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")};const n=r(5145),i=r(7557);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);const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0"))),a={_0:48,_9:57,A:65,F:70,a:97,f:102};function u(t){return t>=a._0&&t<=a._9?t-a._0:t>=a.A&&t<=a.F?t-(a.A-10):t>=a.a&&t<=a.f?t-(a.a-10):void 0}function s(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function c(t){return"string"==typeof t&&(t=s(t)),(0,i.abytes)(t),t}e.nextTick=async()=>{},e.Hash=class{clone(){return this._cloneInto()}}},4148:(t,e,r)=>{var n=r(5606);function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(void 0,o=function(t){if("object"!==i(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key),"symbol"===i(o)?o:String(o)),n)}var o}function a(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}var u,s,c=r(9597).codes,f=c.ERR_AMBIGUOUS_ARGUMENT,l=c.ERR_INVALID_ARG_TYPE,h=c.ERR_INVALID_ARG_VALUE,p=c.ERR_INVALID_RETURN_VALUE,d=c.ERR_MISSING_ARGS,y=r(3918),g=r(537).inspect,b=r(537).types,v=b.isPromise,w=b.isRegExp,m=r(9133)(),_=r(9394)(),E=r(8075)("RegExp.prototype.test");function S(){var t=r(2299);u=t.isDeepEqual,s=t.isDeepStrictEqual}new Map;var k=!1,O=t.exports=P,T={};function x(t){if(t.message instanceof Error)throw t.message;throw new y(t)}function A(t,e,r,n){if(!r){var i=!1;if(0===e)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new y({actual:r,expected:!0,message:n,operator:"==",stackStartFn:t});throw o.generatedMessage=i,o}}function P(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];A.apply(void 0,[P,e.length].concat(e))}O.fail=function t(e,r,i,o,a){var u,s=arguments.length;if(0===s?u="Failed":1===s?(i=e,e=void 0):(!1===k&&(k=!0,(n.emitWarning?n.emitWarning:console.warn.bind(console))("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")),2===s&&(o="!=")),i instanceof Error)throw i;var c={actual:e,expected:r,operator:void 0===o?"fail":o,stackStartFn:a||t};void 0!==i&&(c.message=i);var f=new y(c);throw u&&(f.message=u,f.generatedMessage=!0),f},O.AssertionError=y,O.ok=P,O.equal=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");e!=r&&x({actual:e,expected:r,message:n,operator:"==",stackStartFn:t})},O.notEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");e==r&&x({actual:e,expected:r,message:n,operator:"!=",stackStartFn:t})},O.deepEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===u&&S(),u(e,r)||x({actual:e,expected:r,message:n,operator:"deepEqual",stackStartFn:t})},O.notDeepEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===u&&S(),u(e,r)&&x({actual:e,expected:r,message:n,operator:"notDeepEqual",stackStartFn:t})},O.deepStrictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===u&&S(),s(e,r)||x({actual:e,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:t})},O.notDeepStrictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===u&&S(),s(e,r)&&x({actual:e,expected:r,message:n,operator:"notDeepStrictEqual",stackStartFn:t})},O.strictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");_(e,r)||x({actual:e,expected:r,message:n,operator:"strictEqual",stackStartFn:t})},O.notStrictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");_(e,r)&&x({actual:e,expected:r,message:n,operator:"notStrictEqual",stackStartFn:t})};var I=a((function t(e,r,n){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r.forEach((function(t){t in e&&(void 0!==n&&"string"==typeof n[t]&&w(e[t])&&E(e[t],n[t])?i[t]=n[t]:i[t]=e[t])}))}));function L(t,e,r,n){if("function"!=typeof e){if(w(e))return E(e,t);if(2===arguments.length)throw new l("expected",["Function","RegExp"],e);if("object"!==i(t)||null===t){var o=new y({actual:t,expected:e,message:r,operator:"deepStrictEqual",stackStartFn:n});throw o.operator=n.name,o}var a=Object.keys(e);if(e instanceof Error)a.push("name","message");else if(0===a.length)throw new h("error",e,"may not be an empty object");return void 0===u&&S(),a.forEach((function(i){"string"==typeof t[i]&&w(e[i])&&E(e[i],t[i])||function(t,e,r,n,i,o){if(!(r in t)||!s(t[r],e[r])){if(!n){var a=new I(t,i),u=new I(e,i,t),c=new y({actual:a,expected:u,operator:"deepStrictEqual",stackStartFn:o});throw c.actual=t,c.expected=e,c.operator=o.name,c}x({actual:t,expected:e,message:n,operator:o.name,stackStartFn:o})}}(t,e,i,r,a,n)})),!0}return void 0!==e.prototype&&t instanceof e||!Error.isPrototypeOf(e)&&!0===e.call({},t)}function B(t){if("function"!=typeof t)throw new l("fn","Function",t);try{t()}catch(t){return t}return T}function R(t){return v(t)||null!==t&&"object"===i(t)&&"function"==typeof t.then&&"function"==typeof t.catch}function j(t){return Promise.resolve().then((function(){var e;if("function"==typeof t){if(!R(e=t()))throw new p("instance of Promise","promiseFn",e)}else{if(!R(t))throw new l("promiseFn",["Function","Promise"],t);e=t}return Promise.resolve().then((function(){return e})).then((function(){return T})).catch((function(t){return t}))}))}function N(t,e,r,n){if("string"==typeof r){if(4===arguments.length)throw new l("error",["Object","Error","Function","RegExp"],r);if("object"===i(e)&&null!==e){if(e.message===r)throw new f("error/message",'The error message "'.concat(e.message,'" is identical to the message.'))}else if(e===r)throw new f("error/message",'The error "'.concat(e,'" is identical to the message.'));n=r,r=void 0}else if(null!=r&&"object"!==i(r)&&"function"!=typeof r)throw new l("error",["Object","Error","Function","RegExp"],r);if(e===T){var o="";r&&r.name&&(o+=" (".concat(r.name,")")),o+=n?": ".concat(n):".";var a="rejects"===t.name?"rejection":"exception";x({actual:void 0,expected:r,operator:t.name,message:"Missing expected ".concat(a).concat(o),stackStartFn:t})}if(r&&!L(e,r,n,t))throw e}function U(t,e,r,n){if(e!==T){if("string"==typeof r&&(n=r,r=void 0),!r||L(e,r)){var i=n?": ".concat(n):".",o="doesNotReject"===t.name?"rejection":"exception";x({actual:e,expected:r,operator:t.name,message:"Got unwanted ".concat(o).concat(i,"\n")+'Actual message: "'.concat(e&&e.message,'"'),stackStartFn:t})}throw e}}function C(t,e,r,n,o){if(!w(e))throw new l("regexp","RegExp",e);var a="match"===o;if("string"!=typeof t||E(e,t)!==a){if(r instanceof Error)throw r;var u=!r;r=r||("string"!=typeof t?'The "string" argument must be of type string. Received type '+"".concat(i(t)," (").concat(g(t),")"):(a?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(g(e),". Input:\n\n").concat(g(t),"\n"));var s=new y({actual:t,expected:e,message:r,operator:o,stackStartFn:n});throw s.generatedMessage=u,s}}function F(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];A.apply(void 0,[F,e.length].concat(e))}O.throws=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];N.apply(void 0,[t,B(e)].concat(n))},O.rejects=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return j(e).then((function(e){return N.apply(void 0,[t,e].concat(n))}))},O.doesNotThrow=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];U.apply(void 0,[t,B(e)].concat(n))},O.doesNotReject=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return j(e).then((function(e){return U.apply(void 0,[t,e].concat(n))}))},O.ifError=function t(e){if(null!=e){var r="ifError got unwanted exception: ";"object"===i(e)&&"string"==typeof e.message?0===e.message.length&&e.constructor?r+=e.constructor.name:r+=e.message:r+=g(e);var n=new y({actual:e,expected:null,operator:"ifError",message:r,stackStartFn:t}),o=e.stack;if("string"==typeof o){var a=o.split("\n");a.shift();for(var u=n.stack.split("\n"),s=0;s<a.length;s++){var c=u.indexOf(a[s]);if(-1!==c){u=u.slice(0,c);break}}n.stack="".concat(u.join("\n"),"\n").concat(a.join("\n"))}throw n}},O.match=function t(e,r,n){C(e,r,n,t,"match")},O.doesNotMatch=function t(e,r,n){C(e,r,n,t,"doesNotMatch")},O.strict=m(F,O,{equal:O.strictEqual,deepEqual:O.deepStrictEqual,notEqual:O.notStrictEqual,notDeepEqual:O.notDeepStrictEqual}),O.strict.strict=O.strict},3918:(t,e,r)=>{var n=r(5606);function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function o(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){var n,i,o;n=t,i=e,o=r[e],(i=u(i))in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,u(n.key),n)}}function u(t){var e=function(t){if("object"!==y(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===y(e)?e:String(e)}function s(t,e){if(e&&("object"===y(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return c(t)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t){var e="function"==typeof Map?new Map:void 0;return f=function(t){if(null===t||!function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return l(t,arguments,d(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),p(r,t)},f(t)}function l(t,e,r){return l=h()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&p(i,r.prototype),i},l.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function y(t){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(t)}var g=r(537).inspect,b=r(9597).codes.ERR_INVALID_ARG_TYPE;function v(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}var w="",m="",_="",E="",S={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"};function k(t){var e=Object.keys(t),r=Object.create(Object.getPrototypeOf(t));return e.forEach((function(e){r[e]=t[e]})),Object.defineProperty(r,"message",{value:t.message}),r}function O(t){return g(t,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}var T=function(t,e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&p(t,e)}(T,t);var r,i,u,f,l=(r=T,i=h(),function(){var t,e=d(r);if(i){var n=d(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return s(this,t)});function T(t){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,T),"object"!==y(t)||null===t)throw new b("options","Object",t);var r=t.message,i=t.operator,o=t.stackStartFn,a=t.actual,u=t.expected,f=Error.stackTraceLimit;if(Error.stackTraceLimit=0,null!=r)e=l.call(this,String(r));else if(n.stderr&&n.stderr.isTTY&&(n.stderr&&n.stderr.getColorDepth&&1!==n.stderr.getColorDepth()?(w="",m="",E="",_=""):(w="",m="",E="",_="")),"object"===y(a)&&null!==a&&"object"===y(u)&&null!==u&&"stack"in a&&a instanceof Error&&"stack"in u&&u instanceof Error&&(a=k(a),u=k(u)),"deepStrictEqual"===i||"strictEqual"===i)e=l.call(this,function(t,e,r){var i="",o="",a=0,u="",s=!1,c=O(t),f=c.split("\n"),l=O(e).split("\n"),h=0,p="";if("strictEqual"===r&&"object"===y(t)&&"object"===y(e)&&null!==t&&null!==e&&(r="strictEqualObject"),1===f.length&&1===l.length&&f[0]!==l[0]){var d=f[0].length+l[0].length;if(d<=10){if(!("object"===y(t)&&null!==t||"object"===y(e)&&null!==e||0===t&&0===e))return"".concat(S[r],"\n\n")+"".concat(f[0]," !== ").concat(l[0],"\n")}else if("strictEqualObject"!==r&&d<(n.stderr&&n.stderr.isTTY?n.stderr.columns:80)){for(;f[0][h]===l[0][h];)h++;h>2&&(p="\n ".concat(function(t,e){if(e=Math.floor(e),0==t.length||0==e)return"";var r=t.length*e;for(e=Math.floor(Math.log(e)/Math.log(2));e;)t+=t,e--;return t+t.substring(0,r-t.length)}(" ",h),"^"),h=0)}}for(var g=f[f.length-1],b=l[l.length-1];g===b&&(h++<2?u="\n ".concat(g).concat(u):i=g,f.pop(),l.pop(),0!==f.length&&0!==l.length);)g=f[f.length-1],b=l[l.length-1];var k=Math.max(f.length,l.length);if(0===k){var T=c.split("\n");if(T.length>30)for(T[26]="".concat(w,"...").concat(E);T.length>27;)T.pop();return"".concat(S.notIdentical,"\n\n").concat(T.join("\n"),"\n")}h>3&&(u="\n".concat(w,"...").concat(E).concat(u),s=!0),""!==i&&(u="\n ".concat(i).concat(u),i="");var x=0,A=S[r]+"\n".concat(m,"+ actual").concat(E," ").concat(_,"- expected").concat(E),P=" ".concat(w,"...").concat(E," Lines skipped");for(h=0;h<k;h++){var I=h-a;if(f.length<h+1)I>1&&h>2&&(I>4?(o+="\n".concat(w,"...").concat(E),s=!0):I>3&&(o+="\n ".concat(l[h-2]),x++),o+="\n ".concat(l[h-1]),x++),a=h,i+="\n".concat(_,"-").concat(E," ").concat(l[h]),x++;else if(l.length<h+1)I>1&&h>2&&(I>4?(o+="\n".concat(w,"...").concat(E),s=!0):I>3&&(o+="\n ".concat(f[h-2]),x++),o+="\n ".concat(f[h-1]),x++),a=h,o+="\n".concat(m,"+").concat(E," ").concat(f[h]),x++;else{var L=l[h],B=f[h],R=B!==L&&(!v(B,",")||B.slice(0,-1)!==L);R&&v(L,",")&&L.slice(0,-1)===B&&(R=!1,B+=","),R?(I>1&&h>2&&(I>4?(o+="\n".concat(w,"...").concat(E),s=!0):I>3&&(o+="\n ".concat(f[h-2]),x++),o+="\n ".concat(f[h-1]),x++),a=h,o+="\n".concat(m,"+").concat(E," ").concat(B),i+="\n".concat(_,"-").concat(E," ").concat(L),x+=2):(o+=i,i="",1!==I&&0!==h||(o+="\n ".concat(B),x++))}if(x>20&&h<k-2)return"".concat(A).concat(P,"\n").concat(o,"\n").concat(w,"...").concat(E).concat(i,"\n")+"".concat(w,"...").concat(E)}return"".concat(A).concat(s?P:"","\n").concat(o).concat(i).concat(u).concat(p)}(a,u,i));else if("notDeepStrictEqual"===i||"notStrictEqual"===i){var h=S[i],p=O(a).split("\n");if("notStrictEqual"===i&&"object"===y(a)&&null!==a&&(h=S.notStrictEqualObject),p.length>30)for(p[26]="".concat(w,"...").concat(E);p.length>27;)p.pop();e=1===p.length?l.call(this,"".concat(h," ").concat(p[0])):l.call(this,"".concat(h,"\n\n").concat(p.join("\n"),"\n"))}else{var d=O(a),g="",x=S[i];"notDeepEqual"===i||"notEqual"===i?(d="".concat(S[i],"\n\n").concat(d)).length>1024&&(d="".concat(d.slice(0,1021),"...")):(g="".concat(O(u)),d.length>512&&(d="".concat(d.slice(0,509),"...")),g.length>512&&(g="".concat(g.slice(0,509),"...")),"deepEqual"===i||"equal"===i?d="".concat(x,"\n\n").concat(d,"\n\nshould equal\n\n"):g=" ".concat(i," ").concat(g)),e=l.call(this,"".concat(d).concat(g))}return Error.stackTraceLimit=f,e.generatedMessage=!r,Object.defineProperty(c(e),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),e.code="ERR_ASSERTION",e.actual=a,e.expected=u,e.operator=i,Error.captureStackTrace&&Error.captureStackTrace(c(e),o),e.stack,e.name="AssertionError",s(e)}return u=T,(f=[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:e,value:function(t,e){return g(this,o(o({},e),{},{customInspect:!1,depth:0}))}}])&&a(u.prototype,f),Object.defineProperty(u,"prototype",{writable:!1}),T}(f(Error),g.custom);t.exports=T},9597:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}var a,u,s={};function c(t,e,r){r||(r=Error);var a=function(r){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(f,r);var a,u,s,c=(u=f,s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=o(u);if(s){var r=o(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function f(r,n,i){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,f),o=c.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i)),o.code=t,o}return a=f,Object.defineProperty(a,"prototype",{writable:!1}),a}(r);s[t]=a}function f(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}c("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),c("ERR_INVALID_ARG_TYPE",(function(t,e,i){var o,u,s;if(void 0===a&&(a=r(4148)),a("string"==typeof t,"'name' must be a string"),"string"==typeof e&&(s="not ",e.substr(0,4)===s)?(o="must not be",e=e.replace(/^not /,"")):o="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))u="The ".concat(t," ").concat(o," ").concat(f(e,"type"));else{var c=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+1>t.length)&&-1!==t.indexOf(".",r)}(t)?"property":"argument";u='The "'.concat(t,'" ').concat(c," ").concat(o," ").concat(f(e,"type"))}return u+". Received type ".concat(n(i))}),TypeError),c("ERR_INVALID_ARG_VALUE",(function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"is invalid";void 0===u&&(u=r(537));var i=u.inspect(e);return i.length>128&&(i="".concat(i.slice(0,128),"...")),"The argument '".concat(t,"' ").concat(n,". Received ").concat(i)}),TypeError,RangeError),c("ERR_INVALID_RETURN_VALUE",(function(t,e,r){var i;return i=r&&r.constructor&&r.constructor.name?"instance of ".concat(r.constructor.name):"type ".concat(n(r)),"Expected ".concat(t,' to be returned from the "').concat(e,'"')+" function but got ".concat(i,".")}),TypeError),c("ERR_MISSING_ARGS",(function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];void 0===a&&(a=r(4148)),a(e.length>0,"At least one arg needs to be specified");var i="The ",o=e.length;switch(e=e.map((function(t){return'"'.concat(t,'"')})),o){case 1:i+="".concat(e[0]," argument");break;case 2:i+="".concat(e[0]," and ").concat(e[1]," arguments");break;default:i+=e.slice(0,o-1).join(", "),i+=", and ".concat(e[o-1]," arguments")}return"".concat(i," must be specified")}),TypeError),t.exports.codes=s},2299:(t,e,r)=>{function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,u=[],s=!0,c=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=o.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){c=!0,i=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var a=void 0!==/a/g.flags,u=function(t){var e=[];return t.forEach((function(t){return e.push(t)})),e},s=function(t){var e=[];return t.forEach((function(t,r){return e.push([r,t])})),e},c=Object.is?Object.is:r(7653),f=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},l=Number.isNaN?Number.isNaN:r(4133);function h(t){return t.call.bind(t)}var p=h(Object.prototype.hasOwnProperty),d=h(Object.prototype.propertyIsEnumerable),y=h(Object.prototype.toString),g=r(537).types,b=g.isAnyArrayBuffer,v=g.isArrayBufferView,w=g.isDate,m=g.isMap,_=g.isRegExp,E=g.isSet,S=g.isNativeError,k=g.isBoxedPrimitive,O=g.isNumberObject,T=g.isStringObject,x=g.isBooleanObject,A=g.isBigIntObject,P=g.isSymbolObject,I=g.isFloat32Array,L=g.isFloat64Array;function B(t){if(0===t.length||t.length>10)return!0;for(var e=0;e<t.length;e++){var r=t.charCodeAt(e);if(r<48||r>57)return!0}return 10===t.length&&t>=Math.pow(2,32)}function R(t){return Object.keys(t).filter(B).concat(f(t).filter(Object.prototype.propertyIsEnumerable.bind(t)))}function j(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0}function N(t,e,r,n){if(t===e)return 0!==t||!r||c(t,e);if(r){if("object"!==o(t))return"number"==typeof t&&l(t)&&l(e);if("object"!==o(e)||null===t||null===e)return!1;if(Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1}else{if(null===t||"object"!==o(t))return(null===e||"object"!==o(e))&&t==e;if(null===e||"object"!==o(e))return!1}var i,u,s=y(t);if(s!==y(e))return!1;if(Array.isArray(t)){if(t.length!==e.length)return!1;var f=R(t),h=R(e);return f.length===h.length&&C(t,e,r,n,1,f)}if("[object Object]"===s&&(!m(t)&&m(e)||!E(t)&&E(e)))return!1;if(w(t)){if(!w(e)||Date.prototype.getTime.call(t)!==Date.prototype.getTime.call(e))return!1}else if(_(t)){if(!_(e)||!function(t,e){return a?t.source===e.source&&t.flags===e.flags:RegExp.prototype.toString.call(t)===RegExp.prototype.toString.call(e)}(t,e))return!1}else if(S(t)||t instanceof Error){if(t.message!==e.message||t.name!==e.name)return!1}else{if(v(t)){if(r||!I(t)&&!L(t)){if(!function(t,e){return t.byteLength===e.byteLength&&0===j(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}(t,e))return!1}else if(!function(t,e){if(t.byteLength!==e.byteLength)return!1;for(var r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}(t,e))return!1;var p=R(t),d=R(e);return p.length===d.length&&C(t,e,r,n,0,p)}if(E(t))return!(!E(e)||t.size!==e.size)&&C(t,e,r,n,2);if(m(t))return!(!m(e)||t.size!==e.size)&&C(t,e,r,n,3);if(b(t)){if(u=e,(i=t).byteLength!==u.byteLength||0!==j(new Uint8Array(i),new Uint8Array(u)))return!1}else if(k(t)&&!function(t,e){return O(t)?O(e)&&c(Number.prototype.valueOf.call(t),Number.prototype.valueOf.call(e)):T(t)?T(e)&&String.prototype.valueOf.call(t)===String.prototype.valueOf.call(e):x(t)?x(e)&&Boolean.prototype.valueOf.call(t)===Boolean.prototype.valueOf.call(e):A(t)?A(e)&&BigInt.prototype.valueOf.call(t)===BigInt.prototype.valueOf.call(e):P(e)&&Symbol.prototype.valueOf.call(t)===Symbol.prototype.valueOf.call(e)}(t,e))return!1}return C(t,e,r,n,0)}function U(t,e){return e.filter((function(e){return d(t,e)}))}function C(t,e,r,i,a,c){if(5===arguments.length){c=Object.keys(t);var l=Object.keys(e);if(c.length!==l.length)return!1}for(var h=0;h<c.length;h++)if(!p(e,c[h]))return!1;if(r&&5===arguments.length){var y=f(t);if(0!==y.length){var g=0;for(h=0;h<y.length;h++){var b=y[h];if(d(t,b)){if(!d(e,b))return!1;c.push(b),g++}else if(d(e,b))return!1}var v=f(e);if(y.length!==v.length&&U(e,v).length!==g)return!1}else{var w=f(e);if(0!==w.length&&0!==U(e,w).length)return!1}}if(0===c.length&&(0===a||1===a&&0===t.length||0===t.size))return!0;if(void 0===i)i={val1:new Map,val2:new Map,position:0};else{var m=i.val1.get(t);if(void 0!==m){var _=i.val2.get(e);if(void 0!==_)return m===_}i.position++}i.val1.set(t,i.position),i.val2.set(e,i.position);var E=function(t,e,r,i,a,c){var f=0;if(2===c){if(!function(t,e,r,n){for(var i=null,a=u(t),s=0;s<a.length;s++){var c=a[s];if("object"===o(c)&&null!==c)null===i&&(i=new Set),i.add(c);else if(!e.has(c)){if(r)return!1;if(!D(t,e,c))return!1;null===i&&(i=new Set),i.add(c)}}if(null!==i){for(var f=u(e),l=0;l<f.length;l++){var h=f[l];if("object"===o(h)&&null!==h){if(!F(i,h,r,n))return!1}else if(!r&&!t.has(h)&&!F(i,h,r,n))return!1}return 0===i.size}return!0}(t,e,r,a))return!1}else if(3===c){if(!function(t,e,r,i){for(var a=null,u=s(t),c=0;c<u.length;c++){var f=n(u[c],2),l=f[0],h=f[1];if("object"===o(l)&&null!==l)null===a&&(a=new Set),a.add(l);else{var p=e.get(l);if(void 0===p&&!e.has(l)||!N(h,p,r,i)){if(r)return!1;if(!H(t,e,l,h,i))return!1;null===a&&(a=new Set),a.add(l)}}}if(null!==a){for(var d=s(e),y=0;y<d.length;y++){var g=n(d[y],2),b=g[0],v=g[1];if("object"===o(b)&&null!==b){if(!K(a,t,b,v,r,i))return!1}else if(!(r||t.has(b)&&N(t.get(b),v,!1,i)||K(a,t,b,v,!1,i)))return!1}return 0===a.size}return!0}(t,e,r,a))return!1}else if(1===c)for(;f<t.length;f++){if(!p(t,f)){if(p(e,f))return!1;for(var l=Object.keys(t);f<l.length;f++){var h=l[f];if(!p(e,h)||!N(t[h],e[h],r,a))return!1}return l.length===Object.keys(e).length}if(!p(e,f)||!N(t[f],e[f],r,a))return!1}for(f=0;f<i.length;f++){var d=i[f];if(!N(t[d],e[d],r,a))return!1}return!0}(t,e,r,c,i,a);return i.val1.delete(t),i.val2.delete(e),E}function F(t,e,r,n){for(var i=u(t),o=0;o<i.length;o++){var a=i[o];if(N(e,a,r,n))return t.delete(a),!0}return!1}function M(t){switch(o(t)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":t=+t;case"number":if(l(t))return!1}return!0}function D(t,e,r){var n=M(r);return null!=n?n:e.has(n)&&!t.has(n)}function H(t,e,r,n,i){var o=M(r);if(null!=o)return o;var a=e.get(o);return!(void 0===a&&!e.has(o)||!N(n,a,!1,i))&&!t.has(o)&&N(n,a,!1,i)}function K(t,e,r,n,i,o){for(var a=u(t),s=0;s<a.length;s++){var c=a[s];if(N(r,c,i,o)&&N(n,e.get(c),i,o))return t.delete(c),!0}return!1}t.exports={isDeepEqual:function(t,e){return N(t,e,!1)},isDeepStrictEqual:function(t,e){return N(t,e,!0)}}},7526:(t,e)=>{e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=u(t),a=o[0],s=o[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,s)),f=0,l=s>0?a-4:a;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],c[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;return 2===s&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[f++]=255&e),1===s&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,u=0,c=n-i;u<c;u+=a)o.push(s(t,u,u+a>c?c:u+a));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function u(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 s(t,e,n){for(var i,o,a=[],u=e;u<n;u+=3)i=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},2343:(t,e)=>{e.p2=e.I=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(1&e)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=i(e)^n>>5}e=i(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=i(e)^31&n}return e}function a(t,e,r,n){let i=0,o=0;const a=(1<<r)-1,u=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],o+=e;o>=r;)o-=r,u.push(i>>o&a);if(n)o>0&&u.push(i<<r-o&a);else{if(o>=e)return"Excess padding";if(i<<r-o&a)return"Non-zero padding"}return u}function u(t){return a(t,8,5,!0)}function s(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e}function c(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function f(t){let e;function a(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const a=t.toLowerCase(),u=t.toUpperCase();if(t!==a&&t!==u)return"Mixed-case string "+t;const s=(t=a).lastIndexOf("1");if(-1===s)return"No separator character for "+t;if(0===s)return"Missing prefix for "+t;const c=t.slice(0,s),f=t.slice(s+1);if(f.length<6)return"Data too short";let l=o(c);if("string"==typeof l)return l;const h=[];for(let t=0;t<f.length;++t){const e=f.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;l=i(l)^r,t+6>=f.length||h.push(r)}return l!==e?"Invalid checksum for "+t:{prefix:c,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=a(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=a(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,a){if(a=a||90,t.length+7+n.length>a)throw new TypeError("Exceeds length limit");let u=o(t=t.toLowerCase());if("string"==typeof u)throw new Error(u);let s=t+"1";for(let t=0;t<n.length;++t){const e=n[t];if(e>>5)throw new Error("Non 5-bit word");u=i(u)^e,s+=r.charAt(e)}for(let t=0;t<6;++t)u=i(u);u^=e;for(let t=0;t<6;++t)s+=r.charAt(u>>5*(5-t)&31);return s},toWords:u,fromWordsUnsafe:s,fromWords:c}}e.I=f("bech32"),e.p2=f("bech32m")},5974:(t,e,r)=>{var n=r(8287).Buffer,i=r(5606),o=r(4148),a=r(4442),u=r(8411),s=r(1447),c=r(9681);for(var f in c)e[f]=c[f];function l(t){if("number"!=typeof t||t<e.DEFLATE||t>e.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=t,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}e.NONE=0,e.DEFLATE=1,e.INFLATE=2,e.GZIP=3,e.GUNZIP=4,e.DEFLATERAW=5,e.INFLATERAW=6,e.UNZIP=7,l.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,o(this.init_done,"close before init"),o(this.mode<=e.UNZIP),this.mode===e.DEFLATE||this.mode===e.GZIP||this.mode===e.DEFLATERAW?u.deflateEnd(this.strm):this.mode!==e.INFLATE&&this.mode!==e.GUNZIP&&this.mode!==e.INFLATERAW&&this.mode!==e.UNZIP||s.inflateEnd(this.strm),this.mode=e.NONE,this.dictionary=null)},l.prototype.write=function(t,e,r,n,i,o,a){return this._write(!0,t,e,r,n,i,o,a)},l.prototype.writeSync=function(t,e,r,n,i,o,a){return this._write(!1,t,e,r,n,i,o,a)},l.prototype._write=function(t,r,a,u,s,c,f,l){if(o.equal(arguments.length,8),o(this.init_done,"write before init"),o(this.mode!==e.NONE,"already finalized"),o.equal(!1,this.write_in_progress,"write already in progress"),o.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,o.equal(!1,void 0===r,"must provide flush value"),this.write_in_progress=!0,r!==e.Z_NO_FLUSH&&r!==e.Z_PARTIAL_FLUSH&&r!==e.Z_SYNC_FLUSH&&r!==e.Z_FULL_FLUSH&&r!==e.Z_FINISH&&r!==e.Z_BLOCK)throw new Error("Invalid flush value");if(null==a&&(a=n.alloc(0),s=0,u=0),this.strm.avail_in=s,this.strm.input=a,this.strm.next_in=u,this.strm.avail_out=l,this.strm.output=c,this.strm.next_out=f,this.flush=r,!t)return this._process(),this._checkError()?this._afterSync():void 0;var h=this;return i.nextTick((function(){h._process(),h._after()})),this},l.prototype._afterSync=function(){var t=this.strm.avail_out,e=this.strm.avail_in;return this.write_in_progress=!1,[e,t]},l.prototype._process=function(){var t=null;switch(this.mode){case e.DEFLATE:case e.GZIP:case e.DEFLATERAW:this.err=u.deflate(this.strm,this.flush);break;case e.UNZIP:switch(this.strm.avail_in>0&&(t=this.strm.next_in),this.gzip_id_bytes_read){case 0:if(null===t)break;if(31!==this.strm.input[t]){this.mode=e.INFLATE;break}if(this.gzip_id_bytes_read=1,t++,1===this.strm.avail_in)break;case 1:if(null===t)break;139===this.strm.input[t]?(this.gzip_id_bytes_read=2,this.mode=e.GUNZIP):this.mode=e.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case e.INFLATE:case e.GUNZIP:case e.INFLATERAW:for(this.err=s.inflate(this.strm,this.flush),this.err===e.Z_NEED_DICT&&this.dictionary&&(this.err=s.inflateSetDictionary(this.strm,this.dictionary),this.err===e.Z_OK?this.err=s.inflate(this.strm,this.flush):this.err===e.Z_DATA_ERROR&&(this.err=e.Z_NEED_DICT));this.strm.avail_in>0&&this.mode===e.GUNZIP&&this.err===e.Z_STREAM_END&&0!==this.strm.next_in[0];)this.reset(),this.err=s.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},l.prototype._checkError=function(){switch(this.err){case e.Z_OK:case e.Z_BUF_ERROR:if(0!==this.strm.avail_out&&this.flush===e.Z_FINISH)return this._error("unexpected end of file"),!1;break;case e.Z_STREAM_END:break;case e.Z_NEED_DICT:return null==this.dictionary?this._error("Missing dictionary"):this._error("Bad dictionary"),!1;default:return this._error("Zlib error"),!1}return!0},l.prototype._after=function(){if(this._checkError()){var t=this.strm.avail_out,e=this.strm.avail_in;this.write_in_progress=!1,this.callback(e,t),this.pending_close&&this.close()}},l.prototype._error=function(t){this.strm.msg&&(t=this.strm.msg),this.onerror(t,this.err),this.write_in_progress=!1,this.pending_close&&this.close()},l.prototype.init=function(t,r,n,i,a){o(4===arguments.length||5===arguments.length,"init(windowBits, level, memLevel, strategy, [dictionary])"),o(t>=8&&t<=15,"invalid windowBits"),o(r>=-1&&r<=9,"invalid compression level"),o(n>=1&&n<=9,"invalid memlevel"),o(i===e.Z_FILTERED||i===e.Z_HUFFMAN_ONLY||i===e.Z_RLE||i===e.Z_FIXED||i===e.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(r,t,n,i,a),this._setDictionary()},l.prototype.params=function(){throw new Error("deflateParams Not supported")},l.prototype.reset=function(){this._reset(),this._setDictionary()},l.prototype._init=function(t,r,n,i,o){switch(this.level=t,this.windowBits=r,this.memLevel=n,this.strategy=i,this.flush=e.Z_NO_FLUSH,this.err=e.Z_OK,this.mode!==e.GZIP&&this.mode!==e.GUNZIP||(this.windowBits+=16),this.mode===e.UNZIP&&(this.windowBits+=32),this.mode!==e.DEFLATERAW&&this.mode!==e.INFLATERAW||(this.windowBits=-1*this.windowBits),this.strm=new a,this.mode){case e.DEFLATE:case e.GZIP:case e.DEFLATERAW:this.err=u.deflateInit2(this.strm,this.level,e.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case e.INFLATE:case e.GUNZIP:case e.INFLATERAW:case e.UNZIP:this.err=s.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}this.err!==e.Z_OK&&this._error("Init error"),this.dictionary=o,this.write_in_progress=!1,this.init_done=!0},l.prototype._setDictionary=function(){if(null!=this.dictionary){switch(this.err=e.Z_OK,this.mode){case e.DEFLATE:case e.DEFLATERAW:this.err=u.deflateSetDictionary(this.strm,this.dictionary)}this.err!==e.Z_OK&&this._error("Failed to set dictionary")}},l.prototype._reset=function(){switch(this.err=e.Z_OK,this.mode){case e.DEFLATE:case e.DEFLATERAW:case e.GZIP:this.err=u.deflateReset(this.strm);break;case e.INFLATE:case e.INFLATERAW:case e.GUNZIP:this.err=s.inflateReset(this.strm)}this.err!==e.Z_OK&&this._error("Failed to reset stream")},e.Zlib=l},8559:(t,e,r)=>{var n=r(5606),i=r(8287).Buffer,o=r(8310).Transform,a=r(5974),u=r(537),s=r(4148).ok,c=r(8287).kMaxLength,f="Cannot create final Buffer. It would be larger than 0x"+c.toString(16)+" bytes";a.Z_MIN_WINDOWBITS=8,a.Z_MAX_WINDOWBITS=15,a.Z_DEFAULT_WINDOWBITS=15,a.Z_MIN_CHUNK=64,a.Z_MAX_CHUNK=1/0,a.Z_DEFAULT_CHUNK=16384,a.Z_MIN_MEMLEVEL=1,a.Z_MAX_MEMLEVEL=9,a.Z_DEFAULT_MEMLEVEL=8,a.Z_MIN_LEVEL=-1,a.Z_MAX_LEVEL=9,a.Z_DEFAULT_LEVEL=a.Z_DEFAULT_COMPRESSION;for(var l=Object.keys(a),h=0;h<l.length;h++){var p=l[h];p.match(/^Z/)&&Object.defineProperty(e,p,{enumerable:!0,value:a[p],writable:!1})}for(var d={Z_OK:a.Z_OK,Z_STREAM_END:a.Z_STREAM_END,Z_NEED_DICT:a.Z_NEED_DICT,Z_ERRNO:a.Z_ERRNO,Z_STREAM_ERROR:a.Z_STREAM_ERROR,Z_DATA_ERROR:a.Z_DATA_ERROR,Z_MEM_ERROR:a.Z_MEM_ERROR,Z_BUF_ERROR:a.Z_BUF_ERROR,Z_VERSION_ERROR:a.Z_VERSION_ERROR},y=Object.keys(d),g=0;g<y.length;g++){var b=y[g];d[d[b]]=b}function v(t,e,r){var n=[],o=0;function a(){for(var e;null!==(e=t.read());)n.push(e),o+=e.length;t.once("readable",a)}function u(){var e,a=null;o>=c?a=new RangeError(f):e=i.concat(n,o),n=[],t.close(),r(a,e)}t.on("error",(function(e){t.removeListener("end",u),t.removeListener("readable",a),r(e)})),t.on("end",u),t.end(e),a()}function w(t,e){if("string"==typeof e&&(e=i.from(e)),!i.isBuffer(e))throw new TypeError("Not a string or buffer");var r=t._finishFlushFlag;return t._processChunk(e,r)}function m(t){if(!(this instanceof m))return new m(t);A.call(this,t,a.DEFLATE)}function _(t){if(!(this instanceof _))return new _(t);A.call(this,t,a.INFLATE)}function E(t){if(!(this instanceof E))return new E(t);A.call(this,t,a.GZIP)}function S(t){if(!(this instanceof S))return new S(t);A.call(this,t,a.GUNZIP)}function k(t){if(!(this instanceof k))return new k(t);A.call(this,t,a.DEFLATERAW)}function O(t){if(!(this instanceof O))return new O(t);A.call(this,t,a.INFLATERAW)}function T(t){if(!(this instanceof T))return new T(t);A.call(this,t,a.UNZIP)}function x(t){return t===a.Z_NO_FLUSH||t===a.Z_PARTIAL_FLUSH||t===a.Z_SYNC_FLUSH||t===a.Z_FULL_FLUSH||t===a.Z_FINISH||t===a.Z_BLOCK}function A(t,r){var n=this;if(this._opts=t=t||{},this._chunkSize=t.chunkSize||e.Z_DEFAULT_CHUNK,o.call(this,t),t.flush&&!x(t.flush))throw new Error("Invalid flush flag: "+t.flush);if(t.finishFlush&&!x(t.finishFlush))throw new Error("Invalid flush flag: "+t.finishFlush);if(this._flushFlag=t.flush||a.Z_NO_FLUSH,this._finishFlushFlag=void 0!==t.finishFlush?t.finishFlush:a.Z_FINISH,t.chunkSize&&(t.chunkSize<e.Z_MIN_CHUNK||t.chunkSize>e.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+t.chunkSize);if(t.windowBits&&(t.windowBits<e.Z_MIN_WINDOWBITS||t.windowBits>e.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+t.windowBits);if(t.level&&(t.level<e.Z_MIN_LEVEL||t.level>e.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+t.level);if(t.memLevel&&(t.memLevel<e.Z_MIN_MEMLEVEL||t.memLevel>e.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+t.memLevel);if(t.strategy&&t.strategy!=e.Z_FILTERED&&t.strategy!=e.Z_HUFFMAN_ONLY&&t.strategy!=e.Z_RLE&&t.strategy!=e.Z_FIXED&&t.strategy!=e.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+t.strategy);if(t.dictionary&&!i.isBuffer(t.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new a.Zlib(r);var u=this;this._hadError=!1,this._handle.onerror=function(t,r){P(u),u._hadError=!0;var n=new Error(t);n.errno=r,n.code=e.codes[r],u.emit("error",n)};var s=e.Z_DEFAULT_COMPRESSION;"number"==typeof t.level&&(s=t.level);var c=e.Z_DEFAULT_STRATEGY;"number"==typeof t.strategy&&(c=t.strategy),this._handle.init(t.windowBits||e.Z_DEFAULT_WINDOWBITS,s,t.memLevel||e.Z_DEFAULT_MEMLEVEL,c,t.dictionary),this._buffer=i.allocUnsafe(this._chunkSize),this._offset=0,this._level=s,this._strategy=c,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!n._handle},configurable:!0,enumerable:!0})}function P(t,e){e&&n.nextTick(e),t._handle&&(t._handle.close(),t._handle=null)}function I(t){t.emit("close")}Object.defineProperty(e,"codes",{enumerable:!0,value:Object.freeze(d),writable:!1}),e.Deflate=m,e.Inflate=_,e.Gzip=E,e.Gunzip=S,e.DeflateRaw=k,e.InflateRaw=O,e.Unzip=T,e.createDeflate=function(t){return new m(t)},e.createInflate=function(t){return new _(t)},e.createDeflateRaw=function(t){return new k(t)},e.createInflateRaw=function(t){return new O(t)},e.createGzip=function(t){return new E(t)},e.createGunzip=function(t){return new S(t)},e.createUnzip=function(t){return new T(t)},e.deflate=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new m(e),t,r)},e.deflateSync=function(t,e){return w(new m(e),t)},e.gzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new E(e),t,r)},e.gzipSync=function(t,e){return w(new E(e),t)},e.deflateRaw=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new k(e),t,r)},e.deflateRawSync=function(t,e){return w(new k(e),t)},e.unzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new T(e),t,r)},e.unzipSync=function(t,e){return w(new T(e),t)},e.inflate=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new _(e),t,r)},e.inflateSync=function(t,e){return w(new _(e),t)},e.gunzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new S(e),t,r)},e.gunzipSync=function(t,e){return w(new S(e),t)},e.inflateRaw=function(t,e,r){return"function"==typeof e&&(r=e,e={}),v(new O(e),t,r)},e.inflateRawSync=function(t,e){return w(new O(e),t)},u.inherits(A,o),A.prototype.params=function(t,r,i){if(t<e.Z_MIN_LEVEL||t>e.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+t);if(r!=e.Z_FILTERED&&r!=e.Z_HUFFMAN_ONLY&&r!=e.Z_RLE&&r!=e.Z_FIXED&&r!=e.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+r);if(this._level!==t||this._strategy!==r){var o=this;this.flush(a.Z_SYNC_FLUSH,(function(){s(o._handle,"zlib binding closed"),o._handle.params(t,r),o._hadError||(o._level=t,o._strategy=r,i&&i())}))}else n.nextTick(i)},A.prototype.reset=function(){return s(this._handle,"zlib binding closed"),this._handle.reset()},A.prototype._flush=function(t){this._transform(i.alloc(0),"",t)},A.prototype.flush=function(t,e){var r=this,o=this._writableState;("function"==typeof t||void 0===t&&!e)&&(e=t,t=a.Z_FULL_FLUSH),o.ended?e&&n.nextTick(e):o.ending?e&&this.once("end",e):o.needDrain?e&&this.once("drain",(function(){return r.flush(t,e)})):(this._flushFlag=t,this.write(i.alloc(0),"",e))},A.prototype.close=function(t){P(this,t),n.nextTick(I,this)},A.prototype._transform=function(t,e,r){var n,o=this._writableState,u=(o.ending||o.ended)&&(!t||o.length===t.length);return null===t||i.isBuffer(t)?this._handle?(u?n=this._finishFlushFlag:(n=this._flushFlag,t.length>=o.length&&(this._flushFlag=this._opts.flush||a.Z_NO_FLUSH)),void this._processChunk(t,n,r)):r(new Error("zlib binding closed")):r(new Error("invalid input"))},A.prototype._processChunk=function(t,e,r){var n=t&&t.length,o=this._chunkSize-this._offset,a=0,u=this,l="function"==typeof r;if(!l){var h,p=[],d=0;this.on("error",(function(t){h=t})),s(this._handle,"zlib binding closed");do{var y=this._handle.writeSync(e,t,a,n,this._buffer,this._offset,o)}while(!this._hadError&&v(y[0],y[1]));if(this._hadError)throw h;if(d>=c)throw P(this),new RangeError(f);var g=i.concat(p,d);return P(this),g}s(this._handle,"zlib binding closed");var b=this._handle.write(e,t,a,n,this._buffer,this._offset,o);function v(c,f){if(this&&(this.buffer=null,this.callback=null),!u._hadError){var h=o-f;if(s(h>=0,"have should not go down"),h>0){var y=u._buffer.slice(u._offset,u._offset+h);u._offset+=h,l?u.push(y):(p.push(y),d+=y.length)}if((0===f||u._offset>=u._chunkSize)&&(o=u._chunkSize,u._offset=0,u._buffer=i.allocUnsafe(u._chunkSize)),0===f){if(a+=n-c,n=c,!l)return!0;var g=u._handle.write(e,t,a,n,u._buffer,u._offset,u._chunkSize);return g.callback=v,void(g.buffer=t)}if(!l)return!1;r()}}b.buffer=t,b.callback=v},u.inherits(m,A),u.inherits(_,A),u.inherits(E,A),u.inherits(S,A),u.inherits(k,A),u.inherits(O,A),u.inherits(T,A)},8287:(t,e,r)=>{const n=r(7526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=s,e.SlowBuffer=function(t){return+t!=t&&(t=0),s.alloc(+t)},e.INSPECT_MAX_BYTES=50;const a=2147483647;function u(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return c(t,e,r)}function c(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=u(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return s.from(n,e,r);const i=function(t){if(s.isBuffer(t)){const e=0|d(t.length),r=u(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Z(t.length)?u(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 s.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return f(t),u(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=u(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,s.prototype),n}function d(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return z(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function g(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 I(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Z(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=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){let o,a=1,u=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,u/=2,s/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<u;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===s)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+s>u&&(r=u-s),o=r;o>=0;o--){let r=!0;for(let n=0;n<s;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(Z(n))return a;t[r+a]=n}return a}function _(t,e,r,n){return Y(q(e,t.length-r),t,r,n)}function E(t,e,r,n){return Y(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 Y(z(e),t,r,n)}function k(t,e,r,n){return Y(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,u,s;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(s=(31&e)<<6|63&r,s>127&&(o=s));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(s=(15&e)<<12|(63&r)<<6|63&n,s>2047&&(s<55296||s>57343)&&(o=s));break;case 4:r=t[i+1],n=t[i+2],u=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&u)&&(s=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&u,s>65535&&s<1114112&&(o=s))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=x));return r}(n)}e.kMaxLength=a,s.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}}(),s.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(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(t,e,r){return c(t,e,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(t,e,r){return function(t,e,r){return f(t),t<=0?u(t):void 0!==e?"string"==typeof r?u(t).fill(e,r):u(t).fill(e):u(t)}(t,e,r)},s.allocUnsafe=function(t){return l(t)},s.allocUnsafeSlow=function(t){return l(t)},s.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==s.prototype},s.compare=function(t,e){if(X(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},s.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}},s.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=s.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(X(e,Uint8Array))i+e.length>n.length?(s.isBuffer(e)||(e=s.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!s.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},s.byteLength=y,s.prototype._isBuffer=!0,s.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)b(this,e,e+1);return this},s.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)b(this,e,e+3),b(this,e+1,e+2);return this},s.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)b(this,e,e+7),b(this,e+1,e+6),b(this,e+2,e+5),b(this,e+3,e+4);return this},s.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?T(this,0,t):g.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(s.prototype[o]=s.prototype.inspect),s.prototype.compare=function(t,e,r,n,i){if(X(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const u=Math.min(o,a),c=this.slice(n,i),f=t.slice(e,r);for(let t=0;t<u;++t)if(c[t]!==f[t]){o=c[t],a=f[t];break}return o<a?-1:a<o?1:0},s.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},s.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},s.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},s.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":case"latin1":case"binary":return E(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const x=4096;function A(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function P(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function I(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=$[t[n]];return i}function L(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 B(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 R(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function j(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function N(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.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,s.prototype),n},s.prototype.readUintLE=s.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readBigUInt64LE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),s.prototype.readBigUInt64BE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||B(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||B(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readBigInt64LE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),s.prototype.readBigInt64BE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),s.prototype.readFloatLE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||R(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||R(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||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},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||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},s.prototype.writeBigUInt64LE=J((function(t,e=0){return j(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeBigUInt64BE=J((function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);R(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);R(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||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},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||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},s.prototype.writeBigInt64LE=J((function(t,e=0){return j(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeBigInt64BE=J((function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.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},s.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&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=s.isBuffer(t)?t:s.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const M={};function D(t,e,r){M[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 H(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function K(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new M.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||W(e,t.length-(r+1))}(n,i,o)}function G(t,e){if("number"!=typeof t)throw new M.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,r){if(Math.floor(t)!==t)throw G(t,r),new M.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}D("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),D("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),D("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=H(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=H(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const V=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function z(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Z(t){return t!=t}const $=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},3144:(t,e,r)=>{var n=r(6743),i=r(1002),o=r(76),a=r(7119);t.exports=a||n.call(o,i)},2205:(t,e,r)=>{var n=r(6743),i=r(1002),o=r(3144);t.exports=function(){return o(n,i,arguments)}},1002:t=>{t.exports=Function.prototype.apply},76:t=>{t.exports=Function.prototype.call},3126:(t,e,r)=>{var n=r(6743),i=r(9675),o=r(76),a=r(3144);t.exports=function(t){if(t.length<1||"function"!=typeof t[0])throw new i("a function is required");return a(n,o,t)}},7119:t=>{t.exports="undefined"!=typeof Reflect&&Reflect&&Reflect.apply},8075:(t,e,r)=>{var n=r(453),i=r(487),o=i(n("String.prototype.indexOf"));t.exports=function(t,e){var r=n(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?i(r):r}},487:(t,e,r)=>{var n=r(6897),i=r(655),o=r(3126),a=r(2205);t.exports=function(t){var e=o(arguments),r=t.length-(arguments.length-1);return n(e,1+(r>0?r:0),!0)},i?i(t.exports,"apply",{value:a}):t.exports.apply=a},6556:(t,e,r)=>{var n=r(453),i=r(3126),o=i([n("%String.prototype.indexOf%")]);t.exports=function(t,e){var r=n(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?i([r]):r}},6168:(t,e,r)=>{var n=r(2861).Buffer,i=r(8310).Transform,o=r(9579).I;function a(t){i.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(6698)(a,i);var u="undefined"!=typeof Uint8Array,s="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&ArrayBuffer.isView&&(n.prototype instanceof Uint8Array||n.TYPED_ARRAY_SUPPORT);a.prototype.update=function(t,e,r){var i=function(t,e){if(t instanceof n)return t;if("string"==typeof t)return n.from(t,e);if(s&&ArrayBuffer.isView(t)){if(0===t.byteLength)return n.alloc(0);var r=n.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}if(u&&t instanceof Uint8Array)return n.from(t);if(n.isBuffer(t)&&t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t))return n.from(t);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}(t,e),o=this._update(i);return this.hashMode?this:(r&&(o=this._toString(o,r)),o)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},a.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},a.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},a.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error("can’t switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},t.exports=a},7108:(t,e,r)=>{var n=r(6698),i=r(320),o=r(6011),a=r(2802),u=r(6168);function s(t){u.call(this,"digest"),this._hash=t}n(s,u),s.prototype._update=function(t){this._hash.update(t)},s.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return"md5"===(t=t.toLowerCase())?new i:"rmd160"===t||"ripemd160"===t?new o:new s(a(t))}},320:(t,e,r)=>{var n=r(320);t.exports=function(t){return(new n).update(t).digest()}},41:(t,e,r)=>{var n=r(655),i=r(8068),o=r(9675),a=r(5795);t.exports=function(t,e,r){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new o("`obj` must be an object or a function`");if("string"!=typeof e&&"symbol"!=typeof e)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var u=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,c=arguments.length>5?arguments[5]:null,f=arguments.length>6&&arguments[6],l=!!a&&a(t,e);if(n)n(t,e,{configurable:null===c&&l?l.configurable:!c,enumerable:null===u&&l?l.enumerable:!u,value:r,writable:null===s&&l?l.writable:!s});else{if(!f&&(u||s||c))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");t[e]=r}}},8452:(t,e,r)=>{var n=r(1189),i="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),o=Object.prototype.toString,a=Array.prototype.concat,u=r(41),s=r(592)(),c=function(t,e,r,n){if(e in t)if(!0===n){if(t[e]===r)return}else if(!function(t){return"function"==typeof t&&"[object Function]"===o.call(t)}(n)||!n())return;s?u(t,e,r,!0):u(t,e,r)},f=function(t,e){var r=arguments.length>2?arguments[2]:{},o=n(e);i&&(o=a.call(o,Object.getOwnPropertySymbols(e)));for(var u=0;u<o.length;u+=1)c(t,o[u],e[o[u]],r[o[u]])};f.supportsDescriptors=!!s,t.exports=f},7176:(t,e,r)=>{var n,i=r(3126),o=r(5795);try{n=[].__proto__===Array.prototype}catch(t){if(!t||"object"!=typeof t||!("code"in t)||"ERR_PROTO_ACCESS"!==t.code)throw t}var a=!!n&&o&&o(Object.prototype,"__proto__"),u=Object,s=u.getPrototypeOf;t.exports=a&&"function"==typeof a.get?i([a.get]):"function"==typeof s&&function(t){return s(null==t?t:u(t))}},9284:(t,e,r)=>{var n=r(2861).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),a=o.charCodeAt(0);if(255!==e[a])throw new TypeError(o+" is ambiguous");e[a]=i}var u=t.length,s=t.charAt(0),c=Math.log(u)/Math.log(256),f=Math.log(256)/Math.log(u);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return n.alloc(0);for(var r=0,i=0,o=0;t[r]===s;)i++,r++;for(var a=(t.length-r)*c+1>>>0,f=new Uint8Array(a);r<t.length;){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,p=a-1;(0!==l||h<o)&&-1!==p;p--,h++)l+=u*f[p]>>>0,f[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}for(var d=a-o;d!==a&&0===f[d];)d++;var y=n.allocUnsafe(i+(a-d));y.fill(0,0,i);for(var g=i;d!==a;)y[g++]=f[d++];return y}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,a=e.length;o!==a&&0===e[o];)o++,r++;for(var c=(a-o)*f+1>>>0,l=new Uint8Array(c);o!==a;){for(var h=e[o],p=0,d=c-1;(0!==h||p<i)&&-1!==d;d--,p++)h+=256*l[d]>>>0,l[d]=h%u>>>0,h=h/u>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,o++}for(var y=c-i;y!==c&&0===l[y];)y++;for(var g=s.repeat(r);y<c;++y)g+=t.charAt(l[y]);return g},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+u+" character")}}}},3835:(t,e,r)=>{var n=r(9284);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},8212:(t,e,r)=>{var n=r(3835),i=r(2861).Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=t(e);return n.encode(i.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},2577:(t,e,r)=>{var n=r(7108),i=r(8212);t.exports=i((function(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}))},8377:(t,e,r)=>{var n=r(8287).Buffer,i=r(2577);function o(t,e){if(void 0!==e&&t[0]!==e)throw new Error("Invalid network version");if(33===t.length)return{version:t[0],privateKey:t.slice(1,33),compressed:!1};if(34!==t.length)throw new Error("Invalid WIF length");if(1!==t[33])throw new Error("Invalid compression flag");return{version:t[0],privateKey:t.slice(1,33),compressed:!0}}function a(t,e,r){var i=new n(r?34:33);return i.writeUInt8(t,0),e.copy(i,1),r&&(i[33]=1),i}t.exports={decode:function(t,e){return o(i.decode(t),e)},decodeRaw:o,encode:function(t,e,r){return"number"==typeof t?i.encode(a(t,e,r)):i.encode(a(t.version,t.privateKey,t.compressed))},encodeRaw:a}},5170:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.ECPairFactory=e.networks=void 0;const i=r(5249);e.networks=i;const o=r(953),a=r(3209),u=r(8377),s=r(709),c=o.typeforce.maybe(o.typeforce.compile({compressed:o.maybe(o.Boolean),network:o.maybe(o.Network)}));e.ECPairFactory=function(t){function e(e,r){if(o.typeforce(o.Buffer256bit,e),!t.isPrivate(e))throw new TypeError("Private key not in range [1, n)");return o.typeforce(c,r),new f(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(c,r),new f(void 0,e,r)}(0,s.testEcc)(t);class f{__D;__Q;compressed;network;lowR;constructor(e,r,o){this.__D=e,this.__Q=r,this.lowR=!1,void 0===o&&(o={}),this.compressed=void 0===o.compressed||o.compressed,this.network=o.network||i.bitcoin,void 0!==r&&(this.__Q=n.from(t.pointCompress(r,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const e=t.pointFromScalar(this.__D,this.compressed);this.__Q=n.from(e)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return u.encode(this.network.wif,this.__D,this.compressed)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}sign(e,r){if(!this.__D)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.__D));{let r=t.sign(e,this.__D);const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=t.sign(e,this.__D,i);return n.from(r)}}signSchnorr(e){if(!this.privateKey)throw new Error("Missing private key");if(!t.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}tweakFromPublicKey(e){const i=32===(o=this.publicKey).length?o:o.slice(1,33);var o;const a=t.xOnlyPointAddTweak(i,e);if(!a||null===a.xOnlyPubkey)throw new Error("Cannot tweak public key!");const u=n.from([0===a.parity?2:3]);return r(n.concat([u,a.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(r){const i=3!==this.publicKey[0]&&(4!==this.publicKey[0]||1&~this.publicKey[64])?this.privateKey:t.privateNegate(this.privateKey),o=t.privateAdd(i,r);if(!o)throw new Error("Invalid tweaked private key!");return e(n.from(o),{network:this.network,compressed:this.compressed})}}return{isPoint:function(e){return t.isPoint(e)},fromPrivateKey:e,fromPublicKey:r,fromWIF:function(t,r){const n=u.decode(t),a=n.version;if(o.Array(r)){if(r=r.filter((t=>a===t.wif)).pop(),!r)throw new Error("Unknown network version")}else if(r=r||i.bitcoin,a!==r.wif)throw new Error("Invalid network version");return e(n.privateKey,{compressed:n.compressed,network:r})},makeRandom:function(r){o.typeforce(c,r),void 0===r&&(r={});const n=r.rng||a;let i;do{i=n(32),o.typeforce(o.Buffer256bit,i)}while(!t.isPrivate(i));return e(i,r)}}}},8700:(t,e,r)=>{e.dg=void 0;var n=r(5170);Object.defineProperty(e,"dg",{enumerable:!0,get:function(){return n.ECPairFactory}})},5249:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.testnet=e.bitcoin=void 0,e.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},709:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,"hex");function o(t){if(!t)throw new Error("ecc library invalid")}e.testEcc=function(t){o(t.isPoint(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(!t.isPoint(i("030000000000000000000000000000000000000000000000000000000000000005"))),o(t.isPrivate(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(!t.isPrivate(i("0000000000000000000000000000000000000000000000000000000000000000"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),o(n.from(t.privateAdd(i("0000000000000000000000000000000000000000000000000000000000000001"),i("0000000000000000000000000000000000000000000000000000000000000000"))).equals(i("0000000000000000000000000000000000000000000000000000000000000001"))),o(null===t.privateAdd(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateAdd(i("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),i("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(i("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),o(n.from(t.privateNegate(i("0000000000000000000000000000000000000000000000000000000000000001"))).equals(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(n.from(t.privateNegate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateNegate(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointFromScalar(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),o(null===t.xOnlyPointAddTweak(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")));let e=t.xOnlyPointAddTweak(i("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),i("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));o(n.from(e.xOnlyPubkey).equals(i("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&1===e.parity),e=t.xOnlyPointAddTweak(i("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),i("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),o(n.from(e.xOnlyPubkey).equals(i("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&0===e.parity),o(n.from(t.sign(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),o(t.verify(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),t.signSchnorr&&o(n.from(t.signSchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),i("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),t.verifySchnorr&&o(t.verifySchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}},953:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=r(8676),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe},655:t=>{var e=Object.defineProperty||!1;if(e)try{e({},"a",{value:1})}catch(t){e=!1}t.exports=e},1237:t=>{t.exports=EvalError},9383:t=>{t.exports=Error},9290:t=>{t.exports=RangeError},9538:t=>{t.exports=ReferenceError},8068:t=>{t.exports=SyntaxError},9675:t=>{t.exports=TypeError},5345:t=>{t.exports=URIError},9612:t=>{t.exports=Object},7007:t=>{var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function u(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function s(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function c(t,e,r,n){var i,o,a,c;if(u(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),a=o[e]),void 0===a)a=o[e]=r,++t._eventsCount;else if("function"==typeof a?a=o[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=s(t))>0&&a.length>i&&!a.warned){a.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=t,f.type=e,f.count=a.length,c=f,console&&console.warn&&console.warn(c)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=f.bind(n);return i.listener=r,n.wrapFn=i,i}function h(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):d(i,i.length)}function p(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function y(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function i(o){n.once&&t.removeEventListener(e,i),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return s(this)},o.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i="error"===t,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var u=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw u.context=a,u}var s=o[t];if(void 0===s)return!1;if("function"==typeof s)n(s,this,e);else{var c=s.length,f=d(s,c);for(r=0;r<c;++r)n(f[r],this,e)}return!0},o.prototype.addListener=function(t,e){return c(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return c(this,t,e,!0)},o.prototype.once=function(t,e){return u(e),this.on(t,l(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return u(e),this.prependListener(t,l(this,t,e)),this},o.prototype.removeListener=function(t,e){var r,n,i,o,a;if(u(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,a||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},2682:(t,e,r)=>{var n=r(9600),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(t,e,r){if(!n(e))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),"[object Array]"===i.call(t)?function(t,e,r){for(var n=0,i=t.length;n<i;n++)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,a):"string"==typeof t?function(t,e,r){for(var n=0,i=t.length;n<i;n++)null==r?e(t.charAt(n),n,t):e.call(r,t.charAt(n),n,t)}(t,e,a):function(t,e,r){for(var n in t)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,a)}},9353:t=>{var e=Object.prototype.toString,r=Math.max,n=function(t,e){for(var r=[],n=0;n<t.length;n+=1)r[n]=t[n];for(var i=0;i<e.length;i+=1)r[i+t.length]=e[i];return r};t.exports=function(t){var i=this;if("function"!=typeof i||"[object Function]"!==e.apply(i))throw new TypeError("Function.prototype.bind called on incompatible "+i);for(var o,a=function(t){for(var e=[],r=1,n=0;r<t.length;r+=1,n+=1)e[n]=t[r];return e}(arguments),u=r(0,i.length-a.length),s=[],c=0;c<u;c++)s[c]="$"+c;if(o=Function("binder","return function ("+function(t){for(var e="",r=0;r<t.length;r+=1)e+=t[r],r+1<t.length&&(e+=",");return e}(s)+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof o){var e=i.apply(this,n(a,arguments));return Object(e)===e?e:this}return i.apply(t,n(a,arguments))})),i.prototype){var f=function(){};f.prototype=i.prototype,o.prototype=new f,f.prototype=null}return o}},6743:(t,e,r)=>{var n=r(9353);t.exports=Function.prototype.bind||n},453:(t,e,r)=>{var n,i=r(9612),o=r(9383),a=r(1237),u=r(9290),s=r(9538),c=r(8068),f=r(9675),l=r(5345),h=r(1514),p=r(8968),d=r(6188),y=r(8002),g=r(5880),b=r(414),v=r(3093),w=Function,m=function(t){try{return w('"use strict"; return ('+t+").constructor;")()}catch(t){}},_=r(5795),E=r(655),S=function(){throw new f},k=_?function(){try{return S}catch(t){try{return _(arguments,"callee").get}catch(t){return S}}}():S,O=r(4039)(),T=r(3628),x=r(1064),A=r(8648),P=r(1002),I=r(76),L={},B="undefined"!=typeof Uint8Array&&T?T(Uint8Array):n,R={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"%ArrayIteratorPrototype%":O&&T?T([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":L,"%AsyncGenerator%":L,"%AsyncGeneratorFunction%":L,"%AsyncIteratorPrototype%":L,"%Atomics%":"undefined"==typeof Atomics?n:Atomics,"%BigInt%":"undefined"==typeof BigInt?n:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?n:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":o,"%eval%":eval,"%EvalError%":a,"%Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?n:FinalizationRegistry,"%Function%":w,"%GeneratorFunction%":L,"%Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":O&&T?T(T([][Symbol.iterator]())):n,"%JSON%":"object"==typeof JSON?JSON:n,"%Map%":"undefined"==typeof Map?n:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&O&&T?T((new Map)[Symbol.iterator]()):n,"%Math%":Math,"%Number%":Number,"%Object%":i,"%Object.getOwnPropertyDescriptor%":_,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?n:Promise,"%Proxy%":"undefined"==typeof Proxy?n:Proxy,"%RangeError%":u,"%ReferenceError%":s,"%Reflect%":"undefined"==typeof Reflect?n:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?n:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&O&&T?T((new Set)[Symbol.iterator]()):n,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":O&&T?T(""[Symbol.iterator]()):n,"%Symbol%":O?Symbol:n,"%SyntaxError%":c,"%ThrowTypeError%":k,"%TypedArray%":B,"%TypeError%":f,"%Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"%URIError%":l,"%WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?n:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?n:WeakSet,"%Function.prototype.call%":I,"%Function.prototype.apply%":P,"%Object.defineProperty%":E,"%Object.getPrototypeOf%":x,"%Math.abs%":h,"%Math.floor%":p,"%Math.max%":d,"%Math.min%":y,"%Math.pow%":g,"%Math.round%":b,"%Math.sign%":v,"%Reflect.getPrototypeOf%":A};if(T)try{null.error}catch(t){var j=T(T(t));R["%Error.prototype%"]=j}var N=function t(e){var r;if("%AsyncFunction%"===e)r=m("async function () {}");else if("%GeneratorFunction%"===e)r=m("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=m("async function* () {}");else if("%AsyncGenerator%"===e){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===e){var i=t("%AsyncGenerator%");i&&T&&(r=T(i.prototype))}return R[e]=r,r},U={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},C=r(6743),F=r(9957),M=C.call(I,Array.prototype.concat),D=C.call(P,Array.prototype.splice),H=C.call(I,String.prototype.replace),K=C.call(I,String.prototype.slice),G=C.call(I,RegExp.prototype.exec),W=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,V=/\\(\\)?/g,q=function(t,e){var r,n=t;if(F(U,n)&&(n="%"+(r=U[n])[0]+"%"),F(R,n)){var i=R[n];if(i===L&&(i=N(n)),void 0===i&&!e)throw new f("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new c("intrinsic "+t+" does not exist!")};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new f("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new f('"allowMissing" argument must be a boolean');if(null===G(/^%?[^%]*%?$/,t))throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=K(t,0,1),r=K(t,-1);if("%"===e&&"%"!==r)throw new c("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new c("invalid intrinsic syntax, expected opening `%`");var n=[];return H(t,W,(function(t,e,r,i){n[n.length]=r?H(i,V,"$1"):e||t})),n}(t),n=r.length>0?r[0]:"",i=q("%"+n+"%",e),o=i.name,a=i.value,u=!1,s=i.alias;s&&(n=s[0],D(r,M([0,1],s)));for(var l=1,h=!0;l<r.length;l+=1){var p=r[l],d=K(p,0,1),y=K(p,-1);if(('"'===d||"'"===d||"`"===d||'"'===y||"'"===y||"`"===y)&&d!==y)throw new c("property names with quotes must have matching quotes");if("constructor"!==p&&h||(u=!0),F(R,o="%"+(n+="."+p)+"%"))a=R[o];else if(null!=a){if(!(p in a)){if(!e)throw new f("base intrinsic for "+t+" exists, but the property is not available.");return}if(_&&l+1>=r.length){var g=_(a,p);a=(h=!!g)&&"get"in g&&!("originalValue"in g.get)?g.get:a[p]}else h=F(a,p),a=a[p];h&&!u&&(R[o]=a)}}return a}},1064:(t,e,r)=>{var n=r(9612);t.exports=n.getPrototypeOf||null},8648:t=>{t.exports="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null},3628:(t,e,r)=>{var n=r(8648),i=r(1064),o=r(7176);t.exports=n?function(t){return n(t)}:i?function(t){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("getProto: not an object");return i(t)}:o?function(t){return o(t)}:null},6549:t=>{t.exports=Object.getOwnPropertyDescriptor},5795:(t,e,r)=>{var n=r(6549);if(n)try{n([],"length")}catch(t){n=null}t.exports=n},592:(t,e,r)=>{var n=r(655),i=function(){return!!n};i.hasArrayLengthDefineBug=function(){if(!n)return null;try{return 1!==n([],"length",{value:1}).length}catch(t){return!0}},t.exports=i},4039:(t,e,r)=>{var n="undefined"!=typeof Symbol&&Symbol,i=r(1333);t.exports=function(){return"function"==typeof n&&"function"==typeof Symbol&&"symbol"==typeof n("foo")&&"symbol"==typeof Symbol("bar")&&i()}},1333:t=>{t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var n in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var i=Object.getOwnPropertySymbols(t);if(1!==i.length||i[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(t,e);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},9092:(t,e,r)=>{var n=r(1333);t.exports=function(){return n()&&!!Symbol.toStringTag}},4729:(t,e,r)=>{var n=r(2861).Buffer,i=r(1603).Transform;function o(t){i.call(this),this._block=n.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(6698)(o,i),o.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},o.prototype.update=function(t,e){if(function(t){if(!n.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer")}(t),this._finalized)throw new Error("Digest already called");n.isBuffer(t)||(t=n.from(t,e));for(var r=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)r[o++]=t[i++];this._update(),this._blockOffset=0}for(;i<t.length;)r[this._blockOffset++]=t[i++];for(var a=0,u=8*t.length;u>0;++a)this._length[a]+=u,(u=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*u);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},2260:t=>{var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(t,e,r){var i,o,a;if("string"==typeof e&&(a="not ",e.substr(0,4)===a)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))o="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var u=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+1>t.length)&&-1!==t.indexOf(".",r)}(t)?"property":"argument";o='The "'.concat(t,'" ').concat(u," ").concat(i," ").concat(n(e,"type"))}return o+". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},2818:(t,e,r)=>{var n=r(5606),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var o=r(6736),a=r(2192);r(6698)(f,o);for(var u=i(a.prototype),s=0;s<u.length;s++){var c=u[s];f.prototype[c]||(f.prototype[c]=a.prototype[c])}function f(t){if(!(this instanceof f))return new f(t);o.call(this,t),a.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},5860:(t,e,r)=>{t.exports=i;var n=r(3054);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(6698)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},6736:(t,e,r)=>{var n,i=r(5606);t.exports=O,O.ReadableState=k,r(7007).EventEmitter;var o,a=function(t,e){return t.listeners(e).length},u=r(1181),s=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(2382);o=f&&f.debuglog?f.debuglog("stream"):function(){};var l,h,p,d=r(2389),y=r(1468),g=r(8775).getHighWaterMark,b=r(2260).F,v=b.ERR_INVALID_ARG_TYPE,w=b.ERR_STREAM_PUSH_AFTER_EOF,m=b.ERR_METHOD_NOT_IMPLEMENTED,_=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(O,u);var E=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function k(t,e,i){n=n||r(2818),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",i),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=r(7137).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function O(t){if(n=n||r(2818),!(this instanceof O))return new O(t);var e=this instanceof n;this._readableState=new k(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),u.call(this)}function T(t,e,r,n,i){o("readableAddChunk",e);var a,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?I(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,L(t)))}}(t,u);else if(i||(a=function(t,e){var r,n;return n=e,s.isBuffer(n)||n instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],e)),r}(u,e)),a)E(t,a);else if(u.objectMode||e&&e.length>0)if("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===s.prototype||(e=function(t){return s.from(t)}(e)),n)u.endEmitted?E(t,new _):x(t,u,e,!0);else if(u.ended)E(t,new w);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!r?(e=u.decoder.write(e),u.objectMode||0!==e.length?x(t,u,e,!1):B(t,u)):x(t,u,e,!1)}else n||(u.reading=!1,B(t,u));return!u.ended&&(u.length<u.highWaterMark||0===u.length)}function x(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&I(t)),B(t,e)}Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),O.prototype.destroy=y.destroy,O.prototype._undestroy=y.undestroy,O.prototype._destroy=function(t,e){e(t)},O.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=s.from(t,e),e=""),r=!0),T(this,t,e,!1,r)},O.prototype.unshift=function(t){return T(this,t,null,!0,!1)},O.prototype.isPaused=function(){return!1===this._readableState.flowing},O.prototype.setEncoding=function(t){l||(l=r(7137).I);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var A=1073741824;function P(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=A?t=A:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function I(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(L,t))}function L(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,C(t)}function B(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(R,t,e))}function R(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function j(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function N(t){o("readable nexttick read 0"),t.read(0)}function U(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function F(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function M(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}O.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):I(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&M(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=P(r,e))),null===(n=t>0?F(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&M(this)),null!==n&&this.emit("data",n),n},O.prototype._read=function(t){E(this,new m("_read()"))},O.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o("pipe count=%d opts=%j",n.pipesCount,e);var u=e&&!1===e.end||t===i.stdout||t===i.stderr?y:s;function s(){o("onend"),t.end()}n.endEmitted?i.nextTick(u):r.once("end",u),t.on("unpipe",(function e(i,a){o("onunpipe"),i===r&&a&&!1===a.hasUnpiped&&(a.hasUnpiped=!0,o("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",s),r.removeListener("end",y),r.removeListener("data",l),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||c())}));var c=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",c);var f=!1;function l(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==H(n.pipes,t))&&!f&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===a(t,"error")&&E(t,e)}function p(){t.removeListener("finish",d),y()}function d(){o("onfinish"),t.removeListener("close",p),y()}function y(){o("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),t},O.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=H(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},O.prototype.on=function(t,e){var r=u.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,o("on readable",n.length,n.reading),n.length?I(this):n.reading||i.nextTick(N,this))),r},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(t,e){var r=u.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(j,this),r},O.prototype.removeAllListeners=function(t){var e=u.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(j,this),e},O.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(U,t,e))}(this,t)),t.paused=!1,this},O.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},O.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",(function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<S.length;a++)t.on(S[a],this.emit.bind(this,S[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(O.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(4743)),h(this)}),Object.defineProperty(O.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(O.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(O.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),O._fromList=F,Object.defineProperty(O.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(O.from=function(t,e){return void 0===p&&(p=r(5049)),p(O,t,e)})},3054:(t,e,r)=>{t.exports=f;var n=r(2260).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,u=n.ERR_TRANSFORM_WITH_LENGTH_0,s=r(2818);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function f(t){if(!(this instanceof f))return new f(t);s.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush((function(e,r){h(t,e,r)}))}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new u;if(t._transformState.transforming)throw new a;return t.push(null)}r(6698)(f,s),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,s.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,r){r(new i("_transform()"))},f.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},f.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},f.prototype._destroy=function(t,e){s.prototype._destroy.call(this,t,(function(t){e(t)}))}},2192:(t,e,r)=>{var n,i=r(5606);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=O,O.WritableState=k;var a,u={deprecate:r(4643)},s=r(1181),c=r(8287).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(1468),h=r(8775).getHighWaterMark,p=r(2260).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,g=p.ERR_MULTIPLE_CALLBACK,b=p.ERR_STREAM_CANNOT_PIPE,v=p.ERR_STREAM_DESTROYED,w=p.ERR_STREAM_NULL_VALUES,m=p.ERR_STREAM_WRITE_AFTER_END,_=p.ERR_UNKNOWN_ENCODING,E=l.errorOrDestroy;function S(){}function k(t,e,a){n=n||r(2818),t=t||{},"boolean"!=typeof a&&(a=e instanceof n),this.objectMode=!!t.objectMode,a&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",a),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var u=!1===t.decodeStrings;this.decodeStrings=!u,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,o){--e.pendingcb,r?(i.nextTick(o,n),i.nextTick(L,t,e),t._writableState.errorEmitted=!0,E(t,n)):(o(n),t._writableState.errorEmitted=!0,E(t,n),L(t,e))}(t,r,n,e,o);else{var a=P(r)||t.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||A(t,r),n?i.nextTick(x,t,r,a,o):x(t,r,a,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function O(t){var e=this instanceof(n=n||r(2818));if(!e&&!a.call(O,this))return new O(t);this._writableState=new k(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),s.call(this)}function T(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new v("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function x(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),L(t,e)}function A(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),a=e.corkedRequestsFree;a.entry=r;for(var u=0,s=!0;r;)i[u]=r,r.isBuf||(s=!1),r=r.next,u+=1;i.allBuffers=s,T(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,l=r.callback;if(T(t,e,!1,e.objectMode?1:c.length,c,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function P(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function I(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit("prefinish"),L(t,e)}))}function L(t,e){var r=P(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(I,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(6698)(O,s),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,"buffer",{get:u.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(O,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===O&&t&&t._writableState instanceof k}})):a=function(t){return t instanceof this},O.prototype.pipe=function(){E(this,new b)},O.prototype.write=function(t,e,r){var n,o=this._writableState,a=!1,u=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof f);return u&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),u?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(t,e){var r=new m;E(t,r),i.nextTick(e,r)}(this,r):(u||function(t,e,r,n){var o;return null===r?o=new w:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(E(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,a=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var u=e.objectMode?1:n.length;e.length+=u;var s=e.length<e.highWaterMark;if(s||(e.needDrain=!0),e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else T(t,e,!1,u,n,i,o);return s}(this,o,u,t,e,r)),a},O.prototype.cork=function(){this._writableState.corked++},O.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||A(this,t))},O.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new _(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(O.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(O.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),O.prototype._write=function(t,e,r){r(new y("_write()"))},O.prototype._writev=null,O.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,L(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(O.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),O.prototype.destroy=l.destroy,O.prototype._undestroy=l.undestroy,O.prototype._destroy=function(t,e){e(t)}},4743:(t,e,r)=>{var n,i=r(5606);function o(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var a=r(5826),u=Symbol("lastResolve"),s=Symbol("lastReject"),c=Symbol("error"),f=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[u];if(null!==e){var r=t[p].read();null!==r&&(t[l]=null,t[u]=null,t[s]=null,e(d(r,!1)))}}function g(t){i.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[f])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise((function(e,r){i.nextTick((function(){t[c]?r(t[c]):e(d(void 0,!0))}))}));var r,n=this[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[f]?r(d(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[h])}return this[l]=r,r}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var t=this;return new Promise((function(e,r){t[p].destroy(null,(function(t){t?r(t):e(d(void 0,!0))}))}))})),n),b);t.exports=function(t){var e,r=Object.create(v,(o(e={},p,{value:t,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,f,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[l]=null,r[u]=null,r[s]=null,t(d(n,!1))):(r[u]=t,r[s]=e)},writable:!0}),e));return r[l]=null,a(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[s];return null!==e&&(r[l]=null,r[u]=null,r[s]=null,e(t)),void(r[c]=t)}var n=r[u];null!==n&&(r[l]=null,r[u]=null,r[s]=null,n(d(void 0,!0))),r[f]=!0})),t.on("readable",g.bind(null,r)),r}},2389:(t,e,r)=>{function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e,r){return(e=u(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,u(n.key),n)}}function u(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var s=r(8287).Buffer,c=r(8460).inspect,f=c&&c.custom||"inspect";function l(t,e,r){s.prototype.copy.call(t,e,r)}t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r;return e=t,r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return s.alloc(0);for(var e=s.allocUnsafe(t>>>0),r=this.head,n=0;r;)l(r.data,e,n),n+=r.data.length,r=r.next;return e}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=s.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:f,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},1468:(t,e,r)=>{var n=r(5606);function i(t,e){a(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,u=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return u||s?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(a,this,t)):n.nextTick(a,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,t)):n.nextTick(i,r,t):e?(n.nextTick(o,r),e(t)):n.nextTick(o,r)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},5826:(t,e,r)=>{var n=r(2260).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var a=r.readable||!1!==r.readable&&e.readable,u=r.writable||!1!==r.writable&&e.writable,s=function(){e.writable||f()},c=e._writableState&&e._writableState.finished,f=function(){u=!1,c=!0,a||o.call(e)},l=e._readableState&&e._readableState.endEmitted,h=function(){a=!1,l=!0,u||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!l?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):u&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",f),e.on("abort",d),e.req?y():e.on("request",y)):u&&!e._writableState&&(e.on("end",s),e.on("close",s)),e.on("end",h),e.on("finish",f),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",f),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",s),e.removeListener("close",s),e.removeListener("finish",f),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},5049:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},9434:(t,e,r)=>{var n,i=r(2260).F,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function u(t){if(t)throw t}function s(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var f,l=function(t){return t.length?"function"!=typeof t[t.length-1]?u:t.pop():u}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var h=e.map((function(t,i){var o=i<e.length-1;return function(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var u=!1;t.on("close",(function(){u=!0})),void 0===n&&(n=r(5826)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);u=!0,o()}));var s=!1;return function(e){if(!u&&!s)return s=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new a("pipe"))}}(t,o,i>0,(function(t){f||(f=t),t&&h.forEach(s),o||(h.forEach(s),l(f))}))}));return e.reduce(c)}},8775:(t,e,r)=>{var n=r(2260).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},1181:(t,e,r)=>{t.exports=r(7007).EventEmitter},1603:(t,e,r)=>{(e=t.exports=r(6736)).Stream=e,e.Readable=e,e.Writable=r(2192),e.Duplex=r(2818),e.Transform=r(3054),e.PassThrough=r(5860),e.finished=r(5826),e.pipeline=r(9434)},7137:(t,e,r)=>{var n=r(2861).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=s,this.end=c,e=4;break;case"utf8":this.fillLast=u,e=4;break;case"base64":this.text=f,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function u(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function s(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.I=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},o.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var i=a(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},9957:(t,e,r)=>{var n=Function.prototype.call,i=Object.prototype.hasOwnProperty,o=r(6743);t.exports=o.call(n,i)},251:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,u=8*i-n-1,s=(1<<u)-1,c=s>>1,f=-7,l=r?i-1:0,h=r?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=u;f>0;o=256*o+t[e+l],l+=h,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===s)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,u,s,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-a))<1&&(a--,s*=2),(e+=a+l>=1?h/s:h*Math.pow(2,1-l))*s>=2&&(a++,s/=2),a+l>=f?(u=0,a=f):a+l>=1?(u=(e*s-1)*Math.pow(2,i),a+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&u,p+=d,u/=256,i-=8);for(a=a<<i|u,c+=i;c>0;t[r+p]=255&a,p+=d,a/=256,c-=8);t[r+p-d]|=128*y}},6698:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},7244:(t,e,r)=>{var n=r(9092)(),i=r(6556)("Object.prototype.toString"),o=function(t){return!(n&&t&&"object"==typeof t&&Symbol.toStringTag in t)&&"[object Arguments]"===i(t)},a=function(t){return!!o(t)||null!==t&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&t.length>=0&&"[object Array]"!==i(t)&&"callee"in t&&"[object Function]"===i(t.callee)},u=function(){return o(arguments)}();o.isLegacyArguments=a,t.exports=u?o:a},9600:t=>{var e,r,n=Function.prototype.toString,i="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof i&&"function"==typeof Object.defineProperty)try{e=Object.defineProperty({},"length",{get:function(){throw r}}),r={},i((function(){throw 42}),null,e)}catch(t){t!==r&&(i=null)}else i=null;var o=/^\s*class\b/,a=function(t){try{var e=n.call(t);return o.test(e)}catch(t){return!1}},u=function(t){try{return!a(t)&&(n.call(t),!0)}catch(t){return!1}},s=Object.prototype.toString,c="function"==typeof Symbol&&!!Symbol.toStringTag,f=!(0 in[,]),l=function(){return!1};if("object"==typeof document){var h=document.all;s.call(h)===s.call(document.all)&&(l=function(t){if((f||!t)&&(void 0===t||"object"==typeof t))try{var e=s.call(t);return("[object HTMLAllCollection]"===e||"[object HTML document.all class]"===e||"[object HTMLCollection]"===e||"[object Object]"===e)&&null==t("")}catch(t){}return!1})}t.exports=i?function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;try{i(t,null,e)}catch(t){if(t!==r)return!1}return!a(t)&&u(t)}:function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if(c)return u(t);if(a(t))return!1;var e=s.call(t);return!("[object Function]"!==e&&"[object GeneratorFunction]"!==e&&!/^\[object HTML/.test(e))&&u(t)}},8184:(t,e,r)=>{var n,i=r(6556),o=r(9721)(/^\s*(?:function)?\*/),a=r(9092)(),u=r(3628),s=i("Object.prototype.toString"),c=i("Function.prototype.toString");t.exports=function(t){if("function"!=typeof t)return!1;if(o(c(t)))return!0;if(!a)return"[object GeneratorFunction]"===s(t);if(!u)return!1;if(void 0===n){var e=function(){if(!a)return!1;try{return Function("return function*() {}")()}catch(t){}}();n=!!e&&u(e)}return u(t)===n}},3003:t=>{t.exports=function(t){return t!=t}},4133:(t,e,r)=>{var n=r(487),i=r(8452),o=r(3003),a=r(6642),u=r(2464),s=n(a(),Number);i(s,{getPolyfill:a,implementation:o,shim:u}),t.exports=s},6642:(t,e,r)=>{var n=r(3003);t.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:n}},2464:(t,e,r)=>{var n=r(8452),i=r(6642);t.exports=function(){var t=i();return n(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}},4035:(t,e,r)=>{var n,i=r(6556),o=r(9092)(),a=r(9957),u=r(5795);if(o){var s=i("RegExp.prototype.exec"),c={},f=function(){throw c},l={toString:f,valueOf:f};"symbol"==typeof Symbol.toPrimitive&&(l[Symbol.toPrimitive]=f),n=function(t){if(!t||"object"!=typeof t)return!1;var e=u(t,"lastIndex");if(!e||!a(e,"value"))return!1;try{s(t,l)}catch(t){return t===c}}}else{var h=i("Object.prototype.toString");n=function(t){return!(!t||"object"!=typeof t&&"function"!=typeof t)&&"[object RegExp]"===h(t)}}t.exports=n},5680:(t,e,r)=>{var n=r(5767);t.exports=function(t){return!!n(t)}},1514:t=>{t.exports=Math.abs},8968:t=>{t.exports=Math.floor},4459:t=>{t.exports=Number.isNaN||function(t){return t!=t}},6188:t=>{t.exports=Math.max},8002:t=>{t.exports=Math.min},5880:t=>{t.exports=Math.pow},414:t=>{t.exports=Math.round},3093:(t,e,r)=>{var n=r(4459);t.exports=function(t){return n(t)||0===t?t:t<0?-1:1}},9211:t=>{var e=function(t){return t!=t};t.exports=function(t,r){return 0===t&&0===r?1/t==1/r:t===r||!(!e(t)||!e(r))}},7653:(t,e,r)=>{var n=r(8452),i=r(487),o=r(9211),a=r(9394),u=r(6576),s=i(a(),Object);n(s,{getPolyfill:a,implementation:o,shim:u}),t.exports=s},9394:(t,e,r)=>{var n=r(9211);t.exports=function(){return"function"==typeof Object.is?Object.is:n}},6576:(t,e,r)=>{var n=r(9394),i=r(8452);t.exports=function(){var t=n();return i(Object,{is:t},{is:function(){return Object.is!==t}}),t}},8875:(t,e,r)=>{var n;if(!Object.keys){var i=Object.prototype.hasOwnProperty,o=Object.prototype.toString,a=r(1093),u=Object.prototype.propertyIsEnumerable,s=!u.call({toString:null},"toString"),c=u.call((function(){}),"prototype"),f=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(t){var e=t.constructor;return e&&e.prototype===t},h={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},p=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!h["$"+t]&&i.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{l(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();n=function(t){var e=null!==t&&"object"==typeof t,r="[object Function]"===o.call(t),n=a(t),u=e&&"[object String]"===o.call(t),h=[];if(!e&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var d=c&&r;if(u&&t.length>0&&!i.call(t,0))for(var y=0;y<t.length;++y)h.push(String(y));if(n&&t.length>0)for(var g=0;g<t.length;++g)h.push(String(g));else for(var b in t)d&&"prototype"===b||!i.call(t,b)||h.push(String(b));if(s)for(var v=function(t){if("undefined"==typeof window||!p)return l(t);try{return l(t)}catch(t){return!1}}(t),w=0;w<f.length;++w)v&&"constructor"===f[w]||!i.call(t,f[w])||h.push(f[w]);return h}}t.exports=n},1189:(t,e,r)=>{var n=Array.prototype.slice,i=r(1093),o=Object.keys,a=o?function(t){return o(t)}:r(8875),u=Object.keys;a.shim=function(){if(Object.keys){var t=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);t||(Object.keys=function(t){return i(t)?u(n.call(t)):u(t)})}else Object.keys=a;return Object.keys||a},t.exports=a},1093:t=>{var e=Object.prototype.toString;t.exports=function(t){var r=e.call(t),n="[object Arguments]"===r;return n||(n="[object Array]"!==r&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===e.call(t.callee)),n}},8403:(t,e,r)=>{var n=r(1189),i=r(1333)(),o=r(6556),a=r(9612),u=o("Array.prototype.push"),s=o("Object.prototype.propertyIsEnumerable"),c=i?a.getOwnPropertySymbols:null;t.exports=function(t,e){if(null==t)throw new TypeError("target must be an object");var r=a(t);if(1===arguments.length)return r;for(var o=1;o<arguments.length;++o){var f=a(arguments[o]),l=n(f),h=i&&(a.getOwnPropertySymbols||c);if(h)for(var p=h(f),d=0;d<p.length;++d){var y=p[d];s(f,y)&&u(l,y)}for(var g=0;g<l.length;++g){var b=l[g];if(s(f,b)){var v=f[b];r[b]=v}}}return r}},9133:(t,e,r)=>{var n=r(8403);t.exports=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var t="abcdefghijklmnopqrst",e=t.split(""),r={},n=0;n<e.length;++n)r[e[n]]=e[n];var i=Object.assign({},r),o="";for(var a in i)o+=a;return t!==o}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var t=Object.preventExtensions({1:2});try{Object.assign(t,"xy")}catch(e){return"y"===t[1]}return!1}()?n:Object.assign:n}},9805:(t,e)=>{var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)n(r,i)&&(t[i]=r[i])}}return t},e.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var i={arraySet:function(t,e,r,n,i){if(e.subarray&&t.subarray)t.set(e.subarray(r,r+n),i);else for(var o=0;o<n;o++)t[i+o]=e[r+o]},flattenChunks:function(t){var e,r,n,i,o,a;for(n=0,e=0,r=t.length;e<r;e++)n+=t[e].length;for(a=new Uint8Array(n),i=0,e=0,r=t.length;e<r;e++)o=t[e],a.set(o,i),i+=o.length;return a}},o={arraySet:function(t,e,r,n,i){for(var o=0;o<n;o++)t[i+o]=e[r+o]},flattenChunks:function(t){return[].concat.apply([],t)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,i)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,o))},e.setTyped(r)},3269:t=>{t.exports=function(t,e,r,n){for(var i=65535&t,o=t>>>16&65535,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+e[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16}},9681:t=>{t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},4823:t=>{var e=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();t.exports=function(t,r,n,i){var o=e,a=i+n;t^=-1;for(var u=i;u<a;u++)t=t>>>8^o[255&(t^r[u])];return~t}},8411:(t,e,r)=>{var n,i=r(9805),o=r(3665),a=r(3269),u=r(4823),s=r(4674),c=-2,f=258,l=262,h=103,p=113,d=666;function y(t,e){return t.msg=s[e],e}function g(t){return(t<<1)-(t>4?9:0)}function b(t){for(var e=t.length;--e>=0;)t[e]=0}function v(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(i.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))}function w(t,e){o._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,v(t.strm)}function m(t,e){t.pending_buf[t.pending++]=e}function _(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function E(t,e){var r,n,i=t.max_chain_length,o=t.strstart,a=t.prev_length,u=t.nice_match,s=t.strstart>t.w_size-l?t.strstart-(t.w_size-l):0,c=t.window,h=t.w_mask,p=t.prev,d=t.strstart+f,y=c[o+a-1],g=c[o+a];t.prev_length>=t.good_match&&(i>>=2),u>t.lookahead&&(u=t.lookahead);do{if(c[(r=e)+a]===g&&c[r+a-1]===y&&c[r]===c[o]&&c[++r]===c[o+1]){o+=2,r++;do{}while(c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&o<d);if(n=f-(d-o),o=d-f,n>a){if(t.match_start=e,a=n,n>=u)break;y=c[o+a-1],g=c[o+a]}}}while((e=p[e&h])>s&&0!=--i);return a<=t.lookahead?a:t.lookahead}function S(t){var e,r,n,o,s,c,f,h,p,d,y=t.w_size;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=y+(y-l)){i.arraySet(t.window,t.window,y,y,0),t.match_start-=y,t.strstart-=y,t.block_start-=y,e=r=t.hash_size;do{n=t.head[--e],t.head[e]=n>=y?n-y:0}while(--r);e=r=y;do{n=t.prev[--e],t.prev[e]=n>=y?n-y:0}while(--r);o+=y}if(0===t.strm.avail_in)break;if(c=t.strm,f=t.window,h=t.strstart+t.lookahead,p=o,d=void 0,(d=c.avail_in)>p&&(d=p),r=0===d?0:(c.avail_in-=d,i.arraySet(f,c.input,c.next_in,d,h),1===c.state.wrap?c.adler=a(c.adler,f,d,h):2===c.state.wrap&&(c.adler=u(c.adler,f,d,h)),c.next_in+=d,c.total_in+=d,d),t.lookahead+=r,t.lookahead+t.insert>=3)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=(t.ins_h<<t.hash_shift^t.window[s+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[s+3-1])&t.hash_mask,t.prev[s&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=s,s++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<l&&0!==t.strm.avail_in)}function k(t,e){for(var r,n;;){if(t.lookahead<l){if(S(t),t.lookahead<l&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-l&&(t.match_length=E(t,r)),t.match_length>=3)if(n=o._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else n=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}function O(t,e){for(var r,n,i;;){if(t.lookahead<l){if(S(t),t.lookahead<l&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-l&&(t.match_length=E(t,r),t.match_length<=5&&(1===t.strategy||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=o._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(w(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=o._tr_tally(t,0,t.window[t.strstart-1]))&&w(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=o._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}function T(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}function x(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),b(this.dyn_ltree),b(this.dyn_dtree),b(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),b(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),b(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function A(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=2,(e=t.state).pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:p,t.adler=2===e.wrap?0:1,e.last_flush=0,o._tr_init(e),0):y(t,c)}function P(t){var e=A(t);return 0===e&&function(t){t.window_size=2*t.w_size,b(t.head),t.max_lazy_match=n[t.level].max_lazy,t.good_match=n[t.level].good_length,t.nice_match=n[t.level].nice_length,t.max_chain_length=n[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0}(t.state),e}function I(t,e,r,n,o,a){if(!t)return c;var u=1;if(-1===e&&(e=6),n<0?(u=0,n=-n):n>15&&(u=2,n-=16),o<1||o>9||8!==r||n<8||n>15||e<0||e>9||a<0||a>4)return y(t,c);8===n&&(n=9);var s=new x;return t.state=s,s.strm=t,s.wrap=u,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=o+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new i.Buf8(2*s.w_size),s.head=new i.Buf16(s.hash_size),s.prev=new i.Buf16(s.w_size),s.lit_bufsize=1<<o+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new i.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=e,s.strategy=a,s.method=r,P(t)}n=[new T(0,0,0,0,(function(t,e){var r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(S(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,w(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-l&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(w(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(w(t,!1),t.strm.avail_out),1)})),new T(4,4,8,4,k),new T(4,5,16,8,k),new T(4,6,32,32,k),new T(4,4,16,16,O),new T(8,16,32,32,O),new T(8,16,128,128,O),new T(8,32,128,256,O),new T(32,128,258,1024,O),new T(32,258,258,4096,O)],e.deflateInit=function(t,e){return I(t,e,8,15,8,0)},e.deflateInit2=I,e.deflateReset=P,e.deflateResetKeep=A,e.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?c:(t.state.gzhead=e,0):c},e.deflate=function(t,e){var r,i,a,s;if(!t||!t.state||e>5||e<0)return t?y(t,c):c;if(i=t.state,!t.output||!t.input&&0!==t.avail_in||i.status===d&&4!==e)return y(t,0===t.avail_out?-5:c);if(i.strm=t,r=i.last_flush,i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,m(i,31),m(i,139),m(i,8),i.gzhead?(m(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),m(i,255&i.gzhead.time),m(i,i.gzhead.time>>8&255),m(i,i.gzhead.time>>16&255),m(i,i.gzhead.time>>24&255),m(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),m(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(m(i,255&i.gzhead.extra.length),m(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=u(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(m(i,0),m(i,0),m(i,0),m(i,0),m(i,0),m(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),m(i,3),i.status=p);else{var l=8+(i.w_bits-8<<4)<<8;l|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(l|=32),l+=31-l%31,i.status=p,_(i,l),0!==i.strstart&&(_(i,t.adler>>>16),_(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(a=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>a&&(t.adler=u(t.adler,i.pending_buf,i.pending-a,a)),v(t),a=i.pending,i.pending!==i.pending_buf_size));)m(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>a&&(t.adler=u(t.adler,i.pending_buf,i.pending-a,a)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(t.adler=u(t.adler,i.pending_buf,i.pending-a,a)),v(t),a=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,m(i,s)}while(0!==s);i.gzhead.hcrc&&i.pending>a&&(t.adler=u(t.adler,i.pending_buf,i.pending-a,a)),0===s&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(t.adler=u(t.adler,i.pending_buf,i.pending-a,a)),v(t),a=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,m(i,s)}while(0!==s);i.gzhead.hcrc&&i.pending>a&&(t.adler=u(t.adler,i.pending_buf,i.pending-a,a)),0===s&&(i.status=h)}else i.status=h;if(i.status===h&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&v(t),i.pending+2<=i.pending_buf_size&&(m(i,255&t.adler),m(i,t.adler>>8&255),t.adler=0,i.status=p)):i.status=p),0!==i.pending){if(v(t),0===t.avail_out)return i.last_flush=-1,0}else if(0===t.avail_in&&g(e)<=g(r)&&4!==e)return y(t,-5);if(i.status===d&&0!==t.avail_in)return y(t,-5);if(0!==t.avail_in||0!==i.lookahead||0!==e&&i.status!==d){var E=2===i.strategy?function(t,e){for(var r;;){if(0===t.lookahead&&(S(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,r=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}(i,e):3===i.strategy?function(t,e){for(var r,n,i,a,u=t.window;;){if(t.lookahead<=f){if(S(t),t.lookahead<=f&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=u[i=t.strstart-1])===u[++i]&&n===u[++i]&&n===u[++i]){a=t.strstart+f;do{}while(n===u[++i]&&n===u[++i]&&n===u[++i]&&n===u[++i]&&n===u[++i]&&n===u[++i]&&n===u[++i]&&n===u[++i]&&i<a);t.match_length=f-(a-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=o._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(w(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(w(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(w(t,!1),0===t.strm.avail_out)?1:2}(i,e):n[i.level].func(i,e);if(3!==E&&4!==E||(i.status=d),1===E||3===E)return 0===t.avail_out&&(i.last_flush=-1),0;if(2===E&&(1===e?o._tr_align(i):5!==e&&(o._tr_stored_block(i,0,0,!1),3===e&&(b(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),v(t),0===t.avail_out))return i.last_flush=-1,0}return 4!==e?0:i.wrap<=0?1:(2===i.wrap?(m(i,255&t.adler),m(i,t.adler>>8&255),m(i,t.adler>>16&255),m(i,t.adler>>24&255),m(i,255&t.total_in),m(i,t.total_in>>8&255),m(i,t.total_in>>16&255),m(i,t.total_in>>24&255)):(_(i,t.adler>>>16),_(i,65535&t.adler)),v(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)},e.deflateEnd=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&e!==h&&e!==p&&e!==d?y(t,c):(t.state=null,e===p?y(t,-3):0):c},e.deflateSetDictionary=function(t,e){var r,n,o,u,s,f,l,h,p=e.length;if(!t||!t.state)return c;if(2===(u=(r=t.state).wrap)||1===u&&42!==r.status||r.lookahead)return c;for(1===u&&(t.adler=a(t.adler,e,p,0)),r.wrap=0,p>=r.w_size&&(0===u&&(b(r.head),r.strstart=0,r.block_start=0,r.insert=0),h=new i.Buf8(r.w_size),i.arraySet(h,e,p-r.w_size,r.w_size,0),e=h,p=r.w_size),s=t.avail_in,f=t.next_in,l=t.input,t.avail_in=p,t.next_in=0,t.input=e,S(r);r.lookahead>=3;){n=r.strstart,o=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--o);r.strstart=n,r.lookahead=2,S(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=f,t.input=l,t.avail_in=s,r.wrap=u,0},e.deflateInfo="pako deflate (from Nodeca project)"},7293:t=>{t.exports=function(t,e){var r,n,i,o,a,u,s,c,f,l,h,p,d,y,g,b,v,w,m,_,E,S,k,O,T;r=t.state,n=t.next_in,O=t.input,i=n+(t.avail_in-5),o=t.next_out,T=t.output,a=o-(e-t.avail_out),u=o+(t.avail_out-257),s=r.dmax,c=r.wsize,f=r.whave,l=r.wnext,h=r.window,p=r.hold,d=r.bits,y=r.lencode,g=r.distcode,b=(1<<r.lenbits)-1,v=(1<<r.distbits)-1;t:do{d<15&&(p+=O[n++]<<d,d+=8,p+=O[n++]<<d,d+=8),w=y[p&b];e:for(;;){if(p>>>=m=w>>>24,d-=m,0==(m=w>>>16&255))T[o++]=65535&w;else{if(!(16&m)){if(64&m){if(32&m){r.mode=12;break t}t.msg="invalid literal/length code",r.mode=30;break t}w=y[(65535&w)+(p&(1<<m)-1)];continue e}for(_=65535&w,(m&=15)&&(d<m&&(p+=O[n++]<<d,d+=8),_+=p&(1<<m)-1,p>>>=m,d-=m),d<15&&(p+=O[n++]<<d,d+=8,p+=O[n++]<<d,d+=8),w=g[p&v];;){if(p>>>=m=w>>>24,d-=m,16&(m=w>>>16&255)){if(E=65535&w,d<(m&=15)&&(p+=O[n++]<<d,(d+=8)<m&&(p+=O[n++]<<d,d+=8)),(E+=p&(1<<m)-1)>s){t.msg="invalid distance too far back",r.mode=30;break t}if(p>>>=m,d-=m,E>(m=o-a)){if((m=E-m)>f&&r.sane){t.msg="invalid distance too far back",r.mode=30;break t}if(S=0,k=h,0===l){if(S+=c-m,m<_){_-=m;do{T[o++]=h[S++]}while(--m);S=o-E,k=T}}else if(l<m){if(S+=c+l-m,(m-=l)<_){_-=m;do{T[o++]=h[S++]}while(--m);if(S=0,l<_){_-=m=l;do{T[o++]=h[S++]}while(--m);S=o-E,k=T}}}else if(S+=l-m,m<_){_-=m;do{T[o++]=h[S++]}while(--m);S=o-E,k=T}for(;_>2;)T[o++]=k[S++],T[o++]=k[S++],T[o++]=k[S++],_-=3;_&&(T[o++]=k[S++],_>1&&(T[o++]=k[S++]))}else{S=o-E;do{T[o++]=T[S++],T[o++]=T[S++],T[o++]=T[S++],_-=3}while(_>2);_&&(T[o++]=T[S++],_>1&&(T[o++]=T[S++]))}break}if(64&m){t.msg="invalid distance code",r.mode=30;break t}w=g[(65535&w)+(p&(1<<m)-1)]}}break}}while(n<i&&o<u);n-=_=d>>3,p&=(1<<(d-=_<<3))-1,t.next_in=n,t.next_out=o,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=o<u?u-o+257:257-(o-u),r.hold=p,r.bits=d}},1447:(t,e,r)=>{var n=r(9805),i=r(3269),o=r(4823),a=r(7293),u=r(1998),s=-2,c=12,f=30;function l(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function h(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function p(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new n.Buf32(852),e.distcode=e.distdyn=new n.Buf32(592),e.sane=1,e.back=-1,0):s}function d(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,p(t)):s}function y(t,e){var r,n;return t&&t.state?(n=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?s:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,d(t))):s}function g(t,e){var r,n;return t?(n=new h,t.state=n,n.window=null,0!==(r=y(t,e))&&(t.state=null),r):s}var b,v,w=!0;function m(t){if(w){var e;for(b=new n.Buf32(512),v=new n.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(u(1,t.lens,0,288,b,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;u(2,t.lens,0,32,v,0,t.work,{bits:5}),w=!1}t.lencode=b,t.lenbits=9,t.distcode=v,t.distbits=5}function _(t,e,r,i){var o,a=t.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new n.Buf8(a.wsize)),i>=a.wsize?(n.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((o=a.wsize-a.wnext)>i&&(o=i),n.arraySet(a.window,e,r-i,o,a.wnext),(i-=o)?(n.arraySet(a.window,e,r-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=o,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=o))),0}e.inflateReset=d,e.inflateReset2=y,e.inflateResetKeep=p,e.inflateInit=function(t){return g(t,15)},e.inflateInit2=g,e.inflate=function(t,e){var r,h,p,d,y,g,b,v,w,E,S,k,O,T,x,A,P,I,L,B,R,j,N,U,C=0,F=new n.Buf8(4),M=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return s;(r=t.state).mode===c&&(r.mode=13),y=t.next_out,p=t.output,b=t.avail_out,d=t.next_in,h=t.input,g=t.avail_in,v=r.hold,w=r.bits,E=g,S=b,j=0;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;w<16;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(2&r.wrap&&35615===v){r.check=0,F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0),v=0,w=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&v)<<8)+(v>>8))%31){t.msg="incorrect header check",r.mode=f;break}if(8!=(15&v)){t.msg="unknown compression method",r.mode=f;break}if(w-=4,R=8+(15&(v>>>=4)),0===r.wbits)r.wbits=R;else if(R>r.wbits){t.msg="invalid window size",r.mode=f;break}r.dmax=1<<R,t.adler=r.check=1,r.mode=512&v?10:c,v=0,w=0;break;case 2:for(;w<16;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(r.flags=v,8!=(255&r.flags)){t.msg="unknown compression method",r.mode=f;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=f;break}r.head&&(r.head.text=v>>8&1),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0)),v=0,w=0,r.mode=3;case 3:for(;w<32;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}r.head&&(r.head.time=v),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,F[2]=v>>>16&255,F[3]=v>>>24&255,r.check=o(r.check,F,4,0)),v=0,w=0,r.mode=4;case 4:for(;w<16;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}r.head&&(r.head.xflags=255&v,r.head.os=v>>8),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0)),v=0,w=0,r.mode=5;case 5:if(1024&r.flags){for(;w<16;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}r.length=v,r.head&&(r.head.extra_len=v),512&r.flags&&(F[0]=255&v,F[1]=v>>>8&255,r.check=o(r.check,F,2,0)),v=0,w=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((k=r.length)>g&&(k=g),k&&(r.head&&(R=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),n.arraySet(r.head.extra,h,d,k,R)),512&r.flags&&(r.check=o(r.check,h,k,d)),g-=k,d+=k,r.length-=k),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===g)break t;k=0;do{R=h[d+k++],r.head&&R&&r.length<65536&&(r.head.name+=String.fromCharCode(R))}while(R&&k<g);if(512&r.flags&&(r.check=o(r.check,h,k,d)),g-=k,d+=k,R)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===g)break t;k=0;do{R=h[d+k++],r.head&&R&&r.length<65536&&(r.head.comment+=String.fromCharCode(R))}while(R&&k<g);if(512&r.flags&&(r.check=o(r.check,h,k,d)),g-=k,d+=k,R)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;w<16;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(v!==(65535&r.check)){t.msg="header crc mismatch",r.mode=f;break}v=0,w=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=c;break;case 10:for(;w<32;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}t.adler=r.check=l(v),v=0,w=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=y,t.avail_out=b,t.next_in=d,t.avail_in=g,r.hold=v,r.bits=w,2;t.adler=r.check=1,r.mode=c;case c:if(5===e||6===e)break t;case 13:if(r.last){v>>>=7&w,w-=7&w,r.mode=27;break}for(;w<3;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}switch(r.last=1&v,w-=1,3&(v>>>=1)){case 0:r.mode=14;break;case 1:if(m(r),r.mode=20,6===e){v>>>=2,w-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=f}v>>>=2,w-=2;break;case 14:for(v>>>=7&w,w-=7&w;w<32;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if((65535&v)!=(v>>>16^65535)){t.msg="invalid stored block lengths",r.mode=f;break}if(r.length=65535&v,v=0,w=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(k=r.length){if(k>g&&(k=g),k>b&&(k=b),0===k)break t;n.arraySet(p,h,d,k,y),g-=k,d+=k,b-=k,y+=k,r.length-=k;break}r.mode=c;break;case 17:for(;w<14;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(r.nlen=257+(31&v),v>>>=5,w-=5,r.ndist=1+(31&v),v>>>=5,w-=5,r.ncode=4+(15&v),v>>>=4,w-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=f;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;w<3;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}r.lens[M[r.have++]]=7&v,v>>>=3,w-=3}for(;r.have<19;)r.lens[M[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,N={bits:r.lenbits},j=u(0,r.lens,0,19,r.lencode,0,r.work,N),r.lenbits=N.bits,j){t.msg="invalid code lengths set",r.mode=f;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;A=(C=r.lencode[v&(1<<r.lenbits)-1])>>>16&255,P=65535&C,!((x=C>>>24)<=w);){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(P<16)v>>>=x,w-=x,r.lens[r.have++]=P;else{if(16===P){for(U=x+2;w<U;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(v>>>=x,w-=x,0===r.have){t.msg="invalid bit length repeat",r.mode=f;break}R=r.lens[r.have-1],k=3+(3&v),v>>>=2,w-=2}else if(17===P){for(U=x+3;w<U;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}w-=x,R=0,k=3+(7&(v>>>=x)),v>>>=3,w-=3}else{for(U=x+7;w<U;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}w-=x,R=0,k=11+(127&(v>>>=x)),v>>>=7,w-=7}if(r.have+k>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=f;break}for(;k--;)r.lens[r.have++]=R}}if(r.mode===f)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=f;break}if(r.lenbits=9,N={bits:r.lenbits},j=u(1,r.lens,0,r.nlen,r.lencode,0,r.work,N),r.lenbits=N.bits,j){t.msg="invalid literal/lengths set",r.mode=f;break}if(r.distbits=6,r.distcode=r.distdyn,N={bits:r.distbits},j=u(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,N),r.distbits=N.bits,j){t.msg="invalid distances set",r.mode=f;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(g>=6&&b>=258){t.next_out=y,t.avail_out=b,t.next_in=d,t.avail_in=g,r.hold=v,r.bits=w,a(t,S),y=t.next_out,p=t.output,b=t.avail_out,d=t.next_in,h=t.input,g=t.avail_in,v=r.hold,w=r.bits,r.mode===c&&(r.back=-1);break}for(r.back=0;A=(C=r.lencode[v&(1<<r.lenbits)-1])>>>16&255,P=65535&C,!((x=C>>>24)<=w);){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(A&&!(240&A)){for(I=x,L=A,B=P;A=(C=r.lencode[B+((v&(1<<I+L)-1)>>I)])>>>16&255,P=65535&C,!(I+(x=C>>>24)<=w);){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}v>>>=I,w-=I,r.back+=I}if(v>>>=x,w-=x,r.back+=x,r.length=P,0===A){r.mode=26;break}if(32&A){r.back=-1,r.mode=c;break}if(64&A){t.msg="invalid literal/length code",r.mode=f;break}r.extra=15&A,r.mode=22;case 22:if(r.extra){for(U=r.extra;w<U;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}r.length+=v&(1<<r.extra)-1,v>>>=r.extra,w-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;A=(C=r.distcode[v&(1<<r.distbits)-1])>>>16&255,P=65535&C,!((x=C>>>24)<=w);){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(!(240&A)){for(I=x,L=A,B=P;A=(C=r.distcode[B+((v&(1<<I+L)-1)>>I)])>>>16&255,P=65535&C,!(I+(x=C>>>24)<=w);){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}v>>>=I,w-=I,r.back+=I}if(v>>>=x,w-=x,r.back+=x,64&A){t.msg="invalid distance code",r.mode=f;break}r.offset=P,r.extra=15&A,r.mode=24;case 24:if(r.extra){for(U=r.extra;w<U;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}r.offset+=v&(1<<r.extra)-1,v>>>=r.extra,w-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=f;break}r.mode=25;case 25:if(0===b)break t;if(k=S-b,r.offset>k){if((k=r.offset-k)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=f;break}k>r.wnext?(k-=r.wnext,O=r.wsize-k):O=r.wnext-k,k>r.length&&(k=r.length),T=r.window}else T=p,O=y-r.offset,k=r.length;k>b&&(k=b),b-=k,r.length-=k;do{p[y++]=T[O++]}while(--k);0===r.length&&(r.mode=21);break;case 26:if(0===b)break t;p[y++]=r.length,b--,r.mode=21;break;case 27:if(r.wrap){for(;w<32;){if(0===g)break t;g--,v|=h[d++]<<w,w+=8}if(S-=b,t.total_out+=S,r.total+=S,S&&(t.adler=r.check=r.flags?o(r.check,p,S,y-S):i(r.check,p,S,y-S)),S=b,(r.flags?v:l(v))!==r.check){t.msg="incorrect data check",r.mode=f;break}v=0,w=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;w<32;){if(0===g)break t;g--,v+=h[d++]<<w,w+=8}if(v!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=f;break}v=0,w=0}r.mode=29;case 29:j=1;break t;case f:j=-3;break t;case 31:return-4;default:return s}return t.next_out=y,t.avail_out=b,t.next_in=d,t.avail_in=g,r.hold=v,r.bits=w,(r.wsize||S!==t.avail_out&&r.mode<f&&(r.mode<27||4!==e))&&_(t,t.output,t.next_out,S-t.avail_out)?(r.mode=31,-4):(E-=t.avail_in,S-=t.avail_out,t.total_in+=E,t.total_out+=S,r.total+=S,r.wrap&&S&&(t.adler=r.check=r.flags?o(r.check,p,S,t.next_out-S):i(r.check,p,S,t.next_out-S)),t.data_type=r.bits+(r.last?64:0)+(r.mode===c?128:0)+(20===r.mode||15===r.mode?256:0),(0===E&&0===S||4===e)&&0===j&&(j=-5),j)},e.inflateEnd=function(t){if(!t||!t.state)return s;var e=t.state;return e.window&&(e.window=null),t.state=null,0},e.inflateGetHeader=function(t,e){var r;return t&&t.state&&2&(r=t.state).wrap?(r.head=e,e.done=!1,0):s},e.inflateSetDictionary=function(t,e){var r,n=e.length;return t&&t.state?0!==(r=t.state).wrap&&11!==r.mode?s:11===r.mode&&i(1,e,n,0)!==r.check?-3:_(t,e,n,n)?(r.mode=31,-4):(r.havedict=1,0):s},e.inflateInfo="pako inflate (from Nodeca project)"},1998:(t,e,r)=>{var n=r(9805),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],a=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(t,e,r,s,c,f,l,h){var p,d,y,g,b,v,w,m,_,E=h.bits,S=0,k=0,O=0,T=0,x=0,A=0,P=0,I=0,L=0,B=0,R=null,j=0,N=new n.Buf16(16),U=new n.Buf16(16),C=null,F=0;for(S=0;S<=15;S++)N[S]=0;for(k=0;k<s;k++)N[e[r+k]]++;for(x=E,T=15;T>=1&&0===N[T];T--);if(x>T&&(x=T),0===T)return c[f++]=20971520,c[f++]=20971520,h.bits=1,0;for(O=1;O<T&&0===N[O];O++);for(x<O&&(x=O),I=1,S=1;S<=15;S++)if(I<<=1,(I-=N[S])<0)return-1;if(I>0&&(0===t||1!==T))return-1;for(U[1]=0,S=1;S<15;S++)U[S+1]=U[S]+N[S];for(k=0;k<s;k++)0!==e[r+k]&&(l[U[e[r+k]]++]=k);if(0===t?(R=C=l,v=19):1===t?(R=i,j-=257,C=o,F-=257,v=256):(R=a,C=u,v=-1),B=0,k=0,S=O,b=f,A=x,P=0,y=-1,g=(L=1<<x)-1,1===t&&L>852||2===t&&L>592)return 1;for(;;){w=S-P,l[k]<v?(m=0,_=l[k]):l[k]>v?(m=C[F+l[k]],_=R[j+l[k]]):(m=96,_=0),p=1<<S-P,O=d=1<<A;do{c[b+(B>>P)+(d-=p)]=w<<24|m<<16|_}while(0!==d);for(p=1<<S-1;B&p;)p>>=1;if(0!==p?(B&=p-1,B+=p):B=0,k++,0==--N[S]){if(S===T)break;S=e[r+l[k]]}if(S>x&&(B&g)!==y){for(0===P&&(P=x),b+=O,I=1<<(A=S-P);A+P<T&&!((I-=N[A+P])<=0);)A++,I<<=1;if(L+=1<<A,1===t&&L>852||2===t&&L>592)return 1;c[y=B&g]=x<<24|A<<16|b-f}}return 0!==B&&(c[b+B]=S-P<<24|64<<16),h.bits=x,0}},4674:t=>{t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},3665:(t,e,r)=>{var n=r(9805);function i(t){for(var e=t.length;--e>=0;)t[e]=0}var o=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],a=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],s=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],c=new Array(576);i(c);var f=new Array(60);i(f);var l=new Array(512);i(l);var h=new Array(256);i(h);var p=new Array(29);i(p);var d,y,g,b=new Array(30);function v(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}function w(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function m(t){return t<256?l[t]:l[256+(t>>>7)]}function _(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function E(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,_(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)}function S(t,e,r){E(t,r[2*e],r[2*e+1])}function k(t,e){var r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1}function O(t,e,r){var n,i,o=new Array(16),a=0;for(n=1;n<=15;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=e;i++){var u=t[2*i+1];0!==u&&(t[2*i]=k(o[u]++,u))}}function T(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function x(t){t.bi_valid>8?_(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function A(t,e,r,n){var i=2*e,o=2*r;return t[i]<t[o]||t[i]===t[o]&&n[e]<=n[r]}function P(t,e,r){for(var n=t.heap[r],i=r<<1;i<=t.heap_len&&(i<t.heap_len&&A(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!A(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n}function I(t,e,r){var n,i,u,s,c=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*c]<<8|t.pending_buf[t.d_buf+2*c+1],i=t.pending_buf[t.l_buf+c],c++,0===n?S(t,i,e):(S(t,(u=h[i])+256+1,e),0!==(s=o[u])&&E(t,i-=p[u],s),S(t,u=m(--n),r),0!==(s=a[u])&&E(t,n-=b[u],s))}while(c<t.last_lit);S(t,256,e)}function L(t,e){var r,n,i,o=e.dyn_tree,a=e.stat_desc.static_tree,u=e.stat_desc.has_stree,s=e.stat_desc.elems,c=-1;for(t.heap_len=0,t.heap_max=573,r=0;r<s;r++)0!==o[2*r]?(t.heap[++t.heap_len]=c=r,t.depth[r]=0):o[2*r+1]=0;for(;t.heap_len<2;)o[2*(i=t.heap[++t.heap_len]=c<2?++c:0)]=1,t.depth[i]=0,t.opt_len--,u&&(t.static_len-=a[2*i+1]);for(e.max_code=c,r=t.heap_len>>1;r>=1;r--)P(t,o,r);i=s;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],P(t,o,1),n=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=n,o[2*i]=o[2*r]+o[2*n],t.depth[i]=(t.depth[r]>=t.depth[n]?t.depth[r]:t.depth[n])+1,o[2*r+1]=o[2*n+1]=i,t.heap[1]=i++,P(t,o,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,n,i,o,a,u,s=e.dyn_tree,c=e.max_code,f=e.stat_desc.static_tree,l=e.stat_desc.has_stree,h=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,d=e.stat_desc.max_length,y=0;for(o=0;o<=15;o++)t.bl_count[o]=0;for(s[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)(o=s[2*s[2*(n=t.heap[r])+1]+1]+1)>d&&(o=d,y++),s[2*n+1]=o,n>c||(t.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),u=s[2*n],t.opt_len+=u*(o+a),l&&(t.static_len+=u*(f[2*n+1]+a)));if(0!==y){do{for(o=d-1;0===t.bl_count[o];)o--;t.bl_count[o]--,t.bl_count[o+1]+=2,t.bl_count[d]--,y-=2}while(y>0);for(o=d;0!==o;o--)for(n=t.bl_count[o];0!==n;)(i=t.heap[--r])>c||(s[2*i+1]!==o&&(t.opt_len+=(o-s[2*i+1])*s[2*i],s[2*i+1]=o),n--)}}(t,e),O(o,c,t.bl_count)}function B(t,e,r){var n,i,o=-1,a=e[1],u=0,s=7,c=4;for(0===a&&(s=138,c=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=e[2*(n+1)+1],++u<s&&i===a||(u<c?t.bl_tree[2*i]+=u:0!==i?(i!==o&&t.bl_tree[2*i]++,t.bl_tree[32]++):u<=10?t.bl_tree[34]++:t.bl_tree[36]++,u=0,o=i,0===a?(s=138,c=3):i===a?(s=6,c=3):(s=7,c=4))}function R(t,e,r){var n,i,o=-1,a=e[1],u=0,s=7,c=4;for(0===a&&(s=138,c=3),n=0;n<=r;n++)if(i=a,a=e[2*(n+1)+1],!(++u<s&&i===a)){if(u<c)do{S(t,i,t.bl_tree)}while(0!=--u);else 0!==i?(i!==o&&(S(t,i,t.bl_tree),u--),S(t,16,t.bl_tree),E(t,u-3,2)):u<=10?(S(t,17,t.bl_tree),E(t,u-3,3)):(S(t,18,t.bl_tree),E(t,u-11,7));u=0,o=i,0===a?(s=138,c=3):i===a?(s=6,c=3):(s=7,c=4)}}i(b);var j=!1;function N(t,e,r,i){E(t,0+(i?1:0),3),function(t,e,r){x(t),_(t,r),_(t,~r),n.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}(t,e,r)}e._tr_init=function(t){j||(function(){var t,e,r,n,i,s=new Array(16);for(r=0,n=0;n<28;n++)for(p[n]=r,t=0;t<1<<o[n];t++)h[r++]=n;for(h[r-1]=n,i=0,n=0;n<16;n++)for(b[n]=i,t=0;t<1<<a[n];t++)l[i++]=n;for(i>>=7;n<30;n++)for(b[n]=i<<7,t=0;t<1<<a[n]-7;t++)l[256+i++]=n;for(e=0;e<=15;e++)s[e]=0;for(t=0;t<=143;)c[2*t+1]=8,t++,s[8]++;for(;t<=255;)c[2*t+1]=9,t++,s[9]++;for(;t<=279;)c[2*t+1]=7,t++,s[7]++;for(;t<=287;)c[2*t+1]=8,t++,s[8]++;for(O(c,287,s),t=0;t<30;t++)f[2*t+1]=5,f[2*t]=k(t,5);d=new v(c,o,257,286,15),y=new v(f,a,0,30,15),g=new v(new Array(0),u,0,19,7)}(),j=!0),t.l_desc=new w(t.dyn_ltree,d),t.d_desc=new w(t.dyn_dtree,y),t.bl_desc=new w(t.bl_tree,g),t.bi_buf=0,t.bi_valid=0,T(t)},e._tr_stored_block=N,e._tr_flush_block=function(t,e,r,n){var i,o,a=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),L(t,t.l_desc),L(t,t.d_desc),a=function(t){var e;for(B(t,t.dyn_ltree,t.l_desc.max_code),B(t,t.dyn_dtree,t.d_desc.max_code),L(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*s[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),i=t.opt_len+3+7>>>3,(o=t.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==e?N(t,e,r,n):4===t.strategy||o===i?(E(t,2+(n?1:0),3),I(t,c,f)):(E(t,4+(n?1:0),3),function(t,e,r,n){var i;for(E(t,e-257,5),E(t,r-1,5),E(t,n-4,4),i=0;i<n;i++)E(t,t.bl_tree[2*s[i]+1],3);R(t,t.dyn_ltree,e-1),R(t,t.dyn_dtree,r-1)}(t,t.l_desc.max_code+1,t.d_desc.max_code+1,a+1),I(t,t.dyn_ltree,t.dyn_dtree)),T(t),n&&x(t)},e._tr_tally=function(t,e,r){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(h[r]+256+1)]++,t.dyn_dtree[2*m(e)]++),t.last_lit===t.lit_bufsize-1},e._tr_align=function(t){E(t,2,3),S(t,256,c),function(t){16===t.bi_valid?(_(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},4442:t=>{t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},6578:t=>{t.exports=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]},5606:t=>{var e,r,n=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(r){try{return e.call(null,t,0)}catch(r){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var u,s=[],c=!1,f=-1;function l(){c&&u&&(c=!1,u.length?s=u.concat(s):f=-1,s.length&&h())}function h(){if(!c){var t=a(l);c=!0;for(var e=s.length;e;){for(u=s,s=[];++f<e;)u&&u[f].run();f=-1,e=s.length}u=null,c=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{return r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function d(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];s.push(new p(t,e)),1!==s.length||c||a(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=d,n.addListener=d,n.once=d,n.off=d,n.removeListener=d,n.removeAllListeners=d,n.emit=d,n.prependListener=d,n.prependOnceListener=d,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},3209:(t,e,r)=>{var n=r(5606),i=65536,o=r(2861).Buffer,a=r.g.crypto||r.g.msCrypto;a&&a.getRandomValues?t.exports=function(t,e){if(t>4294967295)throw new RangeError("requested too many random bytes");var r=o.allocUnsafe(t);if(t>0)if(t>i)for(var u=0;u<t;u+=i)a.getRandomValues(r.slice(u,u+i));else a.getRandomValues(r);return"function"==typeof e?n.nextTick((function(){e(null,r)})):r}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}},6011:(t,e,r)=>{var n=r(8287).Buffer,i=r(6698),o=r(4729),a=new Array(16),u=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],s=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],c=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],l=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<<e|t>>>32-e}function y(t,e,r,n,i,o,a,u){return d(t+(e^r^n)+o+a|0,u)+i|0}function g(t,e,r,n,i,o,a,u){return d(t+(e&r|~e&n)+o+a|0,u)+i|0}function b(t,e,r,n,i,o,a,u){return d(t+((e|~r)^n)+o+a|0,u)+i|0}function v(t,e,r,n,i,o,a,u){return d(t+(e&n|r&~n)+o+a|0,u)+i|0}function w(t,e,r,n,i,o,a,u){return d(t+(e^(r|~n))+o+a|0,u)+i|0}i(p,o),p.prototype._update=function(){for(var t=a,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,p=0|this._e,m=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,O=0;O<80;O+=1){var T,x;O<16?(T=y(r,n,i,o,p,t[u[O]],l[0],c[O]),x=w(m,_,E,S,k,t[s[O]],h[0],f[O])):O<32?(T=g(r,n,i,o,p,t[u[O]],l[1],c[O]),x=v(m,_,E,S,k,t[s[O]],h[1],f[O])):O<48?(T=b(r,n,i,o,p,t[u[O]],l[2],c[O]),x=b(m,_,E,S,k,t[s[O]],h[2],f[O])):O<64?(T=v(r,n,i,o,p,t[u[O]],l[3],c[O]),x=g(m,_,E,S,k,t[s[O]],h[3],f[O])):(T=w(r,n,i,o,p,t[u[O]],l[4],c[O]),x=y(m,_,E,S,k,t[s[O]],h[4],f[O])),r=p,p=o,o=d(i,10),i=n,n=T,m=k,k=S,S=d(E,10),E=_,_=x}var A=this._b+i+S|0;this._b=this._c+o+k|0,this._c=this._d+p+m|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=A},p.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=n.alloc?n.alloc(20):new n(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=p},2861:(t,e,r)=>{var n=r(8287),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function a(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},a.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},9721:(t,e,r)=>{var n=r(6556),i=r(4035),o=n("RegExp.prototype.exec"),a=r(9675);t.exports=function(t){if(!i(t))throw new a("`regex` must be a RegExp");return function(e){return null!==o(t,e)}}},6897:(t,e,r)=>{var n=r(453),i=r(41),o=r(592)(),a=r(5795),u=r(9675),s=n("%Math.floor%");t.exports=function(t,e){if("function"!=typeof t)throw new u("`fn` is not a function");if("number"!=typeof e||e<0||e>4294967295||s(e)!==e)throw new u("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],n=!0,c=!0;if("length"in t&&a){var f=a(t,"length");f&&!f.configurable&&(n=!1),f&&!f.writable&&(c=!1)}return(n||c||!r)&&(o?i(t,"length",e,!0,!0):i(t,"length",e)),t}},392:(t,e,r)=>{var n=r(2861).Buffer;function i(t,e){this._block=n.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}i.prototype.update=function(t,e){"string"==typeof t&&(e=e||"utf8",t=n.from(t,e));for(var r=this._block,i=this._blockSize,o=t.length,a=this._len,u=0;u<o;){for(var s=a%i,c=Math.min(o-u,i-s),f=0;f<c;f++)r[s+f]=t[u+f];u+=c,(a+=c)%i==0&&this._update(r)}return this._len+=o,this},i.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},2802:(t,e,r)=>{var n=t.exports=function(t){t=t.toLowerCase();var e=n[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e};n.sha=r(7816),n.sha1=r(3737),n.sha224=r(6710),n.sha256=r(4107),n.sha384=r(2827),n.sha512=r(2890)},7816:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],u=new Array(80);function s(){this.init(),this._w=u,i.call(this,64,56)}function c(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,u=0|this._d,s=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=r[l-3]^r[l-8]^r[l-14]^r[l-16];for(var h=0;h<80;++h){var p=~~(h/20),d=0|((e=n)<<5|e>>>27)+f(p,i,o,u)+s+r[h]+a[p];s=u,u=o,o=c(i),i=n,n=d}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=u+this._d|0,this._e=s+this._e|0},s.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=s},3737:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],u=new Array(80);function s(){this.init(),this._w=u,i.call(this,64,56)}function c(t){return t<<5|t>>>27}function f(t){return t<<30|t>>>2}function l(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,u=0|this._d,s=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=(e=r[h-3]^r[h-8]^r[h-14]^r[h-16])<<1|e>>>31;for(var p=0;p<80;++p){var d=~~(p/20),y=c(n)+l(d,i,o,u)+s+r[p]+a[d]|0;s=u,u=o,o=f(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=u+this._d|0,this._e=s+this._e|0},s.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=s},6710:(t,e,r)=>{var n=r(6698),i=r(4107),o=r(392),a=r(2861).Buffer,u=new Array(64);function s(){this.init(),this._w=u,o.call(this,64,56)}n(s,i),s.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},s.prototype._hash=function(){var t=a.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=s},4107:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],u=new Array(64);function s(){this.init(),this._w=u,i.call(this,64,56)}function c(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function l(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function d(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}n(s,i),s.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},s.prototype._update=function(t){for(var e=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,u=0|this._e,s=0|this._f,y=0|this._g,g=0|this._h,b=0;b<16;++b)e[b]=t.readInt32BE(4*b);for(;b<64;++b)e[b]=d(e[b-2])+e[b-7]+p(e[b-15])+e[b-16]|0;for(var v=0;v<64;++v){var w=g+h(u)+c(u,s,y)+a[v]+e[v]|0,m=l(r)+f(r,n,i)|0;g=y,y=s,s=u,u=o+w|0,o=i,i=n,n=r,r=w+m|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=u+this._e|0,this._f=s+this._f|0,this._g=y+this._g|0,this._h=g+this._h|0},s.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=s},2827:(t,e,r)=>{var n=r(6698),i=r(2890),o=r(392),a=r(2861).Buffer,u=new Array(160);function s(){this.init(),this._w=u,o.call(this,128,112)}n(s,i),s.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},s.prototype._hash=function(){var t=a.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=s},2890:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],u=new Array(160);function s(){this.init(),this._w=u,i.call(this,128,112)}function c(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function l(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function g(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function b(t,e){return t>>>0<e>>>0?1:0}n(s,i),s.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},s.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,u=0|this._eh,s=0|this._fh,v=0|this._gh,w=0|this._hh,m=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,O=0|this._fl,T=0|this._gl,x=0|this._hl,A=0;A<32;A+=2)e[A]=t.readInt32BE(4*A),e[A+1]=t.readInt32BE(4*A+4);for(;A<160;A+=2){var P=e[A-30],I=e[A-30+1],L=p(P,I),B=d(I,P),R=y(P=e[A-4],I=e[A-4+1]),j=g(I,P),N=e[A-14],U=e[A-14+1],C=e[A-32],F=e[A-32+1],M=B+U|0,D=L+N+b(M,B)|0;D=(D=D+R+b(M=M+j|0,j)|0)+C+b(M=M+F|0,F)|0,e[A]=D,e[A+1]=M}for(var H=0;H<160;H+=2){D=e[H],M=e[H+1];var K=f(r,n,i),G=f(m,_,E),W=l(r,m),V=l(m,r),q=h(u,k),z=h(k,u),Y=a[H],X=a[H+1],Z=c(u,s,v),$=c(k,O,T),J=x+z|0,Q=w+q+b(J,x)|0;Q=(Q=(Q=Q+Z+b(J=J+$|0,$)|0)+Y+b(J=J+X|0,X)|0)+D+b(J=J+M|0,M)|0;var tt=V+G|0,et=W+K+b(tt,V)|0;w=v,x=T,v=s,T=O,s=u,O=k,u=o+Q+b(k=S+J|0,S)|0,o=i,S=E,i=n,E=_,n=r,_=m,r=Q+et+b(m=J+tt|0,J)|0}this._al=this._al+m|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+O|0,this._gl=this._gl+T|0,this._hl=this._hl+x|0,this._ah=this._ah+r+b(this._al,m)|0,this._bh=this._bh+n+b(this._bl,_)|0,this._ch=this._ch+i+b(this._cl,E)|0,this._dh=this._dh+o+b(this._dl,S)|0,this._eh=this._eh+u+b(this._el,k)|0,this._fh=this._fh+s+b(this._fl,O)|0,this._gh=this._gh+v+b(this._gl,T)|0,this._hh=this._hh+w+b(this._hl,x)|0},s.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=s},8310:(t,e,r)=>{t.exports=i;var n=r(7007).EventEmitter;function i(){n.call(this)}r(6698)(i,n),i.Readable=r(6891),i.Writable=r(1999),i.Duplex=r(8101),i.Transform=r(9083),i.PassThrough=r(3681),i.finished=r(4257),i.pipeline=r(5267),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",u),r.on("close",s));var a=!1;function u(){a||(a=!0,t.end())}function s(){a||(a=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",u),r.removeListener("close",s),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",c),t.on("error",c),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t}},2463:t=>{var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(t,e,r){var i,o,a;if("string"==typeof e&&(a="not ",e.substr(0,4)===a)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))o="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var u=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+1>t.length)&&-1!==t.indexOf(".",r)}(t)?"property":"argument";o='The "'.concat(t,'" ').concat(u," ").concat(i," ").concat(n(e,"type"))}return o+". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},8101:(t,e,r)=>{var n=r(5606),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var o=r(6891),a=r(1999);r(6698)(f,o);for(var u=i(a.prototype),s=0;s<u.length;s++){var c=u[s];f.prototype[c]||(f.prototype[c]=a.prototype[c])}function f(t){if(!(this instanceof f))return new f(t);o.call(this,t),a.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},3681:(t,e,r)=>{t.exports=i;var n=r(9083);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(6698)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},6891:(t,e,r)=>{var n,i=r(5606);t.exports=O,O.ReadableState=k,r(7007).EventEmitter;var o,a=function(t,e){return t.listeners(e).length},u=r(1396),s=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(7199);o=f&&f.debuglog?f.debuglog("stream"):function(){};var l,h,p,d=r(1766),y=r(4347),g=r(6644).getHighWaterMark,b=r(2463).F,v=b.ERR_INVALID_ARG_TYPE,w=b.ERR_STREAM_PUSH_AFTER_EOF,m=b.ERR_METHOD_NOT_IMPLEMENTED,_=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(O,u);var E=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function k(t,e,i){n=n||r(8101),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",i),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=r(3516).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function O(t){if(n=n||r(8101),!(this instanceof O))return new O(t);var e=this instanceof n;this._readableState=new k(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),u.call(this)}function T(t,e,r,n,i){o("readableAddChunk",e);var a,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?I(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,L(t)))}}(t,u);else if(i||(a=function(t,e){var r,n;return n=e,s.isBuffer(n)||n instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],e)),r}(u,e)),a)E(t,a);else if(u.objectMode||e&&e.length>0)if("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===s.prototype||(e=function(t){return s.from(t)}(e)),n)u.endEmitted?E(t,new _):x(t,u,e,!0);else if(u.ended)E(t,new w);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!r?(e=u.decoder.write(e),u.objectMode||0!==e.length?x(t,u,e,!1):B(t,u)):x(t,u,e,!1)}else n||(u.reading=!1,B(t,u));return!u.ended&&(u.length<u.highWaterMark||0===u.length)}function x(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&I(t)),B(t,e)}Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),O.prototype.destroy=y.destroy,O.prototype._undestroy=y.undestroy,O.prototype._destroy=function(t,e){e(t)},O.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=s.from(t,e),e=""),r=!0),T(this,t,e,!1,r)},O.prototype.unshift=function(t){return T(this,t,null,!0,!1)},O.prototype.isPaused=function(){return!1===this._readableState.flowing},O.prototype.setEncoding=function(t){l||(l=r(3516).I);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var A=1073741824;function P(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=A?t=A:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function I(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(L,t))}function L(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,C(t)}function B(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(R,t,e))}function R(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function j(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function N(t){o("readable nexttick read 0"),t.read(0)}function U(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function F(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function M(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}O.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):I(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&M(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=P(r,e))),null===(n=t>0?F(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&M(this)),null!==n&&this.emit("data",n),n},O.prototype._read=function(t){E(this,new m("_read()"))},O.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o("pipe count=%d opts=%j",n.pipesCount,e);var u=e&&!1===e.end||t===i.stdout||t===i.stderr?y:s;function s(){o("onend"),t.end()}n.endEmitted?i.nextTick(u):r.once("end",u),t.on("unpipe",(function e(i,a){o("onunpipe"),i===r&&a&&!1===a.hasUnpiped&&(a.hasUnpiped=!0,o("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",s),r.removeListener("end",y),r.removeListener("data",l),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||c())}));var c=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",c);var f=!1;function l(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==H(n.pipes,t))&&!f&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===a(t,"error")&&E(t,e)}function p(){t.removeListener("finish",d),y()}function d(){o("onfinish"),t.removeListener("close",p),y()}function y(){o("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),t},O.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=H(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},O.prototype.on=function(t,e){var r=u.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,o("on readable",n.length,n.reading),n.length?I(this):n.reading||i.nextTick(N,this))),r},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(t,e){var r=u.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(j,this),r},O.prototype.removeAllListeners=function(t){var e=u.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(j,this),e},O.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(U,t,e))}(this,t)),t.paused=!1,this},O.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},O.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",(function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<S.length;a++)t.on(S[a],this.emit.bind(this,S[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(O.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(5034)),h(this)}),Object.defineProperty(O.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(O.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(O.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),O._fromList=F,Object.defineProperty(O.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(O.from=function(t,e){return void 0===p&&(p=r(968)),p(O,t,e)})},9083:(t,e,r)=>{t.exports=f;var n=r(2463).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,u=n.ERR_TRANSFORM_WITH_LENGTH_0,s=r(8101);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function f(t){if(!(this instanceof f))return new f(t);s.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush((function(e,r){h(t,e,r)}))}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new u;if(t._transformState.transforming)throw new a;return t.push(null)}r(6698)(f,s),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,s.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,r){r(new i("_transform()"))},f.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},f.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},f.prototype._destroy=function(t,e){s.prototype._destroy.call(this,t,(function(t){e(t)}))}},1999:(t,e,r)=>{var n,i=r(5606);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=O,O.WritableState=k;var a,u={deprecate:r(4643)},s=r(1396),c=r(8287).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(4347),h=r(6644).getHighWaterMark,p=r(2463).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,g=p.ERR_MULTIPLE_CALLBACK,b=p.ERR_STREAM_CANNOT_PIPE,v=p.ERR_STREAM_DESTROYED,w=p.ERR_STREAM_NULL_VALUES,m=p.ERR_STREAM_WRITE_AFTER_END,_=p.ERR_UNKNOWN_ENCODING,E=l.errorOrDestroy;function S(){}function k(t,e,a){n=n||r(8101),t=t||{},"boolean"!=typeof a&&(a=e instanceof n),this.objectMode=!!t.objectMode,a&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",a),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var u=!1===t.decodeStrings;this.decodeStrings=!u,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,o){--e.pendingcb,r?(i.nextTick(o,n),i.nextTick(L,t,e),t._writableState.errorEmitted=!0,E(t,n)):(o(n),t._writableState.errorEmitted=!0,E(t,n),L(t,e))}(t,r,n,e,o);else{var a=P(r)||t.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||A(t,r),n?i.nextTick(x,t,r,a,o):x(t,r,a,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function O(t){var e=this instanceof(n=n||r(8101));if(!e&&!a.call(O,this))return new O(t);this._writableState=new k(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),s.call(this)}function T(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new v("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function x(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),L(t,e)}function A(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),a=e.corkedRequestsFree;a.entry=r;for(var u=0,s=!0;r;)i[u]=r,r.isBuf||(s=!1),r=r.next,u+=1;i.allBuffers=s,T(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,l=r.callback;if(T(t,e,!1,e.objectMode?1:c.length,c,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function P(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function I(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit("prefinish"),L(t,e)}))}function L(t,e){var r=P(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(I,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(6698)(O,s),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,"buffer",{get:u.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(O,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===O&&t&&t._writableState instanceof k}})):a=function(t){return t instanceof this},O.prototype.pipe=function(){E(this,new b)},O.prototype.write=function(t,e,r){var n,o=this._writableState,a=!1,u=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof f);return u&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),u?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(t,e){var r=new m;E(t,r),i.nextTick(e,r)}(this,r):(u||function(t,e,r,n){var o;return null===r?o=new w:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(E(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,a=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var u=e.objectMode?1:n.length;e.length+=u;var s=e.length<e.highWaterMark;if(s||(e.needDrain=!0),e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else T(t,e,!1,u,n,i,o);return s}(this,o,u,t,e,r)),a},O.prototype.cork=function(){this._writableState.corked++},O.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||A(this,t))},O.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new _(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(O.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(O.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),O.prototype._write=function(t,e,r){r(new y("_write()"))},O.prototype._writev=null,O.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,L(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(O.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),O.prototype.destroy=l.destroy,O.prototype._undestroy=l.undestroy,O.prototype._destroy=function(t,e){e(t)}},5034:(t,e,r)=>{var n,i=r(5606);function o(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var a=r(4257),u=Symbol("lastResolve"),s=Symbol("lastReject"),c=Symbol("error"),f=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[u];if(null!==e){var r=t[p].read();null!==r&&(t[l]=null,t[u]=null,t[s]=null,e(d(r,!1)))}}function g(t){i.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[f])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise((function(e,r){i.nextTick((function(){t[c]?r(t[c]):e(d(void 0,!0))}))}));var r,n=this[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[f]?r(d(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[h])}return this[l]=r,r}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var t=this;return new Promise((function(e,r){t[p].destroy(null,(function(t){t?r(t):e(d(void 0,!0))}))}))})),n),b);t.exports=function(t){var e,r=Object.create(v,(o(e={},p,{value:t,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,f,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[l]=null,r[u]=null,r[s]=null,t(d(n,!1))):(r[u]=t,r[s]=e)},writable:!0}),e));return r[l]=null,a(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[s];return null!==e&&(r[l]=null,r[u]=null,r[s]=null,e(t)),void(r[c]=t)}var n=r[u];null!==n&&(r[l]=null,r[u]=null,r[s]=null,n(d(void 0,!0))),r[f]=!0})),t.on("readable",g.bind(null,r)),r}},1766:(t,e,r)=>{function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e,r){return(e=u(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,u(n.key),n)}}function u(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var s=r(8287).Buffer,c=r(3779).inspect,f=c&&c.custom||"inspect";function l(t,e,r){s.prototype.copy.call(t,e,r)}t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r;return e=t,r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return s.alloc(0);for(var e=s.allocUnsafe(t>>>0),r=this.head,n=0;r;)l(r.data,e,n),n+=r.data.length,r=r.next;return e}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=s.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:f,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},4347:(t,e,r)=>{var n=r(5606);function i(t,e){a(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,u=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return u||s?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(a,this,t)):n.nextTick(a,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,t)):n.nextTick(i,r,t):e?(n.nextTick(o,r),e(t)):n.nextTick(o,r)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},4257:(t,e,r)=>{var n=r(2463).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var a=r.readable||!1!==r.readable&&e.readable,u=r.writable||!1!==r.writable&&e.writable,s=function(){e.writable||f()},c=e._writableState&&e._writableState.finished,f=function(){u=!1,c=!0,a||o.call(e)},l=e._readableState&&e._readableState.endEmitted,h=function(){a=!1,l=!0,u||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!l?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):u&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",f),e.on("abort",d),e.req?y():e.on("request",y)):u&&!e._writableState&&(e.on("end",s),e.on("close",s)),e.on("end",h),e.on("finish",f),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",f),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",s),e.removeListener("close",s),e.removeListener("finish",f),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},968:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},5267:(t,e,r)=>{var n,i=r(2463).F,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function u(t){if(t)throw t}function s(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var f,l=function(t){return t.length?"function"!=typeof t[t.length-1]?u:t.pop():u}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var h=e.map((function(t,i){var o=i<e.length-1;return function(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var u=!1;t.on("close",(function(){u=!0})),void 0===n&&(n=r(4257)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);u=!0,o()}));var s=!1;return function(e){if(!u&&!s)return s=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new a("pipe"))}}(t,o,i>0,(function(t){f||(f=t),t&&h.forEach(s),o||(h.forEach(s),l(f))}))}));return e.reduce(c)}},6644:(t,e,r)=>{var n=r(2463).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},1396:(t,e,r)=>{t.exports=r(7007).EventEmitter},3516:(t,e,r)=>{var n=r(2861).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=s,this.end=c,e=4;break;case"utf8":this.fillLast=u,e=4;break;case"base64":this.text=f,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function u(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function s(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.I=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},o.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var i=a(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},9579:(t,e,r)=>{var n=r(8287).Buffer,i=n.isEncoding||function(t){switch(t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},o=e.I=function(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),function(t){if(t&&!i(t))throw new Error("Unknown encoding: "+t)}(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=u;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=a)}this.charBuffer=new n(6),this.charReceived=0,this.charLength=0};function a(t){return t.toString(this.encoding)}function u(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function s(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}o.prototype.write=function(t){for(var e="";this.charLength;){var r=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";if(t=t.slice(r,t.length),!((n=(e=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(e.length-1))>=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var n,i=t.length;if(this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),i=(e+=t.toString(this.encoding,0,i)).length-1,(n=e.charCodeAt(i))>=55296&&n<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,i)}return e},o.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var r=t[t.length-e];if(1==e&&r>>5==6){this.charLength=2;break}if(e<=2&&r>>4==14){this.charLength=3;break}if(e<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=e},o.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;e+=n.slice(0,r).toString(i)}return e}},1061:(t,e,r)=>{var n=r(2113);function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function a(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function u(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 s(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 "+u(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function c(t,e,r){r=r||o(e),this.message=s(t,e,r),a(this,c),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),s('property "'+u(r)+o+u(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',a(this,c),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,f.prototype=Object.create(Error.prototype),f.prototype.constructor=c,t.exports={TfTypeError:c,TfPropertyTypeError:f,tfCustomError:function(t,e){return new c(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+"."+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof c&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),a(t),t},tfJSON:u,getValueTypeName:o}},9542:(t,e,r)=>{var n=r(8287).Buffer,i=r(2113),o=r(1061);function a(t){return n.isBuffer(t)}function u(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function s(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var c=s.bind(null,i.Array),f=s.bind(null,a),l=s.bind(null,u),h=s.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:c,Buffer:a,BufferN:f,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:u,HexN:l,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n<e}return r=r||i.Number,n.toJSON=function(){return`${r.toJSON()} between [${t}, ${e}]`},n},StringN:h,UInt8:function(t){return(255&t)===t},UInt16:function(t){return(65535&t)===t},UInt32:function(t){return t>>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},8676:(t,e,r)=>{var n=r(1061),i=r(2113),o=n.tfJSON,a=n.TfTypeError,u=n.TfPropertyTypeError,s=n.tfSubError,c=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==e.minLength&&r.length<e.minLength)&&!(void 0!==e.maxLength&&r.length>e.maxLength)&&(void 0===e.length||r.length===e.length)&&r.every((function(e,r){try{return h(t,e,n)}catch(t){throw s(t,r)}}))}return t=l(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=l(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&h(e,o,n)}catch(t){throw s(t,o,"key")}try{var a=r[o];h(t,a,n)}catch(t){throw s(t,o)}}return!0}return t=l(t),e&&(e=l(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=l(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e)h(e[n],t[n],r)}catch(t){throw s(t,n)}if(r)for(n in t)if(!e[n])throw new u(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.some((function(t){try{return h(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.every((function(t){try{return h(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return!i.Nil(e)&&!i.Nil(e.length)&&(!r||e.length===t.length)&&t.every((function(t,n){try{return h(t,e[n],r)}catch(t){throw s(t,n)}}))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function l(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new a(n||t,e)}return h(l(t),e,r)}for(var p in f.oneOf=f.anyOf,i)h[p]=i[p];for(p in f)h[p]=f[p];var d=r(9542);for(p in d)h[p]=d[p];h.compile=l,h.TfTypeError=a,h.TfPropertyTypeError=u,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},4643:(t,e,r)=>{function n(t){try{if(!r.g.localStorage)return!1}catch(t){return!1}var e=r.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}},1135:t=>{t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},9032:(t,e,r)=>{var n=r(7244),i=r(8184),o=r(5767),a=r(5680);function u(t){return t.call.bind(t)}var s="undefined"!=typeof BigInt,c="undefined"!=typeof Symbol,f=u(Object.prototype.toString),l=u(Number.prototype.valueOf),h=u(String.prototype.valueOf),p=u(Boolean.prototype.valueOf);if(s)var d=u(BigInt.prototype.valueOf);if(c)var y=u(Symbol.prototype.valueOf);function g(t,e){if("object"!=typeof t)return!1;try{return e(t),!0}catch(t){return!1}}function b(t){return"[object Map]"===f(t)}function v(t){return"[object Set]"===f(t)}function w(t){return"[object WeakMap]"===f(t)}function m(t){return"[object WeakSet]"===f(t)}function _(t){return"[object ArrayBuffer]"===f(t)}function E(t){return"undefined"!=typeof ArrayBuffer&&(_.working?_(t):t instanceof ArrayBuffer)}function S(t){return"[object DataView]"===f(t)}function k(t){return"undefined"!=typeof DataView&&(S.working?S(t):t instanceof DataView)}e.isArgumentsObject=n,e.isGeneratorFunction=i,e.isTypedArray=a,e.isPromise=function(t){return"undefined"!=typeof Promise&&t instanceof Promise||null!==t&&"object"==typeof t&&"function"==typeof t.then&&"function"==typeof t.catch},e.isArrayBufferView=function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):a(t)||k(t)},e.isUint8Array=function(t){return"Uint8Array"===o(t)},e.isUint8ClampedArray=function(t){return"Uint8ClampedArray"===o(t)},e.isUint16Array=function(t){return"Uint16Array"===o(t)},e.isUint32Array=function(t){return"Uint32Array"===o(t)},e.isInt8Array=function(t){return"Int8Array"===o(t)},e.isInt16Array=function(t){return"Int16Array"===o(t)},e.isInt32Array=function(t){return"Int32Array"===o(t)},e.isFloat32Array=function(t){return"Float32Array"===o(t)},e.isFloat64Array=function(t){return"Float64Array"===o(t)},e.isBigInt64Array=function(t){return"BigInt64Array"===o(t)},e.isBigUint64Array=function(t){return"BigUint64Array"===o(t)},b.working="undefined"!=typeof Map&&b(new Map),e.isMap=function(t){return"undefined"!=typeof Map&&(b.working?b(t):t instanceof Map)},v.working="undefined"!=typeof Set&&v(new Set),e.isSet=function(t){return"undefined"!=typeof Set&&(v.working?v(t):t instanceof Set)},w.working="undefined"!=typeof WeakMap&&w(new WeakMap),e.isWeakMap=function(t){return"undefined"!=typeof WeakMap&&(w.working?w(t):t instanceof WeakMap)},m.working="undefined"!=typeof WeakSet&&m(new WeakSet),e.isWeakSet=function(t){return m(t)},_.working="undefined"!=typeof ArrayBuffer&&_(new ArrayBuffer),e.isArrayBuffer=E,S.working="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView&&S(new DataView(new ArrayBuffer(1),0,1)),e.isDataView=k;var O="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:void 0;function T(t){return"[object SharedArrayBuffer]"===f(t)}function x(t){return void 0!==O&&(void 0===T.working&&(T.working=T(new O)),T.working?T(t):t instanceof O)}function A(t){return g(t,l)}function P(t){return g(t,h)}function I(t){return g(t,p)}function L(t){return s&&g(t,d)}function B(t){return c&&g(t,y)}e.isSharedArrayBuffer=x,e.isAsyncFunction=function(t){return"[object AsyncFunction]"===f(t)},e.isMapIterator=function(t){return"[object Map Iterator]"===f(t)},e.isSetIterator=function(t){return"[object Set Iterator]"===f(t)},e.isGeneratorObject=function(t){return"[object Generator]"===f(t)},e.isWebAssemblyCompiledModule=function(t){return"[object WebAssembly.Module]"===f(t)},e.isNumberObject=A,e.isStringObject=P,e.isBooleanObject=I,e.isBigIntObject=L,e.isSymbolObject=B,e.isBoxedPrimitive=function(t){return A(t)||P(t)||I(t)||L(t)||B(t)},e.isAnyArrayBuffer=function(t){return"undefined"!=typeof Uint8Array&&(E(t)||x(t))},["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(t){Object.defineProperty(e,t,{enumerable:!1,value:function(){throw new Error(t+" is not supported in userland")}})}))},537:(t,e,r)=>{var n=r(5606),i=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n<e.length;n++)r[e[n]]=Object.getOwnPropertyDescriptor(t,e[n]);return r},o=/%[sdj%]/g;e.format=function(t){if(!w(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(c(arguments[r]));return e.join(" ")}r=1;for(var n=arguments,i=n.length,a=String(t).replace(o,(function(t){if("%%"===t)return"%";if(r>=i)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}})),u=n[r];r<i;u=n[++r])b(u)||!E(u)?a+=" "+u:a+=" "+c(u);return a},e.deprecate=function(t,r){if(void 0!==n&&!0===n.noDeprecation)return t;if(void 0===n)return function(){return e.deprecate(t,r).apply(this,arguments)};var i=!1;return function(){if(!i){if(n.throwDeprecation)throw new Error(r);n.traceDeprecation?console.trace(r):console.error(r),i=!0}return t.apply(this,arguments)}};var a={},u=/^$/;if(n.env.NODE_DEBUG){var s=n.env.NODE_DEBUG;s=s.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),u=new RegExp("^"+s+"$","i")}function c(t,r){var n={seen:[],stylize:l};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(r)?n.showHidden=r:r&&e._extend(n,r),m(n.showHidden)&&(n.showHidden=!1),m(n.depth)&&(n.depth=2),m(n.colors)&&(n.colors=!1),m(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=f),h(n,t,n.depth)}function f(t,e){var r=c.styles[e];return r?"["+c.colors[r][0]+"m"+t+"["+c.colors[r][1]+"m":t}function l(t,e){return t}function h(t,r,n){if(t.customInspect&&r&&O(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return w(i)||(i=h(t,i,n)),i}var o=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(w(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return v(e)?t.stylize(""+e,"number"):g(e)?t.stylize(""+e,"boolean"):b(e)?t.stylize("null","null"):void 0}(t,r);if(o)return o;var a=Object.keys(r),u=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(r)),k(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return p(r);if(0===a.length){if(O(r)){var s=r.name?": "+r.name:"";return t.stylize("[Function"+s+"]","special")}if(_(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(S(r))return t.stylize(Date.prototype.toString.call(r),"date");if(k(r))return p(r)}var c,f="",l=!1,E=["{","}"];return y(r)&&(l=!0,E=["[","]"]),O(r)&&(f=" [Function"+(r.name?": "+r.name:"")+"]"),_(r)&&(f=" "+RegExp.prototype.toString.call(r)),S(r)&&(f=" "+Date.prototype.toUTCString.call(r)),k(r)&&(f=" "+p(r)),0!==a.length||l&&0!=r.length?n<0?_(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),c=l?function(t,e,r,n,i){for(var o=[],a=0,u=e.length;a<u;++a)P(e,String(a))?o.push(d(t,e,r,n,String(a),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(d(t,e,r,n,i,!0))})),o}(t,r,n,u,a):a.map((function(e){return d(t,r,n,u,e,l)})),t.seen.pop(),function(t,e,r){return t.reduce((function(t,e){return e.indexOf("\n"),t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}(c,f,E)):E[0]+f+E[1]}function p(t){return"["+Error.prototype.toString.call(t)+"]"}function d(t,e,r,n,i,o){var a,u,s;if((s=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?u=s.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):s.set&&(u=t.stylize("[Setter]","special")),P(n,i)||(a="["+i+"]"),u||(t.seen.indexOf(s.value)<0?(u=b(r)?h(t,s.value,null):h(t,s.value,r-1)).indexOf("\n")>-1&&(u=o?u.split("\n").map((function(t){return" "+t})).join("\n").slice(2):"\n"+u.split("\n").map((function(t){return" "+t})).join("\n")):u=t.stylize("[Circular]","special")),m(a)){if(o&&i.match(/^\d+$/))return u;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.slice(1,-1),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+u}function y(t){return Array.isArray(t)}function g(t){return"boolean"==typeof t}function b(t){return null===t}function v(t){return"number"==typeof t}function w(t){return"string"==typeof t}function m(t){return void 0===t}function _(t){return E(t)&&"[object RegExp]"===T(t)}function E(t){return"object"==typeof t&&null!==t}function S(t){return E(t)&&"[object Date]"===T(t)}function k(t){return E(t)&&("[object Error]"===T(t)||t instanceof Error)}function O(t){return"function"==typeof t}function T(t){return Object.prototype.toString.call(t)}function x(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(t=t.toUpperCase(),!a[t])if(u.test(t)){var r=n.pid;a[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else a[t]=function(){};return a[t]},e.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.types=r(9032),e.isArray=y,e.isBoolean=g,e.isNull=b,e.isNullOrUndefined=function(t){return null==t},e.isNumber=v,e.isString=w,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=_,e.types.isRegExp=_,e.isObject=E,e.isDate=S,e.types.isDate=S,e.isError=k,e.types.isNativeError=k,e.isFunction=O,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(1135);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",function(){var t=new Date,e=[x(t.getHours()),x(t.getMinutes()),x(t.getSeconds())].join(":");return[t.getDate(),A[t.getMonth()],e].join(" ")}(),e.format.apply(e,arguments))},e.inherits=r(6698),e._extend=function(t,e){if(!e||!E(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var I="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function L(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(I&&t[I]){var e;if("function"!=typeof(e=t[I]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,I,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise((function(t,n){e=t,r=n})),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push((function(t,n){t?r(t):e(n)}));try{t.apply(this,i)}catch(t){r(t)}return n}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),I&&Object.defineProperty(e,I,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,i(t))},e.promisify.custom=I,e.callbackify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');function e(){for(var e=[],r=0;r<arguments.length;r++)e.push(arguments[r]);var i=e.pop();if("function"!=typeof i)throw new TypeError("The last argument must be of type Function");var o=this,a=function(){return i.apply(o,arguments)};t.apply(this,e).then((function(t){n.nextTick(a.bind(null,null,t))}),(function(t){n.nextTick(L.bind(null,t,a))}))}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),Object.defineProperties(e,i(t)),e}},5767:(t,e,r)=>{var n=r(2682),i=r(9209),o=r(487),a=r(6556),u=r(5795),s=a("Object.prototype.toString"),c=r(9092)(),f="undefined"==typeof globalThis?r.g:globalThis,l=i(),h=a("String.prototype.slice"),p=Object.getPrototypeOf,d=a("Array.prototype.indexOf",!0)||function(t,e){for(var r=0;r<t.length;r+=1)if(t[r]===e)return r;return-1},y={__proto__:null};n(l,c&&u&&p?function(t){var e=new f[t];if(Symbol.toStringTag in e){var r=p(e),n=u(r,Symbol.toStringTag);if(!n){var i=p(r);n=u(i,Symbol.toStringTag)}y["$"+t]=o(n.get)}}:function(t){var e=new f[t],r=e.slice||e.set;r&&(y["$"+t]=o(r))}),t.exports=function(t){if(!t||"object"!=typeof t)return!1;if(!c){var e=h(s(t),8,-1);return d(l,e)>-1?e:"Object"===e&&function(t){var e=!1;return n(y,(function(r,n){if(!e)try{r(t),e=h(n,1)}catch(t){}})),e}(t)}return u?function(t){var e=!1;return n(y,(function(r,n){if(!e)try{"$"+r(t)===n&&(e=h(n,1))}catch(t){}})),e}(t):null}},8460:()=>{},2382:()=>{},3779:()=>{},7199:()=>{},9209:(t,e,r)=>{var n=r(6578),i="undefined"==typeof globalThis?r.g:globalThis;t.exports=function(){for(var t=[],e=0;e<n.length;e++)"function"==typeof i[n[e]]&&(t[t.length]=n[e]);return t}}},n={};function i(t){var e=n[t];if(void 0!==e)return e.exports;var o=n[t]={exports:{}};return r[t](o,o.exports,i),o.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var o=Object.create(null);i.r(o);var a={};t=t||[null,e({}),e([]),e(e)];for(var u=2&n&&r;"object"==typeof u&&!~t.indexOf(u);u=e(u))Object.getOwnPropertyNames(u).forEach((t=>a[t]=()=>r[t]));return a.default=()=>r,i.d(o,a),o},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};i.d(o,{_v:()=>gb,y3:()=>lb,Z1:()=>tp,pV:()=>Xp,iy:()=>Kf,vU:()=>rb,dy:()=>Ob,gd:()=>Hf,z2:()=>zf,LC:()=>dp,V5:()=>ab,fI:()=>mb,G7:()=>wd,p9:()=>hb,GF:()=>Gc,nU:()=>nd,zy:()=>Uf,Pq:()=>Uy,wf:()=>p,gf:()=>od,rt:()=>Tp,P8:()=>ad,vg:()=>Zc,nr:()=>iv,ry:()=>Rd,z4:()=>af,qT:()=>uy,t0:()=>Fb,Jf:()=>Vb,kd:()=>kc,eA:()=>iw,no:()=>Yv,o4:()=>Qv,YV:()=>Tc,O5:()=>Sc,cC:()=>by,Wj:()=>Bc,Z4:()=>cp,pp:()=>hp,d6:()=>sp,p6:()=>lp,iV:()=>fp,gh:()=>pp,Bc:()=>ky,TG:()=>bf,$3:()=>Hh,qV:()=>Dh,LL:()=>uw,gK:()=>$v,PE:()=>rw,ev:()=>Qh,Go:()=>nv,dI:()=>Lf,IB:()=>Sf,rl:()=>lg,c1:()=>Zb,Y_:()=>cd,yo:()=>kg,Ko:()=>fw,pe:()=>zv,ho:()=>cw,_l:()=>Mg,QS:()=>ow,Bm:()=>Xv,W_:()=>tw,Hu:()=>jg,Mg:()=>Ng,$v:()=>sw,mt:()=>Jv,lJ:()=>nw,ih:()=>ud,AT:()=>ep,AS:()=>mp,aw:()=>zd,Ph:()=>Bv,tm:()=>zh,Qc:()=>Kh,dF:()=>Xy,Wb:()=>sh,D_:()=>id,aS:()=>ih,_3:()=>kh,p0:()=>np,Rt:()=>ap,ZO:()=>rp,BI:()=>op,MS:()=>ip,ct:()=>up,A9:()=>rv,V$:()=>ev,xc:()=>bv,Gc:()=>aw,zM:()=>Zv,c:()=>ew,uW:()=>Qp,u4:()=>Hv,OH:()=>Lv,sG:()=>Rv,jz:()=>fd,hL:()=>ld,$7:()=>a,rE:()=>u});var a={};i.r(a),i.d(a,{ABICoder:()=>gb,ABIDataTypes:()=>lb,ADDRESS_BYTE_LENGTH:()=>tp,Address:()=>Xp,AddressGenerator:()=>Kf,AddressMap:()=>rb,AddressSet:()=>Ob,AddressTypes:()=>Hf,AddressVerificator:()=>zf,BOOLEAN_BYTE_LENGTH:()=>dp,BinaryReader:()=>ab,BinaryWriter:()=>mb,BitcoinUtils:()=>wd,BufferHelper:()=>hb,CalldataGenerator:()=>Gc,ChainId:()=>nd,ChallengeGenerator:()=>Uf,ChallengeSolutionTransaction:()=>Uy,Compressor:()=>p,Consensus:()=>od,ContractAddress:()=>Tp,ContractBaseMetadata:()=>ad,CustomGenerator:()=>Zc,CustomKeypair:()=>iv,CustomScriptTransaction:()=>Rd,DeploymentGenerator:()=>af,DeploymentTransaction:()=>uy,DeterministicMap:()=>Fb,DeterministicSet:()=>Vb,EcKeyPair:()=>kc,FACTORY_ADDRESS_FRACTAL:()=>iw,FACTORY_ADDRESS_REGTEST:()=>Yv,FACTORY_ADDRESS_TESTNET:()=>Qv,FeatureOpCodes:()=>Tc,Features:()=>Sc,FundingTransaction:()=>by,Generator:()=>Bc,I128_BYTE_LENGTH:()=>cp,I16_BYTE_LENGTH:()=>hp,I256_BYTE_LENGTH:()=>sp,I32_BYTE_LENGTH:()=>lp,I64_BYTE_LENGTH:()=>fp,I8_BYTE_LENGTH:()=>pp,InteractionTransaction:()=>ky,LegacyCalldataGenerator:()=>bf,MINIMUM_AMOUNT_CA:()=>Hh,MINIMUM_AMOUNT_REWARD:()=>Dh,MOTO_ADDRESS_FRACTAL:()=>uw,MOTO_ADDRESS_REGTEST:()=>$v,MOTO_ADDRESS_TESTNET:()=>rw,MessageSigner:()=>Qh,MessageType:()=>nv,MineableReward:()=>Lf,MultiSignGenerator:()=>Sf,MultiSignTransaction:()=>lg,NetEvent:()=>Zb,OPNetConsensusConfig:()=>cd,OPNetLimitedProvider:()=>kg,OPNetMetadata:()=>fw,OPNetNetwork:()=>zv,OPNetTokenAddressManager:()=>cw,P2TR_MS:()=>Mg,POOL_ADDRESS_FRACTAL:()=>ow,POOL_ADDRESS_REGTEST:()=>Xv,POOL_ADDRESS_TESTNET:()=>tw,PSBTTypes:()=>jg,PsbtTransaction:()=>Ng,ROUTER_ADDRESS_FRACTAL:()=>sw,ROUTER_ADDRESS_REGTEST:()=>Jv,ROUTER_ADDRESS_TESTNET:()=>nw,RoswellConsensus:()=>ud,SELECTOR_BYTE_LENGTH:()=>ep,Secp256k1PointDeriver:()=>mp,SharedInteractionTransaction:()=>zd,SupportedWallets:()=>Bv,TapscriptVerificator:()=>zh,TransactionBuilder:()=>Kh,TransactionFactory:()=>Xy,TransactionSequence:()=>sh,TransactionType:()=>id,TweakedSigner:()=>ih,TweakedTransaction:()=>kh,U128_BYTE_LENGTH:()=>np,U16_BYTE_LENGTH:()=>ap,U256_BYTE_LENGTH:()=>rp,U32_BYTE_LENGTH:()=>op,U64_BYTE_LENGTH:()=>ip,U8_BYTE_LENGTH:()=>up,UnisatChainType:()=>rv,UnisatNetwork:()=>ev,UnisatSigner:()=>bv,WBTC_ADDRESS_FRACTAL:()=>aw,WBTC_ADDRESS_REGTEST:()=>Zv,WBTC_ADDRESS_TESTNET:()=>ew,Wallet:()=>Qp,WalletConnection:()=>Hv,XverseNetwork:()=>Lv,XverseSigner:()=>Rv,currentConsensus:()=>fd,currentConsensusConfig:()=>ld,version:()=>u});var u="1.2.3",s=i(8559),c=i.n(s);function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function l(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,h(n.key),n)}}function h(t){var e=function(t){if("object"!=f(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==f(e)?e:e+""}var p=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&l(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"compress",value:function(e){return c().gzipSync(e,t.zlibOptions)}},{key:"decompress",value:function(e){return c().gunzipSync(e,t.zlibOptions)}}])}();!function(t,e,r){(e=h(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(p,"zlibOptions",{level:9,maxOutputLength:16777216});var d={526:(t,e)=>{e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=u(t),a=o[0],s=o[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,s)),f=0,l=s>0?a-4:a;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],c[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;return 2===s&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[f++]=255&e),1===s&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,u=0,c=n-i;u<c;u+=a)o.push(s(t,u,u+a>c?c:u+a));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function u(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 s(t,e,n){for(var i,o,a=[],u=e;u<n;u+=3)i=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},343:(t,e)=>{e.p2=e.I=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(1&e)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=i(e)^n>>5}e=i(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=i(e)^31&n}return e}function a(t,e,r,n){let i=0,o=0;const a=(1<<r)-1,u=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],o+=e;o>=r;)o-=r,u.push(i>>o&a);if(n)o>0&&u.push(i<<r-o&a);else{if(o>=e)return"Excess padding";if(i<<r-o&a)return"Non-zero padding"}return u}function u(t){return a(t,8,5,!0)}function s(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e}function c(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function f(t){let e;function a(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const a=t.toLowerCase(),u=t.toUpperCase();if(t!==a&&t!==u)return"Mixed-case string "+t;const s=(t=a).lastIndexOf("1");if(-1===s)return"No separator character for "+t;if(0===s)return"Missing prefix for "+t;const c=t.slice(0,s),f=t.slice(s+1);if(f.length<6)return"Data too short";let l=o(c);if("string"==typeof l)return l;const h=[];for(let t=0;t<f.length;++t){const e=f.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;l=i(l)^r,t+6>=f.length||h.push(r)}return l!==e?"Invalid checksum for "+t:{prefix:c,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=a(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=a(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,a){if(a=a||90,t.length+7+n.length>a)throw new TypeError("Exceeds length limit");let u=o(t=t.toLowerCase());if("string"==typeof u)throw new Error(u);let s=t+"1";for(let t=0;t<n.length;++t){const e=n[t];if(e>>5)throw new Error("Non 5-bit word");u=i(u)^e,s+=r.charAt(e)}for(let t=0;t<6;++t)u=i(u);u^=e;for(let t=0;t<6;++t)s+=r.charAt(u>>5*(5-t)&31);return s},toWords:u,fromWordsUnsafe:s,fromWords:c}}e.I=f("bech32"),e.p2=f("bech32m")},863:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(457);function i(t,e,r){return n=>{if(t.has(n))return;const i=r.filter((t=>t.key.toString("hex")===n))[0];e.push(i),t.add(n)}}function o(t){return t.globalMap.unsignedTx}function a(t){const e=new Set;return t.forEach((t=>{const r=t.key.toString("hex");if(e.has(r))throw new Error("Combine: KeyValue Map keys should be unique");e.add(r)})),e}e.combine=function(t){const e=t[0],r=n.psbtToKeyVals(e),u=t.slice(1);if(0===u.length)throw new Error("Combine: Nothing to combine");const s=o(e);if(void 0===s)throw new Error("Combine: Self missing transaction");const c=a(r.globalKeyVals),f=r.inputKeyVals.map(a),l=r.outputKeyVals.map(a);for(const t of u){const e=o(t);if(void 0===e||!e.toBuffer().equals(s.toBuffer()))throw new Error("Combine: One of the Psbts does not have the same transaction.");const u=n.psbtToKeyVals(t);a(u.globalKeyVals).forEach(i(c,r.globalKeyVals,u.globalKeyVals)),u.inputKeyVals.map(a).forEach(((t,e)=>t.forEach(i(f[e],r.inputKeyVals[e],u.inputKeyVals[e])))),u.outputKeyVals.map(a).forEach(((t,e)=>t.forEach(i(l[e],r.outputKeyVals[e],u.outputKeyVals[e]))))}return n.psbtFromKeyVals(s,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},834:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.GlobalTypes.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+t.key.toString("hex"));if(79!==t.key.length||![2,3].includes(t.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+t.key.toString("hex"));if(t.value.length/4%1!=0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const e=t.key.slice(1),r={masterFingerprint:t.value.slice(0,4),extendedPubkey:e,path:"m"};for(const e of(n=t.value.length/4-1,[...Array(n).keys()])){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+="/"+o.toString(10)+(i?"'":"")}var n;return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split("/"),a=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(a,0);let u=4;return o.slice(1).forEach((t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),a.writeUInt32LE(r,u),u+=4})),{key:r,value:a}},e.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",e.check=function(t){const e=t.extendedPubkey,r=t.masterFingerprint,i=t.path;return n.isBuffer(e)&&78===e.length&&[2,3].indexOf(e[45])>-1&&n.isBuffer(r)&&4===r.length&&"string"==typeof i&&!!i.match(/^m(\/\d+'?)*$/)},e.canAddToArray=function(t,e,r){const n=e.extendedPubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.extendedPubkey.equals(e.extendedPubkey))).length)}},213:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.encode=function(t){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}}},706:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(80),i=r(834),o=r(213),a=r(605),u=r(795),s=r(431),c=r(907),f=r(949),l=r(344),h=r(760),p=r(695),d=r(454),y=r(34),g=r(926),b=r(851),v=r(545),w=r(412),m=r(307),_=r(636),E=r(223),S=r(578),k={unsignedTx:o,globalXpub:i,checkPubkey:w.makeChecker([])};e.globals=k;const O={nonWitnessUtxo:s,partialSig:c,sighashType:l,finalScriptSig:a,finalScriptWitness:u,porCommitment:f,witnessUtxo:g,bip32Derivation:v.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:w.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:h,tapScriptSig:y,tapLeafScript:p,tapBip32Derivation:_.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:E.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=O;const T={bip32Derivation:v.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:w.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:_.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:b,tapInternalKey:E.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=T},605:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTSIG]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptSig}},795:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptWitness}},431:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.NON_WITNESS_UTXO]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.nonWitnessUtxo}},907:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+t.key.toString("hex"));if(34!==t.key.length&&66!==t.key.length||![2,3,4].includes(t.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.PARTIAL_SIG]);return{key:n.concat([e,t.pubkey]),value:t.signature}},e.expected="{ pubkey: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.signature)&&[33,65].includes(t.pubkey.length)&&[2,3,4].includes(t.pubkey[0])&&function(t){if(!n.isBuffer(t)||t.length<9)return!1;if(48!==t[0])return!1;if(t.length!==t[1]+3)return!1;if(2!==t[2])return!1;const e=t[3];if(e>33||e<1)return!1;if(2!==t[3+e+1])return!1;const r=t[3+e+2];return!(r>33||r<1)&&t.length===3+e+2+r+2}(t.signature)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}},949:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+t.key.toString("hex"));return t.value.toString("utf8")},e.encode=function(t){return{key:n.from([i.InputTypes.POR_COMMITMENT]),value:n.from(t,"utf8")}},e.expected="string",e.check=function(t){return"string"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.porCommitment}},344:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+t.key.toString("hex"));return t.value.readUInt32LE(0)},e.encode=function(t){const e=n.from([i.InputTypes.SIGHASH_TYPE]),r=n.allocUnsafe(4);return r.writeUInt32LE(t,0),{key:e,value:r}},e.expected="number",e.check=function(t){return"number"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.sighashType}},760:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);function o(t){return n.isBuffer(t)&&(64===t.length||65===t.length)}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_KEY_SIG||1!==t.key.length)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_KEY_SIG]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapKeySig}},695:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+t.key.toString("hex"));if((t.key.length-2)%32!=0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+t.key.toString("hex"));const e=t.value[t.value.length-1];if((254&t.key[1])!==e)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+t.key.toString("hex"));const r=t.value.slice(0,-1);return{controlBlock:t.key.slice(1),script:r,leafVersion:e}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_LEAF_SCRIPT]),r=n.from([t.leafVersion]);return{key:n.concat([e,t.controlBlock]),value:n.concat([t.script,r])}},e.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",e.check=function(t){return n.isBuffer(t.controlBlock)&&(t.controlBlock.length-1)%32==0&&(254&t.controlBlock[0])===t.leafVersion&&n.isBuffer(t.script)},e.canAddToArray=function(t,e,r){const n=e.controlBlock.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.controlBlock.equals(e.controlBlock))).length)}},454:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);function o(t){return n.isBuffer(t)&&32===t.length}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_MERKLE_ROOT||1!==t.key.length)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_MERKLE_ROOT]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapMerkleRoot}},34:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+t.key.toString("hex"));if(65!==t.key.length)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+t.key.toString("hex"));if(64!==t.value.length&&65!==t.value.length)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1,33),leafHash:t.key.slice(33),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_SCRIPT_SIG]);return{key:n.concat([e,t.pubkey,t.leafHash]),value:t.signature}},e.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.leafHash)&&n.isBuffer(t.signature)&&32===t.pubkey.length&&32===t.leafHash.length&&(64===t.signature.length||65===t.signature.length)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex")+e.leafHash.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey)&&t.leafHash.equals(e.leafHash))).length)}},926:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80),o=r(133),a=r(394);e.decode=function(t){if(t.key[0]!==i.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+t.key.toString("hex"));const e=o.readUInt64LE(t.value,0);let r=8;const n=a.decode(t.value,r);r+=a.encodingLength(n);const u=t.value.slice(r);if(u.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:u,value:e}},e.encode=function(t){const{script:e,value:r}=t,u=a.encodingLength(e.length),s=n.allocUnsafe(8+u+e.length);return o.writeUInt64LE(s,r,0),a.encode(e.length,s,8),e.copy(s,8+u),{key:n.from([i.InputTypes.WITNESS_UTXO]),value:s}},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}},851:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(80),o=r(394);e.decode=function(t){if(t.key[0]!==i.OutputTypes.TAP_TREE||1!==t.key.length)throw new Error("Decode Error: could not decode tapTree with key 0x"+t.key.toString("hex"));let e=0;const r=[];for(;e<t.value.length;){const n=t.value[e++],i=t.value[e++],a=o.decode(t.value,e);e+=o.encodingLength(a),r.push({depth:n,leafVersion:i,script:t.value.slice(e,e+a)}),e+=a}return{leaves:r}},e.encode=function(t){const e=n.from([i.OutputTypes.TAP_TREE]),r=[].concat(...t.leaves.map((t=>[n.of(t.depth,t.leafVersion),o.encode(t.script.length),t.script])));return{key:e,value:n.concat(r)}},e.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",e.check=function(t){return Array.isArray(t.leaves)&&t.leaves.every((t=>t.depth>=0&&t.depth<=128&&(254&t.leafVersion)===t.leafVersion&&n.isBuffer(t.script)))},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapTree}},545:(t,e,r)=>{var n=r(287).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(o=r.value.length/4-1,[...Array(o).keys()])){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+="/"+o.toString(10)+(n?"'":"")}var o;return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split("/"),a=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(a,0);let u=4;return o.slice(1).forEach((t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),a.writeUInt32LE(r,u),u+=4})),{key:i,value:a}},check:function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.masterFingerprint)&&"string"==typeof t.path&&e(t.pubkey)&&4===t.masterFingerprint.length},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }",canAddToArray:function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}}}},412:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.makeChecker=function(t){return function(e){let r;if(t.includes(e.key[0])&&(r=e.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error("Format Error: invalid pubkey in key 0x"+e.key.toString("hex"));return r}}},307:(t,e,r)=>{var n=r(287).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}}}},636:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394),o=r(545),a=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,a);return{decode:function(t){const r=i.decode(t.value),n=i.encodingLength(r),o=e.decode({key:t.key,value:t.value.slice(n+32*r)}),a=new Array(r);for(let e=0,i=n;e<r;e++,i+=32)a[e]=t.value.slice(i,i+32);return Object.assign({},o,{leafHashes:a})},encode:function(t){const r=e.encode(t),o=i.encodingLength(t.leafHashes.length),a=n.allocUnsafe(o);i.encode(t.leafHashes.length,a);const u=n.concat([a,...t.leafHashes,r.value]);return Object.assign({},r,{value:u})},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}}},223:(t,e,r)=>{var n=r(287).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}}}},578:(t,e,r)=>{var n=r(287).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}}}},133:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394);function o(t){const e=t.key.length,r=t.value.length,o=i.encodingLength(e),a=i.encodingLength(r),u=n.allocUnsafe(o+e+a+r);return i.encode(e,u,0),t.key.copy(u,o),i.encode(r,u,o+e),t.value.copy(u,o+e+a),u}function a(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.range=t=>[...Array(t).keys()],e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n<t.length/2;n++)r=t[n],t[n]=t[e],t[e]=r,e--;return t},e.keyValsToBuffer=function(t){const e=t.map(o);return e.push(n.from([0])),n.concat(e)},e.keyValToBuffer=o,e.readUInt64LE=function(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,a(n+r,9007199254740991),n+r},e.writeUInt64LE=function(t,e,r){return a(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}},394:(t,e,r)=>{var n=r(287).Buffer;function i(t){if(t<0||t>9007199254740991||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}Object.defineProperty(e,"__esModule",{value:!0}),e.encode=function t(e,r,a){if(i(e),r||(r=n.allocUnsafe(o(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return a||(a=0),e<253?(r.writeUInt8(e,a),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,a),r.writeUInt16LE(e,a+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,a),r.writeUInt32LE(e,a+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,a),r.writeUInt32LE(e>>>0,a+1),r.writeUInt32LE(e/4294967296|0,a+5),Object.assign(t,{bytes:9})),r},e.decode=function t(e,r){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);const o=e.readUInt8(r);if(o<253)return Object.assign(t,{bytes:1}),o;if(253===o)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===o)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),o=4294967296*e.readUInt32LE(r+5)+n;return i(o),o}},e.encodingLength=o},263:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(706),o=r(133),a=r(394),u=r(80);function s(t,e,r){if(!e.equals(n.from([r])))throw new Error(`Format Error: Invalid ${t} key: ${e.toString("hex")}`)}function c(t,{globalMapKeyVals:e,inputKeyVals:r,outputKeyVals:n}){const a={unsignedTx:t};let c=0;for(const t of e)switch(t.key[0]){case u.GlobalTypes.UNSIGNED_TX:if(s("global",t.key,u.GlobalTypes.UNSIGNED_TX),c>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");c++;break;case u.GlobalTypes.GLOBAL_XPUB:void 0===a.globalXpub&&(a.globalXpub=[]),a.globalXpub.push(i.globals.globalXpub.decode(t));break;default:a.unknownKeyVals||(a.unknownKeyVals=[]),a.unknownKeyVals.push(t)}const f=r.length,l=n.length,h=[],p=[];for(const t of o.range(f)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case u.InputTypes.NON_WITNESS_UTXO:if(s("input",n.key,u.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 u.InputTypes.WITNESS_UTXO:if(s("input",n.key,u.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 u.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case u.InputTypes.SIGHASH_TYPE:if(s("input",n.key,u.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 u.InputTypes.REDEEM_SCRIPT:if(s("input",n.key,u.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 u.InputTypes.WITNESS_SCRIPT:if(s("input",n.key,u.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 u.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case u.InputTypes.FINAL_SCRIPTSIG:s("input",n.key,u.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case u.InputTypes.FINAL_SCRIPTWITNESS:s("input",n.key,u.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case u.InputTypes.POR_COMMITMENT:s("input",n.key,u.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case u.InputTypes.TAP_KEY_SIG:s("input",n.key,u.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case u.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case u.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case u.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case u.InputTypes.TAP_INTERNAL_KEY:s("input",n.key,u.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case u.InputTypes.TAP_MERKLE_ROOT:s("input",n.key,u.InputTypes.TAP_MERKLE_ROOT),e.tapMerkleRoot=i.inputs.tapMerkleRoot.decode(n);break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(n)}h.push(e)}for(const t of o.range(l)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case u.OutputTypes.REDEEM_SCRIPT:if(s("output",r.key,u.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 u.OutputTypes.WITNESS_SCRIPT:if(s("output",r.key,u.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 u.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case u.OutputTypes.TAP_INTERNAL_KEY:s("output",r.key,u.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case u.OutputTypes.TAP_TREE:s("output",r.key,u.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case u.OutputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.outputs.tapBip32Derivation.decode(r));break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(r)}p.push(e)}return{globalMap:a,inputs:h,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=a.decode(t,r);r+=a.encodingLength(e);const n=t.slice(r,r+e);return r+=e,n}function i(){return{key:n(),value:n()}}function s(){if(r>=t.length)throw new Error("Format Error: Unexpected End of PSBT");const e=0===t.readUInt8(r);return e&&r++,e}if(1886610036!==function(){const e=t.readUInt32BE(r);return r+=4,e}())throw new Error("Format Error: Invalid Magic Number");if(255!==function(){const e=t.readUInt8(r);return r+=1,e}())throw new Error("Format Error: Magic Number must be followed by 0xff separator");const f=[],l={};for(;!s();){const t=i(),e=t.key.toString("hex");if(l[e])throw new Error("Format Error: Keys must be unique for global keymap: key "+e);l[e]=1,f.push(t)}const h=f.filter((t=>t.key[0]===u.GlobalTypes.UNSIGNED_TX));if(1!==h.length)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const p=e(h[0].value),{inputCount:d,outputCount:y}=p.getInputOutputCounts(),g=[],b=[];for(const t of o.range(d)){const e={},r=[];for(;!s();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each input: input index "+t+" key "+o);e[o]=1,r.push(n)}g.push(r)}for(const t of o.range(y)){const e={},r=[];for(;!s();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each output: output index "+t+" key "+o);e[o]=1,r.push(n)}b.push(r)}return c(p,{globalMapKeyVals:f,inputKeyVals:g,outputKeyVals:b})},e.checkKeyBuffer=s,e.psbtFromKeyVals=c},457:(t,e,r)=>{function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),n(r(263)),n(r(238))},238:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(706),o=r(133);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:i,inputKeyVals:a,outputKeyVals:u}=s({globalMap:t,inputs:e,outputs:r}),c=o.keyValsToBuffer(i),f=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),l=f(a),h=f(u),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,c].concat(l,h))};const a=(t,e)=>t.key.compare(e.key);function u(t,e){const r=new Set,n=Object.entries(t).reduce(((t,[n,i])=>{if("unknownKeyVals"===n)return t;const o=e[n];if(void 0===o)return t;const a=(Array.isArray(i)?i:[i]).map(o.encode);return a.map((t=>t.key.toString("hex"))).forEach((t=>{if(r.has(t))throw new Error("Serialize Error: Duplicate key: "+t);r.add(t)})),t.concat(a)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString("hex")))):[];return n.concat(i).sort(a)}function s({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:u(t,i.globals),inputKeyVals:e.map((t=>u(t,i.inputs))),outputKeyVals:r.map((t=>u(t,i.outputs)))}}e.psbtToKeyVals=s},614:(t,e,r)=>{var n=r(287).Buffer;const i=r(863),o=r(457),a=r(80),u=r(699);e.i=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,e){const r=n.from(t,"base64");return this.fromBuffer(r,e)}static fromHex(t,e){const r=n.from(t,"hex");return this.fromBuffer(r,e)}static fromBuffer(t,e){const r=o.psbtFromBuffer(t,e),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString("base64")}toHex(){return this.toBuffer().toString("hex")}toBuffer(){return o.psbtToBuffer(this)}updateGlobal(t){return u.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=u.checkForInput(this.inputs,t);return u.updateInput(e,r),this}updateOutput(t,e){const r=u.checkForOutput(this.outputs,t);return u.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return u.checkHasKey(t,this.globalMap.unknownKeyVals,u.getEnumLength(a.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=u.checkForInput(this.inputs,t);return u.checkHasKey(e,r.unknownKeyVals,u.getEnumLength(a.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=u.checkForOutput(this.outputs,t);return u.checkHasKey(e,r.unknownKeyVals,u.getEnumLength(a.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach((t=>this.addUnknownKeyValToInput(r,t))),u.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))),u.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=u.checkForInput(this.inputs,t);u.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()}}},80:(t,e)=>{var r,n,i;Object.defineProperty(e,"__esModule",{value:!0}),(i=e.GlobalTypes||(e.GlobalTypes={}))[i.UNSIGNED_TX=0]="UNSIGNED_TX",i[i.GLOBAL_XPUB=1]="GLOBAL_XPUB",e.GLOBAL_TYPE_NAMES=["unsignedTx","globalXpub"],(n=e.InputTypes||(e.InputTypes={}))[n.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",n[n.WITNESS_UTXO=1]="WITNESS_UTXO",n[n.PARTIAL_SIG=2]="PARTIAL_SIG",n[n.SIGHASH_TYPE=3]="SIGHASH_TYPE",n[n.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",n[n.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",n[n.BIP32_DERIVATION=6]="BIP32_DERIVATION",n[n.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",n[n.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",n[n.POR_COMMITMENT=9]="POR_COMMITMENT",n[n.TAP_KEY_SIG=19]="TAP_KEY_SIG",n[n.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",n[n.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",n[n.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",n[n.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",n[n.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT",e.INPUT_TYPE_NAMES=["nonWitnessUtxo","witnessUtxo","partialSig","sighashType","redeemScript","witnessScript","bip32Derivation","finalScriptSig","finalScriptWitness","porCommitment","tapKeySig","tapScriptSig","tapLeafScript","tapBip32Derivation","tapInternalKey","tapMerkleRoot"],(r=e.OutputTypes||(e.OutputTypes={}))[r.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",r[r.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",r[r.BIP32_DERIVATION=2]="BIP32_DERIVATION",r[r.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",r[r.TAP_TREE=6]="TAP_TREE",r[r.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION",e.OUTPUT_TYPE_NAMES=["redeemScript","witnessScript","bip32Derivation","tapInternalKey","tapTree","tapBip32Derivation"]},699:(t,e,r)=>{var n=r(287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(706);function o(t,e){const r=t[e];if(void 0===r)throw new Error(`No input #${e}`);return r}function a(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function u(t,e,r,n){throw new Error(`Data for ${t} key ${e} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function s(t){return(e,r)=>{for(const n of Object.keys(e)){const o=e[n],{canAdd:a,canAddToArray:s,check:c,expected:f}=i[t+"s"][n]||{};if(c)if(s){if(!Array.isArray(o)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);o.every(c)||u(t,n,f,o);const e=r[n]||[],i=new Set;if(!o.every((t=>s(e,t,i))))throw new Error("Can not add duplicate data to array");r[n]=e.concat(o)}else{if(c(o)||u(t,n,f,o),!a(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=a,e.checkHasKey=function(t,e,r){if(t.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(e&&0!==e.filter((e=>e.key.equals(t.key))).length)throw new Error(`Duplicate Key: ${t.key.toString("hex")}`)},e.getEnumLength=function(t){let e=0;return Object.keys(t).forEach((t=>{Number(isNaN(Number(t)))&&e++})),e},e.inputCheckUncleanFinalized=function(t,e){let r=!1;if(e.nonWitnessUtxo||e.witnessUtxo){const t=!!e.redeemScript,n=!!e.witnessScript,i=!t||!!e.finalScriptSig,o=!n||!!e.finalScriptWitness,a=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&a}if(!1===r)throw new Error(`Input #${t} has too much or too little data to clean`)},e.updateGlobal=s("global"),e.updateInput=s("input"),e.updateOutput=s("output"),e.addInputAttributes=function(t,r){const n=o(t,t.length-1);e.updateInput(r,n)},e.addOutputAttributes=function(t,r){const n=a(t,t.length-1);e.updateOutput(r,n)},e.defaultVersionSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Version: Invalid Transaction");return e.writeUInt32LE(t,0),e},e.defaultLocktimeSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Locktime: Invalid Transaction");return e.writeUInt32LE(t,e.length-4),e}},287:(t,e,r)=>{const n=r(526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=s,e.SlowBuffer=function(t){return+t!=t&&(t=0),s.alloc(+t)},e.INSPECT_MAX_BYTES=50;const a=2147483647;function u(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return c(t,e,r)}function c(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=u(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return s.from(n,e,r);const i=function(t){if(s.isBuffer(t)){const e=0|d(t.length),r=u(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Z(t.length)?u(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 s.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return f(t),u(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=u(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,s.prototype),n}function d(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return z(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function g(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 I(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Z(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=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){let o,a=1,u=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,u/=2,s/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<u;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===s)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+s>u&&(r=u-s),o=r;o>=0;o--){let r=!0;for(let n=0;n<s;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(Z(n))return a;t[r+a]=n}return a}function _(t,e,r,n){return Y(q(e,t.length-r),t,r,n)}function E(t,e,r,n){return Y(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 Y(z(e),t,r,n)}function k(t,e,r,n){return Y(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,u,s;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(s=(31&e)<<6|63&r,s>127&&(o=s));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(s=(15&e)<<12|(63&r)<<6|63&n,s>2047&&(s<55296||s>57343)&&(o=s));break;case 4:r=t[i+1],n=t[i+2],u=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&u)&&(s=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&u,s>65535&&s<1114112&&(o=s))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=x));return r}(n)}e.kMaxLength=a,s.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}}(),s.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(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(t,e,r){return c(t,e,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(t,e,r){return function(t,e,r){return f(t),t<=0?u(t):void 0!==e?"string"==typeof r?u(t).fill(e,r):u(t).fill(e):u(t)}(t,e,r)},s.allocUnsafe=function(t){return l(t)},s.allocUnsafeSlow=function(t){return l(t)},s.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==s.prototype},s.compare=function(t,e){if(X(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},s.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}},s.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=s.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(X(e,Uint8Array))i+e.length>n.length?(s.isBuffer(e)||(e=s.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!s.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},s.byteLength=y,s.prototype._isBuffer=!0,s.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)b(this,e,e+1);return this},s.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)b(this,e,e+3),b(this,e+1,e+2);return this},s.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)b(this,e,e+7),b(this,e+1,e+6),b(this,e+2,e+5),b(this,e+3,e+4);return this},s.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?T(this,0,t):g.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(s.prototype[o]=s.prototype.inspect),s.prototype.compare=function(t,e,r,n,i){if(X(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const u=Math.min(o,a),c=this.slice(n,i),f=t.slice(e,r);for(let t=0;t<u;++t)if(c[t]!==f[t]){o=c[t],a=f[t];break}return o<a?-1:a<o?1:0},s.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},s.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},s.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},s.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":case"latin1":case"binary":return E(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const x=4096;function A(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function P(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function I(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=$[t[n]];return i}function L(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 B(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 R(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function j(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function N(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function U(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.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,s.prototype),n},s.prototype.readUintLE=s.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readBigUInt64LE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),s.prototype.readBigUInt64BE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||B(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||B(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readBigInt64LE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),s.prototype.readBigInt64BE=J((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),s.prototype.readFloatLE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||R(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||R(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||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},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||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},s.prototype.writeBigUInt64LE=J((function(t,e=0){return j(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeBigUInt64BE=J((function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);R(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);R(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||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},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||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},s.prototype.writeBigInt64LE=J((function(t,e=0){return j(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeBigInt64BE=J((function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.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},s.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&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=s.isBuffer(t)?t:s.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const M={};function D(t,e,r){M[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 H(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function K(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new M.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||W(e,t.length-(r+1))}(n,i,o)}function G(t,e){if("number"!=typeof t)throw new M.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,r){if(Math.floor(t)!==t)throw G(t,r),new M.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}D("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),D("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),D("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=H(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=H(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const V=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function z(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Z(t){return t!=t}const $=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},251:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,u=8*i-n-1,s=(1<<u)-1,c=s>>1,f=-7,l=r?i-1:0,h=r?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=u;f>0;o=256*o+t[e+l],l+=h,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===s)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,u,s,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-a))<1&&(a--,s*=2),(e+=a+l>=1?h/s:h*Math.pow(2,1-l))*s>=2&&(a++,s/=2),a+l>=f?(u=0,a=f):a+l>=1?(u=(e*s-1)*Math.pow(2,i),a+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&u,p+=d,u/=256,i-=8);for(a=a<<i|u,c+=i;c>0;t[r+p]=255&a,p+=d,a/=256,c-=8);t[r+p-d]|=128*y}},861:(t,e,r)=>{var n=r(287),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function a(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},a.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},61:(t,e,r)=>{var n=r(113);function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function a(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function u(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 s(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 "+u(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function c(t,e,r){r=r||o(e),this.message=s(t,e,r),a(this,c),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),s('property "'+u(r)+o+u(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',a(this,c),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,f.prototype=Object.create(Error.prototype),f.prototype.constructor=c,t.exports={TfTypeError:c,TfPropertyTypeError:f,tfCustomError:function(t,e){return new c(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+"."+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof c&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),a(t),t},tfJSON:u,getValueTypeName:o}},542:(t,e,r)=>{var n=r(287).Buffer,i=r(113),o=r(61);function a(t){return n.isBuffer(t)}function u(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function s(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var c=s.bind(null,i.Array),f=s.bind(null,a),l=s.bind(null,u),h=s.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:c,Buffer:a,BufferN:f,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:u,HexN:l,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n<e}return r=r||i.Number,n.toJSON=function(){return`${r.toJSON()} between [${t}, ${e}]`},n},StringN:h,UInt8:function(t){return(255&t)===t},UInt16:function(t){return(65535&t)===t},UInt32:function(t){return t>>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},676:(t,e,r)=>{var n=r(61),i=r(113),o=n.tfJSON,a=n.TfTypeError,u=n.TfPropertyTypeError,s=n.tfSubError,c=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==e.minLength&&r.length<e.minLength)&&!(void 0!==e.maxLength&&r.length>e.maxLength)&&(void 0===e.length||r.length===e.length)&&r.every((function(e,r){try{return h(t,e,n)}catch(t){throw s(t,r)}}))}return t=l(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=l(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&h(e,o,n)}catch(t){throw s(t,o,"key")}try{var a=r[o];h(t,a,n)}catch(t){throw s(t,o)}}return!0}return t=l(t),e&&(e=l(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=l(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e)h(e[n],t[n],r)}catch(t){throw s(t,n)}if(r)for(n in t)if(!e[n])throw new u(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.some((function(t){try{return h(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return t.every((function(t){try{return h(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(l);function e(e,r){return!i.Nil(e)&&!i.Nil(e.length)&&(!r||e.length===t.length)&&t.every((function(t,n){try{return h(t,e[n],r)}catch(t){throw s(t,n)}}))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function l(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new a(n||t,e)}return h(l(t),e,r)}for(var p in f.oneOf=f.anyOf,i)h[p]=i[p];for(p in f)h[p]=f[p];var d=r(542);for(p in d)h[p]=d[p];h.compile=l,h.TfTypeError=a,h.TfPropertyTypeError=u,t.exports=h},113:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return null==t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},469:(t,e,r)=>{var n=r(861).Buffer;function i(t){if(t<0||t>9007199254740991||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}t.exports={encode:function t(e,r,a){if(i(e),r||(r=n.allocUnsafe(o(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return a||(a=0),e<253?(r.writeUInt8(e,a),t.bytes=1):e<=65535?(r.writeUInt8(253,a),r.writeUInt16LE(e,a+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,a),r.writeUInt32LE(e,a+1),t.bytes=5):(r.writeUInt8(255,a),r.writeUInt32LE(e>>>0,a+1),r.writeUInt32LE(e/4294967296|0,a+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 o=e.readUInt8(r);if(o<253)return t.bytes=1,o;if(253===o)return t.bytes=3,e.readUInt16LE(r+1);if(254===o)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var a=e.readUInt32LE(r+1),u=4294967296*e.readUInt32LE(r+5)+a;return i(u),u},encodingLength:o}}},y={};function g(t){var e=y[t];if(void 0!==e)return e.exports;var r=y[t]={exports:{}};return d[t](r,r.exports,g),r.exports}g.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return g.d(e,{a:e}),e},g.d=(t,e)=>{for(var r in e)g.o(e,r)&&!g.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},g.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),g.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var b={};g.d(b,{eB:()=>Zi,Oo:()=>vr,ac:()=>br,ri:()=>_r,RY:()=>Er,iL:()=>Ao,PW:()=>Xe,gp:()=>Ye,gM:()=>St,ZX:()=>Qn,hl:()=>E,p2:()=>Li,XL:()=>Ni,R0:()=>si,vJ:()=>pi,em:()=>ci,Eb:()=>gr,Et:()=>S,m$:()=>Ii,Ay:()=>ca,CB:()=>Tr,VL:()=>we,ow:()=>me,hP:()=>Se,Dk:()=>Go,Ln:()=>Ci,BL:()=>yi,A0:()=>qe,CX:()=>ze,f0:()=>Qe,Bh:()=>Ei,Q2:()=>Si,C5:()=>ki,n0:()=>xi,NI:()=>Ai,fQ:()=>Oi,mG:()=>Ti,AM:()=>ai,Zh:()=>ui,o8:()=>v,Ez:()=>it,KT:()=>O,KS:()=>Wo,AI:()=>ji,k1:()=>Ri,pM:()=>Bi,Qf:()=>pr,Fl:()=>yr,HE:()=>Ge,WH:()=>kr,K$:()=>_,C2:()=>oi,e8:()=>We,sc:()=>Ve,XN:()=>Ui,VQ:()=>Ze,LE:()=>ii,_T:()=>hi,zm:()=>li,qR:()=>Ar,o4:()=>xr,Og:()=>_e,FT:()=>Ee,uu:()=>Or,I:()=>ke,gU:()=>ni,wn:()=>fi,Kn:()=>Pr,Uu:()=>ir,du:()=>Pi,tO:()=>dr});var v={};g.r(v),g.d(v,{bitcoin:()=>T,bitcoinCash:()=>R,bitcoinCashTestnet:()=>j,dash:()=>N,dashTestnet:()=>U,dogecoin:()=>P,dogecoinTestnet:()=>I,litecoin:()=>L,litecoinTestnet:()=>B,regtest:()=>x,testnet:()=>A});var w={};g.r(w),g.d(w,{decode:()=>pt,encode:()=>dt});var m={};g.r(m),g.d(m,{decode:()=>Vt,encode:()=>qt});var _={};g.r(_),g.d(_,{OPS:()=>it,compile:()=>re,countNonPushOnlyOPs:()=>Jt,decompile:()=>ne,fromASM:()=>oe,isCanonicalPubKey:()=>ue,isCanonicalScriptSignature:()=>ce,isDefinedHashType:()=>se,isPushOnly:()=>$t,number:()=>fe,signature:()=>le,toASM:()=>ie,toStack:()=>ae});var E={};g.r(E),g.d(E,{fromBase58Check:()=>we,fromBech32:()=>me,fromOutputScript:()=>Se,toBase58Check:()=>_e,toBech32:()=>Ee,toOutputScript:()=>ke});var S={};g.r(S),g.d(S,{TAGGED_HASH_PREFIXES:()=>Xe,TAGS:()=>Ye,hash160:()=>qe,hash256:()=>ze,ripemd160:()=>Ge,sha1:()=>We,sha256:()=>Ve,taggedHash:()=>Ze});var k={};g.r(k),g.d(k,{Transaction:()=>Qn});var O={};g.r(O),g.d(O,{LEAF_VERSION_TAPSCRIPT:()=>_r,MAX_TAPTREE_DEPTH:()=>Er,findScriptPath:()=>Tr,p2data:()=>jr,p2ms:()=>Cr,p2pk:()=>Mr,p2pkh:()=>Di,p2sh:()=>Tn,p2tr:()=>In,p2wpkh:()=>jn,p2wsh:()=>Mn,prop:()=>Lr,rootHashFromPath:()=>kr,tapTweakHash:()=>Ar,tapleafHash:()=>xr,toHashTree:()=>Or,tweakKey:()=>Pr,value:()=>Br});var T={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},x={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},A={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},P={messagePrefix:"Dogecoin Signed Message:\n",bech32:"",bip32:{public:49990397,private:49988504},pubKeyHash:30,scriptHash:22,wif:158},I={messagePrefix:"Dogecoin Signed Message:\n",bech32:"",bip32:{public:70429096,private:70427203},pubKeyHash:113,scriptHash:196,wif:241},L={messagePrefix:"Litecoin Signed Message:\n",bech32:"ltc",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176},B={messagePrefix:"Litecoin Signed Message:\n",bech32:"tltc",bip32:{public:70709117,private:70711009},pubKeyHash:111,scriptHash:58,wif:239},R={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bitcoincash",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},j={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bchtest",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},N={messagePrefix:"DarkCoin Signed Message:\n",bech32:"",bip32:{public:50221772,private:50221816},pubKeyHash:76,scriptHash:16,wif:204},U={messagePrefix:"DarkCoin Signed Message:\n",bech32:"",bip32:{public:981492128,private:981489719},pubKeyHash:140,scriptHash:19,wif:239},C=g(343);function F(t,...e){if(!((r=t)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function M(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 D=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),H=(t,e)=>t<<32-e|t>>>e,K=(t,e)=>t<<e|t>>>32-e>>>0;function G(t){return"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)),F(t),t}class W{clone(){return this._cloneInto()}}function V(t){const e=e=>t().update(G(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}const q=(t,e,r)=>t&e^~t&r,z=(t,e,r)=>t&e^t&r^e&r;class Y extends W{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=D(this.buffer)}update(t){M(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=G(t)).length;for(let o=0;o<i;){const a=Math.min(n-this.pos,i-o);if(a!==n)r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=D(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){M(this),function(t,e){F(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),u=Number(r&o),s=n?4:0,c=n?0:4;t.setUint32(e+s,a,n),t.setUint32(e+c,u,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=D(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const s=u/4,c=this.get();if(s>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<s;t++)a.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const X=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]),Z=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$=new Uint32Array(64);class J extends Y{constructor(){super(64,32,8,!1),this.A=0|Z[0],this.B=0|Z[1],this.C=0|Z[2],this.D=0|Z[3],this.E=0|Z[4],this.F=0|Z[5],this.G=0|Z[6],this.H=0|Z[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:u}=this;return[t,e,r,n,i,o,a,u]}set(t,e,r,n,i,o,a,u){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|u}process(t,e){for(let r=0;r<16;r++,e+=4)$[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=$[t-15],r=$[t-2],n=H(e,7)^H(e,18)^e>>>3,i=H(r,17)^H(r,19)^r>>>10;$[t]=i+$[t-7]+n+$[t-16]|0}let{A:r,B:n,C:i,D:o,E:a,F:u,G:s,H:c}=this;for(let t=0;t<64;t++){const e=c+(H(a,6)^H(a,11)^H(a,25))+q(a,u,s)+X[t]+$[t]|0,f=(H(r,2)^H(r,13)^H(r,22))+z(r,n,i)|0;c=s,s=u,u=a,a=o+e|0,o=i,i=n,n=r,r=e+f|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,s=s+this.G|0,c=c+this.H|0,this.set(r,n,i,o,a,u,s,c)}roundClean(){$.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Q=V((()=>new J)),tt=function(t){const e=new Uint8Array(256);for(let t=0;t<e.length;t++)e[t]=255;for(let r=0;r<58;r++){const n=t.charAt(r),i=n.charCodeAt(0);if(255!==e[i])throw new TypeError(n+" is ambiguous");e[i]=r}const r=t.charAt(0),n=Math.log(58)/Math.log(256),i=Math.log(256)/Math.log(58);function o(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;let i=0,o=0,a=0;for(;t[i]===r;)o++,i++;const u=(t.length-i)*n+1>>>0,s=new Uint8Array(u);for(;t[i];){let r=e[t.charCodeAt(i)];if(255===r)return;let n=0;for(let t=u-1;(0!==r||n<a)&&-1!==t;t--,n++)r+=58*s[t]>>>0,s[t]=r%256>>>0,r=r/256>>>0;if(0!==r)throw new Error("Non-zero carry");a=n,i++}let c=u-a;for(;c!==u&&0===s[c];)c++;const f=new Uint8Array(o+(u-c));let l=o;for(;c!==u;)f[l++]=s[c++];return f}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";let n=0,o=0,a=0;const u=e.length;for(;a!==u&&0===e[a];)a++,n++;const s=(u-a)*i+1>>>0,c=new Uint8Array(s);for(;a!==u;){let t=e[a],r=0;for(let e=s-1;(0!==t||r<o)&&-1!==e;e--,r++)t+=256*c[e]>>>0,c[e]=t%58>>>0,t=t/58>>>0;if(0!==t)throw new Error("Non-zero carry");o=r,a++}let f=s-o;for(;f!==s&&0===c[f];)f++;let l=r.repeat(n);for(;f<s;++f)l+=t.charAt(c[f]);return l},decodeUnsafe:o,decode:function(t){const e=o(t);if(e)return e;throw new Error("Non-base58 character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),et=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),n=t(r),i=r.length+4,o=new Uint8Array(i);return o.set(r,0),o.set(n.subarray(0,4),r.length),tt.encode(o)},decode:function(t){var r=e(tt.decode(t));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=tt.decodeUnsafe(t);if(null!=r)return e(r)}}}((function(t){return Q(Q(t))}));var rt=g(287).Buffer;function nt(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=rt.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}for(var it={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},ot={},at=0,ut=Object.keys(it);at<ut.length;at++){var st=ut[at],ct=it[st];ot[ct]=st}function ft(t){return t<it.OP_PUSHDATA1?1:t<=255?2:t<=65535?3:5}function lt(t,e){var r,n,i=t.readUInt8(e);if(i<it.OP_PUSHDATA1)r=i,n=1;else if(i===it.OP_PUSHDATA1){if(e+2>t.length)return null;r=t.readUInt8(e+1),n=2}else if(i===it.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),n=3}else{if(e+5>t.length)return null;if(i!==it.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),n=5}return{opcode:i,number:r,size:n}}var ht=g(287).Buffer;function pt(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&!(127&t[n-1]||!(n<=1)&&128&t[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var a=0,u=0;u<n;++u)a|=t[u]<<8*u;return 128&t[n-1]?-(a&~(128<<8*(n-1))):a}function dt(t){for(var e=Math.abs(t),r=function(t){return t>2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=ht.allocUnsafe(r),i=t<0,o=0;o<r;++o)n.writeUInt8(255&e,o),e>>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}var yt=g(287),gt=g(676),bt=g.n(gt)(),vt=yt.Buffer.alloc(32,0),wt=yt.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");function mt(t,e){return t.length===e.length&&t.every((function(t,r){return t.equals(e[r])}))}function _t(t){if(!yt.Buffer.isBuffer(t))return!1;if(t.length<33)return!1;var e=t[0],r=t.slice(1,33);if(0===r.compare(vt))return!1;if(r.compare(wt)>=0)return!1;if((2===e||3===e)&&33===t.length)return!0;if(65!==t.length)return!1;var n=t.slice(33);return!(0===n.compare(vt)||n.compare(wt)>=0||4!==e&&6!==e&&7!==e)}function Et(t){return bt.UInt53(t)&&t<=21e14}var St=254;function kt(t){return!(!t||!("output"in t)||!yt.Buffer.isBuffer(t.output)||void 0!==t.version&&(t.version&St)!==t.version)}function Ot(t){return Pt(t)?2===t.length&&t.every((function(t){return Ot(t)})):kt(t)}bt.BufferN(32);var Tt=bt.BufferN(20),xt=bt.BufferN(32),At=bt.Number,Pt=bt.Array,It=(bt.Boolean,bt.String),Lt=bt.Buffer,Bt=bt.Hex,Rt=bt.maybe,jt=bt.tuple,Nt=bt.UInt8,Ut=bt.UInt32,Ct=bt.Function,Ft=bt.BufferN,Mt=bt.Null,Dt=(bt.oneOf,g(287).Buffer),Ht=bt,Kt=Dt.alloc(1,0);function Gt(t){for(var e=0;0===t[e];)++e;return e===t.length?Kt:128&(t=t.slice(e))[0]?Dt.concat([Kt,t],1+t.length):t}function Wt(t){0===t[0]&&(t=t.slice(1));var e=Dt.alloc(32,0),r=Math.max(0,32-t.length);return t.copy(e,r),e}function Vt(t){var e=t.readUInt8(t.length-1);if(!se(e))throw new Error("Invalid hashType "+e);var r=function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}}(t.slice(0,-1)),n=Wt(r.r),i=Wt(r.s);return{signature:Dt.concat([n,i],64),hashType:e}}function qt(t,e){if(Ht({signature:Ft(64),hashType:Nt},{signature:t,hashType:e}),!se(e))throw new Error("Invalid hashType "+e);var r=Dt.allocUnsafe(1);r.writeUInt8(e,0);var n=Gt(t.slice(0,32)),i=Gt(t.slice(32,64));return Dt.concat([nt(n,i),r])}var zt=g(287).Buffer,Yt=bt,Xt=it.OP_RESERVED;function Zt(t){return Lt(t)||function(t){return At(t)&&(t===it.OP_0||t>=it.OP_1&&t<=it.OP_16||t===it.OP_1NEGATE)}(t)}function $t(t){return Pt(t)&&t.every(Zt)}function Jt(t){return t.length-t.filter(Zt).length}function Qt(t){return 0===t.length?it.OP_0:1===t.length?t[0]>=1&&t[0]<=16?Xt+t[0]:129===t[0]?it.OP_1NEGATE:void 0:void 0}function te(t){return zt.isBuffer(t)}function ee(t){return zt.isBuffer(t)}function re(t){if(te(t))return t;Yt(Pt,t);var e=t.reduce((function(t,e){return ee(e)?1===e.length&&void 0!==Qt(e)?t+1:t+ft(e.length)+e.length:t+1}),0),r=zt.allocUnsafe(e),n=0;if(t.forEach((function(t){if(ee(t)){var e=Qt(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=function(t,e,r){var n=ft(e);return 1===n?t.writeUInt8(e,r):2===n?(t.writeUInt8(it.OP_PUSHDATA1,r),t.writeUInt8(e,r+1)):3===n?(t.writeUInt8(it.OP_PUSHDATA2,r),t.writeUInt16LE(e,r+1)):(t.writeUInt8(it.OP_PUSHDATA4,r),t.writeUInt32LE(e,r+1)),n}(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1})),n!==r.length)throw new Error("Could not decode chunks");return r}function ne(t){if(Pt(t))return t;Yt(Lt,t);for(var e=[],r=0;r<t.length;){var n=t[r];if(n>it.OP_0&&n<=it.OP_PUSHDATA4){var i=lt(t,r);if(null===i)return null;if((r+=i.size)+i.number>t.length)return null;var o=t.slice(r,r+i.number);r+=i.number;var a=Qt(o);void 0!==a?e.push(a):e.push(o)}else e.push(n),r+=1}return e}function ie(t){if(te(t)&&(t=ne(t)),!t)throw new Error("Could not convert invalid chunks to ASM");return t.map((function(t){if(ee(t)){var e=Qt(t);if(void 0===e)return t.toString("hex");t=e}return ot[t]})).join(" ")}function oe(t){return Yt(It,t),re(t.split(" ").map((function(t){return void 0!==it[t]?it[t]:(Yt(Bt,t),zt.from(t,"hex"))})))}function ae(t){return t=ne(t),Yt($t,t),t.map((function(t){return ee(t)?t:t===it.OP_0?zt.allocUnsafe(0):dt(t-Xt)}))}function ue(t){return _t(t)}function se(t){var e=-129&t;return e>0&&e<4}function ce(t){return!!zt.isBuffer(t)&&!!se(t[t.length-1])&&function(t){if(t.length<8)return!1;if(t.length>72)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))}(t.slice(0,-1))}var fe=w,le=m,he=g(287).Buffer,pe=40,de=2,ye=16,ge=2,be=80,ve="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 we(t){var e=he.from(et.decode(t));if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function me(t){var e,r;try{e=C.I.decode(t)}catch(t){}if(e){if(0!==(r=e.words[0]))throw new TypeError(t+" uses wrong encoding")}else if(0===(r=(e=C.p2.decode(t)).words[0]))throw new TypeError(t+" uses wrong encoding");var n=C.I.fromWords(e.words.slice(1));return{version:r,prefix:e.prefix,data:he.from(n)}}function _e(t,e){bt(jt(Tt,Nt),arguments);var r=he.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),et.encode(r)}function Ee(t,e,r){var n=C.I.toWords(t);return n.unshift(e),0===e?C.I.encode(r,n):C.p2.encode(r,n)}function Se(t,e){e=e||T;try{return Di({output:t,network:e}).address}catch(t){}try{return Tn({output:t,network:e}).address}catch(t){}try{return jn({output:t,network:e}).address}catch(t){}try{return Mn({output:t,network:e}).address}catch(t){}try{return In({output:t,network:e}).address}catch(t){}try{return function(t,e){var r=t.slice(2);if(r.length<de||r.length>pe)throw new TypeError("Invalid program length for segwit address");var n=t[0]-be;if(n<ge||n>ye)throw new TypeError("Invalid version for segwit address");if(t[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(ve),Ee(r,n,e.bech32)}(t,e)}catch(t){}throw new Error(ie(t)+" has no matching Address")}function ke(t,e){var r,n;e=e||T;try{r=we(t)}catch(t){}if(r){if(r.version===e.pubKeyHash)return Di({hash:r.hash}).output;if(r.version===e.scriptHash)return Tn({hash:r.hash}).output}else{try{n=me(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 jn({hash:n.data}).output;if(32===n.data.length)return Mn({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return In({pubkey:n.data}).output}else if(n.version>=ge&&n.version<=ye&&n.data.length>=de&&n.data.length<=pe)return console.warn(ve),re([n.version+be,n.data])}}return he.from(t,"hex")}const Oe=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Te=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e)));let xe=[Te],Ae=[Te.map((t=>(9*t+5)%16))];for(let t=0;t<4;t++)for(let e of[xe,Ae])e.push(e[t].map((t=>Oe[t])));const Pe=[[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))),Ie=xe.map(((t,e)=>t.map((t=>Pe[e][t])))),Le=Ae.map(((t,e)=>t.map((t=>Pe[e][t])))),Be=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Re=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function je(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 Ne=new Uint32Array(16);class Ue extends Y{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)Ne[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,i=0|this.h1,o=i,a=0|this.h2,u=a,s=0|this.h3,c=s,f=0|this.h4,l=f;for(let t=0;t<5;t++){const e=4-t,h=Be[t],p=Re[t],d=xe[t],y=Ae[t],g=Ie[t],b=Le[t];for(let e=0;e<16;e++){const n=K(r+je(t,i,a,s)+Ne[d[e]]+h,g[e])+f|0;r=f,f=s,s=0|K(a,10),a=i,i=n}for(let t=0;t<16;t++){const r=K(n+je(e,o,u,c)+Ne[y[t]]+p,b[t])+l|0;n=l,l=c,c=0|K(u,10),u=o,o=r}}this.set(this.h1+a+c|0,this.h2+s+l|0,this.h3+f+n|0,this.h4+r+o|0,this.h0+i+u|0)}roundClean(){Ne.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const Ce=V((()=>new Ue)),Fe=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),Me=new Uint32Array(80);class De extends Y{constructor(){super(64,20,8,!1),this.A=0|Fe[0],this.B=0|Fe[1],this.C=0|Fe[2],this.D=0|Fe[3],this.E=0|Fe[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)Me[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)Me[t]=K(Me[t-3]^Me[t-8]^Me[t-14]^Me[t-16],1);let{A:r,B:n,C:i,D:o,E:a}=this;for(let t=0;t<80;t++){let e,u;t<20?(e=q(n,i,o),u=1518500249):t<40?(e=n^i^o,u=1859775393):t<60?(e=z(n,i,o),u=2400959708):(e=n^i^o,u=3395469782);const s=K(r,5)+e+a+u+Me[t]|0;a=o,o=i,i=K(n,30),n=r,r=s}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,this.set(r,n,i,o,a)}roundClean(){Me.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}const He=V((()=>new De));var Ke=g(287).Buffer;function Ge(t){return Ke.from(Ce(Uint8Array.from(t)))}function We(t){return Ke.from(He(Uint8Array.from(t)))}function Ve(t){return Ke.from(Q(Uint8Array.from(t)))}function qe(t){return Ke.from(Ce(Q(Uint8Array.from(t))))}function ze(t){return Ke.from(Q(Q(Uint8Array.from(t))))}var Ye=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],Xe={"BIP0340/challenge":Ke.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":Ke.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":Ke.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:Ke.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:Ke.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:Ke.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:Ke.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":Ke.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":Ke.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])};function Ze(t,e){return Ve(Ke.concat([Xe[t],e]))}var $e=g(287).Buffer,Je={};function Qe(t){var e;t?t!==Je.eccLib&&(rr("function"==typeof(e=t).isXOnlyPoint),rr(e.isXOnlyPoint(er("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),rr(e.isXOnlyPoint(er("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),rr(e.isXOnlyPoint(er("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),rr(e.isXOnlyPoint(er("0000000000000000000000000000000000000000000000000000000000000001"))),rr(!e.isXOnlyPoint(er("0000000000000000000000000000000000000000000000000000000000000000"))),rr(!e.isXOnlyPoint(er("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),rr("function"==typeof e.xOnlyPointAddTweak),nr.forEach((function(t){var r=e.xOnlyPointAddTweak(er(t.pubkey),er(t.tweak));null===t.result?rr(null===r):(rr(null!==r),rr(r.parity===t.parity),rr($e.from(r.xOnlyPubkey).equals(er(t.result))))})),Je.eccLib=t):Je.eccLib=t}function tr(){if(!Je.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return Je.eccLib}var er=function(t){return $e.from(t,"hex")};function rr(t){if(!t)throw new Error("ecc library invalid")}var nr=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}],ir=g(469),or=g(287).Buffer;function ar(t){return ar="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},ar(t)}function ur(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function sr(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,fr(n.key),n)}}function cr(t,e,r){return e&&sr(t.prototype,e),r&&sr(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function fr(t){var e=function(t){if("object"!=ar(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ar(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ar(e)?e:e+""}var lr=bt;function hr(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 pr(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return hr((n*=4294967296)+r,9007199254740991),n+r}function dr(t,e,r){return hr(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}function yr(t){if(t.length<1)return t;for(var e=t.length-1,r=0,n=0;n<t.length/2;n++)r=t[n],t[n]=t[e],t[e]=r,e--;return t}function gr(t){var e=or.allocUnsafe(t.length);return t.copy(e),e}var br=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;ur(this,t),this.buffer=e,this.offset=r,lr(jt(Lt,Ut),[e,r])}return cr(t,[{key:"writeUInt8",value:function(t){this.offset=this.buffer.writeUInt8(t,this.offset)}},{key:"writeInt32",value:function(t){this.offset=this.buffer.writeInt32LE(t,this.offset)}},{key:"writeUInt32",value:function(t){this.offset=this.buffer.writeUInt32LE(t,this.offset)}},{key:"writeUInt64",value:function(t){this.offset=dr(this.buffer,t,this.offset)}},{key:"writeVarInt",value:function(t){ir.encode(t,this.buffer,this.offset),this.offset+=ir.encode.bytes}},{key:"writeSlice",value:function(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.offset+=t.copy(this.buffer,this.offset)}},{key:"writeVarSlice",value:function(t){this.writeVarInt(t.length),this.writeSlice(t)}},{key:"writeVector",value:function(t){var e=this;this.writeVarInt(t.length),t.forEach((function(t){return e.writeVarSlice(t)}))}},{key:"end",value:function(){if(this.buffer.length===this.offset)return this.buffer;throw new Error("buffer size ".concat(this.buffer.length,", offset ").concat(this.offset))}}],[{key:"withCapacity",value:function(e){return new t(or.alloc(e))}}])}(),vr=cr((function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;ur(this,t),this.buffer=e,this.offset=r,lr(jt(Lt,Ut),[e,r])}),[{key:"readUInt8",value:function(){var t=this.buffer.readUInt8(this.offset);return this.offset++,t}},{key:"readInt32",value:function(){var t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}},{key:"readUInt32",value:function(){var t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}},{key:"readUInt64",value:function(){var t=pr(this.buffer,this.offset);return this.offset+=8,t}},{key:"readVarInt",value:function(){var t=ir.decode(this.buffer,this.offset);return this.offset+=ir.decode.bytes,t}},{key:"readSlice",value:function(t){if(this.buffer.length<this.offset+t)throw new Error("Cannot read slice out of bounds");var e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}},{key:"readVarSlice",value:function(){return this.readSlice(this.readVarInt())}},{key:"readVector",value:function(){for(var t=this.readVarInt(),e=[],r=0;r<t;r++)e.push(this.readVarSlice());return e}}]);function wr(t){return function(t){if(Array.isArray(t))return mr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return mr(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?mr(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function mr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var _r=192,Er=128,Sr=function(t){return"left"in t&&"right"in t};function kr(t,e){if(t.length<33)throw new TypeError("The control-block length is too small. Got ".concat(t.length,", expected min 33."));for(var r=(t.length-33)/32,n=e,i=0;i<r;i++){var o=t.slice(33+32*i,65+32*i);n=n.compare(o)<0?Ir(n,o):Ir(o,n)}return n}function Or(t){if(kt(t))return{hash:xr(t)};var e=[Or(t[0]),Or(t[1])];e.sort((function(t,e){return t.hash.compare(e.hash)}));var r=e[0],n=e[1];return{hash:Ir(r.hash,n.hash),left:r,right:n}}function Tr(t,e){if(Sr(t)){var r=Tr(t.left,e);if(void 0!==r)return[].concat(wr(r),[t.right.hash]);var n=Tr(t.right,e);if(void 0!==n)return[].concat(wr(n),[t.left.hash])}else if(t.hash.equals(e))return[]}function xr(t){var e,r,n,i=t.version||_r;return Ze("TapLeaf",yt.Buffer.concat([yt.Buffer.from([i]),(e=t.output,r=ir.encodingLength(e.length),n=yt.Buffer.allocUnsafe(r),ir.encode(e.length,n),yt.Buffer.concat([n,e]))]))}function Ar(t,e){return Ze("TapTweak",yt.Buffer.concat(e?[t,e]:[t]))}function Pr(t,e){if(!yt.Buffer.isBuffer(t))return null;if(32!==t.length)return null;if(e&&32!==e.length)return null;var r=Ar(t,e),n=tr().xOnlyPointAddTweak(t,r);return n&&null!==n.xOnlyPubkey?{parity:n.parity,x:yt.Buffer.from(n.xOnlyPubkey)}:null}function Ir(t,e){return Ze("TapBranch",yt.Buffer.concat([t,e]))}function Lr(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:function(){var t=r.call(this);return this[e]=t,t},set:function(t){Object.defineProperty(this,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}})}function Br(t){var e;return function(){return void 0!==e?e:e=t()}}var Rr=it;function jr(t,e){if(!t.data&&!t.output)throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),bt({network:bt.maybe(bt.Object),output:bt.maybe(bt.Buffer),data:bt.maybe(bt.arrayOf(bt.Buffer))},t);var r={name:"embed",network:t.network||T};if(Lr(r,"output",(function(){if(t.data)return re([Rr.OP_RETURN].concat(t.data))})),Lr(r,"data",(function(){if(t.output)return ne(t.output).slice(1)})),e.validate&&t.output){var n=ne(t.output);if(n[0]!==Rr.OP_RETURN)throw new TypeError("Output is invalid");if(!n.slice(1).every(bt.Buffer))throw new TypeError("Output is invalid");if(t.data&&!mt(t.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,t)}var Nr=it,Ur=Nr.OP_RESERVED;function Cr(t,e){if(!(t.input||t.output||t.pubkeys&&void 0!==t.m||t.signatures))throw new TypeError("Not enough data");function r(t){return ce(t)||void 0!==(e.allowIncomplete&&t===Nr.OP_0)}e=Object.assign({validate:!0},e||{}),bt({network:bt.maybe(bt.Object),m:bt.maybe(bt.Number),n:bt.maybe(bt.Number),output:bt.maybe(bt.Buffer),pubkeys:bt.maybe(bt.arrayOf(_t)),signatures:bt.maybe(bt.arrayOf(r)),input:bt.maybe(bt.Buffer)},t);var n={network:t.network||T},i=[],o=!1;function a(t){o||(o=!0,i=ne(t),n.m=i[0]-Ur,n.n=i[i.length-2]-Ur,n.pubkeys=i.slice(1,-2))}if(Lr(n,"output",(function(){if(t.m&&n.n&&t.pubkeys)return re([].concat(Ur+t.m,t.pubkeys,Ur+n.n,Nr.OP_CHECKMULTISIG))})),Lr(n,"m",(function(){if(n.output)return a(n.output),n.m})),Lr(n,"n",(function(){if(n.pubkeys)return n.pubkeys.length})),Lr(n,"pubkeys",(function(){if(t.output)return a(t.output),n.pubkeys})),Lr(n,"signatures",(function(){if(t.input)return ne(t.input).slice(1)})),Lr(n,"input",(function(){if(t.signatures)return re([Nr.OP_0].concat(t.signatures))})),Lr(n,"witness",(function(){if(n.input)return[]})),Lr(n,"name",(function(){if(n.m&&n.n)return"p2ms(".concat(n.m," of ").concat(n.n,")")})),e.validate){if(t.output){if(a(t.output),!bt.Number(i[0]))throw new TypeError("Output is invalid");if(!bt.Number(i[i.length-2]))throw new TypeError("Output is invalid");if(i[i.length-1]!==Nr.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every((function(t){return _t(t)})))throw new TypeError("Output is invalid");if(void 0!==t.m&&t.m!==n.m)throw new TypeError("m mismatch");if(void 0!==t.n&&t.n!==n.n)throw new TypeError("n mismatch");if(t.pubkeys&&!mt(t.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(t.pubkeys){if(void 0!==t.n&&t.n!==t.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=t.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(t.signatures){if(t.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(t.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(t.input){if(t.input[0]!==Nr.OP_0)throw new TypeError("Input is invalid");if(0===n.signatures.length||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(t.signatures&&!mt(t.signatures,n.signatures))throw new TypeError("Signature mismatch");if(void 0!==t.m&&t.m!==t.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,t)}var Fr=it;function Mr(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||{}),bt({network:bt.maybe(bt.Object),output:bt.maybe(bt.Buffer),pubkey:bt.maybe(_t),signature:bt.maybe(ce),input:bt.maybe(bt.Buffer)},t);var r=Br((function(){return ne(t.input)})),n={name:"p2pk",network:t.network||T};if(Lr(n,"output",(function(){if(t.pubkey)return re([t.pubkey,Fr.OP_CHECKSIG])})),Lr(n,"pubkey",(function(){if(t.output)return t.output.slice(1,-1)})),Lr(n,"signature",(function(){if(t.input)return r()[0]})),Lr(n,"input",(function(){if(t.signature)return re([t.signature])})),Lr(n,"witness",(function(){if(n.input)return[]})),e.validate){if(t.output){if(t.output[t.output.length-1]!==Fr.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!_t(n.pubkey))throw new TypeError("Output pubkey is invalid");if(t.pubkey&&!t.pubkey.equals(n.pubkey))throw new TypeError("Pubkey mismatch")}if(t.signature&&t.input&&!t.input.equals(n.input))throw new TypeError("Signature mismatch");if(t.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!ce(n.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(n,t)}const Dr=2n**256n,Hr=Dr-0x1000003d1n,Kr=Dr-0x14551231950b75fc4402da1732fc9bebfn,Gr=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Wr=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,Vr={p:Hr,n:Kr,a:0n,b:7n,Gx:Gr,Gy:Wr},qr=t=>en(en(t*t)*t+Vr.b),zr=(t="")=>{throw new Error(t)},Yr=t=>"bigint"==typeof t,Xr=t=>"string"==typeof t,Zr=t=>Yr(t)&&0n<t&&t<Hr,$r=t=>Yr(t)&&0n<t&&t<Kr,Jr=(t,e)=>!(t=>t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name)(t)||"number"==typeof e&&e>0&&t.length!==e?zr("Uint8Array expected"):t,Qr=t=>new Uint8Array(t),tn=(t,e)=>Jr(Xr(t)?cn(t):Qr(Jr(t)),e),en=(t,e=Hr)=>{let r=t%e;return r>=0n?r:e+r},rn=t=>t instanceof nn?t:zr("Point expected");class nn{constructor(t,e,r){this.px=t,this.py=e,this.pz=r}static fromAffine(t){return 0n===t.x&&0n===t.y?nn.ZERO:new nn(t.x,t.y,1n)}static fromHex(t){let e;const r=(t=tn(t))[0],n=t.subarray(1),i=ln(n,0,32),o=t.length;if(33===o&&[2,3].includes(r)){Zr(i)||zr("Point hex invalid: x not FE");let t=gn(qr(i));!(1&~r)!=(1n===(1n&t))&&(t=en(-t)),e=new nn(i,t,1n)}return 65===o&&4===r&&(e=new nn(i,ln(n,32,64),1n)),e?e.ok():zr("Point is not on curve")}static fromPrivateKey(t){return on.mul(bn(t))}get x(){return this.aff().x}get y(){return this.aff().y}equals(t){const{px:e,py:r,pz:n}=this,{px:i,py:o,pz:a}=rn(t),u=en(e*a),s=en(i*n),c=en(r*a),f=en(o*n);return u===s&&c===f}negate(){return new nn(this.px,en(-this.py),this.pz)}double(){return this.add(this)}add(t){const{px:e,py:r,pz:n}=this,{px:i,py:o,pz:a}=rn(t),{a:u,b:s}=Vr;let c=0n,f=0n,l=0n;const h=en(3n*s);let p=en(e*i),d=en(r*o),y=en(n*a),g=en(e+r),b=en(i+o);g=en(g*b),b=en(p+d),g=en(g-b),b=en(e+n);let v=en(i+a);return b=en(b*v),v=en(p+y),b=en(b-v),v=en(r+n),c=en(o+a),v=en(v*c),c=en(d+y),v=en(v-c),l=en(u*b),c=en(h*y),l=en(c+l),c=en(d-l),l=en(d+l),f=en(c*l),d=en(p+p),d=en(d+p),y=en(u*y),b=en(h*b),d=en(d+y),y=en(p-y),y=en(u*y),b=en(b+y),p=en(d*b),f=en(f+p),p=en(v*b),c=en(g*c),c=en(c-p),p=en(g*d),l=en(v*l),l=en(l+p),new nn(c,f,l)}mul(t,e=!0){if(!e&&0n===t)return an;if($r(t)||zr("invalid scalar"),this.equals(on))return En(t).p;let r=an,n=on;for(let i=this;t>0n;i=i.double(),t>>=1n)1n&t?r=r.add(i):e&&(n=n.add(i));return r}mulAddQUns(t,e,r){return this.mul(e,!1).add(t.mul(r,!1)).ok()}toAffine(){const{px:t,py:e,pz:r}=this;if(this.equals(an))return{x:0n,y:0n};if(1n===r)return{x:t,y:e};const n=yn(r);return 1n!==en(r*n)&&zr("invalid inverse"),{x:en(t*n),y:en(e*n)}}assertValidity(){const{x:t,y:e}=this.aff();return Zr(t)&&Zr(e)||zr("Point invalid: x or y"),en(e*e)===qr(t)?this:zr("Point invalid: not on curve")}multiply(t){return this.mul(t)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(t=!0){const{x:e,y:r}=this.aff();return(t?0n===(1n&r)?"02":"03":"04")+pn(e)+(t?"":pn(r))}toRawBytes(t=!0){return cn(this.toHex(t))}}nn.BASE=new nn(Gr,Wr,1n),nn.ZERO=new nn(0n,1n,0n);const{BASE:on,ZERO:an}=nn,un=(t,e)=>t.toString(16).padStart(e,"0"),sn=t=>Array.from(t).map((t=>un(t,2))).join(""),cn=t=>{const e=t.length;(!Xr(t)||e%2)&&zr("hex invalid 1");const r=Qr(e/2);for(let e=0;e<r.length;e++){const n=2*e,i=t.slice(n,n+2),o=Number.parseInt(i,16);(Number.isNaN(o)||o<0)&&zr("hex invalid 2"),r[e]=o}return r},fn=t=>BigInt("0x"+(sn(t)||"0")),ln=(t,e,r)=>fn(t.slice(e,r)),hn=t=>Yr(t)&&t>=0n&&t<Dr?cn(un(t,64)):zr("bigint expected"),pn=t=>sn(hn(t)),dn=(...t)=>{const e=Qr(t.reduce(((t,e)=>t+Jr(e).length),0));let r=0;return t.forEach((t=>{e.set(t,r),r+=t.length})),e},yn=(t,e=Hr)=>{(0n===t||e<=0n)&&zr("no inverse n="+t+" mod="+e);let r=en(t,e),n=e,i=0n,o=1n,a=1n,u=0n;for(;0n!==r;){const t=n/r,e=n%r,s=i-a*t,c=o-u*t;n=r,r=e,i=a,o=u,a=s,u=c}return 1n===n?en(i,e):zr("no inverse")},gn=t=>{let e=1n;for(let r=t,n=(Hr+1n)/4n;n>0n;n>>=1n)1n&n&&(e=e*r%Hr),r=r*r%Hr;return en(e*e)===t?e:zr("sqrt invalid")},bn=t=>(Yr(t)||(t=fn(tn(t,32))),$r(t)?t:zr("private key out of range")),vn=()=>"object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;let wn;const mn={hexToBytes:cn,bytesToHex:sn,concatBytes:dn,bytesToNumberBE:fn,numberToBytesBE:hn,mod:en,invert:yn,hmacSha256Async:async(t,...e)=>{const r=vn(),n=r&&r.subtle;if(!n)return zr("etc.hmacSha256Async not set");const i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return Qr(await n.sign("HMAC",i,dn(...e)))},hmacSha256Sync:wn,hashToPrivateKey:t=>{((t=tn(t)).length<40||t.length>1024)&&zr("expected proper params");const e=en(fn(t),Kr-1n)+1n;return hn(e)},randomBytes:(t=32)=>{const e=vn();return e&&e.getRandomValues||zr("crypto.getRandomValues must be defined"),e.getRandomValues(Qr(t))}};let _n;Object.defineProperties(mn,{hmacSha256Sync:{configurable:!1,get:()=>wn,set(t){wn||(wn=t)}}});const En=t=>{const e=_n||(_n=(()=>{const t=[];let e=on,r=e;for(let n=0;n<33;n++){r=e,t.push(r);for(let n=1;n<128;n++)r=r.add(e),t.push(r);e=r.double()}return t})()),r=(t,e)=>{let r=e.negate();return t?r:e};let n=an,i=on;const o=BigInt(255),a=BigInt(8);for(let u=0;u<33;u++){const s=128*u;let c=Number(t&o);t>>=a,c>128&&(c-=256,t+=1n);const f=s,l=s+Math.abs(c)-1,h=u%2!=0,p=c<0;0===c?i=i.add(r(h,e[f])):n=n.add(r(p,e[l]))}return{p:n,f:i}};var Sn=g(394),kn=g(287).Buffer,On=it;function Tn(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||{}),bt({network:bt.maybe(bt.Object),address:bt.maybe(bt.String),hash:bt.maybe(bt.BufferN(20)),output:bt.maybe(bt.BufferN(23)),redeem:bt.maybe({network:bt.maybe(bt.Object),output:bt.maybe(bt.Buffer),input:bt.maybe(bt.Buffer),witness:bt.maybe(bt.arrayOf(bt.Buffer))}),input:bt.maybe(bt.Buffer),witness:bt.maybe(bt.arrayOf(bt.Buffer))},t);var r=t.network;r||(r=t.redeem&&t.redeem.network||T);var n={network:r},i=Br((function(){var e=kn.from(et.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),o=Br((function(){return ne(t.input)})),a=Br((function(){var e=o(),n=e[e.length-1];return{network:r,output:n===On.OP_FALSE?kn.from([]):n,input:re(e.slice(0,-1)),witness:t.witness||[]}}));if(Lr(n,"address",(function(){if(n.hash){var t=kn.allocUnsafe(21);return t.writeUInt8(n.network.scriptHash,0),n.hash.copy(t,1),et.encode(t)}})),Lr(n,"hash",(function(){return t.output?t.output.slice(2,22):t.address?i().hash:n.redeem&&n.redeem.output?qe(n.redeem.output):void 0})),Lr(n,"output",(function(){if(n.hash)return re([On.OP_HASH160,n.hash,On.OP_EQUAL])})),Lr(n,"redeem",(function(){if(t.input)return a()})),Lr(n,"input",(function(){if(t.redeem&&t.redeem.input&&t.redeem.output)return re([].concat(ne(t.redeem.input),t.redeem.output))})),Lr(n,"witness",(function(){return n.redeem&&n.redeem.witness?n.redeem.witness:n.input?[]:void 0})),Lr(n,"name",(function(){var t=["p2sh"];return void 0!==n.redeem&&void 0!==n.redeem.name&&t.push(n.redeem.name),t.join("-")})),e.validate){var u=kn.from([]);if(t.address){if(i().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==i().hash.length)throw new TypeError("Invalid address");u=i().hash}if(t.hash){if(u.length>0&&!u.equals(t.hash))throw new TypeError("Hash mismatch");u=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==On.OP_HASH160||20!==t.output[1]||t.output[22]!==On.OP_EQUAL)throw new TypeError("Output is invalid");var s=t.output.slice(2,22);if(u.length>0&&!u.equals(s))throw new TypeError("Hash mismatch");u=s}var c=function(t){if(t.output){var e=ne(t.output);if(!e||e.length<1)throw new TypeError("Redeem.output too short");if(t.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(Jt(e)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");var r=qe(t.output);if(u.length>0&&!u.equals(r))throw new TypeError("Hash mismatch");u=r}if(t.input){var n=t.input.length>0,i=t.witness&&t.witness.length>0;if(!n&&!i)throw new TypeError("Empty input");if(n&&i)throw new TypeError("Input and witness provided");if(n&&!$t(ne(t.input)))throw new TypeError("Non push-only scriptSig")}};if(t.input){var f=o();if(!f||f.length<1)throw new TypeError("Input too short");if(!kn.isBuffer(a().output))throw new TypeError("Input is invalid");c(a())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==r)throw new TypeError("Network mismatch");if(t.input){var l=a();if(t.redeem.output&&!t.redeem.output.equals(l.output))throw new TypeError("Redeem.output mismatch");if(t.redeem.input&&!t.redeem.input.equals(l.input))throw new TypeError("Redeem.input mismatch")}c(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!mt(t.redeem.witness,t.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(n,t)}var xn=it,An=1,Pn=80;function In(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||{}),bt({address:bt.maybe(bt.String),input:bt.maybe(bt.BufferN(0)),network:bt.maybe(bt.Object),output:bt.maybe(bt.BufferN(34)),internalPubkey:bt.maybe(bt.BufferN(32)),hash:bt.maybe(bt.BufferN(32)),pubkey:bt.maybe(bt.BufferN(32)),signature:bt.maybe(bt.anyOf(bt.BufferN(64),bt.BufferN(65))),witness:bt.maybe(bt.arrayOf(bt.Buffer)),scriptTree:bt.maybe(Ot),redeem:bt.maybe({output:bt.maybe(bt.Buffer),redeemVersion:bt.maybe(bt.Number),witness:bt.maybe(bt.arrayOf(bt.Buffer))}),redeemVersion:bt.maybe(bt.Number)},t);var r=Br((function(){return me(t.address)})),n=Br((function(){if(t.witness&&t.witness.length)return t.witness.length>=2&&t.witness[t.witness.length-1][0]===Pn?t.witness.slice(0,-1):t.witness.slice()})),i=Br((function(){return t.scriptTree?Or(t.scriptTree):t.hash?{hash:t.hash}:void 0})),o=t.network||T,a={name:"p2tr",network:o};if(Lr(a,"address",(function(){if(a.pubkey){var t=C.p2.toWords(a.pubkey);return t.unshift(An),C.p2.encode(o.bech32,t)}})),Lr(a,"hash",(function(){var t=i();if(t)return t.hash;var e=n();if(e&&e.length>1){var r=e[e.length-1],o=r[0]&St;return kr(r,xr({output:e[e.length-2],version:o}))}return null})),Lr(a,"output",(function(){if(a.pubkey)return re([xn.OP_1,a.pubkey])})),Lr(a,"redeemVersion",(function(){return t.redeemVersion?t.redeemVersion:t.redeem&&void 0!==t.redeem.redeemVersion&&null!==t.redeem.redeemVersion?t.redeem.redeemVersion:_r})),Lr(a,"redeem",(function(){var t=n();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&St}})),Lr(a,"pubkey",(function(){if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(a.internalPubkey){var e=Pr(a.internalPubkey,a.hash);if(e)return e.x}})),Lr(a,"internalPubkey",(function(){if(t.internalPubkey)return t.internalPubkey;var e=n();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),Lr(a,"signature",(function(){if(t.signature)return t.signature;var e=n();return e&&1===e.length?e[0]:void 0})),Lr(a,"witness",(function(){if(t.witness)return t.witness;var e=i();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){var r=Tr(e,xr({output:t.redeem.output,version:a.redeemVersion}));if(!r)return;var n=Pr(t.internalPubkey,e.hash);if(!n)return;var o=yt.Buffer.concat([yt.Buffer.from([a.redeemVersion|n.parity]),t.internalPubkey].concat(r));return[t.redeem.output,o]}return t.signature?[t.signature]:void 0})),e.validate){var u=yt.Buffer.from([]);if(t.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==An)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");u=r().data}if(t.pubkey){if(u.length>0&&!u.equals(t.pubkey))throw new TypeError("Pubkey mismatch");u=t.pubkey}if(t.output){if(34!==t.output.length||t.output[0]!==xn.OP_1||32!==t.output[1])throw new TypeError("Output is invalid");if(u.length>0&&!u.equals(t.output.slice(2)))throw new TypeError("Pubkey mismatch");u=t.output.slice(2)}if(t.internalPubkey){var s=Pr(t.internalPubkey,a.hash);if(u.length>0&&!u.equals(s.x))throw new TypeError("Pubkey mismatch");u=s.x}var c=i();if(t.hash&&c&&!t.hash.equals(c.hash))throw new TypeError("Hash mismatch");if(t.redeem&&t.redeem.output&&c&&!Tr(c,xr({output:t.redeem.output,version:a.redeemVersion})))throw new TypeError("Redeem script not in tree");var f=n();if(t.redeem&&a.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==a.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(t.redeem.output){if(0===ne(t.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(a.redeem.output&&!t.redeem.output.equals(a.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(t.redeem.witness&&a.redeem.witness&&!mt(t.redeem.witness,a.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(f&&f.length)if(1===f.length){if(t.signature&&!t.signature.equals(f[0]))throw new TypeError("Signature mismatch")}else{var l=f[f.length-1];if(l.length<33)throw new TypeError("The control-block length is too small. Got ".concat(l.length,", expected min 33."));if((l.length-33)%32!=0)throw new TypeError("The control-block length of ".concat(l.length," is incorrect!"));var h=(l.length-33)/32;if(h>128)throw new TypeError("The script path is too long. Got ".concat(h,", expected max 128."));var p=l.slice(1,33);if(t.internalPubkey&&!t.internalPubkey.equals(p))throw new TypeError("Internal pubkey mismatch");if(!tr().isXOnlyPoint(p))throw new TypeError("Invalid internalPubkey for p2tr witness");var d=l[0]&St,y=Pr(p,kr(l,xr({output:f[f.length-2],version:d})));if(!y)throw new TypeError("Invalid outputKey for p2tr witness");if(u.length&&!u.equals(y.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(y.parity!==(1&l[0]))throw new Error("Incorrect parity")}}return Object.assign(a,t)}var Ln=g(287).Buffer,Bn=it,Rn=Ln.alloc(0);function jn(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||{}),bt({address:bt.maybe(bt.String),hash:bt.maybe(bt.BufferN(20)),input:bt.maybe(bt.BufferN(0)),network:bt.maybe(bt.Object),output:bt.maybe(bt.BufferN(22)),pubkey:bt.maybe(_t),signature:bt.maybe(ce),witness:bt.maybe(bt.arrayOf(bt.Buffer))},t);var r=Br((function(){var e=C.I.decode(t.address),r=e.words.shift(),n=C.I.fromWords(e.words);return{version:r,prefix:e.prefix,data:Ln.from(n)}})),n=t.network||T,i={name:"p2wpkh",network:n};if(Lr(i,"address",(function(){if(i.hash){var t=C.I.toWords(i.hash);return t.unshift(0),C.I.encode(n.bech32,t)}})),Lr(i,"hash",(function(){return t.output?t.output.slice(2,22):t.address?r().data:t.pubkey||i.pubkey?qe(t.pubkey||i.pubkey):void 0})),Lr(i,"output",(function(){if(i.hash)return re([Bn.OP_0,i.hash])})),Lr(i,"pubkey",(function(){return t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0})),Lr(i,"signature",(function(){if(t.witness)return t.witness[0]})),Lr(i,"input",(function(){if(i.witness)return Rn})),Lr(i,"witness",(function(){if(t.pubkey&&t.signature)return[t.signature,t.pubkey]})),e.validate){var o=Ln.from([]);if(t.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(20!==r().data.length)throw new TypeError("Invalid address data");o=r().data}if(t.hash){if(o.length>0&&!o.equals(t.hash))throw new TypeError("Hash mismatch");o=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==Bn.OP_0||20!==t.output[1])throw new TypeError("Output is invalid");if(o.length>0&&!o.equals(t.output.slice(2)))throw new TypeError("Hash mismatch");o=t.output.slice(2)}if(t.pubkey){var a=qe(t.pubkey);if(o.length>0&&!o.equals(a))throw new TypeError("Hash mismatch");if(o=a,!_t(t.pubkey)||33!==t.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(t.witness){if(2!==t.witness.length)throw new TypeError("Witness is invalid");if(!ce(t.witness[0]))throw new TypeError("Witness has invalid signature");if(!_t(t.witness[1])||33!==t.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError("Pubkey mismatch");var u=qe(t.witness[1]);if(o.length>0&&!o.equals(u))throw new TypeError("Hash mismatch")}}return Object.assign(i,t)}var Nn=g(287).Buffer,Un=it,Cn=Nn.alloc(0);function Fn(t){return!(!Nn.isBuffer(t)||65!==t.length||4!==t[0]||!_t(t))}function Mn(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||{}),bt({network:bt.maybe(bt.Object),address:bt.maybe(bt.String),hash:bt.maybe(bt.BufferN(32)),output:bt.maybe(bt.BufferN(34)),redeem:bt.maybe({input:bt.maybe(bt.Buffer),network:bt.maybe(bt.Object),output:bt.maybe(bt.Buffer),witness:bt.maybe(bt.arrayOf(bt.Buffer))}),input:bt.maybe(bt.BufferN(0)),witness:bt.maybe(bt.arrayOf(bt.Buffer))},t);var r=Br((function(){var e=C.I.decode(t.address),r=e.words.shift(),n=C.I.fromWords(e.words);return{version:r,prefix:e.prefix,data:Nn.from(n)}})),n=Br((function(){return ne(t.redeem.input)})),i=t.network;i||(i=t.redeem&&t.redeem.network||T);var o={network:i};if(Lr(o,"address",(function(){if(o.hash){var t=C.I.toWords(o.hash);return t.unshift(0),C.I.encode(i.bech32,t)}})),Lr(o,"hash",(function(){return t.output?t.output.slice(2):t.address?r().data:o.redeem&&o.redeem.output?Ve(o.redeem.output):void 0})),Lr(o,"output",(function(){if(o.hash)return re([Un.OP_0,o.hash])})),Lr(o,"redeem",(function(){if(t.witness)return{output:t.witness[t.witness.length-1],input:Cn,witness:t.witness.slice(0,-1)}})),Lr(o,"input",(function(){if(o.witness)return Cn})),Lr(o,"witness",(function(){if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){var e=ae(n());return o.redeem=Object.assign({witness:e},t.redeem),o.redeem.input=Cn,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)})),Lr(o,"name",(function(){var t=["p2wsh"];return void 0!==o.redeem&&void 0!==o.redeem.name&&t.push(o.redeem.name),t.join("-")})),e.validate){var a=Nn.from([]);if(t.address){if(r().prefix!==i.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");a=r().data}if(t.hash){if(a.length>0&&!a.equals(t.hash))throw new TypeError("Hash mismatch");a=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==Un.OP_0||32!==t.output[1])throw new TypeError("Output is invalid");var u=t.output.slice(2);if(a.length>0&&!a.equals(u))throw new TypeError("Hash mismatch");a=u}if(t.redeem){if(t.redeem.network&&t.redeem.network!==i)throw new TypeError("Network mismatch");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(t.redeem.output){var s=ne(t.redeem.output);if(!s||s.length<1)throw new TypeError("Redeem.output is invalid");if(t.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(Jt(s)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");var c=Ve(t.redeem.output);if(a.length>0&&!a.equals(c))throw new TypeError("Hash mismatch");a=c}if(t.redeem.input&&!$t(n()))throw new TypeError("Non push-only scriptSig");if(t.witness&&t.redeem.witness&&!mt(t.witness,t.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(t.redeem.input&&n().some(Fn)||t.redeem.output&&(ne(t.redeem.output)||[]).some(Fn))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(t.witness&&t.witness.length>0){var f=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(f))throw new TypeError("Witness and redeem.output mismatch");if(t.witness.some(Fn)||(ne(f)||[]).some(Fn))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,t)}var Dn=g(287).Buffer;function Hn(t){return Hn="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},Hn(t)}function Kn(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,Wn(n.key),n)}}function Gn(t,e,r){return(e=Wn(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Wn(t){var e=function(t){if("object"!=Hn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Hn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Hn(e)?e:e+""}var Vn=bt;function qn(t){var e=t.length;return ir.encodingLength(e)+e}var zn=Dn.allocUnsafe(0),Yn=[],Xn=Dn.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),Zn=Dn.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),$n=Dn.from("ffffffffffffffff","hex"),Jn={script:zn,valueBuffer:$n},Qn=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Gn(this,"version",1),Gn(this,"locktime",0),Gn(this,"ins",[]),Gn(this,"outs",[])}return e=t,r=[{key:"isCoinbase",value:function(){return 1===this.ins.length&&t.isCoinbaseHash(this.ins[0].hash)}},{key:"addInput",value:function(e,r,n,i){return Vn(jt(xt,Ut,Rt(Ut),Rt(Lt)),arguments),Mt(n)&&(n=t.DEFAULT_SEQUENCE),this.ins.push({hash:e,index:r,script:i||zn,sequence:n,witness:Yn})-1}},{key:"addOutput",value:function(t,e){return Vn(jt(Lt,Et),arguments),this.outs.push({script:t,value:e})-1}},{key:"hasWitnesses",value:function(){return this.ins.some((function(t){return 0!==t.witness.length}))}},{key:"weight",value:function(){return 3*this.byteLength(!1)+this.byteLength(!0)}},{key:"virtualSize",value:function(){return Math.ceil(this.weight()/4)}},{key:"byteLength",value:function(){var t=(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&this.hasWitnesses();return(t?10:8)+ir.encodingLength(this.ins.length)+ir.encodingLength(this.outs.length)+this.ins.reduce((function(t,e){return t+40+qn(e.script)}),0)+this.outs.reduce((function(t,e){return t+8+qn(e.script)}),0)+(t?this.ins.reduce((function(t,e){return t+(n=(r=e.witness).length,ir.encodingLength(n)+r.reduce((function(t,e){return t+qn(e)}),0));var r,n}),0):0)}},{key:"clone",value:function(){var e=new t;return e.version=this.version,e.locktime=this.locktime,e.ins=this.ins.map((function(t){return{hash:t.hash,index:t.index,script:t.script,sequence:t.sequence,witness:t.witness}})),e.outs=this.outs.map((function(t){return{script:t.script,value:t.value}})),e}},{key:"hashForSignature",value:function(e,r,n){if(Vn(jt(Ut,Lt,At),arguments),e>=this.ins.length)return Zn;var i=re(ne(r).filter((function(t){return t!==it.OP_CODESEPARATOR}))),o=this.clone();if((31&n)===t.SIGHASH_NONE)o.outs=[],o.ins.forEach((function(t,r){r!==e&&(t.sequence=0)}));else if((31&n)===t.SIGHASH_SINGLE){if(e>=this.outs.length)return Zn;o.outs.length=e+1;for(var a=0;a<e;a++)o.outs[a]=Jn;o.ins.forEach((function(t,r){r!==e&&(t.sequence=0)}))}n&t.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[e]],o.ins[0].script=i):(o.ins.forEach((function(t){t.script=zn})),o.ins[e].script=i);var u=Dn.allocUnsafe(o.byteLength(!1)+4);return u.writeInt32LE(n,u.length-4),o.__toBuffer(u,0,!1),ze(u)}},{key:"hashForWitnessV1",value:function(e,r,n,i,o,a){if(Vn(jt(Ut,Vn.arrayOf(Lt),Vn.arrayOf(Et),Ut),arguments),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");var u=i===t.SIGHASH_DEFAULT?t.SIGHASH_ALL:i&t.SIGHASH_OUTPUT_MASK,s=(i&t.SIGHASH_INPUT_MASK)===t.SIGHASH_ANYONECANPAY,c=u===t.SIGHASH_NONE,f=u===t.SIGHASH_SINGLE,l=zn,h=zn,p=zn,d=zn,y=zn;if(!s){var g=br.withCapacity(36*this.ins.length);this.ins.forEach((function(t){g.writeSlice(t.hash),g.writeUInt32(t.index)})),l=Ve(g.end()),g=br.withCapacity(8*this.ins.length),n.forEach((function(t){return g.writeUInt64(t)})),h=Ve(g.end()),g=br.withCapacity(r.map(qn).reduce((function(t,e){return t+e}))),r.forEach((function(t){return g.writeVarSlice(t)})),p=Ve(g.end()),g=br.withCapacity(4*this.ins.length),this.ins.forEach((function(t){return g.writeUInt32(t.sequence)})),d=Ve(g.end())}if(c||f){if(f&&e<this.outs.length){var b=this.outs[e],v=br.withCapacity(8+qn(b.script));v.writeUInt64(b.value),v.writeVarSlice(b.script),y=Ve(v.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");var w=this.outs.map((function(t){return 8+qn(t.script)})).reduce((function(t,e){return t+e})),m=br.withCapacity(w);this.outs.forEach((function(t){m.writeUInt64(t.value),m.writeVarSlice(t.script)})),y=Ve(m.end())}var _=(o?2:0)+(a?1:0),E=174-(s?49:0)-(c?32:0)+(a?32:0)+(o?37:0),S=br.withCapacity(E);if(S.writeUInt8(i),S.writeInt32(this.version),S.writeUInt32(this.locktime),S.writeSlice(l),S.writeSlice(h),S.writeSlice(p),S.writeSlice(d),c||f||S.writeSlice(y),S.writeUInt8(_),s){var k=this.ins[e];S.writeSlice(k.hash),S.writeUInt32(k.index),S.writeUInt64(n[e]),S.writeVarSlice(r[e]),S.writeUInt32(k.sequence)}else S.writeUInt32(e);if(a){var O=br.withCapacity(qn(a));O.writeVarSlice(a),S.writeSlice(Ve(O.end()))}return f&&S.writeSlice(y),o&&(S.writeSlice(o),S.writeUInt8(0),S.writeUInt32(4294967295)),Ze("TapSighash",Dn.concat([Dn.from([0]),S.end()]))}},{key:"hashForWitnessV0",value:function(e,r,n,i){Vn(jt(Ut,Lt,Et,Ut),arguments);var o,a=Dn.from([]),u=Xn,s=Xn,c=Xn;if(i&t.SIGHASH_ANYONECANPAY||(a=Dn.allocUnsafe(36*this.ins.length),o=new br(a,0),this.ins.forEach((function(t){o.writeSlice(t.hash),o.writeUInt32(t.index)})),s=ze(a)),i&t.SIGHASH_ANYONECANPAY||(31&i)===t.SIGHASH_SINGLE||(31&i)===t.SIGHASH_NONE||(a=Dn.allocUnsafe(4*this.ins.length),o=new br(a,0),this.ins.forEach((function(t){o.writeUInt32(t.sequence)})),c=ze(a)),(31&i)!==t.SIGHASH_SINGLE&&(31&i)!==t.SIGHASH_NONE){var f=this.outs.reduce((function(t,e){return t+8+qn(e.script)}),0);a=Dn.allocUnsafe(f),o=new br(a,0),this.outs.forEach((function(t){o.writeUInt64(t.value),o.writeVarSlice(t.script)})),u=ze(a)}else if((31&i)===t.SIGHASH_SINGLE&&e<this.outs.length){var l=this.outs[e];a=Dn.allocUnsafe(8+qn(l.script)),(o=new br(a,0)).writeUInt64(l.value),o.writeVarSlice(l.script),u=ze(a)}a=Dn.allocUnsafe(156+qn(r)),o=new br(a,0);var h=this.ins[e];return o.writeInt32(this.version),o.writeSlice(s),o.writeSlice(c),o.writeSlice(h.hash),o.writeUInt32(h.index),o.writeVarSlice(r),o.writeUInt64(n),o.writeUInt32(h.sequence),o.writeSlice(u),o.writeUInt32(this.locktime),o.writeUInt32(i),ze(a)}},{key:"getHash",value:function(t){return t&&this.isCoinbase()?Dn.alloc(32,0):ze(this.__toBuffer(void 0,void 0,t))}},{key:"getId",value:function(){return yr(this.getHash(!1)).toString("hex")}},{key:"toBuffer",value:function(t,e){return this.__toBuffer(t,e,!0)}},{key:"toHex",value:function(){return this.toBuffer(void 0,void 0).toString("hex")}},{key:"setInputScript",value:function(t,e){Vn(jt(At,Lt),arguments),this.ins[t].script=e}},{key:"setWitness",value:function(t,e){Vn(jt(At,[Lt]),arguments),this.ins[t].witness=e}},{key:"__toBuffer",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e||(e=Dn.allocUnsafe(this.byteLength(n)));var i=new br(e,r||0);i.writeInt32(this.version);var o=n&&this.hasWitnesses();return o&&(i.writeUInt8(t.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(t.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach((function(t){i.writeSlice(t.hash),i.writeUInt32(t.index),i.writeVarSlice(t.script),i.writeUInt32(t.sequence)})),i.writeVarInt(this.outs.length),this.outs.forEach((function(t){void 0!==t.value?i.writeUInt64(t.value):i.writeSlice(t.valueBuffer),i.writeVarSlice(t.script)})),o&&this.ins.forEach((function(t){i.writeVector(t.witness)})),i.writeUInt32(this.locktime),void 0!==r?e.slice(r,i.offset):e}}],n=[{key:"fromBuffer",value:function(e,r){var n=new vr(e),i=new t;i.version=n.readInt32();var o=n.readUInt8(),a=n.readUInt8(),u=!1;o===t.ADVANCED_TRANSACTION_MARKER&&a===t.ADVANCED_TRANSACTION_FLAG?u=!0:n.offset-=2;for(var s=n.readVarInt(),c=0;c<s;++c){var f=n.readSlice(32),l=n.readUInt32(),h=n.readVarSlice(),p=n.readUInt32();i.ins.push({hash:f,index:l,script:h,sequence:p,witness:Yn})}for(var d=n.readVarInt(),y=0;y<d;++y)i.outs.push({value:n.readUInt64(),script:n.readVarSlice()});if(u){for(var g=0;g<s;++g)i.ins[g].witness=n.readVector();if(!i.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(i.locktime=n.readUInt32(),r)return i;if(n.offset!==e.length)throw new Error("Transaction has unexpected data");return i}},{key:"fromHex",value:function(e){return t.fromBuffer(Dn.from(e,"hex"),!1)}},{key:"isCoinbaseHash",value:function(t){Vn(xt,t);for(var e=0;e<32;++e)if(0!==t[e])return!1;return!0}}],r&&Kn(e.prototype,r),n&&Kn(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}();Gn(Qn,"DEFAULT_SEQUENCE",4294967295),Gn(Qn,"SIGHASH_DEFAULT",0),Gn(Qn,"SIGHASH_ALL",1),Gn(Qn,"SIGHASH_NONE",2),Gn(Qn,"SIGHASH_SINGLE",3),Gn(Qn,"SIGHASH_ANYONECANPAY",128),Gn(Qn,"SIGHASH_OUTPUT_MASK",3),Gn(Qn,"SIGHASH_INPUT_MASK",128),Gn(Qn,"ADVANCED_TRANSACTION_MARKER",0),Gn(Qn,"ADVANCED_TRANSACTION_FLAG",1);var ti=g(287).Buffer;function ei(t,e){if(t){if("string"==typeof t)return ri(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ri(t,e):void 0}}function ri(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var ni=function(t){var e=32===t.length?t:t.slice(1,33);return ti.isBuffer(e)?e:ti.from(e)};function ii(t,e,r){var n=function(t,e,r){if(!t.tapScriptSig||!t.tapScriptSig.length)throw new Error("Can not finalize taproot input #".concat(e,". No tapleaf script signature provided."));var n=(t.tapLeafScript||[]).sort((function(t,e){return t.controlBlock.length-e.controlBlock.length})).find((function(e){return function(t,e,r){var n=xr({output:t.script,version:t.leafVersion});return(!r||r.equals(n))&&void 0!==e.find((function(t){return t.leafHash.equals(n)}))}(e,t.tapScriptSig,r)}));if(!n)throw new Error("Can not finalize taproot input #".concat(e,". Signature for tapleaf script not found."));return n}(e,t,r);try{var i=function(t,e){var r=xr({output:e.script,version:e.leafVersion});return(t.tapScriptSig||[]).filter((function(t){return t.leafHash.equals(r)})).map((function(t){return function(t,e){return Object.assign({positionInScript:Ri(e.pubkey,t)},e)}(e.script,t)})).sort((function(t,e){return e.positionInScript-t.positionInScript})).map((function(t){return t.signature}))}(e,n);return{finalScriptWitness:Pi(i.concat(n.script).concat(n.controlBlock))}}catch(e){throw new Error("Can not finalize taproot input #".concat(t,": ").concat(e))}}function oi(t,e){var r=e?ti.from([e]):ti.from([]);return ti.concat([t,r])}function ai(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&Ai(t.witnessUtxo.script))}function ui(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&Ai(e))}function si(t,e,r){!function(t,e,r){var n=ai(t)&&wi(e),i=wi(t)&&ai(e),o=t===e&&ai(e)&&wi(e);if(n||i||o)throw new Error("Invalid arguments for Psbt.".concat(r,". ")+"Cannot use both taproot and non-taproot fields.")}(t,e,r),function(t,e,r){if(e.tapMerkleRoot){var n=(e.tapLeafScript||[]).every((function(t){return vi(t,e.tapMerkleRoot)})),i=(t.tapLeafScript||[]).every((function(t){return vi(t,e.tapMerkleRoot)}));if(!n||!i)throw new Error("Invalid arguments for Psbt.".concat(r,". Tapleaf not part of taptree."))}else if(t.tapMerkleRoot&&!(e.tapLeafScript||[]).every((function(e){return vi(e,t.tapMerkleRoot)})))throw new Error("Invalid arguments for Psbt.".concat(r,". Tapleaf not part of taptree."))}(t,e,r)}function ci(t,e,r){!function(t,e,r){var n=ui(t)&&wi(e),i=wi(t)&&ui(e),o=t===e&&ui(e)&&wi(e);if(n||i||o)throw new Error("Invalid arguments for Psbt.".concat(r,". ")+"Cannot use both taproot and non-taproot fields.")}(t,e,r),function(t,e){if(e.tapTree||e.tapInternalKey){var r=e.tapInternalKey||t.tapInternalKey,n=e.tapTree||t.tapTree;if(r){var i=t.script,o=function(t,e){return In({internalPubkey:t,scriptTree:e&&hi(e.leaves)}).output}(r,n);if(i&&!i.equals(o))throw new Error("Error adding output. Script or address missmatch.")}}}(t,e)}function fi(t,e){var r=e.tapInternalKey,n=r&&Pr(r,e.tapMerkleRoot);if(!n)throw new Error("Cannot tweak tap internal key for input #".concat(t,". Public key: ").concat(r&&r.toString("hex")));return n.x}function li(t){if(!Ot(t))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return gi(t)}function hi(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return 1===t.length&&0===t[0].depth?{output:t[0].script,version:t[0].leafVersion}:function(t){var e,r,n=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=ei(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(n.s();!(r=n.n()).done;)if(!(e=bi(r.value,e)))throw new Error("No room left to insert tapleaf in tree")}catch(t){n.e(t)}finally{n.f()}return e}(t)}function pi(t,e){var r=function(t){var e,r=[];if(t.tapKeySig&&r.push(t.tapKeySig),t.tapScriptSig&&r.push.apply(r,function(t){if(Array.isArray(t))return ri(t)}(e=t.tapScriptSig.map((function(t){return t.signature})))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||ei(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),!r.length){var n=yi(t.finalScriptWitness);n&&r.push(n)}return r}(t);return r.some((function(t){return Ui(t,di,e)}))}function di(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||Qn.SIGHASH_DEFAULT}}function yi(t){if(t){var e=t.slice(2);return 64===e.length||65===e.length?e:void 0}}function gi(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(r>Er)throw new Error("Max taptree depth exceeded.");return t?kt(t)?(e.push({depth:r,leafVersion:t.version||_r,script:t.output}),e):(t[0]&&gi(t[0],e,r+1),t[1]&&gi(t[1],e,r+1),e):[]}function bi(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(r>Er)throw new Error("Max taptree depth exceeded.");if(t.depth===r)return e?void 0:{output:t.script,version:t.leafVersion};if(!kt(e)){var n=bi(t,e&&e[0],r+1);if(n)return[n,e&&e[1]];var i=bi(t,e&&e[1],r+1);return i?[e&&e[0],i]:void 0}}function vi(t,e){if(!e)return!0;var r=xr({output:t.script,version:t.leafVersion});return kr(t.controlBlock,r).equals(e)}function wi(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}var mi=g(287).Buffer;function _i(t){return function(e){try{return t({output:e}),!0}catch(t){return!1}}}var Ei=_i(Cr),Si=_i(Mr),ki=_i(Di),Oi=_i(jn),Ti=_i(Mn),xi=_i(Tn),Ai=_i(In);function Pi(t){var e,r=mi.allocUnsafe(0);function n(t){var e=r.length,n=Sn.encodingLength(t);r=mi.concat([r,mi.allocUnsafe(n)]),Sn.encode(t,r,e)}return n((e=t).length),e.forEach((function(t){n(t.length),function(t){r=mi.concat([r,mi.from(t)])}(t)})),r}function Ii(t){if(![33,65].includes(t.length))throw new Error("Unsupported key length=".concat(t.length,". Must be 33 (compressed) or 65 (uncompressed)."));var e;try{e=nn.fromHex(t)}catch(t){throw new Error("Invalid secp256k1 public key bytes. Cannot parse.")}var r=Li(e.x),n=Li(e.y),i=e.y%2n===0n?6:7,o=mi.alloc(65);return o[0]=i,r.copy(o,1),n.copy(o,33),{hybrid:o,uncompressed:mi.concat([mi.from([4]),r,n])}}function Li(t){var e=t.toString(16);return(e=e.padStart(64,"0")).length>64&&(e=e.slice(-64)),mi.from(e,"hex")}function Bi(t,e){if(t.equals(e))return!0;if(65===t.length&&65===e.length){var r=mi.from(t),n=mi.from(e);return 6!==r[0]&&7!==r[0]||(r[0]=4),6!==n[0]&&7!==n[0]||(n[0]=4),r.equals(n)}return!1}function Ri(t,e){var r=ne(e);if(null===r)throw new Error("Unknown script error");var n=qe(t),i=ni(t),o=Ii(t),a=qe(o.hybrid),u=qe(o.uncompressed);return r.findIndex((function(e){return"number"!=typeof e&&(!!Bi(e,t)||!!Bi(e,i)||!!e.equals(n)||!!Bi(e,o.uncompressed)||!!Bi(e,o.hybrid)||!(!e.equals(a)&&!e.equals(u))||void 0)}))}function ji(t,e){return-1!==Ri(t,e)}function Ni(t,e){var r=function(t){var e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=Ci(t)}else e=t.partialSig;return e.map((function(t){return t.signature}))}(t);return r.some((function(t){return Ui(t,le.decode,e)}))}function Ui(t,e,r){var n=e(t).hashType,i=[];switch(n&Qn.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case Qn.SIGHASH_ALL:break;case Qn.SIGHASH_SINGLE:case Qn.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}function Ci(t){var e=t.finalScriptSig&&ne(t.finalScriptSig)||[],r=t.finalScriptWitness&&ne(t.finalScriptWitness)||[];return e.concat(r).filter((function(t){return mi.isBuffer(t)&&ce(t)})).map((function(t){return{signature:t}}))}var Fi=g(287).Buffer,Mi=it;function Di(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||{}),bt({network:bt.maybe(bt.Object),address:bt.maybe(bt.String),hash:bt.maybe(bt.BufferN(20)),output:bt.maybe(bt.BufferN(25)),pubkey:bt.maybe(_t),signature:bt.maybe(ce),input:bt.maybe(bt.Buffer)},t);var r=Br((function(){var e=Fi.from(et.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),n=Br((function(){return ne(t.input)})),i=t.network||T,o={name:"p2pkh",network:i};if(Lr(o,"address",(function(){if(o.hash){var t=Fi.allocUnsafe(21);return t.writeUInt8(i.pubKeyHash,0),o.hash.copy(t,1),et.encode(t)}})),Lr(o,"hash",(function(){return t.output?t.output.slice(3,23):t.address?r().hash:t.pubkey||o.pubkey?qe(t.pubkey||o.pubkey):void 0})),Lr(o,"output",(function(){if(o.hash)return re([Mi.OP_DUP,Mi.OP_HASH160,o.hash,Mi.OP_EQUALVERIFY,Mi.OP_CHECKSIG])})),Lr(o,"pubkey",(function(){if(t.input)return n()[1]})),Lr(o,"signature",(function(){if(t.input)return n()[0]})),Lr(o,"input",(function(){if(t.pubkey&&t.signature){var e=t.pubkey;if(t.useHybrid||t.useUncompressed){var r=Ii(t.pubkey);e=t.useUncompressed?r.uncompressed:r.hybrid}return re([t.signature,e])}})),Lr(o,"witness",(function(){if(o.input)return[]})),e.validate){var a=Fi.from([]);if(t.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==r().hash.length)throw new TypeError("Invalid address");a=r().hash}if(t.hash){if(a.length>0&&!a.equals(t.hash))throw new TypeError("Hash mismatch");a=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==Mi.OP_DUP||t.output[1]!==Mi.OP_HASH160||20!==t.output[2]||t.output[23]!==Mi.OP_EQUALVERIFY||t.output[24]!==Mi.OP_CHECKSIG)throw new TypeError("Output is invalid");var u=t.output.slice(3,23);if(a.length>0&&!a.equals(u))throw new TypeError("Hash mismatch");a=u}if(t.pubkey){var s=qe(t.pubkey),c=a.length>0&&!a.equals(s);if(c&&(33===t.pubkey.length&&(2===t.pubkey[0]||3===t.pubkey[0])||65===t.pubkey.length&&4===t.pubkey[0])){var f=Ii(t.pubkey),l=qe(f.uncompressed);if(a.equals(l))c=!1,t.useUncompressed=!0;else{var h=qe(f.hybrid);(c=!a.equals(h))||(t.useHybrid=!0)}}if(c)throw new TypeError("Hash mismatch");a=s}if(t.input){var p=n();if(2!==p.length)throw new TypeError("Input is invalid");if(!ce(p[0]))throw new TypeError("Input has invalid signature");if(!_t(p[1]))throw new TypeError("Input has invalid pubkey");if(t.signature&&!t.signature.equals(p[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(p[1]))throw new TypeError("Pubkey mismatch");var d=qe(p[1]);if(a.length>0&&!a.equals(d))throw new TypeError("Hash mismatch (input)")}}return Object.assign(o,t)}var Hi=g(287).Buffer,Ki=g(287).Buffer;function Gi(t){return Gi="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},Gi(t)}function Wi(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,qi(n.key),n)}}function Vi(t,e,r){return(e=qi(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qi(t){var e=function(t){if("object"!=Gi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Gi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Gi(e)?e:e+""}var zi=bt,Yi=new TypeError("Cannot compute merkle root for zero transactions"),Xi=new TypeError("Cannot compute witness commit for non-segwit block"),Zi=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Vi(this,"version",1),Vi(this,"prevHash",void 0),Vi(this,"merkleRoot",void 0),Vi(this,"timestamp",0),Vi(this,"witnessCommit",void 0),Vi(this,"bits",0),Vi(this,"nonce",0),Vi(this,"transactions",void 0)}return e=t,r=[{key:"getWitnessCommit",value:function(){if(!$i(this.transactions))return null;var t=this.transactions[0].outs.filter((function(t){return t.script.slice(0,6).equals(Ki.from("6a24aa21a9ed","hex"))})).map((function(t){return t.script.slice(6,38)}));if(0===t.length)return null;var e=t[t.length-1];return e instanceof Ki&&32===e.length?e:null}},{key:"hasWitnessCommit",value:function(){return this.witnessCommit instanceof Ki&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}},{key:"hasWitness",value:function(){return(t=this.transactions)instanceof Array&&t.some((function(t){return"object"===Gi(t)&&t.ins instanceof Array&&t.ins.some((function(t){return"object"===Gi(t)&&t.witness instanceof Array&&t.witness.length>0}))}));var t}},{key:"weight",value:function(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}},{key:"byteLength",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t||!this.transactions?80:80+ir.encodingLength(this.transactions.length)+this.transactions.reduce((function(t,r){return t+r.byteLength(e)}),0)}},{key:"getHash",value:function(){return ze(this.toBuffer(!0))}},{key:"getId",value:function(){return yr(this.getHash()).toString("hex")}},{key:"getUTCDate",value:function(){var t=new Date(0);return t.setUTCSeconds(this.timestamp),t}},{key:"toBuffer",value:function(t){var e=Ki.allocUnsafe(this.byteLength(t)),r=new br(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||(ir.encode(this.transactions.length,e,r.offset),r.offset+=ir.encode.bytes,this.transactions.forEach((function(t){var n=t.byteLength();t.toBuffer(e,r.offset),r.offset+=n}))),e}},{key:"toHex",value:function(t){return this.toBuffer(t).toString("hex")}},{key:"checkTxRoots",value:function(){var t=this.hasWitnessCommit();return!(!t&&this.hasWitness())&&this.__checkMerkleRoot()&&(!t||this.__checkWitnessCommit())}},{key:"checkProofOfWork",value:function(){var e=yr(this.getHash()),r=t.calculateTarget(this.bits);return e.compare(r)<=0}},{key:"__checkMerkleRoot",value:function(){if(!this.transactions)throw Yi;var e=t.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)}},{key:"__checkWitnessCommit",value:function(){if(!this.transactions)throw Yi;if(!this.hasWitnessCommit())throw Xi;var e=t.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(e)}}],n=[{key:"fromBuffer",value:function(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");var r=new vr(e),n=new t;if(n.version=r.readInt32(),n.prevHash=r.readSlice(32),n.merkleRoot=r.readSlice(32),n.timestamp=r.readUInt32(),n.bits=r.readUInt32(),n.nonce=r.readUInt32(),80===e.length)return n;var i=function(){var t=Qn.fromBuffer(r.buffer.slice(r.offset),!0);return r.offset+=t.byteLength(),t},o=r.readVarInt();n.transactions=[];for(var a=0;a<o;++a){var u=i();n.transactions.push(u)}var s=n.getWitnessCommit();return s&&(n.witnessCommit=s),n}},{key:"fromHex",value:function(e){return t.fromBuffer(Ki.from(e,"hex"))}},{key:"calculateTarget",value:function(t){var e=((4278190080&t)>>24)-3,r=8388607&t,n=Ki.alloc(32,0);return n.writeUIntBE(r,29-e,3),n}},{key:"calculateMerkleRoot",value:function(t,e){if(zi([{getHash:Ct}],t),0===t.length)throw Yi;if(e&&!$i(t))throw Xi;var r=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o<r;o+=2,++i){var a=n[o],u=o+1===r?a:n[o+1],s=Hi.concat([a,u]);n[i]=e(s)}r=i}return n[0]}(t.map((function(t){return t.getHash(e)})),ze);return e?ze(Ki.concat([r,t[0].ins[0].witness[0]])):r}}],r&&Wi(e.prototype,r),n&&Wi(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}();function $i(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}var Ji=g(614),Qi=g(699);function to(t){return to="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},to(t)}function eo(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ro(t){var e=function(t){if("object"!=to(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=to(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==to(e)?e:e+""}var no=function(){return t=function t(){var e,r,n,i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,r="cacheByLength",n=new Map,(r=ro(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,this.registry=new FinalizationRegistry((function(t){var e=i.cacheByLength.get(t.length);e&&(e.delete(t),0===e.size&&i.cacheByLength.delete(t.length))}))},e=[{key:"addSignature",value:function(t,e){var r=t.length,n={length:r,dataRef:new WeakRef(t),signature:e};return this.cacheByLength.has(r)||this.cacheByLength.set(r,new Set),this.cacheByLength.get(r).add(n),this.registry.register(t,n),e}},{key:"getSignature",value:function(t){var e=t.length,r=this.cacheByLength.get(e);if(r){var n,i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return eo(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?eo(t,e):void 0}}(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(r);try{for(i.s();!(n=i.n()).done;){var o=n.value,a=o.dataRef.deref();if(a&&a.equals(t))return o.signature}}catch(t){i.e(t)}finally{i.f()}}}},{key:"clearCache",value:function(){this.cacheByLength.clear()}}],e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ro(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function io(t){return io="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},io(t)}function oo(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ao(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,uo(n.key),n)}}function uo(t){var e=function(t){if("object"!=io(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=io(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==io(e)?e:e+""}var so=function(){function t(){var e,r,n,i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,r="cacheBySigner",n=new Map,(r=uo(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,this.registry=new FinalizationRegistry((function(t){var e=i.cacheBySigner.get(t.pubKey);e&&(e.delete(t),0===e.size&&i.cacheBySigner.delete(t.pubKey))}))}return e=t,r=[{key:"addSignature",value:function(t,e,r){var n={pubKey:t,dataRef:new WeakRef(e),signature:r};return this.cacheBySigner.has(t)||this.cacheBySigner.set(t,new Set),this.cacheBySigner.get(t).add(n),this.registry.register(e,n),r}},{key:"getSignature",value:function(t,e){var r=this.cacheBySigner.get(t);if(r){var n,i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return oo(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?oo(t,e):void 0}}(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(r);try{for(i.s();!(n=i.n()).done;){var o=n.value,a=o.dataRef.deref();if(a&&a.equals(e))return o.signature}}catch(t){i.e(t)}finally{i.f()}}}},{key:"clearCache",value:function(){this.cacheBySigner.clear()}},{key:"clearCacheForSigner",value:function(t){this.cacheBySigner.delete(t)}}],n=[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}}],r&&ao(e.prototype,r),n&&ao(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}(),co=g(287).Buffer,fo=so.getInstance();function lo(t){if(t.publicKey&&co.isBuffer(t.publicKey))return t.publicKey.toString("hex")}function ho(t){var e=t;e.hasHook||(e.hasHook=!0,e.signatureManager=new no,function(t){var e=t.sign;e&&(t.sign=new Proxy(e,{apply:function(e,r,n){var i=lo(t),o=n[0];if(i){var a=fo.getSignature(i,o);return a||(a=fo.addSignature(i,o,Reflect.apply(e,r,n))),a}var u=t.signatureManager.getSignature(o);return u||(u=t.signatureManager.addSignature(o,Reflect.apply(e,r,n))),u}}));var r=t.signSchnorr;r&&(t.signSchnorr=new Proxy(r,{apply:function(e,r,n){var i=lo(t),o=n[0];if(i){var a=fo.getSignature(i,o);return a||(a=fo.addSignature(i,o,Reflect.apply(e,r,n))),a}var u=t.signatureManager.getSignature(o);return u||(u=t.signatureManager.addSignature(o,Reflect.apply(e,r,n))),u}}))}(e))}var po=g(287).Buffer;function yo(t){return yo="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},yo(t)}function go(){go=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==yo(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(yo(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function bo(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function vo(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){bo(o,n,i,a,u,"next",t)}function u(t){bo(o,n,i,a,u,"throw",t)}a(void 0)}))}}function wo(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=_o(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}function mo(t){return function(t){if(Array.isArray(t))return Eo(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_o(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _o(t,e){if(t){if("string"==typeof t)return Eo(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Eo(t,e):void 0}}function Eo(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function So(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ko(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,To(n.key),n)}}function Oo(t,e,r){return e&&ko(t.prototype,e),r&&ko(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function To(t){var e=function(t){if("object"!=yo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=yo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yo(e)?e:e+""}var xo={network:T,maximumFeeRate:5e3},Ao=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Ji.i(new Io);So(this,t),this.data=r,this.opts=Object.assign({},xo,e),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);var n=function(t,e,r,n){Object.defineProperty(t,e,{enumerable:r,writable:n})};n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}return Oo(t,[{key:"inputCount",get:function(){return this.data.inputs.length}},{key:"version",get:function(){return this.__CACHE.__TX.version},set:function(t){this.setVersion(t)}},{key:"locktime",get:function(){return this.__CACHE.__TX.locktime},set:function(t){this.setLocktime(t)}},{key:"txInputs",get:function(){return this.__CACHE.__TX.ins.map((function(t){return{hash:gr(t.hash),index:t.index,sequence:t.sequence}}))}},{key:"txOutputs",get:function(){var t=this;return this.__CACHE.__TX.outs.map((function(e){var r;try{r=Se(e.script,t.opts.network)}catch(t){}return{script:gr(e.script),value:e.value,address:r}}))}},{key:"combine",value:function(){for(var t,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return(t=this.data).combine.apply(t,mo(r.map((function(t){return t.data})))),this}},{key:"clone",value:function(){return t.fromBuffer(this.data.toBuffer(),JSON.parse(JSON.stringify(this.opts)))}},{key:"setMaximumFeeRate",value:function(t){No(t),this.opts.maximumFeeRate=t}},{key:"setVersion",value:function(t){No(t),Uo(this.data.inputs,"setVersion");var e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}},{key:"setLocktime",value:function(t){No(t),Uo(this.data.inputs,"setLocktime");var e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}},{key:"setInputSequence",value:function(t,e){No(e),Uo(this.data.inputs,"setInputSequence");var r=this.__CACHE;if(r.__TX.ins.length<=t)throw new Error("Input index too high");return r.__TX.ins[t].sequence=e,r.__EXTRACTED_TX=void 0,this}},{key:"addInputs",value:function(t){var e=this,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.forEach((function(t){return e.addInput(t,r)})),this}},{key:"addInput",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!t||void 0===t.hash||void 0===t.index)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");si(t,t,"addInput"),e&&Uo(this.data.inputs,"addInput"),t.witnessScript&&aa(t.witnessScript);var r=this.__CACHE;this.data.addInput(t),Fo(r,r.__TX.ins[r.__TX.ins.length-1]);var n=this.data.inputs.length-1,i=this.data.inputs[n];return i.nonWitnessUtxo&&Qo(this.__CACHE,i,n),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}},{key:"addOutputs",value:function(t){var e=this;return t.forEach((function(t){return e.addOutput(t)})),this}},{key:"addOutput",value:function(t){if(arguments.length>1||!t||void 0===t.value||void 0===t.address&&void 0===t.script)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");Uo(this.data.inputs,"addOutput");var e=t.address;if("string"==typeof e){var r=ke(e,this.opts.network);t=Object.assign({},t,{script:r})}ci(t,t,"addOutput");var n=this.__CACHE;return this.data.addOutput(t),n.__FEE=void 0,n.__FEE_RATE=void 0,n.__EXTRACTED_TX=void 0,this}},{key:"extractTransaction",value:function(t,e){if(e&&(this.data.inputs=this.data.inputs.filter((function(t){return!t.partialSig}))),!this.data.inputs.every(Ro))throw new Error("Not finalized");var r=this.__CACHE;if(t||function(t,e,r){var n=e.__FEE_RATE||t.getFeeRate(),i=e.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error("Warning: You are paying around ".concat((o/1e8).toFixed(8)," in ")+"fees, which is ".concat(n," satoshi per byte for a transaction ")+"with a VSize of ".concat(i," bytes (segwit counted as 0.25 byte per ")+"byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.")}(this,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;var n=r.__TX.clone();return ta(this.data.inputs,n,r,!0,e),n}},{key:"getFeeRate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Ko("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE,t)}},{key:"getFee",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Ko("__FEE","fee",this.data.inputs,this.__CACHE,t)}},{key:"finalizeAllInputs",value:function(){var t=this;return(0,Qi.checkForInput)(this.data.inputs,0),sa(this.data.inputs.length).forEach((function(e){return t.finalizeInput(e)})),this}},{key:"finalizeInput",value:function(t,e,r){var n=(0,Qi.checkForInput)(this.data.inputs,t);return ai(n)?this._finalizeTaprootInput(t,n,void 0,e):this._finalizeInput(t,n,e,null==r||r)}},{key:"finalizeTaprootInput",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ii,n=(0,Qi.checkForInput)(this.data.inputs,t);if(ai(n))return this._finalizeTaprootInput(t,n,e,r);throw new Error("Cannot finalize input #".concat(t,". Not Taproot."))}},{key:"getInputType",value:function(t){var e=(0,Qi.checkForInput)(this.data.inputs,t),r=oa(ra(t,e,this.__CACHE),t,"input",e.redeemScript||function(t){if(t){var e=ne(t);if(e){var r=e[e.length-1];if(po.isBuffer(r)&&!ia(r)&&!ce(r)&&ne(r))return r}}}(e.finalScriptSig),e.witnessScript||function(t){if(t){var e=Jo(t),r=e[e.length-1];if(!ia(r)&&ne(r))return r}}(e.finalScriptWitness));return("raw"===r.type?"":r.type+"-")+ua(r.meaningfulScript)}},{key:"inputHasPubkey",value:function(t,e){return function(t,e,r,n){return ji(t,oa(ra(r,e,n),r,"input",e.redeemScript,e.witnessScript).meaningfulScript)}(e,(0,Qi.checkForInput)(this.data.inputs,t),t,this.__CACHE)}},{key:"inputHasHDKey",value:function(t,e){var r=(0,Qi.checkForInput)(this.data.inputs,t),n=jo(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}},{key:"outputHasPubkey",value:function(t,e){return function(t,e,r,n){return ji(t,oa(n.__TX.outs[r].script,r,"output",e.redeemScript,e.witnessScript).meaningfulScript)}(e,(0,Qi.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}},{key:"outputHasHDKey",value:function(t,e){var r=(0,Qi.checkForOutput)(this.data.outputs,t),n=jo(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}},{key:"validateSignaturesOfAllInputs",value:function(t){var e=this;return(0,Qi.checkForInput)(this.data.inputs,0),sa(this.data.inputs.length).map((function(r){return e.validateSignaturesOfInput(r,t)})).reduce((function(t,e){return!0===e&&t}),!0)}},{key:"validateSignaturesOfInput",value:function(t,e,r){return ai(this.data.inputs[t])?this.validateSignaturesOfTaprootInput(t,e,r):this._validateSignaturesOfInput(t,e,r)}},{key:"signAllInputsHD",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[Qn.SIGHASH_ALL];if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");var r,n=[],i=wo(sa(this.data.inputs.length));try{for(i.s();!(r=i.n()).done;){var o=r.value;try{this.signInputHD(o,t,e),n.push(!0)}catch(t){n.push(!1)}}}catch(t){i.e(t)}finally{i.f()}if(n.every((function(t){return!1===t})))throw new Error("No inputs were signed");return this}},{key:"signAllInputsHDAsync",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[Qn.SIGHASH_ALL];return new Promise((function(n,i){if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));var o,a=[],u=[],s=wo(sa(e.data.inputs.length));try{for(s.s();!(o=s.n()).done;){var c=o.value;u.push(e.signInputHDAsync(c,t,r).then((function(){a.push(!0)}),(function(){a.push(!1)})))}}catch(t){s.e(t)}finally{s.f()}return Promise.all(u).then((function(){if(a.every((function(t){return!1===t})))return i(new Error("No inputs were signed"));n()}))}))}},{key:"signInputHD",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[Qn.SIGHASH_ALL];if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");return $o(t,this.data.inputs,e).forEach((function(e){return r.signInput(t,e,n)})),this}},{key:"signInputHDAsync",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[Qn.SIGHASH_ALL];return new Promise((function(i,o){if(!e||!e.publicKey||!e.fingerprint)return o(new Error("Need HDSigner to sign input"));var a=$o(t,r.data.inputs,e).map((function(e){return r.signInputAsync(t,e,n)}));return Promise.all(a).then((function(){i()})).catch(o)}))}},{key:"signAllInputs",value:function(t,e){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");var r,n=[],i=wo(sa(this.data.inputs.length));try{for(i.s();!(r=i.n()).done;){var o=r.value;try{this.signInput(o,t,e),n.push(!0)}catch(t){n.push(!1)}}}catch(t){i.e(t)}finally{i.f()}if(n.every((function(t){return!1===t})))throw new Error("No inputs were signed");return this}},{key:"signAllInputsAsync",value:function(t,e){var r=this;return new Promise((function(n,i){if(!t||!t.publicKey)return i(new Error("Need Signer to sign input"));var o,a,u=[],s=[],c=wo(r.data.inputs.entries());try{for(c.s();!(o=c.n()).done;){var f=(a=o.value,function(t){if(Array.isArray(t))return t}(a)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,n,i,o,a=[],u=!0,s=!1;try{for(i=(e=e.call(t)).next;!(u=(r=i.call(e)).done)&&(a.push(r.value),1!==a.length);u=!0);}catch(t){s=!0,n=t}finally{try{if(!u&&null!=e.return&&(o=e.return(),Object(o)!==o))return}finally{if(s)throw n}}return a}}(a)||_o(a,1)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];s.push(r.signInputAsync(f,t,e).then((function(){u.push(!0)}),(function(){u.push(!1)})))}}catch(t){c.e(t)}finally{c.f()}return Promise.all(s).then((function(){if(u.every((function(t){return!1===t})))return i(new Error("No inputs were signed"));n()}))}))}},{key:"signInput",value:function(t,e,r){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var n=(0,Qi.checkForInput)(this.data.inputs,t);return ai(n)?this._signTaprootInput(t,n,e,void 0,r):this._signInput(t,e,r)}},{key:"signTaprootInput",value:function(t,e,r,n){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var i=(0,Qi.checkForInput)(this.data.inputs,t);if(ai(i))return this._signTaprootInput(t,i,e,r,n);throw new Error("Input #".concat(t," is not of type Taproot."))}},{key:"signInputAsync",value:function(t,e,r){var n=this;return Promise.resolve().then((function(){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var i=(0,Qi.checkForInput)(n.data.inputs,t);return ai(i)?n._signTaprootInputAsync(t,i,e,void 0,r):n._signInputAsync(t,e,r)}))}},{key:"signTaprootInputAsync",value:function(t,e,r,n){var i=this;return Promise.resolve().then((function(){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var o=(0,Qi.checkForInput)(i.data.inputs,t);if(ai(o))return i._signTaprootInputAsync(t,o,e,r,n);throw new Error("Input #".concat(t," is not of type Taproot."))}))}},{key:"toBuffer",value:function(){return Lo(this.__CACHE),this.data.toBuffer()}},{key:"toHex",value:function(){return Lo(this.__CACHE),this.data.toHex()}},{key:"toBase64",value:function(){return Lo(this.__CACHE),this.data.toBase64()}},{key:"updateGlobal",value:function(t){return this.data.updateGlobal(t),this}},{key:"updateInput",value:function(t,e){return e.witnessScript&&aa(e.witnessScript),si(this.data.inputs[t],e,"updateInput"),this.data.updateInput(t,e),e.nonWitnessUtxo&&Qo(this.__CACHE,this.data.inputs[t],t),this}},{key:"updateOutput",value:function(t,e){return ci(this.data.outputs[t],e,"updateOutput"),this.data.updateOutput(t,e),this}},{key:"addUnknownKeyValToGlobal",value:function(t){return this.data.addUnknownKeyValToGlobal(t),this}},{key:"addUnknownKeyValToInput",value:function(t,e){return this.data.addUnknownKeyValToInput(t,e),this}},{key:"addUnknownKeyValToOutput",value:function(t,e){return this.data.addUnknownKeyValToOutput(t,e),this}},{key:"clearFinalizedInput",value:function(t){return this.data.clearFinalizedInput(t),this}},{key:"checkTaprootHashesForSig",value:function(t,e,r,n,i){if("function"!=typeof r.signSchnorr)throw new Error("Need Schnorr Signer to sign taproot input #".concat(t,"."));var o=Xo(t,e,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error("Can not sign for input #".concat(t," with the key ").concat(r.publicKey.toString("hex")));return o}},{key:"_finalizeInput",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Go,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=function(t,e,r){var n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!e.redeemScript,i.isP2WSH=!!e.witnessScript,e.witnessScript)i.script=e.witnessScript;else if(e.redeemScript)i.script=e.redeemScript;else if(e.nonWitnessUtxo){var o=ea(r,e,t),a=n.ins[t].index;i.script=o.outs[a].script}else e.witnessUtxo&&(i.script=e.witnessUtxo.script);return(e.witnessScript||Oi(i.script))&&(i.isSegwit=!0),i}(t,e,this.__CACHE),o=i.script,a=i.isP2SH,u=i.isP2WSH,s=i.isSegwit;if(!o)throw new Error("No script found for input #".concat(t));!function(t){if(t.sighashType&&t.partialSig){var e=t.partialSig,r=t.sighashType;e.forEach((function(t){var e=le.decode(t.signature).hashType;if(r!==e)throw new Error("Signature sighash does not match input sighash type")}))}}(e);var c=r(t,e,o,s,a,u,n),f=c.finalScriptSig,l=c.finalScriptWitness;if(f&&this.data.updateInput(t,{finalScriptSig:f}),l&&this.data.updateInput(t,{finalScriptWitness:l}),!f&&!l)throw new Error("Unknown error finalizing input #".concat(t));return this.data.clearFinalizedInput(t),this}},{key:"_finalizeTaprootInput",value:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:ii;if(!e.witnessUtxo)throw new Error("Cannot finalize input #".concat(t,". Missing witness utxo."));if(e.tapKeySig){var i=Pi(In({output:e.witnessUtxo.script,signature:e.tapKeySig}).witness);this.data.updateInput(t,{finalScriptWitness:i})}else{var o=n(t,e,r).finalScriptWitness;this.data.updateInput(t,{finalScriptWitness:o})}return this.data.clearFinalizedInput(t),this}},{key:"_validateSignaturesOfInput",value:function(t,e,r){var n=this.data.inputs[t],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");var o=r?i.filter((function(t){return t.pubkey.equals(r)})):i;if(o.length<1)throw new Error("No signatures for this pubkey");var a,u,s,c,f=[],l=wo(o);try{for(l.s();!(c=l.n()).done;){var h=c.value,p=le.decode(h.signature),d=s!==p.hashType?qo(t,Object.assign({},n,{sighashType:p.hashType}),this.__CACHE,!0):{hash:a,script:u},y=d.hash,g=d.script;s=p.hashType,a=y,u=g,Co(h.pubkey,g,"verify"),f.push(e(h.pubkey,y,p.signature))}}catch(t){l.e(t)}finally{l.f()}return f.every((function(t){return!0===t}))}},{key:"validateSignaturesOfTaprootInput",value:function(t,e,r){var n=this.data.inputs[t],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");var a=(r=r&&ni(r))?Xo(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){var i=[];if(e.tapInternalKey){var o=zo(t,e,n);o&&i.push(o)}if(e.tapScriptSig){var a=e.tapScriptSig.map((function(t){return t.pubkey}));i.push.apply(i,mo(a))}return i.map((function(i){return Xo(t,e,r,i,n)})).flat()}(t,n,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");var u=a.find((function(t){return!t.leafHash})),s=0;if(i&&u){if(!e(u.pubkey,u.hash,Yo(i)))return!1;s++}if(o){var c,f=wo(o);try{var l,h=function(){var t=c.value,r=a.find((function(e){return t.pubkey.equals(e.pubkey)}));if(r){if(!e(t.pubkey,r.hash,Yo(t.signature)))return{v:!1};s++}};for(f.s();!(c=f.n()).done;)if(l=h())return l.v}catch(t){f.e(t)}finally{f.f()}}return s>0}},{key:"_signInput",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[Qn.SIGHASH_ALL];ho(e);var n=Vo(this.data.inputs,t,e.publicKey,this.__CACHE,r),i=n.hash,o=n.sighashType,a=[{pubkey:e.publicKey,signature:le.encode(e.sign(i),o)}];return this.data.updateInput(t,{partialSig:a}),this}},{key:"_signTaprootInput",value:function(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[Qn.SIGHASH_DEFAULT];ho(r);var o=this.checkTaprootHashesForSig(t,e,r,n,i),a=o.filter((function(t){return!t.leafHash})).map((function(t){return oi(r.signSchnorr(t.hash),e.sighashType)}))[0],u=o.filter((function(t){return!!t.leafHash})).map((function(t){return{pubkey:ni(r.publicKey),signature:oi(r.signSchnorr(t.hash),e.sighashType),leafHash:t.leafHash}}));return a&&this.data.updateInput(t,{tapKeySig:a}),u.length&&this.data.updateInput(t,{tapScriptSig:u}),this}},{key:"_signInputAsync",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[Qn.SIGHASH_ALL];ho(e);var i=Vo(this.data.inputs,t,e.publicKey,this.__CACHE,n),o=i.hash,a=i.sighashType;return Promise.resolve(e.sign(o)).then((function(n){var i=[{pubkey:e.publicKey,signature:le.encode(n,a)}];r.data.updateInput(t,{partialSig:i})}))}},{key:"_signTaprootInputAsync",value:(e=vo(go().mark((function t(e,r,n,i){var o,a,u,s,c,f,l,h,p,d,y,g=arguments;return go().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=g.length>4&&void 0!==g[4]?g[4]:[Qn.SIGHASH_DEFAULT],ho(n),a=this.checkTaprootHashesForSig(e,r,n,i,o),u=[],s=a.filter((function(t){return!t.leafHash}))[0],s&&(c=Promise.resolve(n.signSchnorr(s.hash)).then((function(t){return{tapKeySig:oi(t,r.sighashType)}})),u.push(c)),f=a.filter((function(t){return!!t.leafHash})),f.length&&(l=f.map(function(){var t=vo(go().mark((function t(e){var i,o;return go().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.signSchnorr(e.hash);case 2:return i=t.sent,o=[{pubkey:ni(n.publicKey),signature:oi(i,r.sighashType),leafHash:e.leafHash}],t.abrupt("return",{tapScriptSig:o});case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),u.push.apply(u,mo(l))),t.next=10,Promise.all(u);case 10:h=t.sent,p=wo(h);try{for(p.s();!(d=p.n()).done;)y=d.value,this.data.updateInput(e,y)}catch(t){p.e(t)}finally{p.f()}case 13:case"end":return t.stop()}}),t,this)}))),function(t,r,n,i){return e.apply(this,arguments)})}],[{key:"fromBase64",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=po.from(t,"base64");return this.fromBuffer(r,e)}},{key:"fromHex",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=po.from(t,"hex");return this.fromBuffer(r,e)}},{key:"fromBuffer",value:function(e){var r,n,i=new t(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},Ji.i.fromBuffer(e,Po));return r=i.__CACHE.__TX,n=i.__CACHE,r.ins.forEach((function(t){Fo(n,t)})),i}}]);var e}(),Po=function(t){return new Io(t)},Io=Oo((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:po.from([2,0,0,0,0,0,0,0,0,0]);So(this,t),this.tx=Qn.fromBuffer(e),function(t){if(!t.ins.every((function(t){return t.script&&0===t.script.length&&t.witness&&0===t.witness.length})))throw new Error("Format Error: Transaction ScriptSigs are not empty")}(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}),[{key:"getInputOutputCounts",value:function(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}},{key:"addInput",value:function(t){if(void 0===t.hash||void 0===t.index||!po.isBuffer(t.hash)&&"string"!=typeof t.hash||"number"!=typeof t.index)throw new Error("Error adding input.");var e="string"==typeof t.hash?yr(po.from(t.hash,"hex")):t.hash;this.tx.addInput(e,t.index,t.sequence)}},{key:"addOutput",value:function(t){if(void 0===t.script||void 0===t.value||!po.isBuffer(t.script)||"number"!=typeof t.value)throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}},{key:"toBuffer",value:function(){return this.tx.toBuffer()}}]);function Lo(t){if(!1!==t.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function Bo(t,e,r){if(!e)return!1;var n;if((n=r?r.map((function(t){var r=function(t){if(65===t.length){var e=1&t[64],r=t.slice(0,33);return r[0]=2|e,r}return t.slice()}(t);return e.find((function(t){return t.pubkey.equals(r)}))})).filter((function(t){return!!t})):e).length>t)throw new Error("Too many signatures");return n.length===t}function Ro(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function jo(t){return function(e){return!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}}function No(t){if("number"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error("Invalid 32 bit integer")}function Uo(t,e){t.forEach((function(t){if(ai(t)?pi(t,e):Ni(t,e))throw new Error("Can not modify transaction, signatures exist.")}))}function Co(t,e,r){if(!ji(t,e))throw new Error("Can not ".concat(r," for this input with the key ").concat(t.toString("hex")))}function Fo(t,e){var r=yr(po.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 Mo(t,e){return function(r,n,i,o){var a=t({redeem:{output:i}}).output;if(!n.equals(a))throw new Error("".concat(e," for ").concat(o," #").concat(r," doesn't match the scriptPubKey in the prevout"))}}var Do=Mo(Tn,"Redeem script"),Ho=Mo(Mn,"Witness script");function Ko(t,e,r,n){var i,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(!r.every(Ro))throw new Error("PSBT must be finalized to calculate ".concat(e));if("__FEE_RATE"===t&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===t&&n.__FEE)return n.__FEE;var a=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,a=!1):i=n.__TX.clone(),ta(r,i,n,a,o),"__FEE_RATE"===t?n.__FEE_RATE:"__FEE"===t?n.__FEE:void 0}function Go(t,e,r,n,i,o){var a=!(arguments.length>6&&void 0!==arguments[6])||arguments[6],u=ua(r);if(!function(t,e,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return Bo(1,t.partialSig);case"multisig":var n=Cr({output:e});return Bo(n.m,t.partialSig,n.pubkeys);default:return!1}}(e,r,u)&&a)throw new Error("Can not finalize input #".concat(t));return Wo(r,u,e.partialSig,n,i,o)}function Wo(t,e,r,n,i,o){var a,u,s=function(t,e,r){var n;switch(e){case"multisig":var i=function(t,e){return Cr({output:t}).pubkeys.map((function(t){return(e.filter((function(e){return e.pubkey.equals(t)}))[0]||{}).signature})).filter((function(t){return!!t}))}(t,r);n=Cr({output:t,signatures:i});break;case"pubkey":n=Mr({output:t,signature:r[0].signature});break;case"pubkeyhash":n=Di({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=jn({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),c=o?Mn({redeem:s}):null,f=i?Tn({redeem:c||s}):null;return n?(u=Pi(c?c.witness:s.witness),f&&(a=f.input)):a=f?f.input:s.input,{finalScriptSig:a,finalScriptWitness:u}}function Vo(t,e,r,n,i){var o=qo(e,(0,Qi.checkForInput)(t,e),n,!1,i),a=o.hash,u=o.sighashType;return Co(r,o.script,"sign"),{hash:a,sighashType:u}}function qo(t,e,r,n,i){var o,a,u=r.__TX,s=e.sighashType||Qn.SIGHASH_ALL;if(Zo(s,i),e.nonWitnessUtxo){var c=ea(r,e,t),f=u.ins[t].hash,l=c.getHash();if(!f.equals(l))throw new Error("Non-witness UTXO hash for input #".concat(t," doesn't match the hash specified in the prevout"));var h=u.ins[t].index;a=c.outs[h]}else{if(!e.witnessUtxo)throw new Error("Need a Utxo input item for signing");a=e.witnessUtxo}var p=oa(a.script,t,"input",e.redeemScript,e.witnessScript),d=p.meaningfulScript,y=p.type;if(["p2sh-p2wsh","p2wsh"].indexOf(y)>=0)o=u.hashForWitnessV0(t,d,a.value,s);else if(Oi(d)){var g=Di({hash:d.slice(2)}).output;o=u.hashForWitnessV0(t,g,a.value,s)}else{if(void 0===e.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Input #".concat(t," has witnessUtxo but non-segwit script: ")+"".concat(d.toString("hex")));n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn("Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecessor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n*********************"),o=u.hashForSignature(t,d,s)}return{script:d,sighashType:s,hash:o}}function zo(t,e,r){var n=na(t,e,r).script;return Ai(n)?n.subarray(2,34):null}function Yo(t){return 64===t.length?t:t.subarray(0,64)}function Xo(t,e,r,n,i,o,a){var u=i.__TX,s=e.sighashType||Qn.SIGHASH_DEFAULT;Zo(s,a);var c=r.map((function(t,e){return na(e,t,i)})),f=c.map((function(t){return t.script})),l=c.map((function(t){return t.value})),h=[];if(e.tapInternalKey&&!o){var p=zo(t,e,i)||po.from([]);if(ni(n).equals(p)){var d=u.hashForWitnessV1(t,f,l,s);h.push({pubkey:n,hash:d})}}var y=(e.tapLeafScript||[]).filter((function(t){return ji(n,t.script)})).map((function(t){var e=xr({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)})).filter((function(t){return!o||o.equals(t.hash)})).map((function(e){var r=u.hashForWitnessV1(t,f,l,s,e.hash);return{pubkey:n,hash:r,leafHash:e.hash}}));return h.concat(y)}function Zo(t,e){if(e&&e.indexOf(t)<0){var r=function(t){var e=t&Qn.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&t){case Qn.SIGHASH_ALL:e+="SIGHASH_ALL";break;case Qn.SIGHASH_SINGLE:e+="SIGHASH_SINGLE";break;case Qn.SIGHASH_NONE:e+="SIGHASH_NONE"}return e}(t);throw new Error("Sighash type is not allowed. Retry the sign method passing the "+"sighashTypes array of whitelisted types. Sighash type: ".concat(r))}}function $o(t,e,r){var n=(0,Qi.checkForInput)(e,t);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");var i=n.bip32Derivation.map((function(t){return t.masterFingerprint.equals(r.fingerprint)?t:void 0})).filter((function(t){return!!t}));if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map((function(t){var e=r.derivePath(t.path);if(!t.pubkey.equals(e.publicKey))throw new Error("pubkey did not match bip32Derivation");return e}))}function Jo(t){var e=0;function r(){var r=Sn.decode(t,e);return e+=Sn.decode.bytes,r}return function(){for(var n=r(),i=[],o=0;o<n;o++)i.push((a=r(),e+=a,t.slice(e-a,e)));var a;return i}()}function Qo(t,e,r){t.__NON_WITNESS_UTXO_BUF_CACHE[r]=e.nonWitnessUtxo,t.__NON_WITNESS_UTXO_TX_CACHE[r]=Qn.fromBuffer(e.nonWitnessUtxo);var n=t,i=r;delete e.nonWitnessUtxo,Object.defineProperty(e,"nonWitnessUtxo",{enumerable:!0,get:function(){var t=n.__NON_WITNESS_UTXO_BUF_CACHE[i],e=n.__NON_WITNESS_UTXO_TX_CACHE[i];if(void 0!==t)return t;var r=e.toBuffer();return n.__NON_WITNESS_UTXO_BUF_CACHE[i]=r,r},set:function(t){n.__NON_WITNESS_UTXO_BUF_CACHE[i]=t}})}function ta(t,e,r,n,i){var o=0;t.forEach((function(t,i){if(n&&t.finalScriptSig&&(e.ins[i].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[i].witness=Jo(t.finalScriptWitness)),t.witnessUtxo)o+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){var a=ea(r,t,i),u=e.ins[i].index,s=a.outs[u];o+=s.value}}));var a=e.outs.reduce((function(t,e){return t+e.value}),0),u=o-a;if(!i&&u<0)throw new Error("Outputs are spending more than Inputs");var s=e.virtualSize();r.__FEE=u,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(u/s)}function ea(t,e,r){var n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||Qo(t,e,r),n[r]}function ra(t,e,r){return na(t,e,r).script}function na(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){var n=ea(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 ia(t){return 33===t.length&&ue(t)}function oa(t,e,r,n,i){var o,a=xi(t),u=a&&n&&Ti(n),s=Ti(t);if(a&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((s||u)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");return u?(o=i,Do(e,t,n,r),Ho(e,n,i,r),aa(o)):s?(o=i,Ho(e,t,i,r),aa(o)):a?(o=n,Do(e,t,n,r)):o=t,{meaningfulScript:o,type:u?"p2sh-p2wsh":a?"p2sh":s?"p2wsh":"raw"}}function aa(t){if(Oi(t)||xi(t))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function ua(t){return Oi(t)?"witnesspubkeyhash":ki(t)?"pubkeyhash":Ei(t)?"multisig":Si(t)?"pubkey":"nonstandard"}function sa(t){return mo(Array(t).keys())}const ca={networks:v,address:E,payments:O,script:_,crypto:S,Transaction:k};var fa=b.iL,la=b.ZX,ha=b.hl,pa=b.Et,da=b.m$,ya=b.Ay,ga=b.Dk,ba=b.f0,va=b.Bh,wa=b.Q2,ma=b.C5,_a=b.n0,Ea=b.NI,Sa=b.fQ,ka=b.mG,Oa=b.o8,Ta=b.Ez,xa=b.KT,Aa=b.k1,Pa=b.HE,Ia=b.K$,La=b.VQ,Ba=b.qR,Ra=b.gU,ja=b.Uu,Na=i(3513),Ua=i.t(Na,2);function Ca(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Fa(t,...e){if(!function(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Ma(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 Da=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ha=(t,e)=>t<<32-e|t>>>e,Ka=(t,e)=>t<<e|t>>>32-e>>>0;function Ga(t){return"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)),Fa(t),t}class Wa{clone(){return this._cloneInto()}}function Va(t){const e=e=>t().update(Ga(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}class qa extends Wa{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");Ca(t.outputLen),Ca(t.blockLen)}(t);const r=Ga(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 Ma(this),this.iHash.update(t),this}digestInto(t){Ma(this),Fa(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const za=(t,e,r)=>new qa(t,e).update(r).digest();za.create=(t,e)=>new qa(t,e);const Ya=(t,e,r)=>t&e^~t&r,Xa=(t,e,r)=>t&e^t&r^e&r;class Za extends Wa{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=Da(this.buffer)}update(t){Ma(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=Ga(t)).length;for(let o=0;o<i;){const a=Math.min(n-this.pos,i-o);if(a!==n)r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=Da(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ma(this),function(t,e){Fa(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),u=Number(r&o),s=n?4:0,c=n?0:4;t.setUint32(e+s,a,n),t.setUint32(e+c,u,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=Da(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const s=u/4,c=this.get();if(s>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<s;t++)a.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const $a=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Ja=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e))),Qa=Ja.map((t=>(9*t+5)%16));let tu=[Ja],eu=[Qa];for(let t=0;t<4;t++)for(let e of[tu,eu])e.push(e[t].map((t=>$a[t])));const ru=[[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))),nu=tu.map(((t,e)=>t.map((t=>ru[e][t])))),iu=eu.map(((t,e)=>t.map((t=>ru[e][t])))),ou=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),au=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function uu(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 su=new Uint32Array(16);class cu extends Za{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)su[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,i=0|this.h1,o=i,a=0|this.h2,u=a,s=0|this.h3,c=s,f=0|this.h4,l=f;for(let t=0;t<5;t++){const e=4-t,h=ou[t],p=au[t],d=tu[t],y=eu[t],g=nu[t],b=iu[t];for(let e=0;e<16;e++){const n=Ka(r+uu(t,i,a,s)+su[d[e]]+h,g[e])+f|0;r=f,f=s,s=0|Ka(a,10),a=i,i=n}for(let t=0;t<16;t++){const r=Ka(n+uu(e,o,u,c)+su[y[t]]+p,b[t])+l|0;n=l,l=c,c=0|Ka(u,10),u=o,o=r}}this.set(this.h1+a+c|0,this.h2+s+l|0,this.h3+f+n|0,this.h4+r+o|0,this.h0+i+u|0)}roundClean(){su.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const fu=Va((()=>new cu)),lu=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]),hu=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),pu=new Uint32Array(64);class du extends Za{constructor(){super(64,32,8,!1),this.A=0|hu[0],this.B=0|hu[1],this.C=0|hu[2],this.D=0|hu[3],this.E=0|hu[4],this.F=0|hu[5],this.G=0|hu[6],this.H=0|hu[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:u}=this;return[t,e,r,n,i,o,a,u]}set(t,e,r,n,i,o,a,u){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|u}process(t,e){for(let r=0;r<16;r++,e+=4)pu[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=pu[t-15],r=pu[t-2],n=Ha(e,7)^Ha(e,18)^e>>>3,i=Ha(r,17)^Ha(r,19)^r>>>10;pu[t]=i+pu[t-7]+n+pu[t-16]|0}let{A:r,B:n,C:i,D:o,E:a,F:u,G:s,H:c}=this;for(let t=0;t<64;t++){const e=c+(Ha(a,6)^Ha(a,11)^Ha(a,25))+Ya(a,u,s)+lu[t]+pu[t]|0,f=(Ha(r,2)^Ha(r,13)^Ha(r,22))+Xa(r,n,i)|0;c=s,s=u,u=a,a=o+e|0,o=i,i=n,n=r,r=e+f|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,s=s+this.G|0,c=c+this.H|0,this.set(r,n,i,o,a,u,s,c)}roundClean(){pu.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const yu=Va((()=>new du)),gu=BigInt(2**32-1),bu=BigInt(32);function vu(t,e=!1){return e?{h:Number(t&gu),l:Number(t>>bu&gu)}:{h:0|Number(t>>bu&gu),l:0|Number(t&gu)}}const wu={fromBig:vu,split:function(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:a}=vu(t[i],e);[r[i],n[i]]=[o,a]}return[r,n]},toBig:(t,e)=>BigInt(t>>>0)<<bu|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:(t,e,r)=>t<<r|e>>>32-r,rotlSL:(t,e,r)=>e<<r|t>>>32-r,rotlBH:(t,e,r)=>e<<r-32|t>>>64-r,rotlBL:(t,e,r)=>t<<r-32|e>>>64-r,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,o)=>e+r+n+i+o+(t/2**32|0)|0,add5L:(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},mu=wu,[_u,Eu]=(()=>mu.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)))))(),Su=new Uint32Array(80),ku=new Uint32Array(80);class Ou extends Za{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:o,Dh:a,Dl:u,Eh:s,El:c,Fh:f,Fl:l,Gh:h,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,a,u,s,c,f,l,h,p,d,y]}set(t,e,r,n,i,o,a,u,s,c,f,l,h,p,d,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|a,this.Dl=0|u,this.Eh=0|s,this.El=0|c,this.Fh=0|f,this.Fl=0|l,this.Gh=0|h,this.Gl=0|p,this.Hh=0|d,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)Su[r]=t.getUint32(e),ku[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|Su[t-15],r=0|ku[t-15],n=mu.rotrSH(e,r,1)^mu.rotrSH(e,r,8)^mu.shrSH(e,r,7),i=mu.rotrSL(e,r,1)^mu.rotrSL(e,r,8)^mu.shrSL(e,r,7),o=0|Su[t-2],a=0|ku[t-2],u=mu.rotrSH(o,a,19)^mu.rotrBH(o,a,61)^mu.shrSH(o,a,6),s=mu.rotrSL(o,a,19)^mu.rotrBL(o,a,61)^mu.shrSL(o,a,6),c=mu.add4L(i,s,ku[t-7],ku[t-16]),f=mu.add4H(c,n,u,Su[t-7],Su[t-16]);Su[t]=0|f,ku[t]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:a,Cl:u,Dh:s,Dl:c,Eh:f,El:l,Fh:h,Fl:p,Gh:d,Gl:y,Hh:g,Hl:b}=this;for(let t=0;t<80;t++){const e=mu.rotrSH(f,l,14)^mu.rotrSH(f,l,18)^mu.rotrBH(f,l,41),v=mu.rotrSL(f,l,14)^mu.rotrSL(f,l,18)^mu.rotrBL(f,l,41),w=f&h^~f&d,m=l&p^~l&y,_=mu.add5L(b,v,m,Eu[t],ku[t]),E=mu.add5H(_,g,e,w,_u[t],Su[t]),S=0|_,k=mu.rotrSH(r,n,28)^mu.rotrBH(r,n,34)^mu.rotrBH(r,n,39),O=mu.rotrSL(r,n,28)^mu.rotrBL(r,n,34)^mu.rotrBL(r,n,39),T=r&i^r&a^i&a,x=n&o^n&u^o&u;g=0|d,b=0|y,d=0|h,y=0|p,h=0|f,p=0|l,({h:f,l}=mu.add(0|s,0|c,0|E,0|S)),s=0|a,c=0|u,a=0|i,u=0|o,i=0|r,o=0|n;const A=mu.add3L(S,O,x);r=mu.add3H(A,E,k,T),n=0|A}({h:r,l:n}=mu.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=mu.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:a,l:u}=mu.add(0|this.Ch,0|this.Cl,0|a,0|u)),({h:s,l:c}=mu.add(0|this.Dh,0|this.Dl,0|s,0|c)),({h:f,l}=mu.add(0|this.Eh,0|this.El,0|f,0|l)),({h,l:p}=mu.add(0|this.Fh,0|this.Fl,0|h,0|p)),({h:d,l:y}=mu.add(0|this.Gh,0|this.Gl,0|d,0|y)),({h:g,l:b}=mu.add(0|this.Hh,0|this.Hl,0|g,0|b)),this.set(r,n,i,o,a,u,s,c,f,l,h,p,d,y,g,b)}roundClean(){Su.fill(0),ku.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 Tu=Va((()=>new Ou));function xu(t,e){return za(Tu,t,e)}const Au="0123456789abcdefABCDEF",Pu=(Au.split("").map((t=>t.codePointAt(0))),Array(256).fill(!0).map(((t,e)=>{const r=String.fromCodePoint(e),n=Au.indexOf(r);return n<0?void 0:n<16?n:n-6}))),Iu=new TextEncoder;function Lu(t,e){const r=Math.min(t.length,e.length);for(let n=0;n<r;++n)if(t[n]!==e[n])return t[n]<e[n]?-1:1;return t.length===e.length?0:t.length>e.length?1:-1}function Bu(t,e,r){if(e+1>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);t[e]=r}function Ru(t,e,r,n){if(e+4>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received ${r}`);"LE"===n?(t[e]=255&r,t[e+1]=r>>8&255,t[e+2]=r>>16&255,t[e+3]=r>>24&255):(t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r)}function ju(t,e,r){if(e+4>t.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0;return r=(r<<8)+t[e+3]>>>0,r=(r<<8)+t[e+2]>>>0,r=(r<<8)+t[e+1]>>>0,r=(r<<8)+t[e]>>>0,r}{let r=0;return r=(r<<8)+t[e]>>>0,r=(r<<8)+t[e+1]>>>0,r=(r<<8)+t[e+2]>>>0,r=(r<<8)+t[e+3]>>>0,r}}new TextDecoder;const Nu=t=>function(t){const e=Iu.encode(t||""),r=new Uint8Array(Math.floor(e.length/2));let n;for(n=0;n<r.length;n++){const t=Pu[e[2*n]],i=Pu[e[2*n+1]];if(void 0===t||void 0===i)break;r[n]=t<<4|i}return n===r.length?r:r.slice(0,n)}(t);function Uu(t){if(!t)throw new Error("ecc library invalid")}function Cu(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function Fu(t,e){return!!Array.isArray(e)&&(0===e.length||(t?e.every((t=>"string"==typeof t)):e.every((t=>Number.isSafeInteger(t)))))}function Mu(t){if("function"!=typeof t)throw new Error("function expected");return!0}function Du(t,e){if("string"!=typeof e)throw new Error(`${t}: string expected`);return!0}function Hu(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Ku(t){if(!Array.isArray(t))throw new Error("array expected")}function Gu(t,e){if(!Fu(!0,e))throw new Error(`${t}: array of strings expected`)}function Wu(t,e){if(!Fu(!1,e))throw new Error(`${t}: array of numbers expected`)}function Vu(...t){const e=t=>t,r=(t,e)=>r=>t(e(r)),n=t.map((t=>t.encode)).reduceRight(r,e),i=t.map((t=>t.decode)).reduce(r,e);return{encode:n,decode:i}}function qu(t){const e="string"==typeof t?t.split(""):t,r=e.length;Gu("alphabet",e);const n=new Map(e.map(((t,e)=>[t,e])));return{encode:n=>(Ku(n),n.map((n=>{if(!Number.isSafeInteger(n)||n<0||n>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${n}". Allowed: ${t}`);return e[n]}))),decode:e=>(Ku(e),e.map((e=>{Du("alphabet.decode",e);const r=n.get(e);if(void 0===r)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return r})))}}function zu(t=""){return Du("join",t),{encode:e=>(Gu("join.decode",e),e.join(t)),decode:e=>(Du("join.decode",e),e.split(t))}}function Yu(t,e="="){return Hu(t),Du("padding",e),{encode(r){for(Gu("padding.encode",r);r.length*t%8;)r.push(e);return r},decode(r){Gu("padding.decode",r);let n=r.length;if(n*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if((n-1)*t%8==0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,n)}}}function Xu(t){return Mu(t),{encode:t=>t,decode:e=>t(e)}}function Zu(t,e,r){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Ku(t),!t.length)return[];let n=0;const i=[],o=Array.from(t,(t=>{if(Hu(t),t<0||t>=e)throw new Error(`invalid integer: ${t}`);return t})),a=o.length;for(;;){let t=0,u=!0;for(let i=n;i<a;i++){const a=o[i],s=e*t,c=s+a;if(!Number.isSafeInteger(c)||s/e!==t||c-a!==s)throw new Error("convertRadix: carry overflow");const f=c/r;t=c%r;const l=Math.floor(f);if(o[i]=l,!Number.isSafeInteger(l)||l*r+t!==c)throw new Error("convertRadix: carry overflow");u&&(l?u=!1:n=i)}if(i.push(t),u)break}for(let e=0;e<t.length-1&&0===t[e];e++)i.push(0);return i.reverse()}const $u=(t,e)=>0===e?t:$u(e,t%e),Ju=(t,e)=>t+(e-$u(t,e)),Qu=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function ts(t,e,r,n){if(Ku(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Ju(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${Ju(e,r)}`);let i=0,o=0;const a=Qu[e],u=Qu[r]-1,s=[];for(const n of t){if(Hu(n),n>=a)throw new Error(`convertRadix2: invalid data word=${n} from=${e}`);if(i=i<<e|n,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=r;o-=r)s.push((i>>o-r&u)>>>0);const t=Qu[o];if(void 0===t)throw new Error("invalid carry");i&=t-1}if(i=i<<r-o&u,!n&&o>=e)throw new Error("Excess padding");if(!n&&i>0)throw new Error(`Non-zero padding: ${i}`);return n&&o>0&&s.push(i>>>0),s}function es(t,e=!1){if(Hu(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Ju(8,t)>32||Ju(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Cu(r))throw new Error("radix2.encode input should be Uint8Array");return ts(Array.from(r),8,t,!e)},decode:r=>(Wu("radix2.decode",r),Uint8Array.from(ts(r,t,8,e)))}}function rs(t){return Mu(t),function(...e){try{return t.apply(null,e)}catch(t){}}}Vu(es(4),qu("0123456789ABCDEF"),zu("")),Vu(es(5),qu("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Yu(5),zu("")),Vu(es(5),qu("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),zu("")),Vu(es(5),qu("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Yu(5),zu("")),Vu(es(5),qu("0123456789ABCDEFGHIJKLMNOPQRSTUV"),zu("")),Vu(es(5),qu("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),zu(""),Xu((t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),Vu(es(6),qu("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Yu(6),zu("")),Vu(es(6),qu("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),zu("")),Vu(es(6),qu("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Yu(6),zu("")),Vu(es(6),qu("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),zu(""));const ns=t=>{return Vu((Hu(e=58),{encode:t=>{if(!Cu(t))throw new Error("radix.encode input should be Uint8Array");return Zu(Array.from(t),256,e)},decode:t=>(Wu("radix.decode",t),Uint8Array.from(Zu(t,e,256)))}),qu(t),zu(""));var e},is=ns("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),os=(ns("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),ns("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),t=>Vu(function(t,e){return Hu(t),Mu(e),{encode(r){if(!Cu(r))throw new Error("checksum.encode: input should be Uint8Array");const n=e(r).slice(0,t),i=new Uint8Array(r.length+t);return i.set(r),i.set(n,r.length),i},decode(r){if(!Cu(r))throw new Error("checksum.decode: input should be Uint8Array");const n=r.slice(0,-t),i=r.slice(-t),o=e(n).slice(0,t);for(let e=0;e<t;e++)if(o[e]!==i[e])throw new Error("Invalid checksum");return n}}}(4,(e=>t(t(e)))),is)),as=Vu(qu("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),zu("")),us=[996825010,642813549,513874426,1027748829,705979059];function ss(t){const e=t>>25;let r=(33554431&t)<<5;for(let t=0;t<us.length;t++)1==(e>>t&1)&&(r^=us[t]);return r}function cs(t,e,r=1){const n=t.length;let i=1;for(let e=0;e<n;e++){const r=t.charCodeAt(e);if(r<33||r>126)throw new Error(`Invalid prefix (${t})`);i=ss(i)^r>>5}i=ss(i);for(let e=0;e<n;e++)i=ss(i)^31&t.charCodeAt(e);for(let t of e)i=ss(i)^t;for(let t=0;t<6;t++)i=ss(i);return i^=r,as.encode(ts([i%Qu[30]],30,5,!1))}function fs(t){const e="bech32"===t?1:734539939,r=es(5),n=r.decode,i=r.encode,o=rs(n);function a(t,r,n=90){Du("bech32.encode prefix",t),Cu(r)&&(r=Array.from(r)),Wu("bech32.encode",r);const i=t.length;if(0===i)throw new TypeError(`Invalid prefix length ${i}`);const o=i+7+r.length;if(!1!==n&&o>n)throw new TypeError(`Length ${o} exceeds limit ${n}`);const a=t.toLowerCase(),u=cs(a,r,e);return`${a}1${as.encode(r)}${u}`}function u(t,r=90){Du("bech32.decode input",t);const n=t.length;if(n<8||!1!==r&&n>r)throw new TypeError(`invalid string length: ${n} (${t}). Expected (8..${r})`);const i=t.toLowerCase();if(t!==i&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=i.lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const a=i.slice(0,o),u=i.slice(o+1);if(u.length<6)throw new Error("Data must be at least 6 characters long");const s=as.decode(u).slice(0,-6),c=cs(a,s,e);if(!u.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected "${c}"`);return{prefix:a,words:s}}return{encode:a,decode:u,encodeFromBytes:function(t,e){return a(t,i(e))},decodeToBytes:function(t){const{prefix:e,words:r}=u(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:rs(u),fromWords:n,fromWordsUnsafe:o,toWords:i}}function ls(t){const e=typeof t;return"string"===e?`"${t}"`:"number"===e||"bigint"===e||"boolean"===e?`${t}`:"object"===e||"function"===e?(t&&Object.getPrototypeOf(t)?.constructor?.name)??"null":e}function hs(t,e,r,n,i){const o=i&&"input"in i?i.input:r.value,a=i?.expected??t.expects??null,u=i?.received??ls(o),s={kind:t.kind,type:t.type,input:o,expected:a,received:u,message:`Invalid ${e}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:t.requirement,path:i?.path,issues:i?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},c="schema"===t.kind,f=i?.message??t.message??(t.reference,void s.lang)??(c?void s.lang:null)??n.message??void s.lang;f&&(s.message="function"==typeof f?f(s):f),c&&(r.typed=!1),r.issues?r.issues.push(s):r.issues=[s]}fs("bech32"),fs("bech32m"),Vu(es(4),qu("0123456789abcdef"),zu(""),Xu((t=>{if("string"!=typeof t||t.length%2!=0)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})));var ps=class extends Error{issues;constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function ds(t){return{kind:"validation",type:"integer",reference:ds,async:!1,expects:null,requirement:Number.isInteger,message:t,_run(t,e){return t.typed&&!this.requirement(t.value)&&hs(this,"integer",t,e),t}}}function ys(t,e){return{kind:"validation",type:"length",reference:ys,async:!1,expects:`${t}`,requirement:t,message:e,_run(t,e){return t.typed&&t.value.length!==this.requirement&&hs(this,"length",t,e,{received:`${t.value.length}`}),t}}}function gs(t,e){return{kind:"validation",type:"max_value",reference:gs,async:!1,expects:`<=${t instanceof Date?t.toJSON():ls(t)}`,requirement:t,message:e,_run(t,e){return t.typed&&t.value>this.requirement&&hs(this,"value",t,e,{received:t.value instanceof Date?t.value.toJSON():ls(t.value)}),t}}}function bs(t,e){return{kind:"validation",type:"min_value",reference:bs,async:!1,expects:`>=${t instanceof Date?t.toJSON():ls(t)}`,requirement:t,message:e,_run(t,e){return t.typed&&t.value<this.requirement&&hs(this,"value",t,e,{received:t.value instanceof Date?t.value.toJSON():ls(t.value)}),t}}}function vs(t,e){return{kind:"schema",type:"instance",reference:vs,expects:t.name,async:!1,class:t,message:e,_run(t,e){return t.value instanceof this.class?t.typed=!0:hs(this,"type",t,e),t}}}function ws(t){return{kind:"schema",type:"number",reference:ws,expects:"number",async:!1,message:t,_run(t,e){return"number"!=typeof t.value||isNaN(t.value)?hs(this,"type",t,e):t.typed=!0,t}}}function ms(t,e){return{kind:"schema",type:"object",reference:ms,expects:"Object",async:!1,entries:t,message:e,_run(t,e){const r=t.value;if(r&&"object"==typeof r){t.typed=!0,t.value={};for(const n in this.entries){const i=r[n],o=this.entries[n]._run({typed:!1,value:i},e);if(o.issues){const a={type:"object",origin:"value",input:r,key:n,value:i};for(const e of o.issues)e.path?e.path.unshift(a):e.path=[a],t.issues?.push(e);if(t.issues||(t.issues=o.issues),e.abortEarly){t.typed=!1;break}}o.typed||(t.typed=!1),(void 0!==o.value||n in r)&&(t.value[n]=o.value)}}else hs(this,"type",t,e);return t}}}function _s(t,e,r){const n=t._run({typed:!1,value:e},function(t){return{lang:t?.lang??void 0,message:t?.message,abortEarly:t?.abortEarly??void 0,abortPipeEarly:t?.abortPipeEarly??void 0}}(r));if(n.issues)throw new ps(n.issues);return n.value}function Es(...t){return{...t[0],pipe:t,_run(e,r){for(const n of t)if("metadata"!==n.kind){if(e.issues&&("schema"===n.kind||"transformation"===n.kind)){e.typed=!1;break}e.issues&&(r.abortEarly||r.abortPipeEarly)||(e=n._run(e,r))}return e}}}const Ss=Es(ws(),ds(),bs(0),gs(4294967295)),ks=Es(ws(),ds(),bs(0),gs(2147483647)),Os=Es(ws(),ds(),bs(0),gs(255)),Ts=Es(vs(Uint8Array),ys(32)),xs=Es(vs(Uint8Array),ys(33)),As=ms({wif:Os,bip32:ms({public:Ss,private:Ss})}),Ps=Es(function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,_run(t,e){return"string"==typeof t.value?t.typed=!0:hs(this,"type",t,e),t}}}(),function t(e,r){return{kind:"validation",type:"regex",reference:t,async:!1,expects:`${e}`,requirement:e,message:r,_run(t,e){return t.typed&&!this.requirement.test(t.value)&&hs(this,"format",t,e),t}}}(/^(m\/)?(\d+'?\/)*\d+'?$/)),Is=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let t=0;t<e.length;t++)e[t]=255;for(let r=0;r<t.length;r++){const n=t.charAt(r),i=n.charCodeAt(0);if(255!==e[i])throw new TypeError(n+" is ambiguous");e[i]=r}const r=t.length,n=t.charAt(0),i=Math.log(r)/Math.log(256),o=Math.log(256)/Math.log(r);function a(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;let o=0,a=0,u=0;for(;t[o]===n;)a++,o++;const s=(t.length-o)*i+1>>>0,c=new Uint8Array(s);for(;t[o];){let n=e[t.charCodeAt(o)];if(255===n)return;let i=0;for(let t=s-1;(0!==n||i<u)&&-1!==t;t--,i++)n+=r*c[t]>>>0,c[t]=n%256>>>0,n=n/256>>>0;if(0!==n)throw new Error("Non-zero carry");u=i,o++}let f=s-u;for(;f!==s&&0===c[f];)f++;const l=new Uint8Array(a+(s-f));let h=a;for(;f!==s;)l[h++]=c[f++];return l}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";let i=0,a=0,u=0;const s=e.length;for(;u!==s&&0===e[u];)u++,i++;const c=(s-u)*o+1>>>0,f=new Uint8Array(c);for(;u!==s;){let t=e[u],n=0;for(let e=c-1;(0!==t||n<a)&&-1!==e;e--,n++)t+=256*f[e]>>>0,f[e]=t%r>>>0,t=t/r>>>0;if(0!==t)throw new Error("Non-zero carry");a=n,u++}let l=c-a;for(;l!==c&&0===f[l];)l++;let h=n.repeat(i);for(;l<c;++l)h+=t.charAt(f[l]);return h},decodeUnsafe:a,decode:function(t){const e=a(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Ls=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),n=t(r),i=r.length+4,o=new Uint8Array(i);return o.set(r,0),o.set(n.subarray(0,4),r.length),Is.encode(o)},decode:function(t){var r=e(Is.decode(t));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=Is.decodeUnsafe(t);if(null!=r)return e(r)}}}((function(t){return yu(yu(t))}));const Bs=os(yu);var Rs=i(8700);const js=2n**256n,Ns=js-0x1000003d1n,Us=js-0x14551231950b75fc4402da1732fc9bebfn,Cs=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Fs=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,Ms={p:Ns,n:Us,a:0n,b:7n,Gx:Cs,Gy:Fs},Ds=t=>Xs(Xs(t*t)*t+Ms.b),Hs=(t="")=>{throw new Error(t)},Ks=t=>"bigint"==typeof t,Gs=t=>"string"==typeof t,Ws=t=>Ks(t)&&0n<t&&t<Ns,Vs=t=>Ks(t)&&0n<t&&t<Us,qs=(t,e)=>!(t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name)(t)||"number"==typeof e&&e>0&&t.length!==e?Hs("Uint8Array expected"):t,zs=t=>new Uint8Array(t),Ys=(t,e)=>qs(Gs(t)?nc(t):zs(qs(t)),e),Xs=(t,e=Ns)=>{const r=t%e;return r>=0n?r:e+r},Zs=t=>t instanceof $s?t:Hs("Point expected");class $s{constructor(t,e,r){this.px=t,this.py=e,this.pz=r,Object.freeze(this)}static fromAffine(t){return 0n===t.x&&0n===t.y?Qs:new $s(t.x,t.y,1n)}static fromHex(t){let e;const r=(t=Ys(t))[0],n=t.subarray(1),i=oc(n,0,32),o=t.length;if(33===o&&[2,3].includes(r)){Ws(i)||Hs("Point hex invalid: x not FE");let t=fc(Ds(i));!(1&~r)!=(1n===(1n&t))&&(t=Xs(-t)),e=new $s(i,t,1n)}return 65===o&&4===r&&(e=new $s(i,oc(n,32,64),1n)),e?e.ok():Hs("Point invalid: not on curve")}static fromPrivateKey(t){return Js.mul(lc(t))}get x(){return this.aff().x}get y(){return this.aff().y}equals(t){const{px:e,py:r,pz:n}=this,{px:i,py:o,pz:a}=Zs(t),u=Xs(e*a),s=Xs(i*n),c=Xs(r*a),f=Xs(o*n);return u===s&&c===f}negate(){return new $s(this.px,Xs(-this.py),this.pz)}double(){return this.add(this)}add(t){const{px:e,py:r,pz:n}=this,{px:i,py:o,pz:a}=Zs(t),{a:u,b:s}=Ms;let c=0n,f=0n,l=0n;const h=Xs(3n*s);let p=Xs(e*i),d=Xs(r*o),y=Xs(n*a),g=Xs(e+r),b=Xs(i+o);g=Xs(g*b),b=Xs(p+d),g=Xs(g-b),b=Xs(e+n);let v=Xs(i+a);return b=Xs(b*v),v=Xs(p+y),b=Xs(b-v),v=Xs(r+n),c=Xs(o+a),v=Xs(v*c),c=Xs(d+y),v=Xs(v-c),l=Xs(u*b),c=Xs(h*y),l=Xs(c+l),c=Xs(d-l),l=Xs(d+l),f=Xs(c*l),d=Xs(p+p),d=Xs(d+p),y=Xs(u*y),b=Xs(h*b),d=Xs(d+y),y=Xs(p-y),y=Xs(u*y),b=Xs(b+y),p=Xs(d*b),f=Xs(f+p),p=Xs(v*b),c=Xs(g*c),c=Xs(c-p),p=Xs(g*d),l=Xs(v*l),l=Xs(l+p),new $s(c,f,l)}mul(t,e=!0){if(!e&&0n===t)return Qs;if(Vs(t)||Hs("scalar invalid"),this.equals(Js))return gc(t).p;let r=Qs,n=Js;for(let i=this;t>0n;i=i.double(),t>>=1n)1n&t?r=r.add(i):e&&(n=n.add(i));return r}mulAddQUns(t,e,r){return this.mul(e,!1).add(t.mul(r,!1)).ok()}toAffine(){const{px:t,py:e,pz:r}=this;if(this.equals(Qs))return{x:0n,y:0n};if(1n===r)return{x:t,y:e};const n=cc(r,Ns);return 1n!==Xs(r*n)&&Hs("inverse invalid"),{x:Xs(t*n),y:Xs(e*n)}}assertValidity(){const{x:t,y:e}=this.aff();return Ws(t)&&Ws(e)||Hs("Point invalid: x or y"),Xs(e*e)===Ds(t)?this:Hs("Point invalid: not on curve")}multiply(t){return this.mul(t)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(t=!0){const{x:e,y:r}=this.aff();return(t?0n===(1n&r)?"02":"03":"04")+uc(e)+(t?"":uc(r))}toRawBytes(t=!0){return nc(this.toHex(t))}}$s.BASE=new $s(Cs,Fs,1n),$s.ZERO=new $s(0n,1n,0n);const{BASE:Js,ZERO:Qs}=$s,tc=(t,e)=>t.toString(16).padStart(e,"0"),ec=t=>Array.from(qs(t)).map((t=>tc(t,2))).join(""),rc=t=>t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0,nc=t=>{const e="hex invalid";if(!Gs(t))return Hs(e);const r=t.length,n=r/2;if(r%2)return Hs(e);const i=zs(n);for(let r=0,o=0;r<n;r++,o+=2){const n=rc(t.charCodeAt(o)),a=rc(t.charCodeAt(o+1));if(void 0===n||void 0===a)return Hs(e);i[r]=16*n+a}return i},ic=t=>BigInt("0x"+(ec(t)||"0")),oc=(t,e,r)=>ic(t.slice(e,r)),ac=t=>Ks(t)&&t>=0n&&t<js?nc(tc(t,64)):Hs("bigint expected"),uc=t=>ec(ac(t)),sc=(...t)=>{const e=zs(t.reduce(((t,e)=>t+qs(e).length),0));let r=0;return t.forEach((t=>{e.set(t,r),r+=t.length})),e},cc=(t,e)=>{(0n===t||e<=0n)&&Hs("no inverse n="+t+" mod="+e);let r=Xs(t,e),n=e,i=0n,o=1n,a=1n,u=0n;for(;0n!==r;){const t=n/r,e=n%r,s=i-a*t,c=o-u*t;n=r,r=e,i=a,o=u,a=s,u=c}return 1n===n?Xs(i,e):Hs("no inverse")},fc=t=>{let e=1n;for(let r=t,n=(Ns+1n)/4n;n>0n;n>>=1n)1n&n&&(e=e*r%Ns),r=r*r%Ns;return Xs(e*e)===t?e:Hs("sqrt invalid")},lc=t=>(Ks(t)||(t=ic(Ys(t,32))),Vs(t)?t:Hs("private key invalid 3")),hc=()=>"object"==typeof globalThis&&"crypto"in globalThis&&"subtle"in globalThis.crypto?globalThis.crypto:void 0;let pc;const dc={hexToBytes:nc,bytesToHex:ec,concatBytes:sc,bytesToNumberBE:ic,numberToBytesBE:ac,mod:Xs,invert:cc,hmacSha256Async:async(t,...e)=>{const r=hc(),n=r&&r.subtle;if(!n)return Hs("etc.hmacSha256Async not set");const i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return zs(await n.sign("HMAC",i,sc(...e)))},hmacSha256Sync:pc,hashToPrivateKey:t=>{((t=Ys(t)).length<40||t.length>1024)&&Hs("expected 40-1024b");const e=Xs(ic(t),Us-1n);return ac(e+1n)},randomBytes:(t=32)=>{const e=hc();return e&&e.getRandomValues||Hs("crypto.getRandomValues must be defined"),e.getRandomValues(zs(t))}};let yc;Object.defineProperties(dc,{hmacSha256Sync:{configurable:!1,get:()=>pc,set(t){pc||(pc=t)}}});const gc=t=>{const e=yc||(yc=(()=>{const t=[];let e=Js,r=e;for(let n=0;n<33;n++){r=e,t.push(r);for(let n=1;n<128;n++)r=r.add(e),t.push(r);e=r.double()}return t})()),r=(t,e)=>{let r=e.negate();return t?r:e};let n=Qs,i=Js;const o=BigInt(255),a=BigInt(8);for(let u=0;u<33;u++){const s=128*u;let c=Number(t&o);t>>=a,c>128&&(c-=256,t+=1n);const f=s,l=s+Math.abs(c)-1,h=u%2!=0,p=c<0;0===c?i=i.add(r(h,e[f])):n=n.add(r(p,e[l]))}return{p:n,f:i}};var bc=i(8287).Buffer;function vc(t){return vc="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},vc(t)}function wc(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,_c(n.key),n)}}function mc(t,e,r){return(e=_c(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _c(t){var e=function(t){if("object"!=vc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=vc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==vc(e)?e:e+""}ba(Ua);var Ec=function(t){!function(t){if(Uu(t.isPoint(Nu("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Uu(!t.isPoint(Nu("030000000000000000000000000000000000000000000000000000000000000005"))),Uu(t.isPrivate(Nu("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Uu(t.isPrivate(Nu("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),Uu(!t.isPrivate(Nu("0000000000000000000000000000000000000000000000000000000000000000"))),Uu(!t.isPrivate(Nu("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),Uu(!t.isPrivate(Nu("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),Uu(0===Lu(t.pointFromScalar(Nu("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")),Nu("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),t.xOnlyPointAddTweak){Uu(null===t.xOnlyPointAddTweak(Nu("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Nu("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")));let e=t.xOnlyPointAddTweak(Nu("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),Nu("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));Uu(0===Lu(e.xOnlyPubkey,Nu("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&1===e.parity),e=t.xOnlyPointAddTweak(Nu("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),Nu("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47"))}Uu(0===Lu(t.pointAddScalar(Nu("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Nu("0000000000000000000000000000000000000000000000000000000000000003")),Nu("02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"))),Uu(0===Lu(t.privateAdd(Nu("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),Nu("0000000000000000000000000000000000000000000000000000000000000002")),Nu("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),t.privateNegate&&(Uu(0===Lu(t.privateNegate(Nu("0000000000000000000000000000000000000000000000000000000000000001")),Nu("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),Uu(0===Lu(t.privateNegate(Nu("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e")),Nu("0000000000000000000000000000000000000000000000000000000000000003"))),Uu(0===Lu(t.privateNegate(Nu("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af")),Nu("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")))),Uu(0===Lu(t.sign(Nu("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),Nu("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")),Nu("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),Uu(t.verify(Nu("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),Nu("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Nu("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),t.signSchnorr&&Uu(0===Lu(t.signSchnorr(Nu("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),Nu("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),Nu("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906")),Nu("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),t.verifySchnorr&&Uu(t.verifySchnorr(Nu("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),Nu("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),Nu("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}(t);const e={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},r=2147483648;class n{__D;__Q;lowR=!1;constructor(t,e){this.__D=t,this.__Q=e}get publicKey(){return void 0===this.__Q&&(this.__Q=t.pointFromScalar(this.__D,!0)),this.__Q}get privateKey(){return this.__D}sign(e,r){if(!this.privateKey)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return t.sign(e,this.privateKey);{let r=t.sign(e,this.privateKey);const n=new Uint8Array(32);let i=0;for(;r[0]>127;)i++,Ru(n,0,i,"LE"),r=t.sign(e,this.privateKey,n);return r}}signSchnorr(e){if(!this.privateKey)throw new Error("Missing private key");if(!t.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return t.signSchnorr(e,this.privateKey)}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}}class i extends n{chainCode;network;__DEPTH;__INDEX;__PARENT_FINGERPRINT;constructor(t,e,r,n,i=0,o=0,a=0){super(t,e),this.chainCode=r,this.network=n,this.__DEPTH=i,this.__INDEX=o,this.__PARENT_FINGERPRINT=a,_s(As,n)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return t=this.publicKey,fu(yu(t));var t}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return void 0===this.__D}neutered(){return u(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const t=this.network,e=this.isNeutered()?t.bip32.public:t.bip32.private,r=new Uint8Array(78);return Ru(r,0,e,"BE"),Bu(r,4,this.depth),Ru(r,5,this.parentFingerprint,"BE"),Ru(r,9,this.index,"BE"),r.set(this.chainCode,13),this.isNeutered()?r.set(this.publicKey,45):(Bu(r,45,0),r.set(this.privateKey,46)),n=r,Bs.encode(n);var n}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return t={version:this.network.wif,privateKey:this.privateKey,compressed:!0},Ls.encode(function(t,e,r){if(32!==e.length)throw new TypeError("Invalid privateKey length");var n=new Uint8Array(r?34:33);return new DataView(n.buffer).setUint8(0,t),n.set(e,1),r&&(n[33]=1),n}(t.version,t.privateKey,t.compressed));var t}derive(e){_s(Ss,e);const n=e>=r,i=new Uint8Array(37);if(n){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");i[0]=0,i.set(this.privateKey,1),Ru(i,33,e,"BE")}else i.set(this.publicKey,0),Ru(i,33,e,"BE");const o=xu(this.chainCode,i),s=o.slice(0,32),c=o.slice(32);if(!t.isPrivate(s))return this.derive(e+1);let f;if(this.isNeutered()){const r=t.pointAddScalar(this.publicKey,s,!0);if(null===r)return this.derive(e+1);f=u(r,c,this.network,this.depth+1,e,ju(this.fingerprint,0,"BE"))}else{const r=t.privateAdd(this.privateKey,s);if(null==r)return this.derive(e+1);f=a(r,c,this.network,this.depth+1,e,ju(this.fingerprint,0,"BE"))}return f}deriveHardened(t){if("number"==typeof _s(ks,t))return this.derive(t+r);throw new TypeError("Expected UInt31, got "+t)}derivePath(t){_s(Ps,t);let e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new TypeError("Expected master, got child");e=e.slice(1)}return e.reduce(((t,e)=>{let r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))}),this)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}tweakFromPublicKey(e){const r=32===(i=this.publicKey).length?i:i.slice(1,33);var i;if(!t.xOnlyPointAddTweak)throw new Error("xOnlyPointAddTweak not supported by ecc library");const o=t.xOnlyPointAddTweak(r,e);if(!o||null===o.xOnlyPubkey)throw new Error("Cannot tweak public key!");const a=function(t){const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);let n=0;for(const e of t)r.set(e,n),n+=e.length;return r}([Uint8Array.from([0===o.parity?2:3]),o.xOnlyPubkey]);return new n(void 0,a)}tweakFromPrivateKey(e){const r=3===this.publicKey[0]||4===this.publicKey[0]&&!(1&~this.publicKey[64]),i=(()=>{if(r){if(t.privateNegate)return t.privateNegate(this.privateKey);throw new Error("privateNegate not supported by ecc library")}return this.privateKey})(),o=t.privateAdd(i,e);if(!o)throw new Error("Invalid tweaked private key!");return new n(o,void 0)}}function o(t,e,r){return a(t,e,r)}function a(r,n,o,a,u,s){if(_s(Ts,r),_s(Ts,n),o=o||e,!t.isPrivate(r))throw new TypeError("Private key not in range [1, n)");return new i(r,void 0,n,o,a,u,s)}function u(r,n,o,a,u,s){if(_s(xs,r),_s(Ts,n),o=o||e,!t.isPoint(r))throw new TypeError("Point is not on the curve");return new i(void 0,r,n,o,a,u,s)}return{fromSeed:function(t,r){if(_s(vs(Uint8Array),t),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");r=r||e;const n=xu(Iu.encode("Bitcoin seed"),t);return o(n.slice(0,32),n.slice(32),r)},fromBase58:function(t,r){const n=(i=t,Bs.decode(i));var i;if(78!==n.length)throw new TypeError("Invalid buffer length");r=r||e;const o=ju(n,0,"BE");if(o!==r.bip32.private&&o!==r.bip32.public)throw new TypeError("Invalid network version");const s=n[4],c=ju(n,5,"BE");if(0===s&&0!==c)throw new TypeError("Invalid parent fingerprint");const f=ju(n,9,"BE");if(0===s&&0!==f)throw new TypeError("Invalid index");const l=n.slice(13,45);let h;if(o===r.bip32.private){if(0!==n[45])throw new TypeError("Invalid private key");h=a(n.slice(46,78),l,r,s,f,c)}else h=u(n.slice(45,78),l,r,s,f,c);return h},fromPublicKey:function(t,e,r){return u(t,e,r)},fromPrivateKey:o}};if(!Ec)throw new Error("Failed to load BIP32 library");var Sc,kc=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&wc(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"fromWIF",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin;return this.ECPair.fromWIF(t,e)}},{key:"fromPrivateKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin;return this.ECPair.fromPrivateKey(bc.isBuffer(t)?t:bc.from(t),{network:e})}},{key:"fromPublicKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin,r=bc.isBuffer(t)?t:bc.from(t);return this.ECPair.fromPublicKey(r,{network:e})}},{key:"generateMultiSigAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Oa.bitcoin,n=this.verifyPubKeys(t,r);if(n.length!==t.length)throw new Error("Contains invalid public keys");var i=xa.p2ms({m:e,pubkeys:n,network:r}),o=xa.p2wsh({redeem:i,network:r}).address;if(!o)throw new Error("Failed to generate address");return o}},{key:"verifyPubKeys",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin;return e.map((function(e){var n=t.fromPublicKey(e,r);if(!n)throw new Error("Failed to regenerate key");return bc.from(n.publicKey)}))}},{key:"getP2WPKHAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin,r=xa.p2wpkh({pubkey:bc.from(t.publicKey),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"tweakedPubKeyToAddress",value:function(e,r){e.startsWith("0x")&&(e=e.slice(2));var n=bc.from(e,"hex");return 32!==n.length&&(n=Ra(n)),t.tweakedPubKeyBufferToAddress(n,r)}},{key:"tweakedPubKeyBufferToAddress",value:function(t,e){var r=xa.p2tr({pubkey:bc.isBuffer(t)?t:bc.from(t),network:e}).address;if(!r)throw new Error("Failed to generate Taproot address");return r}},{key:"xOnlyTweakedPubKeyToAddress",value:function(t,e){t.startsWith("0x")&&(t=t.slice(2));var r=bc.from(t,"hex"),n=xa.p2tr({pubkey:r,network:e}).address;if(!n)throw new Error("Failed to generate Taproot address");return n}},{key:"tweakPublicKey",value:function(t){"string"==typeof t&&t.startsWith("0x")&&(t=t.slice(2)),"string"!=typeof t&&(t=t.toString("hex"));var e=$s.fromHex(t);0n!==(1n&e.y)&&(e=e.negate());var r=e.toRawBytes(!0).slice(1),n=La("TapTweak",bc.from(r)),i=function(t,e){var r=t%e;return r>=0n?r:r+e}(BigInt("0x"+bc.from(n).toString("hex")),Ms.n),o=e.add($s.BASE.mul(i));return bc.from(o.toRawBytes(!0))}},{key:"generateWallet",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Oa.bitcoin,e=this.ECPair.makeRandom({network:t}),r=this.getP2WPKHAddress(e,t);if(!r)throw new Error("Failed to generate wallet");return{address:r,privateKey:e.toWIF(),publicKey:bc.from(e.publicKey).toString("hex")}}},{key:"verifyContractAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin;return!!ha.toOutputScript(t,e)}},{key:"getLegacySegwitAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin,r=xa.p2sh({redeem:xa.p2wpkh({pubkey:bc.from(t.publicKey),network:e}),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"getLegacyAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin,r=xa.p2pkh({pubkey:bc.from(t.publicKey),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"getP2PKAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin,r=xa.p2pk({pubkey:bc.from(t.publicKey),network:e});if(!r.output)throw new Error("Failed to generate wallet");return"0x"+r.output.toString("hex")}},{key:"generateRandomKeyPair",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Oa.bitcoin;return this.ECPair.makeRandom({network:t})}},{key:"fromSeed",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin;return this.BIP32.fromSeed(t,e)}},{key:"getTaprootAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin,r=xa.p2tr({internalPubkey:Ra(bc.from(t.publicKey)),network:e}).address;if(!r)throw new Error("Failed to generate sender address for transaction");return r}},{key:"getTaprootAddressFromAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin,r=xa.p2tr({address:t,network:e}).address;if(!r)throw new Error("Failed to generate sender address for transaction");return r}},{key:"fromSeedKeyPair",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin,r=this.BIP32.fromSeed(t,e).privateKey;if(!r)throw new Error("Failed to generate key pair");return this.ECPair.fromPrivateKey(bc.from(r),{network:e})}}])}();function Oc(t){return Oc="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},Oc(t)}mc(kc,"BIP32",Ec(Ua)),mc(kc,"ECPair",(0,Rs.dg)(Ua)),function(t){t[t.UNWRAP=0]="UNWRAP"}(Sc||(Sc={}));var Tc=function(t,e,r){return(e=function(t){var e=function(t){if("object"!=Oc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Oc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Oc(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},Sc.UNWRAP,Ta.OP_16),xc=i(8287).Buffer;function Ac(t){return Ac="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},Ac(t)}function Pc(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,Lc(n.key),n)}}function Ic(t,e,r){return(e=Lc(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Lc(t){var e=function(t){if("object"!=Ac(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ac(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ac(e)?e:e+""}var Bc=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Oa.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ic(this,"network",Oa.bitcoin),this.senderPubKey=e,this.contractSaltPubKey=r,this.network=n,this.xSenderPubKey=Ra(e)}return function(t,e){return e&&Pc(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"senderFirstByte",get:function(){return xc.from([this.senderPubKey[0],0,0,0])}},{key:"splitBufferIntoChunks",value:function(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.DATA_CHUNK_SIZE,n=[],i=0;i<e.length;i+=r){for(var o=Math.min(r,e.length-i),a=xc.alloc(o),u=0;u<o;u++)a.writeUInt8(e[i+u],u);n.push([a])}return n}}])}();Ic(Bc,"DATA_CHUNK_SIZE",512),Ic(Bc,"MAGIC",xc.from("op","utf-8"));var Rc=i(8287).Buffer;function jc(t){return jc="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},jc(t)}function Nc(t){return function(t){if(Array.isArray(t))return Cc(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Uc(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Uc(t,e){if(t){if("string"==typeof t)return Cc(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Cc(t,e):void 0}}function Cc(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function 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,Mc(n.key),n)}}function Mc(t){var e=function(t){if("object"!=jc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=jc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jc(e)?e:e+""}function Dc(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Dc=function(){return!!t})()}function Hc(t){return Hc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Hc(t)}function Kc(t,e){return Kc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Kc(t,e)}var Gc=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Oa.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Hc(e),function(t,e){if(e&&("object"==jc(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,Dc()?Reflect.construct(e,r||[],Hc(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Kc(t,e)}(t,Bc),function(t,e,r){return e&&Fc(t.prototype,e),r&&Fc(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t,e,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");var o=this.splitBufferIntoChunks(t);if(!o.length)throw new Error("No data chunks found");var a=[this.senderFirstByte,Ta.OP_TOALTSTACK,r,Ta.OP_TOALTSTACK,this.xSenderPubKey,Ta.OP_DUP,Ta.OP_HASH256,pa.hash256(this.xSenderPubKey),Ta.OP_EQUALVERIFY,Ta.OP_CHECKSIGVERIFY,this.contractSaltPubKey,Ta.OP_CHECKSIGVERIFY,Ta.OP_HASH160,pa.hash160(e),Ta.OP_EQUALVERIFY,Ta.OP_DEPTH,Ta.OP_1,Ta.OP_NUMEQUAL,Ta.OP_IF,Bc.MAGIC],u=i.map((function(t){return Tc[t]})),s=(a=(n=a).concat.apply(n,Nc(u).concat([Ta.OP_1NEGATE].concat(Nc(o),[Ta.OP_ELSE,Ta.OP_1,Ta.OP_ENDIF])))).flat(),c=Ia.compile(s);if(!Ia.decompile(c))throw new Error("Failed to decompile script??");return c}}],[{key:"getPubKeyAsBuffer",value:function(t,e){var r,n=Rc.alloc(0),i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Uc(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(!kc.fromPublicKey(o,e).compressed)throw new Error("Public key must be compressed");if(33!==o.byteLength)throw new Error("Public key must be 33 bytes, got ".concat(o.byteLength," bytes."));n=Rc.concat([n,o])}}catch(t){i.e(t)}finally{i.f()}var a=p.compress(n);return a.byteLength>=n.byteLength?n:a}}])}();function Wc(t){return Wc="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},Wc(t)}function Vc(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,qc(n.key),n)}}function qc(t){var e=function(t){if("object"!=Wc(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Wc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Wc(e)?e:e+""}function zc(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(zc=function(){return!!t})()}function Yc(t){return Yc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Yc(t)}function Xc(t,e){return Xc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Xc(t,e)}var Zc=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Yc(e),function(t,e){if(e&&("object"==Wc(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,zc()?Reflect.construct(e,r||[],Yc(t).constructor):e.apply(t,r))}(this,t,[e,void 0,r])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Xc(t,e)}(t,Bc),function(t,e){return e&&Vc(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t){var e=t.flat(),r=Ia.compile(e);if(!Ia.decompile(r))throw new Error("Failed to decompile script??");return r}}])}();function $c(t){return $c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$c(t)}function Jc(t){return function(t){if(Array.isArray(t))return Qc(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Qc(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Qc(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qc(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function tf(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,ef(n.key),n)}}function ef(t){var e=function(t){if("object"!=$c(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=$c(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$c(e)?e:e+""}function rf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(rf=function(){return!!t})()}function nf(t){return nf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},nf(t)}function of(t,e){return of=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},of(t,e)}var af=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Oa.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=nf(e),function(t,e){if(e&&("object"==$c(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,rf()?Reflect.construct(e,r||[],nf(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&of(t,e)}(t,Bc),function(t,e){return e&&tf(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t,e,r,n){var i=this.getAsm(t,e,r,n),o=Ia.compile(i);if(!Ia.decompile(o))throw new Error("Failed to decompile script??");return o}},{key:"getAsm",value:function(t,e,r,n){if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");var i=this.splitBufferIntoChunks(t),o=n?this.splitBufferIntoChunks(n):[];return[this.senderFirstByte,Ta.OP_TOALTSTACK,r,Ta.OP_TOALTSTACK,this.xSenderPubKey,Ta.OP_DUP,Ta.OP_HASH256,pa.hash256(this.xSenderPubKey),Ta.OP_EQUALVERIFY,Ta.OP_CHECKSIGVERIFY,this.contractSaltPubKey,Ta.OP_CHECKSIGVERIFY,Ta.OP_HASH256,pa.hash256(e),Ta.OP_EQUALVERIFY,Ta.OP_DEPTH,Ta.OP_1,Ta.OP_NUMEQUAL,Ta.OP_IF,Bc.MAGIC,Ta.OP_0].concat(Jc(o),[Ta.OP_1NEGATE],Jc(i),[Ta.OP_ELSE,Ta.OP_1,Ta.OP_ENDIF]).flat()}}])}(),uf=i(8287).Buffer;function sf(t){return sf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sf(t)}function cf(t){return function(t){if(Array.isArray(t))return lf(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ff(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ff(t,e){if(t){if("string"==typeof t)return lf(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?lf(t,e):void 0}}function lf(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function hf(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,pf(n.key),n)}}function pf(t){var e=function(t){if("object"!=sf(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sf(e)?e:e+""}function df(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(df=function(){return!!t})()}function yf(t){return yf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},yf(t)}function gf(t,e){return gf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},gf(t,e)}var bf=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=yf(e),function(t,e){if(e&&("object"==sf(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,df()?Reflect.construct(e,r||[],yf(t).constructor):e.apply(t,r))}(this,t,[e,uf.alloc(0),r])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&gf(t,e)}(t,Bc),function(t,e,r){return e&&hf(t.prototype,e),r&&hf(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,u=this.splitBufferIntoChunks(e);if(!u.length)throw new Error("No data chunks found");var s=[this.senderPubKey,Ta.OP_DUP,Ta.OP_HASH256,pa.hash256(this.senderPubKey),Ta.OP_EQUALVERIFY,Ta.OP_CHECKSIGVERIFY,r,Ta.OP_TOALTSTACK,Ta.OP_DEPTH,Ta.OP_1,Ta.OP_NUMEQUAL,Ta.OP_IF,Bc.MAGIC];if(o.length>0){var c,f,l=t.getPubKeyAsBuffer(o,this.network),h=this.splitBufferIntoChunks(l);if(s=(c=s).concat.apply(c,[Ta.OP_0].concat(cf(h))),!a)throw new Error("Minimum signatures must be provided");if(a>255)throw new Error("Minimum signatures cannot exceed 255");var p=uf.alloc(2);p.writeUint16LE(a,0),s=(f=s).concat.apply(f,[Ta.OP_1,p])}var d=i.map((function(t){return Tc[t]})),y=(s=(n=s).concat.apply(n,cf(d).concat([Ta.OP_1NEGATE].concat(cf(u),[Ta.OP_ELSE,Ta.OP_1,Ta.OP_ENDIF])))).flat(),g=Ia.compile(y);if(!Ia.decompile(g))throw new Error("Failed to decompile script??");return g}}],[{key:"getPubKeyAsBuffer",value:function(t,e){var r,n=uf.alloc(0),i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=ff(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(!kc.fromPublicKey(o,e).compressed)throw new Error("Public key must be compressed");if(33!==o.byteLength)throw new Error("Public key must be 33 bytes, got ".concat(o.byteLength," bytes."));n=uf.concat([n,o])}}catch(t){i.e(t)}finally{i.f()}var a=p.compress(n);return a.byteLength>=n.byteLength?n:a}}])}(),vf=i(8287).Buffer;function wf(t){return wf="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},wf(t)}function mf(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function _f(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ef(n.key),n)}}function Ef(t){var e=function(t){if("object"!=wf(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=wf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wf(e)?e:e+""}var Sf=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&_f(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"compile",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;if(r<2)throw new Error("Minimum signatures must be greater than 1");if(e.length<r)throw new Error("The amount of public keys is lower than the minimum required");if(r>t.MAXIMUM_SUPPORTED_SIGNATURE)throw new Error("The maximum amount of signatures is ".concat(t.MAXIMUM_SUPPORTED_SIGNATURE));var i=vf.alloc(1);i.writeUInt8(r),e=(e=e.filter((function(t,e,r){return e===r.findIndex((function(e){return t.equals(e)}))}))).sort((function(t,e){return t.compare(e)}));var o=!1,a=e.map((function(t){var e=Ra(t);return n&&!o&&(o=n.equals(e)),e}));n&&!o&&a.push(n);var u=[Ta.OP_0].concat(function(t){return function(t){if(Array.isArray(t))return mf(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return mf(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?mf(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(a.flatMap((function(t){return[t,Ta.OP_CHECKSIGADD]}))),[i,Ta.OP_NUMEQUAL]).flat(),s=Ia.compile(u);if(!Ia.decompile(s))throw new Error("Failed to decompile script.");return s}}])}();!function(t,e){(e=Ef(e))in t?Object.defineProperty(t,e,{value:255,enumerable:!0,configurable:!0,writable:!0}):t[e]=255}(Sf,"MAXIMUM_SUPPORTED_SIGNATURE");var kf=i(8287).Buffer;function Of(t){return Of="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},Of(t)}function Tf(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,xf(n.key),n)}}function xf(t){var e=function(t){if("object"!=Of(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Of(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Of(e)?e:e+""}function Af(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Af=function(){return!!t})()}function Pf(t){return Pf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Pf(t)}function If(t,e){return If=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},If(t,e)}var Lf=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Pf(e),function(t,e){if(e&&("object"==Of(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,Af()?Reflect.construct(e,r||[],Pf(t).constructor):e.apply(t,r))}(this,t,[e,kf.alloc(0),r])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&If(t,e)}(t,Bc),function(t,e){return e&&Tf(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t){var e=(this.isTestnet()?[t,Ta.OP_SHA1,Ta.OP_SHA1,Ta.OP_SWAP,Ta.OP_SHA1,Ta.OP_SHA1,Ta.OP_EQUAL]:[t,Ta.OP_SWAP,Ta.OP_2DUP,Ta.OP_EQUAL,Ta.OP_NOT,Ta.OP_VERIFY,Ta.OP_SHA1,Ta.OP_SHA1,Ta.OP_SWAP,Ta.OP_SHA1,Ta.OP_SHA1,Ta.OP_EQUAL]).flat(),r=Ia.compile(e);if(!Ia.decompile(r))throw new Error("Failed to decompile script??");return r}},{key:"isTestnet",value:function(){return this.network===Oa.testnet||this.network===Oa.regtest}}])}(),Bf=i(8287).Buffer;function Rf(t){return Rf="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},Rf(t)}function jf(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Nf(n.key),n)}}function Nf(t){var e=function(t){if("object"!=Rf(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Rf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Rf(e)?e:e+""}var Uf=function(){return function(t,e,r){return r&&jf(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"generateMineableReward",value:function(t,e){var r,n,i=new Lf(Bf.alloc(0),e).compile(t),o=ya.payments.p2sh({redeem:{output:i},network:e});if(!(null===(r=o.redeem)||void 0===r?void 0:r.output))throw new Error("Output redeem is required");if(!o.address)throw new Error("P2SH address is required");var a=null==o||null===(n=o.redeem)||void 0===n?void 0:n.output;if(!a)throw new Error("No redeem output");return{address:o.address,p2shOutputScript:a,redeemScript:i}}}])}(),Cf=i(2343);function Ff(t){return Ff="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},Ff(t)}function Mf(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,Df(n.key),n)}}function Df(t){var e=function(t){if("object"!=Ff(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ff(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ff(e)?e:e+""}ba(Ua);var Hf,Kf=function(){return function(t,e,r){return r&&Mf(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"generatePKSH",value:function(t,e){if(32!==t.length)throw new Error("Invalid hash length");var r=Pa(t);return this.toSegwitAddress(r,e)}},{key:"generateTaprootAddress",value:function(t,e){if(32!==t.length)throw new Error("Invalid public key length");var r=Cf.p2.toWords(t);return r.unshift(1),Cf.p2.encode(e.bech32,r)}},{key:"toSegwitAddress",value:function(t,e){var r=Cf.I.toWords(t);return r.unshift(0),Cf.I.encode(e.bech32,r)}}])}(),Gf=i(8287).Buffer;function Wf(t){return Wf="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},Wf(t)}function Vf(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,qf(n.key),n)}}function qf(t){var e=function(t){if("object"!=Wf(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Wf(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Wf(e)?e:e+""}ba(Ua),function(t){t.P2PKH="P2PKH",t.P2SH_OR_P2SH_P2WPKH="P2SH_OR_P2SH-P2WPKH",t.P2PK="P2PK",t.P2TR="P2TR",t.P2WPKH="P2WPKH"}(Hf||(Hf={}));var zf=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&Vf(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"isValidP2TRAddress",value:function(t,e){if(!t||t.length<50)return!1;var r=!1;try{ha.toOutputScript(t,e),r=1===ha.fromBech32(t).version}catch(t){}return r}},{key:"isP2WPKHAddress",value:function(t,e){if(!t||t.length<20||t.length>50)return!1;var r=!1;try{var n=ha.fromBech32(t);ha.toOutputScript(t,e),r=0===n.version&&20===n.data.length}catch(t){}return r}},{key:"isP2PKHOrP2SH",value:function(t,e){try{var r=ha.fromBase58Check(t);return r.version===e.pubKeyHash||r.version===e.scriptHash}catch(t){return!1}}},{key:"isValidPublicKey",value:function(t,e){try{if(t.startsWith("0x")&&(t=t.slice(2)),!/^[0-9a-fA-F]+$/.test(t))return!1;if(64===t.length)return!0;var r=Gf.from(t,"hex");if(130===t.length&&6===r[0]||7===r[0])return!0;if(66===t.length||130===t.length)return kc.fromPublicKey(r,e),!0}catch(t){return!1}return!1}},{key:"requireRedeemScript",value:function(t,e){try{var r=ha.fromBase58Check(t);return r.version!==e.pubKeyHash&&r.version===e.scriptHash}catch(t){return!1}}},{key:"detectAddressType",value:function(e,r){if(t.isValidPublicKey(e,r))return Hf.P2PK;try{var n=ha.fromBase58Check(e);if(n.version===r.pubKeyHash)return Hf.P2PKH;if(n.version===r.scriptHash)return Hf.P2SH_OR_P2SH_P2WPKH}catch(t){}try{var i=ha.fromBech32(e);if(i.prefix===r.bech32){if(0===i.version&&20===i.data.length)return Hf.P2WPKH;if(1===i.version&&32===i.data.length)return Hf.P2TR}}catch(t){}return null}}])}(),Yf={d:(t,e)=>{for(var r in e)Yf.o(e,r)&&!Yf.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},Xf={};Yf.d(Xf,{q$:()=>$l,Vy:()=>Jl,$7:()=>Zf,rE:()=>$f});var Zf={};Yf.r(Zf),Yf.d(Zf,{DebugLevel:()=>$l,Logger:()=>Jl,version:()=>$f});var $f="1.0.2";function Jf(t,e){t=t.replace("#","");var r=parseInt(t,16),n=Math.round(2.55*e),i=(r>>16)+n,o=(r>>8&255)+n,a=(255&r)+n;return(16777216+65536*(i<255?i<1?0:i:255)+256*(o<255?o<1?0:o:255)+(a<255?a<1?0:a:255)).toString(16).slice(1)}const Qf=(t=0)=>e=>`[${e+t}m`,tl=(t=0)=>e=>`[${38+t};5;${e}m`,el=(t=0)=>(e,r,n)=>`[${38+t};2;${e};${r};${n}m`,rl={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(rl.modifier),Object.keys(rl.color),Object.keys(rl.bgColor);const nl=function(){const t=new Map;for(const[e,r]of Object.entries(rl)){for(const[e,n]of Object.entries(r))rl[e]={open:`[${n[0]}m`,close:`[${n[1]}m`},r[e]=rl[e],t.set(n[0],n[1]);Object.defineProperty(rl,e,{value:r,enumerable:!1})}return Object.defineProperty(rl,"codes",{value:t,enumerable:!1}),rl.color.close="",rl.bgColor.close="",rl.color.ansi=Qf(),rl.color.ansi256=tl(),rl.color.ansi16m=el(),rl.bgColor.ansi=Qf(10),rl.bgColor.ansi256=tl(10),rl.bgColor.ansi16m=el(10),Object.defineProperties(rl,{rgbToAnsi256:{value:(t,e,r)=>t===e&&e===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(e/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(t){const e=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!e)return[0,0,0];let[r]=e;3===r.length&&(r=[...r].map((t=>t+t)).join(""));const n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:t=>rl.rgbToAnsi256(...rl.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return t-8+90;let e,r,n;if(t>=232)e=(10*(t-232)+8)/255,r=e,n=e;else{const i=(t-=16)%36;e=Math.floor(t/36)/5,r=Math.floor(i/6)/5,n=i%6/5}const i=2*Math.max(e,r,n);if(0===i)return 30;let o=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(e));return 2===i&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(t,e,r)=>rl.ansi256ToAnsi(rl.rgbToAnsi256(t,e,r)),enumerable:!1},hexToAnsi:{value:t=>rl.ansi256ToAnsi(rl.hexToAnsi256(t)),enumerable:!1}}),rl}(),il=(()=>{if(navigator.userAgentData){const t=navigator.userAgentData.brands.find((({brand:t})=>"Chromium"===t));if(t&&t.version>93)return 3}return/\b(Chrome|Chromium)\//.test(navigator.userAgent)?1:0})(),ol=0!==il&&{level:il,hasBasic:!0,has256:il>=2,has16m:il>=3},al={stdout:ol,stderr:ol};function ul(t,e,r){let n=t.indexOf(e);if(-1===n)return t;const i=e.length;let o=0,a="";do{a+=t.slice(o,n)+e+r,o=n+i,n=t.indexOf(e,o)}while(-1!==n);return a+=t.slice(o),a}const{stdout:sl,stderr:cl}=al,fl=Symbol("GENERATOR"),ll=Symbol("STYLER"),hl=Symbol("IS_EMPTY"),pl=["ansi","ansi","ansi256","ansi16m"],dl=Object.create(null);class yl{constructor(t){return gl(t)}}const gl=t=>{const e=(...t)=>t.join(" ");return((t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=sl?sl.level:0;t.level=void 0===e.level?r:e.level})(e,t),Object.setPrototypeOf(e,bl.prototype),e};function bl(t){return gl(t)}Object.setPrototypeOf(bl.prototype,Function.prototype);for(const[t,e]of Object.entries(nl))dl[t]={get(){const r=El(this,_l(e.open,e.close,this[ll]),this[hl]);return Object.defineProperty(this,t,{value:r}),r}};dl.visible={get(){const t=El(this,this[ll],!0);return Object.defineProperty(this,"visible",{value:t}),t}};const vl=(t,e,r,...n)=>"rgb"===t?"ansi16m"===e?nl[r].ansi16m(...n):"ansi256"===e?nl[r].ansi256(nl.rgbToAnsi256(...n)):nl[r].ansi(nl.rgbToAnsi(...n)):"hex"===t?vl("rgb",e,r,...nl.hexToRgb(...n)):nl[r][t](...n),wl=["rgb","hex","ansi256"];for(const t of wl)dl[t]={get(){const{level:e}=this;return function(...r){const n=_l(vl(t,pl[e],"color",...r),nl.color.close,this[ll]);return El(this,n,this[hl])}}},dl["bg"+t[0].toUpperCase()+t.slice(1)]={get(){const{level:e}=this;return function(...r){const n=_l(vl(t,pl[e],"bgColor",...r),nl.bgColor.close,this[ll]);return El(this,n,this[hl])}}};const ml=Object.defineProperties((()=>{}),{...dl,level:{enumerable:!0,get(){return this[fl].level},set(t){this[fl].level=t}}}),_l=(t,e,r)=>{let n,i;return void 0===r?(n=t,i=e):(n=r.openAll+t,i=e+r.closeAll),{open:t,close:e,openAll:n,closeAll:i,parent:r}},El=(t,e,r)=>{const n=(...t)=>Sl(n,1===t.length?""+t[0]:t.join(" "));return Object.setPrototypeOf(n,ml),n[fl]=t,n[ll]=e,n[hl]=r,n},Sl=(t,e)=>{if(t.level<=0||!e)return t[hl]?"":e;let r=t[ll];if(void 0===r)return e;const{openAll:n,closeAll:i}=r;if(e.includes(""))for(;void 0!==r;)e=ul(e,r.close,r.open),r=r.parent;const o=e.indexOf("\n");return-1!==o&&(e=function(t,e,r,n){let i=0,o="";do{const a="\r"===t[n-1];o+=t.slice(i,a?n-1:n)+e+(a?"\r\n":"\n")+r,i=n+1,n=t.indexOf("\n",i)}while(-1!==n);return o+=t.slice(i),o}(e,i,n,o)),n+e+i};function kl(t){return kl="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},kl(t)}function Ol(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}function Tl(t,e,r){return(e=xl(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function xl(t){var e=function(t){if("object"!=kl(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=kl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==kl(e)?e:e+""}function Al(t,e){return t.get(function(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}(t,e))}Object.defineProperties(bl.prototype,dl),bl(),bl({level:cl?cl.level:0});var Pl=new WeakMap,Il=new WeakMap,Ll=new WeakMap,Bl=new WeakMap,Rl=new WeakMap,jl=new WeakMap,Nl=new WeakMap,Ul=new WeakMap,Cl=new WeakMap,Fl=new WeakMap,Ml=new WeakMap,Dl=new WeakMap,Hl=new WeakMap,Kl=new WeakMap,Gl=new WeakMap,Wl=new WeakMap,Vl=new WeakMap,ql=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new yl;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Tl(this,"moduleName",""),Tl(this,"logColor","#00bfff"),Tl(this,"enableLogs",!0),Tl(this,"hideLogs",!1),Ol(this,Pl,"#ff00ff"),Ol(this,Il,Jf(Al(Pl,this),75)),Ol(this,Ll,"#9400d3"),Ol(this,Bl,Jf(Al(Ll,this),15)),Ol(this,Rl,Jf(Al(Bl,this),15)),Ol(this,jl,"#7cfc00"),Ol(this,Nl,Jf(Al(jl,this),15)),Ol(this,Ul,"#ffdead"),Ol(this,Cl,Jf(Al(Ul,this),15)),Ol(this,Fl,"#ff8c00"),Ol(this,Ml,Jf(Al(Fl,this),15)),Ol(this,Dl,"#ff4500"),Ol(this,Hl,Jf(Al(Dl,this),15)),Ol(this,Kl,"#ffffff"),Ol(this,Gl,Jf(Al(Kl,this),15)),Ol(this,Wl,"#8b0000"),Ol(this,Vl,Jf(Al(Wl,this),15)),Tl(this,"prefix",""),this.chalk=e,this.moduleName=this.constructor.name},e=[{key:"setLogPrefix",value:function(t){this.prefix=t}},{key:"getStartPrefix",value:function(){return this.prefix}},{key:"disable",value:function(){this.enableLogs=!1}},{key:"enable",value:function(){this.enableLogs=!0}},{key:"fancyLog",value:function(t,e,r,n,i){this.enableLogs&&console.log(this.chalk.hex(Al(Pl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," INFO]: "))+this.chalk.hex(Al(Kl,this))(t)+" "+this.chalk.hex(Al(Ml,this))(e)+" "+this.chalk.hex(Al(Kl,this))(r)+" "+this.chalk.hex(Al(Rl,this))(n)+" "+this.chalk.hex(Al(Kl,this))(i))}},{key:"log",value:function(){if(this.enableLogs&&!this.hideLogs){var t=Jf(this.logColor,15);console.log(this.chalk.hex(this.logColor)("".concat(this.getStartPrefix(),"[").concat(this.moduleName," LOG]: "))+this.chalk.hex(t).apply(void 0,arguments))}}},{key:"lightOrangeLog",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(Al(Ml,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," LOG]: "))+this.chalk.hex(Al(Kl,this)).apply(void 0,arguments)))}},{key:"error",value:function(){this.enableLogs&&console.log(this.chalk.hex(Al(Dl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," ERROR]: "))+this.chalk.hex(Al(Hl,this)).apply(void 0,arguments))}},{key:"warn",value:function(){this.enableLogs&&console.log(this.chalk.hex(Al(Fl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," WARN]: "))+this.chalk.hex(Al(Ml,this)).apply(void 0,arguments))}},{key:"debug",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(Al(Ul,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," DEBUG]: "))+this.chalk.hex(Al(Cl,this)).apply(void 0,arguments)))}},{key:"success",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(Al(jl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," SUCCESS]: "))+this.chalk.hex(Al(Nl,this)).apply(void 0,arguments)))}},{key:"fail",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(Al(Dl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," FAIL]: "))+this.chalk.hex(Al(Hl,this)).apply(void 0,arguments)))}},{key:"debugBright",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(Al(Ll,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," DEBUG]: "))+this.chalk.hex(Al(Bl,this)).apply(void 0,arguments)))}},{key:"important",value:function(){this.enableLogs&&console.log(this.chalk.hex(Al(Pl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," IMPORTANT]: "))+this.chalk.hex(Al(Il,this)).apply(void 0,arguments))}},{key:"panic",value:function(){this.enableLogs&&console.log(this.chalk.hex(Al(Wl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," HELP PANIC]: "))+this.chalk.hex(Al(Vl,this)).apply(void 0,arguments))}},{key:"info",value:function(){this.enableLogs&&console.log(this.chalk.hex(Al(Pl,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," INFO]: "))+this.chalk.hex(Al(Kl,this)).apply(void 0,arguments))}},{key:"securityNotice",value:function(){this.enableLogs&&console.log(this.chalk.hex("#22d8e6")("".concat(this.getStartPrefix(),"[").concat(this.moduleName," SECURITY NOTICE]: "))+this.chalk.hex("#22e3e6").apply(void 0,arguments))}},{key:"traceLog",value:function(){this.enableLogs&&console.log(this.chalk.hex("#ffffff")("".concat(this.getStartPrefix(),"[").concat(this.moduleName," TRACE LOG]: "))+this.chalk.hex(Al(Gl,this)).apply(void 0,arguments))}}],e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,xl(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function zl(t){return zl="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},zl(t)}function Yl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Yl=function(){return!!t})()}function Xl(t){return Xl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Xl(t)}function Zl(t,e){return Zl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Zl(t,e)}var $l,Jl=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){return e=Xl(e),function(t,e){if(e&&("object"==zl(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,Yl()?Reflect.construct(e,[],Xl(t).constructor):e.apply(t,void 0))}(this,t)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Zl(t,e)}(t,ql),e=t,Object.defineProperty(e,"prototype",{writable:!1}),e;var e}();!function(t){t[t.NONE=0]="NONE",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.DEBUG=4]="DEBUG",t[t.TRACE=5]="TRACE",t[t.ALL=6]="ALL"}($l||($l={}));var Ql=Xf.Vy,th=i(8287).Buffer;function eh(t){return eh="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},eh(t)}function rh(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,nh(n.key),n)}}function nh(t){var e=function(t){if("object"!=eh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=eh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==eh(e)?e:e+""}ba(Ua);var ih=function(){return function(t,e,r){return r&&rh(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"tweakSigner",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.privateKey;if(!r)throw new Error("Private key is required for tweaking signer!");3===t.publicKey[0]&&(r=Na.privateNegate(r));var n=Na.privateAdd(r,Ba(Ra(th.from(t.publicKey)),e.tweakHash));if(!n)throw new Error("Invalid tweaked private key!");return kc.fromPrivateKey(th.from(n),e.network)}}])}();function oh(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&Ea(t.witnessUtxo.script))}function ah(t,e){if(t.nonWitnessUtxo&&!t.redeemScript&&!t.witnessScript&&!t.witnessUtxo||t.redeemScript)return!0;var r=function(t){return t.redeemScript?t.redeemScript:t.witnessScript?t.witnessScript:t.witnessUtxo?t.witnessUtxo.script:(t.nonWitnessUtxo,null)}(t);return!!r&&uh(e,r)}function uh(t,e){return-1!==Aa(t,e)}var sh,ch=i(8287).Buffer;function fh(t){return fh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fh(t)}function lh(){lh=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==fh(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(fh(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function hh(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function ph(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){hh(o,n,i,a,u,"next",t)}function u(t){hh(o,n,i,a,u,"throw",t)}a(void 0)}))}}function dh(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=gh(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}function yh(t){return function(t){if(Array.isArray(t))return bh(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||gh(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function gh(t,e){if(t){if("string"==typeof t)return bh(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?bh(t,e):void 0}}function bh(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function vh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Sh(n.key),n)}}function wh(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(wh=function(){return!!t})()}function mh(t){return mh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},mh(t)}function _h(t,e){return _h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_h(t,e)}function Eh(t,e,r){return(e=Sh(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sh(t){var e=function(t){if("object"!=fh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=fh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fh(e)?e:e+""}!function(t){t[t.REPLACE_BY_FEE=4294967293]="REPLACE_BY_FEE",t[t.FINAL=4294967295]="FINAL"}(sh||(sh={}));var kh=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Eh(r=function(t,e,r){return e=mh(e),function(t,e){if(e&&("object"==fh(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,wh()?Reflect.construct(e,r||[],mh(t).constructor):e.apply(t,r))}(this,t),"logColor","#00ffe1"),Eh(r,"finalized",!1),Eh(r,"signed",!1),Eh(r,"scriptData",null),Eh(r,"tapData",null),Eh(r,"inputs",[]),Eh(r,"sequence",sh.REPLACE_BY_FEE),Eh(r,"tapLeafScript",null),Eh(r,"isBrowser",!1),Eh(r,"regenerated",!1),Eh(r,"ignoreSignatureErrors",!1),Eh(r,"customFinalizerP2SH",(function(t,e,n,i,o,a){var u=r.inputs[t];if(o&&e.partialSig&&u&&u.redeemScript){var s=e.partialSig.map((function(t){return t.signature}))||[];return{finalScriptSig:Ia.compile([].concat(yh(s),[u.redeemScript])),finalScriptWitness:void 0}}return ga(t,e,n,i,o,a)})),r.signer=e.signer,r.network=e.network,r.nonWitnessUtxo=e.nonWitnessUtxo,r.isBrowser="undefined"!=typeof window,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&&_h(t,e)}(t,Ql),function(t,e,r){return e&&vh(t.prototype,e),r&&vh(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"ignoreSignatureError",value:function(){this.ignoreSignatureErrors=!0}},{key:"getScriptAddress",value:function(){if(!this.scriptData||!this.scriptData.address)throw new Error("Tap data is required");return this.scriptData.address}},{key:"getTransaction",value:function(){return this.transaction.extractTransaction(!1)}},{key:"getTapAddress",value:function(){if(!this.tapData||!this.tapData.address)throw new Error("Tap data is required");return this.tapData.address}},{key:"disableRBF",value:function(){if(this.signed)throw new Error("Transaction is already signed");this.sequence=sh.FINAL;var t,e=dh(this.inputs);try{for(e.s();!(t=e.n()).done;)t.value.sequence=sh.FINAL}catch(t){e.e(t)}finally{e.f()}}},{key:"getTweakerHash",value:function(){var t;return null===(t=this.tapData)||void 0===t?void 0:t.hash}},{key:"preEstimateTransactionFees",value:function(t,e,r,n,i){var o=10n+41n*e+68n*r;return(3n*o+(o+(144n*n+34n*i+(1n+35n*i+1n+n))))/4n*t}},{key:"generateTapData",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network}}},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network}}},{key:"getSignerKey",value:function(){return this.signer}},{key:"signInput",value:(a=ph(lh().mark((function t(e,r,n,i){var o,a,u,s,c,f,l=arguments;return lh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=l.length>4&&void 0!==l[4]&&l[4],a=l.length>5&&void 0!==l[5]&&l[5],u=i.publicKey,s=oh(r),o&&(s=!s),c=!1,f=!1,!s){t.next=20;break}return t.prev=8,t.next=11,this.attemptSignTaproot(e,r,n,i,u);case 11:c=!0,t.next=18;break;case 14:t.prev=14,t.t0=t.catch(8),this.error("Failed to sign Taproot script path input ".concat(n," (reverse: ").concat(o,"): ").concat(t.t0.message)),f=!0;case 18:t.next=31;break;case 20:if(!o&&!ah(r,u)){t.next=31;break}return t.prev=21,t.next=24,this.signNonTaprootInput(i,e,n);case 24:c=!0,t.next=31;break;case 27:t.prev=27,t.t1=t.catch(21),this.error("Failed to sign non-Taproot input ".concat(n,": ").concat(t.t1.stack)),f=!0;case 31:if(c){t.next=42;break}if(!f||!a){t.next=34;break}throw new Error("Failed to sign input ".concat(n," with the provided signer."));case 34:return t.prev=34,t.next=37,this.signInput(e,r,n,i,!0,f);case 37:t.next=42;break;case 39:throw t.prev=39,t.t2=t.catch(34),new Error("Cannot sign input ".concat(n," with the provided signer."));case 42:case"end":return t.stop()}}),t,this,[[8,14],[21,27],[34,39]])}))),function(t,e,r,n){return a.apply(this,arguments)})},{key:"splitArray",value:function(t,e){if(e<=0)throw new Error("Chunk size must be greater than 0.");for(var r=[],n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r}},{key:"signInputs",value:(o=ph(lh().mark((function t(e){var r,n,i,o,a,u,s,c,f,l,h;return lh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!("multiSignPsbt"in this.signer)){t.next=4;break}return t.next=3,this.signInputsWalletBased(e);case 3:return t.abrupt("return");case 4:r=e.data.inputs,n=20,i=this.splitArray(r,n),o=0;case 8:if(!(o<i.length)){t.next=18;break}for(a=i[o],u=[],s=o*n,c=0;c<a.length;c++){f=s+c,l=a[c];try{u.push(this.signInput(e,l,f,this.signer))}catch(t){this.log("Failed to sign input ".concat(f,": ").concat(t.stack))}}return t.next=15,Promise.all(u);case 15:o++,t.next=8;break;case 18:for(h=0;h<e.data.inputs.length;h++)e.finalizeInput(h,this.customFinalizerP2SH);this.finalized=!0;case 20:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"internalPubKeyToXOnly",value:function(){return Ra(ch.from(this.signer.publicKey))}},{key:"internalInit",value:function(){this.scriptData=xa.p2tr(this.generateScriptAddress()),this.tapData=xa.p2tr(this.generateTapData())}},{key:"tweakSigner",value:function(){this.tweakedSigner||(this.tweakedSigner=this.getTweakedSigner(!0))}},{key:"getTweakedSigner",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.signer,r={network:this.network};if(t&&(r.tweakHash=this.getTweakerHash()),"privateKey"in e)return ih.tweakSigner(e,r)}},{key:"generateP2SHRedeemScript",value:function(t){var e=xa.p2wsh({redeem:{output:t},network:this.network});return xa.p2sh({redeem:e,network:this.network}).output}},{key:"generateP2SHRedeemScriptLegacy",value:function(t){var e=pa.hash160(this.signer.publicKey),r=Ia.compile([Ta.OP_DUP,Ta.OP_HASH160,e,Ta.OP_EQUALVERIFY,Ta.OP_CHECKSIG]),n=pa.hash160(r),i=Ia.compile([Ta.OP_HASH160,n,Ta.OP_EQUAL]),o=xa.p2wsh({redeem:{output:r},network:this.network}),a=xa.p2sh({redeem:o,network:this.network});if(ha.fromOutputScript(i,this.network)===t&&a.redeem&&a.redeem.output)return{redeemScript:r,outputScript:a.redeem.output}}},{key:"generateP2SHP2PKHRedeemScript",value:function(t){var e,r=ch.isBuffer(this.signer.publicKey)?this.signer.publicKey:ch.from(this.signer.publicKey,"hex"),n=xa.p2wpkh({pubkey:r,network:this.network}),i=xa.p2sh({redeem:n,network:this.network}),o=i.address;if(!(null===(e=i.redeem)||void 0===e?void 0:e.output))throw new Error("Failed to generate P2SH-P2WPKH redeem script");if(o===t&&i.redeem&&i.redeem.output&&i.output)return{redeemScript:i.redeem.output,outputScript:i.output}}},{key:"generatePsbtInputExtended",value:function(e,r){var n=ch.from(e.scriptPubKey.hex,"hex"),i={hash:e.transactionId,index:e.outputIndex,sequence:this.sequence,witnessUtxo:{value:Number(e.value),script:n}};if(ma(n)){if(!e.nonWitnessUtxo)throw new Error("Missing nonWitnessUtxo for P2PKH UTXO");i.nonWitnessUtxo=ch.isBuffer(e.nonWitnessUtxo)?e.nonWitnessUtxo:ch.from(e.nonWitnessUtxo,"hex")}else if(Sa(n));else if(ka(n)){if(!e.witnessScript)throw new Error("Missing witnessScript for P2WSH UTXO");i.witnessScript=ch.isBuffer(e.witnessScript)?e.witnessScript:ch.from(e.witnessScript,"hex")}else if(_a(n)){var o;if(e.redeemScript)o=ch.isBuffer(e.redeemScript)?e.redeemScript:ch.from(e.redeemScript,"hex");else{if(!e.scriptPubKey.address)throw new Error("Missing redeemScript and no address to regenerate it for P2SH UTXO");var a=this.generateP2SHP2PKHRedeemScript(e.scriptPubKey.address);if(!a)throw new Error("Missing redeemScript for P2SH UTXO and unable to regenerate");o=a.redeemScript}i.redeemScript=o;var u=xa.p2sh({redeem:{output:i.redeemScript}});if(!u.redeem)throw new Error("Failed to extract redeem script from P2SH UTXO");var s=u.redeem.output;if(!s)throw new Error("Failed to extract redeem output from P2SH UTXO");if(e.nonWitnessUtxo&&(i.nonWitnessUtxo=ch.isBuffer(e.nonWitnessUtxo)?e.nonWitnessUtxo:ch.from(e.nonWitnessUtxo,"hex")),Sa(s))delete i.nonWitnessUtxo;else if(ka(s)){if(delete i.nonWitnessUtxo,!i.witnessScript)throw new Error("Missing witnessScript for P2SH-P2WSH UTXO")}else delete i.witnessUtxo}else if(Ea(n)){if(this.sighashTypes){var c=t.calculateSignHash(this.sighashTypes);c&&(i.sighashType=c)}this.tweakSigner(),i.tapInternalKey=this.internalPubKeyToXOnly()}else if(wa(n)||va(n)){if(!e.nonWitnessUtxo)throw new Error("Missing nonWitnessUtxo for P2PK or P2MS UTXO");i.nonWitnessUtxo=ch.isBuffer(e.nonWitnessUtxo)?e.nonWitnessUtxo:ch.from(e.nonWitnessUtxo,"hex")}else this.error("Unknown or unsupported script type for output: ".concat(e.scriptPubKey.hex));return this.tapLeafScript&&(i.tapLeafScript=[this.tapLeafScript]),0===r&&this.nonWitnessUtxo&&(i.nonWitnessUtxo=this.nonWitnessUtxo),i}},{key:"signInputsWalletBased",value:(i=ph(lh().mark((function t(e){var r,n;return lh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.signer,t.next=3,r.multiSignPsbt([e]);case 3:for(n=0;n<e.data.inputs.length;n++)e.finalizeInput(n,this.customFinalizerP2SH);this.finalized=!0;case 5:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"attemptSignTaproot",value:(n=ph(lh().mark((function t(e,r,n,i,o){var a;return lh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isTaprootScriptSpend(r,o)){t.next=6;break}return t.next=4,this.signTaprootInput(i,e,n);case 4:t.next=13;break;case 6:if(i!==this.signer?a=this.getTweakedSigner(!0,i):(this.tweakedSigner||this.tweakSigner(),a=this.tweakedSigner),!a){t.next=12;break}return t.next=10,this.signTaprootInput(a,e,n);case 10:t.next=13;break;case 12:this.error("Failed to obtain tweaked signer for input ".concat(n,"."));case 13:case"end":return t.stop()}}),t,this)}))),function(t,e,r,i,o){return n.apply(this,arguments)})},{key:"isTaprootScriptSpend",value:function(t,e){if(t.tapLeafScript&&t.tapLeafScript.length>0){var r,n=dh(t.tapLeafScript);try{for(n.s();!(r=n.n()).done;)if(uh(e,r.value.script))return!0}catch(t){n.e(t)}finally{n.f()}}return!1}},{key:"signTaprootInput",value:(r=ph(lh().mark((function t(e,r,n,i){return lh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!("signTaprootInput"in e)){t.next=11;break}return t.prev=1,t.next=4,e.signTaprootInput(r,n,i);case 4:t.next=9;break;case 6:throw t.prev=6,t.t0=t.catch(1),new Error("Failed to sign Taproot input with provided signer.");case 9:t.next=12;break;case 11:r.signTaprootInput(n,e);case 12:case"end":return t.stop()}}),t,null,[[1,6]])}))),function(t,e,n,i){return r.apply(this,arguments)})},{key:"signNonTaprootInput",value:(e=ph(lh().mark((function t(e,r,n){return lh().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!("signInput"in e)){t.next=5;break}return t.next=3,e.signInput(r,n);case 3:t.next=6;break;case 5:r.signInput(n,e);case 6:case"end":return t.stop()}}),t)}))),function(t,r,n){return e.apply(this,arguments)})}],[{key:"readScriptWitnessToWitnessStack",value:function(t){var e=0;function r(){var r=ja.decode(t,e);return e+=ja.decode.bytes,r}return function(){for(var n=r(),i=[],o=0;o<n;o++)i.push(function(r){var n=t.subarray(e,e+r);return e+=r,n}(r()));return i}()}},{key:"preEstimateTaprootTransactionFees",value:function(t,e,r,n,i,o){var a=10n+41n*e+68n*r;return(3n*a+(a+(1n*e+n*i+(arguments.length>6&&void 0!==arguments[6]?arguments[6]:32n)*e+(arguments.length>7&&void 0!==arguments[7]?arguments[7]:139n)*e+o)))/4n*t}},{key:"signInput",value:function(t,e,r,n,i){i&&i[0]&&(e.sighashType=i[0]),t.signInput(r,n,i.length?i:void 0)}},{key:"calculateSignHash",value:function(t){if(!t)throw new Error("Sighash types are required");var e,r=0,n=dh(t);try{for(n.s();!(e=n.n()).done;)r|=e.value}catch(t){n.e(t)}finally{n.f()}return r||0}}]);var e,r,n,i,o,a}(),Oh=i(8287).Buffer;function Th(t){return Th="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},Th(t)}function xh(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ah(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}function Ah(t,e){if(t){if("string"==typeof t)return Ph(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ph(t,e):void 0}}function Ph(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ih(){Ih=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==Th(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Th(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Lh(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function Bh(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Lh(o,n,i,a,u,"next",t)}function u(t){Lh(o,n,i,a,u,"throw",t)}a(void 0)}))}}function Rh(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,Mh(n.key),n)}}function jh(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(jh=function(){return!!t})()}function Nh(){return Nh="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Uh(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Nh.apply(null,arguments)}function Uh(t){return Uh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Uh(t)}function Ch(t,e){return Ch=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ch(t,e)}function Fh(t,e,r){return(e=Mh(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Mh(t){var e=function(t){if("object"!=Th(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Th(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Th(e)?e:e+""}ba(Ua);var Dh=540n,Hh=330n,Kh=function(){function t(e){var r,n;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Fh(n=function(t,e,r){return e=Uh(e),function(t,e){if(e&&("object"==Th(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,jh()?Reflect.construct(e,r||[],Uh(t).constructor):e.apply(t,r))}(this,t,[e]),"logColor","#785def"),Fh(n,"overflowFees",0n),Fh(n,"transactionFee",0n),Fh(n,"estimatedFees",0n),Fh(n,"updateInputs",[]),Fh(n,"outputs",[]),Fh(n,"feeOutput",null),Fh(n,"_maximumFeeRate",1e8),e.estimatedFees&&(n.estimatedFees=e.estimatedFees),n.signer=e.signer,n.network=e.network,n.feeRate=e.feeRate,n.priorityFee=null!==(r=e.priorityFee)&&void 0!==r?r:0n,n.utxos=e.utxos,n.to=e.to||void 0,n.isPubKeyDestination=!!n.to&&zf.isValidPublicKey(n.to,n.network),n.optionalOutputs=e.optionalOutputs,n.from=t.getFrom(e.from,n.signer,n.network),n.totalInputAmount=n.calculateTotalUTXOAmount(),n.calculateTotalVOutAmount()<n.totalInputAmount)throw new Error("Vout value is less than the value to send");return n.transaction=new fa({network:n.network}),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ch(t,e)}(t,kh),function(t,e,r){return e&&Rh(t.prototype,e),r&&Rh(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"getFundingTransactionParameters",value:(c=Bh(Ih().mark((function t(){var e;return Ih().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.estimatedFees){t.next=4;break}return t.next=3,this.estimateTransactionFees();case 3:this.estimatedFees=t.sent;case 4:return t.abrupt("return",{utxos:this.utxos,to:this.getScriptAddress(),signer:this.signer,network:this.network,feeRate:this.feeRate,priorityFee:null!==(e=this.priorityFee)&&void 0!==e?e:0n,from:this.from,amount:this.estimatedFees,optionalOutputs:this.optionalOutputs});case 5:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"setDestinationAddress",value:function(t){this.to=t}},{key:"setMaximumFeeRate",value:function(t){this._maximumFeeRate=t}},{key:"signTransaction",value:(s=Bh(Ih().mark((function t(){return Ih().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.utxos.length){t.next=2;break}throw new Error("No UTXOs specified");case 2:if(!this.to||this.isPubKeyDestination||kc.verifyContractAddress(this.to,this.network)){t.next=4;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 4:if(!this.signed){t.next=6;break}throw new Error("Transaction is already signed");case 6:return this.signed=!0,t.next=9,this.buildTransaction();case 9:return t.next=11,this.internalBuildTransaction(this.transaction);case 11:if(!t.sent){t.next=16;break}if(!this.regenerated){t.next=15;break}throw new Error("Transaction was regenerated");case 15:return t.abrupt("return",this.transaction.extractTransaction(!0,!0));case 16:throw new Error("Could not sign transaction");case 17:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"generateTransactionMinimalSignatures",value:(u=Bh(Ih().mark((function t(){var e,r,n,i,o=arguments;return Ih().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=o.length>0&&void 0!==o[0]&&o[0],!this.to||this.isPubKeyDestination||kc.verifyContractAddress(this.to,this.network)){t.next=3;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 3:return t.next=5,this.buildTransaction();case 5:if(0===this.transaction.data.inputs.length){for(r=this.getInputs(),n=this.getOutputs(),this.transaction.setMaximumFeeRate(this._maximumFeeRate),this.transaction.addInputs(r,e),i=0;i<this.updateInputs.length;i++)this.transaction.updateInput(i,this.updateInputs[i]);this.transaction.addOutputs(n)}case 6:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"signPSBT",value:(a=Bh(Ih().mark((function t(){return Ih().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signTransaction();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.transaction);case 4:throw new Error("Could not sign transaction");case 5:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"addInput",value:function(t){this.inputs.push(t)}},{key:"addOutput",value:function(e){if(0!==e.value){if(e.value<t.MINIMUM_DUST)throw new Error("Output value is less than the minimum dust ".concat(e.value," < ").concat(t.MINIMUM_DUST));this.outputs.push(e)}}},{key:"toAddress",value:function(){return this.to}},{key:"address",value:function(){var t;return null===(t=this.tapData)||void 0===t?void 0:t.address}},{key:"estimateTransactionFees",value:(o=Bh(Ih().mark((function t(){var e,r,n,i;return Ih().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.utxos.length){t.next=2;break}throw new Error("No UTXOs specified");case 2:if(!this.estimatedFees){t.next=4;break}return t.abrupt("return",this.estimatedFees);case 4:return e=new fa({network:this.network}),t.next=7,this.internalBuildTransaction(e);case 7:if(!t.sent){t.next=16;break}return r=e.extractTransaction(!0,!0),n=r.virtualSize(),i=this.feeRate*n,this.estimatedFees=BigInt(Math.ceil(i)+1),t.abrupt("return",this.estimatedFees);case 16:throw new Error("Could not build transaction to estimate fee. Something went wrong while building the transaction.");case 17:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"rebuildFromBase64",value:(i=Bh(Ih().mark((function t(e){return Ih().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.transaction=fa.fromBase64(e,{network:this.network}),this.signed=!1,this.sighashTypes=[la.SIGHASH_ANYONECANPAY,la.SIGHASH_ALL],t.next=5,this.signPSBT();case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"setPSBT",value:function(t){this.transaction=t}},{key:"getInputs",value:function(){return this.inputs}},{key:"getOutputs",value:function(){var t=function(t){return function(t){if(Array.isArray(t))return Ph(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ah(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this.outputs);return this.feeOutput&&t.push(this.feeOutput),t}},{key:"getOptionalOutputValue",value:function(){if(!this.optionalOutputs)return 0n;for(var t=0n,e=0;e<this.optionalOutputs.length;e++)t+=BigInt(this.optionalOutputs[e].value);return t}},{key:"addRefundOutput",value:(n=Bh(Ih().mark((function e(r){var n,i;return Ih().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((n=this.totalInputAmount-r)>=t.MINIMUM_DUST)){e.next=16;break}if(!zf.isValidP2TRAddress(this.from,this.network)){e.next=7;break}return e.next=5,this.setFeeOutput({value:Number(n),address:this.from,tapInternalKey:this.internalPubKeyToXOnly()});case 5:e.next=15;break;case 7:if(!zf.isValidPublicKey(this.from,this.network)){e.next=13;break}return i=Ia.compile([Oh.from(this.from.replace("0x",""),"hex"),Ta.OP_CHECKSIG]),e.next=11,this.setFeeOutput({value:Number(n),script:i});case 11:e.next=15;break;case 13:return e.next=15,this.setFeeOutput({value:Number(n),address:this.from});case 15:return e.abrupt("return");case 16:this.warn("Amount to send back (".concat(n," sat) is less than the minimum dust (").concat(t.MINIMUM_DUST," sat), it will be consumed in fees instead."));case 17:case"end":return e.stop()}}),e,this)}))),function(t){return n.apply(this,arguments)})},{key:"addValueToToOutput",value:function(e){if(e<t.MINIMUM_DUST)throw new Error("Value to send is less than the minimum dust ".concat(e," < ").concat(t.MINIMUM_DUST));var r,n=xh(this.outputs);try{for(n.s();!(r=n.n()).done;){var i=r.value;if("address"in i&&i.address===this.to)return void(i.value+=Number(e))}}catch(t){n.e(t)}finally{n.f()}throw new Error("Output not found")}},{key:"getTransactionOPNetFee",value:function(){return this.priorityFee>t.MINIMUM_DUST?this.priorityFee:t.MINIMUM_DUST}},{key:"calculateTotalUTXOAmount",value:function(){var t,e=0n,r=xh(this.utxos);try{for(r.s();!(t=r.n()).done;)e+=t.value.value}catch(t){r.e(t)}finally{r.f()}return e}},{key:"calculateTotalVOutAmount",value:function(){var t,e=0n,r=xh(this.utxos);try{for(r.s();!(t=r.n()).done;)e+=t.value.value}catch(t){r.e(t)}finally{r.f()}return e}},{key:"addOptionalOutputsAndGetAmount",value:function(){if(!this.optionalOutputs)return 0n;for(var t=0n,e=0;e<this.optionalOutputs.length;e++)this.addOutput(this.optionalOutputs[e]),t+=BigInt(this.optionalOutputs[e].value);return t}},{key:"addInputsFromUTXO",value:function(){if(this.utxos.length){if(this.totalInputAmount<t.MINIMUM_DUST)throw new Error("Total input amount is ".concat(this.totalInputAmount," sat which is less than the minimum dust ").concat(t.MINIMUM_DUST," sat."));for(var e=0;e<this.utxos.length;e++){var r=this.utxos[e],n=this.generatePsbtInputExtended(r,e);this.addInput(n)}}}},{key:"internalInit",value:function(){this.verifyUTXOValidity(),function(t,e,r){var n=Nh(Uh(t.prototype),"internalInit",r);return"function"==typeof n?function(t){return n.apply(r,t)}:n}(t,0,this)([])}},{key:"updateInput",value:function(t){this.updateInputs.push(t)}},{key:"getWitness",value:function(){if(!this.tapData||!this.tapData.witness)throw new Error("Witness is required");if(0===this.tapData.witness.length)throw new Error("Witness is empty");return this.tapData.witness[this.tapData.witness.length-1]}},{key:"getTapOutput",value:function(){if(!this.tapData||!this.tapData.output)throw new Error("Tap data is required");return this.tapData.output}},{key:"verifyUTXOValidity",value:function(){var t,e=xh(this.utxos);try{for(e.s();!(t=e.n()).done;)if(!t.value.scriptPubKey)throw new Error("Address is required")}catch(t){e.e(t)}finally{e.f()}}},{key:"setFeeOutput",value:(r=Bh(Ih().mark((function e(r){var n,i,o,a;return Ih().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.value,e.next=3,this.estimateTransactionFees();case 3:if(i=e.sent,r.value=n-Number(i),!(r.value<t.MINIMUM_DUST)){e.next=11;break}if(this.feeOutput=null,!(r.value<0)){e.next=9;break}throw new Error("setFeeOutput: Insufficient funds to pay the fees. Fee: ".concat(i," < Value: ").concat(n,". Total input: ").concat(this.totalInputAmount," sat"));case 9:e.next=20;break;case 11:return this.feeOutput=r,e.next=14,this.estimateTransactionFees();case 14:if(!((o=e.sent)>BigInt(n))){e.next=17;break}throw new Error("estimateTransactionFees: Insufficient funds to pay the fees. Fee: ".concat(o," > Value: ").concat(n,". Total input: ").concat(this.totalInputAmount," sat"));case 17:(a=n-Number(o))<t.MINIMUM_DUST?this.feeOutput=null:this.feeOutput.value=a,this.overflowFees=BigInt(a);case 20:case"end":return e.stop()}}),e,this)}))),function(t){return r.apply(this,arguments)})},{key:"internalBuildTransaction",value:(e=Bh(Ih().mark((function t(e){var r,n,i,o,a,u=arguments;return Ih().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=u.length>1&&void 0!==u[1]&&u[1],0===e.data.inputs.length){for(n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);e.addOutputs(i)}return t.prev=2,t.next=5,this.signInputs(e);case 5:return this.finalized&&(this.transactionFee=BigInt(e.getFee())),t.abrupt("return",!0);case 9:t.prev=9,t.t0=t.catch(2),a=t.t0,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack));case 13:return t.abrupt("return",!1);case 14:case"end":return t.stop()}}),t,this,[[2,9]])}))),function(t){return e.apply(this,arguments)})}],[{key:"getFrom",value:function(t,e,r){return t||kc.getTaprootAddress(e,r)}},{key:"witnessStackToScriptWitness",value:function(t){var e,r=Oh.allocUnsafe(0);function n(t){var e=r.length,n=ja.encodingLength(t);r=Oh.concat([r,Oh.allocUnsafe(n)]),ja.encode(t,r,e)}return n((e=t).length),e.forEach((function(t){n(t.length),function(t){r=Oh.concat([r,Oh.from(t)])}(t)})),r}}]);var e,r,n,i,o,a,u,s,c}();Fh(Kh,"LOCK_LEAF_SCRIPT",Ia.compile([Ta.OP_0])),Fh(Kh,"MINIMUM_DUST",50n);var Gh=i(8287).Buffer;function Wh(t){return Wh="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},Wh(t)}function Vh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,qh(n.key),n)}}function qh(t){var e=function(t){if("object"!=Wh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Wh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Wh(e)?e:e+""}var zh=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&Vh(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"getContractAddress",value:function(e){var r=e.network||Oa.bitcoin,n=[{output:new af(e.deployerPubKey,Ra(e.contractSaltPubKey),r).compile(e.bytecode,e.originalSalt,e.preimage,e.calldata),version:t.TAP_SCRIPT_VERSION},{output:Kh.LOCK_LEAF_SCRIPT,version:t.TAP_SCRIPT_VERSION}];return t.generateAddressFromScript(e,n)}},{key:"verifyControlBlock",value:function(e,r){var n=e.network||Oa.bitcoin,i=new af(e.deployerPubKey,Ra(e.contractSaltPubKey),n).compile(e.bytecode,e.originalSalt,e.preimage,e.calldata),o=[{output:i,version:t.TAP_SCRIPT_VERSION},{output:Kh.LOCK_LEAF_SCRIPT,version:t.TAP_SCRIPT_VERSION}],a=xa.p2tr({internalPubkey:Ra(e.deployerPubKey),network:n,scriptTree:o,redeem:{pubkeys:[e.deployerPubKey,e.contractSaltPubKey],output:i,redeemVersion:t.TAP_SCRIPT_VERSION}}).witness;return!(!a||0===a.length)&&a[a.length-1].equals(r)}},{key:"getContractSeed",value:function(t,e,r){var n=pa.hash256(e),i=Gh.concat([t,r,n]);return pa.hash256(i)}},{key:"generateAddressFromScript",value:function(t,e){var r=t.network||Oa.bitcoin,n={internalPubkey:Ra(t.deployerPubKey),network:r,scriptTree:e};return xa.p2tr(n).address}}])}();!function(t,e){(e=qh(e))in t?Object.defineProperty(t,e,{value:192,enumerable:!0,configurable:!0,writable:!0}):t[e]=192}(zh,"TAP_SCRIPT_VERSION");var Yh=i(8287).Buffer;function Xh(t){return Xh="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},Xh(t)}function Zh(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,$h(n.key),n)}}function $h(t){var e=function(t){if("object"!=Xh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Xh(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xh(e)?e:e+""}var Jh=function(){return function(t,e){return e&&Zh(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),[{key:"sha256",value:function(t){return pa.sha256(Yh.from(t))}},{key:"tweakAndSignMessage",value:function(t,e,r){var n=ih.tweakSigner(t,{network:r});return this.signMessage(n,e)}},{key:"signMessage",value:function(t,e){if("string"==typeof e&&(e=Yh.from(e,"utf-8")),!t.privateKey)throw new Error("Private key not found in keypair.");var r=this.sha256(e);return{signature:Na.signSchnorr(r,t.privateKey),message:r}}},{key:"verifySignature",value:function(t,e,r){if("string"==typeof e&&(e=Yh.from(e,"utf-8")),64!==r.length)throw new Error("Invalid signature length.");var n=this.sha256(e);return Na.verifySchnorr(n,Ra(Yh.from(t)),r)}},{key:"tweakAndVerifySignature",value:function(t,e,r){var n=kc.tweakPublicKey(Yh.from(t));return this.verifySignature(n,e,r)}}])}(),Qh=new Jh,tp=32,ep=4,rp=32,np=16,ip=8,op=4,ap=2,up=1,sp=32,cp=16,fp=8,lp=4,hp=2,pp=1,dp=1;function yp(t){return yp="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},yp(t)}function gp(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function bp(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,vp(n.key),n)}}function vp(t){var e=function(t){if("object"!=yp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=yp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yp(e)?e:e+""}var wp=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,mp=function(){return function(t,e){return e&&bp(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.maxTries=e}),[{key:"findOrDeriveValidPoint",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.maxTries;if(32!==t.length)throw new Error("xBytes must be exactly 32 bytes.");var n=this.bytesToBigInt(t)%wp,i=this.isValidX(n);if(e&&null===i)throw new Error("The given x is not a valid curve point.");for(var o=0;null===i;)if(n=(n+1n)%wp,i=this.isValidX(n),++o>r)throw new Error("Could not find a valid X point within ".concat(r," increments."));return{x:n,y1:i,y2:(wp-i)%wp}}},{key:"getCanonicalY",value:function(t,e){return t<e?t:e}},{key:"getHybridPublicKey",value:function(t,e){var r=e%2n===0n?6:7,n=this.bigIntTo32Bytes(t),i=this.bigIntTo32Bytes(e),o=new Uint8Array(65);return o[0]=r,o.set(n,1),o.set(i,33),o}},{key:"isValidX",value:function(t){var e=(this.modPow(t,3n,wp)+7n)%wp;return this.sqrtModP(e,wp)}},{key:"modPow",value:function(t,e,r){for(var n=1n,i=t%r,o=e;o>0;)1n===(1n&o)&&(n=n*i%r),i=i*i%r,o>>=1n;return n}},{key:"sqrtModP",value:function(t,e){var r=this.modPow(t,e+1n>>2n,e);return r*r%e!=t%e?null:r}},{key:"bytesToBigInt",value:function(t){var e,r=0n,n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return gp(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?gp(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r=r<<8n|BigInt(i)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"bigIntTo32Bytes",value:function(t){for(var e=new Uint8Array(32),r=31;r>=0;r--)e[r]=Number(0xffn&t),t>>=8n;return e}}])}(),_p=i(8287).Buffer;function Ep(t){return Ep="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},Ep(t)}function Sp(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,kp(n.key),n)}}function kp(t){var e=function(t){if("object"!=Ep(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ep(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ep(e)?e:e+""}var Op=function(){return function(t,e){return e&&Sp(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=kp(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(this,"deriver",new mp)}),[{key:"generateHybridKeyFromHash",value:function(t){var e=this.deriver.findOrDeriveValidPoint(this.cloneBuffer(t),!1),r=this.deriver.getCanonicalY(e.y1,e.y2);return _p.from(this.deriver.getHybridPublicKey(e.x,r))}},{key:"cloneBuffer",value:function(t){return _p.from(t)}}])}(),Tp=new Op,xp=i(8287).Buffer;function Ap(t){return Ap="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ap(t)}function Pp(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ip(n.key),n)}}function Ip(t){var e=function(t){if("object"!=Ap(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ap(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ap(e)?e:e+""}function Lp(t,e){if(e&&("object"==Ap(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Bp(t,e,r,n){var i=Rp(Cp(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function Rp(){return Rp="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Cp(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Rp.apply(null,arguments)}function jp(t){var e="function"==typeof Map?new Map:void 0;return jp=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(Np())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&Up(i,r.prototype),i}(t,arguments,Cp(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Up(r,t)},jp(t)}function Np(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Np=function(){return!!t})()}function Up(t,e){return Up=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Up(t,e)}function Cp(t){return Cp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Cp(t)}function Fp(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}function Mp(t,e,r){return t.set(Hp(t,e),r),r}function Dp(t,e){return t.get(Hp(t,e))}function Hp(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}var Kp=/^[0-9a-fA-F]+$/,Gp=new WeakMap,Wp=new WeakMap,Vp=new WeakMap,qp=new WeakMap,zp=new WeakMap,Yp=new WeakMap,Xp=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r=function(t,e,r){return e=Cp(e),Lp(t,Np()?Reflect.construct(e,r||[],Cp(t).constructor):e.apply(t,r))}(this,t,[tp]),Fp(r,Gp,void 0),Fp(r,Wp,void 0),Fp(r,Vp,void 0),Fp(r,qp,void 0),Fp(r,zp,void 0),Fp(r,Yp,void 0),e?(r.set(e),r):Lp(r)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Up(t,e)}(t,jp(Uint8Array)),function(t,e,r){return e&&Pp(t.prototype,e),r&&Pp(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"originalPublicKey",get:function(){return Dp(Vp,this)}},{key:"keyPair",get:function(){if(!Dp(qp,this))throw new Error("Public key not set for address");return Dp(qp,this)}},{key:"toHex",value:function(){return"0x"+xp.from(this).toString("hex")}},{key:"toBuffer",value:function(){return xp.from(this)}},{key:"toUncompressedHex",value:function(){if(!Dp(zp,this))throw new Error("Public key not set");return"0x"+Dp(zp,this).uncompressed.toString("hex")}},{key:"toUncompressedBuffer",value:function(){if(!Dp(zp,this))throw new Error("Public key not set");return Dp(zp,this).uncompressed}},{key:"toHybridPublicKeyHex",value:function(){if(!Dp(zp,this))throw new Error("Public key not set");return"0x"+Dp(zp,this).hybrid.toString("hex")}},{key:"toHybridPublicKeyBuffer",value:function(){if(!Dp(zp,this))throw new Error("Public key not set");return Dp(zp,this).hybrid}},{key:"originalPublicKeyBuffer",value:function(){if(!Dp(Vp,this))throw new Error("Public key not set");return xp.from(Dp(Vp,this))}},{key:"equals",value:function(t){var e=this;if(t.length!==e.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}},{key:"lessThan",value:function(t){for(var e=0;e<tp;e++){var r=this[e],n=t[e];if(r<n)return!0;if(r>n)return!1}return!1}},{key:"greaterThan",value:function(t){for(var e=0;e<tp;e++){var r=this[e],n=t[e];if(r>n)return!0;if(r<n)return!1}return!1}},{key:"set",value:function(e){if(![tp,33,65].includes(e.length))throw new Error("Invalid public key length ".concat(e.length));if(e.length===tp){var r=xp.alloc(tp);r.set(e),Mp(Yp,this,Tp.generateHybridKeyFromHash(r)),Bp(t,"set",this,3)([e])}else this.autoFormat(e)}},{key:"isValid",value:function(t){return zf.isValidPublicKey(xp.from(this).toString("hex"),t)}},{key:"p2pk",value:function(){return this.toHex()}},{key:"p2wpkh",value:function(t){return kc.getP2WPKHAddress(this.keyPair,t)}},{key:"p2pkh",value:function(t){return kc.getLegacyAddress(this.keyPair,t)}},{key:"p2shp2wpkh",value:function(t){return kc.getLegacySegwitAddress(this.keyPair,t)}},{key:"toString",value:function(){return this.toHex()}},{key:"toJSON",value:function(){return this.toHex()}},{key:"p2tr",value:function(t){if(Dp(Gp,this)&&Dp(Wp,this)===t)return Dp(Gp,this);var e=kc.tweakedPubKeyBufferToAddress(this,t);if(e)return Mp(Wp,this,t),Mp(Gp,this,e),e;throw new Error("Public key not set")}},{key:"toTweakedHybridPublicKeyHex",value:function(){if(!Dp(Yp,this))throw new Error("Public key not set");return"0x"+Dp(Yp,this).toString("hex")}},{key:"toTweakedHybridPublicKeyBuffer",value:function(){if(!Dp(Yp,this))throw new Error("Public key not set");return Dp(Yp,this)}},{key:"autoFormat",value:function(e){var r=e[0];3===r||2===r||4!==r&&6!==r&&7!==r||(e=t.uncompressedToCompressed(e)),Mp(Vp,this,Uint8Array.from(e)),Mp(qp,this,kc.fromPublicKey(Dp(Vp,this))),Mp(zp,this,da(Dp(Vp,this)));var n=Ra(kc.tweakPublicKey(xp.from(Dp(Vp,this))));Mp(Yp,this,Tp.generateHybridKeyFromHash(n)),Bp(t,"set",this,3)([n])}}],[{key:"dead",value:function(){return t.fromString("0x04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f")}},{key:"fromString",value:function(e){if(!e)throw new Error("Invalid public key");if(e.startsWith("0x")&&(e=e.slice(2)),r=e,!Kp.test(r))throw new Error('You must only pass public keys in hexadecimal format. If you have an address such as bc1q... you must convert it to a public key first. Please refer to await provider.getPublicKeyInfo("bc1q..."). If the public key associated with the address is not found, you must force the user to enter the destination public key. It looks like: 0x020373626d317ae8788ce3280b491068610d840c23ecb64c14075bbb9f670af52c.');var r;return new t(xp.from(e,"hex"))}},{key:"wrap",value:function(e){return new t(e)}},{key:"uncompressedToCompressed",value:function(t){var e=Uint8Array.from(t),r=e.slice(1,33),n=e.slice(33),i=xp.alloc(33);return i[0]=2+(1&n[n.length-1]),i.set(r,1),i}}])}();function Zp(t){return Zp="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},Zp(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,Jp(n.key),n)}}function Jp(t){var e=function(t){if("object"!=Zp(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Zp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Zp(e)?e:e+""}var Qp=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.network=r,this._keypair=kc.fromWIF(e.privateKey,this.network),this._p2wpkh=kc.getP2WPKHAddress(this._keypair,this.network),this._p2tr=kc.getTaprootAddress(this._keypair,this.network),this._legacy=kc.getLegacyAddress(this._keypair,this.network),this._segwitLegacy=kc.getLegacySegwitAddress(this._keypair,this.network),this._tweakedKey=kc.tweakPublicKey(this._keypair.publicKey.toString("hex")),this._bufferPubKey=this._keypair.publicKey,this._address=new Xp(this._keypair.publicKey)}return function(t,e,r){return e&&$p(t.prototype,e),r&&$p(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"address",get:function(){return this._address}},{key:"tweakedPubKeyKey",get:function(){return this._tweakedKey}},{key:"keypair",get:function(){if(!this._keypair)throw new Error("Keypair not set");return this._keypair}},{key:"p2wpkh",get:function(){return this._p2wpkh}},{key:"p2tr",get:function(){return this._p2tr}},{key:"legacy",get:function(){return this._legacy}},{key:"addresses",get:function(){return[this.p2wpkh,this.p2tr,this.legacy,this.segwitLegacy]}},{key:"segwitLegacy",get:function(){return this._segwitLegacy}},{key:"publicKey",get:function(){if(!this._bufferPubKey)throw new Error("Public key not set");return this._bufferPubKey}},{key:"xOnly",get:function(){if(!this.keypair)throw new Error("Keypair not set");return Ra(this._bufferPubKey)}}],[{key:"fromWif",value:function(e){return new t({privateKey:e,address:"",publicKey:""},arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa.bitcoin)}}])}();function td(t){return td="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},td(t)}function ed(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,rd(n.key),n)}}function rd(t){var e=function(t){if("object"!=td(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=td(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==td(e)?e:e+""}var nd,id,od,ad=function(){return function(t,e,r){return e&&ed(t.prototype,e),r&&ed(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Oa.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.network=e}),[{key:"getAddress",value:function(){return this.address}}],[{key:"getAddress",value:function(){throw arguments.length>0&&void 0!==arguments[0]||Oa.bitcoin,new Error("Method not implemented.")}}])}();!function(t){t[t.Bitcoin=0]="Bitcoin",t[t.Fractal=1]="Fractal"}(nd||(nd={})),function(t){t[t.GENERIC=0]="GENERIC",t[t.FUNDING=1]="FUNDING",t[t.DEPLOYMENT=2]="DEPLOYMENT",t[t.INTERACTION=3]="INTERACTION",t[t.MULTI_SIG=4]="MULTI_SIG",t[t.CUSTOM_CODE=5]="CUSTOM_CODE",t[t.CHALLENGE_SOLUTION=6]="CHALLENGE_SOLUTION"}(id||(id={})),function(t){t[t.Roswell=0]="Roswell",t[t.Rachel=1]="Rachel",t[t.Kecksburg=2]="Kecksburg",t[t.Phoenix=3]="Phoenix",t[t.Aurora=4]="Aurora",t[t.Rendlesham=5]="Rendlesham",t[t.Lazar=6]="Lazar",t[t.ShagHarbor=7]="ShagHarbor",t[t.Exeter=8]="Exeter",t[t.Stephenville=9]="Stephenville",t[t.Valensole=10]="Valensole",t[t.Socorro=11]="Socorro",t[t.Pascagoula=12]="Pascagoula",t[t.Tehran=13]="Tehran",t[t.Westall=14]="Westall",t[t.Hopkinsville=15]="Hopkinsville",t[t.Belgium=16]="Belgium",t[t.Breeze=17]="Breeze",t[t.Flatwoods=18]="Flatwoods",t[t.Maury=20]="Maury",t[t.Varginha=21]="Varginha",t[t.Trindade=22]="Trindade",t[t.Levelland=23]="Levelland",t[t.Wanaque=24]="Wanaque",t[t.Coyame=25]="Coyame",t[t.Delphos=26]="Delphos"}(od||(od={}));var ud={CONSENSUS:od.Roswell,CONSENSUS_NAME:"Roswell",ENABLED_AT_BLOCK:0n};function sd(t){return sd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sd(t)}var cd=function(t,e,r){return(e=function(t){var e=function(t){if("object"!=sd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sd(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},od.Roswell,ud),fd=od.Roswell,ld=cd[fd],hd=i(4148);var pd=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 dd(t){switch(t){case"sha256":return yu.create();case"sha512":return Tu.create()}hd(!1,"invalid hashing algorithm name","INVALID_ARGUMENT",{argument:"algorithm",value:t})}pd.crypto||pd.msCrypto;var yd=i(8287).Buffer;function gd(t){return gd="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},gd(t)}function bd(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,vd(n.key),n)}}function vd(t){var e=function(t){if("object"!=gd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=gd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gd(e)?e:e+""}var wd=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&bd(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"btcToSatoshi",value:function(t){return BigInt(1e8*t)}},{key:"rndBytes",value:function(){var e=t.getSafeRandomValues(64);return yd.from(e)}},{key:"getSafeRandomValues",value:function(t){if(void 0!==globalThis.window&&globalThis.window.crypto&&"function"==typeof globalThis.window.crypto.getRandomValues){var e=new Uint8Array(t);return window.crypto.getRandomValues(e),yd.from(e)}if(globalThis.crypto&&"function"==typeof globalThis.crypto.getRandomValues){var r=new Uint8Array(t);return globalThis.crypto.getRandomValues(r),yd.from(r)}throw console.log("No secure random number generator available. Please upgrade your environment.",globalThis.window.crypto,globalThis.crypto),new Error("No secure random number generator available. Please upgrade your environment.")}},{key:"opnetHash",value:function(t){var e=dd("sha512");e.update(t);var r=e.digest();return"0x".concat(yd.from(r).toString("hex"))}}])}(),md=i(8287).Buffer;function _d(t){return _d="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},_d(t)}function Ed(){Ed=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==_d(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(_d(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Sd(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function kd(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Sd(o,n,i,a,u,"next",t)}function u(t){Sd(o,n,i,a,u,"throw",t)}a(void 0)}))}}function Od(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,Bd(n.key),n)}}function Td(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Td=function(){return!!t})()}function xd(t,e,r,n){var i=Ad(Pd(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function Ad(){return Ad="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Pd(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Ad.apply(null,arguments)}function Pd(t){return Pd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Pd(t)}function Id(t,e){return Id=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Id(t,e)}function Ld(t,e,r){return(e=Bd(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Bd(t){var e=function(t){if("object"!=_d(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=_d(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_d(e)?e:e+""}var Rd=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ld(r=function(t,e,r){return e=Pd(e),function(t,e){if(e&&("object"==_d(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,Td()?Reflect.construct(e,r||[],Pd(t).constructor):e.apply(t,r))}(this,t,[e]),"type",id.CUSTOM_CODE),Ld(r,"tapLeafScript",null),Ld(r,"targetScriptRedeem",null),Ld(r,"leftOverFundsScriptRedeem",null),Ld(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");var n=r.witnesses.concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:Kh.witnessStackToScriptWitness(n)}})),!e.script)throw new Error("Bitcoin script is required");if(!e.witnesses)throw new Error("Witness(es) are required");return r.witnesses=e.witnesses,r.randomBytes=e.randomBytes||wd.rndBytes(),r.scriptSeed=r.getContractSeed(),r.contractSigner=kc.fromSeedKeyPair(r.scriptSeed,r.network),r.generator=new Zc(r.internalPubKeyToXOnly(),r.network),r.compiledTargetScript=r.generator.compile(e.script),r.scriptTree=r.getScriptTree(),r.internalInit(),r._scriptAddress=Kf.generatePKSH(r.scriptSeed,r.network),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Id(t,e)}(t,Kh),function(t,e){return e&&Od(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"scriptAddress",get:function(){return this._scriptAddress}},{key:"p2trAddress",get:function(){return this.to||this.getScriptAddress()}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"contractSignerXOnlyPubKey",value:function(){return Ra(md.from(this.contractSigner.publicKey))}},{key:"buildTransaction",value:(r=kd(Ed().mark((function t(){var e,r;return Ed().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to||(this.to=this.getScriptAddress()),e=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=4;break}throw new Error("Left over funds script redeem is required");case 4:if(e.redeemVersion){t.next=6;break}throw new Error("Left over funds script redeem version is required");case 6:if(e.output){t.next=8;break}throw new Error("Left over funds script redeem output is required");case 8:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),t.next=14,this.addRefundOutput(r+this.addOptionalOutputsAndGetAmount());case 14:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"signInputs",value:(e=kd(Ed().mark((function e(r){var n;return Ed().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.contractSigner){e.next=4;break}return e.next=3,xd(t,"signInputs",this,3)([r]);case 3:return e.abrupt("return");case 4:for(n=0;n<r.data.inputs.length;n++)0===n?(r.signInput(0,this.contractSigner),r.signInput(0,this.getSignerKey()),r.finalizeInput(0,this.customFinalizer)):(r.signInput(n,this.getSignerKey()),r.finalizeInput(n));case 5:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"getContractSeed",value:function(){return pa.hash256(this.randomBytes)}},{key:"getPubKeys",value:function(){var t=[md.from(this.signer.publicKey)];return this.contractSigner&&t.push(md.from(this.contractSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={pubkeys:this.getPubKeys(),output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={pubkeys:this.getPubKeys(),output:this.getLeafScript(),redeemVersion:192}}},{key:"getLeafScript",value:function(){return Kh.LOCK_LEAF_SCRIPT}},{key:"getScriptTree",value:function(){return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:this.getLeafScript(),version:192}]}}]);var e,r}(),jd=i(8287).Buffer;function Nd(t){return Nd="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},Nd(t)}function Ud(){Ud=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==Nd(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Nd(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Cd(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function Fd(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Cd(o,n,i,a,u,"next",t)}function u(t){Cd(o,n,i,a,u,"throw",t)}a(void 0)}))}}function Md(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,qd(n.key),n)}}function Dd(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Dd=function(){return!!t})()}function Hd(t,e,r,n){var i=Kd(Gd(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function Kd(){return Kd="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Gd(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Kd.apply(null,arguments)}function Gd(t){return Gd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Gd(t)}function Wd(t,e){return Wd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Wd(t,e)}function Vd(t,e,r){return(e=qd(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qd(t){var e=function(t){if("object"!=Nd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Nd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Nd(e)?e:e+""}var zd=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Vd(r=function(t,e,r){return e=Gd(e),function(t,e){if(e&&("object"==Nd(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,Dd()?Reflect.construct(e,r||[],Gd(t).constructor):e.apply(t,r))}(this,t,[e]),"targetScriptRedeem",null),Vd(r,"leftOverFundsScriptRedeem",null),Vd(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");if(!r.contractSecret)throw new Error("Contract secret is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:Kh.witnessStackToScriptWitness(n)}})),!e.calldata)throw new Error("Calldata is required");return r.preimage=e.preimage||wd.getSafeRandomValues(128),r.disableAutoRefund=e.disableAutoRefund||!1,r.rewardChallenge=Uf.generateMineableReward(r.preimage,r.network),r.calldata=p.compress(e.calldata),r.randomBytes=e.randomBytes||wd.rndBytes(),r.scriptSigner=r.generateKeyPairFromSeed(),r.calldataGenerator=new Gc(jd.from(r.signer.publicKey),r.scriptSignerXOnlyPubKey(),r.network),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Wd(t,e)}(t,Kh),function(t,e){return e&&Md(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"getContractSecret",value:function(){return this.contractSecret}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"getPreimage",value:function(){return this.preimage}},{key:"generateSecret",value:function(){if(!this.to)throw new Error("To address is required");return ha.fromBech32(this.to).data}},{key:"scriptSignerXOnlyPubKey",value:function(){return Ra(jd.from(this.scriptSigner.publicKey))}},{key:"generateKeyPairFromSeed",value:function(){return kc.fromSeedKeyPair(this.randomBytes,this.network)}},{key:"buildTransaction",value:(o=Fd(Ud().mark((function t(){var e;return Ud().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=3;break}throw new Error("Left over funds script redeem is required");case 3:if(e.redeemVersion){t.next=5;break}throw new Error("Left over funds script redeem version is required");case 5:if(e.output){t.next=7;break}throw new Error("Left over funds script redeem output is required");case 7:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.regenerated||this.addInputsFromUTXO(),t.next=11,this.createMineableRewardOutputs();case 11:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"signInputs",value:(i=Fd(Ud().mark((function e(r){return Ud().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.scriptSigner){e.next=4;break}return e.next=3,Hd(t,"signInputs",this,3)([r]);case 3:return e.abrupt("return");case 4:if(!("multiSignPsbt"in this.signer)){e.next=9;break}return e.next=7,this.signInputsWalletBased(r);case 7:e.next=11;break;case 9:return e.next=11,this.signInputsNonWalletBased(r);case 11:case"end":return e.stop()}}),e,this)}))),function(t){return i.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"getScriptSolution",value:function(t){if(!t.tapScriptSig)throw new Error("Tap script signature is required");return[this.contractSecret,t.tapScriptSig[0].signature,t.tapScriptSig[1].signature]}},{key:"getScriptTree",value:function(){if(!this.calldata)throw new Error("Calldata is required");return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:t.LOCK_LEAF_SCRIPT,version:192}]}},{key:"signInputsWalletBased",value:(n=Fd(Ud().mark((function t(e){var r,n;return Ud().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.signer,t.next=3,this.signInput(e,e.data.inputs[0],0,this.scriptSigner);case 3:return t.next=5,r.multiSignPsbt([e]);case 5:for(n=0;n<e.data.inputs.length;n++)0===n?e.finalizeInput(n,this.customFinalizer):e.finalizeInput(n);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"createMineableRewardOutputs",value:(r=Fd(Ud().mark((function t(){var e,r,n;return Ud().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to){t.next=2;break}throw new Error("To address is required");case 2:if(e=this.getTransactionOPNetFee(),r=e>Dh+Hh?Hh:e,this.addOutput({value:Number(r),address:this.to}),r===Hh&&e-Hh>Dh&&this.addOutput({value:Number(e-r),address:this.rewardChallenge.address}),n=this.addOptionalOutputsAndGetAmount(),this.disableAutoRefund){t.next=10;break}return t.next=10,this.addRefundOutput(e+n);case 10:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"signInputsNonWalletBased",value:(e=Fd(Ud().mark((function t(e){var r;return Ud().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=0;case 1:if(!(r<e.data.inputs.length)){t.next=16;break}if(0!==r){t.next=10;break}return t.next=5,this.signInput(e,e.data.inputs[r],r,this.scriptSigner);case 5:return t.next=7,this.signInput(e,e.data.inputs[r],r,this.getSignerKey());case 7:e.finalizeInput(r,this.customFinalizer),t.next=13;break;case 10:return t.next=12,this.signInput(e,e.data.inputs[r],r,this.getSignerKey());case 12:e.finalizeInput(r);case 13:r++,t.next=1;break;case 16:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"getPubKeys",value:function(){var t=[jd.from(this.signer.publicKey)];return this.scriptSigner&&t.push(jd.from(this.scriptSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={output:t.LOCK_LEAF_SCRIPT,redeemVersion:192}}}]);var e,r,n,i,o}();Vd(zd,"MAXIMUM_CALLDATA_SIZE",1048576);var Yd=i(8287).Buffer;function Xd(t){return Xd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xd(t)}function Zd(){Zd=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==Xd(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Xd(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function $d(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function Jd(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){$d(o,n,i,a,u,"next",t)}function u(t){$d(o,n,i,a,u,"throw",t)}a(void 0)}))}}function Qd(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ay(n.key),n)}}function ty(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ty=function(){return!!t})()}function ey(t,e,r,n){var i=ry(ny(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function ry(){return ry="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=ny(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},ry.apply(null,arguments)}function ny(t){return ny=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ny(t)}function iy(t,e){return iy=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},iy(t,e)}function oy(t,e,r){return(e=ay(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ay(t){var e=function(t){if("object"!=Xd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Xd(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xd(e)?e:e+""}var uy=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),oy(r=function(t,e,r){return e=ny(e),function(t,e){if(e&&("object"==Xd(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ty()?Reflect.construct(e,r||[],ny(t).constructor):e.apply(t,r))}(this,t,[e]),"type",id.DEPLOYMENT),oy(r,"tapLeafScript",null),oy(r,"targetScriptRedeem",null),oy(r,"leftOverFundsScriptRedeem",null),oy(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");if(!e.tapScriptSig)throw new Error("Tap script signature is required");var n=[r.randomBytes,e.tapScriptSig[0].signature,e.tapScriptSig[1].signature].concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:Kh.witnessStackToScriptWitness(n)}})),r.bytecode=p.compress(e.bytecode),r.verifyBytecode(),e.calldata&&(r.calldata=e.calldata,r.verifyCalldata()),r.randomBytes=e.randomBytes||wd.rndBytes(),r.preimage=e.preimage||wd.getSafeRandomValues(128),r.rewardChallenge=Uf.generateMineableReward(r.preimage,r.network),r.contractSeed=r.getContractSeed(),r.contractSigner=kc.fromSeedKeyPair(r.contractSeed,r.network),r.deploymentGenerator=new af(Yd.from(r.signer.publicKey),r.contractSignerXOnlyPubKey(),r.network),r.compiledTargetScript=r.deploymentGenerator.compile(r.bytecode,r.randomBytes,r.preimage,r.calldata),r.scriptTree=r.getScriptTree(),r.internalInit(),r._contractPubKey="0x"+r.contractSeed.toString("hex"),r._contractAddress=new Xp(r.contractSeed),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&iy(t,e)}(t,Kh),function(t,e){return e&&Qd(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"contractPubKey",get:function(){return this._contractPubKey}},{key:"contractAddress",get:function(){return this._contractAddress}},{key:"p2trAddress",get:function(){return this.to||this.getScriptAddress()}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"getPreimage",value:function(){return this.preimage}},{key:"contractSignerXOnlyPubKey",value:function(){return Ra(Yd.from(this.contractSigner.publicKey))}},{key:"buildTransaction",value:(n=Jd(Zd().mark((function t(){var e,r,n;return Zd().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to||(this.to=this.getScriptAddress()),e=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=4;break}throw new Error("Left over funds script redeem is required");case 4:if(e.redeemVersion){t.next=6;break}throw new Error("Left over funds script redeem version is required");case 6:if(e.output){t.next=8;break}throw new Error("Left over funds script redeem output is required");case 8:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),n=r>Dh+Hh?Hh:r,this.addOutput({value:Number(n),address:this.contractAddress.p2tr(this.network)}),n===Hh&&r-Hh>Dh&&this.addOutput({value:Number(r-n),address:this.rewardChallenge.address}),t.next=16,this.addRefundOutput(r+this.addOptionalOutputsAndGetAmount());case 16:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"signInputsWalletBased",value:(r=Jd(Zd().mark((function t(e){var r,n;return Zd().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.signer,t.next=3,this.signInput(e,e.data.inputs[0],0,this.contractSigner);case 3:return t.next=5,r.multiSignPsbt([e]);case 5:for(n=0;n<e.data.inputs.length;n++)0===n?e.finalizeInput(n,this.customFinalizer):e.finalizeInput(n);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"signInputs",value:(e=Jd(Zd().mark((function e(r){var n;return Zd().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.contractSigner){e.next=4;break}return e.next=3,ey(t,"signInputs",this,3)([r]);case 3:return e.abrupt("return");case 4:if(!("multiSignPsbt"in this.signer)){e.next=8;break}return e.next=7,this.signInputsWalletBased(r);case 7:return e.abrupt("return");case 8:for(n=0;n<r.data.inputs.length;n++)0===n?(r.signInput(0,this.contractSigner),r.signInput(0,this.getSignerKey()),r.finalizeInput(0,this.customFinalizer)):(r.signInput(n,this.getSignerKey()),r.finalizeInput(n));case 9:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"verifyCalldata",value:function(){if(this.calldata&&this.calldata.length>zd.MAXIMUM_CALLDATA_SIZE)throw new Error("Calldata size overflow.")}},{key:"verifyBytecode",value:function(){if(!this.bytecode)throw new Error("Bytecode is required");if(this.bytecode.length>t.MAXIMUM_CONTRACT_SIZE)throw new Error("Contract size overflow.")}},{key:"getContractSeed",value:function(){if(!this.bytecode)throw new Error("Bytecode is required");var t=this.internalPubKeyToXOnly(),e=pa.hash256(this.randomBytes),r=pa.hash256(this.bytecode),n=Yd.concat([t,e,r]);return pa.hash256(n)}},{key:"getPubKeys",value:function(){var t=[Yd.from(this.signer.publicKey)];return this.contractSigner&&t.push(Yd.from(this.contractSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={pubkeys:this.getPubKeys(),output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={pubkeys:this.getPubKeys(),output:this.getLeafScript(),redeemVersion:192}}},{key:"getLeafScript",value:function(){return Kh.LOCK_LEAF_SCRIPT}},{key:"getScriptTree",value:function(){if(!this.bytecode)throw new Error("Contract bytecode is required");return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:this.getLeafScript(),version:192}]}}]);var e,r,n}();oy(uy,"MAXIMUM_CONTRACT_SIZE",131072);var sy=i(8287).Buffer;function cy(t){return cy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},cy(t)}function fy(){fy=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==cy(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(cy(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function ly(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function hy(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,gy(n.key),n)}}function py(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(py=function(){return!!t})()}function dy(t){return dy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},dy(t)}function yy(t,e){return yy=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},yy(t,e)}function gy(t){var e=function(t){if("object"!=cy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=cy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==cy(e)?e:e+""}var by=function(){function t(e){var r,n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=gy(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(n=function(t,e,r){return e=dy(e),function(t,e){if(e&&("object"==cy(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,py()?Reflect.construct(e,r||[],dy(t).constructor):e.apply(t,r))}(this,t,[e]),"type",id.FUNDING),n.amount=e.amount,n.splitInputsInto=null!==(r=e.splitInputsInto)&&void 0!==r?r:1,n.internalInit(),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&yy(t,e)}(t,Kh),function(t,e){return e&&hy(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"buildTransaction",value:(e=function(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){ly(o,n,i,a,u,"next",t)}function u(t){ly(o,n,i,a,u,"throw",t)}a(void 0)}))}}(fy().mark((function t(){var e;return fy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to){t.next=2;break}throw new Error("Recipient address is required");case 2:return this.addInputsFromUTXO(),this.splitInputsInto>1?this.splitInputs(this.amount):this.isPubKeyDestination?(e=Ia.compile([sy.from(this.to.replace("0x",""),"hex"),Ta.OP_CHECKSIG]),this.addOutput({value:Number(this.amount),script:e})):this.addOutput({value:Number(this.amount),address:this.to}),t.next=6,this.addRefundOutput(this.amount+this.addOptionalOutputsAndGetAmount());case 6:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"splitInputs",value:function(t){if(!this.to)throw new Error("Recipient address is required");for(var e=t/BigInt(this.splitInputsInto),r=0;r<this.splitInputsInto;r++)this.isPubKeyDestination?this.addOutput({value:Number(e),script:sy.from(this.to.slice(2),"hex")}):this.addOutput({value:Number(e),address:this.to})}},{key:"getSignerKey",value:function(){return this.signer}}]);var e}();function vy(t){return vy="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},vy(t)}function wy(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(wy=function(){return!!t})()}function my(t){return my=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},my(t)}function _y(t,e){return _y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_y(t,e)}function Ey(t,e,r){return(e=Sy(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sy(t){var e=function(t){if("object"!=vy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=vy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==vy(e)?e:e+""}var ky=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ey(r=function(t,e,r){return e=my(e),function(t,e){if(e&&("object"==vy(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,wy()?Reflect.construct(e,r||[],my(t).constructor):e.apply(t,r))}(this,t,[e]),"type",id.INTERACTION),Ey(r,"tapLeafScript",null),r.contractSecret=r.generateSecret(),r.compiledTargetScript=r.calldataGenerator.compile(r.calldata,r.contractSecret,r.preimage),r.scriptTree=r.getScriptTree(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_y(t,e)}(t,zd),function(t){return Object.defineProperty(t,"prototype",{writable:!1}),t}(t)}(),Oy=i(8287).Buffer;function Ty(t){return Ty="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},Ty(t)}function xy(){xy=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==Ty(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Ty(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Ay(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function Py(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Ay(o,n,i,a,u,"next",t)}function u(t){Ay(o,n,i,a,u,"throw",t)}a(void 0)}))}}function Iy(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ny(n.key),n)}}function Ly(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Ly=function(){return!!t})()}function By(t){return By=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},By(t)}function Ry(t,e){return Ry=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ry(t,e)}function jy(t,e,r){return(e=Ny(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ny(t){var e=function(t){if("object"!=Ty(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ty(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ty(e)?e:e+""}var Uy=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),jy(r=function(t,e,r){return e=By(e),function(t,e){if(e&&("object"==Ty(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,Ly()?Reflect.construct(e,r||[],By(t).constructor):e.apply(t,r))}(this,t,[e]),"type",id.CHALLENGE_SOLUTION),jy(r,"customFinalizerP2SH",(function(t,e,n,i,o,a){var u=r.inputs[t];return o&&u&&u.redeemScript?{finalScriptSig:Ia.compile([r.challengeSolution,u.redeemScript]),finalScriptWitness:void 0}:ga(t,e,n,i,o,a,!1)})),r.amount=e.amount,r.challengeSolution=e.challengeSolution,r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ry(t,e)}(t,Kh),function(t,e){return e&&Iy(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"buildTransaction",value:(r=Py(xy().mark((function t(){var e;return xy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to){t.next=2;break}throw new Error("Recipient address is required");case 2:return this.addInputsFromUTXO(),this.isPubKeyDestination?(e=Ia.compile([Oy.from(this.to.replace("0x",""),"hex"),Ta.OP_CHECKSIG]),this.addOutput({value:Number(this.amount),script:e})):this.addOutput({value:Number(this.amount),address:this.to}),t.next=6,this.addRefundOutput(this.amount+this.addOptionalOutputsAndGetAmount());case 6:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"signInput",value:(e=Py(xy().mark((function t(e,r,n,i){return xy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case 2:case"end":return t.stop()}}),t)}))),function(t,r,n,i){return e.apply(this,arguments)})},{key:"getSignerKey",value:function(){return this.signer}}]);var e,r}(),Cy=i(8287).Buffer;function Fy(t){return Fy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fy(t)}function My(t){return function(t){if(Array.isArray(t))return Dy(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Dy(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Dy(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Dy(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Hy(){Hy=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==Fy(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Fy(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Ky(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Gy(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Ky(Object(r),!0).forEach((function(e){Wy(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ky(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Wy(t,e,r){return(e=Yy(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Vy(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function qy(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Vy(o,n,i,a,u,"next",t)}function u(t){Vy(o,n,i,a,u,"throw",t)}a(void 0)}))}}function zy(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Yy(n.key),n)}}function Yy(t){var e=function(t){if("object"!=Fy(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Fy(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Fy(e)?e:e+""}var Xy=function(){return function(t,e){return e&&zy(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),[{key:"createCustomScriptTransaction",value:(a=qy(Hy().mark((function t(e){var r,n,i,o,a,u,s;return Hy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:if(e.from){t.next=4;break}throw new Error('Field "from" not provided.');case 4:return r=new Rd(Gy(Gy({},e),{},{utxos:[e.utxos[0]]})),t.next=7,r.generateTransactionMinimalSignatures();case 7:return t.next=9,r.getFundingTransactionParameters();case 9:return(n=t.sent).utxos=e.utxos,t.next=13,r.estimateTransactionFees();case 13:return t.t0=t.sent,t.t1=this.getPriorityFee(e),t.t2=t.t0+t.t1,t.t3=r.getOptionalOutputValue(),n.amount=t.t2+t.t3,t.next=20,this.createFundTransaction(Gy({},n));case 20:if(i=t.sent){t.next=23;break}throw new Error("Could not sign funding transaction.");case 23:return n.estimatedFees=i.estimatedFees,t.next=26,this.createFundTransaction(n);case 26:if(o=t.sent){t.next=29;break}throw new Error("Could not sign funding transaction.");case 29:return e.utxos=this.getUTXOAsTransaction(o.tx,e.to,0),a=Gy(Gy({},e),{},{utxos:this.getUTXOAsTransaction(o.tx,e.to,0),randomBytes:r.getRndBytes(),nonWitnessUtxo:o.tx.toBuffer(),estimatedFees:r.estimatedFees}),u=new Rd(a),t.next=34,u.signTransaction();case 34:return s=t.sent,t.abrupt("return",[o.tx.toHex(),s.toHex(),this.getUTXOAsTransaction(o.tx,e.from,1)]);case 36:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"signInteraction",value:(o=qy(Hy().mark((function t(e){var r,n,i,o,a,u,s;return Hy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:if(e.from){t.next=4;break}throw new Error('Field "from" not provided.');case 4:if(e.utxos[0]){t.next=6;break}throw new Error("Missing at least one UTXO.");case 6:return r=new ky(Gy(Gy({},e),{},{utxos:[e.utxos[0]]})),t.next=9,r.generateTransactionMinimalSignatures();case 9:return t.next=11,r.getFundingTransactionParameters();case 11:return(n=t.sent).utxos=e.utxos,t.next=15,r.estimateTransactionFees();case 15:return t.t0=t.sent,t.t1=this.getPriorityFee(e),t.t2=t.t0+t.t1,t.t3=r.getOptionalOutputValue(),n.amount=t.t2+t.t3,t.next=22,this.createFundTransaction(Gy(Gy({},n),{},{optionalOutputs:[]}));case 22:if(i=t.sent){t.next=25;break}throw new Error("Could not sign funding transaction.");case 25:return n.estimatedFees=i.estimatedFees,t.next=28,this.createFundTransaction(Gy(Gy({},n),{},{optionalOutputs:[]}));case 28:if(o=t.sent){t.next=31;break}throw new Error("Could not sign funding transaction.");case 31:return e.utxos=this.getUTXOAsTransaction(o.tx,e.to,0),a=Gy(Gy({},e),{},{utxos:this.getUTXOAsTransaction(o.tx,e.to,0),randomBytes:r.getRndBytes(),preimage:r.getPreimage(),nonWitnessUtxo:o.tx.toBuffer(),estimatedFees:r.estimatedFees}),u=new ky(a),t.next=36,u.signTransaction();case 36:return s=t.sent,t.abrupt("return",[o.tx.toHex(),s.toHex(),this.getUTXOAsTransaction(o.tx,e.from,1),r.getPreimage().toString("hex")]);case 38:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"signDeployment",value:(i=qy(Hy().mark((function t(e){var r,n,i,o,a,u,s,c,f,l,h;return Hy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new uy(e),t.next=3,r.signTransaction();case 3:return t.next=5,r.getFundingTransactionParameters();case 5:return n=t.sent,t.next=8,r.estimateTransactionFees();case 8:return t.t0=t.sent,t.t1=this.getPriorityFee(e),t.t2=t.t0+t.t1,t.t3=r.getOptionalOutputValue(),n.amount=t.t2+t.t3,i=new by(n),t.next=16,i.signTransaction();case 16:if(o=t.sent){t.next=19;break}throw new Error("Could not sign funding transaction.");case 19:return a=o.outs[0],u={transactionId:o.getId(),outputIndex:0,scriptPubKey:{hex:a.script.toString("hex"),address:r.getScriptAddress()},value:BigInt(a.value)},s=Gy(Gy({},e),{},{utxos:[u],randomBytes:r.getRndBytes(),preimage:r.getPreimage(),nonWitnessUtxo:o.toBuffer(),optionalOutputs:[]}),c=new uy(s),t.next=25,c.signTransaction();case 25:return f=t.sent,l=o.outs[1],h={transactionId:o.getId(),outputIndex:1,scriptPubKey:{hex:l.script.toString("hex"),address:e.from},value:BigInt(l.value)},t.abrupt("return",{transaction:[o.toHex(),f.toHex()],contractAddress:c.contractAddress.p2tr(e.network),contractPubKey:c.contractPubKey,p2trAddress:c.p2trAddress,utxos:[h],preimage:r.getPreimage().toString("hex")});case 29:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"createBTCTransfer",value:(n=qy(Hy().mark((function t(e){var r;return Hy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.from){t.next=2;break}throw new Error('Field "from" not provided.');case 2:return t.next=4,this.createFundTransaction(e);case 4:return r=t.sent,t.abrupt("return",{estimatedFees:r.estimatedFees,original:r.original,tx:r.tx.toHex(),nextUTXOs:this.getAllNewUTXOs(r.original,r.tx,e.from)});case 6:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"createChallengeSolution",value:(r=qy(Hy().mark((function t(e){var r;return Hy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.from){t.next=2;break}throw new Error('Field "from" not provided.');case 2:return t.next=4,this._createChallengeSolution(e);case 4:return r=t.sent,t.abrupt("return",{estimatedFees:r.estimatedFees,original:r.original,tx:r.tx.toHex(),nextUTXOs:this.getAllNewUTXOs(r.original,r.tx,e.from)});case 6:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"getAllNewUTXOs",value:function(t,e,r){for(var n=t.getOutputs(),i=[],o=0;o<e.outs.length;o++){var a=n[o];"address"in a&&a.address===r&&i.push.apply(i,My(this.getUTXOAsTransaction(e,r,o)))}return i}},{key:"_createChallengeSolution",value:(e=qy(Hy().mark((function t(e){var r,n;return Hy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:return r=new Uy(e),t.next=5,r.signTransaction();case 5:if(n=t.sent){t.next=8;break}throw new Error("Could not sign funding transaction.");case 8:return t.abrupt("return",{tx:n,original:r,estimatedFees:r.estimatedFees,nextUTXOs:this.getUTXOAsTransaction(n,e.to,0)});case 9:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"createFundTransaction",value:(t=qy(Hy().mark((function t(e){var r,n;return Hy().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:return r=new by(e),t.next=5,r.signTransaction();case 5:if(n=t.sent){t.next=8;break}throw new Error("Could not sign funding transaction.");case 8:return t.abrupt("return",{tx:n,original:r,estimatedFees:r.estimatedFees,nextUTXOs:this.getUTXOAsTransaction(n,e.to,0)});case 9:case"end":return t.stop()}}),t,this)}))),function(e){return t.apply(this,arguments)})},{key:"writePSBTHeader",value:function(t,e){var r=Cy.from(e,"base64"),n=Cy.alloc(2);return n.writeUInt8(t,0),n.writeUInt8(fd,1),Cy.concat([n,r]).toString("hex")}},{key:"getPriorityFee",value:function(t){return t.priorityFee<Kh.MINIMUM_DUST?Kh.MINIMUM_DUST:t.priorityFee}},{key:"getUTXOAsTransaction",value:function(t,e,r){if(!t.outs[r])return[];var n=t.outs[r];return[{transactionId:t.getId(),outputIndex:r,scriptPubKey:{hex:n.script.toString("hex"),address:e},value:BigInt(n.value)}]}}]);var t,e,r,n,i,o,a}(),Zy=i(8287).Buffer;function $y(t){return $y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$y(t)}function Jy(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 Qy(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Qy(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}function Qy(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function tg(){tg=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==$y(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError($y(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function eg(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function rg(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){eg(o,n,i,a,u,"next",t)}function u(t){eg(o,n,i,a,u,"throw",t)}a(void 0)}))}}function ng(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ig(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ng(Object(r),!0).forEach((function(e){cg(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ng(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function og(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,fg(n.key),n)}}function ag(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ag=function(){return!!t})()}function ug(t){return ug=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ug(t)}function sg(t,e){return sg=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},sg(t,e)}function cg(t,e,r){return(e=fg(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function fg(t){var e=function(t){if("object"!=$y(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=$y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$y(e)?e:e+""}var lg=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e.refundVault)throw new Error("Refund vault is required");if(!e.requestedAmount)throw new Error("Requested amount is required");if(!e.receiver)throw new Error("Receiver is required");if(cg(r=function(t,e,r){return e=ug(e),function(t,e){if(e&&("object"==$y(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ag()?Reflect.construct(e,r||[],ug(t).constructor):e.apply(t,r))}(this,t,[ig(ig({},e),{},{signer:kc.fromPrivateKey(pa.sha256(Zy.from("aaaaaaaa","utf-8"))),priorityFee:0n})]),"type",id.MULTI_SIG),cg(r,"targetScriptRedeem",null),cg(r,"leftOverFundsScriptRedeem",null),cg(r,"originalInputCount",0),cg(r,"sighashTypes",t.signHashTypesArray),cg(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:Kh.witnessStackToScriptWitness(n)}})),!e.pubkeys)throw new Error("Pubkeys are required");return e.psbt&&(r.log("Using provided PSBT."),r.transaction=e.psbt,r.originalInputCount=r.transaction.data.inputs.length),r.refundVault=e.refundVault,r.requestedAmount=e.requestedAmount,r.receiver=e.receiver,r.publicKeys=e.pubkeys,r.minimumSignatures=e.minimumSignatures,r.compiledTargetScript=Sf.compile(e.pubkeys,r.minimumSignatures),r.scriptTree=r.getScriptTree(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&sg(t,e)}(t,Kh),function(t,e,r){return e&&og(t.prototype,e),r&&og(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"finalizeTransactionInputs",value:function(){var t=!1;try{for(var e=this.originalInputCount;e<this.transaction.data.inputs.length;e++)this.transaction.finalizeInput(e,this.customFinalizer.bind(this));t=!0}catch(t){this.error("Error finalizing transaction inputs: ".concat(t.stack))}return t}},{key:"signPSBT",value:(i=rg(tg().mark((function t(){return tg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signTransaction();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.transaction);case 4:throw new Error("Could not sign transaction");case 5:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"buildTransaction",value:(n=rg(tg().mark((function t(){var e,r;return tg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=this.targetScriptRedeem){t.next=3;break}throw new Error("Left over funds script redeem is required");case 3:if(e.redeemVersion){t.next=5;break}throw new Error("Left over funds script redeem version is required");case 5:if(e.output){t.next=7;break}throw new Error("Left over funds script redeem output is required");case 7:if(this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),!((r=this.calculateOutputLeftAmountFromVaults(this.utxos))<0)){t.next=12;break}throw new Error("Output value left is negative ".concat(r,"."));case 12:this.addOutput({address:this.refundVault,value:Number(r)}),this.addOutput({address:this.receiver,value:Number(this.requestedAmount)});case 14:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"internalBuildTransaction",value:(r=rg(tg().mark((function t(e){var r,n,i,o,a,u=arguments;return tg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=u.length>1&&void 0!==u[1]&&u[1],n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);return e.addOutputs(i),t.prev=7,t.next=10,this.signInputs(e);case 10:return t.abrupt("return",this.finalizeTransactionInputs());case 13:t.prev=13,t.t0=t.catch(7),a=t.t0,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack));case 17:return t.abrupt("return",!1);case 18:case"end":return t.stop()}}),t,this,[[7,13]])}))),function(t){return r.apply(this,arguments)})},{key:"signInputs",value:(e=rg(tg().mark((function t(e){return tg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:Ra(t.numsPoint),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var e=this.targetScriptRedeem;if(!e)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:Ra(t.numsPoint),network:this.network,scriptTree:this.scriptTree,redeem:e}}},{key:"getScriptSolution",value:function(t){return t.tapScriptSig?t.tapScriptSig.map((function(t){return t.signature})):[]}},{key:"getScriptTree",value:function(){return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:t.LOCK_LEAF_SCRIPT,version:192}]}},{key:"getTotalOutputAmount",value:function(t){var e,r=BigInt(0),n=Jy(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.value)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"calculateOutputLeftAmountFromVaults",value:function(t){return this.getTotalOutputAmount(t)-this.requestedAmount}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={output:t.LOCK_LEAF_SCRIPT,redeemVersion:192}}}],[{key:"fromBase64",value:function(e){var r=fa.fromBase64(e.psbt,{network:e.network});return new t(ig(ig({},e),{},{psbt:r}))}},{key:"verifyIfSigned",value:function(t,e){for(var r=!1,n=1;n<t.data.inputs.length;n++){var i=t.data.inputs[n];if(i.finalScriptWitness){var o=Kh.readScriptWitnessToWitnessStack(i.finalScriptWitness);if(!(o.length<3))for(var a=0;a<o.length-2;a+=3)if(o[a+2].equals(e)){r=!0;break}}}return r}},{key:"signPartial",value:function(e,r,n,i){for(var o=!1,a=!0,u=n;u<e.data.inputs.length;u++){var s=e.data.inputs[u];s.tapInternalKey||(s.tapInternalKey=Ra(t.numsPoint));var c=[];if(s.finalScriptWitness){var f=Kh.readScriptWitnessToWitnessStack(s.finalScriptWitness);s.tapLeafScript=[{leafVersion:192,script:f[f.length-2],controlBlock:f[f.length-1]}];for(var l=0;l<f.length-2;l+=3)c.push({signature:f[l],leafHash:f[l+1],pubkey:f[l+2]});s.tapScriptSig=(s.tapScriptSig||[]).concat(c)}delete s.finalScriptWitness;var h=t.signHashTypesArray?[t.calculateSignHash(t.signHashTypesArray)]:[];try{t.signInput(e,s,u,r,h),o=!0}catch(t){console.log(t)}if(o){if(!s.tapScriptSig)throw new Error("No new signatures for input");s.tapScriptSig.length!==i[u-n]&&(a=!1)}}return{signed:o,final:!!o&&a}}},{key:"dedupeSignatures",value:function(t,e){var r,n=new Map,i=Jy(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;n.set(o.pubkey.toString("hex"),o)}}catch(t){i.e(t)}finally{i.f()}var a,u=Jy(e);try{for(u.s();!(a=u.n()).done;){var s=a.value;n.has(s.pubkey.toString("hex"))||n.set(s.pubkey.toString("hex"),s)}}catch(t){u.e(t)}finally{u.f()}return Array.from(n.values())}},{key:"attemptFinalizeInputs",value:function(e,r,n,i){for(var o=0,a=function(a){try{var u=e.data.inputs[a];u.tapInternalKey||(u.tapInternalKey=Ra(t.numsPoint));var s=[];if(u.finalScriptWitness){for(var c=Kh.readScriptWitnessToWitnessStack(u.finalScriptWitness),f=0;f<c.length-2;f+=3)s.push({signature:c[f],leafHash:c[f+1],pubkey:c[f+2]});u.tapLeafScript=[{leafVersion:192,script:c[c.length-2],controlBlock:c[c.length-1]}],u.tapScriptSig=t.dedupeSignatures(u.tapScriptSig||[],s)}delete u.finalScriptWitness,e.finalizeInput(a,(function(e,o){return t.partialFinalizer(e,o,[],n[a-r],i)})),o++}catch(t){}},u=r;u<e.data.inputs.length;u++)a(u);return o===e.data.inputs.length-r}}]);var e,r,n,i}();cg(lg,"LOCK_LEAF_SCRIPT",Ia.compile([Ta.OP_XOR,Ta.OP_NOP,Ta.OP_CODESEPARATOR])),cg(lg,"signHashTypesArray",[]),cg(lg,"numsPoint",Zy.from("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex")),cg(lg,"partialFinalizer",(function(t,e,r,n,i){if(!e.tapLeafScript||!e.tapLeafScript[0].script||!e.tapLeafScript[0].controlBlock)throw new Error("Tap leaf script is required");if(!e.tapScriptSig)throw new Error("No new signatures for input ".concat(t,"."));var o=[];if(i){var a,u=Jy(n);try{for(u.s();!(a=u.n()).done;){var s,c=a.value,f=!1,l=Jy(e.tapScriptSig);try{for(l.s();!(s=l.n()).done;){var h=s.value;h.pubkey.equals(Ra(c))&&(o.push(h.signature),f=!0)}}catch(t){l.e(t)}finally{l.f()}f||o.push(Zy.alloc(0))}}catch(t){u.e(t)}finally{u.f()}o=o.reverse()}else o=e.tapScriptSig.map((function(t){return[t.signature,t.leafHash,t.pubkey]})).flat();r.length>0&&(o=o.concat(r));var p=o.concat(e.tapLeafScript[0].script).concat(e.tapLeafScript[0].controlBlock);return{finalScriptWitness:Kh.witnessStackToScriptWitness(p)}}));var hg=i(8287).Buffer;function pg(t){return pg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pg(t)}function dg(){dg=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==pg(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(pg(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function yg(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=bg(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}function gg(t){return function(t){if(Array.isArray(t))return vg(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||bg(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bg(t,e){if(t){if("string"==typeof t)return vg(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vg(t,e):void 0}}function vg(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function wg(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function mg(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){wg(o,n,i,a,u,"next",t)}function u(t){wg(o,n,i,a,u,"throw",t)}a(void 0)}))}}function _g(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,Sg(n.key),n)}}function Eg(t,e,r){return(e=Sg(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sg(t){var e=function(t){if("object"!=pg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=pg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pg(e)?e:e+""}var kg=function(){return function(t,e){return e&&_g(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Eg(this,"utxoPath","address/utxos"),Eg(this,"rpc","json-rpc"),this.opnetAPIUrl=e}),[{key:"fetchUTXO",value:(i=mg(dg().mark((function t(e){var r,n,i,o,a,u,s,c,f,l,h,p,d,y,g,b,v,w;return dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e.usePendingUTXO&&(e.usePendingUTXO=!0),void 0===e.optimized&&(e.optimized=!0),n={method:"GET",headers:{"Content-Type":"application/json"}},i="".concat(this.opnetAPIUrl,"/api/v1/").concat(this.utxoPath,"?address=").concat(e.address,"&optimize=").concat(null!==(r=e.optimized)&&void 0!==r&&r),t.next=6,fetch(i,n);case 6:if((o=t.sent).ok){t.next=9;break}throw new Error("Failed to fetch UTXO data: ".concat(o.statusText));case 9:return t.next=11,o.json();case 11:a=t.sent,u=e.usePendingUTXO?[].concat(gg(a.confirmed),gg(a.pending)):a.confirmed,s=[],c=yg(u),t.prev=15,l=dg().mark((function t(){var e;return dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=f.value,!a.spentTransactions.some((function(t){return t.transactionId===e.transactionId&&t.outputIndex===e.outputIndex}))){t.next=3;break}return t.abrupt("return",1);case 3:s.push(e);case 4:case"end":return t.stop()}}),t)})),c.s();case 18:if((f=c.n()).done){t.next=24;break}return t.delegateYield(l(),"t0",20);case 20:if(!t.t0){t.next=22;break}return t.abrupt("continue",22);case 22:t.next=18;break;case 24:t.next=29;break;case 26:t.prev=26,t.t1=t.catch(15),c.e(t.t1);case 29:return t.prev=29,c.f(),t.finish(29);case 32:if(0!==s.length){t.next=34;break}throw new Error("No UTXO found");case 34:if(h=s.filter((function(t){return BigInt(t.value)>=e.minAmount})),0!==h.length){t.next=37;break}throw new Error("No UTXO found (minAmount)");case 37:p=[],d=0n,y=e.requestedAmount,g=yg(h),t.prev=41,g.s();case 43:if((b=g.n()).done){t.next=54;break}if(v=b.value,!((w=BigInt(v.value))<=0n)){t.next=48;break}return t.abrupt("continue",52);case 48:if(d+=w,p.push({transactionId:v.transactionId,outputIndex:v.outputIndex,value:w,scriptPubKey:v.scriptPubKey,nonWitnessUtxo:hg.from(v.raw,"base64")}),!(d>y)){t.next=52;break}return t.abrupt("break",54);case 52:t.next=43;break;case 54:t.next=59;break;case 56:t.prev=56,t.t2=t.catch(41),g.e(t.t2);case 59:return t.prev=59,g.f(),t.finish(59);case 62:return t.abrupt("return",p);case 63:case"end":return t.stop()}}),t,this,[[15,26,29,32],[41,56,59,62]])}))),function(t){return i.apply(this,arguments)})},{key:"fetchUTXOMultiAddr",value:(n=mg(dg().mark((function t(e){var r,n,i,o,a,u,s,c,f,l,h,p;return dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=[],n=yg(e.addresses);try{for(n.s();!(i=n.n()).done;)o=i.value,a={address:o,minAmount:e.minAmount,requestedAmount:e.requestedAmount,optimized:e.optimized,usePendingUTXO:e.usePendingUTXO},u=this.fetchUTXO(a).catch((function(){return[]})),r.push(u)}catch(t){n.e(t)}finally{n.f()}return t.next=5,Promise.all(r);case 5:s=t.sent,c=s.flat(),f=[],l=0n,h=0;case 10:if(!(h<c.length)){t.next=19;break}if(p=c[h],!(l>=e.requestedAmount)){t.next=14;break}return t.abrupt("break",19);case 14:l+=p.value,f.push(p);case 16:h++,t.next=10;break;case 19:return t.abrupt("return",f);case 20:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"broadcastTransaction",value:(r=mg(dg().mark((function t(e,r){var n,i;return dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[e,r],t.next=3,this.rpcMethod("btc_sendRawTransaction",n);case 3:if(i=t.sent){t.next=6;break}return t.abrupt("return");case 6:return t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e){return r.apply(this,arguments)})},{key:"splitUTXOs",value:(e=mg(dg().mark((function t(e,r,n,i){var o,a,u,s,c,f,l;return dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o={addresses:[e.p2wpkh,e.p2tr],minAmount:330n,requestedAmount:1000000000000000n},t.next=3,this.fetchUTXOMultiAddr(o);case 3:if((a=t.sent)&&a.length){t.next=6;break}return t.abrupt("return",{error:"No UTXOs found"});case 6:return u=BigInt(n)*i,s={amount:u,feeRate:500,from:e.p2tr,utxos:a,signer:e.keypair,network:r,to:e.p2tr,splitInputsInto:n,priorityFee:330n},c=new Xy,t.next=11,c.createBTCTransfer(s);case 11:return f=t.sent,t.next=14,this.broadcastTransaction(f.tx,!1);case 14:if(l=t.sent){t.next=17;break}return t.abrupt("return",{error:"Could not broadcast transaction"});case 17:return t.abrupt("return",l);case 18:case"end":return t.stop()}}),t,this)}))),function(t,r,n,i){return e.apply(this,arguments)})},{key:"rpcMethod",value:(t=mg(dg().mark((function t(e,r){var n,i,o,a,u;return dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:e,params:r,id:1})},i="".concat(this.opnetAPIUrl,"/api/v1/").concat(this.rpc),t.next=4,fetch(i,n);case 4:if((o=t.sent).ok){t.next=7;break}throw new Error("Failed to fetch to rpc: ".concat(o.statusText));case 7:return t.next=9,o.json();case 9:if(a=t.sent){t.next=12;break}throw new Error("No data fetched");case 12:if(u=a.result){t.next=15;break}throw new Error("No rpc parameters found");case 15:if(!("error"in u)){t.next=17;break}throw new Error("Error in fetching to rpc ".concat(u.error));case 17:return t.abrupt("return",u);case 18:case"end":return t.stop()}}),t,this)}))),function(e,r){return t.apply(this,arguments)})}]);var t,e,r,n,i}();function Og(t){return Og="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},Og(t)}function Tg(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function xg(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Tg(Object(r),!0).forEach((function(e){Bg(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Tg(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Ag(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,Rg(n.key),n)}}function Pg(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Pg=function(){return!!t})()}function Ig(t){return Ig=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ig(t)}function Lg(t,e){return Lg=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Lg(t,e)}function Bg(t,e,r){return(e=Rg(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Rg(t){var e=function(t){if("object"!=Og(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Og(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Og(e)?e:e+""}var jg,Ng=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Bg(r=function(t,e,r){return e=Ig(e),function(t,e){if(e&&("object"==Og(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Pg()?Reflect.construct(e,r||[],Ig(t).constructor):e.apply(t,r))}(this,t,[e]),"logColor","#00ffe1"),Bg(r,"feesAddition",10000n),Bg(r,"sighashTypes",[]),r.signer=e.signer,r.network=e.network,r.transaction=e.psbt,r.ignoreSignatureError(),r.tweakSigner(),r.internalInit(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Lg(t,e)}(t,kh),function(t,e,r){return e&&Ag(t.prototype,e),r&&Ag(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"extractTransaction",value:function(){return this.transaction.extractTransaction()}},{key:"final",value:function(){return this.extractTransaction().toHex()}},{key:"toHex",value:function(){return this.transaction.toHex()}},{key:"addInput",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.transaction.addInput(t,e)}},{key:"addOutput",value:function(t){t.value&&this.transaction.addOutput(t)}},{key:"attemptFinalizeInputs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;try{for(var e=this.transaction.data.inputs,r=t;r<e.length;r++){var n=e[r];n.finalScriptWitness?this.transaction.finalizeTaprootInput(r,n.finalScriptWitness):this.transaction.finalizeInput(r)}return!0}catch(t){return this.warn(t.stack||"Couldn't finalize inputs"),!1}}},{key:"getPSBT",value:function(){return this.transaction}}],[{key:"fromBase64",value:function(e,r){var n=fa.fromBase64(e,{network:r.network});return new t(xg(xg({},r),{},{psbt:n}))}},{key:"fromHex",value:function(e,r){var n=fa.fromHex(e,{network:r.network});return new t(xg(xg({},r),{},{psbt:n}))}},{key:"from",value:function(e){var r=new fa({network:e.network});return new t(xg(xg({},e),{},{psbt:r}))}}])}();function Ug(t){return Ug="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ug(t)}function Cg(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,Fg(n.key),n)}}function Fg(t){var e=function(t){if("object"!=Ug(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ug(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ug(e)?e:e+""}!function(t){t[t.UNWRAP=0]="UNWRAP"}(jg||(jg={}));var Mg=function(){return function(t,e,r){return r&&Cg(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"generateMultiSigAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Oa.bitcoin;if(kc.verifyPubKeys(t,r).length!==t.length)throw new Error("Contains invalid public keys");var n=new lg({network:r,utxos:[],pubkeys:t,minimumSignatures:e,feeRate:100,receiver:"a",requestedAmount:1n,refundVault:"a"}).getScriptAddress();if(!n)throw new Error("Failed to generate address");return n}}])}(),Dg=i(2802),Hg=i.n(Dg);function Kg(t){return Kg="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},Kg(t)}function Gg(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,Vg(n.key),n)}}function Wg(t,e,r){return(e=Vg(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Vg(t){var e=function(t){if("object"!=Kg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Kg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kg(e)?e:e+""}var qg=function(){return function(t,e){return e&&Gg(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Wg(this,"_keys",[]),Wg(this,"_values",[])}),[{key:"size",get:function(){return this._keys.length}},{key:"keys",value:function(){return this._keys}},{key:"values",value:function(){return this._values}},{key:"entires",value:function(){for(var t=[],e=0;e<this._keys.length;e++)t.push([this._keys[e],this._values[e]]);return t}},{key:"set",value:function(t,e){var r=this.indexOf(t);-1==r?(this._keys.push(t),this._values.push(e)):this._values[r]=e}},{key:"indexOf",value:function(t){for(var e=0;e<this._keys.length;e++)if(this._keys[e]==t)return e;return-1}},{key:"get",value:function(t){var e=this.indexOf(t);if(-1!=e)return this._values[e]}},{key:"has",value:function(t){return-1!=this.indexOf(t)}},{key:"delete",value:function(t){var e=this.indexOf(t);return-1!=e&&(this._keys.splice(e,1),this._values.splice(e,1),!0)}},{key:"clear",value:function(){this._keys=[],this._values=[]}}])}();function zg(t){return zg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zg(t)}function Yg(){Yg=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==zg(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(zg(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Xg(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 Zg(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Zg(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}function Zg(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function $g(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,Jg(n.key),n)}}function Jg(t){var e=function(t){if("object"!=zg(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=zg(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==zg(e)?e:e+""}function Qg(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Qg=function(){return!!t})()}function tb(t){return tb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},tb(t)}function eb(t,e){return eb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},eb(t,e)}var rb=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=tb(e),function(t,e){if(e&&("object"==zg(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Qg()?Reflect.construct(e,r||[],tb(t).constructor):e.apply(t,r))}(this,t,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&eb(t,e)}(t,qg),function(t,e){return e&&$g(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"set",value:function(t,e){var r=this.indexOf(t);-1==r?(this._keys.push(t),this._values.push(e)):this._values[r]=e}},{key:"indexOf",value:function(t){for(var e=0;e<this._keys.length;e++){var r=this._keys[e];if(t.equals(r))return e}return-1}},{key:"has",value:function(t){for(var e=0;e<this._keys.length;e++)if(t.equals(this._keys[e]))return!0;return!1}},{key:"get",value:function(t){var e=this.indexOf(t);if(-1!=e)return this._values[e]}},{key:"delete",value:function(t){var e=this.indexOf(t);return-1!=e&&(this._keys.splice(e,1),this._values.splice(e,1),!0)}},{key:Symbol.iterator,value:Yg().mark((function t(){var e,r,n;return Yg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=Xg(this._keys),t.prev=1,e.s();case 3:if((r=e.n()).done){t.next=9;break}return n=r.value,t.next=7,[n,this.get(n)];case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),e.e(t.t0);case 14:return t.prev=14,e.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])}))}])}();function nb(t){return nb="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},nb(t)}function ib(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,ob(n.key),n)}}function ob(t){var e=function(t){if("object"!=nb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=nb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==nb(e)?e:e+""}var ab=function(){return function(t,e,r){return e&&ib(t.prototype,e),r&&ib(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){(e=ob(e))in t?Object.defineProperty(t,e,{value:0,enumerable:!0,configurable:!0,writable:!0}):t[e]=0}(this,"currentOffset"),this.buffer=new DataView(e.buffer,e.byteOffset,e.byteLength)}),[{key:"setBuffer",value:function(t){this.buffer=new DataView(t.buffer,t.byteOffset,t.byteLength),this.currentOffset=0}},{key:"readAddressArray",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readAddress();return e}},{key:"readU256Array",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU256();return e}},{key:"readU128Array",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU128();return e}},{key:"readU64Array",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU64();return e}},{key:"readU32Array",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU32();return e}},{key:"readU16Array",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU16();return e}},{key:"readU8Array",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU8();return e}},{key:"readStringArray",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readStringWithLength();return e}},{key:"readBytesArray",value:function(){for(var t=this.readU16(),e=new Array(t),r=0;r<t;r++)e[r]=this.readBytesWithLength();return e}},{key:"readBytesWithLength",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=this.readU32();if(t>0&&e>t)throw new Error("Data length exceeds maximum length.");return this.readBytes(e)}},{key:"readTuple",value:function(){for(var t=this.readU32(),e=new Array(t),r=0;r<t;r++)e[r]=this.readU256();return e}},{key:"readU8",value:function(){this.verifyEnd(this.currentOffset+up);var t=this.buffer.getUint8(this.currentOffset);return this.currentOffset+=up,t}},{key:"readU16",value:function(){this.verifyEnd(this.currentOffset+ap);var t=this.buffer.getUint16(this.currentOffset,!0);return this.currentOffset+=ap,t}},{key:"readU32",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.verifyEnd(this.currentOffset+op);var e=this.buffer.getUint32(this.currentOffset,t);return this.currentOffset+=op,e}},{key:"readU64",value:function(){this.verifyEnd(this.currentOffset+ip);var t=this.buffer.getBigUint64(this.currentOffset,!0);return this.currentOffset+=ip,t}},{key:"readAddressValueTuple",value:function(){for(var t=this.readU16(),e=new rb,r=0;r<t;r++){var n=this.readAddress(),i=this.readU256();if(e.has(n))throw new Error("Duplicate address found in map");e.set(n,i)}return e}},{key:"readU128",value:function(){var t=this.readBytes(np);return BigInt("0x"+t.reduce((function(t,e){return t+e.toString(16).padStart(2,"0")}),""))}},{key:"readU256",value:function(){var t=this.readBytes(rp);return BigInt("0x"+t.reduce((function(t,e){return t+e.toString(16).padStart(2,"0")}),""))}},{key:"readBytes",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new Uint8Array(t),n=0;n<t;n++){var i=this.readU8();if(e&&0===i){r=r.slice(0,n);break}r[n]=i}return r}},{key:"readString",value:function(t){var e=new TextDecoder,r=this.readBytes(t,!0);return e.decode(r)}},{key:"readSelector",value:function(){return this.readU32(!1)}},{key:"readStringWithLength",value:function(){var t=this.readU16();return this.readString(t)}},{key:"readBoolean",value:function(){return 0!==this.readU8()}},{key:"readAddress",value:function(){for(var t=new Array(tp),e=0;e<tp;e++)t[e]=this.readU8();return new Xp(t)}},{key:"getOffset",value:function(){return this.currentOffset}},{key:"setOffset",value:function(t){this.currentOffset=t}},{key:"verifyEnd",value:function(t){if(this.currentOffset>this.buffer.byteLength)throw new Error("Expected to read ".concat(t," bytes but read ").concat(this.currentOffset," bytes"))}}],[{key:"stringCompare",value:function(t,e){return t.localeCompare(e)}},{key:"bigintCompare",value:function(t,e){return t<e?-1:t>e?1:0}},{key:"numberCompare",value:function(t,e){return t<e?-1:t>e?1:0}}])}(),ub=i(8287).Buffer;function sb(t){return sb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sb(t)}function cb(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,fb(n.key),n)}}function fb(t){var e=function(t){if("object"!=sb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sb(e)?e:e+""}var lb,hb=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&cb(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"bufferToUint8Array",value:function(t){if(ub.isBuffer(t)){for(var e=t.byteLength,r=new ArrayBuffer(e),n=new Uint8Array(r),i=0;i<e;++i)n[i]=t[i];return n}return t}},{key:"uint8ArrayToHex",value:function(t){return ub.from(t.buffer,0,t.byteLength).toString("hex")}},{key:"hexToUint8Array",value:function(t){t.startsWith("0x")&&(t=t.substring(2)),t.length%2!=0&&(t="0"+t);for(var e=t.length/2,r=new Uint8Array(e),n=0;n<e;n++)r[n]=parseInt(t.substring(2*n,2*n+2),16);return r}},{key:"pointerToUint8Array",value:function(e){var r=e.toString(16).padStart(64,"0");return t.hexToUint8Array(r)}},{key:"uint8ArrayToPointer",value:function(e){var r=t.uint8ArrayToHex(e);return BigInt("0x"+r)}},{key:"valueToUint8Array",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:rp,n=e.toString(16).padStart(2*r,"0");return t.hexToUint8Array(n)}},{key:"uint8ArrayToValue",value:function(e){var r=t.uint8ArrayToHex(e);return r?BigInt("0x"+r):BigInt(0)}}])}();function pb(t){return pb="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},pb(t)}function db(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,yb(n.key),n)}}function yb(t){var e=function(t){if("object"!=pb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=pb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pb(e)?e:e+""}!function(t,e){(e=fb(e))in t?Object.defineProperty(t,e,{value:32,enumerable:!0,configurable:!0,writable:!0}):t[e]=32}(hb,"EXPECTED_BUFFER_LENGTH"),function(t){t.UINT8="UINT8",t.UINT16="UINT16",t.UINT32="UINT32",t.UINT64="UINT64",t.UINT128="UINT128",t.UINT256="UINT256",t.BOOL="BOOL",t.ADDRESS="ADDRESS",t.STRING="STRING",t.BYTES32="BYTES32",t.TUPLE="TUPLE",t.BYTES="BYTES",t.ADDRESS_UINT256_TUPLE="ADDRESS_UINT256_TUPLE",t.ARRAY_OF_ADDRESSES="ARRAY_OF_ADDRESSES",t.ARRAY_OF_UINT256="ARRAY_OF_UINT256",t.ARRAY_OF_UINT128="ARRAY_OF_UINT128",t.ARRAY_OF_UINT64="ARRAY_OF_UINT64",t.ARRAY_OF_UINT32="ARRAY_OF_UINT32",t.ARRAY_OF_UINT16="ARRAY_OF_UINT16",t.ARRAY_OF_UINT8="ARRAY_OF_UINT8",t.ARRAY_OF_STRING="ARRAY_OF_STRING",t.ARRAY_OF_BYTES="ARRAY_OF_BYTES"}(lb||(lb={}));var gb=function(){return function(t,e){return e&&db(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),[{key:"decodeData",value:function(t,e){for(var r=new ab(t),n=[],i=0;i<e.length;i++)switch(e[i]){case lb.UINT8:n.push(r.readU8());break;case lb.UINT16:n.push(r.readU16());break;case lb.UINT32:n.push(r.readU32());break;case lb.BYTES32:n.push(r.readBytes(32));break;case lb.BOOL:n.push(r.readBoolean());break;case lb.ADDRESS:n.push(r.readAddress());break;case lb.STRING:n.push(r.readStringWithLength());break;case lb.UINT128:n.push(r.readU128());break;case lb.UINT256:n.push(r.readU256());break;case lb.TUPLE:n.push(r.readTuple());break;case lb.ADDRESS_UINT256_TUPLE:n.push(r.readAddressValueTuple());break;case lb.BYTES:n.push(r.readBytesWithLength());break;case lb.UINT64:n.push(r.readU64());break;case lb.ARRAY_OF_ADDRESSES:n.push(r.readAddressArray());break;case lb.ARRAY_OF_UINT256:n.push(r.readU256Array());break;case lb.ARRAY_OF_UINT128:n.push(r.readU128Array());break;case lb.ARRAY_OF_UINT64:n.push(r.readU64Array());break;case lb.ARRAY_OF_UINT32:n.push(r.readU32Array());break;case lb.ARRAY_OF_UINT16:n.push(r.readU16Array());break;case lb.ARRAY_OF_UINT8:n.push(r.readU8Array());break;case lb.ARRAY_OF_STRING:n.push(r.readStringArray());break;case lb.ARRAY_OF_BYTES:n.push(r.readBytesArray())}return n}},{key:"encodeSelector",value:function(t){return this.sha256(t).subarray(0,4).toString("hex")}},{key:"numericSelectorToHex",value:function(t){return t.toString(16)}},{key:"bigIntToUint8Array",value:function(t,e){for(var r=new Uint8Array(e),n=hb.valueToUint8Array(t),i=0;i<e;i++)r[i]=n[i]||0;return r}},{key:"sha256",value:function(t){return(new(Hg().sha256)).update(t).digest()}}])}();function bb(t){return bb="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},bb(t)}function vb(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,wb(n.key),n)}}function wb(t){var e=function(t){if("object"!=bb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=bb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==bb(e)?e:e+""}var mb=function(){return function(t,e){return e&&vb(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){(e=wb(e))in t?Object.defineProperty(t,e,{value:0,enumerable:!0,configurable:!0,writable:!0}):t[e]=0}(this,"currentOffset"),this.buffer=this.getDefaultBuffer(e)}),[{key:"writeU8",value:function(t){if(t>255)throw new Error("Value is too large.");this.allocSafe(up),this.buffer.setUint8(this.currentOffset++,t)}},{key:"writeU16",value:function(t){if(t>65535)throw new Error("Value is too large.");this.allocSafe(ap),this.buffer.setUint16(this.currentOffset,t,!0),this.currentOffset+=2}},{key:"writeU32",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t>4294967295)throw new Error("Value is too large.");this.allocSafe(op),this.buffer.setUint32(this.currentOffset,t,e),this.currentOffset+=4}},{key:"writeU64",value:function(t){if(t>18446744073709551615n)throw new Error("Value is too large.");this.allocSafe(ip),this.buffer.setBigUint64(this.currentOffset,t,!0),this.currentOffset+=8}},{key:"writeSelector",value:function(t){this.writeU32(t,!1)}},{key:"writeBoolean",value:function(t){this.writeU8(t?1:0)}},{key:"writeU256",value:function(t){if(t>115792089237316195423570985008687907853269984665640564039457584007913129639935n)throw new Error("Value is too large.");this.allocSafe(rp);var e=hb.valueToUint8Array(t);if(e.byteLength!==rp)throw new Error("Invalid u256 value: ".concat(t));for(var r=0;r<e.byteLength;r++)this.writeU8(e[r])}},{key:"writeU128",value:function(t){if(t>340282366920938463463374607431768211455n)throw new Error("Value is too large.");this.allocSafe(np);var e=hb.valueToUint8Array(t,np);if(e.byteLength!==np)throw new Error("Invalid u128 value: ".concat(t));for(var r=0;r<e.byteLength;r++)this.writeU8(e[r])}},{key:"writeBytes",value:function(t){this.allocSafe(t.byteLength);for(var e=0;e<t.byteLength;e++)this.writeU8(t[e])}},{key:"writeString",value:function(t){this.allocSafe(t.length);for(var e=0;e<t.length;e++)this.writeU8(t.charCodeAt(e))}},{key:"writeAddress",value:function(t){this.verifyAddress(t),this.writeBytes(t)}},{key:"writeStringWithLength",value:function(t){this.allocSafe(ap+t.length),this.writeU16(t.length),this.writeString(t)}},{key:"getBuffer",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=new Uint8Array(this.buffer.byteLength),r=0;r<this.buffer.byteLength;r++)e[r]=this.buffer.getUint8(r);return t&&this.clear(),e}},{key:"reset",value:function(){this.currentOffset=0,this.buffer=this.getDefaultBuffer(4)}},{key:"writeTuple",value:function(t){this.allocSafe(op+t.length*rp),this.writeU32(t.length);for(var e=0;e<t.length;e++)this.writeU256(t[e])}},{key:"toBytesReader",value:function(){return new ab(this.getBuffer())}},{key:"getOffset",value:function(){return this.currentOffset}},{key:"setOffset",value:function(t){this.currentOffset=t}},{key:"clear",value:function(){this.currentOffset=0,this.buffer=this.getDefaultBuffer()}},{key:"allocSafe",value:function(t){this.currentOffset+t>this.buffer.byteLength&&this.resize(t)}},{key:"writeABISelector",value:function(t,e){this.writeStringWithLength(t),this.writeSelector(e)}},{key:"writeAddressValueTupleMap",value:function(t){if(t.size>65535)throw new Error("Map size is too large");this.writeU16(t.size);for(var e=Array.from(t.keys()),r=0;r<e.length;r++){var n=e[r],i=t.get(n);if(null==i)throw new Error("Value not found");this.writeAddress(n),this.writeU256(i)}}},{key:"writeLimitedAddressBytesMap",value:function(t){if(t.size>8)throw new Error("Too many contract calls");this.writeU8(t.size);for(var e=Array.from(t.keys()),r=0;r<e.length;r++){var n=e[r],i=t.get(n);if(!i)throw new Error("Calls not found");if(i.length>10)throw new Error("Too many calls.");this.writeAddress(n),this.writeU8(i.length);for(var o=0;o<i.length;o++)this.writeBytesWithLength(i[o])}}},{key:"writeBytesWithLength",value:function(t){this.writeU32(t.length),this.writeBytes(t)}},{key:"writeAddressArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeAddress(t[e])}},{key:"writeU32Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU32(t[e])}},{key:"writeU256Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU256(t[e])}},{key:"writeU128Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU128(t[e])}},{key:"writeStringArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeStringWithLength(t[e])}},{key:"writeU16Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU16(t[e])}},{key:"writeU8Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU8(t[e])}},{key:"writeU64Array",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeU64(t[e])}},{key:"writeBytesArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeBytesWithLength(t[e])}},{key:"writeSelectorArray",value:function(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(var e=0;e<t.length;e++)this.writeSelector(t[e])}},{key:"getChecksum",value:function(){for(var t=0,e=0;e<this.buffer.byteLength;e++)t+=this.buffer.getUint8(e);return t%Math.pow(2,32)}},{key:"writeMethodSelectorMap",value:function(t){var e=this;this.writeU16(t.size),t.forEach((function(t,r,n){e.writeSelector(t)}))}},{key:"verifyAddress",value:function(t){if(t.byteLength>tp)throw new Error("Address is too long ".concat(t.byteLength," > ").concat(tp," bytes"))}},{key:"resize",value:function(t){for(var e=new Uint8Array(this.buffer.byteLength+t),r=0;r<this.buffer.byteLength;r++)e[r]=this.buffer.getUint8(r);this.buffer=new DataView(e.buffer,e.byteOffset,e.byteLength)}},{key:"getDefaultBuffer",value:function(){return new DataView(new ArrayBuffer(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0))}}])}();function _b(t){return _b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_b(t)}function Eb(){Eb=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==_b(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(_b(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Sb(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,kb(n.key),n)}}function kb(t){var e=function(t){if("object"!=_b(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=_b(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_b(e)?e:e+""}var Ob=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.keys=e}return function(t,e){return e&&Sb(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"size",get:function(){return this.keys.length}},{key:"add",value:function(t){this.has(t)||this.keys.push(t)}},{key:"has",value:function(t){for(var e=0;e<this.keys.length;e++)if(this.keys[e].equals(t))return!0;return!1}},{key:"remove",value:function(t){var e=this.keys.findIndex((function(e){return e.equals(t)}));-1!==e&&this.keys.splice(e,1)}},{key:"clone",value:function(){for(var e=new t,r=0;r<this.keys.length;r++)e.add(this.keys[r]);return e}},{key:"clear",value:function(){this.keys=[]}},{key:"combine",value:function(t){for(var e=this.clone(),r=0;r<t.keys.length;r++)e.add(t.keys[r]);return e}},{key:Symbol.iterator,value:Eb().mark((function t(){var e;return Eb().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=0;case 1:if(!(e<this.keys.length)){t.next=7;break}return t.next=4,this.keys[e];case 4:e++,t.next=1;break;case 7:case"end":return t.stop()}}),t,this)}))}])}();function Tb(t){return Tb="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},Tb(t)}function xb(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,u=[],s=!0,c=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=o.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){c=!0,i=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return u}}(t,e)||Ib(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ab(){Ab=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==Tb(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Tb(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Pb(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ib(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}function Ib(t,e){if(t){if("string"==typeof t)return Lb(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Lb(t,e):void 0}}function Lb(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Bb(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,Rb(n.key),n)}}function Rb(t){var e=function(t){if("object"!=Tb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Tb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tb(e)?e:e+""}function jb(t,e){return t.get(Ub(t,e))}function Nb(t,e,r){return t.set(Ub(t,e),r),r}function Ub(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}var Cb=new WeakMap,Fb=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}(this,Cb,void 0),this.compareFn=e,this.map=new Map,Nb(Cb,this,[])}return function(t,e,r){return e&&Bb(t.prototype,e),r&&Bb(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"size",get:function(){return this.map.size}},{key:"set",value:function(t,e){this.map.has(t)||(jb(Cb,this).push(t),jb(Cb,this).sort(this.compareFn)),this.map.set(t,e)}},{key:"get",value:function(t){return this.map.get(t)}},{key:"keys",value:function(){return jb(Cb,this).values()}},{key:"values",value:function(){for(var t=[],e=0;e<jb(Cb,this).length;e++){var r=jb(Cb,this)[e],n=this.map.get(r);if(!n)throw new Error("Value not found");t.push(n)}return t.values()}},{key:"has",value:function(t){return this.map.has(t)}},{key:"delete",value:function(t){return!!this.map.has(t)&&(this.map.delete(t),Nb(Cb,this,jb(Cb,this).filter((function(e){return e!==t}))),!0)}},{key:"clear",value:function(){this.map.clear(),Nb(Cb,this,[])}},{key:"forEach",value:function(t){var e,r=Pb(jb(Cb,this));try{for(r.s();!(e=r.n()).done;){var n=e.value;t(this.map.get(n),n,this)}}catch(t){r.e(t)}finally{r.f()}}},{key:Symbol.iterator,value:Ab().mark((function t(){var e,r,n;return Ab().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=Pb(jb(Cb,this)),t.prev=1,e.s();case 3:if((r=e.n()).done){t.next=9;break}return n=r.value,t.next=7,[n,this.map.get(n)];case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),e.e(t.t0);case 14:return t.prev=14,e.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])}))}],[{key:"fromMap",value:function(e,r){var n,i=new t(r),o=Pb(e);try{for(o.s();!(n=o.n()).done;){var a=xb(n.value,2),u=a[0],s=a[1];i.set(u,s)}}catch(t){o.e(t)}finally{o.f()}return i}}])}();function Mb(t){return Mb="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},Mb(t)}function Db(){Db=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==Mb(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(Mb(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Hb(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 Kb(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Kb(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}function Kb(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Gb(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,Wb(n.key),n)}}function Wb(t){var e=function(t){if("object"!=Mb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Mb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Mb(e)?e:e+""}var Vb=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.compareFn=e,this.elements=[]}return function(t,e,r){return e&&Gb(t.prototype,e),r&&Gb(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"add",value:function(t){this.elements.includes(t)||(this.elements.push(t),this.elements.sort(this.compareFn))}},{key:"delete",value:function(t){var e=this.elements.indexOf(t);return-1!==e&&(this.elements.splice(e,1),!0)}},{key:"has",value:function(t){return this.elements.includes(t)}},{key:"clear",value:function(){this.elements=[]}},{key:"forEach",value:function(t){var e,r=Hb(this.elements);try{for(r.s();!(e=r.n()).done;)t(e.value,this)}catch(t){r.e(t)}finally{r.f()}}},{key:"size",get:function(){return this.elements.length}},{key:Symbol.iterator,value:Db().mark((function(){var t,e,r;return Db().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:t=Hb(this.elements),n.prev=1,t.s();case 3:if((e=t.n()).done){n.next=9;break}return r=e.value,n.next=7,r;case 7:n.next=3;break;case 9:n.next=14;break;case 11:n.prev=11,n.t0=n.catch(1),t.e(n.t0);case 14:return n.prev=14,t.f(),n.finish(14);case 17:case"end":return n.stop()}}),r,this,[[1,11,14,17]])}))}],[{key:"fromSet",value:function(e,r){var n,i=new t(r),o=Hb(e);try{for(o.s();!(n=o.n()).done;){var a=n.value;i.add(a)}}catch(t){o.e(t)}finally{o.f()}return i}}])}();function qb(t){return qb="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},qb(t)}function zb(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,Xb(n.key),n)}}function Yb(t,e,r){return e&&zb(t.prototype,e),r&&zb(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Xb(t){var e=function(t){if("object"!=qb(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=qb(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qb(e)?e:e+""}var Zb=Yb((function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.type=e,this.data=r}));function $b(t){return $b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$b(t)}function Jb(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,tv(n.key),n)}}function Qb(t,e,r){return e&&Jb(t.prototype,e),r&&Jb(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function tv(t){var e=function(t){if("object"!=$b(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=$b(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$b(e)?e:e+""}var ev,rv,nv,iv=Qb((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}));!function(t){t.testnet="testnet",t.mainnet="livenet",t.regtest="regtest"}(ev||(ev={})),function(t){t.BITCOIN_MAINNET="BITCOIN_MAINNET",t.BITCOIN_TESTNET="BITCOIN_TESTNET",t.BITCOIN_TESTNET4="BITCOIN_TESTNET4",t.BITCOIN_REGTEST="BITCOIN_REGTEST",t.BITCOIN_SIGNET="BITCOIN_SIGNET",t.FRACTAL_BITCOIN_MAINNET="FRACTAL_BITCOIN_MAINNET",t.FRACTAL_BITCOIN_TESTNET="FRACTAL_BITCOIN_TESTNET"}(rv||(rv={})),function(t){t.ecdsa="ecdsa",t.bip322="bip322-simple"}(nv||(nv={}));var ov=i(8287).Buffer;function av(t){return av="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},av(t)}function uv(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return sv(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?sv(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}function sv(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function cv(){cv=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==av(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(av(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function fv(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function lv(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){fv(o,n,i,a,u,"next",t)}function u(t){fv(o,n,i,a,u,"throw",t)}a(void 0)}))}}function hv(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,gv(n.key),n)}}function pv(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(pv=function(){return!!t})()}function dv(t){return dv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},dv(t)}function yv(t,e){return yv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},yv(t,e)}function gv(t){var e=function(t){if("object"!=av(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=av(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==av(e)?e:e+""}var bv=function(){function t(){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=gv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(e=function(t,e,r){return e=dv(e),function(t,e){if(e&&("object"==av(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,pv()?Reflect.construct(e,r||[],dv(t).constructor):e.apply(t,r))}(this,t),"isInitialized",!1),!window)throw new Error("UnisatSigner can only be used in a browser environment");return e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&yv(t,e)}(t,iv),function(t,e){return e&&hv(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"p2tr",get:function(){if(!this._p2tr)throw new Error("P2TR address not set");return this._p2tr}},{key:"p2wpkh",get:function(){if(!this._p2wpkh)throw new Error("P2PKH address not set");return this._p2wpkh}},{key:"addresses",get:function(){if(!this._addresses)throw new Error("Addresses not set");return this._addresses}},{key:"publicKey",get:function(){if(!this._publicKey)throw new Error("Public key not set");return this._publicKey}},{key:"network",get:function(){if(!this._network)throw new Error("Network not set");return this._network}},{key:"unisat",get:function(){var t=window.opnet||window.unisat;if(!t)throw new Error("OPWallet extension not found");return t}},{key:"init",value:(o=lv(cv().mark((function t(){var e,r;return cv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isInitialized){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this.unisat.getNetwork();case 4:e=t.sent,t.t0=e,t.next=t.t0===ev.mainnet?8:t.t0===ev.testnet?10:t.t0===ev.regtest?12:14;break;case 8:return this._network=Oa.bitcoin,t.abrupt("break",15);case 10:return this._network=Oa.testnet,t.abrupt("break",15);case 12:return this._network=Oa.regtest,t.abrupt("break",15);case 14:throw new Error("Invalid network: ".concat(e));case 15:return t.next=17,this.unisat.getPublicKey();case 17:if(""!==(r=t.sent)){t.next=20;break}throw new Error("Unlock your wallet first");case 20:this._publicKey=ov.from(r,"hex"),this._p2wpkh=kc.getP2WPKHAddress(this,this.network),this._p2tr=kc.getTaprootAddress(this,this.network),this._addresses=[this._p2wpkh,this._p2tr],this.isInitialized=!0;case 25:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"getPublicKey",value:function(){if(!this.isInitialized)throw new Error("UnisatSigner not initialized");return this.publicKey}},{key:"sign",value:function(t,e){throw new Error("Not implemented: sign")}},{key:"signSchnorr",value:function(t){throw new Error("Not implemented: signSchnorr")}},{key:"verify",value:function(t,e){throw new Error("Not implemented: verify")}},{key:"signTaprootInput",value:(i=lv(cv().mark((function t(e,r,n){var i,o;return cv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,this.signAllTweaked(e,n,!1);case 5:o=t.sent,this.combine(e,o,r);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return i.apply(this,arguments)})},{key:"signInput",value:(n=lv(cv().mark((function t(e,r,n){var i,o;return cv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,this.signAllTweaked(e,n,!0);case 5:o=t.sent,this.combine(e,o,r);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return n.apply(this,arguments)})},{key:"multiSignPsbt",value:(r=lv(cv().mark((function t(e){var r,n,i,o,a,u,s,c,f,l=this;return cv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=[],n=[],i=uv(e);try{for(i.s();!(o=i.n()).done;)a=o.value,u=a.toHex(),r.push(u),s=a.data.inputs.map((function(t,e){var r=!1,n=!1;if(oh(t)){if(t.tapLeafScript&&t.tapLeafScript.length>0){var i,o=uv(t.tapLeafScript);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(-1!==function(t,e){var r=pa.hash160(t),n=Ra(t),i=Ia.decompile(e);if(null===i)throw new Error("Unknown script error");return i.findIndex((function(e){return"number"!=typeof e&&ov.isBuffer(e)&&(e.equals(t)||e.equals(r)||e.equals(n))}))}(l.publicKey,a.script)){r=!0,n=!1;break}}}catch(t){o.e(t)}finally{o.f()}}if(!r&&t.tapInternalKey){var u=t.tapInternalKey,s=Ra(l.publicKey);u.equals(s)&&(r=!0,n=!0)}}else ah(t,l.publicKey)&&(r=!0,n=!1);return r?{index:e,publicKey:l.publicKey.toString("hex"),disableTweakSigner:!n}:null})).filter((function(t){return null!==t})),n.push({autoFinalized:!1,toSignInputs:s})}catch(t){i.e(t)}finally{i.f()}return t.next=6,this.unisat.signPsbt(r[0],n[0]);case 6:c=t.sent,f=fa.fromHex(c),e[0].combine(f);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"hasAlreadySignedTapScriptSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(ov.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"hasAlreadyPartialSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(ov.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"combine",value:function(t,e,r){var n,i=e.data.inputs[r],o=t.data.inputs[r];if(i.partialSig&&t.updateInput(r,{partialSig:i.partialSig}),i.tapKeySig&&!o.tapKeySig&&t.updateInput(r,{tapKeySig:i.tapKeySig}),null!==(n=i.tapScriptSig)&&void 0!==n&&n.length){var a=o.tapScriptSig;if(a){var u=this.getNonDuplicateScriptSig(a,i.tapScriptSig);u.length&&t.updateInput(r,{tapScriptSig:u})}else t.updateInput(r,{tapScriptSig:i.tapScriptSig})}}},{key:"signAllTweaked",value:(e=lv(cv().mark((function t(e,r){var n,i,o,a,u,s,c=arguments;return cv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.length>2&&void 0!==c[2]&&c[2],i=this.publicKey.toString("hex"),o=e.data.inputs.map((function(t,e){return[{index:e,publicKey:i,sighashTypes:r,disableTweakSigner:n}]})),a={autoFinalized:!1,toSignInputs:o.flat()},u=e.toHex(),t.next=7,this.unisat.signPsbt(u,a);case 7:return s=t.sent,t.abrupt("return",fa.fromHex(s));case 9:case"end":return t.stop()}}),t,this)}))),function(t,r){return e.apply(this,arguments)})},{key:"getNonDuplicateScriptSig",value:function(t,e){for(var r=[],n=function(n){t.find((function(t){return t.pubkey.equals(e[n].pubkey)}))||r.push(e[n])},i=0;i<e.length;i++)n(i);return r}}]);var e,r,n,i,o}(),vv=i(8287).Buffer;function wv(t){return wv="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},wv(t)}function mv(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 _v(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_v(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}function _v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ev(){Ev=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==wv(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(wv(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Sv(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function kv(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Sv(o,n,i,a,u,"next",t)}function u(t){Sv(o,n,i,a,u,"throw",t)}a(void 0)}))}}function Ov(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Iv(n.key),n)}}function Tv(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Tv=function(){return!!t})()}function xv(t){return xv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},xv(t)}function Av(t,e){return Av=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Av(t,e)}function Pv(t,e,r){return(e=Iv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Iv(t){var e=function(t){if("object"!=wv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=wv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wv(e)?e:e+""}var Lv,Bv,Rv=function(){function t(){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Pv(e=function(t,e,r){return e=xv(e),function(t,e){if(e&&("object"==wv(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,Tv()?Reflect.construct(e,r||[],xv(t).constructor):e.apply(t,r))}(this,t),"isInitialized",!1),!window)throw new Error("XverseSigner can only be used in a browser environment");return e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Av(t,e)}(t,iv),function(t,e){return e&&Ov(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"p2tr",get:function(){if(!this._p2tr)throw new Error("P2TR address not set");return this._p2tr}},{key:"p2wpkh",get:function(){if(!this._p2wpkh)throw new Error("P2PKH address not set");return this._p2wpkh}},{key:"addresses",get:function(){if(!this._addresses)throw new Error("Addresses not set");return this._addresses}},{key:"publicKey",get:function(){if(!this._publicKey)throw new Error("Public key not set");return this._publicKey}},{key:"network",get:function(){if(!this._network)throw new Error("Network not set");return this._network}},{key:"BitcoinProvider",get:function(){var t=window.BitcoinProvider;if(!t)throw new Error("Xverse Wallet extension not found");return t}},{key:"init",value:(o=kv(Ev().mark((function t(){var e,r,n;return Ev().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isInitialized){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this.BitcoinProvider.request("wallet_connect",null);case 4:if(!("error"in(e=t.sent))){t.next=7;break}throw new Error(e.error.message);case 7:if(r=e.result.addresses.find((function(t){return"payment"===t.purpose}))){t.next=10;break}throw new Error("Payment address not found");case 10:if(n=r.address.startsWith("tb")?Oa.testnet:r.address.startsWith("bc")?Oa.bitcoin:null){t.next=13;break}throw new Error("Network not supported");case 13:this._network=n,this._publicKey=vv.from(r.publicKey,"hex"),this._p2wpkh=kc.getP2WPKHAddress(this,this.network),this._p2tr=kc.getTaprootAddress(this,this.network),this._addresses=[this._p2wpkh,this._p2tr],this.isInitialized=!0;case 19:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"getPublicKey",value:function(){if(!this.isInitialized)throw new Error("UnisatSigner not initialized");return this.publicKey}},{key:"sign",value:function(t,e){throw new Error("Not implemented: sign")}},{key:"signSchnorr",value:function(t){throw new Error("Not implemented: signSchnorr")}},{key:"verify",value:function(t,e){throw new Error("Not implemented: verify")}},{key:"signTaprootInput",value:(i=kv(Ev().mark((function t(e,r,n){var i,o;return Ev().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,this.signAllTweaked(e,n,!1);case 5:o=t.sent,this.combine(e,o,r);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return i.apply(this,arguments)})},{key:"signInput",value:(n=kv(Ev().mark((function t(e,r,n){var i,o;return Ev().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((i=e.data.inputs[r]).tapKeySig||i.finalScriptSig||Array.isArray(i.partialSig)&&i.partialSig.length&&this.hasAlreadyPartialSig(i.partialSig)||Array.isArray(i.tapScriptSig)&&i.tapScriptSig.length&&this.hasAlreadySignedTapScriptSig(i.tapScriptSig))){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,this.signAllTweaked(e,n,!0);case 5:o=t.sent,this.combine(e,o,r);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return n.apply(this,arguments)})},{key:"multiSignPsbt",value:(r=kv(Ev().mark((function t(e){var r,n,i,o,a,u,s,c,f,l,h,p=this;return Ev().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=[],i=[],o=mv(e);try{for(o.s();!(a=o.n()).done;)u=a.value,s=u.toBase64(),n.push(s),c=u.data.inputs.map((function(t,e){var r=!1,n=!1;if(oh(t)){if(t.tapLeafScript&&t.tapLeafScript.length>0){var i,o=mv(t.tapLeafScript);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(uh(p.publicKey,a.script)){r=!0,n=!1;break}}}catch(t){o.e(t)}finally{o.f()}}if(!r&&t.tapInternalKey){var u=t.tapInternalKey,s=Ra(p.publicKey);u.equals(s)&&(r=!0,n=!0)}}else ah(t,p.publicKey)&&(r=!0,n=!1);return r?{index:e,publicKey:p.publicKey.toString("hex"),disableTweakSigner:!n}:null})).filter((function(t){return null!==t})),i.push({autoFinalized:!1,toSignInputs:c})}catch(t){o.e(t)}finally{o.f()}return f=Pv({},this.p2wpkh,(null===(r=i[0].toSignInputs)||void 0===r?void 0:r.map((function(t){return t.index})))||[]),t.next=7,this.BitcoinProvider.request("signPsbt",{psbt:n[0],signInputs:f});case 7:if(!("error"in(l=t.sent))){t.next=10;break}throw new Error(l.error.message);case 10:h=fa.fromBase64(l.result.psbt),e[0].combine(h);case 12:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"hasAlreadySignedTapScriptSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(vv.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"hasAlreadyPartialSig",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(vv.from(r.pubkey).equals(this.publicKey)&&r.signature)return!0}return!1}},{key:"combine",value:function(t,e,r){var n,i=e.data.inputs[r],o=t.data.inputs[r];if(i.partialSig&&t.updateInput(r,{partialSig:i.partialSig}),i.tapKeySig&&!o.tapKeySig&&t.updateInput(r,{tapKeySig:i.tapKeySig}),null!==(n=i.tapScriptSig)&&void 0!==n&&n.length){var a=o.tapScriptSig;if(a){var u=this.getNonDuplicateScriptSig(a,i.tapScriptSig);u.length&&t.updateInput(r,{tapScriptSig:u})}else t.updateInput(r,{tapScriptSig:i.tapScriptSig})}}},{key:"signAllTweaked",value:(e=kv(Ev().mark((function t(e,r){var n,i,o,a,u,s,c,f,l=arguments;return Ev().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=l.length>2&&void 0!==l[2]&&l[2],o=this.publicKey.toString("hex"),a=e.data.inputs.map((function(t,e){return[{index:e,publicKey:o,sighashTypes:r,disableTweakSigner:i}]})),u={autoFinalized:!1,toSignInputs:a.flat()},s=e.toBase64(),c=Pv({},this.p2wpkh,(null===(n=u.toSignInputs)||void 0===n?void 0:n.map((function(t){return t.index})))||[]),t.next=8,this.BitcoinProvider.request("signPsbt",{psbt:s,signInputs:c});case 8:if(!("error"in(f=t.sent))){t.next=11;break}throw new Error(f.error.message);case 11:return t.abrupt("return",fa.fromBase64(f.result.psbt));case 12:case"end":return t.stop()}}),t,this)}))),function(t,r){return e.apply(this,arguments)})},{key:"getNonDuplicateScriptSig",value:function(t,e){for(var r=[],n=function(n){t.find((function(t){return t.pubkey.equals(e[n].pubkey)}))||r.push(e[n])},i=0;i<e.length;i++)n(i);return r}}]);var e,r,n,i,o}();function jv(t){return jv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jv(t)}function Nv(){Nv=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.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 f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:T(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function v(){}function w(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=w.prototype=b.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,a,u){var s=l(t[i],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==jv(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var u=n.delegate;if(u){var s=x(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=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 o.next=o}}throw new TypeError(jv(e)+" is not iterable")}return v.prototype=w,i(S,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:v,configurable:!0}),v.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(O.prototype),c(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,s,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 u.type="throw",u.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},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),g},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),P(r),g}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Uv(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function Cv(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Uv(o,n,i,a,u,"next",t)}function u(t){Uv(o,n,i,a,u,"throw",t)}a(void 0)}))}}function Fv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Dv(n.key),n)}}function Mv(t,e,r){return(e=Dv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Dv(t){var e=function(t){if("object"!=jv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=jv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jv(e)?e:e+""}!function(t){t.mainnet="mainnet",t.testnet="testnet",t.signet="Signet"}(Lv||(Lv={})),function(t){t.Unisat="unisat",t.Xverse="xverse"}(Bv||(Bv={}));var Hv=function(){return function(t,e){return e&&Fv(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Mv(this,"wallet_type",null),Mv(this,"unisatSigner",null),Mv(this,"xverseSigner",null)}),[{key:"connect",value:(r=Cv(Nv().mark((function t(){return Nv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.wallet_type){t.next=2;break}throw new Error("Wallet already connected");case 2:if(this.unisatSigner=new bv,this.xverseSigner=new Rv,!window.opnet&&!window.unisat){t.next=17;break}return t.prev=5,t.next=8,this.unisatSigner.init();case 8:return this.wallet_type=Bv.Unisat,t.abrupt("return");case 12:if(t.prev=12,t.t0=t.catch(5),!(t.t0 instanceof Error)){t.next=16;break}throw new Error(t.t0.message);case 16:case 29:throw new Error("Error connecting wallet");case 17:if(!window.BitcoinProvider){t.next=30;break}return t.prev=18,t.next=21,this.xverseSigner.init();case 21:return this.wallet_type=Bv.Xverse,t.abrupt("return");case 25:if(t.prev=25,t.t1=t.catch(18),!(t.t1 instanceof Error)){t.next=29;break}throw new Error(t.t1.message);case 30:throw new Error("Wallet not found");case 31:case"end":return t.stop()}}),t,this,[[5,12],[18,25]])}))),function(){return r.apply(this,arguments)})},{key:"disconnect",value:(e=Cv(Nv().mark((function t(){return Nv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.unisatSigner&&this.xverseSigner){t.next=2;break}throw new Error("Wallet not connected");case 2:if(this.wallet_type!==Bv.Unisat){t.next=6;break}this.unisatSigner.unisat.disconnect(),t.next=8;break;case 6:return t.next=8,this.xverseSigner.BitcoinProvider.request("wallet_disconnect",null);case 8:this.wallet_type=null;case 9:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"switchTo",value:(t=Cv(Nv().mark((function t(e){return Nv().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.unisatSigner&&this.xverseSigner){t.next=2;break}throw new Error("Wallet not connected");case 2:if(this.wallet_type!==e){t.next=4;break}return t.abrupt("return");case 4:if(e!==Bv.Unisat){t.next=10;break}return t.next=7,this.unisatSigner.init();case 7:this.wallet_type=Bv.Unisat,t.next=13;break;case 10:return t.next=12,this.xverseSigner.init();case 12:this.wallet_type=Bv.Xverse;case 13:case"end":return t.stop()}}),t,this)}))),function(e){return t.apply(this,arguments)})},{key:"getAddress",value:function(){if(!this.unisatSigner||!this.xverseSigner)throw new Error("Wallet not connected");return this.wallet_type===Bv.Unisat?Xp.fromString(this.unisatSigner.getPublicKey().toString("hex")):Xp.fromString(this.xverseSigner.getPublicKey().toString("hex"))}},{key:"getSigner",value:function(){if(!this.unisatSigner||!this.xverseSigner)throw new Error("Wallet not connected");return this.wallet_type===Bv.Unisat?this.unisatSigner:this.xverseSigner}}]);var t,e,r}();function Kv(t){return Kv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kv(t)}function Gv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Vv(n.key),n)}}function Wv(t,e,r){return(e=Vv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Vv(t){var e=function(t){if("object"!=Kv(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Kv(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kv(e)?e:e+""}function qv(){return Xp.dead()}var zv,Yv=qv(),Xv=qv(),Zv=qv(),$v=qv(),Jv=qv(),Qv=qv(),tw=qv(),ew=qv(),rw=qv(),nw=qv(),iw=qv(),ow=qv(),aw=qv(),uw=qv(),sw=qv();!function(t){t.Mainnet="mainnet",t.Testnet="testnet",t.Regtest="regtest"}(zv||(zv={}));var cw=function(){return function(t,e){return e&&Gv(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Wv(this,"metadata",Wv(Wv({},nd.Bitcoin,Wv(Wv({},zv.Testnet,{factory:Qv,pool:tw,wbtc:ew,moto:rw,router:nw}),zv.Regtest,{factory:Yv,pool:Xv,wbtc:Zv,moto:$v,router:Jv})),nd.Fractal,Wv({},zv.Mainnet,{factory:iw,pool:ow,wbtc:aw,moto:uw,router:sw})))}),[{key:"getFactoryAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.factory;if(!n)throw new Error("Factory address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getPoolAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.pool;if(!n)throw new Error("Pool address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getWBTCAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.wbtc;if(!n)throw new Error("WBTC address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getMOTOAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.moto;if(!n)throw new Error("MOTO address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getRouterAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.router;if(!n)throw new Error("Router address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getAddresses",value:function(t,e){var r=this.metadata[e][t];if(!r)throw new Error("Metadata not found for network ".concat(t," and chainId ").concat(e));return r}}])}(),fw=new cw,lw=o._v,hw=o.y3,pw=o.Z1,dw=o.pV,yw=o.iy,gw=o.vU,bw=o.dy,vw=o.gd,ww=o.z2,mw=o.LC,_w=o.V5,Ew=o.fI,Sw=o.G7,kw=o.p9,Ow=o.GF,Tw=o.nU,xw=o.zy,Aw=o.Pq,Pw=o.wf,Iw=o.gf,Lw=o.rt,Bw=o.P8,Rw=o.vg,jw=o.nr,Nw=o.ry,Uw=o.z4,Cw=o.qT,Fw=o.t0,Mw=o.Jf,Dw=o.kd,Hw=o.eA,Kw=o.no,Gw=o.o4,Ww=o.YV,Vw=o.O5,qw=o.cC,zw=o.Wj,Yw=o.Z4,Xw=o.pp,Zw=o.d6,$w=o.p6,Jw=o.iV,Qw=o.gh,tm=o.Bc,em=o.TG,rm=o.$3,nm=o.qV,im=o.LL,om=o.gK,am=o.PE,um=o.ev,sm=o.Go,cm=o.dI,fm=o.IB,lm=o.rl,hm=o.c1,pm=o.Y_,dm=o.yo,ym=o.Ko,gm=o.pe,bm=o.ho,vm=o._l,wm=o.QS,mm=o.Bm,_m=o.W_,Em=o.Hu,Sm=o.Mg,km=o.$v,Om=o.mt,Tm=o.lJ,xm=o.ih,Am=o.AT,Pm=o.AS,Im=o.aw,Lm=o.Ph,Bm=o.tm,Rm=o.Qc,jm=o.dF,Nm=o.Wb,Um=o.D_,Cm=o.aS,Fm=o._3,Mm=o.p0,Dm=o.Rt,Hm=o.ZO,Km=o.BI,Gm=o.MS,Wm=o.ct,Vm=o.A9,qm=o.V$,zm=o.xc,Ym=o.Gc,Xm=o.zM,Zm=o.c,$m=o.uW,Jm=o.u4,Qm=o.OH,t_=o.sG,e_=o.jz,r_=o.hL,n_=o.$7,i_=o.rE;export{lw as ABICoder,hw as ABIDataTypes,pw as ADDRESS_BYTE_LENGTH,dw as Address,yw as AddressGenerator,gw as AddressMap,bw as AddressSet,vw as AddressTypes,ww as AddressVerificator,mw as BOOLEAN_BYTE_LENGTH,_w as BinaryReader,Ew as BinaryWriter,Sw as BitcoinUtils,kw as BufferHelper,Ow as CalldataGenerator,Tw as ChainId,xw as ChallengeGenerator,Aw as ChallengeSolutionTransaction,Pw as Compressor,Iw as Consensus,Lw as ContractAddress,Bw as ContractBaseMetadata,Rw as CustomGenerator,jw as CustomKeypair,Nw as CustomScriptTransaction,Uw as DeploymentGenerator,Cw as DeploymentTransaction,Fw as DeterministicMap,Mw as DeterministicSet,Dw as EcKeyPair,Hw as FACTORY_ADDRESS_FRACTAL,Kw as FACTORY_ADDRESS_REGTEST,Gw as FACTORY_ADDRESS_TESTNET,Ww as FeatureOpCodes,Vw as Features,qw as FundingTransaction,zw as Generator,Yw as I128_BYTE_LENGTH,Xw as I16_BYTE_LENGTH,Zw as I256_BYTE_LENGTH,$w as I32_BYTE_LENGTH,Jw as I64_BYTE_LENGTH,Qw as I8_BYTE_LENGTH,tm as InteractionTransaction,em as LegacyCalldataGenerator,rm as MINIMUM_AMOUNT_CA,nm as MINIMUM_AMOUNT_REWARD,im as MOTO_ADDRESS_FRACTAL,om as MOTO_ADDRESS_REGTEST,am as MOTO_ADDRESS_TESTNET,um as MessageSigner,sm as MessageType,cm as MineableReward,fm as MultiSignGenerator,lm as MultiSignTransaction,hm as NetEvent,pm as OPNetConsensusConfig,dm as OPNetLimitedProvider,ym as OPNetMetadata,gm as OPNetNetwork,bm as OPNetTokenAddressManager,vm as P2TR_MS,wm as POOL_ADDRESS_FRACTAL,mm as POOL_ADDRESS_REGTEST,_m as POOL_ADDRESS_TESTNET,Em as PSBTTypes,Sm as PsbtTransaction,km as ROUTER_ADDRESS_FRACTAL,Om as ROUTER_ADDRESS_REGTEST,Tm as ROUTER_ADDRESS_TESTNET,xm as RoswellConsensus,Am as SELECTOR_BYTE_LENGTH,Pm as Secp256k1PointDeriver,Im as SharedInteractionTransaction,Lm as SupportedWallets,Bm as TapscriptVerificator,Rm as TransactionBuilder,jm as TransactionFactory,Nm as TransactionSequence,Um as TransactionType,Cm as TweakedSigner,Fm as TweakedTransaction,Mm as U128_BYTE_LENGTH,Dm as U16_BYTE_LENGTH,Hm as U256_BYTE_LENGTH,Km as U32_BYTE_LENGTH,Gm as U64_BYTE_LENGTH,Wm as U8_BYTE_LENGTH,Vm as UnisatChainType,qm as UnisatNetwork,zm as UnisatSigner,Ym as WBTC_ADDRESS_FRACTAL,Xm as WBTC_ADDRESS_REGTEST,Zm as WBTC_ADDRESS_TESTNET,$m as Wallet,Jm as WalletConnection,Qm as XverseNetwork,t_ as XverseSigner,e_ as currentConsensus,r_ as currentConsensusConfig,n_ as opnet,i_ as version};