@smartledger/bsv 9.0.0 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/README.md +152 -1041
  3. package/STABILITY.md +134 -0
  4. package/bsv-gdaf.min.js +53 -48
  5. package/bsv-ltp.min.js +23 -18
  6. package/bsv-smartcontract.min.js +18 -18
  7. package/bsv.bundle.js +53 -48
  8. package/bsv.min.js +53 -48
  9. package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
  10. package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
  11. package/docs/getting-started/INSTALLATION.md +23 -23
  12. package/docs/getting-started/QUICK_START.md +7 -7
  13. package/docs/migration/FROM_BSV_1_5_6.md +5 -5
  14. package/docs/proposals/10.0.0-package-split.md +131 -0
  15. package/index.js +5 -0
  16. package/lib/block/merkleblock.js +19 -5
  17. package/lib/hdprivatekey.js +15 -0
  18. package/lib/script/interpreter.js +109 -1
  19. package/lib/smart_contract/builder.js +14 -0
  20. package/lib/util/deprecate.js +159 -0
  21. package/package.json +19 -82
  22. package/version.js +1 -1
  23. package/.mocharc.json +0 -5
  24. package/test/address.js +0 -629
  25. package/test/block/block.js +0 -239
  26. package/test/block/blockheader.js +0 -270
  27. package/test/block/merkleblock.js +0 -207
  28. package/test/build/bundle_crypto_shim.js +0 -104
  29. package/test/build/bundle_externals.js +0 -125
  30. package/test/build/bundle_smoke.js +0 -55
  31. package/test/build/esbuild_main.js +0 -65
  32. package/test/build/esm_wrapper.js +0 -97
  33. package/test/build/exports_resolution.js +0 -84
  34. package/test/build/version_sync.js +0 -14
  35. package/test/cli/smoke.js +0 -261
  36. package/test/consensus/base58-vectors.js +0 -120
  37. package/test/consensus/sv-script-vectors.js +0 -81
  38. package/test/consensus/sv-sighash-vectors.js +0 -51
  39. package/test/consensus/sv-tx-vectors.js +0 -48
  40. package/test/credentials-test.js +0 -332
  41. package/test/crypto/backend_selection.js +0 -126
  42. package/test/crypto/bn.js +0 -168
  43. package/test/crypto/ecdsa.js +0 -426
  44. package/test/crypto/elliptic-fixed.js +0 -61
  45. package/test/crypto/hash.browser.js +0 -121
  46. package/test/crypto/hash.js +0 -122
  47. package/test/crypto/point.js +0 -193
  48. package/test/crypto/random.js +0 -105
  49. package/test/crypto/security.js +0 -176
  50. package/test/crypto/shamir.js +0 -177
  51. package/test/crypto/shamir_rngcap.js +0 -29
  52. package/test/crypto/signature.js +0 -399
  53. package/test/data/bip69.json +0 -215
  54. package/test/data/bitcoin-sv/README.md +0 -170
  55. package/test/data/bitcoin-sv/base58_encode_decode.json +0 -14
  56. package/test/data/bitcoin-sv/base58_keys_invalid.json +0 -152
  57. package/test/data/bitcoin-sv/base58_keys_valid.json +0 -452
  58. package/test/data/bitcoin-sv/script_tests.json +0 -2591
  59. package/test/data/bitcoin-sv/sighash.json +0 -1003
  60. package/test/data/bitcoin-sv/tx_invalid.json +0 -285
  61. package/test/data/bitcoin-sv/tx_valid.json +0 -367
  62. package/test/data/bitcoind/base58_keys_invalid.json +0 -152
  63. package/test/data/bitcoind/base58_keys_valid.json +0 -452
  64. package/test/data/bitcoind/blocks.json +0 -27
  65. package/test/data/bitcoind/script_tests.json +0 -2244
  66. package/test/data/bitcoind/sig_canonical.json +0 -7
  67. package/test/data/bitcoind/sig_noncanonical.json +0 -22
  68. package/test/data/bitcoind/tx_invalid.json +0 -177
  69. package/test/data/bitcoind/tx_valid.json +0 -224
  70. package/test/data/blk86756-testnet.dat +0 -0
  71. package/test/data/blk86756-testnet.js +0 -12
  72. package/test/data/blk86756-testnet.json +0 -684
  73. package/test/data/brc220-batch-vector.json +0 -129
  74. package/test/data/ecdsa.json +0 -230
  75. package/test/data/merkleblocks.js +0 -486
  76. package/test/data/messages.json +0 -22
  77. package/test/data/sighash.json +0 -1004
  78. package/test/data/tx_creation.json +0 -85
  79. package/test/didweb/relationships.js +0 -144
  80. package/test/ecies/bitcore-ecies.js +0 -178
  81. package/test/ecies/electrum-ecies.js +0 -206
  82. package/test/encoding/base58.js +0 -131
  83. package/test/encoding/base58check.js +0 -145
  84. package/test/encoding/bufferreader.js +0 -328
  85. package/test/encoding/bufferwriter.js +0 -160
  86. package/test/encoding/varint.js +0 -104
  87. package/test/gdaf/anchor_no_key_leak.js +0 -146
  88. package/test/gdaf/anchor_spv.js +0 -163
  89. package/test/gdaf/canonicalization.js +0 -106
  90. package/test/gdaf/canonicalize.js +0 -140
  91. package/test/gdaf/zk_prover.js +0 -204
  92. package/test/hdkeys.js +0 -365
  93. package/test/hdprivatekey.js +0 -339
  94. package/test/hdpublickey.js +0 -293
  95. package/test/index.js +0 -16
  96. package/test/ltp/ids.js +0 -74
  97. package/test/ltp/right.js +0 -198
  98. package/test/ltp/verify_failclosed.js +0 -134
  99. package/test/message/message.js +0 -190
  100. package/test/mnemonic/data/fixtures.json +0 -300
  101. package/test/mnemonic/mnemonic.js +0 -277
  102. package/test/mnemonic/mocha.opts +0 -1
  103. package/test/mnemonic/pbkdf2.test.js +0 -43
  104. package/test/networks.js +0 -207
  105. package/test/notaryhash/batch_leaf.js +0 -140
  106. package/test/notaryhash/batch_vector.js +0 -282
  107. package/test/notaryhash/certificate.js +0 -249
  108. package/test/notaryhash/encoding.js +0 -186
  109. package/test/notaryhash/interop.js +0 -112
  110. package/test/notaryhash/merkle.js +0 -181
  111. package/test/notaryhash/script.js +0 -270
  112. package/test/notaryhash/verify.js +0 -342
  113. package/test/opcode.js +0 -186
  114. package/test/ordinals/bsv20.js +0 -337
  115. package/test/ordinals/inscription.js +0 -329
  116. package/test/ordinals/ordlock.js +0 -567
  117. package/test/privatekey.js +0 -540
  118. package/test/publickey.js +0 -411
  119. package/test/regressions.js +0 -215
  120. package/test/script/chronicle.js +0 -543
  121. package/test/script/defaults.js +0 -160
  122. package/test/script/genesis_limits.js +0 -203
  123. package/test/script/interpreter.js +0 -776
  124. package/test/script/script.js +0 -1259
  125. package/test/script/string_ops.js +0 -88
  126. package/test/security/fail_closed_contracts.js +0 -104
  127. package/test/security/threat_model_coverage.js +0 -31
  128. package/test/smart_contract/covenants.js +0 -207
  129. package/test/smart_contract/dsl_debugger.js +0 -92
  130. package/test/smart_contract/extract_field.js +0 -61
  131. package/test/smart_contract/nonenforcing_guard.js +0 -44
  132. package/test/smart_contract/ordinal_transfer.js +0 -71
  133. package/test/smart_contract/preimage.js +0 -98
  134. package/test/smart_contract/sighash_marketplace.js +0 -98
  135. package/test/smart_contract/token_generalized.js +0 -175
  136. package/test/spv/headerchain.js +0 -86
  137. package/test/spv/merkleproof.js +0 -133
  138. package/test/statuslist/failclosed.js +0 -78
  139. package/test/transaction/deserialize.js +0 -33
  140. package/test/transaction/input/input.js +0 -92
  141. package/test/transaction/input/multisig.js +0 -174
  142. package/test/transaction/input/multisigscripthash.js +0 -111
  143. package/test/transaction/input/publickey.js +0 -68
  144. package/test/transaction/input/publickeyhash.js +0 -59
  145. package/test/transaction/output.js +0 -185
  146. package/test/transaction/sighash.js +0 -91
  147. package/test/transaction/signature.js +0 -127
  148. package/test/transaction/transaction.js +0 -1299
  149. package/test/transaction/unspentoutput.js +0 -97
  150. package/test/types/dts_drift.js +0 -124
  151. package/test/types/surface_honesty.js +0 -102
  152. package/test/util/id.js +0 -72
  153. package/test/util/js.js +0 -76
  154. package/test/util/preconditions.js +0 -79
  155. package/test/vcjwt/interop.js +0 -126
package/bsv-ltp.min.js CHANGED
@@ -1,22 +1,22 @@
1
- var bsvLTP=(()=>{var Qx=Object.create;var hs=Object.defineProperty;var eI=Object.getOwnPropertyDescriptor;var tI=Object.getOwnPropertyNames;var rI=Object.getPrototypeOf,nI=Object.prototype.hasOwnProperty;var iI=(e,t,r)=>t in e?hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Wt=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var P=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},ol=(e,t)=>{for(var r in t)hs(e,r,{get:t[r],enumerable:!0})},t0=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of tI(t))!nI.call(e,i)&&i!==r&&hs(e,i,{get:()=>t[i],enumerable:!(n=eI(t,i))||n.enumerable});return e};var r0=(e,t,r)=>(r=e!=null?Qx(rI(e)):{},t0(t||!e||!e.__esModule?hs(r,"default",{value:e,enumerable:!0}):r,e)),sl=e=>t0(hs({},"__esModule",{value:!0}),e);var $=(e,t,r)=>iI(e,typeof t!="symbol"?t+"":t,r);var a0=P((bC,s0)=>{p();var tt=s0.exports={},Wr,zr;function al(){throw new Error("setTimeout has not been defined")}function ul(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Wr=setTimeout:Wr=al}catch{Wr=al}try{typeof clearTimeout=="function"?zr=clearTimeout:zr=ul}catch{zr=ul}})();function n0(e){if(Wr===setTimeout)return setTimeout(e,0);if((Wr===al||!Wr)&&setTimeout)return Wr=setTimeout,setTimeout(e,0);try{return Wr(e,0)}catch{try{return Wr.call(null,e,0)}catch{return Wr.call(this,e,0)}}}function oI(e){if(zr===clearTimeout)return clearTimeout(e);if((zr===ul||!zr)&&clearTimeout)return zr=clearTimeout,clearTimeout(e);try{return zr(e)}catch{try{return zr.call(null,e)}catch{return zr.call(this,e)}}}var pn=[],uo=!1,wi,$a=-1;function sI(){!uo||!wi||(uo=!1,wi.length?pn=wi.concat(pn):$a=-1,pn.length&&i0())}function i0(){if(!uo){var e=n0(sI);uo=!0;for(var t=pn.length;t;){for(wi=pn,pn=[];++$a<t;)wi&&wi[$a].run();$a=-1,t=pn.length}wi=null,uo=!1,oI(e)}}tt.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];pn.push(new o0(e,t)),pn.length===1&&!uo&&n0(i0)};function o0(e,t){this.fun=e,this.array=t}o0.prototype.run=function(){this.fun.apply(null,this.array)};tt.title="browser";tt.browser=!0;tt.env={};tt.argv=[];tt.version="";tt.versions={};function gn(){}tt.on=gn;tt.addListener=gn;tt.once=gn;tt.off=gn;tt.removeListener=gn;tt.removeAllListeners=gn;tt.emit=gn;tt.prependListener=gn;tt.prependOnceListener=gn;tt.listeners=function(e){return[]};tt.binding=function(e){throw new Error("process.binding is not supported")};tt.cwd=function(){return"/"};tt.chdir=function(e){throw new Error("process.chdir is not supported")};tt.umask=function(){return 0}});var c0=P(Za=>{"use strict";p();Za.byteLength=uI;Za.toByteArray=cI;Za.fromByteArray=dI;var Yr=[],vr=[],aI=typeof Uint8Array<"u"?Uint8Array:Array,fl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Si=0,u0=fl.length;Si<u0;++Si)Yr[Si]=fl[Si],vr[fl.charCodeAt(Si)]=Si;var Si,u0;vr[45]=62;vr[95]=63;function f0(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function uI(e){var t=f0(e),r=t[0],n=t[1];return(r+n)*3/4-n}function fI(e,t,r){return(t+r)*3/4-r}function cI(e){var t,r=f0(e),n=r[0],i=r[1],o=new aI(fI(e,n,i)),s=0,a=i>0?n-4:n,f;for(f=0;f<a;f+=4)t=vr[e.charCodeAt(f)]<<18|vr[e.charCodeAt(f+1)]<<12|vr[e.charCodeAt(f+2)]<<6|vr[e.charCodeAt(f+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=vr[e.charCodeAt(f)]<<2|vr[e.charCodeAt(f+1)]>>4,o[s++]=t&255),i===1&&(t=vr[e.charCodeAt(f)]<<10|vr[e.charCodeAt(f+1)]<<4|vr[e.charCodeAt(f+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function lI(e){return Yr[e>>18&63]+Yr[e>>12&63]+Yr[e>>6&63]+Yr[e&63]}function hI(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(lI(n));return i.join("")}function dI(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(hI(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Yr[t>>2]+Yr[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Yr[t>>10]+Yr[t>>4&63]+Yr[t<<2&63]+"=")),i.join("")}});var l0=P(cl=>{p();cl.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,f=(1<<a)-1,l=f>>1,m=-7,g=r?i-1:0,v=r?-1:1,E=e[t+g];for(g+=v,o=E&(1<<-m)-1,E>>=-m,m+=a;m>0;o=o*256+e[t+g],g+=v,m-=8);for(s=o&(1<<-m)-1,o>>=-m,m+=n;m>0;s=s*256+e[t+g],g+=v,m-=8);if(o===0)o=1-l;else{if(o===f)return s?NaN:(E?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-l}return(E?-1:1)*s*Math.pow(2,o-n)};cl.write=function(e,t,r,n,i,o){var s,a,f,l=o*8-i-1,m=(1<<l)-1,g=m>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=n?0:o-1,T=n?1:-1,N=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=m):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),s+g>=1?t+=v/f:t+=v*Math.pow(2,1-g),t*f>=2&&(s++,f/=2),s+g>=m?(a=0,s=m):s+g>=1?(a=(t*f-1)*Math.pow(2,i),s=s+g):(a=t*Math.pow(2,g-1)*Math.pow(2,i),s=0));i>=8;e[r+E]=a&255,E+=T,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[r+E]=s&255,E+=T,s/=256,l-=8);e[r+E-T]|=N*128}});var Nt=P(ho=>{"use strict";p();var ll=c0(),co=l0(),h0=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ho.Buffer=H;ho.SlowBuffer=bI;ho.INSPECT_MAX_BYTES=50;var Xa=2147483647;ho.kMaxLength=Xa;H.TYPED_ARRAY_SUPPORT=pI();!H.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function pI(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(H.prototype,"parent",{enumerable:!0,get:function(){if(H.isBuffer(this))return this.buffer}});Object.defineProperty(H.prototype,"offset",{enumerable:!0,get:function(){if(H.isBuffer(this))return this.byteOffset}});function yn(e){if(e>Xa)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,H.prototype),t}function H(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return gl(e)}return y0(e,t,r)}H.poolSize=8192;function y0(e,t,r){if(typeof e=="string")return yI(e,t);if(ArrayBuffer.isView(e))return mI(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if($r(e,ArrayBuffer)||e&&$r(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&($r(e,SharedArrayBuffer)||e&&$r(e.buffer,SharedArrayBuffer)))return dl(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return H.from(n,t,r);let i=vI(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return H.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}H.from=function(e,t,r){return y0(e,t,r)};Object.setPrototypeOf(H.prototype,Uint8Array.prototype);Object.setPrototypeOf(H,Uint8Array);function m0(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function gI(e,t,r){return m0(e),e<=0?yn(e):t!==void 0?typeof r=="string"?yn(e).fill(t,r):yn(e).fill(t):yn(e)}H.alloc=function(e,t,r){return gI(e,t,r)};function gl(e){return m0(e),yn(e<0?0:yl(e)|0)}H.allocUnsafe=function(e){return gl(e)};H.allocUnsafeSlow=function(e){return gl(e)};function yI(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!H.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=v0(e,t)|0,n=yn(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function hl(e){let t=e.length<0?0:yl(e.length)|0,r=yn(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function mI(e){if($r(e,Uint8Array)){let t=new Uint8Array(e);return dl(t.buffer,t.byteOffset,t.byteLength)}return hl(e)}function dl(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,H.prototype),n}function vI(e){if(H.isBuffer(e)){let t=yl(e.length)|0,r=yn(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||vl(e.length)?yn(0):hl(e);if(e.type==="Buffer"&&Array.isArray(e.data))return hl(e.data)}function yl(e){if(e>=Xa)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Xa.toString(16)+" bytes");return e|0}function bI(e){return+e!=e&&(e=0),H.alloc(+e)}H.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==H.prototype};H.compare=function(t,r){if($r(t,Uint8Array)&&(t=H.from(t,t.offset,t.byteLength)),$r(r,Uint8Array)&&(r=H.from(r,r.offset,r.byteLength)),!H.isBuffer(t)||!H.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};H.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}};H.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return H.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=H.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let s=t[n];if($r(s,Uint8Array))o+s.length>i.length?(H.isBuffer(s)||(s=H.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(H.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function v0(e,t){if(H.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||$r(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return pl(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return O0(e).length;default:if(i)return n?-1:pl(e).length;t=(""+t).toLowerCase(),i=!0}}H.byteLength=v0;function _I(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return PI(this,t,r);case"utf8":case"utf-8":return _0(this,t,r);case"ascii":return RI(this,t,r);case"latin1":case"binary":return TI(this,t,r);case"base64":return AI(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return BI(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}H.prototype._isBuffer=!0;function Ei(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}H.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)Ei(this,r,r+1);return this};H.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)Ei(this,r,r+3),Ei(this,r+1,r+2);return this};H.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)Ei(this,r,r+7),Ei(this,r+1,r+6),Ei(this,r+2,r+5),Ei(this,r+3,r+4);return this};H.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?_0(this,0,t):_I.apply(this,arguments)};H.prototype.toLocaleString=H.prototype.toString;H.prototype.equals=function(t){if(!H.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:H.compare(this,t)===0};H.prototype.inspect=function(){let t="",r=ho.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};h0&&(H.prototype[h0]=H.prototype.inspect);H.prototype.compare=function(t,r,n,i,o){if($r(t,Uint8Array)&&(t=H.from(t,t.offset,t.byteLength)),!H.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,a=n-r,f=Math.min(s,a),l=this.slice(i,o),m=t.slice(r,n);for(let g=0;g<f;++g)if(l[g]!==m[g]){s=l[g],a=m[g];break}return s<a?-1:a<s?1:0};function b0(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,vl(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=H.from(t,n)),H.isBuffer(t))return t.length===0?-1:d0(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):d0(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function d0(e,t,r,n,i){let o=1,s=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,s/=2,a/=2,r/=2}function f(m,g){return o===1?m[g]:m.readUInt16BE(g*o)}let l;if(i){let m=-1;for(l=r;l<s;l++)if(f(e,l)===f(t,m===-1?0:l-m)){if(m===-1&&(m=l),l-m+1===a)return m*o}else m!==-1&&(l-=l-m),m=-1}else for(r+a>s&&(r=s-a),l=r;l>=0;l--){let m=!0;for(let g=0;g<a;g++)if(f(e,l+g)!==f(t,g)){m=!1;break}if(m)return l}return-1}H.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};H.prototype.indexOf=function(t,r,n){return b0(this,t,r,n,!0)};H.prototype.lastIndexOf=function(t,r,n){return b0(this,t,r,n,!1)};function wI(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(t.substr(s*2,2),16);if(vl(a))return s;e[r+s]=a}return s}function SI(e,t,r,n){return Ja(pl(t,e.length-r),e,r,n)}function EI(e,t,r,n){return Ja(CI(t),e,r,n)}function xI(e,t,r,n){return Ja(O0(t),e,r,n)}function II(e,t,r,n){return Ja(LI(t,e.length-r),e,r,n)}H.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return wI(this,t,r,n);case"utf8":case"utf-8":return SI(this,t,r,n);case"ascii":case"latin1":case"binary":return EI(this,t,r,n);case"base64":return xI(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return II(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function AI(e,t,r){return t===0&&r===e.length?ll.fromByteArray(e):ll.fromByteArray(e.slice(t,r))}function _0(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let f,l,m,g;switch(a){case 1:o<128&&(s=o);break;case 2:f=e[i+1],(f&192)===128&&(g=(o&31)<<6|f&63,g>127&&(s=g));break;case 3:f=e[i+1],l=e[i+2],(f&192)===128&&(l&192)===128&&(g=(o&15)<<12|(f&63)<<6|l&63,g>2047&&(g<55296||g>57343)&&(s=g));break;case 4:f=e[i+1],l=e[i+2],m=e[i+3],(f&192)===128&&(l&192)===128&&(m&192)===128&&(g=(o&15)<<18|(f&63)<<12|(l&63)<<6|m&63,g>65535&&g<1114112&&(s=g))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return OI(n)}var p0=4096;function OI(e){let t=e.length;if(t<=p0)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=p0));return r}function RI(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function TI(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function PI(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=DI[e[o]];return i}function BI(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}H.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,H.prototype),i};function Ut(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}H.prototype.readUintLE=H.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return i};H.prototype.readUintBE=H.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};H.prototype.readUint8=H.prototype.readUInt8=function(t,r){return t=t>>>0,r||Ut(t,1,this.length),this[t]};H.prototype.readUint16LE=H.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||Ut(t,2,this.length),this[t]|this[t+1]<<8};H.prototype.readUint16BE=H.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||Ut(t,2,this.length),this[t]<<8|this[t+1]};H.prototype.readUint32LE=H.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};H.prototype.readUint32BE=H.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};H.prototype.readBigUInt64LE=jn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ds(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});H.prototype.readBigUInt64BE=jn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ds(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});H.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};H.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(t,r,this.length);let i=r,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};H.prototype.readInt8=function(t,r){return t=t>>>0,r||Ut(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};H.prototype.readInt16LE=function(t,r){t=t>>>0,r||Ut(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};H.prototype.readInt16BE=function(t,r){t=t>>>0,r||Ut(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};H.prototype.readInt32LE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};H.prototype.readInt32BE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};H.prototype.readBigInt64LE=jn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ds(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});H.prototype.readBigInt64BE=jn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ds(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});H.prototype.readFloatLE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),co.read(this,t,!0,23,4)};H.prototype.readFloatBE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),co.read(this,t,!1,23,4)};H.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||Ut(t,8,this.length),co.read(this,t,!0,52,8)};H.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||Ut(t,8,this.length),co.read(this,t,!1,52,8)};function sr(e,t,r,n,i,o){if(!H.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}H.prototype.writeUintLE=H.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;sr(this,t,r,n,a,0)}let o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n};H.prototype.writeUintBE=H.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;sr(this,t,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n};H.prototype.writeUint8=H.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,1,255,0),this[r]=t&255,r+1};H.prototype.writeUint16LE=H.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};H.prototype.writeUint16BE=H.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};H.prototype.writeUint32LE=H.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};H.prototype.writeUint32BE=H.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function w0(e,t,r,n,i){A0(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function S0(e,t,r,n,i){A0(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}H.prototype.writeBigUInt64LE=jn(function(t,r=0){return w0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});H.prototype.writeBigUInt64BE=jn(function(t,r=0){return S0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});H.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);sr(this,t,r,n,f-1,-f)}let o=0,s=1,a=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};H.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);sr(this,t,r,n,f-1,-f)}let o=n-1,s=1,a=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};H.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};H.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};H.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};H.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};H.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};H.prototype.writeBigInt64LE=jn(function(t,r=0){return w0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});H.prototype.writeBigInt64BE=jn(function(t,r=0){return S0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function E0(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x0(e,t,r,n,i){return t=+t,r=r>>>0,i||E0(e,t,r,4,34028234663852886e22,-34028234663852886e22),co.write(e,t,r,n,23,4),r+4}H.prototype.writeFloatLE=function(t,r,n){return x0(this,t,r,!0,n)};H.prototype.writeFloatBE=function(t,r,n){return x0(this,t,r,!1,n)};function I0(e,t,r,n,i){return t=+t,r=r>>>0,i||E0(e,t,r,8,17976931348623157e292,-17976931348623157e292),co.write(e,t,r,n,52,8),r+8}H.prototype.writeDoubleLE=function(t,r,n){return I0(this,t,r,!0,n)};H.prototype.writeDoubleBE=function(t,r,n){return I0(this,t,r,!1,n)};H.prototype.copy=function(t,r,n,i){if(!H.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};H.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!H.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let s=H.isBuffer(t)?t:H.from(t,i),a=s.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var fo={};function ml(e,t,r){fo[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}ml("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ml("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);ml("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=g0(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=g0(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function g0(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function NI(e,t,r){lo(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&ds(t,e.length-(r+1))}function A0(e,t,r,n,i,o){if(e>r||e<t){let s=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${t}${s} and <= ${r}${s}`,new fo.ERR_OUT_OF_RANGE("value",a,e)}NI(n,i,o)}function lo(e,t){if(typeof e!="number")throw new fo.ERR_INVALID_ARG_TYPE(t,"number",e)}function ds(e,t,r){throw Math.floor(e)!==e?(lo(e,r),new fo.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new fo.ERR_BUFFER_OUT_OF_BOUNDS:new fo.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var MI=/[^+/0-9A-Za-z-_]/g;function kI(e){if(e=e.split("=")[0],e=e.trim().replace(MI,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function pl(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function CI(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function LI(e,t){let r,n,i,o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function O0(e){return ll.toByteArray(kI(e))}function Ja(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function $r(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function vl(e){return e!==e}var DI=(function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t})();function jn(e){return typeof BigInt>"u"?UI:e}function UI(){throw new Error("BigInt not supported")}});var I,d,p=Wt(()=>{I=r0(a0()),d=r0(Nt())});var T0=P((R0,bl)=>{p();(function(e,t){"use strict";function r(x,u){if(!x)throw new Error(u||"Assertion failed")}function n(x,u){x.super_=u;var h=function(){};h.prototype=u.prototype,x.prototype=new h,x.prototype.constructor=x}function i(x,u,h){if(i.isBN(x))return x;this.negative=0,this.words=null,this.length=0,this.red=null,x!==null&&((u==="le"||u==="be")&&(h=u,u=10),this._init(x||0,u||10,h||"be"))}typeof e=="object"?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Nt().Buffer}catch{}i.isBN=function(u){return u instanceof i?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===i.wordSize&&Array.isArray(u.words)},i.max=function(u,h){return u.cmp(h)>0?u:h},i.min=function(u,h){return u.cmp(h)<0?u:h},i.prototype._init=function(u,h,y){if(typeof u=="number")return this._initNumber(u,h,y);if(typeof u=="object")return this._initArray(u,h,y);h==="hex"&&(h=16),r(h===(h|0)&&h>=2&&h<=36),u=u.toString().replace(/\s+/g,"");var w=0;u[0]==="-"&&(w++,this.negative=1),w<u.length&&(h===16?this._parseHex(u,w,y):(this._parseBase(u,h,w),y==="le"&&this._initArray(this.toArray(),h,y)))},i.prototype._initNumber=function(u,h,y){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(r(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),h,y)},i.prototype._initArray=function(u,h,y){if(r(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var S,R,A=0;if(y==="be")for(w=u.length-1,S=0;w>=0;w-=3)R=u[w]|u[w-1]<<8|u[w-2]<<16,this.words[S]|=R<<A&67108863,this.words[S+1]=R>>>26-A&67108863,A+=24,A>=26&&(A-=26,S++);else if(y==="le")for(w=0,S=0;w<u.length;w+=3)R=u[w]|u[w+1]<<8|u[w+2]<<16,this.words[S]|=R<<A&67108863,this.words[S+1]=R>>>26-A&67108863,A+=24,A>=26&&(A-=26,S++);return this.strip()};function s(x,u){var h=x.charCodeAt(u);return h>=65&&h<=70?h-55:h>=97&&h<=102?h-87:h-48&15}function a(x,u,h){var y=s(x,h);return h-1>=u&&(y|=s(x,h-1)<<4),y}i.prototype._parseHex=function(u,h,y){this.length=Math.ceil((u.length-h)/6),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var S=0,R=0,A;if(y==="be")for(w=u.length-1;w>=h;w-=2)A=a(u,h,w)<<S,this.words[R]|=A&67108863,S>=18?(S-=18,R+=1,this.words[R]|=A>>>26):S+=8;else{var _=u.length-h;for(w=_%2===0?h+1:h;w<u.length;w+=2)A=a(u,h,w)<<S,this.words[R]|=A&67108863,S>=18?(S-=18,R+=1,this.words[R]|=A>>>26):S+=8}this.strip()};function f(x,u,h,y){for(var w=0,S=Math.min(x.length,h),R=u;R<S;R++){var A=x.charCodeAt(R)-48;w*=y,A>=49?w+=A-49+10:A>=17?w+=A-17+10:w+=A}return w}i.prototype._parseBase=function(u,h,y){this.words=[0],this.length=1;for(var w=0,S=1;S<=67108863;S*=h)w++;w--,S=S/h|0;for(var R=u.length-y,A=R%w,_=Math.min(R,R-A)+y,c=0,b=y;b<_;b+=w)c=f(u,b,b+w,h),this.imuln(S),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(A!==0){var k=1;for(c=f(u,b,u.length,h),b=0;b<A;b++)k*=h;this.imuln(k),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this.strip()},i.prototype.copy=function(u){u.words=new Array(this.length);for(var h=0;h<this.length;h++)u.words[h]=this.words[h];u.length=this.length,u.negative=this.negative,u.red=this.red},i.prototype.clone=function(){var u=new i(null);return this.copy(u),u},i.prototype._expand=function(u){for(;this.length<u;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],m=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],g=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(u,h){u=u||10,h=h|0||1;var y;if(u===16||u==="hex"){y="";for(var w=0,S=0,R=0;R<this.length;R++){var A=this.words[R],_=((A<<w|S)&16777215).toString(16);S=A>>>24-w&16777215,w+=2,w>=26&&(w-=26,R--),S!==0||R!==this.length-1?y=l[6-_.length]+_+y:y=_+y}for(S!==0&&(y=S.toString(16)+y);y.length%h!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(u===(u|0)&&u>=2&&u<=36){var c=m[u],b=g[u];y="";var k=this.clone();for(k.negative=0;!k.isZero();){var D=k.modn(b).toString(u);k=k.idivn(b),k.isZero()?y=D+y:y=l[c-D.length]+D+y}for(this.isZero()&&(y="0"+y);y.length%h!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(u,h){return r(typeof o<"u"),this.toArrayLike(o,u,h)},i.prototype.toArray=function(u,h){return this.toArrayLike(Array,u,h)},i.prototype.toArrayLike=function(u,h,y){var w=this.byteLength(),S=y||Math.max(1,w);r(w<=S,"byte array longer than desired length"),r(S>0,"Requested array length <= 0"),this.strip();var R=h==="le",A=new u(S),_,c,b=this.clone();if(R){for(c=0;!b.isZero();c++)_=b.andln(255),b.iushrn(8),A[c]=_;for(;c<S;c++)A[c]=0}else{for(c=0;c<S-w;c++)A[c]=0;for(c=0;!b.isZero();c++)_=b.andln(255),b.iushrn(8),A[S-c-1]=_}return A},Math.clz32?i.prototype._countBits=function(u){return 32-Math.clz32(u)}:i.prototype._countBits=function(u){var h=u,y=0;return h>=4096&&(y+=13,h>>>=13),h>=64&&(y+=7,h>>>=7),h>=8&&(y+=4,h>>>=4),h>=2&&(y+=2,h>>>=2),y+h},i.prototype._zeroBits=function(u){if(u===0)return 26;var h=u,y=0;return(h&8191)===0&&(y+=13,h>>>=13),(h&127)===0&&(y+=7,h>>>=7),(h&15)===0&&(y+=4,h>>>=4),(h&3)===0&&(y+=2,h>>>=2),(h&1)===0&&y++,y},i.prototype.bitLength=function(){var u=this.words[this.length-1],h=this._countBits(u);return(this.length-1)*26+h};function v(x){for(var u=new Array(x.bitLength()),h=0;h<u.length;h++){var y=h/26|0,w=h%26;u[h]=(x.words[y]&1<<w)>>>w}return u}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,h=0;h<this.length;h++){var y=this._zeroBits(this.words[h]);if(u+=y,y!==26)break}return u},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},i.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var h=0;h<u.length;h++)this.words[h]=this.words[h]|u.words[h];return this.strip()},i.prototype.ior=function(u){return r((this.negative|u.negative)===0),this.iuor(u)},i.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},i.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},i.prototype.iuand=function(u){var h;this.length>u.length?h=u:h=this;for(var y=0;y<h.length;y++)this.words[y]=this.words[y]&u.words[y];return this.length=h.length,this.strip()},i.prototype.iand=function(u){return r((this.negative|u.negative)===0),this.iuand(u)},i.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},i.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},i.prototype.iuxor=function(u){var h,y;this.length>u.length?(h=this,y=u):(h=u,y=this);for(var w=0;w<y.length;w++)this.words[w]=h.words[w]^y.words[w];if(this!==h)for(;w<h.length;w++)this.words[w]=h.words[w];return this.length=h.length,this.strip()},i.prototype.ixor=function(u){return r((this.negative|u.negative)===0),this.iuxor(u)},i.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},i.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},i.prototype.inotn=function(u){r(typeof u=="number"&&u>=0);var h=Math.ceil(u/26)|0,y=u%26;this._expand(h),y>0&&h--;for(var w=0;w<h;w++)this.words[w]=~this.words[w]&67108863;for(y>0&&(this.words[w]=~this.words[w]&67108863>>26-y,w++);w<this.length;w++)this.words[w]=0;return this.strip()},i.prototype.notn=function(u){return this.clone().inotn(u)},i.prototype.setn=function(u,h){r(typeof u=="number"&&u>=0);var y=u/26|0,w=u%26;return this._expand(y+1),h?this.words[y]=this.words[y]|1<<w:this.words[y]=this.words[y]&~(1<<w),this.strip()},i.prototype.iadd=function(u){var h;if(this.negative!==0&&u.negative===0)return this.negative=0,h=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,h=this.isub(u),u.negative=1,h._normSign();var y,w;this.length>u.length?(y=this,w=u):(y=u,w=this);for(var S=0,R=0;R<w.length;R++)h=(y.words[R]|0)+(w.words[R]|0)+S,this.words[R]=h&67108863,S=h>>>26;for(;S!==0&&R<y.length;R++)h=(y.words[R]|0)+S,this.words[R]=h&67108863,S=h>>>26;if(this.length=y.length,S!==0)this.words[this.length]=S,this.length++;else if(y!==this)for(;R<y.length;R++)this.words[R]=y.words[R];return this},i.prototype.add=function(u){var h;return u.negative!==0&&this.negative===0?(u.negative=0,h=this.sub(u),u.negative^=1,h):u.negative===0&&this.negative!==0?(this.negative=0,h=u.sub(this),this.negative=1,h):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},i.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var h=this.iadd(u);return u.negative=1,h._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var y=this.cmp(u);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var w,S;y>0?(w=this,S=u):(w=u,S=this);for(var R=0,A=0;A<S.length;A++)h=(w.words[A]|0)-(S.words[A]|0)+R,R=h>>26,this.words[A]=h&67108863;for(;R!==0&&A<w.length;A++)h=(w.words[A]|0)+R,R=h>>26,this.words[A]=h&67108863;if(R===0&&A<w.length&&w!==this)for(;A<w.length;A++)this.words[A]=w.words[A];return this.length=Math.max(this.length,A),w!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(u){return this.clone().isub(u)};function E(x,u,h){h.negative=u.negative^x.negative;var y=x.length+u.length|0;h.length=y,y=y-1|0;var w=x.words[0]|0,S=u.words[0]|0,R=w*S,A=R&67108863,_=R/67108864|0;h.words[0]=A;for(var c=1;c<y;c++){for(var b=_>>>26,k=_&67108863,D=Math.min(c,u.length-1),K=Math.max(0,c-x.length+1);K<=D;K++){var G=c-K|0;w=x.words[G]|0,S=u.words[K]|0,R=w*S+k,b+=R/67108864|0,k=R&67108863}h.words[c]=k|0,_=b|0}return _!==0?h.words[c]=_|0:h.length--,h.strip()}var T=function(u,h,y){var w=u.words,S=h.words,R=y.words,A=0,_,c,b,k=w[0]|0,D=k&8191,K=k>>>13,G=w[1]|0,X=G&8191,Z=G>>>13,le=w[2]|0,se=le&8191,O=le>>>13,C=w[3]|0,U=C&8191,j=C>>>13,re=w[4]|0,J=re&8191,te=re>>>13,ae=w[5]|0,oe=ae&8191,ue=ae>>>13,_e=w[6]|0,Se=_e&8191,fe=_e>>>13,de=w[7]|0,be=de&8191,xe=de>>>13,or=w[8]|0,Ze=or&8191,Ve=or>>>13,Ya=w[9]|0,Je=Ya&8191,st=Ya>>>13,Vp=S[0]|0,at=Vp&8191,ut=Vp>>>13,Wp=S[1]|0,ft=Wp&8191,ct=Wp>>>13,zp=S[2]|0,lt=zp&8191,ht=zp>>>13,Yp=S[3]|0,dt=Yp&8191,pt=Yp>>>13,$p=S[4]|0,gt=$p&8191,yt=$p>>>13,Zp=S[5]|0,mt=Zp&8191,vt=Zp>>>13,Xp=S[6]|0,bt=Xp&8191,_t=Xp>>>13,Jp=S[7]|0,wt=Jp&8191,St=Jp>>>13,Qp=S[8]|0,Et=Qp&8191,xt=Qp>>>13,e0=S[9]|0,It=e0&8191,At=e0>>>13;y.negative=u.negative^h.negative,y.length=19,_=Math.imul(D,at),c=Math.imul(D,ut),c=c+Math.imul(K,at)|0,b=Math.imul(K,ut);var qc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(qc>>>26)|0,qc&=67108863,_=Math.imul(X,at),c=Math.imul(X,ut),c=c+Math.imul(Z,at)|0,b=Math.imul(Z,ut),_=_+Math.imul(D,ft)|0,c=c+Math.imul(D,ct)|0,c=c+Math.imul(K,ft)|0,b=b+Math.imul(K,ct)|0;var jc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(jc>>>26)|0,jc&=67108863,_=Math.imul(se,at),c=Math.imul(se,ut),c=c+Math.imul(O,at)|0,b=Math.imul(O,ut),_=_+Math.imul(X,ft)|0,c=c+Math.imul(X,ct)|0,c=c+Math.imul(Z,ft)|0,b=b+Math.imul(Z,ct)|0,_=_+Math.imul(D,lt)|0,c=c+Math.imul(D,ht)|0,c=c+Math.imul(K,lt)|0,b=b+Math.imul(K,ht)|0;var Hc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Hc>>>26)|0,Hc&=67108863,_=Math.imul(U,at),c=Math.imul(U,ut),c=c+Math.imul(j,at)|0,b=Math.imul(j,ut),_=_+Math.imul(se,ft)|0,c=c+Math.imul(se,ct)|0,c=c+Math.imul(O,ft)|0,b=b+Math.imul(O,ct)|0,_=_+Math.imul(X,lt)|0,c=c+Math.imul(X,ht)|0,c=c+Math.imul(Z,lt)|0,b=b+Math.imul(Z,ht)|0,_=_+Math.imul(D,dt)|0,c=c+Math.imul(D,pt)|0,c=c+Math.imul(K,dt)|0,b=b+Math.imul(K,pt)|0;var Kc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Kc>>>26)|0,Kc&=67108863,_=Math.imul(J,at),c=Math.imul(J,ut),c=c+Math.imul(te,at)|0,b=Math.imul(te,ut),_=_+Math.imul(U,ft)|0,c=c+Math.imul(U,ct)|0,c=c+Math.imul(j,ft)|0,b=b+Math.imul(j,ct)|0,_=_+Math.imul(se,lt)|0,c=c+Math.imul(se,ht)|0,c=c+Math.imul(O,lt)|0,b=b+Math.imul(O,ht)|0,_=_+Math.imul(X,dt)|0,c=c+Math.imul(X,pt)|0,c=c+Math.imul(Z,dt)|0,b=b+Math.imul(Z,pt)|0,_=_+Math.imul(D,gt)|0,c=c+Math.imul(D,yt)|0,c=c+Math.imul(K,gt)|0,b=b+Math.imul(K,yt)|0;var Gc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Gc>>>26)|0,Gc&=67108863,_=Math.imul(oe,at),c=Math.imul(oe,ut),c=c+Math.imul(ue,at)|0,b=Math.imul(ue,ut),_=_+Math.imul(J,ft)|0,c=c+Math.imul(J,ct)|0,c=c+Math.imul(te,ft)|0,b=b+Math.imul(te,ct)|0,_=_+Math.imul(U,lt)|0,c=c+Math.imul(U,ht)|0,c=c+Math.imul(j,lt)|0,b=b+Math.imul(j,ht)|0,_=_+Math.imul(se,dt)|0,c=c+Math.imul(se,pt)|0,c=c+Math.imul(O,dt)|0,b=b+Math.imul(O,pt)|0,_=_+Math.imul(X,gt)|0,c=c+Math.imul(X,yt)|0,c=c+Math.imul(Z,gt)|0,b=b+Math.imul(Z,yt)|0,_=_+Math.imul(D,mt)|0,c=c+Math.imul(D,vt)|0,c=c+Math.imul(K,mt)|0,b=b+Math.imul(K,vt)|0;var Vc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Vc>>>26)|0,Vc&=67108863,_=Math.imul(Se,at),c=Math.imul(Se,ut),c=c+Math.imul(fe,at)|0,b=Math.imul(fe,ut),_=_+Math.imul(oe,ft)|0,c=c+Math.imul(oe,ct)|0,c=c+Math.imul(ue,ft)|0,b=b+Math.imul(ue,ct)|0,_=_+Math.imul(J,lt)|0,c=c+Math.imul(J,ht)|0,c=c+Math.imul(te,lt)|0,b=b+Math.imul(te,ht)|0,_=_+Math.imul(U,dt)|0,c=c+Math.imul(U,pt)|0,c=c+Math.imul(j,dt)|0,b=b+Math.imul(j,pt)|0,_=_+Math.imul(se,gt)|0,c=c+Math.imul(se,yt)|0,c=c+Math.imul(O,gt)|0,b=b+Math.imul(O,yt)|0,_=_+Math.imul(X,mt)|0,c=c+Math.imul(X,vt)|0,c=c+Math.imul(Z,mt)|0,b=b+Math.imul(Z,vt)|0,_=_+Math.imul(D,bt)|0,c=c+Math.imul(D,_t)|0,c=c+Math.imul(K,bt)|0,b=b+Math.imul(K,_t)|0;var Wc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Wc>>>26)|0,Wc&=67108863,_=Math.imul(be,at),c=Math.imul(be,ut),c=c+Math.imul(xe,at)|0,b=Math.imul(xe,ut),_=_+Math.imul(Se,ft)|0,c=c+Math.imul(Se,ct)|0,c=c+Math.imul(fe,ft)|0,b=b+Math.imul(fe,ct)|0,_=_+Math.imul(oe,lt)|0,c=c+Math.imul(oe,ht)|0,c=c+Math.imul(ue,lt)|0,b=b+Math.imul(ue,ht)|0,_=_+Math.imul(J,dt)|0,c=c+Math.imul(J,pt)|0,c=c+Math.imul(te,dt)|0,b=b+Math.imul(te,pt)|0,_=_+Math.imul(U,gt)|0,c=c+Math.imul(U,yt)|0,c=c+Math.imul(j,gt)|0,b=b+Math.imul(j,yt)|0,_=_+Math.imul(se,mt)|0,c=c+Math.imul(se,vt)|0,c=c+Math.imul(O,mt)|0,b=b+Math.imul(O,vt)|0,_=_+Math.imul(X,bt)|0,c=c+Math.imul(X,_t)|0,c=c+Math.imul(Z,bt)|0,b=b+Math.imul(Z,_t)|0,_=_+Math.imul(D,wt)|0,c=c+Math.imul(D,St)|0,c=c+Math.imul(K,wt)|0,b=b+Math.imul(K,St)|0;var zc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(zc>>>26)|0,zc&=67108863,_=Math.imul(Ze,at),c=Math.imul(Ze,ut),c=c+Math.imul(Ve,at)|0,b=Math.imul(Ve,ut),_=_+Math.imul(be,ft)|0,c=c+Math.imul(be,ct)|0,c=c+Math.imul(xe,ft)|0,b=b+Math.imul(xe,ct)|0,_=_+Math.imul(Se,lt)|0,c=c+Math.imul(Se,ht)|0,c=c+Math.imul(fe,lt)|0,b=b+Math.imul(fe,ht)|0,_=_+Math.imul(oe,dt)|0,c=c+Math.imul(oe,pt)|0,c=c+Math.imul(ue,dt)|0,b=b+Math.imul(ue,pt)|0,_=_+Math.imul(J,gt)|0,c=c+Math.imul(J,yt)|0,c=c+Math.imul(te,gt)|0,b=b+Math.imul(te,yt)|0,_=_+Math.imul(U,mt)|0,c=c+Math.imul(U,vt)|0,c=c+Math.imul(j,mt)|0,b=b+Math.imul(j,vt)|0,_=_+Math.imul(se,bt)|0,c=c+Math.imul(se,_t)|0,c=c+Math.imul(O,bt)|0,b=b+Math.imul(O,_t)|0,_=_+Math.imul(X,wt)|0,c=c+Math.imul(X,St)|0,c=c+Math.imul(Z,wt)|0,b=b+Math.imul(Z,St)|0,_=_+Math.imul(D,Et)|0,c=c+Math.imul(D,xt)|0,c=c+Math.imul(K,Et)|0,b=b+Math.imul(K,xt)|0;var Yc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Yc>>>26)|0,Yc&=67108863,_=Math.imul(Je,at),c=Math.imul(Je,ut),c=c+Math.imul(st,at)|0,b=Math.imul(st,ut),_=_+Math.imul(Ze,ft)|0,c=c+Math.imul(Ze,ct)|0,c=c+Math.imul(Ve,ft)|0,b=b+Math.imul(Ve,ct)|0,_=_+Math.imul(be,lt)|0,c=c+Math.imul(be,ht)|0,c=c+Math.imul(xe,lt)|0,b=b+Math.imul(xe,ht)|0,_=_+Math.imul(Se,dt)|0,c=c+Math.imul(Se,pt)|0,c=c+Math.imul(fe,dt)|0,b=b+Math.imul(fe,pt)|0,_=_+Math.imul(oe,gt)|0,c=c+Math.imul(oe,yt)|0,c=c+Math.imul(ue,gt)|0,b=b+Math.imul(ue,yt)|0,_=_+Math.imul(J,mt)|0,c=c+Math.imul(J,vt)|0,c=c+Math.imul(te,mt)|0,b=b+Math.imul(te,vt)|0,_=_+Math.imul(U,bt)|0,c=c+Math.imul(U,_t)|0,c=c+Math.imul(j,bt)|0,b=b+Math.imul(j,_t)|0,_=_+Math.imul(se,wt)|0,c=c+Math.imul(se,St)|0,c=c+Math.imul(O,wt)|0,b=b+Math.imul(O,St)|0,_=_+Math.imul(X,Et)|0,c=c+Math.imul(X,xt)|0,c=c+Math.imul(Z,Et)|0,b=b+Math.imul(Z,xt)|0,_=_+Math.imul(D,It)|0,c=c+Math.imul(D,At)|0,c=c+Math.imul(K,It)|0,b=b+Math.imul(K,At)|0;var $c=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+($c>>>26)|0,$c&=67108863,_=Math.imul(Je,ft),c=Math.imul(Je,ct),c=c+Math.imul(st,ft)|0,b=Math.imul(st,ct),_=_+Math.imul(Ze,lt)|0,c=c+Math.imul(Ze,ht)|0,c=c+Math.imul(Ve,lt)|0,b=b+Math.imul(Ve,ht)|0,_=_+Math.imul(be,dt)|0,c=c+Math.imul(be,pt)|0,c=c+Math.imul(xe,dt)|0,b=b+Math.imul(xe,pt)|0,_=_+Math.imul(Se,gt)|0,c=c+Math.imul(Se,yt)|0,c=c+Math.imul(fe,gt)|0,b=b+Math.imul(fe,yt)|0,_=_+Math.imul(oe,mt)|0,c=c+Math.imul(oe,vt)|0,c=c+Math.imul(ue,mt)|0,b=b+Math.imul(ue,vt)|0,_=_+Math.imul(J,bt)|0,c=c+Math.imul(J,_t)|0,c=c+Math.imul(te,bt)|0,b=b+Math.imul(te,_t)|0,_=_+Math.imul(U,wt)|0,c=c+Math.imul(U,St)|0,c=c+Math.imul(j,wt)|0,b=b+Math.imul(j,St)|0,_=_+Math.imul(se,Et)|0,c=c+Math.imul(se,xt)|0,c=c+Math.imul(O,Et)|0,b=b+Math.imul(O,xt)|0,_=_+Math.imul(X,It)|0,c=c+Math.imul(X,At)|0,c=c+Math.imul(Z,It)|0,b=b+Math.imul(Z,At)|0;var Zc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Zc>>>26)|0,Zc&=67108863,_=Math.imul(Je,lt),c=Math.imul(Je,ht),c=c+Math.imul(st,lt)|0,b=Math.imul(st,ht),_=_+Math.imul(Ze,dt)|0,c=c+Math.imul(Ze,pt)|0,c=c+Math.imul(Ve,dt)|0,b=b+Math.imul(Ve,pt)|0,_=_+Math.imul(be,gt)|0,c=c+Math.imul(be,yt)|0,c=c+Math.imul(xe,gt)|0,b=b+Math.imul(xe,yt)|0,_=_+Math.imul(Se,mt)|0,c=c+Math.imul(Se,vt)|0,c=c+Math.imul(fe,mt)|0,b=b+Math.imul(fe,vt)|0,_=_+Math.imul(oe,bt)|0,c=c+Math.imul(oe,_t)|0,c=c+Math.imul(ue,bt)|0,b=b+Math.imul(ue,_t)|0,_=_+Math.imul(J,wt)|0,c=c+Math.imul(J,St)|0,c=c+Math.imul(te,wt)|0,b=b+Math.imul(te,St)|0,_=_+Math.imul(U,Et)|0,c=c+Math.imul(U,xt)|0,c=c+Math.imul(j,Et)|0,b=b+Math.imul(j,xt)|0,_=_+Math.imul(se,It)|0,c=c+Math.imul(se,At)|0,c=c+Math.imul(O,It)|0,b=b+Math.imul(O,At)|0;var Xc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Xc>>>26)|0,Xc&=67108863,_=Math.imul(Je,dt),c=Math.imul(Je,pt),c=c+Math.imul(st,dt)|0,b=Math.imul(st,pt),_=_+Math.imul(Ze,gt)|0,c=c+Math.imul(Ze,yt)|0,c=c+Math.imul(Ve,gt)|0,b=b+Math.imul(Ve,yt)|0,_=_+Math.imul(be,mt)|0,c=c+Math.imul(be,vt)|0,c=c+Math.imul(xe,mt)|0,b=b+Math.imul(xe,vt)|0,_=_+Math.imul(Se,bt)|0,c=c+Math.imul(Se,_t)|0,c=c+Math.imul(fe,bt)|0,b=b+Math.imul(fe,_t)|0,_=_+Math.imul(oe,wt)|0,c=c+Math.imul(oe,St)|0,c=c+Math.imul(ue,wt)|0,b=b+Math.imul(ue,St)|0,_=_+Math.imul(J,Et)|0,c=c+Math.imul(J,xt)|0,c=c+Math.imul(te,Et)|0,b=b+Math.imul(te,xt)|0,_=_+Math.imul(U,It)|0,c=c+Math.imul(U,At)|0,c=c+Math.imul(j,It)|0,b=b+Math.imul(j,At)|0;var Jc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Jc>>>26)|0,Jc&=67108863,_=Math.imul(Je,gt),c=Math.imul(Je,yt),c=c+Math.imul(st,gt)|0,b=Math.imul(st,yt),_=_+Math.imul(Ze,mt)|0,c=c+Math.imul(Ze,vt)|0,c=c+Math.imul(Ve,mt)|0,b=b+Math.imul(Ve,vt)|0,_=_+Math.imul(be,bt)|0,c=c+Math.imul(be,_t)|0,c=c+Math.imul(xe,bt)|0,b=b+Math.imul(xe,_t)|0,_=_+Math.imul(Se,wt)|0,c=c+Math.imul(Se,St)|0,c=c+Math.imul(fe,wt)|0,b=b+Math.imul(fe,St)|0,_=_+Math.imul(oe,Et)|0,c=c+Math.imul(oe,xt)|0,c=c+Math.imul(ue,Et)|0,b=b+Math.imul(ue,xt)|0,_=_+Math.imul(J,It)|0,c=c+Math.imul(J,At)|0,c=c+Math.imul(te,It)|0,b=b+Math.imul(te,At)|0;var Qc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Qc>>>26)|0,Qc&=67108863,_=Math.imul(Je,mt),c=Math.imul(Je,vt),c=c+Math.imul(st,mt)|0,b=Math.imul(st,vt),_=_+Math.imul(Ze,bt)|0,c=c+Math.imul(Ze,_t)|0,c=c+Math.imul(Ve,bt)|0,b=b+Math.imul(Ve,_t)|0,_=_+Math.imul(be,wt)|0,c=c+Math.imul(be,St)|0,c=c+Math.imul(xe,wt)|0,b=b+Math.imul(xe,St)|0,_=_+Math.imul(Se,Et)|0,c=c+Math.imul(Se,xt)|0,c=c+Math.imul(fe,Et)|0,b=b+Math.imul(fe,xt)|0,_=_+Math.imul(oe,It)|0,c=c+Math.imul(oe,At)|0,c=c+Math.imul(ue,It)|0,b=b+Math.imul(ue,At)|0;var el=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(el>>>26)|0,el&=67108863,_=Math.imul(Je,bt),c=Math.imul(Je,_t),c=c+Math.imul(st,bt)|0,b=Math.imul(st,_t),_=_+Math.imul(Ze,wt)|0,c=c+Math.imul(Ze,St)|0,c=c+Math.imul(Ve,wt)|0,b=b+Math.imul(Ve,St)|0,_=_+Math.imul(be,Et)|0,c=c+Math.imul(be,xt)|0,c=c+Math.imul(xe,Et)|0,b=b+Math.imul(xe,xt)|0,_=_+Math.imul(Se,It)|0,c=c+Math.imul(Se,At)|0,c=c+Math.imul(fe,It)|0,b=b+Math.imul(fe,At)|0;var tl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(tl>>>26)|0,tl&=67108863,_=Math.imul(Je,wt),c=Math.imul(Je,St),c=c+Math.imul(st,wt)|0,b=Math.imul(st,St),_=_+Math.imul(Ze,Et)|0,c=c+Math.imul(Ze,xt)|0,c=c+Math.imul(Ve,Et)|0,b=b+Math.imul(Ve,xt)|0,_=_+Math.imul(be,It)|0,c=c+Math.imul(be,At)|0,c=c+Math.imul(xe,It)|0,b=b+Math.imul(xe,At)|0;var rl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(rl>>>26)|0,rl&=67108863,_=Math.imul(Je,Et),c=Math.imul(Je,xt),c=c+Math.imul(st,Et)|0,b=Math.imul(st,xt),_=_+Math.imul(Ze,It)|0,c=c+Math.imul(Ze,At)|0,c=c+Math.imul(Ve,It)|0,b=b+Math.imul(Ve,At)|0;var nl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(nl>>>26)|0,nl&=67108863,_=Math.imul(Je,It),c=Math.imul(Je,At),c=c+Math.imul(st,It)|0,b=Math.imul(st,At);var il=(A+_|0)+((c&8191)<<13)|0;return A=(b+(c>>>13)|0)+(il>>>26)|0,il&=67108863,R[0]=qc,R[1]=jc,R[2]=Hc,R[3]=Kc,R[4]=Gc,R[5]=Vc,R[6]=Wc,R[7]=zc,R[8]=Yc,R[9]=$c,R[10]=Zc,R[11]=Xc,R[12]=Jc,R[13]=Qc,R[14]=el,R[15]=tl,R[16]=rl,R[17]=nl,R[18]=il,A!==0&&(R[19]=A,y.length++),y};Math.imul||(T=E);function N(x,u,h){h.negative=u.negative^x.negative,h.length=x.length+u.length;for(var y=0,w=0,S=0;S<h.length-1;S++){var R=w;w=0;for(var A=y&67108863,_=Math.min(S,u.length-1),c=Math.max(0,S-x.length+1);c<=_;c++){var b=S-c,k=x.words[b]|0,D=u.words[c]|0,K=k*D,G=K&67108863;R=R+(K/67108864|0)|0,G=G+A|0,A=G&67108863,R=R+(G>>>26)|0,w+=R>>>26,R&=67108863}h.words[S]=A,y=R,R=w}return y!==0?h.words[S]=y:h.length--,h.strip()}function L(x,u,h){var y=new F;return y.mulp(x,u,h)}i.prototype.mulTo=function(u,h){var y,w=this.length+u.length;return this.length===10&&u.length===10?y=T(this,u,h):w<63?y=E(this,u,h):w<1024?y=N(this,u,h):y=L(this,u,h),y};function F(x,u){this.x=x,this.y=u}F.prototype.makeRBT=function(u){for(var h=new Array(u),y=i.prototype._countBits(u)-1,w=0;w<u;w++)h[w]=this.revBin(w,y,u);return h},F.prototype.revBin=function(u,h,y){if(u===0||u===y-1)return u;for(var w=0,S=0;S<h;S++)w|=(u&1)<<h-S-1,u>>=1;return w},F.prototype.permute=function(u,h,y,w,S,R){for(var A=0;A<R;A++)w[A]=h[u[A]],S[A]=y[u[A]]},F.prototype.transform=function(u,h,y,w,S,R){this.permute(R,u,h,y,w,S);for(var A=1;A<S;A<<=1)for(var _=A<<1,c=Math.cos(2*Math.PI/_),b=Math.sin(2*Math.PI/_),k=0;k<S;k+=_)for(var D=c,K=b,G=0;G<A;G++){var X=y[k+G],Z=w[k+G],le=y[k+G+A],se=w[k+G+A],O=D*le-K*se;se=D*se+K*le,le=O,y[k+G]=X+le,w[k+G]=Z+se,y[k+G+A]=X-le,w[k+G+A]=Z-se,G!==_&&(O=c*D-b*K,K=c*K+b*D,D=O)}},F.prototype.guessLen13b=function(u,h){var y=Math.max(h,u)|1,w=y&1,S=0;for(y=y/2|0;y;y=y>>>1)S++;return 1<<S+1+w},F.prototype.conjugate=function(u,h,y){if(!(y<=1))for(var w=0;w<y/2;w++){var S=u[w];u[w]=u[y-w-1],u[y-w-1]=S,S=h[w],h[w]=-h[y-w-1],h[y-w-1]=-S}},F.prototype.normalize13b=function(u,h){for(var y=0,w=0;w<h/2;w++){var S=Math.round(u[2*w+1]/h)*8192+Math.round(u[2*w]/h)+y;u[w]=S&67108863,S<67108864?y=0:y=S/67108864|0}return u},F.prototype.convert13b=function(u,h,y,w){for(var S=0,R=0;R<h;R++)S=S+(u[R]|0),y[2*R]=S&8191,S=S>>>13,y[2*R+1]=S&8191,S=S>>>13;for(R=2*h;R<w;++R)y[R]=0;r(S===0),r((S&-8192)===0)},F.prototype.stub=function(u){for(var h=new Array(u),y=0;y<u;y++)h[y]=0;return h},F.prototype.mulp=function(u,h,y){var w=2*this.guessLen13b(u.length,h.length),S=this.makeRBT(w),R=this.stub(w),A=new Array(w),_=new Array(w),c=new Array(w),b=new Array(w),k=new Array(w),D=new Array(w),K=y.words;K.length=w,this.convert13b(u.words,u.length,A,w),this.convert13b(h.words,h.length,b,w),this.transform(A,R,_,c,w,S),this.transform(b,R,k,D,w,S);for(var G=0;G<w;G++){var X=_[G]*k[G]-c[G]*D[G];c[G]=_[G]*D[G]+c[G]*k[G],_[G]=X}return this.conjugate(_,c,w),this.transform(_,c,K,R,w,S),this.conjugate(K,R,w),this.normalize13b(K,w),y.negative=u.negative^h.negative,y.length=u.length+h.length,y.strip()},i.prototype.mul=function(u){var h=new i(null);return h.words=new Array(this.length+u.length),this.mulTo(u,h)},i.prototype.mulf=function(u){var h=new i(null);return h.words=new Array(this.length+u.length),L(this,u,h)},i.prototype.imul=function(u){return this.clone().mulTo(u,this)},i.prototype.imuln=function(u){r(typeof u=="number"),r(u<67108864);for(var h=0,y=0;y<this.length;y++){var w=(this.words[y]|0)*u,S=(w&67108863)+(h&67108863);h>>=26,h+=w/67108864|0,h+=S>>>26,this.words[y]=S&67108863}return h!==0&&(this.words[y]=h,this.length++),u===0&&(this.length=1,this._normSign()),this},i.prototype.muln=function(u){return this.clone().imuln(u)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(u){var h=v(u);if(h.length===0)return new i(1);for(var y=this,w=0;w<h.length&&h[w]===0;w++,y=y.sqr());if(++w<h.length)for(var S=y.sqr();w<h.length;w++,S=S.sqr())h[w]!==0&&(y=y.mul(S));return y},i.prototype.iushln=function(u){r(typeof u=="number"&&u>=0);var h=u%26,y=(u-h)/26,w=67108863>>>26-h<<26-h,S;if(h!==0){var R=0;for(S=0;S<this.length;S++){var A=this.words[S]&w,_=(this.words[S]|0)-A<<h;this.words[S]=_|R,R=A>>>26-h}R&&(this.words[S]=R,this.length++)}if(y!==0){for(S=this.length-1;S>=0;S--)this.words[S+y]=this.words[S];for(S=0;S<y;S++)this.words[S]=0;this.length+=y}return this.strip()},i.prototype.ishln=function(u){return r(this.negative===0),this.iushln(u)},i.prototype.iushrn=function(u,h,y){r(typeof u=="number"&&u>=0);var w;h?w=(h-h%26)/26:w=0;var S=u%26,R=Math.min((u-S)/26,this.length),A=67108863^67108863>>>S<<S,_=y;if(w-=R,w=Math.max(0,w),_){for(var c=0;c<R;c++)_.words[c]=this.words[c];_.length=R}if(R!==0)if(this.length>R)for(this.length-=R,c=0;c<this.length;c++)this.words[c]=this.words[c+R];else this.words[0]=0,this.length=1;var b=0;for(c=this.length-1;c>=0&&(b!==0||c>=w);c--){var k=this.words[c]|0;this.words[c]=b<<26-S|k>>>S,b=k&A}return _&&b!==0&&(_.words[_.length++]=b),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(u,h,y){return r(this.negative===0),this.iushrn(u,h,y)},i.prototype.shln=function(u){return this.clone().ishln(u)},i.prototype.ushln=function(u){return this.clone().iushln(u)},i.prototype.shrn=function(u){return this.clone().ishrn(u)},i.prototype.ushrn=function(u){return this.clone().iushrn(u)},i.prototype.testn=function(u){r(typeof u=="number"&&u>=0);var h=u%26,y=(u-h)/26,w=1<<h;if(this.length<=y)return!1;var S=this.words[y];return!!(S&w)},i.prototype.imaskn=function(u){r(typeof u=="number"&&u>=0);var h=u%26,y=(u-h)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(h!==0&&y++,this.length=Math.min(y,this.length),h!==0){var w=67108863^67108863>>>h<<h;this.words[this.length-1]&=w}return this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.maskn=function(u){return this.clone().imaskn(u)},i.prototype.iaddn=function(u){return r(typeof u=="number"),r(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},i.prototype._iaddn=function(u){this.words[0]+=u;for(var h=0;h<this.length&&this.words[h]>=67108864;h++)this.words[h]-=67108864,h===this.length-1?this.words[h+1]=1:this.words[h+1]++;return this.length=Math.max(this.length,h+1),this},i.prototype.isubn=function(u){if(r(typeof u=="number"),r(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var h=0;h<this.length&&this.words[h]<0;h++)this.words[h]+=67108864,this.words[h+1]-=1;return this.strip()},i.prototype.addn=function(u){return this.clone().iaddn(u)},i.prototype.subn=function(u){return this.clone().isubn(u)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(u,h,y){var w=u.length+y,S;this._expand(w);var R,A=0;for(S=0;S<u.length;S++){R=(this.words[S+y]|0)+A;var _=(u.words[S]|0)*h;R-=_&67108863,A=(R>>26)-(_/67108864|0),this.words[S+y]=R&67108863}for(;S<this.length-y;S++)R=(this.words[S+y]|0)+A,A=R>>26,this.words[S+y]=R&67108863;if(A===0)return this.strip();for(r(A===-1),A=0,S=0;S<this.length;S++)R=-(this.words[S]|0)+A,A=R>>26,this.words[S]=R&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(u,h){var y=this.length-u.length,w=this.clone(),S=u,R=S.words[S.length-1]|0,A=this._countBits(R);y=26-A,y!==0&&(S=S.ushln(y),w.iushln(y),R=S.words[S.length-1]|0);var _=w.length-S.length,c;if(h!=="mod"){c=new i(null),c.length=_+1,c.words=new Array(c.length);for(var b=0;b<c.length;b++)c.words[b]=0}var k=w.clone()._ishlnsubmul(S,1,_);k.negative===0&&(w=k,c&&(c.words[_]=1));for(var D=_-1;D>=0;D--){var K=(w.words[S.length+D]|0)*67108864+(w.words[S.length+D-1]|0);for(K=Math.min(K/R|0,67108863),w._ishlnsubmul(S,K,D);w.negative!==0;)K--,w.negative=0,w._ishlnsubmul(S,1,D),w.isZero()||(w.negative^=1);c&&(c.words[D]=K)}return c&&c.strip(),w.strip(),h!=="div"&&y!==0&&w.iushrn(y),{div:c||null,mod:w}},i.prototype.divmod=function(u,h,y){if(r(!u.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var w,S,R;return this.negative!==0&&u.negative===0?(R=this.neg().divmod(u,h),h!=="mod"&&(w=R.div.neg()),h!=="div"&&(S=R.mod.neg(),y&&S.negative!==0&&S.iadd(u)),{div:w,mod:S}):this.negative===0&&u.negative!==0?(R=this.divmod(u.neg(),h),h!=="mod"&&(w=R.div.neg()),{div:w,mod:R.mod}):(this.negative&u.negative)!==0?(R=this.neg().divmod(u.neg(),h),h!=="div"&&(S=R.mod.neg(),y&&S.negative!==0&&S.isub(u)),{div:R.div,mod:S}):u.length>this.length||this.cmp(u)<0?{div:new i(0),mod:this}:u.length===1?h==="div"?{div:this.divn(u.words[0]),mod:null}:h==="mod"?{div:null,mod:new i(this.modn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new i(this.modn(u.words[0]))}:this._wordDiv(u,h)},i.prototype.div=function(u){return this.divmod(u,"div",!1).div},i.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},i.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},i.prototype.divRound=function(u){var h=this.divmod(u);if(h.mod.isZero())return h.div;var y=h.mod.abs(),w=u.abs().iushrn(1),S=u.words[0]&1,R=y.cmp(w);if(R<0||S===1&&R===0)return h.div;var A=new i(1);return A.negative=this.negative^u.negative,h.div.iadd(A)},i.prototype.modn=function(u){r(u<=67108863);for(var h=(1<<26)%u,y=0,w=this.length-1;w>=0;w--)y=(h*y+(this.words[w]|0))%u;return y},i.prototype.idivn=function(u){r(u<=67108863);for(var h=0,y=this.length-1;y>=0;y--){var w=(this.words[y]|0)+h*67108864;this.words[y]=w/u|0,h=w%u}return this.strip()},i.prototype.divn=function(u){return this.clone().idivn(u)},i.prototype.egcd=function(u){r(u.negative===0),r(!u.isZero());var h=this,y=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var w=new i(1),S=new i(0),R=new i(0),A=new i(1),_=0;h.isEven()&&y.isEven();)h.iushrn(1),y.iushrn(1),++_;for(var c=y.clone(),b=h.clone();!h.isZero();){for(var k=0,D=1;(h.words[0]&D)===0&&k<26;++k,D<<=1);if(k>0)for(h.iushrn(k);k-- >0;)(w.isOdd()||S.isOdd())&&(w.iadd(c),S.isub(b)),w.iushrn(1),S.iushrn(1);for(var K=0,G=1;(y.words[0]&G)===0&&K<26;++K,G<<=1);if(K>0)for(y.iushrn(K);K-- >0;)(R.isOdd()||A.isOdd())&&(R.iadd(c),A.isub(b)),R.iushrn(1),A.iushrn(1);h.cmp(y)>=0?(h.isub(y),w.isub(R),S.isub(A)):(y.isub(h),R.isub(w),A.isub(S))}return{a:R,b:A,gcd:y.iushln(_)}},i.prototype._invmp=function(u){r(u.negative===0),r(!u.isZero());var h=this,y=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var w=new i(1),S=new i(0),R=y.clone();h.cmpn(1)>0&&y.cmpn(1)>0;){for(var A=0,_=1;(h.words[0]&_)===0&&A<26;++A,_<<=1);if(A>0)for(h.iushrn(A);A-- >0;)w.isOdd()&&w.iadd(R),w.iushrn(1);for(var c=0,b=1;(y.words[0]&b)===0&&c<26;++c,b<<=1);if(c>0)for(y.iushrn(c);c-- >0;)S.isOdd()&&S.iadd(R),S.iushrn(1);h.cmp(y)>=0?(h.isub(y),w.isub(S)):(y.isub(h),S.isub(w))}var k;return h.cmpn(1)===0?k=w:k=S,k.cmpn(0)<0&&k.iadd(u),k},i.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var h=this.clone(),y=u.clone();h.negative=0,y.negative=0;for(var w=0;h.isEven()&&y.isEven();w++)h.iushrn(1),y.iushrn(1);do{for(;h.isEven();)h.iushrn(1);for(;y.isEven();)y.iushrn(1);var S=h.cmp(y);if(S<0){var R=h;h=y,y=R}else if(S===0||y.cmpn(1)===0)break;h.isub(y)}while(!0);return y.iushln(w)},i.prototype.invm=function(u){return this.egcd(u).a.umod(u)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(u){return this.words[0]&u},i.prototype.bincn=function(u){r(typeof u=="number");var h=u%26,y=(u-h)/26,w=1<<h;if(this.length<=y)return this._expand(y+1),this.words[y]|=w,this;for(var S=w,R=y;S!==0&&R<this.length;R++){var A=this.words[R]|0;A+=S,S=A>>>26,A&=67108863,this.words[R]=A}return S!==0&&(this.words[R]=S,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(u){var h=u<0;if(this.negative!==0&&!h)return-1;if(this.negative===0&&h)return 1;this.strip();var y;if(this.length>1)y=1;else{h&&(u=-u),r(u<=67108863,"Number is too big");var w=this.words[0]|0;y=w===u?0:w<u?-1:1}return this.negative!==0?-y|0:y},i.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var h=this.ucmp(u);return this.negative!==0?-h|0:h},i.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var h=0,y=this.length-1;y>=0;y--){var w=this.words[y]|0,S=u.words[y]|0;if(w!==S){w<S?h=-1:w>S&&(h=1);break}}return h},i.prototype.gtn=function(u){return this.cmpn(u)===1},i.prototype.gt=function(u){return this.cmp(u)===1},i.prototype.gten=function(u){return this.cmpn(u)>=0},i.prototype.gte=function(u){return this.cmp(u)>=0},i.prototype.ltn=function(u){return this.cmpn(u)===-1},i.prototype.lt=function(u){return this.cmp(u)===-1},i.prototype.lten=function(u){return this.cmpn(u)<=0},i.prototype.lte=function(u){return this.cmp(u)<=0},i.prototype.eqn=function(u){return this.cmpn(u)===0},i.prototype.eq=function(u){return this.cmp(u)===0},i.red=function(u){return new ce(u)},i.prototype.toRed=function(u){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(u){return this.red=u,this},i.prototype.forceRed=function(u){return r(!this.red,"Already a number in reduction context"),this._forceRed(u)},i.prototype.redAdd=function(u){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},i.prototype.redIAdd=function(u){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},i.prototype.redSub=function(u){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},i.prototype.redISub=function(u){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},i.prototype.redShl=function(u){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},i.prototype.redMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},i.prototype.redIMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(u){return r(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var V={k256:null,p224:null,p192:null,p25519:null};function z(x,u){this.name=x,this.p=new i(u,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var u=new i(null);return u.words=new Array(Math.ceil(this.n/13)),u},z.prototype.ireduce=function(u){var h=u,y;do this.split(h,this.tmp),h=this.imulK(h),h=h.iadd(this.tmp),y=h.bitLength();while(y>this.n);var w=y<this.n?-1:h.ucmp(this.p);return w===0?(h.words[0]=0,h.length=1):w>0?h.isub(this.p):h.strip!==void 0?h.strip():h._strip(),h},z.prototype.split=function(u,h){u.iushrn(this.n,0,h)},z.prototype.imulK=function(u){return u.imul(this.k)};function W(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(W,z),W.prototype.split=function(u,h){for(var y=4194303,w=Math.min(u.length,9),S=0;S<w;S++)h.words[S]=u.words[S];if(h.length=w,u.length<=9){u.words[0]=0,u.length=1;return}var R=u.words[9];for(h.words[h.length++]=R&y,S=10;S<u.length;S++){var A=u.words[S]|0;u.words[S-10]=(A&y)<<4|R>>>22,R=A}R>>>=22,u.words[S-10]=R,R===0&&u.length>10?u.length-=10:u.length-=9},W.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var h=0,y=0;y<u.length;y++){var w=u.words[y]|0;h+=w*977,u.words[y]=h&67108863,h=w*64+(h/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function ie(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(ie,z);function ee(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(ee,z);function ge(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(ge,z),ge.prototype.imulK=function(u){for(var h=0,y=0;y<u.length;y++){var w=(u.words[y]|0)*19+h,S=w&67108863;w>>>=26,u.words[y]=S,h=w}return h!==0&&(u.words[u.length++]=h),u},i._prime=function(u){if(V[u])return V[u];var h;if(u==="k256")h=new W;else if(u==="p224")h=new ie;else if(u==="p192")h=new ee;else if(u==="p25519")h=new ge;else throw new Error("Unknown prime "+u);return V[u]=h,h};function ce(x){if(typeof x=="string"){var u=i._prime(x);this.m=u.p,this.prime=u}else r(x.gtn(1),"modulus must be greater than 1"),this.m=x,this.prime=null}ce.prototype._verify1=function(u){r(u.negative===0,"red works only with positives"),r(u.red,"red works only with red numbers")},ce.prototype._verify2=function(u,h){r((u.negative|h.negative)===0,"red works only with positives"),r(u.red&&u.red===h.red,"red works only with red numbers")},ce.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):u.umod(this.m)._forceRed(this)},ce.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},ce.prototype.add=function(u,h){this._verify2(u,h);var y=u.add(h);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},ce.prototype.iadd=function(u,h){this._verify2(u,h);var y=u.iadd(h);return y.cmp(this.m)>=0&&y.isub(this.m),y},ce.prototype.sub=function(u,h){this._verify2(u,h);var y=u.sub(h);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},ce.prototype.isub=function(u,h){this._verify2(u,h);var y=u.isub(h);return y.cmpn(0)<0&&y.iadd(this.m),y},ce.prototype.shl=function(u,h){return this._verify1(u),this.imod(u.ushln(h))},ce.prototype.imul=function(u,h){return this._verify2(u,h),this.imod(u.imul(h))},ce.prototype.mul=function(u,h){return this._verify2(u,h),this.imod(u.mul(h))},ce.prototype.isqr=function(u){return this.imul(u,u.clone())},ce.prototype.sqr=function(u){return this.mul(u,u)},ce.prototype.sqrt=function(u){if(u.isZero())return u.clone();var h=this.m.andln(3);if(r(h%2===1),h===3){var y=this.m.add(new i(1)).iushrn(2);return this.pow(u,y)}for(var w=this.m.subn(1),S=0;!w.isZero()&&w.andln(1)===0;)S++,w.iushrn(1);r(!w.isZero());var R=new i(1).toRed(this),A=R.redNeg(),_=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);this.pow(c,_).cmp(A)!==0;)c.redIAdd(A);for(var b=this.pow(c,w),k=this.pow(u,w.addn(1).iushrn(1)),D=this.pow(u,w),K=S;D.cmp(R)!==0;){for(var G=D,X=0;G.cmp(R)!==0;X++)G=G.redSqr();r(X<K);var Z=this.pow(b,new i(1).iushln(K-X-1));k=k.redMul(Z),b=Z.redSqr(),D=D.redMul(b),K=X}return k},ce.prototype.invm=function(u){var h=u._invmp(this.m);return h.negative!==0?(h.negative=0,this.imod(h).redNeg()):this.imod(h)},ce.prototype.pow=function(u,h){if(h.isZero())return new i(1).toRed(this);if(h.cmpn(1)===0)return u.clone();var y=4,w=new Array(1<<y);w[0]=new i(1).toRed(this),w[1]=u;for(var S=2;S<w.length;S++)w[S]=this.mul(w[S-1],u);var R=w[0],A=0,_=0,c=h.bitLength()%26;for(c===0&&(c=26),S=h.length-1;S>=0;S--){for(var b=h.words[S],k=c-1;k>=0;k--){var D=b>>k&1;if(R!==w[0]&&(R=this.sqr(R)),D===0&&A===0){_=0;continue}A<<=1,A|=D,_++,!(_!==y&&(S!==0||k!==0))&&(R=this.mul(R,w[A]),_=0,A=0)}c=26}return R},ce.prototype.convertTo=function(u){var h=u.umod(this.m);return h===u?h.clone():h},ce.prototype.convertFrom=function(u){var h=u.clone();return h.red=null,h},i.mont=function(u){return new me(u)};function me(x){ce.call(this,x),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(me,ce),me.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},me.prototype.convertFrom=function(u){var h=this.imod(u.mul(this.rinv));return h.red=null,h},me.prototype.imul=function(u,h){if(u.isZero()||h.isZero())return u.words[0]=0,u.length=1,u;var y=u.imul(h),w=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=y.isub(w).iushrn(this.shift),R=S;return S.cmp(this.m)>=0?R=S.isub(this.m):S.cmpn(0)<0&&(R=S.iadd(this.m)),R._forceRed(this)},me.prototype.mul=function(u,h){if(u.isZero()||h.isZero())return new i(0)._forceRed(this);var y=u.mul(h),w=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=y.isub(w).iushrn(this.shift),R=S;return S.cmp(this.m)>=0?R=S.isub(this.m):S.cmpn(0)<0&&(R=S.iadd(this.m)),R._forceRed(this)},me.prototype.invm=function(u){var h=this.imod(u._invmp(this.m).mul(this.r2));return h._forceRed(this)}})(typeof bl>"u"||bl,R0)});var Fe=P((PC,_l)=>{p();typeof Object.create=="function"?_l.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:_l.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}}});var Gt=P((wl,B0)=>{p();var Qa=Nt(),Zr=Qa.Buffer;function P0(e,t){for(var r in e)t[r]=e[r]}Zr.from&&Zr.alloc&&Zr.allocUnsafe&&Zr.allocUnsafeSlow?B0.exports=Qa:(P0(Qa,wl),wl.Buffer=xi);function xi(e,t,r){return Zr(e,t,r)}xi.prototype=Object.create(Zr.prototype);P0(Zr,xi);xi.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Zr(e,t,r)};xi.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=Zr(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};xi.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Zr(e)};xi.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Qa.SlowBuffer(e)}});var go=P((MC,Sl)=>{"use strict";p();var po=typeof Reflect=="object"?Reflect:null,N0=po&&typeof po.apply=="function"?po.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},eu;po&&typeof po.ownKeys=="function"?eu=po.ownKeys:Object.getOwnPropertySymbols?eu=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:eu=function(t){return Object.getOwnPropertyNames(t)};function FI(e){console&&console.warn&&console.warn(e)}var k0=Number.isNaN||function(t){return t!==t};function De(){De.init.call(this)}Sl.exports=De;Sl.exports.once=KI;De.EventEmitter=De;De.prototype._events=void 0;De.prototype._eventsCount=0;De.prototype._maxListeners=void 0;var M0=10;function tu(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(De,"defaultMaxListeners",{enumerable:!0,get:function(){return M0},set:function(e){if(typeof e!="number"||e<0||k0(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");M0=e}});De.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};De.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||k0(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function C0(e){return e._maxListeners===void 0?De.defaultMaxListeners:e._maxListeners}De.prototype.getMaxListeners=function(){return C0(this)};De.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=t==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var f=o[t];if(f===void 0)return!1;if(typeof f=="function")N0(f,this,r);else for(var l=f.length,m=q0(f,l),n=0;n<l;++n)N0(m[n],this,r);return!0};function L0(e,t,r,n){var i,o,s;if(tu(r),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),s===void 0)s=o[t]=r,++e._eventsCount;else if(typeof s=="function"?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=C0(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,FI(a)}return e}De.prototype.addListener=function(t,r){return L0(this,t,r,!1)};De.prototype.on=De.prototype.addListener;De.prototype.prependListener=function(t,r){return L0(this,t,r,!0)};function qI(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function D0(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=qI.bind(n);return i.listener=r,n.wrapFn=i,i}De.prototype.once=function(t,r){return tu(r),this.on(t,D0(this,t,r)),this};De.prototype.prependOnceListener=function(t,r){return tu(r),this.prependListener(t,D0(this,t,r)),this};De.prototype.removeListener=function(t,r){var n,i,o,s,a;if(tu(r),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():jI(n,o),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||r)}return this};De.prototype.off=De.prototype.removeListener;De.prototype.removeAllListeners=function(t){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[t],typeof r=="function")this.removeListener(t,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(t,r[i]);return this};function U0(e,t,r){var n=e._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?HI(i):q0(i,i.length)}De.prototype.listeners=function(t){return U0(this,t,!0)};De.prototype.rawListeners=function(t){return U0(this,t,!1)};De.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):F0.call(e,t)};De.prototype.listenerCount=F0;function F0(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}De.prototype.eventNames=function(){return this._eventsCount>0?eu(this._events):[]};function q0(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function jI(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function HI(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function KI(e,t){return new Promise(function(r,n){function i(s){e.removeListener(t,o),n(s)}function o(){typeof e.removeListener=="function"&&e.removeListener("error",i),r([].slice.call(arguments))}j0(e,t,o,{once:!0}),t!=="error"&&GI(e,i,{once:!0})})}function GI(e,t,r){typeof e.on=="function"&&j0(e,"error",t,r)}function j0(e,t,r,n){if(typeof e.on=="function")n.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(o){n.once&&e.removeEventListener(t,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var El=P((CC,H0)=>{p();H0.exports=go().EventEmitter});var ru=P((DC,K0)=>{"use strict";p();K0.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[r]=i;for(var o in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var s=Object.getOwnPropertySymbols(t);if(s.length!==1||s[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,r);if(a.value!==i||a.enumerable!==!0)return!1}return!0}});var ps=P((FC,G0)=>{"use strict";p();var VI=ru();G0.exports=function(){return VI()&&!!Symbol.toStringTag}});var nu=P((jC,V0)=>{"use strict";p();V0.exports=Object});var z0=P((KC,W0)=>{"use strict";p();W0.exports=Error});var $0=P((VC,Y0)=>{"use strict";p();Y0.exports=EvalError});var X0=P((zC,Z0)=>{"use strict";p();Z0.exports=RangeError});var Q0=P(($C,J0)=>{"use strict";p();J0.exports=ReferenceError});var xl=P((XC,eg)=>{"use strict";p();eg.exports=SyntaxError});var Ii=P((QC,tg)=>{"use strict";p();tg.exports=TypeError});var ng=P((t8,rg)=>{"use strict";p();rg.exports=URIError});var og=P((n8,ig)=>{"use strict";p();ig.exports=Math.abs});var ag=P((o8,sg)=>{"use strict";p();sg.exports=Math.floor});var fg=P((a8,ug)=>{"use strict";p();ug.exports=Math.max});var lg=P((f8,cg)=>{"use strict";p();cg.exports=Math.min});var dg=P((l8,hg)=>{"use strict";p();hg.exports=Math.pow});var gg=P((d8,pg)=>{"use strict";p();pg.exports=Math.round});var mg=P((g8,yg)=>{"use strict";p();yg.exports=Number.isNaN||function(t){return t!==t}});var bg=P((m8,vg)=>{"use strict";p();var WI=mg();vg.exports=function(t){return WI(t)||t===0?t:t<0?-1:1}});var wg=P((b8,_g)=>{"use strict";p();_g.exports=Object.getOwnPropertyDescriptor});var Ai=P((w8,Sg)=>{"use strict";p();var iu=wg();if(iu)try{iu([],"length")}catch{iu=null}Sg.exports=iu});var gs=P((E8,Eg)=>{"use strict";p();var ou=Object.defineProperty||!1;if(ou)try{ou({},"a",{value:1})}catch{ou=!1}Eg.exports=ou});var Ag=P((I8,Ig)=>{"use strict";p();var xg=typeof Symbol<"u"&&Symbol,zI=ru();Ig.exports=function(){return typeof xg!="function"||typeof Symbol!="function"||typeof xg("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:zI()}});var Il=P((O8,Og)=>{"use strict";p();Og.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var Al=P((T8,Rg)=>{"use strict";p();var YI=nu();Rg.exports=YI.getPrototypeOf||null});var Bg=P((B8,Pg)=>{"use strict";p();var $I="Function.prototype.bind called on incompatible ",ZI=Object.prototype.toString,XI=Math.max,JI="[object Function]",Tg=function(t,r){for(var n=[],i=0;i<t.length;i+=1)n[i]=t[i];for(var o=0;o<r.length;o+=1)n[o+t.length]=r[o];return n},QI=function(t,r){for(var n=[],i=r||0,o=0;i<t.length;i+=1,o+=1)n[o]=t[i];return n},eA=function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r};Pg.exports=function(t){var r=this;if(typeof r!="function"||ZI.apply(r)!==JI)throw new TypeError($I+r);for(var n=QI(arguments,1),i,o=function(){if(this instanceof i){var m=r.apply(this,Tg(n,arguments));return Object(m)===m?m:this}return r.apply(t,Tg(n,arguments))},s=XI(0,r.length-n.length),a=[],f=0;f<s;f++)a[f]="$"+f;if(i=Function("binder","return function ("+eA(a,",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var l=function(){};l.prototype=r.prototype,i.prototype=new l,l.prototype=null}return i}});var yo=P((M8,Ng)=>{"use strict";p();var tA=Bg();Ng.exports=Function.prototype.bind||tA});var su=P((C8,Mg)=>{"use strict";p();Mg.exports=Function.prototype.call});var au=P((D8,kg)=>{"use strict";p();kg.exports=Function.prototype.apply});var Lg=P((F8,Cg)=>{"use strict";p();Cg.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var Ol=P((j8,Dg)=>{"use strict";p();var rA=yo(),nA=au(),iA=su(),oA=Lg();Dg.exports=oA||rA.call(iA,nA)});var uu=P((K8,Ug)=>{"use strict";p();var sA=yo(),aA=Ii(),uA=su(),fA=Ol();Ug.exports=function(t){if(t.length<1||typeof t[0]!="function")throw new aA("a function is required");return fA(sA,uA,t)}});var Gg=P((V8,Kg)=>{"use strict";p();var cA=uu(),Fg=Ai(),jg;try{jg=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!="object"||!("code"in e)||e.code!=="ERR_PROTO_ACCESS")throw e}var Rl=!!jg&&Fg&&Fg(Object.prototype,"__proto__"),Hg=Object,qg=Hg.getPrototypeOf;Kg.exports=Rl&&typeof Rl.get=="function"?cA([Rl.get]):typeof qg=="function"?function(t){return qg(t==null?t:Hg(t))}:!1});var fu=P((z8,Yg)=>{"use strict";p();var Vg=Il(),Wg=Al(),zg=Gg();Yg.exports=Vg?function(t){return Vg(t)}:Wg?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return Wg(t)}:zg?function(t){return zg(t)}:null});var Tl=P(($8,$g)=>{"use strict";p();var lA=Function.prototype.call,hA=Object.prototype.hasOwnProperty,dA=yo();$g.exports=dA.call(lA,hA)});var hu=P((X8,ty)=>{"use strict";p();var Ie,pA=nu(),gA=z0(),yA=$0(),mA=X0(),vA=Q0(),_o=xl(),bo=Ii(),bA=ng(),_A=og(),wA=ag(),SA=fg(),EA=lg(),xA=dg(),IA=gg(),AA=bg(),Qg=Function,Pl=function(e){try{return Qg('"use strict"; return ('+e+").constructor;")()}catch{}},ys=Ai(),OA=gs(),Bl=function(){throw new bo},RA=ys?(function(){try{return arguments.callee,Bl}catch{try{return ys(arguments,"callee").get}catch{return Bl}}})():Bl,mo=Ag()(),Ft=fu(),TA=Al(),PA=Il(),ey=au(),ms=su(),vo={},BA=typeof Uint8Array>"u"||!Ft?Ie:Ft(Uint8Array),Oi={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Ie:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Ie:ArrayBuffer,"%ArrayIteratorPrototype%":mo&&Ft?Ft([][Symbol.iterator]()):Ie,"%AsyncFromSyncIteratorPrototype%":Ie,"%AsyncFunction%":vo,"%AsyncGenerator%":vo,"%AsyncGeneratorFunction%":vo,"%AsyncIteratorPrototype%":vo,"%Atomics%":typeof Atomics>"u"?Ie:Atomics,"%BigInt%":typeof BigInt>"u"?Ie:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Ie:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Ie:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Ie:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":gA,"%eval%":eval,"%EvalError%":yA,"%Float16Array%":typeof Float16Array>"u"?Ie:Float16Array,"%Float32Array%":typeof Float32Array>"u"?Ie:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Ie:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Ie:FinalizationRegistry,"%Function%":Qg,"%GeneratorFunction%":vo,"%Int8Array%":typeof Int8Array>"u"?Ie:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Ie:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Ie:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":mo&&Ft?Ft(Ft([][Symbol.iterator]())):Ie,"%JSON%":typeof JSON=="object"?JSON:Ie,"%Map%":typeof Map>"u"?Ie:Map,"%MapIteratorPrototype%":typeof Map>"u"||!mo||!Ft?Ie:Ft(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":pA,"%Object.getOwnPropertyDescriptor%":ys,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Ie:Promise,"%Proxy%":typeof Proxy>"u"?Ie:Proxy,"%RangeError%":mA,"%ReferenceError%":vA,"%Reflect%":typeof Reflect>"u"?Ie:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Ie:Set,"%SetIteratorPrototype%":typeof Set>"u"||!mo||!Ft?Ie:Ft(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Ie:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":mo&&Ft?Ft(""[Symbol.iterator]()):Ie,"%Symbol%":mo?Symbol:Ie,"%SyntaxError%":_o,"%ThrowTypeError%":RA,"%TypedArray%":BA,"%TypeError%":bo,"%Uint8Array%":typeof Uint8Array>"u"?Ie:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Ie:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Ie:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Ie:Uint32Array,"%URIError%":bA,"%WeakMap%":typeof WeakMap>"u"?Ie:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Ie:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Ie:WeakSet,"%Function.prototype.call%":ms,"%Function.prototype.apply%":ey,"%Object.defineProperty%":OA,"%Object.getPrototypeOf%":TA,"%Math.abs%":_A,"%Math.floor%":wA,"%Math.max%":SA,"%Math.min%":EA,"%Math.pow%":xA,"%Math.round%":IA,"%Math.sign%":AA,"%Reflect.getPrototypeOf%":PA};if(Ft)try{null.error}catch(e){Zg=Ft(Ft(e)),Oi["%Error.prototype%"]=Zg}var Zg,NA=function e(t){var r;if(t==="%AsyncFunction%")r=Pl("async function () {}");else if(t==="%GeneratorFunction%")r=Pl("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=Pl("async function* () {}");else if(t==="%AsyncGenerator%"){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=e("%AsyncGenerator%");i&&Ft&&(r=Ft(i.prototype))}return Oi[t]=r,r},Xg={__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"]},vs=yo(),cu=Tl(),MA=vs.call(ms,Array.prototype.concat),kA=vs.call(ey,Array.prototype.splice),Jg=vs.call(ms,String.prototype.replace),lu=vs.call(ms,String.prototype.slice),CA=vs.call(ms,RegExp.prototype.exec),LA=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,DA=/\\(\\)?/g,UA=function(t){var r=lu(t,0,1),n=lu(t,-1);if(r==="%"&&n!=="%")throw new _o("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new _o("invalid intrinsic syntax, expected opening `%`");var i=[];return Jg(t,LA,function(o,s,a,f){i[i.length]=a?Jg(f,DA,"$1"):s||o}),i},FA=function(t,r){var n=t,i;if(cu(Xg,n)&&(i=Xg[n],n="%"+i[0]+"%"),cu(Oi,n)){var o=Oi[n];if(o===vo&&(o=NA(n)),typeof o>"u"&&!r)throw new bo("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:o}}throw new _o("intrinsic "+t+" does not exist!")};ty.exports=function(t,r){if(typeof t!="string"||t.length===0)throw new bo("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new bo('"allowMissing" argument must be a boolean');if(CA(/^%?[^%]*%?$/,t)===null)throw new _o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=UA(t),i=n.length>0?n[0]:"",o=FA("%"+i+"%",r),s=o.name,a=o.value,f=!1,l=o.alias;l&&(i=l[0],kA(n,MA([0,1],l)));for(var m=1,g=!0;m<n.length;m+=1){var v=n[m],E=lu(v,0,1),T=lu(v,-1);if((E==='"'||E==="'"||E==="`"||T==='"'||T==="'"||T==="`")&&E!==T)throw new _o("property names with quotes must have matching quotes");if((v==="constructor"||!g)&&(f=!0),i+="."+v,s="%"+i+"%",cu(Oi,s))a=Oi[s];else if(a!=null){if(!(v in a)){if(!r)throw new bo("base intrinsic for "+t+" exists, but the property is not available.");return}if(ys&&m+1>=n.length){var N=ys(a,v);g=!!N,g&&"get"in N&&!("originalValue"in N.get)?a=N.get:a=a[v]}else g=cu(a,v),a=a[v];g&&!f&&(Oi[s]=a)}}return a}});var Hn=P((Q8,iy)=>{"use strict";p();var ry=hu(),ny=uu(),qA=ny([ry("%String.prototype.indexOf%")]);iy.exports=function(t,r){var n=ry(t,!!r);return typeof n=="function"&&qA(t,".prototype.")>-1?ny([n]):n}});var ay=P((tL,sy)=>{"use strict";p();var jA=ps()(),HA=Hn(),Nl=HA("Object.prototype.toString"),du=function(t){return jA&&t&&typeof t=="object"&&Symbol.toStringTag in t?!1:Nl(t)==="[object Arguments]"},oy=function(t){return du(t)?!0:t!==null&&typeof t=="object"&&"length"in t&&typeof t.length=="number"&&t.length>=0&&Nl(t)!=="[object Array]"&&"callee"in t&&Nl(t.callee)==="[object Function]"},KA=(function(){return du(arguments)})();du.isLegacyArguments=oy;sy.exports=KA?du:oy});var dy=P((nL,hy)=>{"use strict";p();var uy=Hn(),GA=ps()(),VA=Tl(),WA=Ai(),Cl;GA?(fy=uy("RegExp.prototype.exec"),Ml={},pu=function(){throw Ml},kl={toString:pu,valueOf:pu},typeof Symbol.toPrimitive=="symbol"&&(kl[Symbol.toPrimitive]=pu),Cl=function(t){if(!t||typeof t!="object")return!1;var r=WA(t,"lastIndex"),n=r&&VA(r,"value");if(!n)return!1;try{fy(t,kl)}catch(i){return i===Ml}}):(cy=uy("Object.prototype.toString"),ly="[object RegExp]",Cl=function(t){return!t||typeof t!="object"&&typeof t!="function"?!1:cy(t)===ly});var fy,Ml,pu,kl,cy,ly;hy.exports=Cl});var gy=P((oL,py)=>{"use strict";p();var zA=Hn(),YA=dy(),$A=zA("RegExp.prototype.exec"),ZA=Ii();py.exports=function(t){if(!YA(t))throw new ZA("`regex` must be a RegExp");return function(n){return $A(t,n)!==null}}});var my=P((aL,yy)=>{"use strict";p();var XA=function*(){}.constructor;yy.exports=()=>XA});var wy=P((fL,_y)=>{"use strict";p();var by=Hn(),JA=gy(),QA=JA(/^\s*(?:function)?\*/),eO=ps()(),vy=fu(),tO=by("Object.prototype.toString"),rO=by("Function.prototype.toString"),nO=my();_y.exports=function(t){if(typeof t!="function")return!1;if(QA(rO(t)))return!0;if(!eO){var r=tO(t);return r==="[object GeneratorFunction]"}if(!vy)return!1;var n=nO();return n&&vy(t)===n.prototype}});var Iy=P((lL,xy)=>{"use strict";p();var Ey=Function.prototype.toString,wo=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Dl,gu;if(typeof wo=="function"&&typeof Object.defineProperty=="function")try{Dl=Object.defineProperty({},"length",{get:function(){throw gu}}),gu={},wo(function(){throw 42},null,Dl)}catch(e){e!==gu&&(wo=null)}else wo=null;var iO=/^\s*class\b/,Ul=function(t){try{var r=Ey.call(t);return iO.test(r)}catch{return!1}},Ll=function(t){try{return Ul(t)?!1:(Ey.call(t),!0)}catch{return!1}},yu=Object.prototype.toString,oO="[object Object]",sO="[object Function]",aO="[object GeneratorFunction]",uO="[object HTMLAllCollection]",fO="[object HTML document.all class]",cO="[object HTMLCollection]",lO=typeof Symbol=="function"&&!!Symbol.toStringTag,hO=!(0 in[,]),Fl=function(){return!1};typeof document=="object"&&(Sy=document.all,yu.call(Sy)===yu.call(document.all)&&(Fl=function(t){if((hO||!t)&&(typeof t>"u"||typeof t=="object"))try{var r=yu.call(t);return(r===uO||r===fO||r===cO||r===oO)&&t("")==null}catch{}return!1}));var Sy;xy.exports=wo?function(t){if(Fl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{wo(t,null,Dl)}catch(r){if(r!==gu)return!1}return!Ul(t)&&Ll(t)}:function(t){if(Fl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(lO)return Ll(t);if(Ul(t))return!1;var r=yu.call(t);return r!==sO&&r!==aO&&!/^\[object HTML/.test(r)?!1:Ll(t)}});var Ry=P((dL,Oy)=>{"use strict";p();var dO=Iy(),pO=Object.prototype.toString,Ay=Object.prototype.hasOwnProperty,gO=function(t,r,n){for(var i=0,o=t.length;i<o;i++)Ay.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))},yO=function(t,r,n){for(var i=0,o=t.length;i<o;i++)n==null?r(t.charAt(i),i,t):r.call(n,t.charAt(i),i,t)},mO=function(t,r,n){for(var i in t)Ay.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))};function vO(e){return pO.call(e)==="[object Array]"}Oy.exports=function(t,r,n){if(!dO(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),vO(t)?gO(t,r,i):typeof t=="string"?yO(t,r,i):mO(t,r,i)}});var Py=P((gL,Ty)=>{"use strict";p();Ty.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]});var Ny=P((mL,By)=>{"use strict";p();var ql=Py(),bO=globalThis;By.exports=function(){for(var t=[],r=0;r<ql.length;r++)typeof bO[ql[r]]=="function"&&(t[t.length]=ql[r]);return t}});var jl=P((bL,Cy)=>{"use strict";p();var My=gs(),_O=xl(),So=Ii(),ky=Ai();Cy.exports=function(t,r,n){if(!t||typeof t!="object"&&typeof t!="function")throw new So("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new So("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new So("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new So("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new So("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new So("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,s=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,f=!!ky&&ky(t,r);if(My)My(t,r,{configurable:s===null&&f?f.configurable:!s,enumerable:i===null&&f?f.enumerable:!i,value:n,writable:o===null&&f?f.writable:!o});else if(a||!i&&!o&&!s)t[r]=n;else throw new _O("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var Kl=P((wL,Dy)=>{"use strict";p();var Hl=gs(),Ly=function(){return!!Hl};Ly.hasArrayLengthDefineBug=function(){if(!Hl)return null;try{return Hl([],"length",{value:1}).length!==1}catch{return!0}};Dy.exports=Ly});var Hy=P((EL,jy)=>{"use strict";p();var wO=hu(),Uy=jl(),SO=Kl()(),Fy=Ai(),qy=Ii(),EO=wO("%Math.floor%");jy.exports=function(t,r){if(typeof t!="function")throw new qy("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||EO(r)!==r)throw new qy("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in t&&Fy){var s=Fy(t,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(SO?Uy(t,"length",r,!0,!0):Uy(t,"length",r)),t}});var Gy=P((IL,Ky)=>{"use strict";p();var xO=yo(),IO=au(),AO=Ol();Ky.exports=function(){return AO(xO,IO,arguments)}});var bs=P((OL,mu)=>{"use strict";p();var OO=Hy(),Vy=gs(),RO=uu(),Wy=Gy();mu.exports=function(t){var r=RO(arguments),n=1+t.length-(arguments.length-1);return OO(r,n>0?n:0,!0)};Vy?Vy(mu.exports,"apply",{value:Wy}):mu.exports.apply=Wy});var zl=P((TL,Zy)=>{"use strict";p();var _u=Ry(),TO=Ny(),zy=bs(),Vl=Hn(),bu=Ai(),vu=fu(),PO=Vl("Object.prototype.toString"),$y=ps()(),Yy=globalThis,Gl=TO(),Wl=Vl("String.prototype.slice"),BO=Vl("Array.prototype.indexOf",!0)||function(t,r){for(var n=0;n<t.length;n+=1)if(t[n]===r)return n;return-1},wu={__proto__:null};$y&&bu&&vu?_u(Gl,function(e){var t=new Yy[e];if(Symbol.toStringTag in t&&vu){var r=vu(t),n=bu(r,Symbol.toStringTag);if(!n&&r){var i=vu(r);n=bu(i,Symbol.toStringTag)}if(n&&n.get){var o=zy(n.get);wu["$"+e]=o}}}):_u(Gl,function(e){var t=new Yy[e],r=t.slice||t.set;if(r){var n=zy(r);wu["$"+e]=n}});var NO=function(t){var r=!1;return _u(wu,function(n,i){if(!r)try{"$"+n(t)===i&&(r=Wl(i,1))}catch{}}),r},MO=function(t){var r=!1;return _u(wu,function(n,i){if(!r)try{n(t),r=Wl(i,1)}catch{}}),r};Zy.exports=function(t){if(!t||typeof t!="object")return!1;if(!$y){var r=Wl(PO(t),8,-1);return BO(Gl,r)>-1?r:r!=="Object"?!1:MO(t)}return bu?NO(t):null}});var Yl=P((BL,Xy)=>{"use strict";p();var kO=zl();Xy.exports=function(t){return!!kO(t)}});var lm=P(Ae=>{"use strict";p();var CO=ay(),LO=wy(),Tr=zl(),Jy=Yl();function Eo(e){return e.call.bind(e)}var Qy=typeof BigInt<"u",em=typeof Symbol<"u",br=Eo(Object.prototype.toString),DO=Eo(Number.prototype.valueOf),UO=Eo(String.prototype.valueOf),FO=Eo(Boolean.prototype.valueOf);Qy&&(tm=Eo(BigInt.prototype.valueOf));var tm;em&&(rm=Eo(Symbol.prototype.valueOf));var rm;function ws(e,t){if(typeof e!="object")return!1;try{return t(e),!0}catch{return!1}}Ae.isArgumentsObject=CO;Ae.isGeneratorFunction=LO;Ae.isTypedArray=Jy;function qO(e){return typeof Promise<"u"&&e instanceof Promise||e!==null&&typeof e=="object"&&typeof e.then=="function"&&typeof e.catch=="function"}Ae.isPromise=qO;function jO(e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(e):Jy(e)||im(e)}Ae.isArrayBufferView=jO;function HO(e){return Tr(e)==="Uint8Array"}Ae.isUint8Array=HO;function KO(e){return Tr(e)==="Uint8ClampedArray"}Ae.isUint8ClampedArray=KO;function GO(e){return Tr(e)==="Uint16Array"}Ae.isUint16Array=GO;function VO(e){return Tr(e)==="Uint32Array"}Ae.isUint32Array=VO;function WO(e){return Tr(e)==="Int8Array"}Ae.isInt8Array=WO;function zO(e){return Tr(e)==="Int16Array"}Ae.isInt16Array=zO;function YO(e){return Tr(e)==="Int32Array"}Ae.isInt32Array=YO;function $O(e){return Tr(e)==="Float32Array"}Ae.isFloat32Array=$O;function ZO(e){return Tr(e)==="Float64Array"}Ae.isFloat64Array=ZO;function XO(e){return Tr(e)==="BigInt64Array"}Ae.isBigInt64Array=XO;function JO(e){return Tr(e)==="BigUint64Array"}Ae.isBigUint64Array=JO;function Su(e){return br(e)==="[object Map]"}Su.working=typeof Map<"u"&&Su(new Map);function QO(e){return typeof Map>"u"?!1:Su.working?Su(e):e instanceof Map}Ae.isMap=QO;function Eu(e){return br(e)==="[object Set]"}Eu.working=typeof Set<"u"&&Eu(new Set);function eR(e){return typeof Set>"u"?!1:Eu.working?Eu(e):e instanceof Set}Ae.isSet=eR;function xu(e){return br(e)==="[object WeakMap]"}xu.working=typeof WeakMap<"u"&&xu(new WeakMap);function tR(e){return typeof WeakMap>"u"?!1:xu.working?xu(e):e instanceof WeakMap}Ae.isWeakMap=tR;function Zl(e){return br(e)==="[object WeakSet]"}Zl.working=typeof WeakSet<"u"&&Zl(new WeakSet);function rR(e){return Zl(e)}Ae.isWeakSet=rR;function Iu(e){return br(e)==="[object ArrayBuffer]"}Iu.working=typeof ArrayBuffer<"u"&&Iu(new ArrayBuffer);function nm(e){return typeof ArrayBuffer>"u"?!1:Iu.working?Iu(e):e instanceof ArrayBuffer}Ae.isArrayBuffer=nm;function Au(e){return br(e)==="[object DataView]"}Au.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&Au(new DataView(new ArrayBuffer(1),0,1));function im(e){return typeof DataView>"u"?!1:Au.working?Au(e):e instanceof DataView}Ae.isDataView=im;var $l=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function _s(e){return br(e)==="[object SharedArrayBuffer]"}function om(e){return typeof $l>"u"?!1:(typeof _s.working>"u"&&(_s.working=_s(new $l)),_s.working?_s(e):e instanceof $l)}Ae.isSharedArrayBuffer=om;function nR(e){return br(e)==="[object AsyncFunction]"}Ae.isAsyncFunction=nR;function iR(e){return br(e)==="[object Map Iterator]"}Ae.isMapIterator=iR;function oR(e){return br(e)==="[object Set Iterator]"}Ae.isSetIterator=oR;function sR(e){return br(e)==="[object Generator]"}Ae.isGeneratorObject=sR;function aR(e){return br(e)==="[object WebAssembly.Module]"}Ae.isWebAssemblyCompiledModule=aR;function sm(e){return ws(e,DO)}Ae.isNumberObject=sm;function am(e){return ws(e,UO)}Ae.isStringObject=am;function um(e){return ws(e,FO)}Ae.isBooleanObject=um;function fm(e){return Qy&&ws(e,tm)}Ae.isBigIntObject=fm;function cm(e){return em&&ws(e,rm)}Ae.isSymbolObject=cm;function uR(e){return sm(e)||am(e)||um(e)||fm(e)||cm(e)}Ae.isBoxedPrimitive=uR;function fR(e){return typeof Uint8Array<"u"&&(nm(e)||om(e))}Ae.isAnyArrayBuffer=fR;["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(e){Object.defineProperty(Ae,e,{enumerable:!1,value:function(){throw new Error(e+" is not supported in userland")}})})});var dm=P((CL,hm)=>{p();hm.exports=function(t){return t&&typeof t=="object"&&typeof t.copy=="function"&&typeof t.fill=="function"&&typeof t.readUInt8=="function"}});var Xr=P(Oe=>{p();var pm=Object.getOwnPropertyDescriptors||function(t){for(var r=Object.keys(t),n={},i=0;i<r.length;i++)n[r[i]]=Object.getOwnPropertyDescriptor(t,r[i]);return n},cR=/%[sdj%]/g;Oe.format=function(e){if(!Mu(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(Kn(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,i=n.length,o=String(e).replace(cR,function(a){if(a==="%%")return"%";if(r>=i)return a;switch(a){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch{return"[Circular]"}default:return a}}),s=n[r];r<i;s=n[++r])Nu(s)||!xo(s)?o+=" "+s:o+=" "+Kn(s);return o};Oe.deprecate=function(e,t){if(typeof I.default<"u"&&I.default.noDeprecation===!0)return e;if(typeof I.default>"u")return function(){return Oe.deprecate(e,t).apply(this,arguments)};var r=!1;function n(){if(!r){if(I.default.throwDeprecation)throw new Error(t);I.default.traceDeprecation?console.trace(t):console.error(t),r=!0}return e.apply(this,arguments)}return n};var Ou={},gm=/^$/;I.default.env.NODE_DEBUG&&(Ru=I.default.env.NODE_DEBUG,Ru=Ru.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),gm=new RegExp("^"+Ru+"$","i"));var Ru;Oe.debuglog=function(e){if(e=e.toUpperCase(),!Ou[e])if(gm.test(e)){var t=I.default.pid;Ou[e]=function(){var r=Oe.format.apply(Oe,arguments);console.error("%s %d: %s",e,t,r)}}else Ou[e]=function(){};return Ou[e]};function Kn(e,t){var r={seen:[],stylize:hR};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),eh(t)?r.showHidden=t:t&&Oe._extend(r,t),Ti(r.showHidden)&&(r.showHidden=!1),Ti(r.depth)&&(r.depth=2),Ti(r.colors)&&(r.colors=!1),Ti(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=lR),Pu(r,e,r.depth)}Oe.inspect=Kn;Kn.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]};Kn.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function lR(e,t){var r=Kn.styles[t];return r?"\x1B["+Kn.colors[r][0]+"m"+e+"\x1B["+Kn.colors[r][1]+"m":e}function hR(e,t){return e}function dR(e){var t={};return e.forEach(function(r,n){t[r]=!0}),t}function Pu(e,t,r){if(e.customInspect&&t&&Tu(t.inspect)&&t.inspect!==Oe.inspect&&!(t.constructor&&t.constructor.prototype===t)){var n=t.inspect(r,e);return Mu(n)||(n=Pu(e,n,r)),n}var i=pR(e,t);if(i)return i;var o=Object.keys(t),s=dR(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),Es(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return Xl(t);if(o.length===0){if(Tu(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(Ss(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(Bu(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Es(t))return Xl(t)}var f="",l=!1,m=["{","}"];if(ym(t)&&(l=!0,m=["[","]"]),Tu(t)){var g=t.name?": "+t.name:"";f=" [Function"+g+"]"}if(Ss(t)&&(f=" "+RegExp.prototype.toString.call(t)),Bu(t)&&(f=" "+Date.prototype.toUTCString.call(t)),Es(t)&&(f=" "+Xl(t)),o.length===0&&(!l||t.length==0))return m[0]+f+m[1];if(r<0)return Ss(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var v;return l?v=gR(e,t,r,s,o):v=o.map(function(E){return Ql(e,t,r,s,E,l)}),e.seen.pop(),yR(v,f,m)}function pR(e,t){if(Ti(t))return e.stylize("undefined","undefined");if(Mu(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(mm(t))return e.stylize(""+t,"number");if(eh(t))return e.stylize(""+t,"boolean");if(Nu(t))return e.stylize("null","null")}function Xl(e){return"["+Error.prototype.toString.call(e)+"]"}function gR(e,t,r,n,i){for(var o=[],s=0,a=t.length;s<a;++s)vm(t,String(s))?o.push(Ql(e,t,r,n,String(s),!0)):o.push("");return i.forEach(function(f){f.match(/^\d+$/)||o.push(Ql(e,t,r,n,f,!0))}),o}function Ql(e,t,r,n,i,o){var s,a,f;if(f=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},f.get?f.set?a=e.stylize("[Getter/Setter]","special"):a=e.stylize("[Getter]","special"):f.set&&(a=e.stylize("[Setter]","special")),vm(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(f.value)<0?(Nu(r)?a=Pu(e,f.value,null):a=Pu(e,f.value,r-1),a.indexOf(`
1
+ var bsvLTP=(()=>{var eI=Object.create;var hs=Object.defineProperty;var tI=Object.getOwnPropertyDescriptor;var rI=Object.getOwnPropertyNames;var nI=Object.getPrototypeOf,iI=Object.prototype.hasOwnProperty;var oI=(e,t,r)=>t in e?hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Wt=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var B=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},ol=(e,t)=>{for(var r in t)hs(e,r,{get:t[r],enumerable:!0})},r0=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of rI(t))!iI.call(e,i)&&i!==r&&hs(e,i,{get:()=>t[i],enumerable:!(n=tI(t,i))||n.enumerable});return e};var n0=(e,t,r)=>(r=e!=null?eI(nI(e)):{},r0(t||!e||!e.__esModule?hs(r,"default",{value:e,enumerable:!0}):r,e)),sl=e=>r0(hs({},"__esModule",{value:!0}),e);var $=(e,t,r)=>oI(e,typeof t!="symbol"?t+"":t,r);var u0=B((_C,a0)=>{p();var tt=a0.exports={},Wr,zr;function al(){throw new Error("setTimeout has not been defined")}function ul(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Wr=setTimeout:Wr=al}catch{Wr=al}try{typeof clearTimeout=="function"?zr=clearTimeout:zr=ul}catch{zr=ul}})();function i0(e){if(Wr===setTimeout)return setTimeout(e,0);if((Wr===al||!Wr)&&setTimeout)return Wr=setTimeout,setTimeout(e,0);try{return Wr(e,0)}catch{try{return Wr.call(null,e,0)}catch{return Wr.call(this,e,0)}}}function sI(e){if(zr===clearTimeout)return clearTimeout(e);if((zr===ul||!zr)&&clearTimeout)return zr=clearTimeout,clearTimeout(e);try{return zr(e)}catch{try{return zr.call(null,e)}catch{return zr.call(this,e)}}}var pn=[],uo=!1,Si,$a=-1;function aI(){!uo||!Si||(uo=!1,Si.length?pn=Si.concat(pn):$a=-1,pn.length&&o0())}function o0(){if(!uo){var e=i0(aI);uo=!0;for(var t=pn.length;t;){for(Si=pn,pn=[];++$a<t;)Si&&Si[$a].run();$a=-1,t=pn.length}Si=null,uo=!1,sI(e)}}tt.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];pn.push(new s0(e,t)),pn.length===1&&!uo&&i0(o0)};function s0(e,t){this.fun=e,this.array=t}s0.prototype.run=function(){this.fun.apply(null,this.array)};tt.title="browser";tt.browser=!0;tt.env={};tt.argv=[];tt.version="";tt.versions={};function gn(){}tt.on=gn;tt.addListener=gn;tt.once=gn;tt.off=gn;tt.removeListener=gn;tt.removeAllListeners=gn;tt.emit=gn;tt.prependListener=gn;tt.prependOnceListener=gn;tt.listeners=function(e){return[]};tt.binding=function(e){throw new Error("process.binding is not supported")};tt.cwd=function(){return"/"};tt.chdir=function(e){throw new Error("process.chdir is not supported")};tt.umask=function(){return 0}});var l0=B(Za=>{"use strict";p();Za.byteLength=fI;Za.toByteArray=lI;Za.fromByteArray=pI;var Yr=[],vr=[],uI=typeof Uint8Array<"u"?Uint8Array:Array,fl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(wi=0,f0=fl.length;wi<f0;++wi)Yr[wi]=fl[wi],vr[fl.charCodeAt(wi)]=wi;var wi,f0;vr[45]=62;vr[95]=63;function c0(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function fI(e){var t=c0(e),r=t[0],n=t[1];return(r+n)*3/4-n}function cI(e,t,r){return(t+r)*3/4-r}function lI(e){var t,r=c0(e),n=r[0],i=r[1],o=new uI(cI(e,n,i)),s=0,a=i>0?n-4:n,f;for(f=0;f<a;f+=4)t=vr[e.charCodeAt(f)]<<18|vr[e.charCodeAt(f+1)]<<12|vr[e.charCodeAt(f+2)]<<6|vr[e.charCodeAt(f+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=vr[e.charCodeAt(f)]<<2|vr[e.charCodeAt(f+1)]>>4,o[s++]=t&255),i===1&&(t=vr[e.charCodeAt(f)]<<10|vr[e.charCodeAt(f+1)]<<4|vr[e.charCodeAt(f+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function hI(e){return Yr[e>>18&63]+Yr[e>>12&63]+Yr[e>>6&63]+Yr[e&63]}function dI(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(hI(n));return i.join("")}function pI(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(dI(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Yr[t>>2]+Yr[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Yr[t>>10]+Yr[t>>4&63]+Yr[t<<2&63]+"=")),i.join("")}});var h0=B(cl=>{p();cl.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,f=(1<<a)-1,l=f>>1,m=-7,g=r?i-1:0,v=r?-1:1,E=e[t+g];for(g+=v,o=E&(1<<-m)-1,E>>=-m,m+=a;m>0;o=o*256+e[t+g],g+=v,m-=8);for(s=o&(1<<-m)-1,o>>=-m,m+=n;m>0;s=s*256+e[t+g],g+=v,m-=8);if(o===0)o=1-l;else{if(o===f)return s?NaN:(E?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-l}return(E?-1:1)*s*Math.pow(2,o-n)};cl.write=function(e,t,r,n,i,o){var s,a,f,l=o*8-i-1,m=(1<<l)-1,g=m>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=n?0:o-1,T=n?1:-1,N=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=m):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),s+g>=1?t+=v/f:t+=v*Math.pow(2,1-g),t*f>=2&&(s++,f/=2),s+g>=m?(a=0,s=m):s+g>=1?(a=(t*f-1)*Math.pow(2,i),s=s+g):(a=t*Math.pow(2,g-1)*Math.pow(2,i),s=0));i>=8;e[r+E]=a&255,E+=T,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[r+E]=s&255,E+=T,s/=256,l-=8);e[r+E-T]|=N*128}});var Nt=B(ho=>{"use strict";p();var ll=l0(),co=h0(),d0=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ho.Buffer=H;ho.SlowBuffer=_I;ho.INSPECT_MAX_BYTES=50;var Xa=2147483647;ho.kMaxLength=Xa;H.TYPED_ARRAY_SUPPORT=gI();!H.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function gI(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(H.prototype,"parent",{enumerable:!0,get:function(){if(H.isBuffer(this))return this.buffer}});Object.defineProperty(H.prototype,"offset",{enumerable:!0,get:function(){if(H.isBuffer(this))return this.byteOffset}});function yn(e){if(e>Xa)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,H.prototype),t}function H(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return gl(e)}return m0(e,t,r)}H.poolSize=8192;function m0(e,t,r){if(typeof e=="string")return mI(e,t);if(ArrayBuffer.isView(e))return vI(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if($r(e,ArrayBuffer)||e&&$r(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&($r(e,SharedArrayBuffer)||e&&$r(e.buffer,SharedArrayBuffer)))return dl(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return H.from(n,t,r);let i=bI(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return H.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}H.from=function(e,t,r){return m0(e,t,r)};Object.setPrototypeOf(H.prototype,Uint8Array.prototype);Object.setPrototypeOf(H,Uint8Array);function v0(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function yI(e,t,r){return v0(e),e<=0?yn(e):t!==void 0?typeof r=="string"?yn(e).fill(t,r):yn(e).fill(t):yn(e)}H.alloc=function(e,t,r){return yI(e,t,r)};function gl(e){return v0(e),yn(e<0?0:yl(e)|0)}H.allocUnsafe=function(e){return gl(e)};H.allocUnsafeSlow=function(e){return gl(e)};function mI(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!H.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=b0(e,t)|0,n=yn(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function hl(e){let t=e.length<0?0:yl(e.length)|0,r=yn(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function vI(e){if($r(e,Uint8Array)){let t=new Uint8Array(e);return dl(t.buffer,t.byteOffset,t.byteLength)}return hl(e)}function dl(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,H.prototype),n}function bI(e){if(H.isBuffer(e)){let t=yl(e.length)|0,r=yn(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||vl(e.length)?yn(0):hl(e);if(e.type==="Buffer"&&Array.isArray(e.data))return hl(e.data)}function yl(e){if(e>=Xa)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Xa.toString(16)+" bytes");return e|0}function _I(e){return+e!=e&&(e=0),H.alloc(+e)}H.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==H.prototype};H.compare=function(t,r){if($r(t,Uint8Array)&&(t=H.from(t,t.offset,t.byteLength)),$r(r,Uint8Array)&&(r=H.from(r,r.offset,r.byteLength)),!H.isBuffer(t)||!H.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};H.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}};H.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return H.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=H.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let s=t[n];if($r(s,Uint8Array))o+s.length>i.length?(H.isBuffer(s)||(s=H.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(H.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function b0(e,t){if(H.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||$r(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return pl(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return R0(e).length;default:if(i)return n?-1:pl(e).length;t=(""+t).toLowerCase(),i=!0}}H.byteLength=b0;function SI(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return BI(this,t,r);case"utf8":case"utf-8":return S0(this,t,r);case"ascii":return TI(this,t,r);case"latin1":case"binary":return PI(this,t,r);case"base64":return AI(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return NI(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}H.prototype._isBuffer=!0;function Ei(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}H.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)Ei(this,r,r+1);return this};H.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)Ei(this,r,r+3),Ei(this,r+1,r+2);return this};H.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)Ei(this,r,r+7),Ei(this,r+1,r+6),Ei(this,r+2,r+5),Ei(this,r+3,r+4);return this};H.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?S0(this,0,t):SI.apply(this,arguments)};H.prototype.toLocaleString=H.prototype.toString;H.prototype.equals=function(t){if(!H.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:H.compare(this,t)===0};H.prototype.inspect=function(){let t="",r=ho.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};d0&&(H.prototype[d0]=H.prototype.inspect);H.prototype.compare=function(t,r,n,i,o){if($r(t,Uint8Array)&&(t=H.from(t,t.offset,t.byteLength)),!H.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,a=n-r,f=Math.min(s,a),l=this.slice(i,o),m=t.slice(r,n);for(let g=0;g<f;++g)if(l[g]!==m[g]){s=l[g],a=m[g];break}return s<a?-1:a<s?1:0};function _0(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,vl(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=H.from(t,n)),H.isBuffer(t))return t.length===0?-1:p0(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):p0(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function p0(e,t,r,n,i){let o=1,s=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,s/=2,a/=2,r/=2}function f(m,g){return o===1?m[g]:m.readUInt16BE(g*o)}let l;if(i){let m=-1;for(l=r;l<s;l++)if(f(e,l)===f(t,m===-1?0:l-m)){if(m===-1&&(m=l),l-m+1===a)return m*o}else m!==-1&&(l-=l-m),m=-1}else for(r+a>s&&(r=s-a),l=r;l>=0;l--){let m=!0;for(let g=0;g<a;g++)if(f(e,l+g)!==f(t,g)){m=!1;break}if(m)return l}return-1}H.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};H.prototype.indexOf=function(t,r,n){return _0(this,t,r,n,!0)};H.prototype.lastIndexOf=function(t,r,n){return _0(this,t,r,n,!1)};function wI(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(t.substr(s*2,2),16);if(vl(a))return s;e[r+s]=a}return s}function EI(e,t,r,n){return Ja(pl(t,e.length-r),e,r,n)}function xI(e,t,r,n){return Ja(LI(t),e,r,n)}function II(e,t,r,n){return Ja(R0(t),e,r,n)}function OI(e,t,r,n){return Ja(DI(t,e.length-r),e,r,n)}H.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return wI(this,t,r,n);case"utf8":case"utf-8":return EI(this,t,r,n);case"ascii":case"latin1":case"binary":return xI(this,t,r,n);case"base64":return II(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return OI(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function AI(e,t,r){return t===0&&r===e.length?ll.fromByteArray(e):ll.fromByteArray(e.slice(t,r))}function S0(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let f,l,m,g;switch(a){case 1:o<128&&(s=o);break;case 2:f=e[i+1],(f&192)===128&&(g=(o&31)<<6|f&63,g>127&&(s=g));break;case 3:f=e[i+1],l=e[i+2],(f&192)===128&&(l&192)===128&&(g=(o&15)<<12|(f&63)<<6|l&63,g>2047&&(g<55296||g>57343)&&(s=g));break;case 4:f=e[i+1],l=e[i+2],m=e[i+3],(f&192)===128&&(l&192)===128&&(m&192)===128&&(g=(o&15)<<18|(f&63)<<12|(l&63)<<6|m&63,g>65535&&g<1114112&&(s=g))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return RI(n)}var g0=4096;function RI(e){let t=e.length;if(t<=g0)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=g0));return r}function TI(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function PI(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function BI(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=UI[e[o]];return i}function NI(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}H.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,H.prototype),i};function Ut(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}H.prototype.readUintLE=H.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return i};H.prototype.readUintBE=H.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};H.prototype.readUint8=H.prototype.readUInt8=function(t,r){return t=t>>>0,r||Ut(t,1,this.length),this[t]};H.prototype.readUint16LE=H.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||Ut(t,2,this.length),this[t]|this[t+1]<<8};H.prototype.readUint16BE=H.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||Ut(t,2,this.length),this[t]<<8|this[t+1]};H.prototype.readUint32LE=H.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};H.prototype.readUint32BE=H.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};H.prototype.readBigUInt64LE=jn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ds(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});H.prototype.readBigUInt64BE=jn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ds(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});H.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};H.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(t,r,this.length);let i=r,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};H.prototype.readInt8=function(t,r){return t=t>>>0,r||Ut(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};H.prototype.readInt16LE=function(t,r){t=t>>>0,r||Ut(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};H.prototype.readInt16BE=function(t,r){t=t>>>0,r||Ut(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};H.prototype.readInt32LE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};H.prototype.readInt32BE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};H.prototype.readBigInt64LE=jn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ds(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});H.prototype.readBigInt64BE=jn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ds(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});H.prototype.readFloatLE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),co.read(this,t,!0,23,4)};H.prototype.readFloatBE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),co.read(this,t,!1,23,4)};H.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||Ut(t,8,this.length),co.read(this,t,!0,52,8)};H.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||Ut(t,8,this.length),co.read(this,t,!1,52,8)};function sr(e,t,r,n,i,o){if(!H.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}H.prototype.writeUintLE=H.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;sr(this,t,r,n,a,0)}let o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n};H.prototype.writeUintBE=H.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;sr(this,t,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n};H.prototype.writeUint8=H.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,1,255,0),this[r]=t&255,r+1};H.prototype.writeUint16LE=H.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};H.prototype.writeUint16BE=H.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};H.prototype.writeUint32LE=H.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};H.prototype.writeUint32BE=H.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function w0(e,t,r,n,i){A0(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function E0(e,t,r,n,i){A0(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}H.prototype.writeBigUInt64LE=jn(function(t,r=0){return w0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});H.prototype.writeBigUInt64BE=jn(function(t,r=0){return E0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});H.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);sr(this,t,r,n,f-1,-f)}let o=0,s=1,a=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};H.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);sr(this,t,r,n,f-1,-f)}let o=n-1,s=1,a=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};H.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};H.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};H.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};H.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};H.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};H.prototype.writeBigInt64LE=jn(function(t,r=0){return w0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});H.prototype.writeBigInt64BE=jn(function(t,r=0){return E0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function x0(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I0(e,t,r,n,i){return t=+t,r=r>>>0,i||x0(e,t,r,4,34028234663852886e22,-34028234663852886e22),co.write(e,t,r,n,23,4),r+4}H.prototype.writeFloatLE=function(t,r,n){return I0(this,t,r,!0,n)};H.prototype.writeFloatBE=function(t,r,n){return I0(this,t,r,!1,n)};function O0(e,t,r,n,i){return t=+t,r=r>>>0,i||x0(e,t,r,8,17976931348623157e292,-17976931348623157e292),co.write(e,t,r,n,52,8),r+8}H.prototype.writeDoubleLE=function(t,r,n){return O0(this,t,r,!0,n)};H.prototype.writeDoubleBE=function(t,r,n){return O0(this,t,r,!1,n)};H.prototype.copy=function(t,r,n,i){if(!H.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};H.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!H.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let s=H.isBuffer(t)?t:H.from(t,i),a=s.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var fo={};function ml(e,t,r){fo[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}ml("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ml("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);ml("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=y0(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=y0(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function y0(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function MI(e,t,r){lo(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&ds(t,e.length-(r+1))}function A0(e,t,r,n,i,o){if(e>r||e<t){let s=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${t}${s} and <= ${r}${s}`,new fo.ERR_OUT_OF_RANGE("value",a,e)}MI(n,i,o)}function lo(e,t){if(typeof e!="number")throw new fo.ERR_INVALID_ARG_TYPE(t,"number",e)}function ds(e,t,r){throw Math.floor(e)!==e?(lo(e,r),new fo.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new fo.ERR_BUFFER_OUT_OF_BOUNDS:new fo.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var kI=/[^+/0-9A-Za-z-_]/g;function CI(e){if(e=e.split("=")[0],e=e.trim().replace(kI,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function pl(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function LI(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function DI(e,t){let r,n,i,o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function R0(e){return ll.toByteArray(CI(e))}function Ja(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function $r(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function vl(e){return e!==e}var UI=(function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t})();function jn(e){return typeof BigInt>"u"?FI:e}function FI(){throw new Error("BigInt not supported")}});var x,d,p=Wt(()=>{x=n0(u0()),d=n0(Nt())});var P0=B((T0,bl)=>{p();(function(e,t){"use strict";function r(I,u){if(!I)throw new Error(u||"Assertion failed")}function n(I,u){I.super_=u;var h=function(){};h.prototype=u.prototype,I.prototype=new h,I.prototype.constructor=I}function i(I,u,h){if(i.isBN(I))return I;this.negative=0,this.words=null,this.length=0,this.red=null,I!==null&&((u==="le"||u==="be")&&(h=u,u=10),this._init(I||0,u||10,h||"be"))}typeof e=="object"?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Nt().Buffer}catch{}i.isBN=function(u){return u instanceof i?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===i.wordSize&&Array.isArray(u.words)},i.max=function(u,h){return u.cmp(h)>0?u:h},i.min=function(u,h){return u.cmp(h)<0?u:h},i.prototype._init=function(u,h,y){if(typeof u=="number")return this._initNumber(u,h,y);if(typeof u=="object")return this._initArray(u,h,y);h==="hex"&&(h=16),r(h===(h|0)&&h>=2&&h<=36),u=u.toString().replace(/\s+/g,"");var S=0;u[0]==="-"&&(S++,this.negative=1),S<u.length&&(h===16?this._parseHex(u,S,y):(this._parseBase(u,h,S),y==="le"&&this._initArray(this.toArray(),h,y)))},i.prototype._initNumber=function(u,h,y){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(r(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),h,y)},i.prototype._initArray=function(u,h,y){if(r(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var S=0;S<this.length;S++)this.words[S]=0;var w,R,O=0;if(y==="be")for(S=u.length-1,w=0;S>=0;S-=3)R=u[S]|u[S-1]<<8|u[S-2]<<16,this.words[w]|=R<<O&67108863,this.words[w+1]=R>>>26-O&67108863,O+=24,O>=26&&(O-=26,w++);else if(y==="le")for(S=0,w=0;S<u.length;S+=3)R=u[S]|u[S+1]<<8|u[S+2]<<16,this.words[w]|=R<<O&67108863,this.words[w+1]=R>>>26-O&67108863,O+=24,O>=26&&(O-=26,w++);return this.strip()};function s(I,u){var h=I.charCodeAt(u);return h>=65&&h<=70?h-55:h>=97&&h<=102?h-87:h-48&15}function a(I,u,h){var y=s(I,h);return h-1>=u&&(y|=s(I,h-1)<<4),y}i.prototype._parseHex=function(u,h,y){this.length=Math.ceil((u.length-h)/6),this.words=new Array(this.length);for(var S=0;S<this.length;S++)this.words[S]=0;var w=0,R=0,O;if(y==="be")for(S=u.length-1;S>=h;S-=2)O=a(u,h,S)<<w,this.words[R]|=O&67108863,w>=18?(w-=18,R+=1,this.words[R]|=O>>>26):w+=8;else{var _=u.length-h;for(S=_%2===0?h+1:h;S<u.length;S+=2)O=a(u,h,S)<<w,this.words[R]|=O&67108863,w>=18?(w-=18,R+=1,this.words[R]|=O>>>26):w+=8}this.strip()};function f(I,u,h,y){for(var S=0,w=Math.min(I.length,h),R=u;R<w;R++){var O=I.charCodeAt(R)-48;S*=y,O>=49?S+=O-49+10:O>=17?S+=O-17+10:S+=O}return S}i.prototype._parseBase=function(u,h,y){this.words=[0],this.length=1;for(var S=0,w=1;w<=67108863;w*=h)S++;S--,w=w/h|0;for(var R=u.length-y,O=R%S,_=Math.min(R,R-O)+y,c=0,b=y;b<_;b+=S)c=f(u,b,b+S,h),this.imuln(w),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(O!==0){var k=1;for(c=f(u,b,u.length,h),b=0;b<O;b++)k*=h;this.imuln(k),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this.strip()},i.prototype.copy=function(u){u.words=new Array(this.length);for(var h=0;h<this.length;h++)u.words[h]=this.words[h];u.length=this.length,u.negative=this.negative,u.red=this.red},i.prototype.clone=function(){var u=new i(null);return this.copy(u),u},i.prototype._expand=function(u){for(;this.length<u;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],m=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],g=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(u,h){u=u||10,h=h|0||1;var y;if(u===16||u==="hex"){y="";for(var S=0,w=0,R=0;R<this.length;R++){var O=this.words[R],_=((O<<S|w)&16777215).toString(16);w=O>>>24-S&16777215,S+=2,S>=26&&(S-=26,R--),w!==0||R!==this.length-1?y=l[6-_.length]+_+y:y=_+y}for(w!==0&&(y=w.toString(16)+y);y.length%h!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(u===(u|0)&&u>=2&&u<=36){var c=m[u],b=g[u];y="";var k=this.clone();for(k.negative=0;!k.isZero();){var D=k.modn(b).toString(u);k=k.idivn(b),k.isZero()?y=D+y:y=l[c-D.length]+D+y}for(this.isZero()&&(y="0"+y);y.length%h!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(u,h){return r(typeof o<"u"),this.toArrayLike(o,u,h)},i.prototype.toArray=function(u,h){return this.toArrayLike(Array,u,h)},i.prototype.toArrayLike=function(u,h,y){var S=this.byteLength(),w=y||Math.max(1,S);r(S<=w,"byte array longer than desired length"),r(w>0,"Requested array length <= 0"),this.strip();var R=h==="le",O=new u(w),_,c,b=this.clone();if(R){for(c=0;!b.isZero();c++)_=b.andln(255),b.iushrn(8),O[c]=_;for(;c<w;c++)O[c]=0}else{for(c=0;c<w-S;c++)O[c]=0;for(c=0;!b.isZero();c++)_=b.andln(255),b.iushrn(8),O[w-c-1]=_}return O},Math.clz32?i.prototype._countBits=function(u){return 32-Math.clz32(u)}:i.prototype._countBits=function(u){var h=u,y=0;return h>=4096&&(y+=13,h>>>=13),h>=64&&(y+=7,h>>>=7),h>=8&&(y+=4,h>>>=4),h>=2&&(y+=2,h>>>=2),y+h},i.prototype._zeroBits=function(u){if(u===0)return 26;var h=u,y=0;return(h&8191)===0&&(y+=13,h>>>=13),(h&127)===0&&(y+=7,h>>>=7),(h&15)===0&&(y+=4,h>>>=4),(h&3)===0&&(y+=2,h>>>=2),(h&1)===0&&y++,y},i.prototype.bitLength=function(){var u=this.words[this.length-1],h=this._countBits(u);return(this.length-1)*26+h};function v(I){for(var u=new Array(I.bitLength()),h=0;h<u.length;h++){var y=h/26|0,S=h%26;u[h]=(I.words[y]&1<<S)>>>S}return u}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,h=0;h<this.length;h++){var y=this._zeroBits(this.words[h]);if(u+=y,y!==26)break}return u},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},i.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var h=0;h<u.length;h++)this.words[h]=this.words[h]|u.words[h];return this.strip()},i.prototype.ior=function(u){return r((this.negative|u.negative)===0),this.iuor(u)},i.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},i.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},i.prototype.iuand=function(u){var h;this.length>u.length?h=u:h=this;for(var y=0;y<h.length;y++)this.words[y]=this.words[y]&u.words[y];return this.length=h.length,this.strip()},i.prototype.iand=function(u){return r((this.negative|u.negative)===0),this.iuand(u)},i.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},i.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},i.prototype.iuxor=function(u){var h,y;this.length>u.length?(h=this,y=u):(h=u,y=this);for(var S=0;S<y.length;S++)this.words[S]=h.words[S]^y.words[S];if(this!==h)for(;S<h.length;S++)this.words[S]=h.words[S];return this.length=h.length,this.strip()},i.prototype.ixor=function(u){return r((this.negative|u.negative)===0),this.iuxor(u)},i.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},i.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},i.prototype.inotn=function(u){r(typeof u=="number"&&u>=0);var h=Math.ceil(u/26)|0,y=u%26;this._expand(h),y>0&&h--;for(var S=0;S<h;S++)this.words[S]=~this.words[S]&67108863;for(y>0&&(this.words[S]=~this.words[S]&67108863>>26-y,S++);S<this.length;S++)this.words[S]=0;return this.strip()},i.prototype.notn=function(u){return this.clone().inotn(u)},i.prototype.setn=function(u,h){r(typeof u=="number"&&u>=0);var y=u/26|0,S=u%26;return this._expand(y+1),h?this.words[y]=this.words[y]|1<<S:this.words[y]=this.words[y]&~(1<<S),this.strip()},i.prototype.iadd=function(u){var h;if(this.negative!==0&&u.negative===0)return this.negative=0,h=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,h=this.isub(u),u.negative=1,h._normSign();var y,S;this.length>u.length?(y=this,S=u):(y=u,S=this);for(var w=0,R=0;R<S.length;R++)h=(y.words[R]|0)+(S.words[R]|0)+w,this.words[R]=h&67108863,w=h>>>26;for(;w!==0&&R<y.length;R++)h=(y.words[R]|0)+w,this.words[R]=h&67108863,w=h>>>26;if(this.length=y.length,w!==0)this.words[this.length]=w,this.length++;else if(y!==this)for(;R<y.length;R++)this.words[R]=y.words[R];return this},i.prototype.add=function(u){var h;return u.negative!==0&&this.negative===0?(u.negative=0,h=this.sub(u),u.negative^=1,h):u.negative===0&&this.negative!==0?(this.negative=0,h=u.sub(this),this.negative=1,h):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},i.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var h=this.iadd(u);return u.negative=1,h._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var y=this.cmp(u);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var S,w;y>0?(S=this,w=u):(S=u,w=this);for(var R=0,O=0;O<w.length;O++)h=(S.words[O]|0)-(w.words[O]|0)+R,R=h>>26,this.words[O]=h&67108863;for(;R!==0&&O<S.length;O++)h=(S.words[O]|0)+R,R=h>>26,this.words[O]=h&67108863;if(R===0&&O<S.length&&S!==this)for(;O<S.length;O++)this.words[O]=S.words[O];return this.length=Math.max(this.length,O),S!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(u){return this.clone().isub(u)};function E(I,u,h){h.negative=u.negative^I.negative;var y=I.length+u.length|0;h.length=y,y=y-1|0;var S=I.words[0]|0,w=u.words[0]|0,R=S*w,O=R&67108863,_=R/67108864|0;h.words[0]=O;for(var c=1;c<y;c++){for(var b=_>>>26,k=_&67108863,D=Math.min(c,u.length-1),K=Math.max(0,c-I.length+1);K<=D;K++){var G=c-K|0;S=I.words[G]|0,w=u.words[K]|0,R=S*w+k,b+=R/67108864|0,k=R&67108863}h.words[c]=k|0,_=b|0}return _!==0?h.words[c]=_|0:h.length--,h.strip()}var T=function(u,h,y){var S=u.words,w=h.words,R=y.words,O=0,_,c,b,k=S[0]|0,D=k&8191,K=k>>>13,G=S[1]|0,X=G&8191,Z=G>>>13,le=S[2]|0,se=le&8191,A=le>>>13,C=S[3]|0,U=C&8191,j=C>>>13,re=S[4]|0,J=re&8191,te=re>>>13,ae=S[5]|0,oe=ae&8191,ue=ae>>>13,_e=S[6]|0,we=_e&8191,fe=_e>>>13,de=S[7]|0,be=de&8191,xe=de>>>13,or=S[8]|0,Ze=or&8191,Ve=or>>>13,Ya=S[9]|0,Je=Ya&8191,st=Ya>>>13,Wp=w[0]|0,at=Wp&8191,ut=Wp>>>13,zp=w[1]|0,ft=zp&8191,ct=zp>>>13,Yp=w[2]|0,lt=Yp&8191,ht=Yp>>>13,$p=w[3]|0,dt=$p&8191,pt=$p>>>13,Zp=w[4]|0,gt=Zp&8191,yt=Zp>>>13,Xp=w[5]|0,mt=Xp&8191,vt=Xp>>>13,Jp=w[6]|0,bt=Jp&8191,_t=Jp>>>13,Qp=w[7]|0,St=Qp&8191,wt=Qp>>>13,e0=w[8]|0,Et=e0&8191,xt=e0>>>13,t0=w[9]|0,It=t0&8191,Ot=t0>>>13;y.negative=u.negative^h.negative,y.length=19,_=Math.imul(D,at),c=Math.imul(D,ut),c=c+Math.imul(K,at)|0,b=Math.imul(K,ut);var qc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(qc>>>26)|0,qc&=67108863,_=Math.imul(X,at),c=Math.imul(X,ut),c=c+Math.imul(Z,at)|0,b=Math.imul(Z,ut),_=_+Math.imul(D,ft)|0,c=c+Math.imul(D,ct)|0,c=c+Math.imul(K,ft)|0,b=b+Math.imul(K,ct)|0;var jc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(jc>>>26)|0,jc&=67108863,_=Math.imul(se,at),c=Math.imul(se,ut),c=c+Math.imul(A,at)|0,b=Math.imul(A,ut),_=_+Math.imul(X,ft)|0,c=c+Math.imul(X,ct)|0,c=c+Math.imul(Z,ft)|0,b=b+Math.imul(Z,ct)|0,_=_+Math.imul(D,lt)|0,c=c+Math.imul(D,ht)|0,c=c+Math.imul(K,lt)|0,b=b+Math.imul(K,ht)|0;var Hc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(Hc>>>26)|0,Hc&=67108863,_=Math.imul(U,at),c=Math.imul(U,ut),c=c+Math.imul(j,at)|0,b=Math.imul(j,ut),_=_+Math.imul(se,ft)|0,c=c+Math.imul(se,ct)|0,c=c+Math.imul(A,ft)|0,b=b+Math.imul(A,ct)|0,_=_+Math.imul(X,lt)|0,c=c+Math.imul(X,ht)|0,c=c+Math.imul(Z,lt)|0,b=b+Math.imul(Z,ht)|0,_=_+Math.imul(D,dt)|0,c=c+Math.imul(D,pt)|0,c=c+Math.imul(K,dt)|0,b=b+Math.imul(K,pt)|0;var Kc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(Kc>>>26)|0,Kc&=67108863,_=Math.imul(J,at),c=Math.imul(J,ut),c=c+Math.imul(te,at)|0,b=Math.imul(te,ut),_=_+Math.imul(U,ft)|0,c=c+Math.imul(U,ct)|0,c=c+Math.imul(j,ft)|0,b=b+Math.imul(j,ct)|0,_=_+Math.imul(se,lt)|0,c=c+Math.imul(se,ht)|0,c=c+Math.imul(A,lt)|0,b=b+Math.imul(A,ht)|0,_=_+Math.imul(X,dt)|0,c=c+Math.imul(X,pt)|0,c=c+Math.imul(Z,dt)|0,b=b+Math.imul(Z,pt)|0,_=_+Math.imul(D,gt)|0,c=c+Math.imul(D,yt)|0,c=c+Math.imul(K,gt)|0,b=b+Math.imul(K,yt)|0;var Gc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(Gc>>>26)|0,Gc&=67108863,_=Math.imul(oe,at),c=Math.imul(oe,ut),c=c+Math.imul(ue,at)|0,b=Math.imul(ue,ut),_=_+Math.imul(J,ft)|0,c=c+Math.imul(J,ct)|0,c=c+Math.imul(te,ft)|0,b=b+Math.imul(te,ct)|0,_=_+Math.imul(U,lt)|0,c=c+Math.imul(U,ht)|0,c=c+Math.imul(j,lt)|0,b=b+Math.imul(j,ht)|0,_=_+Math.imul(se,dt)|0,c=c+Math.imul(se,pt)|0,c=c+Math.imul(A,dt)|0,b=b+Math.imul(A,pt)|0,_=_+Math.imul(X,gt)|0,c=c+Math.imul(X,yt)|0,c=c+Math.imul(Z,gt)|0,b=b+Math.imul(Z,yt)|0,_=_+Math.imul(D,mt)|0,c=c+Math.imul(D,vt)|0,c=c+Math.imul(K,mt)|0,b=b+Math.imul(K,vt)|0;var Vc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(Vc>>>26)|0,Vc&=67108863,_=Math.imul(we,at),c=Math.imul(we,ut),c=c+Math.imul(fe,at)|0,b=Math.imul(fe,ut),_=_+Math.imul(oe,ft)|0,c=c+Math.imul(oe,ct)|0,c=c+Math.imul(ue,ft)|0,b=b+Math.imul(ue,ct)|0,_=_+Math.imul(J,lt)|0,c=c+Math.imul(J,ht)|0,c=c+Math.imul(te,lt)|0,b=b+Math.imul(te,ht)|0,_=_+Math.imul(U,dt)|0,c=c+Math.imul(U,pt)|0,c=c+Math.imul(j,dt)|0,b=b+Math.imul(j,pt)|0,_=_+Math.imul(se,gt)|0,c=c+Math.imul(se,yt)|0,c=c+Math.imul(A,gt)|0,b=b+Math.imul(A,yt)|0,_=_+Math.imul(X,mt)|0,c=c+Math.imul(X,vt)|0,c=c+Math.imul(Z,mt)|0,b=b+Math.imul(Z,vt)|0,_=_+Math.imul(D,bt)|0,c=c+Math.imul(D,_t)|0,c=c+Math.imul(K,bt)|0,b=b+Math.imul(K,_t)|0;var Wc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(Wc>>>26)|0,Wc&=67108863,_=Math.imul(be,at),c=Math.imul(be,ut),c=c+Math.imul(xe,at)|0,b=Math.imul(xe,ut),_=_+Math.imul(we,ft)|0,c=c+Math.imul(we,ct)|0,c=c+Math.imul(fe,ft)|0,b=b+Math.imul(fe,ct)|0,_=_+Math.imul(oe,lt)|0,c=c+Math.imul(oe,ht)|0,c=c+Math.imul(ue,lt)|0,b=b+Math.imul(ue,ht)|0,_=_+Math.imul(J,dt)|0,c=c+Math.imul(J,pt)|0,c=c+Math.imul(te,dt)|0,b=b+Math.imul(te,pt)|0,_=_+Math.imul(U,gt)|0,c=c+Math.imul(U,yt)|0,c=c+Math.imul(j,gt)|0,b=b+Math.imul(j,yt)|0,_=_+Math.imul(se,mt)|0,c=c+Math.imul(se,vt)|0,c=c+Math.imul(A,mt)|0,b=b+Math.imul(A,vt)|0,_=_+Math.imul(X,bt)|0,c=c+Math.imul(X,_t)|0,c=c+Math.imul(Z,bt)|0,b=b+Math.imul(Z,_t)|0,_=_+Math.imul(D,St)|0,c=c+Math.imul(D,wt)|0,c=c+Math.imul(K,St)|0,b=b+Math.imul(K,wt)|0;var zc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(zc>>>26)|0,zc&=67108863,_=Math.imul(Ze,at),c=Math.imul(Ze,ut),c=c+Math.imul(Ve,at)|0,b=Math.imul(Ve,ut),_=_+Math.imul(be,ft)|0,c=c+Math.imul(be,ct)|0,c=c+Math.imul(xe,ft)|0,b=b+Math.imul(xe,ct)|0,_=_+Math.imul(we,lt)|0,c=c+Math.imul(we,ht)|0,c=c+Math.imul(fe,lt)|0,b=b+Math.imul(fe,ht)|0,_=_+Math.imul(oe,dt)|0,c=c+Math.imul(oe,pt)|0,c=c+Math.imul(ue,dt)|0,b=b+Math.imul(ue,pt)|0,_=_+Math.imul(J,gt)|0,c=c+Math.imul(J,yt)|0,c=c+Math.imul(te,gt)|0,b=b+Math.imul(te,yt)|0,_=_+Math.imul(U,mt)|0,c=c+Math.imul(U,vt)|0,c=c+Math.imul(j,mt)|0,b=b+Math.imul(j,vt)|0,_=_+Math.imul(se,bt)|0,c=c+Math.imul(se,_t)|0,c=c+Math.imul(A,bt)|0,b=b+Math.imul(A,_t)|0,_=_+Math.imul(X,St)|0,c=c+Math.imul(X,wt)|0,c=c+Math.imul(Z,St)|0,b=b+Math.imul(Z,wt)|0,_=_+Math.imul(D,Et)|0,c=c+Math.imul(D,xt)|0,c=c+Math.imul(K,Et)|0,b=b+Math.imul(K,xt)|0;var Yc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(Yc>>>26)|0,Yc&=67108863,_=Math.imul(Je,at),c=Math.imul(Je,ut),c=c+Math.imul(st,at)|0,b=Math.imul(st,ut),_=_+Math.imul(Ze,ft)|0,c=c+Math.imul(Ze,ct)|0,c=c+Math.imul(Ve,ft)|0,b=b+Math.imul(Ve,ct)|0,_=_+Math.imul(be,lt)|0,c=c+Math.imul(be,ht)|0,c=c+Math.imul(xe,lt)|0,b=b+Math.imul(xe,ht)|0,_=_+Math.imul(we,dt)|0,c=c+Math.imul(we,pt)|0,c=c+Math.imul(fe,dt)|0,b=b+Math.imul(fe,pt)|0,_=_+Math.imul(oe,gt)|0,c=c+Math.imul(oe,yt)|0,c=c+Math.imul(ue,gt)|0,b=b+Math.imul(ue,yt)|0,_=_+Math.imul(J,mt)|0,c=c+Math.imul(J,vt)|0,c=c+Math.imul(te,mt)|0,b=b+Math.imul(te,vt)|0,_=_+Math.imul(U,bt)|0,c=c+Math.imul(U,_t)|0,c=c+Math.imul(j,bt)|0,b=b+Math.imul(j,_t)|0,_=_+Math.imul(se,St)|0,c=c+Math.imul(se,wt)|0,c=c+Math.imul(A,St)|0,b=b+Math.imul(A,wt)|0,_=_+Math.imul(X,Et)|0,c=c+Math.imul(X,xt)|0,c=c+Math.imul(Z,Et)|0,b=b+Math.imul(Z,xt)|0,_=_+Math.imul(D,It)|0,c=c+Math.imul(D,Ot)|0,c=c+Math.imul(K,It)|0,b=b+Math.imul(K,Ot)|0;var $c=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+($c>>>26)|0,$c&=67108863,_=Math.imul(Je,ft),c=Math.imul(Je,ct),c=c+Math.imul(st,ft)|0,b=Math.imul(st,ct),_=_+Math.imul(Ze,lt)|0,c=c+Math.imul(Ze,ht)|0,c=c+Math.imul(Ve,lt)|0,b=b+Math.imul(Ve,ht)|0,_=_+Math.imul(be,dt)|0,c=c+Math.imul(be,pt)|0,c=c+Math.imul(xe,dt)|0,b=b+Math.imul(xe,pt)|0,_=_+Math.imul(we,gt)|0,c=c+Math.imul(we,yt)|0,c=c+Math.imul(fe,gt)|0,b=b+Math.imul(fe,yt)|0,_=_+Math.imul(oe,mt)|0,c=c+Math.imul(oe,vt)|0,c=c+Math.imul(ue,mt)|0,b=b+Math.imul(ue,vt)|0,_=_+Math.imul(J,bt)|0,c=c+Math.imul(J,_t)|0,c=c+Math.imul(te,bt)|0,b=b+Math.imul(te,_t)|0,_=_+Math.imul(U,St)|0,c=c+Math.imul(U,wt)|0,c=c+Math.imul(j,St)|0,b=b+Math.imul(j,wt)|0,_=_+Math.imul(se,Et)|0,c=c+Math.imul(se,xt)|0,c=c+Math.imul(A,Et)|0,b=b+Math.imul(A,xt)|0,_=_+Math.imul(X,It)|0,c=c+Math.imul(X,Ot)|0,c=c+Math.imul(Z,It)|0,b=b+Math.imul(Z,Ot)|0;var Zc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(Zc>>>26)|0,Zc&=67108863,_=Math.imul(Je,lt),c=Math.imul(Je,ht),c=c+Math.imul(st,lt)|0,b=Math.imul(st,ht),_=_+Math.imul(Ze,dt)|0,c=c+Math.imul(Ze,pt)|0,c=c+Math.imul(Ve,dt)|0,b=b+Math.imul(Ve,pt)|0,_=_+Math.imul(be,gt)|0,c=c+Math.imul(be,yt)|0,c=c+Math.imul(xe,gt)|0,b=b+Math.imul(xe,yt)|0,_=_+Math.imul(we,mt)|0,c=c+Math.imul(we,vt)|0,c=c+Math.imul(fe,mt)|0,b=b+Math.imul(fe,vt)|0,_=_+Math.imul(oe,bt)|0,c=c+Math.imul(oe,_t)|0,c=c+Math.imul(ue,bt)|0,b=b+Math.imul(ue,_t)|0,_=_+Math.imul(J,St)|0,c=c+Math.imul(J,wt)|0,c=c+Math.imul(te,St)|0,b=b+Math.imul(te,wt)|0,_=_+Math.imul(U,Et)|0,c=c+Math.imul(U,xt)|0,c=c+Math.imul(j,Et)|0,b=b+Math.imul(j,xt)|0,_=_+Math.imul(se,It)|0,c=c+Math.imul(se,Ot)|0,c=c+Math.imul(A,It)|0,b=b+Math.imul(A,Ot)|0;var Xc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(Xc>>>26)|0,Xc&=67108863,_=Math.imul(Je,dt),c=Math.imul(Je,pt),c=c+Math.imul(st,dt)|0,b=Math.imul(st,pt),_=_+Math.imul(Ze,gt)|0,c=c+Math.imul(Ze,yt)|0,c=c+Math.imul(Ve,gt)|0,b=b+Math.imul(Ve,yt)|0,_=_+Math.imul(be,mt)|0,c=c+Math.imul(be,vt)|0,c=c+Math.imul(xe,mt)|0,b=b+Math.imul(xe,vt)|0,_=_+Math.imul(we,bt)|0,c=c+Math.imul(we,_t)|0,c=c+Math.imul(fe,bt)|0,b=b+Math.imul(fe,_t)|0,_=_+Math.imul(oe,St)|0,c=c+Math.imul(oe,wt)|0,c=c+Math.imul(ue,St)|0,b=b+Math.imul(ue,wt)|0,_=_+Math.imul(J,Et)|0,c=c+Math.imul(J,xt)|0,c=c+Math.imul(te,Et)|0,b=b+Math.imul(te,xt)|0,_=_+Math.imul(U,It)|0,c=c+Math.imul(U,Ot)|0,c=c+Math.imul(j,It)|0,b=b+Math.imul(j,Ot)|0;var Jc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(Jc>>>26)|0,Jc&=67108863,_=Math.imul(Je,gt),c=Math.imul(Je,yt),c=c+Math.imul(st,gt)|0,b=Math.imul(st,yt),_=_+Math.imul(Ze,mt)|0,c=c+Math.imul(Ze,vt)|0,c=c+Math.imul(Ve,mt)|0,b=b+Math.imul(Ve,vt)|0,_=_+Math.imul(be,bt)|0,c=c+Math.imul(be,_t)|0,c=c+Math.imul(xe,bt)|0,b=b+Math.imul(xe,_t)|0,_=_+Math.imul(we,St)|0,c=c+Math.imul(we,wt)|0,c=c+Math.imul(fe,St)|0,b=b+Math.imul(fe,wt)|0,_=_+Math.imul(oe,Et)|0,c=c+Math.imul(oe,xt)|0,c=c+Math.imul(ue,Et)|0,b=b+Math.imul(ue,xt)|0,_=_+Math.imul(J,It)|0,c=c+Math.imul(J,Ot)|0,c=c+Math.imul(te,It)|0,b=b+Math.imul(te,Ot)|0;var Qc=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(Qc>>>26)|0,Qc&=67108863,_=Math.imul(Je,mt),c=Math.imul(Je,vt),c=c+Math.imul(st,mt)|0,b=Math.imul(st,vt),_=_+Math.imul(Ze,bt)|0,c=c+Math.imul(Ze,_t)|0,c=c+Math.imul(Ve,bt)|0,b=b+Math.imul(Ve,_t)|0,_=_+Math.imul(be,St)|0,c=c+Math.imul(be,wt)|0,c=c+Math.imul(xe,St)|0,b=b+Math.imul(xe,wt)|0,_=_+Math.imul(we,Et)|0,c=c+Math.imul(we,xt)|0,c=c+Math.imul(fe,Et)|0,b=b+Math.imul(fe,xt)|0,_=_+Math.imul(oe,It)|0,c=c+Math.imul(oe,Ot)|0,c=c+Math.imul(ue,It)|0,b=b+Math.imul(ue,Ot)|0;var el=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(el>>>26)|0,el&=67108863,_=Math.imul(Je,bt),c=Math.imul(Je,_t),c=c+Math.imul(st,bt)|0,b=Math.imul(st,_t),_=_+Math.imul(Ze,St)|0,c=c+Math.imul(Ze,wt)|0,c=c+Math.imul(Ve,St)|0,b=b+Math.imul(Ve,wt)|0,_=_+Math.imul(be,Et)|0,c=c+Math.imul(be,xt)|0,c=c+Math.imul(xe,Et)|0,b=b+Math.imul(xe,xt)|0,_=_+Math.imul(we,It)|0,c=c+Math.imul(we,Ot)|0,c=c+Math.imul(fe,It)|0,b=b+Math.imul(fe,Ot)|0;var tl=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(tl>>>26)|0,tl&=67108863,_=Math.imul(Je,St),c=Math.imul(Je,wt),c=c+Math.imul(st,St)|0,b=Math.imul(st,wt),_=_+Math.imul(Ze,Et)|0,c=c+Math.imul(Ze,xt)|0,c=c+Math.imul(Ve,Et)|0,b=b+Math.imul(Ve,xt)|0,_=_+Math.imul(be,It)|0,c=c+Math.imul(be,Ot)|0,c=c+Math.imul(xe,It)|0,b=b+Math.imul(xe,Ot)|0;var rl=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(rl>>>26)|0,rl&=67108863,_=Math.imul(Je,Et),c=Math.imul(Je,xt),c=c+Math.imul(st,Et)|0,b=Math.imul(st,xt),_=_+Math.imul(Ze,It)|0,c=c+Math.imul(Ze,Ot)|0,c=c+Math.imul(Ve,It)|0,b=b+Math.imul(Ve,Ot)|0;var nl=(O+_|0)+((c&8191)<<13)|0;O=(b+(c>>>13)|0)+(nl>>>26)|0,nl&=67108863,_=Math.imul(Je,It),c=Math.imul(Je,Ot),c=c+Math.imul(st,It)|0,b=Math.imul(st,Ot);var il=(O+_|0)+((c&8191)<<13)|0;return O=(b+(c>>>13)|0)+(il>>>26)|0,il&=67108863,R[0]=qc,R[1]=jc,R[2]=Hc,R[3]=Kc,R[4]=Gc,R[5]=Vc,R[6]=Wc,R[7]=zc,R[8]=Yc,R[9]=$c,R[10]=Zc,R[11]=Xc,R[12]=Jc,R[13]=Qc,R[14]=el,R[15]=tl,R[16]=rl,R[17]=nl,R[18]=il,O!==0&&(R[19]=O,y.length++),y};Math.imul||(T=E);function N(I,u,h){h.negative=u.negative^I.negative,h.length=I.length+u.length;for(var y=0,S=0,w=0;w<h.length-1;w++){var R=S;S=0;for(var O=y&67108863,_=Math.min(w,u.length-1),c=Math.max(0,w-I.length+1);c<=_;c++){var b=w-c,k=I.words[b]|0,D=u.words[c]|0,K=k*D,G=K&67108863;R=R+(K/67108864|0)|0,G=G+O|0,O=G&67108863,R=R+(G>>>26)|0,S+=R>>>26,R&=67108863}h.words[w]=O,y=R,R=S}return y!==0?h.words[w]=y:h.length--,h.strip()}function L(I,u,h){var y=new F;return y.mulp(I,u,h)}i.prototype.mulTo=function(u,h){var y,S=this.length+u.length;return this.length===10&&u.length===10?y=T(this,u,h):S<63?y=E(this,u,h):S<1024?y=N(this,u,h):y=L(this,u,h),y};function F(I,u){this.x=I,this.y=u}F.prototype.makeRBT=function(u){for(var h=new Array(u),y=i.prototype._countBits(u)-1,S=0;S<u;S++)h[S]=this.revBin(S,y,u);return h},F.prototype.revBin=function(u,h,y){if(u===0||u===y-1)return u;for(var S=0,w=0;w<h;w++)S|=(u&1)<<h-w-1,u>>=1;return S},F.prototype.permute=function(u,h,y,S,w,R){for(var O=0;O<R;O++)S[O]=h[u[O]],w[O]=y[u[O]]},F.prototype.transform=function(u,h,y,S,w,R){this.permute(R,u,h,y,S,w);for(var O=1;O<w;O<<=1)for(var _=O<<1,c=Math.cos(2*Math.PI/_),b=Math.sin(2*Math.PI/_),k=0;k<w;k+=_)for(var D=c,K=b,G=0;G<O;G++){var X=y[k+G],Z=S[k+G],le=y[k+G+O],se=S[k+G+O],A=D*le-K*se;se=D*se+K*le,le=A,y[k+G]=X+le,S[k+G]=Z+se,y[k+G+O]=X-le,S[k+G+O]=Z-se,G!==_&&(A=c*D-b*K,K=c*K+b*D,D=A)}},F.prototype.guessLen13b=function(u,h){var y=Math.max(h,u)|1,S=y&1,w=0;for(y=y/2|0;y;y=y>>>1)w++;return 1<<w+1+S},F.prototype.conjugate=function(u,h,y){if(!(y<=1))for(var S=0;S<y/2;S++){var w=u[S];u[S]=u[y-S-1],u[y-S-1]=w,w=h[S],h[S]=-h[y-S-1],h[y-S-1]=-w}},F.prototype.normalize13b=function(u,h){for(var y=0,S=0;S<h/2;S++){var w=Math.round(u[2*S+1]/h)*8192+Math.round(u[2*S]/h)+y;u[S]=w&67108863,w<67108864?y=0:y=w/67108864|0}return u},F.prototype.convert13b=function(u,h,y,S){for(var w=0,R=0;R<h;R++)w=w+(u[R]|0),y[2*R]=w&8191,w=w>>>13,y[2*R+1]=w&8191,w=w>>>13;for(R=2*h;R<S;++R)y[R]=0;r(w===0),r((w&-8192)===0)},F.prototype.stub=function(u){for(var h=new Array(u),y=0;y<u;y++)h[y]=0;return h},F.prototype.mulp=function(u,h,y){var S=2*this.guessLen13b(u.length,h.length),w=this.makeRBT(S),R=this.stub(S),O=new Array(S),_=new Array(S),c=new Array(S),b=new Array(S),k=new Array(S),D=new Array(S),K=y.words;K.length=S,this.convert13b(u.words,u.length,O,S),this.convert13b(h.words,h.length,b,S),this.transform(O,R,_,c,S,w),this.transform(b,R,k,D,S,w);for(var G=0;G<S;G++){var X=_[G]*k[G]-c[G]*D[G];c[G]=_[G]*D[G]+c[G]*k[G],_[G]=X}return this.conjugate(_,c,S),this.transform(_,c,K,R,S,w),this.conjugate(K,R,S),this.normalize13b(K,S),y.negative=u.negative^h.negative,y.length=u.length+h.length,y.strip()},i.prototype.mul=function(u){var h=new i(null);return h.words=new Array(this.length+u.length),this.mulTo(u,h)},i.prototype.mulf=function(u){var h=new i(null);return h.words=new Array(this.length+u.length),L(this,u,h)},i.prototype.imul=function(u){return this.clone().mulTo(u,this)},i.prototype.imuln=function(u){r(typeof u=="number"),r(u<67108864);for(var h=0,y=0;y<this.length;y++){var S=(this.words[y]|0)*u,w=(S&67108863)+(h&67108863);h>>=26,h+=S/67108864|0,h+=w>>>26,this.words[y]=w&67108863}return h!==0&&(this.words[y]=h,this.length++),u===0&&(this.length=1,this._normSign()),this},i.prototype.muln=function(u){return this.clone().imuln(u)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(u){var h=v(u);if(h.length===0)return new i(1);for(var y=this,S=0;S<h.length&&h[S]===0;S++,y=y.sqr());if(++S<h.length)for(var w=y.sqr();S<h.length;S++,w=w.sqr())h[S]!==0&&(y=y.mul(w));return y},i.prototype.iushln=function(u){r(typeof u=="number"&&u>=0);var h=u%26,y=(u-h)/26,S=67108863>>>26-h<<26-h,w;if(h!==0){var R=0;for(w=0;w<this.length;w++){var O=this.words[w]&S,_=(this.words[w]|0)-O<<h;this.words[w]=_|R,R=O>>>26-h}R&&(this.words[w]=R,this.length++)}if(y!==0){for(w=this.length-1;w>=0;w--)this.words[w+y]=this.words[w];for(w=0;w<y;w++)this.words[w]=0;this.length+=y}return this.strip()},i.prototype.ishln=function(u){return r(this.negative===0),this.iushln(u)},i.prototype.iushrn=function(u,h,y){r(typeof u=="number"&&u>=0);var S;h?S=(h-h%26)/26:S=0;var w=u%26,R=Math.min((u-w)/26,this.length),O=67108863^67108863>>>w<<w,_=y;if(S-=R,S=Math.max(0,S),_){for(var c=0;c<R;c++)_.words[c]=this.words[c];_.length=R}if(R!==0)if(this.length>R)for(this.length-=R,c=0;c<this.length;c++)this.words[c]=this.words[c+R];else this.words[0]=0,this.length=1;var b=0;for(c=this.length-1;c>=0&&(b!==0||c>=S);c--){var k=this.words[c]|0;this.words[c]=b<<26-w|k>>>w,b=k&O}return _&&b!==0&&(_.words[_.length++]=b),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(u,h,y){return r(this.negative===0),this.iushrn(u,h,y)},i.prototype.shln=function(u){return this.clone().ishln(u)},i.prototype.ushln=function(u){return this.clone().iushln(u)},i.prototype.shrn=function(u){return this.clone().ishrn(u)},i.prototype.ushrn=function(u){return this.clone().iushrn(u)},i.prototype.testn=function(u){r(typeof u=="number"&&u>=0);var h=u%26,y=(u-h)/26,S=1<<h;if(this.length<=y)return!1;var w=this.words[y];return!!(w&S)},i.prototype.imaskn=function(u){r(typeof u=="number"&&u>=0);var h=u%26,y=(u-h)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(h!==0&&y++,this.length=Math.min(y,this.length),h!==0){var S=67108863^67108863>>>h<<h;this.words[this.length-1]&=S}return this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.maskn=function(u){return this.clone().imaskn(u)},i.prototype.iaddn=function(u){return r(typeof u=="number"),r(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},i.prototype._iaddn=function(u){this.words[0]+=u;for(var h=0;h<this.length&&this.words[h]>=67108864;h++)this.words[h]-=67108864,h===this.length-1?this.words[h+1]=1:this.words[h+1]++;return this.length=Math.max(this.length,h+1),this},i.prototype.isubn=function(u){if(r(typeof u=="number"),r(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var h=0;h<this.length&&this.words[h]<0;h++)this.words[h]+=67108864,this.words[h+1]-=1;return this.strip()},i.prototype.addn=function(u){return this.clone().iaddn(u)},i.prototype.subn=function(u){return this.clone().isubn(u)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(u,h,y){var S=u.length+y,w;this._expand(S);var R,O=0;for(w=0;w<u.length;w++){R=(this.words[w+y]|0)+O;var _=(u.words[w]|0)*h;R-=_&67108863,O=(R>>26)-(_/67108864|0),this.words[w+y]=R&67108863}for(;w<this.length-y;w++)R=(this.words[w+y]|0)+O,O=R>>26,this.words[w+y]=R&67108863;if(O===0)return this.strip();for(r(O===-1),O=0,w=0;w<this.length;w++)R=-(this.words[w]|0)+O,O=R>>26,this.words[w]=R&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(u,h){var y=this.length-u.length,S=this.clone(),w=u,R=w.words[w.length-1]|0,O=this._countBits(R);y=26-O,y!==0&&(w=w.ushln(y),S.iushln(y),R=w.words[w.length-1]|0);var _=S.length-w.length,c;if(h!=="mod"){c=new i(null),c.length=_+1,c.words=new Array(c.length);for(var b=0;b<c.length;b++)c.words[b]=0}var k=S.clone()._ishlnsubmul(w,1,_);k.negative===0&&(S=k,c&&(c.words[_]=1));for(var D=_-1;D>=0;D--){var K=(S.words[w.length+D]|0)*67108864+(S.words[w.length+D-1]|0);for(K=Math.min(K/R|0,67108863),S._ishlnsubmul(w,K,D);S.negative!==0;)K--,S.negative=0,S._ishlnsubmul(w,1,D),S.isZero()||(S.negative^=1);c&&(c.words[D]=K)}return c&&c.strip(),S.strip(),h!=="div"&&y!==0&&S.iushrn(y),{div:c||null,mod:S}},i.prototype.divmod=function(u,h,y){if(r(!u.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var S,w,R;return this.negative!==0&&u.negative===0?(R=this.neg().divmod(u,h),h!=="mod"&&(S=R.div.neg()),h!=="div"&&(w=R.mod.neg(),y&&w.negative!==0&&w.iadd(u)),{div:S,mod:w}):this.negative===0&&u.negative!==0?(R=this.divmod(u.neg(),h),h!=="mod"&&(S=R.div.neg()),{div:S,mod:R.mod}):(this.negative&u.negative)!==0?(R=this.neg().divmod(u.neg(),h),h!=="div"&&(w=R.mod.neg(),y&&w.negative!==0&&w.isub(u)),{div:R.div,mod:w}):u.length>this.length||this.cmp(u)<0?{div:new i(0),mod:this}:u.length===1?h==="div"?{div:this.divn(u.words[0]),mod:null}:h==="mod"?{div:null,mod:new i(this.modn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new i(this.modn(u.words[0]))}:this._wordDiv(u,h)},i.prototype.div=function(u){return this.divmod(u,"div",!1).div},i.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},i.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},i.prototype.divRound=function(u){var h=this.divmod(u);if(h.mod.isZero())return h.div;var y=h.mod.abs(),S=u.abs().iushrn(1),w=u.words[0]&1,R=y.cmp(S);if(R<0||w===1&&R===0)return h.div;var O=new i(1);return O.negative=this.negative^u.negative,h.div.iadd(O)},i.prototype.modn=function(u){r(u<=67108863);for(var h=(1<<26)%u,y=0,S=this.length-1;S>=0;S--)y=(h*y+(this.words[S]|0))%u;return y},i.prototype.idivn=function(u){r(u<=67108863);for(var h=0,y=this.length-1;y>=0;y--){var S=(this.words[y]|0)+h*67108864;this.words[y]=S/u|0,h=S%u}return this.strip()},i.prototype.divn=function(u){return this.clone().idivn(u)},i.prototype.egcd=function(u){r(u.negative===0),r(!u.isZero());var h=this,y=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var S=new i(1),w=new i(0),R=new i(0),O=new i(1),_=0;h.isEven()&&y.isEven();)h.iushrn(1),y.iushrn(1),++_;for(var c=y.clone(),b=h.clone();!h.isZero();){for(var k=0,D=1;(h.words[0]&D)===0&&k<26;++k,D<<=1);if(k>0)for(h.iushrn(k);k-- >0;)(S.isOdd()||w.isOdd())&&(S.iadd(c),w.isub(b)),S.iushrn(1),w.iushrn(1);for(var K=0,G=1;(y.words[0]&G)===0&&K<26;++K,G<<=1);if(K>0)for(y.iushrn(K);K-- >0;)(R.isOdd()||O.isOdd())&&(R.iadd(c),O.isub(b)),R.iushrn(1),O.iushrn(1);h.cmp(y)>=0?(h.isub(y),S.isub(R),w.isub(O)):(y.isub(h),R.isub(S),O.isub(w))}return{a:R,b:O,gcd:y.iushln(_)}},i.prototype._invmp=function(u){r(u.negative===0),r(!u.isZero());var h=this,y=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var S=new i(1),w=new i(0),R=y.clone();h.cmpn(1)>0&&y.cmpn(1)>0;){for(var O=0,_=1;(h.words[0]&_)===0&&O<26;++O,_<<=1);if(O>0)for(h.iushrn(O);O-- >0;)S.isOdd()&&S.iadd(R),S.iushrn(1);for(var c=0,b=1;(y.words[0]&b)===0&&c<26;++c,b<<=1);if(c>0)for(y.iushrn(c);c-- >0;)w.isOdd()&&w.iadd(R),w.iushrn(1);h.cmp(y)>=0?(h.isub(y),S.isub(w)):(y.isub(h),w.isub(S))}var k;return h.cmpn(1)===0?k=S:k=w,k.cmpn(0)<0&&k.iadd(u),k},i.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var h=this.clone(),y=u.clone();h.negative=0,y.negative=0;for(var S=0;h.isEven()&&y.isEven();S++)h.iushrn(1),y.iushrn(1);do{for(;h.isEven();)h.iushrn(1);for(;y.isEven();)y.iushrn(1);var w=h.cmp(y);if(w<0){var R=h;h=y,y=R}else if(w===0||y.cmpn(1)===0)break;h.isub(y)}while(!0);return y.iushln(S)},i.prototype.invm=function(u){return this.egcd(u).a.umod(u)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(u){return this.words[0]&u},i.prototype.bincn=function(u){r(typeof u=="number");var h=u%26,y=(u-h)/26,S=1<<h;if(this.length<=y)return this._expand(y+1),this.words[y]|=S,this;for(var w=S,R=y;w!==0&&R<this.length;R++){var O=this.words[R]|0;O+=w,w=O>>>26,O&=67108863,this.words[R]=O}return w!==0&&(this.words[R]=w,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(u){var h=u<0;if(this.negative!==0&&!h)return-1;if(this.negative===0&&h)return 1;this.strip();var y;if(this.length>1)y=1;else{h&&(u=-u),r(u<=67108863,"Number is too big");var S=this.words[0]|0;y=S===u?0:S<u?-1:1}return this.negative!==0?-y|0:y},i.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var h=this.ucmp(u);return this.negative!==0?-h|0:h},i.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var h=0,y=this.length-1;y>=0;y--){var S=this.words[y]|0,w=u.words[y]|0;if(S!==w){S<w?h=-1:S>w&&(h=1);break}}return h},i.prototype.gtn=function(u){return this.cmpn(u)===1},i.prototype.gt=function(u){return this.cmp(u)===1},i.prototype.gten=function(u){return this.cmpn(u)>=0},i.prototype.gte=function(u){return this.cmp(u)>=0},i.prototype.ltn=function(u){return this.cmpn(u)===-1},i.prototype.lt=function(u){return this.cmp(u)===-1},i.prototype.lten=function(u){return this.cmpn(u)<=0},i.prototype.lte=function(u){return this.cmp(u)<=0},i.prototype.eqn=function(u){return this.cmpn(u)===0},i.prototype.eq=function(u){return this.cmp(u)===0},i.red=function(u){return new ce(u)},i.prototype.toRed=function(u){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(u){return this.red=u,this},i.prototype.forceRed=function(u){return r(!this.red,"Already a number in reduction context"),this._forceRed(u)},i.prototype.redAdd=function(u){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},i.prototype.redIAdd=function(u){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},i.prototype.redSub=function(u){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},i.prototype.redISub=function(u){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},i.prototype.redShl=function(u){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},i.prototype.redMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},i.prototype.redIMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(u){return r(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var V={k256:null,p224:null,p192:null,p25519:null};function z(I,u){this.name=I,this.p=new i(u,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var u=new i(null);return u.words=new Array(Math.ceil(this.n/13)),u},z.prototype.ireduce=function(u){var h=u,y;do this.split(h,this.tmp),h=this.imulK(h),h=h.iadd(this.tmp),y=h.bitLength();while(y>this.n);var S=y<this.n?-1:h.ucmp(this.p);return S===0?(h.words[0]=0,h.length=1):S>0?h.isub(this.p):h.strip!==void 0?h.strip():h._strip(),h},z.prototype.split=function(u,h){u.iushrn(this.n,0,h)},z.prototype.imulK=function(u){return u.imul(this.k)};function W(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(W,z),W.prototype.split=function(u,h){for(var y=4194303,S=Math.min(u.length,9),w=0;w<S;w++)h.words[w]=u.words[w];if(h.length=S,u.length<=9){u.words[0]=0,u.length=1;return}var R=u.words[9];for(h.words[h.length++]=R&y,w=10;w<u.length;w++){var O=u.words[w]|0;u.words[w-10]=(O&y)<<4|R>>>22,R=O}R>>>=22,u.words[w-10]=R,R===0&&u.length>10?u.length-=10:u.length-=9},W.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var h=0,y=0;y<u.length;y++){var S=u.words[y]|0;h+=S*977,u.words[y]=h&67108863,h=S*64+(h/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function ie(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(ie,z);function ee(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(ee,z);function ge(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(ge,z),ge.prototype.imulK=function(u){for(var h=0,y=0;y<u.length;y++){var S=(u.words[y]|0)*19+h,w=S&67108863;S>>>=26,u.words[y]=w,h=S}return h!==0&&(u.words[u.length++]=h),u},i._prime=function(u){if(V[u])return V[u];var h;if(u==="k256")h=new W;else if(u==="p224")h=new ie;else if(u==="p192")h=new ee;else if(u==="p25519")h=new ge;else throw new Error("Unknown prime "+u);return V[u]=h,h};function ce(I){if(typeof I=="string"){var u=i._prime(I);this.m=u.p,this.prime=u}else r(I.gtn(1),"modulus must be greater than 1"),this.m=I,this.prime=null}ce.prototype._verify1=function(u){r(u.negative===0,"red works only with positives"),r(u.red,"red works only with red numbers")},ce.prototype._verify2=function(u,h){r((u.negative|h.negative)===0,"red works only with positives"),r(u.red&&u.red===h.red,"red works only with red numbers")},ce.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):u.umod(this.m)._forceRed(this)},ce.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},ce.prototype.add=function(u,h){this._verify2(u,h);var y=u.add(h);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},ce.prototype.iadd=function(u,h){this._verify2(u,h);var y=u.iadd(h);return y.cmp(this.m)>=0&&y.isub(this.m),y},ce.prototype.sub=function(u,h){this._verify2(u,h);var y=u.sub(h);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},ce.prototype.isub=function(u,h){this._verify2(u,h);var y=u.isub(h);return y.cmpn(0)<0&&y.iadd(this.m),y},ce.prototype.shl=function(u,h){return this._verify1(u),this.imod(u.ushln(h))},ce.prototype.imul=function(u,h){return this._verify2(u,h),this.imod(u.imul(h))},ce.prototype.mul=function(u,h){return this._verify2(u,h),this.imod(u.mul(h))},ce.prototype.isqr=function(u){return this.imul(u,u.clone())},ce.prototype.sqr=function(u){return this.mul(u,u)},ce.prototype.sqrt=function(u){if(u.isZero())return u.clone();var h=this.m.andln(3);if(r(h%2===1),h===3){var y=this.m.add(new i(1)).iushrn(2);return this.pow(u,y)}for(var S=this.m.subn(1),w=0;!S.isZero()&&S.andln(1)===0;)w++,S.iushrn(1);r(!S.isZero());var R=new i(1).toRed(this),O=R.redNeg(),_=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);this.pow(c,_).cmp(O)!==0;)c.redIAdd(O);for(var b=this.pow(c,S),k=this.pow(u,S.addn(1).iushrn(1)),D=this.pow(u,S),K=w;D.cmp(R)!==0;){for(var G=D,X=0;G.cmp(R)!==0;X++)G=G.redSqr();r(X<K);var Z=this.pow(b,new i(1).iushln(K-X-1));k=k.redMul(Z),b=Z.redSqr(),D=D.redMul(b),K=X}return k},ce.prototype.invm=function(u){var h=u._invmp(this.m);return h.negative!==0?(h.negative=0,this.imod(h).redNeg()):this.imod(h)},ce.prototype.pow=function(u,h){if(h.isZero())return new i(1).toRed(this);if(h.cmpn(1)===0)return u.clone();var y=4,S=new Array(1<<y);S[0]=new i(1).toRed(this),S[1]=u;for(var w=2;w<S.length;w++)S[w]=this.mul(S[w-1],u);var R=S[0],O=0,_=0,c=h.bitLength()%26;for(c===0&&(c=26),w=h.length-1;w>=0;w--){for(var b=h.words[w],k=c-1;k>=0;k--){var D=b>>k&1;if(R!==S[0]&&(R=this.sqr(R)),D===0&&O===0){_=0;continue}O<<=1,O|=D,_++,!(_!==y&&(w!==0||k!==0))&&(R=this.mul(R,S[O]),_=0,O=0)}c=26}return R},ce.prototype.convertTo=function(u){var h=u.umod(this.m);return h===u?h.clone():h},ce.prototype.convertFrom=function(u){var h=u.clone();return h.red=null,h},i.mont=function(u){return new me(u)};function me(I){ce.call(this,I),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(me,ce),me.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},me.prototype.convertFrom=function(u){var h=this.imod(u.mul(this.rinv));return h.red=null,h},me.prototype.imul=function(u,h){if(u.isZero()||h.isZero())return u.words[0]=0,u.length=1,u;var y=u.imul(h),S=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=y.isub(S).iushrn(this.shift),R=w;return w.cmp(this.m)>=0?R=w.isub(this.m):w.cmpn(0)<0&&(R=w.iadd(this.m)),R._forceRed(this)},me.prototype.mul=function(u,h){if(u.isZero()||h.isZero())return new i(0)._forceRed(this);var y=u.mul(h),S=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=y.isub(S).iushrn(this.shift),R=w;return w.cmp(this.m)>=0?R=w.isub(this.m):w.cmpn(0)<0&&(R=w.iadd(this.m)),R._forceRed(this)},me.prototype.invm=function(u){var h=this.imod(u._invmp(this.m).mul(this.r2));return h._forceRed(this)}})(typeof bl>"u"||bl,T0)});var Fe=B((BC,_l)=>{p();typeof Object.create=="function"?_l.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:_l.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}}});var Gt=B((Sl,N0)=>{p();var Qa=Nt(),Zr=Qa.Buffer;function B0(e,t){for(var r in e)t[r]=e[r]}Zr.from&&Zr.alloc&&Zr.allocUnsafe&&Zr.allocUnsafeSlow?N0.exports=Qa:(B0(Qa,Sl),Sl.Buffer=xi);function xi(e,t,r){return Zr(e,t,r)}xi.prototype=Object.create(Zr.prototype);B0(Zr,xi);xi.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Zr(e,t,r)};xi.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=Zr(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};xi.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Zr(e)};xi.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Qa.SlowBuffer(e)}});var go=B((kC,wl)=>{"use strict";p();var po=typeof Reflect=="object"?Reflect:null,M0=po&&typeof po.apply=="function"?po.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},eu;po&&typeof po.ownKeys=="function"?eu=po.ownKeys:Object.getOwnPropertySymbols?eu=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:eu=function(t){return Object.getOwnPropertyNames(t)};function qI(e){console&&console.warn&&console.warn(e)}var C0=Number.isNaN||function(t){return t!==t};function De(){De.init.call(this)}wl.exports=De;wl.exports.once=GI;De.EventEmitter=De;De.prototype._events=void 0;De.prototype._eventsCount=0;De.prototype._maxListeners=void 0;var k0=10;function tu(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(De,"defaultMaxListeners",{enumerable:!0,get:function(){return k0},set:function(e){if(typeof e!="number"||e<0||C0(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");k0=e}});De.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};De.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||C0(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function L0(e){return e._maxListeners===void 0?De.defaultMaxListeners:e._maxListeners}De.prototype.getMaxListeners=function(){return L0(this)};De.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=t==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var f=o[t];if(f===void 0)return!1;if(typeof f=="function")M0(f,this,r);else for(var l=f.length,m=j0(f,l),n=0;n<l;++n)M0(m[n],this,r);return!0};function D0(e,t,r,n){var i,o,s;if(tu(r),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),s===void 0)s=o[t]=r,++e._eventsCount;else if(typeof s=="function"?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=L0(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,qI(a)}return e}De.prototype.addListener=function(t,r){return D0(this,t,r,!1)};De.prototype.on=De.prototype.addListener;De.prototype.prependListener=function(t,r){return D0(this,t,r,!0)};function jI(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function U0(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=jI.bind(n);return i.listener=r,n.wrapFn=i,i}De.prototype.once=function(t,r){return tu(r),this.on(t,U0(this,t,r)),this};De.prototype.prependOnceListener=function(t,r){return tu(r),this.prependListener(t,U0(this,t,r)),this};De.prototype.removeListener=function(t,r){var n,i,o,s,a;if(tu(r),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():HI(n,o),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||r)}return this};De.prototype.off=De.prototype.removeListener;De.prototype.removeAllListeners=function(t){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[t],typeof r=="function")this.removeListener(t,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(t,r[i]);return this};function F0(e,t,r){var n=e._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?KI(i):j0(i,i.length)}De.prototype.listeners=function(t){return F0(this,t,!0)};De.prototype.rawListeners=function(t){return F0(this,t,!1)};De.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):q0.call(e,t)};De.prototype.listenerCount=q0;function q0(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}De.prototype.eventNames=function(){return this._eventsCount>0?eu(this._events):[]};function j0(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function HI(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function KI(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function GI(e,t){return new Promise(function(r,n){function i(s){e.removeListener(t,o),n(s)}function o(){typeof e.removeListener=="function"&&e.removeListener("error",i),r([].slice.call(arguments))}H0(e,t,o,{once:!0}),t!=="error"&&VI(e,i,{once:!0})})}function VI(e,t,r){typeof e.on=="function"&&H0(e,"error",t,r)}function H0(e,t,r,n){if(typeof e.on=="function")n.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(o){n.once&&e.removeEventListener(t,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var El=B((LC,K0)=>{p();K0.exports=go().EventEmitter});var ru=B((UC,G0)=>{"use strict";p();G0.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[r]=i;for(var o in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var s=Object.getOwnPropertySymbols(t);if(s.length!==1||s[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,r);if(a.value!==i||a.enumerable!==!0)return!1}return!0}});var ps=B((qC,V0)=>{"use strict";p();var WI=ru();V0.exports=function(){return WI()&&!!Symbol.toStringTag}});var nu=B((HC,W0)=>{"use strict";p();W0.exports=Object});var Y0=B((GC,z0)=>{"use strict";p();z0.exports=Error});var Z0=B((WC,$0)=>{"use strict";p();$0.exports=EvalError});var J0=B((YC,X0)=>{"use strict";p();X0.exports=RangeError});var eg=B((ZC,Q0)=>{"use strict";p();Q0.exports=ReferenceError});var xl=B((JC,tg)=>{"use strict";p();tg.exports=SyntaxError});var Ii=B((e8,rg)=>{"use strict";p();rg.exports=TypeError});var ig=B((r8,ng)=>{"use strict";p();ng.exports=URIError});var sg=B((i8,og)=>{"use strict";p();og.exports=Math.abs});var ug=B((s8,ag)=>{"use strict";p();ag.exports=Math.floor});var cg=B((u8,fg)=>{"use strict";p();fg.exports=Math.max});var hg=B((c8,lg)=>{"use strict";p();lg.exports=Math.min});var pg=B((h8,dg)=>{"use strict";p();dg.exports=Math.pow});var yg=B((p8,gg)=>{"use strict";p();gg.exports=Math.round});var vg=B((y8,mg)=>{"use strict";p();mg.exports=Number.isNaN||function(t){return t!==t}});var _g=B((v8,bg)=>{"use strict";p();var zI=vg();bg.exports=function(t){return zI(t)||t===0?t:t<0?-1:1}});var wg=B((_8,Sg)=>{"use strict";p();Sg.exports=Object.getOwnPropertyDescriptor});var Oi=B((w8,Eg)=>{"use strict";p();var iu=wg();if(iu)try{iu([],"length")}catch{iu=null}Eg.exports=iu});var gs=B((x8,xg)=>{"use strict";p();var ou=Object.defineProperty||!1;if(ou)try{ou({},"a",{value:1})}catch{ou=!1}xg.exports=ou});var Ag=B((O8,Og)=>{"use strict";p();var Ig=typeof Symbol<"u"&&Symbol,YI=ru();Og.exports=function(){return typeof Ig!="function"||typeof Symbol!="function"||typeof Ig("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:YI()}});var Il=B((R8,Rg)=>{"use strict";p();Rg.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var Ol=B((P8,Tg)=>{"use strict";p();var $I=nu();Tg.exports=$I.getPrototypeOf||null});var Ng=B((N8,Bg)=>{"use strict";p();var ZI="Function.prototype.bind called on incompatible ",XI=Object.prototype.toString,JI=Math.max,QI="[object Function]",Pg=function(t,r){for(var n=[],i=0;i<t.length;i+=1)n[i]=t[i];for(var o=0;o<r.length;o+=1)n[o+t.length]=r[o];return n},eO=function(t,r){for(var n=[],i=r||0,o=0;i<t.length;i+=1,o+=1)n[o]=t[i];return n},tO=function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r};Bg.exports=function(t){var r=this;if(typeof r!="function"||XI.apply(r)!==QI)throw new TypeError(ZI+r);for(var n=eO(arguments,1),i,o=function(){if(this instanceof i){var m=r.apply(this,Pg(n,arguments));return Object(m)===m?m:this}return r.apply(t,Pg(n,arguments))},s=JI(0,r.length-n.length),a=[],f=0;f<s;f++)a[f]="$"+f;if(i=Function("binder","return function ("+tO(a,",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var l=function(){};l.prototype=r.prototype,i.prototype=new l,l.prototype=null}return i}});var yo=B((k8,Mg)=>{"use strict";p();var rO=Ng();Mg.exports=Function.prototype.bind||rO});var su=B((L8,kg)=>{"use strict";p();kg.exports=Function.prototype.call});var au=B((U8,Cg)=>{"use strict";p();Cg.exports=Function.prototype.apply});var Dg=B((q8,Lg)=>{"use strict";p();Lg.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var Al=B((H8,Ug)=>{"use strict";p();var nO=yo(),iO=au(),oO=su(),sO=Dg();Ug.exports=sO||nO.call(oO,iO)});var uu=B((G8,Fg)=>{"use strict";p();var aO=yo(),uO=Ii(),fO=su(),cO=Al();Fg.exports=function(t){if(t.length<1||typeof t[0]!="function")throw new uO("a function is required");return cO(aO,fO,t)}});var Vg=B((W8,Gg)=>{"use strict";p();var lO=uu(),qg=Oi(),Hg;try{Hg=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!="object"||!("code"in e)||e.code!=="ERR_PROTO_ACCESS")throw e}var Rl=!!Hg&&qg&&qg(Object.prototype,"__proto__"),Kg=Object,jg=Kg.getPrototypeOf;Gg.exports=Rl&&typeof Rl.get=="function"?lO([Rl.get]):typeof jg=="function"?function(t){return jg(t==null?t:Kg(t))}:!1});var fu=B((Y8,$g)=>{"use strict";p();var Wg=Il(),zg=Ol(),Yg=Vg();$g.exports=Wg?function(t){return Wg(t)}:zg?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return zg(t)}:Yg?function(t){return Yg(t)}:null});var Tl=B((Z8,Zg)=>{"use strict";p();var hO=Function.prototype.call,dO=Object.prototype.hasOwnProperty,pO=yo();Zg.exports=pO.call(hO,dO)});var hu=B((J8,ry)=>{"use strict";p();var Ie,gO=nu(),yO=Y0(),mO=Z0(),vO=J0(),bO=eg(),_o=xl(),bo=Ii(),_O=ig(),SO=sg(),wO=ug(),EO=cg(),xO=hg(),IO=pg(),OO=yg(),AO=_g(),ey=Function,Pl=function(e){try{return ey('"use strict"; return ('+e+").constructor;")()}catch{}},ys=Oi(),RO=gs(),Bl=function(){throw new bo},TO=ys?(function(){try{return arguments.callee,Bl}catch{try{return ys(arguments,"callee").get}catch{return Bl}}})():Bl,mo=Ag()(),Ft=fu(),PO=Ol(),BO=Il(),ty=au(),ms=su(),vo={},NO=typeof Uint8Array>"u"||!Ft?Ie:Ft(Uint8Array),Ai={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Ie:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Ie:ArrayBuffer,"%ArrayIteratorPrototype%":mo&&Ft?Ft([][Symbol.iterator]()):Ie,"%AsyncFromSyncIteratorPrototype%":Ie,"%AsyncFunction%":vo,"%AsyncGenerator%":vo,"%AsyncGeneratorFunction%":vo,"%AsyncIteratorPrototype%":vo,"%Atomics%":typeof Atomics>"u"?Ie:Atomics,"%BigInt%":typeof BigInt>"u"?Ie:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Ie:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Ie:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Ie:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":yO,"%eval%":eval,"%EvalError%":mO,"%Float16Array%":typeof Float16Array>"u"?Ie:Float16Array,"%Float32Array%":typeof Float32Array>"u"?Ie:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Ie:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Ie:FinalizationRegistry,"%Function%":ey,"%GeneratorFunction%":vo,"%Int8Array%":typeof Int8Array>"u"?Ie:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Ie:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Ie:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":mo&&Ft?Ft(Ft([][Symbol.iterator]())):Ie,"%JSON%":typeof JSON=="object"?JSON:Ie,"%Map%":typeof Map>"u"?Ie:Map,"%MapIteratorPrototype%":typeof Map>"u"||!mo||!Ft?Ie:Ft(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":gO,"%Object.getOwnPropertyDescriptor%":ys,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Ie:Promise,"%Proxy%":typeof Proxy>"u"?Ie:Proxy,"%RangeError%":vO,"%ReferenceError%":bO,"%Reflect%":typeof Reflect>"u"?Ie:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Ie:Set,"%SetIteratorPrototype%":typeof Set>"u"||!mo||!Ft?Ie:Ft(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Ie:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":mo&&Ft?Ft(""[Symbol.iterator]()):Ie,"%Symbol%":mo?Symbol:Ie,"%SyntaxError%":_o,"%ThrowTypeError%":TO,"%TypedArray%":NO,"%TypeError%":bo,"%Uint8Array%":typeof Uint8Array>"u"?Ie:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Ie:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Ie:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Ie:Uint32Array,"%URIError%":_O,"%WeakMap%":typeof WeakMap>"u"?Ie:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Ie:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Ie:WeakSet,"%Function.prototype.call%":ms,"%Function.prototype.apply%":ty,"%Object.defineProperty%":RO,"%Object.getPrototypeOf%":PO,"%Math.abs%":SO,"%Math.floor%":wO,"%Math.max%":EO,"%Math.min%":xO,"%Math.pow%":IO,"%Math.round%":OO,"%Math.sign%":AO,"%Reflect.getPrototypeOf%":BO};if(Ft)try{null.error}catch(e){Xg=Ft(Ft(e)),Ai["%Error.prototype%"]=Xg}var Xg,MO=function e(t){var r;if(t==="%AsyncFunction%")r=Pl("async function () {}");else if(t==="%GeneratorFunction%")r=Pl("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=Pl("async function* () {}");else if(t==="%AsyncGenerator%"){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=e("%AsyncGenerator%");i&&Ft&&(r=Ft(i.prototype))}return Ai[t]=r,r},Jg={__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"]},vs=yo(),cu=Tl(),kO=vs.call(ms,Array.prototype.concat),CO=vs.call(ty,Array.prototype.splice),Qg=vs.call(ms,String.prototype.replace),lu=vs.call(ms,String.prototype.slice),LO=vs.call(ms,RegExp.prototype.exec),DO=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,UO=/\\(\\)?/g,FO=function(t){var r=lu(t,0,1),n=lu(t,-1);if(r==="%"&&n!=="%")throw new _o("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new _o("invalid intrinsic syntax, expected opening `%`");var i=[];return Qg(t,DO,function(o,s,a,f){i[i.length]=a?Qg(f,UO,"$1"):s||o}),i},qO=function(t,r){var n=t,i;if(cu(Jg,n)&&(i=Jg[n],n="%"+i[0]+"%"),cu(Ai,n)){var o=Ai[n];if(o===vo&&(o=MO(n)),typeof o>"u"&&!r)throw new bo("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:o}}throw new _o("intrinsic "+t+" does not exist!")};ry.exports=function(t,r){if(typeof t!="string"||t.length===0)throw new bo("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new bo('"allowMissing" argument must be a boolean');if(LO(/^%?[^%]*%?$/,t)===null)throw new _o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=FO(t),i=n.length>0?n[0]:"",o=qO("%"+i+"%",r),s=o.name,a=o.value,f=!1,l=o.alias;l&&(i=l[0],CO(n,kO([0,1],l)));for(var m=1,g=!0;m<n.length;m+=1){var v=n[m],E=lu(v,0,1),T=lu(v,-1);if((E==='"'||E==="'"||E==="`"||T==='"'||T==="'"||T==="`")&&E!==T)throw new _o("property names with quotes must have matching quotes");if((v==="constructor"||!g)&&(f=!0),i+="."+v,s="%"+i+"%",cu(Ai,s))a=Ai[s];else if(a!=null){if(!(v in a)){if(!r)throw new bo("base intrinsic for "+t+" exists, but the property is not available.");return}if(ys&&m+1>=n.length){var N=ys(a,v);g=!!N,g&&"get"in N&&!("originalValue"in N.get)?a=N.get:a=a[v]}else g=cu(a,v),a=a[v];g&&!f&&(Ai[s]=a)}}return a}});var Hn=B((eL,oy)=>{"use strict";p();var ny=hu(),iy=uu(),jO=iy([ny("%String.prototype.indexOf%")]);oy.exports=function(t,r){var n=ny(t,!!r);return typeof n=="function"&&jO(t,".prototype.")>-1?iy([n]):n}});var uy=B((rL,ay)=>{"use strict";p();var HO=ps()(),KO=Hn(),Nl=KO("Object.prototype.toString"),du=function(t){return HO&&t&&typeof t=="object"&&Symbol.toStringTag in t?!1:Nl(t)==="[object Arguments]"},sy=function(t){return du(t)?!0:t!==null&&typeof t=="object"&&"length"in t&&typeof t.length=="number"&&t.length>=0&&Nl(t)!=="[object Array]"&&"callee"in t&&Nl(t.callee)==="[object Function]"},GO=(function(){return du(arguments)})();du.isLegacyArguments=sy;ay.exports=GO?du:sy});var py=B((iL,dy)=>{"use strict";p();var fy=Hn(),VO=ps()(),WO=Tl(),zO=Oi(),Cl;VO?(cy=fy("RegExp.prototype.exec"),Ml={},pu=function(){throw Ml},kl={toString:pu,valueOf:pu},typeof Symbol.toPrimitive=="symbol"&&(kl[Symbol.toPrimitive]=pu),Cl=function(t){if(!t||typeof t!="object")return!1;var r=zO(t,"lastIndex"),n=r&&WO(r,"value");if(!n)return!1;try{cy(t,kl)}catch(i){return i===Ml}}):(ly=fy("Object.prototype.toString"),hy="[object RegExp]",Cl=function(t){return!t||typeof t!="object"&&typeof t!="function"?!1:ly(t)===hy});var cy,Ml,pu,kl,ly,hy;dy.exports=Cl});var yy=B((sL,gy)=>{"use strict";p();var YO=Hn(),$O=py(),ZO=YO("RegExp.prototype.exec"),XO=Ii();gy.exports=function(t){if(!$O(t))throw new XO("`regex` must be a RegExp");return function(n){return ZO(t,n)!==null}}});var vy=B((uL,my)=>{"use strict";p();var JO=function*(){}.constructor;my.exports=()=>JO});var wy=B((cL,Sy)=>{"use strict";p();var _y=Hn(),QO=yy(),eA=QO(/^\s*(?:function)?\*/),tA=ps()(),by=fu(),rA=_y("Object.prototype.toString"),nA=_y("Function.prototype.toString"),iA=vy();Sy.exports=function(t){if(typeof t!="function")return!1;if(eA(nA(t)))return!0;if(!tA){var r=rA(t);return r==="[object GeneratorFunction]"}if(!by)return!1;var n=iA();return n&&by(t)===n.prototype}});var Oy=B((hL,Iy)=>{"use strict";p();var xy=Function.prototype.toString,So=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Dl,gu;if(typeof So=="function"&&typeof Object.defineProperty=="function")try{Dl=Object.defineProperty({},"length",{get:function(){throw gu}}),gu={},So(function(){throw 42},null,Dl)}catch(e){e!==gu&&(So=null)}else So=null;var oA=/^\s*class\b/,Ul=function(t){try{var r=xy.call(t);return oA.test(r)}catch{return!1}},Ll=function(t){try{return Ul(t)?!1:(xy.call(t),!0)}catch{return!1}},yu=Object.prototype.toString,sA="[object Object]",aA="[object Function]",uA="[object GeneratorFunction]",fA="[object HTMLAllCollection]",cA="[object HTML document.all class]",lA="[object HTMLCollection]",hA=typeof Symbol=="function"&&!!Symbol.toStringTag,dA=!(0 in[,]),Fl=function(){return!1};typeof document=="object"&&(Ey=document.all,yu.call(Ey)===yu.call(document.all)&&(Fl=function(t){if((dA||!t)&&(typeof t>"u"||typeof t=="object"))try{var r=yu.call(t);return(r===fA||r===cA||r===lA||r===sA)&&t("")==null}catch{}return!1}));var Ey;Iy.exports=So?function(t){if(Fl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{So(t,null,Dl)}catch(r){if(r!==gu)return!1}return!Ul(t)&&Ll(t)}:function(t){if(Fl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(hA)return Ll(t);if(Ul(t))return!1;var r=yu.call(t);return r!==aA&&r!==uA&&!/^\[object HTML/.test(r)?!1:Ll(t)}});var Ty=B((pL,Ry)=>{"use strict";p();var pA=Oy(),gA=Object.prototype.toString,Ay=Object.prototype.hasOwnProperty,yA=function(t,r,n){for(var i=0,o=t.length;i<o;i++)Ay.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))},mA=function(t,r,n){for(var i=0,o=t.length;i<o;i++)n==null?r(t.charAt(i),i,t):r.call(n,t.charAt(i),i,t)},vA=function(t,r,n){for(var i in t)Ay.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))};function bA(e){return gA.call(e)==="[object Array]"}Ry.exports=function(t,r,n){if(!pA(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),bA(t)?yA(t,r,i):typeof t=="string"?mA(t,r,i):vA(t,r,i)}});var By=B((yL,Py)=>{"use strict";p();Py.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]});var My=B((vL,Ny)=>{"use strict";p();var ql=By(),_A=globalThis;Ny.exports=function(){for(var t=[],r=0;r<ql.length;r++)typeof _A[ql[r]]=="function"&&(t[t.length]=ql[r]);return t}});var jl=B((_L,Ly)=>{"use strict";p();var ky=gs(),SA=xl(),wo=Ii(),Cy=Oi();Ly.exports=function(t,r,n){if(!t||typeof t!="object"&&typeof t!="function")throw new wo("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new wo("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new wo("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new wo("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new wo("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new wo("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,s=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,f=!!Cy&&Cy(t,r);if(ky)ky(t,r,{configurable:s===null&&f?f.configurable:!s,enumerable:i===null&&f?f.enumerable:!i,value:n,writable:o===null&&f?f.writable:!o});else if(a||!i&&!o&&!s)t[r]=n;else throw new SA("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var Kl=B((wL,Uy)=>{"use strict";p();var Hl=gs(),Dy=function(){return!!Hl};Dy.hasArrayLengthDefineBug=function(){if(!Hl)return null;try{return Hl([],"length",{value:1}).length!==1}catch{return!0}};Uy.exports=Dy});var Ky=B((xL,Hy)=>{"use strict";p();var wA=hu(),Fy=jl(),EA=Kl()(),qy=Oi(),jy=Ii(),xA=wA("%Math.floor%");Hy.exports=function(t,r){if(typeof t!="function")throw new jy("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||xA(r)!==r)throw new jy("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in t&&qy){var s=qy(t,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(EA?Fy(t,"length",r,!0,!0):Fy(t,"length",r)),t}});var Vy=B((OL,Gy)=>{"use strict";p();var IA=yo(),OA=au(),AA=Al();Gy.exports=function(){return AA(IA,OA,arguments)}});var bs=B((RL,mu)=>{"use strict";p();var RA=Ky(),Wy=gs(),TA=uu(),zy=Vy();mu.exports=function(t){var r=TA(arguments),n=1+t.length-(arguments.length-1);return RA(r,n>0?n:0,!0)};Wy?Wy(mu.exports,"apply",{value:zy}):mu.exports.apply=zy});var zl=B((PL,Xy)=>{"use strict";p();var _u=Ty(),PA=My(),Yy=bs(),Vl=Hn(),bu=Oi(),vu=fu(),BA=Vl("Object.prototype.toString"),Zy=ps()(),$y=globalThis,Gl=PA(),Wl=Vl("String.prototype.slice"),NA=Vl("Array.prototype.indexOf",!0)||function(t,r){for(var n=0;n<t.length;n+=1)if(t[n]===r)return n;return-1},Su={__proto__:null};Zy&&bu&&vu?_u(Gl,function(e){var t=new $y[e];if(Symbol.toStringTag in t&&vu){var r=vu(t),n=bu(r,Symbol.toStringTag);if(!n&&r){var i=vu(r);n=bu(i,Symbol.toStringTag)}if(n&&n.get){var o=Yy(n.get);Su["$"+e]=o}}}):_u(Gl,function(e){var t=new $y[e],r=t.slice||t.set;if(r){var n=Yy(r);Su["$"+e]=n}});var MA=function(t){var r=!1;return _u(Su,function(n,i){if(!r)try{"$"+n(t)===i&&(r=Wl(i,1))}catch{}}),r},kA=function(t){var r=!1;return _u(Su,function(n,i){if(!r)try{n(t),r=Wl(i,1)}catch{}}),r};Xy.exports=function(t){if(!t||typeof t!="object")return!1;if(!Zy){var r=Wl(BA(t),8,-1);return NA(Gl,r)>-1?r:r!=="Object"?!1:kA(t)}return bu?MA(t):null}});var Yl=B((NL,Jy)=>{"use strict";p();var CA=zl();Jy.exports=function(t){return!!CA(t)}});var hm=B(Oe=>{"use strict";p();var LA=uy(),DA=wy(),Tr=zl(),Qy=Yl();function Eo(e){return e.call.bind(e)}var em=typeof BigInt<"u",tm=typeof Symbol<"u",br=Eo(Object.prototype.toString),UA=Eo(Number.prototype.valueOf),FA=Eo(String.prototype.valueOf),qA=Eo(Boolean.prototype.valueOf);em&&(rm=Eo(BigInt.prototype.valueOf));var rm;tm&&(nm=Eo(Symbol.prototype.valueOf));var nm;function Ss(e,t){if(typeof e!="object")return!1;try{return t(e),!0}catch{return!1}}Oe.isArgumentsObject=LA;Oe.isGeneratorFunction=DA;Oe.isTypedArray=Qy;function jA(e){return typeof Promise<"u"&&e instanceof Promise||e!==null&&typeof e=="object"&&typeof e.then=="function"&&typeof e.catch=="function"}Oe.isPromise=jA;function HA(e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(e):Qy(e)||om(e)}Oe.isArrayBufferView=HA;function KA(e){return Tr(e)==="Uint8Array"}Oe.isUint8Array=KA;function GA(e){return Tr(e)==="Uint8ClampedArray"}Oe.isUint8ClampedArray=GA;function VA(e){return Tr(e)==="Uint16Array"}Oe.isUint16Array=VA;function WA(e){return Tr(e)==="Uint32Array"}Oe.isUint32Array=WA;function zA(e){return Tr(e)==="Int8Array"}Oe.isInt8Array=zA;function YA(e){return Tr(e)==="Int16Array"}Oe.isInt16Array=YA;function $A(e){return Tr(e)==="Int32Array"}Oe.isInt32Array=$A;function ZA(e){return Tr(e)==="Float32Array"}Oe.isFloat32Array=ZA;function XA(e){return Tr(e)==="Float64Array"}Oe.isFloat64Array=XA;function JA(e){return Tr(e)==="BigInt64Array"}Oe.isBigInt64Array=JA;function QA(e){return Tr(e)==="BigUint64Array"}Oe.isBigUint64Array=QA;function wu(e){return br(e)==="[object Map]"}wu.working=typeof Map<"u"&&wu(new Map);function eR(e){return typeof Map>"u"?!1:wu.working?wu(e):e instanceof Map}Oe.isMap=eR;function Eu(e){return br(e)==="[object Set]"}Eu.working=typeof Set<"u"&&Eu(new Set);function tR(e){return typeof Set>"u"?!1:Eu.working?Eu(e):e instanceof Set}Oe.isSet=tR;function xu(e){return br(e)==="[object WeakMap]"}xu.working=typeof WeakMap<"u"&&xu(new WeakMap);function rR(e){return typeof WeakMap>"u"?!1:xu.working?xu(e):e instanceof WeakMap}Oe.isWeakMap=rR;function Zl(e){return br(e)==="[object WeakSet]"}Zl.working=typeof WeakSet<"u"&&Zl(new WeakSet);function nR(e){return Zl(e)}Oe.isWeakSet=nR;function Iu(e){return br(e)==="[object ArrayBuffer]"}Iu.working=typeof ArrayBuffer<"u"&&Iu(new ArrayBuffer);function im(e){return typeof ArrayBuffer>"u"?!1:Iu.working?Iu(e):e instanceof ArrayBuffer}Oe.isArrayBuffer=im;function Ou(e){return br(e)==="[object DataView]"}Ou.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&Ou(new DataView(new ArrayBuffer(1),0,1));function om(e){return typeof DataView>"u"?!1:Ou.working?Ou(e):e instanceof DataView}Oe.isDataView=om;var $l=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function _s(e){return br(e)==="[object SharedArrayBuffer]"}function sm(e){return typeof $l>"u"?!1:(typeof _s.working>"u"&&(_s.working=_s(new $l)),_s.working?_s(e):e instanceof $l)}Oe.isSharedArrayBuffer=sm;function iR(e){return br(e)==="[object AsyncFunction]"}Oe.isAsyncFunction=iR;function oR(e){return br(e)==="[object Map Iterator]"}Oe.isMapIterator=oR;function sR(e){return br(e)==="[object Set Iterator]"}Oe.isSetIterator=sR;function aR(e){return br(e)==="[object Generator]"}Oe.isGeneratorObject=aR;function uR(e){return br(e)==="[object WebAssembly.Module]"}Oe.isWebAssemblyCompiledModule=uR;function am(e){return Ss(e,UA)}Oe.isNumberObject=am;function um(e){return Ss(e,FA)}Oe.isStringObject=um;function fm(e){return Ss(e,qA)}Oe.isBooleanObject=fm;function cm(e){return em&&Ss(e,rm)}Oe.isBigIntObject=cm;function lm(e){return tm&&Ss(e,nm)}Oe.isSymbolObject=lm;function fR(e){return am(e)||um(e)||fm(e)||cm(e)||lm(e)}Oe.isBoxedPrimitive=fR;function cR(e){return typeof Uint8Array<"u"&&(im(e)||sm(e))}Oe.isAnyArrayBuffer=cR;["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(e){Object.defineProperty(Oe,e,{enumerable:!1,value:function(){throw new Error(e+" is not supported in userland")}})})});var pm=B((LL,dm)=>{p();dm.exports=function(t){return t&&typeof t=="object"&&typeof t.copy=="function"&&typeof t.fill=="function"&&typeof t.readUInt8=="function"}});var Xr=B(Ae=>{p();var gm=Object.getOwnPropertyDescriptors||function(t){for(var r=Object.keys(t),n={},i=0;i<r.length;i++)n[r[i]]=Object.getOwnPropertyDescriptor(t,r[i]);return n},lR=/%[sdj%]/g;Ae.format=function(e){if(!Mu(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(Kn(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,i=n.length,o=String(e).replace(lR,function(a){if(a==="%%")return"%";if(r>=i)return a;switch(a){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch{return"[Circular]"}default:return a}}),s=n[r];r<i;s=n[++r])Nu(s)||!xo(s)?o+=" "+s:o+=" "+Kn(s);return o};Ae.deprecate=function(e,t){if(typeof x.default<"u"&&x.default.noDeprecation===!0)return e;if(typeof x.default>"u")return function(){return Ae.deprecate(e,t).apply(this,arguments)};var r=!1;function n(){if(!r){if(x.default.throwDeprecation)throw new Error(t);x.default.traceDeprecation?console.trace(t):console.error(t),r=!0}return e.apply(this,arguments)}return n};var Au={},ym=/^$/;x.default.env.NODE_DEBUG&&(Ru=x.default.env.NODE_DEBUG,Ru=Ru.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),ym=new RegExp("^"+Ru+"$","i"));var Ru;Ae.debuglog=function(e){if(e=e.toUpperCase(),!Au[e])if(ym.test(e)){var t=x.default.pid;Au[e]=function(){var r=Ae.format.apply(Ae,arguments);console.error("%s %d: %s",e,t,r)}}else Au[e]=function(){};return Au[e]};function Kn(e,t){var r={seen:[],stylize:dR};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),eh(t)?r.showHidden=t:t&&Ae._extend(r,t),Ti(r.showHidden)&&(r.showHidden=!1),Ti(r.depth)&&(r.depth=2),Ti(r.colors)&&(r.colors=!1),Ti(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=hR),Pu(r,e,r.depth)}Ae.inspect=Kn;Kn.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]};Kn.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function hR(e,t){var r=Kn.styles[t];return r?"\x1B["+Kn.colors[r][0]+"m"+e+"\x1B["+Kn.colors[r][1]+"m":e}function dR(e,t){return e}function pR(e){var t={};return e.forEach(function(r,n){t[r]=!0}),t}function Pu(e,t,r){if(e.customInspect&&t&&Tu(t.inspect)&&t.inspect!==Ae.inspect&&!(t.constructor&&t.constructor.prototype===t)){var n=t.inspect(r,e);return Mu(n)||(n=Pu(e,n,r)),n}var i=gR(e,t);if(i)return i;var o=Object.keys(t),s=pR(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),Es(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return Xl(t);if(o.length===0){if(Tu(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ws(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(Bu(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Es(t))return Xl(t)}var f="",l=!1,m=["{","}"];if(mm(t)&&(l=!0,m=["[","]"]),Tu(t)){var g=t.name?": "+t.name:"";f=" [Function"+g+"]"}if(ws(t)&&(f=" "+RegExp.prototype.toString.call(t)),Bu(t)&&(f=" "+Date.prototype.toUTCString.call(t)),Es(t)&&(f=" "+Xl(t)),o.length===0&&(!l||t.length==0))return m[0]+f+m[1];if(r<0)return ws(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var v;return l?v=yR(e,t,r,s,o):v=o.map(function(E){return Ql(e,t,r,s,E,l)}),e.seen.pop(),mR(v,f,m)}function gR(e,t){if(Ti(t))return e.stylize("undefined","undefined");if(Mu(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(vm(t))return e.stylize(""+t,"number");if(eh(t))return e.stylize(""+t,"boolean");if(Nu(t))return e.stylize("null","null")}function Xl(e){return"["+Error.prototype.toString.call(e)+"]"}function yR(e,t,r,n,i){for(var o=[],s=0,a=t.length;s<a;++s)bm(t,String(s))?o.push(Ql(e,t,r,n,String(s),!0)):o.push("");return i.forEach(function(f){f.match(/^\d+$/)||o.push(Ql(e,t,r,n,f,!0))}),o}function Ql(e,t,r,n,i,o){var s,a,f;if(f=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},f.get?f.set?a=e.stylize("[Getter/Setter]","special"):a=e.stylize("[Getter]","special"):f.set&&(a=e.stylize("[Setter]","special")),bm(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(f.value)<0?(Nu(r)?a=Pu(e,f.value,null):a=Pu(e,f.value,r-1),a.indexOf(`
2
2
  `)>-1&&(o?a=a.split(`
3
3
  `).map(function(l){return" "+l}).join(`
4
4
  `).slice(2):a=`
5
5
  `+a.split(`
6
6
  `).map(function(l){return" "+l}).join(`
7
- `))):a=e.stylize("[Circular]","special")),Ti(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.slice(1,-1),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function yR(e,t,r){var n=0,i=e.reduce(function(o,s){return n++,s.indexOf(`
7
+ `))):a=e.stylize("[Circular]","special")),Ti(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.slice(1,-1),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function mR(e,t,r){var n=0,i=e.reduce(function(o,s){return n++,s.indexOf(`
8
8
  `)>=0&&n++,o+s.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(t===""?"":t+`
9
9
  `)+" "+e.join(`,
10
- `)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}Oe.types=lm();function ym(e){return Array.isArray(e)}Oe.isArray=ym;function eh(e){return typeof e=="boolean"}Oe.isBoolean=eh;function Nu(e){return e===null}Oe.isNull=Nu;function mR(e){return e==null}Oe.isNullOrUndefined=mR;function mm(e){return typeof e=="number"}Oe.isNumber=mm;function Mu(e){return typeof e=="string"}Oe.isString=Mu;function vR(e){return typeof e=="symbol"}Oe.isSymbol=vR;function Ti(e){return e===void 0}Oe.isUndefined=Ti;function Ss(e){return xo(e)&&th(e)==="[object RegExp]"}Oe.isRegExp=Ss;Oe.types.isRegExp=Ss;function xo(e){return typeof e=="object"&&e!==null}Oe.isObject=xo;function Bu(e){return xo(e)&&th(e)==="[object Date]"}Oe.isDate=Bu;Oe.types.isDate=Bu;function Es(e){return xo(e)&&(th(e)==="[object Error]"||e instanceof Error)}Oe.isError=Es;Oe.types.isNativeError=Es;function Tu(e){return typeof e=="function"}Oe.isFunction=Tu;function bR(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}Oe.isPrimitive=bR;Oe.isBuffer=dm();function th(e){return Object.prototype.toString.call(e)}function Jl(e){return e<10?"0"+e.toString(10):e.toString(10)}var _R=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function wR(){var e=new Date,t=[Jl(e.getHours()),Jl(e.getMinutes()),Jl(e.getSeconds())].join(":");return[e.getDate(),_R[e.getMonth()],t].join(" ")}Oe.log=function(){console.log("%s - %s",wR(),Oe.format.apply(Oe,arguments))};Oe.inherits=Fe();Oe._extend=function(e,t){if(!t||!xo(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};function vm(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Ri=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;Oe.promisify=function(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');if(Ri&&t[Ri]){var r=t[Ri];if(typeof r!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(r,Ri,{value:r,enumerable:!1,writable:!1,configurable:!0}),r}function r(){for(var n,i,o=new Promise(function(f,l){n=f,i=l}),s=[],a=0;a<arguments.length;a++)s.push(arguments[a]);s.push(function(f,l){f?i(f):n(l)});try{t.apply(this,s)}catch(f){i(f)}return o}return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),Ri&&Object.defineProperty(r,Ri,{value:r,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(r,pm(t))};Oe.promisify.custom=Ri;function SR(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}function ER(e){if(typeof e!="function")throw new TypeError('The "original" argument must be of type Function');function t(){for(var r=[],n=0;n<arguments.length;n++)r.push(arguments[n]);var i=r.pop();if(typeof i!="function")throw new TypeError("The last argument must be of type Function");var o=this,s=function(){return i.apply(o,arguments)};e.apply(this,r).then(function(a){I.default.nextTick(s.bind(null,null,a))},function(a){I.default.nextTick(SR.bind(null,a,s))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,pm(e)),t}Oe.callbackify=ER});var xm=P((FL,Em)=>{"use strict";p();function bm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function _m(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?bm(Object(r),!0).forEach(function(n){xR(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):bm(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function xR(e,t,r){return t=Sm(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function IR(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wm(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Sm(n.key),n)}}function AR(e,t,r){return t&&wm(e.prototype,t),r&&wm(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Sm(e){var t=OR(e,"string");return typeof t=="symbol"?t:String(t)}function OR(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var RR=Nt(),ku=RR.Buffer,TR=Xr(),rh=TR.inspect,PR=rh&&rh.custom||"inspect";function BR(e,t,r){ku.prototype.copy.call(e,t,r)}Em.exports=(function(){function e(){IR(this,e),this.head=null,this.tail=null,this.length=0}return AR(e,[{key:"push",value:function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length}},{key:"unshift",value:function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i}},{key:"concat",value:function(r){if(this.length===0)return ku.alloc(0);for(var n=ku.allocUnsafe(r>>>0),i=this.head,o=0;i;)BR(i.data,n,o),o+=i.data.length,i=i.next;return n}},{key:"consume",value:function(r,n){var i;return r<this.head.data.length?(i=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?i=this.shift():i=n?this._getString(r):this._getBuffer(r),i}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(r){var n=this.head,i=1,o=n.data;for(r-=o.length;n=n.next;){var s=n.data,a=r>s.length?s.length:r;if(a===s.length?o+=s:o+=s.slice(0,r),r-=a,r===0){a===s.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=s.slice(a));break}++i}return this.length-=i,o}},{key:"_getBuffer",value:function(r){var n=ku.allocUnsafe(r),i=this.head,o=1;for(i.data.copy(n),r-=i.data.length;i=i.next;){var s=i.data,a=r>s.length?s.length:r;if(s.copy(n,n.length-r,0,a),r-=a,r===0){a===s.length?(++o,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=s.slice(a));break}++o}return this.length-=o,n}},{key:PR,value:function(r,n){return rh(this,_m(_m({},n),{},{depth:0,customInspect:!1}))}}]),e})()});var ih=P((jL,Am)=>{"use strict";p();function NR(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,I.default.nextTick(nh,this,e)):I.default.nextTick(nh,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted?I.default.nextTick(Cu,r):(r._writableState.errorEmitted=!0,I.default.nextTick(Im,r,o)):I.default.nextTick(Im,r,o):t?(I.default.nextTick(Cu,r),t(o)):I.default.nextTick(Cu,r)}),this)}function Im(e,t){nh(e,t),Cu(e)}function Cu(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function MR(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function nh(e,t){e.emit("error",t)}function kR(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}Am.exports={destroy:NR,undestroy:MR,errorOrDestroy:kR}});var Pi=P((KL,Tm)=>{"use strict";p();function CR(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Rm={};function _r(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){CR(s,o);function s(a,f,l){return o.call(this,n(a,f,l))||this}return s})(r);i.prototype.name=r.name,i.prototype.code=e,Rm[e]=i}function Om(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function LR(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function DR(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function UR(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}_r("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);_r("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&LR(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(DR(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Om(t,"type"));else{var o=UR(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(Om(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);_r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");_r("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});_r("ERR_STREAM_PREMATURE_CLOSE","Premature close");_r("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" 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(e){return"Unknown encoding: "+e},TypeError);_r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Tm.exports.codes=Rm});var oh=P((VL,Pm)=>{"use strict";p();var FR=Pi().codes.ERR_INVALID_OPT_VALUE;function qR(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function jR(e,t,r,n){var i=qR(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new FR(o,i)}return Math.floor(i)}return e.objectMode?16:16*1024}Pm.exports={getHighWaterMark:jR}});var ah=P((zL,Bm)=>{p();Bm.exports=HR;function HR(e,t){if(sh("noDeprecation"))return e;var r=!1;function n(){if(!r){if(sh("throwDeprecation"))throw new Error(t);sh("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function sh(e){try{if(!globalThis.localStorage)return!1}catch{return!1}var t=globalThis.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}});var ch=P(($L,Dm)=>{"use strict";p();Dm.exports=Qe;function Mm(e){var t=this;this.next=null,this.entry=null,this.finish=function(){gT(t,e)}}var Io;Qe.WritableState=Is;var KR={deprecate:ah()},km=El(),Du=Nt().Buffer,GR=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function VR(e){return Du.from(e)}function WR(e){return Du.isBuffer(e)||e instanceof GR}var fh=ih(),zR=oh(),YR=zR.getHighWaterMark,Gn=Pi().codes,$R=Gn.ERR_INVALID_ARG_TYPE,ZR=Gn.ERR_METHOD_NOT_IMPLEMENTED,XR=Gn.ERR_MULTIPLE_CALLBACK,JR=Gn.ERR_STREAM_CANNOT_PIPE,QR=Gn.ERR_STREAM_DESTROYED,eT=Gn.ERR_STREAM_NULL_VALUES,tT=Gn.ERR_STREAM_WRITE_AFTER_END,rT=Gn.ERR_UNKNOWN_ENCODING,Ao=fh.errorOrDestroy;Fe()(Qe,km);function nT(){}function Is(e,t,r){Io=Io||Bi(),e=e||{},typeof r!="boolean"&&(r=t instanceof Io),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=YR(this,e,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=e.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){cT(t,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new Mm(this)}Is.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Is.prototype,"buffer",{get:KR.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var Lu;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Lu=Function.prototype[Symbol.hasInstance],Object.defineProperty(Qe,Symbol.hasInstance,{value:function(t){return Lu.call(this,t)?!0:this!==Qe?!1:t&&t._writableState instanceof Is}})):Lu=function(t){return t instanceof this};function Qe(e){Io=Io||Bi();var t=this instanceof Io;if(!t&&!Lu.call(Qe,this))return new Qe(e);this._writableState=new Is(e,this,t),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),km.call(this)}Qe.prototype.pipe=function(){Ao(this,new JR)};function iT(e,t){var r=new tT;Ao(e,r),I.default.nextTick(t,r)}function oT(e,t,r,n){var i;return r===null?i=new eT:typeof r!="string"&&!t.objectMode&&(i=new $R("chunk",["string","Buffer"],r)),i?(Ao(e,i),I.default.nextTick(n,i),!1):!0}Qe.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&WR(e);return o&&!Du.isBuffer(e)&&(e=VR(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=nT),n.ending?iT(this,r):(o||oT(this,n,e,r))&&(n.pendingcb++,i=aT(this,n,o,e,t,r)),i};Qe.prototype.cork=function(){this._writableState.corked++};Qe.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&Cm(this,e))};Qe.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new rT(t);return this._writableState.defaultEncoding=t,this};Object.defineProperty(Qe.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function sT(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=Du.from(t,r)),t}Object.defineProperty(Qe.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function aT(e,t,r,n,i,o){if(!r){var s=sT(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var f=t.length<t.highWaterMark;if(f||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else uh(e,t,!1,a,n,i,o);return f}function uh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new QR("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function uT(e,t,r,n,i){--t.pendingcb,r?(I.default.nextTick(i,n),I.default.nextTick(xs,e,t),e._writableState.errorEmitted=!0,Ao(e,n)):(i(n),e._writableState.errorEmitted=!0,Ao(e,n),xs(e,t))}function fT(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function cT(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new XR;if(fT(r),t)uT(e,r,n,t,i);else{var o=Lm(r)||e.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Cm(e,r),n?I.default.nextTick(Nm,e,r,o,i):Nm(e,r,o,i)}}function Nm(e,t,r,n){r||lT(e,t),t.pendingcb--,n(),xs(e,t)}function lT(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Cm(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,uh(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Mm(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,m=r.callback,g=t.objectMode?1:f.length;if(uh(e,t,!1,g,f,l,m),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Qe.prototype._write=function(e,t,r){r(new ZR("_write()"))};Qe.prototype._writev=null;Qe.prototype.end=function(e,t,r){var n=this._writableState;return typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||pT(this,n,r),this};Object.defineProperty(Qe.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Lm(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function hT(e,t){e._final(function(r){t.pendingcb--,r&&Ao(e,r),t.prefinished=!0,e.emit("prefinish"),xs(e,t)})}function dT(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,I.default.nextTick(hT,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function xs(e,t){var r=Lm(t);if(r&&(dT(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return r}function pT(e,t,r){t.ending=!0,xs(e,t),r&&(t.finished?I.default.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function gT(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(Qe.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}});Qe.prototype.destroy=fh.destroy;Qe.prototype._undestroy=fh.undestroy;Qe.prototype._destroy=function(e,t){t(e)}});var Bi=P((XL,Fm)=>{"use strict";p();var yT=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Fm.exports=Jr;var Um=dh(),hh=ch();Fe()(Jr,Um);for(lh=yT(hh.prototype),Uu=0;Uu<lh.length;Uu++)Fu=lh[Uu],Jr.prototype[Fu]||(Jr.prototype[Fu]=hh.prototype[Fu]);var lh,Fu,Uu;function Jr(e){if(!(this instanceof Jr))return new Jr(e);Um.call(this,e),hh.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",mT)))}Object.defineProperty(Jr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(Jr.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(Jr.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function mT(){this._writableState.ended||I.default.nextTick(vT,this)}function vT(e){e.end()}Object.defineProperty(Jr.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(t){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=t,this._writableState.destroyed=t)}})});var Hm=P((ph,jm)=>{p();var qu=Nt(),mn=qu.Buffer;function qm(e,t){for(var r in e)t[r]=e[r]}mn.from&&mn.alloc&&mn.allocUnsafe&&mn.allocUnsafeSlow?jm.exports=qu:(qm(qu,ph),ph.Buffer=Oo);function Oo(e,t,r){return mn(e,t,r)}qm(mn,Oo);Oo.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return mn(e,t,r)};Oo.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=mn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Oo.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return mn(e)};Oo.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return qu.SlowBuffer(e)}});var Ro=P(Gm=>{"use strict";p();var yh=Hm().Buffer,Km=yh.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function bT(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function _T(e){var t=bT(e);if(typeof t!="string"&&(yh.isEncoding===Km||!Km(e)))throw new Error("Unknown encoding: "+e);return t||e}Gm.StringDecoder=As;function As(e){this.encoding=_T(e);var t;switch(this.encoding){case"utf16le":this.text=AT,this.end=OT,t=4;break;case"utf8":this.fillLast=ET,t=4;break;case"base64":this.text=RT,this.end=TT,t=3;break;default:this.write=PT,this.end=BT;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=yh.allocUnsafe(t)}As.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};As.prototype.end=IT;As.prototype.text=xT;As.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function gh(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function wT(e,t,r){var n=t.length-1;if(n<r)return 0;var i=gh(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=gh(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=gh(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function ST(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function ET(e){var t=this.lastTotal-this.lastNeed,r=ST(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function xT(e,t){var r=wT(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function IT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function AT(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function OT(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function RT(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function TT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function PT(e){return e.toString(this.encoding)}function BT(e){return e&&e.length?this.write(e):""}});var ju=P((r4,zm)=>{"use strict";p();var Vm=Pi().codes.ERR_STREAM_PREMATURE_CLOSE;function NT(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e.apply(this,n)}}}function MT(){}function kT(e){return e.setHeader&&typeof e.abort=="function"}function Wm(e,t,r){if(typeof t=="function")return Wm(e,null,t);t||(t={}),r=NT(r||MT);var n=t.readable||t.readable!==!1&&e.readable,i=t.writable||t.writable!==!1&&e.writable,o=function(){e.writable||a()},s=e._writableState&&e._writableState.finished,a=function(){i=!1,s=!0,n||r.call(e)},f=e._readableState&&e._readableState.endEmitted,l=function(){n=!1,f=!0,i||r.call(e)},m=function(T){r.call(e,T)},g=function(){var T;if(n&&!f)return(!e._readableState||!e._readableState.ended)&&(T=new Vm),r.call(e,T);if(i&&!s)return(!e._writableState||!e._writableState.ended)&&(T=new Vm),r.call(e,T)},v=function(){e.req.on("finish",a)};return kT(e)?(e.on("complete",a),e.on("abort",g),e.req?v():e.on("request",v)):i&&!e._writableState&&(e.on("end",o),e.on("close",o)),e.on("end",l),e.on("finish",a),t.error!==!1&&e.on("error",m),e.on("close",g),function(){e.removeListener("complete",a),e.removeListener("abort",g),e.removeListener("request",v),e.req&&e.req.removeListener("finish",a),e.removeListener("end",o),e.removeListener("close",o),e.removeListener("finish",a),e.removeListener("end",l),e.removeListener("error",m),e.removeListener("close",g)}}zm.exports=Wm});var $m=P((i4,Ym)=>{"use strict";p();var Hu;function Vn(e,t,r){return t=CT(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function CT(e){var t=LT(e,"string");return typeof t=="symbol"?t:String(t)}function LT(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var DT=ju(),Wn=Symbol("lastResolve"),Ni=Symbol("lastReject"),Os=Symbol("error"),Ku=Symbol("ended"),Mi=Symbol("lastPromise"),mh=Symbol("handlePromise"),ki=Symbol("stream");function zn(e,t){return{value:e,done:t}}function UT(e){var t=e[Wn];if(t!==null){var r=e[ki].read();r!==null&&(e[Mi]=null,e[Wn]=null,e[Ni]=null,t(zn(r,!1)))}}function FT(e){I.default.nextTick(UT,e)}function qT(e,t){return function(r,n){e.then(function(){if(t[Ku]){r(zn(void 0,!0));return}t[mh](r,n)},n)}}var jT=Object.getPrototypeOf(function(){}),HT=Object.setPrototypeOf((Hu={get stream(){return this[ki]},next:function(){var t=this,r=this[Os];if(r!==null)return Promise.reject(r);if(this[Ku])return Promise.resolve(zn(void 0,!0));if(this[ki].destroyed)return new Promise(function(s,a){I.default.nextTick(function(){t[Os]?a(t[Os]):s(zn(void 0,!0))})});var n=this[Mi],i;if(n)i=new Promise(qT(n,this));else{var o=this[ki].read();if(o!==null)return Promise.resolve(zn(o,!1));i=new Promise(this[mh])}return this[Mi]=i,i}},Vn(Hu,Symbol.asyncIterator,function(){return this}),Vn(Hu,"return",function(){var t=this;return new Promise(function(r,n){t[ki].destroy(null,function(i){if(i){n(i);return}r(zn(void 0,!0))})})}),Hu),jT),KT=function(t){var r,n=Object.create(HT,(r={},Vn(r,ki,{value:t,writable:!0}),Vn(r,Wn,{value:null,writable:!0}),Vn(r,Ni,{value:null,writable:!0}),Vn(r,Os,{value:null,writable:!0}),Vn(r,Ku,{value:t._readableState.endEmitted,writable:!0}),Vn(r,mh,{value:function(o,s){var a=n[ki].read();a?(n[Mi]=null,n[Wn]=null,n[Ni]=null,o(zn(a,!1))):(n[Wn]=o,n[Ni]=s)},writable:!0}),r));return n[Mi]=null,DT(t,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[Ni];o!==null&&(n[Mi]=null,n[Wn]=null,n[Ni]=null,o(i)),n[Os]=i;return}var s=n[Wn];s!==null&&(n[Mi]=null,n[Wn]=null,n[Ni]=null,s(zn(void 0,!0))),n[Ku]=!0}),t.on("readable",FT.bind(null,n)),n};Ym.exports=KT});var Xm=P((s4,Zm)=>{p();Zm.exports=function(){throw new Error("Readable.from is not available in the browser")}});var dh=P((f4,av)=>{"use strict";p();av.exports=Be;var To;Be.ReadableState=tv;var u4=go().EventEmitter,ev=function(t,r){return t.listeners(r).length},Ts=El(),Gu=Nt().Buffer,GT=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function VT(e){return Gu.from(e)}function WT(e){return Gu.isBuffer(e)||e instanceof GT}var vh=Xr(),Ee;vh&&vh.debuglog?Ee=vh.debuglog("stream"):Ee=function(){};var zT=xm(),Ih=ih(),YT=oh(),$T=YT.getHighWaterMark,Vu=Pi().codes,ZT=Vu.ERR_INVALID_ARG_TYPE,XT=Vu.ERR_STREAM_PUSH_AFTER_EOF,JT=Vu.ERR_METHOD_NOT_IMPLEMENTED,QT=Vu.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,Po,bh,_h;Fe()(Be,Ts);var Rs=Ih.errorOrDestroy,wh=["error","close","destroy","pause","resume"];function e2(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function tv(e,t,r){To=To||Bi(),e=e||{},typeof r!="boolean"&&(r=t instanceof To),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=$T(this,e,"readableHighWaterMark",r),this.buffer=new zT,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Po||(Po=Ro().StringDecoder),this.decoder=new Po(e.encoding),this.encoding=e.encoding)}function Be(e){if(To=To||Bi(),!(this instanceof Be))return new Be(e);var t=this instanceof To;this._readableState=new tv(e,this,t),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Ts.call(this)}Object.defineProperty(Be.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});Be.prototype.destroy=Ih.destroy;Be.prototype._undestroy=Ih.undestroy;Be.prototype._destroy=function(e,t){t(e)};Be.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Gu.from(e,t),t=""),n=!0),rv(this,e,t,!1,n)};Be.prototype.unshift=function(e){return rv(this,e,null,!0,!1)};function rv(e,t,r,n,i){Ee("readableAddChunk",t);var o=e._readableState;if(t===null)o.reading=!1,n2(e,o);else{var s;if(i||(s=t2(o,t)),s)Rs(e,s);else if(o.objectMode||t&&t.length>0)if(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Gu.prototype&&(t=VT(t)),n)o.endEmitted?Rs(e,new QT):Sh(e,o,t,!0);else if(o.ended)Rs(e,new XT);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Sh(e,o,t,!1):xh(e,o)):Sh(e,o,t,!1)}else n||(o.reading=!1,xh(e,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function Sh(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Wu(e)),xh(e,t)}function t2(e,t){var r;return!WT(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new ZT("chunk",["string","Buffer","Uint8Array"],t)),r}Be.prototype.isPaused=function(){return this._readableState.flowing===!1};Be.prototype.setEncoding=function(e){Po||(Po=Ro().StringDecoder);var t=new Po(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";r!==null;)n+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),n!==""&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var Jm=1073741824;function r2(e){return e>=Jm?e=Jm:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function Qm(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=r2(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Be.prototype.read=function(e){Ee("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark!==0?t.length>=t.highWaterMark:t.length>0)||t.ended))return Ee("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Eh(this):Wu(this),null;if(e=Qm(e,t),e===0&&t.ended)return t.length===0&&Eh(this),null;var n=t.needReadable;Ee("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,Ee("length less than watermark",n)),t.ended||t.reading?(n=!1,Ee("reading or ended",n)):n&&(Ee("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Qm(r,t)));var i;return e>0?i=ov(e,t):i=null,i===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Eh(this)),i!==null&&this.emit("data",i),i};function n2(e,t){if(Ee("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?Wu(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,nv(e)))}}function Wu(e){var t=e._readableState;Ee("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(Ee("emitReadable",t.flowing),t.emittedReadable=!0,I.default.nextTick(nv,e))}function nv(e){var t=e._readableState;Ee("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,Ah(e)}function xh(e,t){t.readingMore||(t.readingMore=!0,I.default.nextTick(i2,e,t))}function i2(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var r=t.length;if(Ee("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}Be.prototype._read=function(e){Rs(this,new JT("_read()"))};Be.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,Ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==I.default.stdout&&e!==I.default.stderr,o=i?a:N;n.endEmitted?I.default.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(L,F){Ee("onunpipe"),L===r&&F&&F.hasUnpiped===!1&&(F.hasUnpiped=!0,m())}function a(){Ee("onend"),e.end()}var f=o2(r);e.on("drain",f);var l=!1;function m(){Ee("cleanup"),e.removeListener("close",E),e.removeListener("finish",T),e.removeListener("drain",f),e.removeListener("error",v),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",N),r.removeListener("data",g),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}r.on("data",g);function g(L){Ee("ondata");var F=e.write(L);Ee("dest.write",F),F===!1&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&sv(n.pipes,e)!==-1)&&!l&&(Ee("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function v(L){Ee("onerror",L),N(),e.removeListener("error",v),ev(e,"error")===0&&Rs(e,L)}e2(e,"error",v);function E(){e.removeListener("finish",T),N()}e.once("close",E);function T(){Ee("onfinish"),e.removeListener("close",E),N()}e.once("finish",T);function N(){Ee("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(Ee("pipe resume"),r.resume()),e};function o2(e){return function(){var r=e._readableState;Ee("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&ev(e,"data")&&(r.flowing=!0,Ah(e))}}Be.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=sv(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};Be.prototype.on=function(e,t){var r=Ts.prototype.on.call(this,e,t),n=this._readableState;return e==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):e==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Ee("on readable",n.length,n.reading),n.length?Wu(this):n.reading||I.default.nextTick(s2,this)),r};Be.prototype.addListener=Be.prototype.on;Be.prototype.removeListener=function(e,t){var r=Ts.prototype.removeListener.call(this,e,t);return e==="readable"&&I.default.nextTick(iv,this),r};Be.prototype.removeAllListeners=function(e){var t=Ts.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&I.default.nextTick(iv,this),t};function iv(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function s2(e){Ee("readable nexttick read 0"),e.read(0)}Be.prototype.resume=function(){var e=this._readableState;return e.flowing||(Ee("resume"),e.flowing=!e.readableListening,a2(this,e)),e.paused=!1,this};function a2(e,t){t.resumeScheduled||(t.resumeScheduled=!0,I.default.nextTick(u2,e,t))}function u2(e,t){Ee("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),Ah(e),t.flowing&&!t.reading&&e.read(0)}Be.prototype.pause=function(){return Ee("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Ee("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Ah(e){var t=e._readableState;for(Ee("flow",t.flowing);t.flowing&&e.read()!==null;);}Be.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(Ee("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(Ee("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(a){return function(){return e[a].apply(e,arguments)}})(i));for(var o=0;o<wh.length;o++)e.on(wh[o],this.emit.bind(this,wh[o]));return this._read=function(s){Ee("wrapped _read",s),n&&(n=!1,e.resume())},this};typeof Symbol=="function"&&(Be.prototype[Symbol.asyncIterator]=function(){return bh===void 0&&(bh=$m()),bh(this)});Object.defineProperty(Be.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(Be.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(Be.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}});Be._fromList=ov;Object.defineProperty(Be.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function ov(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.first():r=t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}function Eh(e){var t=e._readableState;Ee("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,I.default.nextTick(f2,t,e))}function f2(e,t){if(Ee("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}typeof Symbol=="function"&&(Be.from=function(e,t){return _h===void 0&&(_h=Xm()),_h(Be,e,t)});function sv(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Oh=P((l4,fv)=>{"use strict";p();fv.exports=vn;var zu=Pi().codes,c2=zu.ERR_METHOD_NOT_IMPLEMENTED,l2=zu.ERR_MULTIPLE_CALLBACK,h2=zu.ERR_TRANSFORM_ALREADY_TRANSFORMING,d2=zu.ERR_TRANSFORM_WITH_LENGTH_0,Yu=Bi();Fe()(vn,Yu);function p2(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new l2);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function vn(e){if(!(this instanceof vn))return new vn(e);Yu.call(this,e),this._transformState={afterTransform:p2.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",g2)}function g2(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){uv(e,t,r)}):uv(this,null,null)}vn.prototype.push=function(e,t){return this._transformState.needTransform=!1,Yu.prototype.push.call(this,e,t)};vn.prototype._transform=function(e,t,r){r(new c2("_transform()"))};vn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};vn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};vn.prototype._destroy=function(e,t){Yu.prototype._destroy.call(this,e,function(r){t(r)})};function uv(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new d2;if(e._transformState.transforming)throw new h2;return e.push(null)}});var hv=P((d4,lv)=>{"use strict";p();lv.exports=Ps;var cv=Oh();Fe()(Ps,cv);function Ps(e){if(!(this instanceof Ps))return new Ps(e);cv.call(this,e)}Ps.prototype._transform=function(e,t,r){r(null,e)}});var mv=P((g4,yv)=>{"use strict";p();var Rh;function y2(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var gv=Pi().codes,m2=gv.ERR_MISSING_ARGS,v2=gv.ERR_STREAM_DESTROYED;function dv(e){if(e)throw e}function b2(e){return e.setHeader&&typeof e.abort=="function"}function _2(e,t,r,n){n=y2(n);var i=!1;e.on("close",function(){i=!0}),Rh===void 0&&(Rh=ju()),Rh(e,{readable:t,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,b2(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(s||new v2("pipe"))}}}function pv(e){e()}function w2(e,t){return e.pipe(t)}function S2(e){return!e.length||typeof e[e.length-1]!="function"?dv:e.pop()}function E2(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=S2(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new m2("streams");var i,o=t.map(function(s,a){var f=a<t.length-1,l=a>0;return _2(s,f,l,function(m){i||(i=m),m&&o.forEach(pv),!f&&(o.forEach(pv),n(i))})});return t.reduce(w2)}yv.exports=E2});var Ph=P((m4,vv)=>{p();vv.exports=wr;var Th=go().EventEmitter,x2=Fe();x2(wr,Th);wr.Readable=dh();wr.Writable=ch();wr.Duplex=Bi();wr.Transform=Oh();wr.PassThrough=hv();wr.finished=ju();wr.pipeline=mv();wr.Stream=wr;function wr(){Th.call(this)}wr.prototype.pipe=function(e,t){var r=this;function n(m){e.writable&&e.write(m)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}e.on("drain",i),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",s),r.on("close",a));var o=!1;function s(){o||(o=!0,e.end())}function a(){o||(o=!0,typeof e.destroy=="function"&&e.destroy())}function f(m){if(l(),Th.listenerCount(this,"error")===0)throw m}r.on("error",f),e.on("error",f);function l(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",f),e.removeListener("error",f),r.removeListener("end",l),r.removeListener("close",l),e.removeListener("close",l)}return r.on("end",l),r.on("close",l),e.on("close",l),e.emit("pipe",r),e}});var wv=P((b4,_v)=>{"use strict";p();var Qr=Gt().Buffer,bv=Ph().Transform,I2=Fe();function Yn(e){bv.call(this),this._block=Qr.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}I2(Yn,bv);Yn.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};Yn.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};var A2=typeof Uint8Array<"u",O2=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(Qr.prototype instanceof Uint8Array||Qr.TYPED_ARRAY_SUPPORT);function R2(e,t){if(e instanceof Qr)return e;if(typeof e=="string")return Qr.from(e,t);if(O2&&ArrayBuffer.isView(e)){if(e.byteLength===0)return Qr.alloc(0);var r=Qr.from(e.buffer,e.byteOffset,e.byteLength);if(r.byteLength===e.byteLength)return r}if(A2&&e instanceof Uint8Array||Qr.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return Qr.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}Yn.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");e=R2(e,t);for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var o=0,s=e.length*8;s>0;++o)this._length[o]+=s,s=this._length[o]/4294967296|0,s>0&&(this._length[o]-=4294967296*s);return this};Yn.prototype._update=function(){throw new Error("_update is not implemented")};Yn.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};Yn.prototype._digest=function(){throw new Error("_digest is not implemented")};_v.exports=Yn});var Bh=P((w4,Ev)=>{"use strict";p();var T2=Fe(),Sv=wv(),P2=Gt().Buffer,B2=new Array(16);function $u(){Sv.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}T2($u,Sv);$u.prototype._update=function(){for(var e=B2,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,n=this._b,i=this._c,o=this._d;r=zt(r,n,i,o,e[0],3614090360,7),o=zt(o,r,n,i,e[1],3905402710,12),i=zt(i,o,r,n,e[2],606105819,17),n=zt(n,i,o,r,e[3],3250441966,22),r=zt(r,n,i,o,e[4],4118548399,7),o=zt(o,r,n,i,e[5],1200080426,12),i=zt(i,o,r,n,e[6],2821735955,17),n=zt(n,i,o,r,e[7],4249261313,22),r=zt(r,n,i,o,e[8],1770035416,7),o=zt(o,r,n,i,e[9],2336552879,12),i=zt(i,o,r,n,e[10],4294925233,17),n=zt(n,i,o,r,e[11],2304563134,22),r=zt(r,n,i,o,e[12],1804603682,7),o=zt(o,r,n,i,e[13],4254626195,12),i=zt(i,o,r,n,e[14],2792965006,17),n=zt(n,i,o,r,e[15],1236535329,22),r=Yt(r,n,i,o,e[1],4129170786,5),o=Yt(o,r,n,i,e[6],3225465664,9),i=Yt(i,o,r,n,e[11],643717713,14),n=Yt(n,i,o,r,e[0],3921069994,20),r=Yt(r,n,i,o,e[5],3593408605,5),o=Yt(o,r,n,i,e[10],38016083,9),i=Yt(i,o,r,n,e[15],3634488961,14),n=Yt(n,i,o,r,e[4],3889429448,20),r=Yt(r,n,i,o,e[9],568446438,5),o=Yt(o,r,n,i,e[14],3275163606,9),i=Yt(i,o,r,n,e[3],4107603335,14),n=Yt(n,i,o,r,e[8],1163531501,20),r=Yt(r,n,i,o,e[13],2850285829,5),o=Yt(o,r,n,i,e[2],4243563512,9),i=Yt(i,o,r,n,e[7],1735328473,14),n=Yt(n,i,o,r,e[12],2368359562,20),r=$t(r,n,i,o,e[5],4294588738,4),o=$t(o,r,n,i,e[8],2272392833,11),i=$t(i,o,r,n,e[11],1839030562,16),n=$t(n,i,o,r,e[14],4259657740,23),r=$t(r,n,i,o,e[1],2763975236,4),o=$t(o,r,n,i,e[4],1272893353,11),i=$t(i,o,r,n,e[7],4139469664,16),n=$t(n,i,o,r,e[10],3200236656,23),r=$t(r,n,i,o,e[13],681279174,4),o=$t(o,r,n,i,e[0],3936430074,11),i=$t(i,o,r,n,e[3],3572445317,16),n=$t(n,i,o,r,e[6],76029189,23),r=$t(r,n,i,o,e[9],3654602809,4),o=$t(o,r,n,i,e[12],3873151461,11),i=$t(i,o,r,n,e[15],530742520,16),n=$t(n,i,o,r,e[2],3299628645,23),r=Zt(r,n,i,o,e[0],4096336452,6),o=Zt(o,r,n,i,e[7],1126891415,10),i=Zt(i,o,r,n,e[14],2878612391,15),n=Zt(n,i,o,r,e[5],4237533241,21),r=Zt(r,n,i,o,e[12],1700485571,6),o=Zt(o,r,n,i,e[3],2399980690,10),i=Zt(i,o,r,n,e[10],4293915773,15),n=Zt(n,i,o,r,e[1],2240044497,21),r=Zt(r,n,i,o,e[8],1873313359,6),o=Zt(o,r,n,i,e[15],4264355552,10),i=Zt(i,o,r,n,e[6],2734768916,15),n=Zt(n,i,o,r,e[13],1309151649,21),r=Zt(r,n,i,o,e[4],4149444226,6),o=Zt(o,r,n,i,e[11],3174756917,10),i=Zt(i,o,r,n,e[2],718787259,15),n=Zt(n,i,o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0};$u.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=P2.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function Zu(e,t){return e<<t|e>>>32-t}function zt(e,t,r,n,i,o,s){return Zu(e+(t&r|~t&n)+i+o|0,s)+t|0}function Yt(e,t,r,n,i,o,s){return Zu(e+(t&n|r&~n)+i+o|0,s)+t|0}function $t(e,t,r,n,i,o,s){return Zu(e+(t^r^n)+i+o|0,s)+t|0}function Zt(e,t,r,n,i,o,s){return Zu(e+(r^(t|~n))+i+o|0,s)+t|0}Ev.exports=$u});var Iv=P((E4,xv)=>{p();var N2={}.toString;xv.exports=Array.isArray||function(e){return N2.call(e)=="[object Array]"}});var Ov=P((I4,Av)=>{"use strict";p();var M2=Ii(),k2=Hn(),C2=k2("TypedArray.prototype.buffer",!0),L2=Yl();Av.exports=C2||function(t){if(!L2(t))throw new M2("Not a Typed Array");return t.buffer}});var Xu=P((O4,Tv)=>{"use strict";p();var Pr=Gt().Buffer,D2=Iv(),U2=Ov(),F2=ArrayBuffer.isView||function(t){try{return U2(t),!0}catch{return!1}},q2=typeof Uint8Array<"u",Rv=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",j2=Rv&&(Pr.prototype instanceof Uint8Array||Pr.TYPED_ARRAY_SUPPORT);Tv.exports=function(t,r){if(Pr.isBuffer(t))return t.constructor&&!("isBuffer"in t)?Pr.from(t):t;if(typeof t=="string")return Pr.from(t,r);if(Rv&&F2(t)){if(t.byteLength===0)return Pr.alloc(0);if(j2){var n=Pr.from(t.buffer,t.byteOffset,t.byteLength);if(n.byteLength===t.byteLength)return n}var i=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=Pr.from(i);if(o.length===t.byteLength)return o}if(q2&&t instanceof Uint8Array)return Pr.from(t);var s=D2(t);if(s)for(var a=0;a<t.length;a+=1){var f=t[a];if(typeof f!="number"||f<0||f>255||~~f!==f)throw new RangeError("Array items must be numbers in the range 0-255.")}if(s||Pr.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return Pr.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var Mv=P((T4,Nv)=>{"use strict";p();var H2=Gt().Buffer,K2=Xu(),Bv=typeof Uint8Array<"u",G2=Bv&&typeof ArrayBuffer<"u",Pv=G2&&ArrayBuffer.isView;Nv.exports=function(e,t){if(typeof e=="string"||H2.isBuffer(e)||Bv&&e instanceof Uint8Array||Pv&&Pv(e))return K2(e,t);throw new TypeError('The "data" argument must be a string, a Buffer, a Uint8Array, or a DataView')}});var Bs=P((B4,Nh)=>{"use strict";p();typeof I.default>"u"||!I.default.version||I.default.version.indexOf("v0.")===0||I.default.version.indexOf("v1.")===0&&I.default.version.indexOf("v1.8.")!==0?Nh.exports={nextTick:V2}:Nh.exports=I.default;function V2(e,t,r,n){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,o,s;switch(i){case 0:case 1:return I.default.nextTick(e);case 2:return I.default.nextTick(function(){e.call(null,t)});case 3:return I.default.nextTick(function(){e.call(null,t,r)});case 4:return I.default.nextTick(function(){e.call(null,t,r,n)});default:for(o=new Array(i-1),s=0;s<o.length;)o[s++]=arguments[s];return I.default.nextTick(function(){e.apply(null,o)})}}});var Cv=P((M4,kv)=>{p();var W2={}.toString;kv.exports=Array.isArray||function(e){return W2.call(e)=="[object Array]"}});var Mh=P((C4,Lv)=>{p();Lv.exports=go().EventEmitter});var Qu=P((kh,Uv)=>{p();var Ju=Nt(),bn=Ju.Buffer;function Dv(e,t){for(var r in e)t[r]=e[r]}bn.from&&bn.alloc&&bn.allocUnsafe&&bn.allocUnsafeSlow?Uv.exports=Ju:(Dv(Ju,kh),kh.Buffer=Bo);function Bo(e,t,r){return bn(e,t,r)}Dv(bn,Bo);Bo.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return bn(e,t,r)};Bo.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=bn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Bo.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return bn(e)};Bo.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Ju.SlowBuffer(e)}});var No=P(Xt=>{p();function z2(e){return Array.isArray?Array.isArray(e):ef(e)==="[object Array]"}Xt.isArray=z2;function Y2(e){return typeof e=="boolean"}Xt.isBoolean=Y2;function $2(e){return e===null}Xt.isNull=$2;function Z2(e){return e==null}Xt.isNullOrUndefined=Z2;function X2(e){return typeof e=="number"}Xt.isNumber=X2;function J2(e){return typeof e=="string"}Xt.isString=J2;function Q2(e){return typeof e=="symbol"}Xt.isSymbol=Q2;function eP(e){return e===void 0}Xt.isUndefined=eP;function tP(e){return ef(e)==="[object RegExp]"}Xt.isRegExp=tP;function rP(e){return typeof e=="object"&&e!==null}Xt.isObject=rP;function nP(e){return ef(e)==="[object Date]"}Xt.isDate=nP;function iP(e){return ef(e)==="[object Error]"||e instanceof Error}Xt.isError=iP;function oP(e){return typeof e=="function"}Xt.isFunction=oP;function sP(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}Xt.isPrimitive=sP;Xt.isBuffer=Nt().Buffer.isBuffer;function ef(e){return Object.prototype.toString.call(e)}});var qv=P((q4,Ch)=>{"use strict";p();function aP(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Fv=Qu().Buffer,Ns=Xr();function uP(e,t,r){e.copy(t,r)}Ch.exports=(function(){function e(){aP(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},e.prototype.concat=function(r){if(this.length===0)return Fv.alloc(0);for(var n=Fv.allocUnsafe(r>>>0),i=this.head,o=0;i;)uP(i.data,n,o),o+=i.data.length,i=i.next;return n},e})();Ns&&Ns.inspect&&Ns.inspect.custom&&(Ch.exports.prototype[Ns.inspect.custom]=function(){var e=Ns.inspect({length:this.length});return this.constructor.name+" "+e})});var Lh=P((H4,jv)=>{"use strict";p();var tf=Bs();function fP(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,tf.nextTick(rf,this,e)):tf.nextTick(rf,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,tf.nextTick(rf,r,o)):tf.nextTick(rf,r,o):t&&t(o)}),this)}function cP(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function rf(e,t){e.emit("error",t)}jv.exports={destroy:fP,undestroy:cP}});var Uh=P((G4,$v)=>{"use strict";p();var Ci=Bs();$v.exports=Ot;function Kv(e){var t=this;this.next=null,this.entry=null,this.finish=function(){RP(t,e)}}var lP=!I.default.browser&&["v0.10","v0.9."].indexOf(I.default.version.slice(0,5))>-1?setImmediate:Ci.nextTick,Mo;Ot.WritableState=ks;var Gv=Object.create(No());Gv.inherits=Fe();var hP={deprecate:ah()},Vv=Mh(),of=Qu().Buffer,dP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function pP(e){return of.from(e)}function gP(e){return of.isBuffer(e)||e instanceof dP}var Wv=Lh();Gv.inherits(Ot,Vv);function yP(){}function ks(e,t){Mo=Mo||Li(),e=e||{};var r=t instanceof Mo;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){EP(t,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Kv(this)}ks.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(ks.prototype,"buffer",{get:hP.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var nf;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(nf=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ot,Symbol.hasInstance,{value:function(e){return nf.call(this,e)?!0:this!==Ot?!1:e&&e._writableState instanceof ks}})):nf=function(e){return e instanceof this};function Ot(e){if(Mo=Mo||Li(),!nf.call(Ot,this)&&!(this instanceof Mo))return new Ot(e);this._writableState=new ks(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),Vv.call(this)}Ot.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function mP(e,t){var r=new Error("write after end");e.emit("error",r),Ci.nextTick(t,r)}function vP(e,t,r,n){var i=!0,o=!1;return r===null?o=new TypeError("May not write null values to stream"):typeof r!="string"&&r!==void 0&&!t.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Ci.nextTick(n,o),i=!1),i}Ot.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&gP(e);return o&&!of.isBuffer(e)&&(e=pP(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=yP),n.ended?mP(this,r):(o||vP(this,n,e,r))&&(n.pendingcb++,i=_P(this,n,o,e,t,r)),i};Ot.prototype.cork=function(){var e=this._writableState;e.corked++};Ot.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&zv(this,e))};Ot.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function bP(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=of.from(t,r)),t}Object.defineProperty(Ot.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function _P(e,t,r,n,i,o){if(!r){var s=bP(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var f=t.length<t.highWaterMark;if(f||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Dh(e,t,!1,a,n,i,o);return f}function Dh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function wP(e,t,r,n,i){--t.pendingcb,r?(Ci.nextTick(i,n),Ci.nextTick(Ms,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ms(e,t))}function SP(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function EP(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(SP(r),t)wP(e,r,n,t,i);else{var o=Yv(r);!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&zv(e,r),n?lP(Hv,e,r,o,i):Hv(e,r,o,i)}}function Hv(e,t,r,n){r||xP(e,t),t.pendingcb--,n(),Ms(e,t)}function xP(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function zv(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,Dh(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Kv(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,m=r.callback,g=t.objectMode?1:f.length;if(Dh(e,t,!1,g,f,l,m),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Ot.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};Ot.prototype._writev=null;Ot.prototype.end=function(e,t,r){var n=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||OP(this,n,r)};function Yv(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function IP(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ms(e,t)})}function AP(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,Ci.nextTick(IP,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Ms(e,t){var r=Yv(t);return r&&(AP(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function OP(e,t,r){t.ending=!0,Ms(e,t),r&&(t.finished?Ci.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function RP(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(Ot.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});Ot.prototype.destroy=Wv.destroy;Ot.prototype._undestroy=Wv.undestroy;Ot.prototype._destroy=function(e,t){this.end(),t(e)}});var Li=P((W4,Qv)=>{"use strict";p();var Zv=Bs(),TP=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Qv.exports=_n;var Xv=Object.create(No());Xv.inherits=Fe();var Jv=jh(),qh=Uh();Xv.inherits(_n,Jv);for(Fh=TP(qh.prototype),sf=0;sf<Fh.length;sf++)af=Fh[sf],_n.prototype[af]||(_n.prototype[af]=qh.prototype[af]);var Fh,af,sf;function _n(e){if(!(this instanceof _n))return new _n(e);Jv.call(this,e),qh.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",PP)}Object.defineProperty(_n.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function PP(){this.allowHalfOpen||this._writableState.ended||Zv.nextTick(BP,this)}function BP(e){e.end()}Object.defineProperty(_n.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}});_n.prototype._destroy=function(e,t){this.push(null),this.end(),Zv.nextTick(t,e)}});var jh=P(($4,lb)=>{"use strict";p();var Co=Bs();lb.exports=$e;var NP=Cv(),Cs;$e.ReadableState=sb;var Y4=go().EventEmitter,nb=function(e,t){return e.listeners(t).length},Wh=Mh(),Ls=Qu().Buffer,MP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function kP(e){return Ls.from(e)}function CP(e){return Ls.isBuffer(e)||e instanceof MP}var ib=Object.create(No());ib.inherits=Fe();var Hh=Xr(),ke=void 0;Hh&&Hh.debuglog?ke=Hh.debuglog("stream"):ke=function(){};var LP=qv(),ob=Lh(),ko;ib.inherits($e,Wh);var Kh=["error","close","destroy","pause","resume"];function DP(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):NP(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function sb(e,t){Cs=Cs||Li(),e=e||{};var r=t instanceof Cs;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,i=e.readableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new LP,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(ko||(ko=Ro().StringDecoder),this.decoder=new ko(e.encoding),this.encoding=e.encoding)}function $e(e){if(Cs=Cs||Li(),!(this instanceof $e))return new $e(e);this._readableState=new sb(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Wh.call(this)}Object.defineProperty($e.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});$e.prototype.destroy=ob.destroy;$e.prototype._undestroy=ob.undestroy;$e.prototype._destroy=function(e,t){this.push(null),t(e)};$e.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Ls.from(e,t),t=""),n=!0),ab(this,e,t,!1,n)};$e.prototype.unshift=function(e){return ab(this,e,null,!0,!1)};function ab(e,t,r,n,i){var o=e._readableState;if(t===null)o.reading=!1,jP(e,o);else{var s;i||(s=UP(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Ls.prototype&&(t=kP(t)),n?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):Gh(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Gh(e,o,t,!1):ub(e,o)):Gh(e,o,t,!1))):n||(o.reading=!1)}return FP(o)}function Gh(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&uf(e)),ub(e,t)}function UP(e,t){var r;return!CP(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function FP(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}$e.prototype.isPaused=function(){return this._readableState.flowing===!1};$e.prototype.setEncoding=function(e){return ko||(ko=Ro().StringDecoder),this._readableState.decoder=new ko(e),this._readableState.encoding=e,this};var eb=8388608;function qP(e){return e>=eb?e=eb:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function tb(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=qP(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}$e.prototype.read=function(e){ke("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return ke("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Vh(this):uf(this),null;if(e=tb(e,t),e===0&&t.ended)return t.length===0&&Vh(this),null;var n=t.needReadable;ke("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,ke("length less than watermark",n)),t.ended||t.reading?(n=!1,ke("reading or ended",n)):n&&(ke("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=tb(r,t)));var i;return e>0?i=fb(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Vh(this)),i!==null&&this.emit("data",i),i};function jP(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,uf(e)}}function uf(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ke("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Co.nextTick(rb,e):rb(e))}function rb(e){ke("emit readable"),e.emit("readable"),zh(e)}function ub(e,t){t.readingMore||(t.readingMore=!0,Co.nextTick(HP,e,t))}function HP(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(ke("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}$e.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};$e.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,ke("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==I.default.stdout&&e!==I.default.stderr,o=i?a:L;n.endEmitted?Co.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(F,V){ke("onunpipe"),F===r&&V&&V.hasUnpiped===!1&&(V.hasUnpiped=!0,m())}function a(){ke("onend"),e.end()}var f=KP(r);e.on("drain",f);var l=!1;function m(){ke("cleanup"),e.removeListener("close",T),e.removeListener("finish",N),e.removeListener("drain",f),e.removeListener("error",E),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",L),r.removeListener("data",v),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}var g=!1;r.on("data",v);function v(F){ke("ondata"),g=!1;var V=e.write(F);V===!1&&!g&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&cb(n.pipes,e)!==-1)&&!l&&(ke("false write response, pause",n.awaitDrain),n.awaitDrain++,g=!0),r.pause())}function E(F){ke("onerror",F),L(),e.removeListener("error",E),nb(e,"error")===0&&e.emit("error",F)}DP(e,"error",E);function T(){e.removeListener("finish",N),L()}e.once("close",T);function N(){ke("onfinish"),e.removeListener("close",T),L()}e.once("finish",N);function L(){ke("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(ke("pipe resume"),r.resume()),e};function KP(e){return function(){var t=e._readableState;ke("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&nb(e,"data")&&(t.flowing=!0,zh(e))}}$e.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=cb(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};$e.prototype.on=function(e,t){var r=Wh.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var n=this._readableState;!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&uf(this):Co.nextTick(GP,this))}return r};$e.prototype.addListener=$e.prototype.on;function GP(e){ke("readable nexttick read 0"),e.read(0)}$e.prototype.resume=function(){var e=this._readableState;return e.flowing||(ke("resume"),e.flowing=!0,VP(this,e)),this};function VP(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Co.nextTick(WP,e,t))}function WP(e,t){t.reading||(ke("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),zh(e),t.flowing&&!t.reading&&e.read(0)}$e.prototype.pause=function(){return ke("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(ke("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function zh(e){var t=e._readableState;for(ke("flow",t.flowing);t.flowing&&e.read()!==null;);}$e.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(ke("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(ke("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(s){return function(){return e[s].apply(e,arguments)}})(i));for(var o=0;o<Kh.length;o++)e.on(Kh[o],this.emit.bind(this,Kh[o]));return this._read=function(s){ke("wrapped _read",s),n&&(n=!1,e.resume())},this};Object.defineProperty($e.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});$e._fromList=fb;function fb(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=zP(e,t.buffer,t.decoder),r}function zP(e,t,r){var n;return e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?n=t.shift():n=r?YP(e,t):$P(e,t),n}function YP(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),e-=s,e===0){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}function $P(e,t){var r=Ls.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),e-=s,e===0){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}function Vh(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Co.nextTick(ZP,t,e))}function ZP(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function cb(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Yh=P((X4,pb)=>{"use strict";p();pb.exports=wn;var ff=Li(),db=Object.create(No());db.inherits=Fe();db.inherits(wn,ff);function XP(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function wn(e){if(!(this instanceof wn))return new wn(e);ff.call(this,e),this._transformState={afterTransform:XP.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",JP)}function JP(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){hb(e,t,r)}):hb(this,null,null)}wn.prototype.push=function(e,t){return this._transformState.needTransform=!1,ff.prototype.push.call(this,e,t)};wn.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")};wn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};wn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};wn.prototype._destroy=function(e,t){var r=this;ff.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function hb(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var vb=P((Q4,mb)=>{"use strict";p();mb.exports=Ds;var gb=Yh(),yb=Object.create(No());yb.inherits=Fe();yb.inherits(Ds,gb);function Ds(e){if(!(this instanceof Ds))return new Ds(e);gb.call(this,e)}Ds.prototype._transform=function(e,t,r){r(null,e)}});var _b=P((en,bb)=>{p();en=bb.exports=jh();en.Stream=en;en.Readable=en;en.Writable=Uh();en.Duplex=Li();en.Transform=Yh();en.PassThrough=vb()});var Eb=P((rD,Sb)=>{"use strict";p();var QP=Gt().Buffer,eB=Mv(),wb=_b().Transform,tB=Fe();function $n(e){wb.call(this),this._block=QP.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}tB($n,wb);$n.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};$n.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};$n.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");for(var r=eB(e,t),n=this._block,i=0;this._blockOffset+r.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)n[o]=r[i],o+=1,i+=1;this._update(),this._blockOffset=0}for(;i<r.length;)n[this._blockOffset]=r[i],this._blockOffset+=1,i+=1;for(var s=0,a=r.length*8;a>0;++s)this._length[s]+=a,a=this._length[s]/4294967296|0,a>0&&(this._length[s]-=4294967296*a);return this};$n.prototype._update=function(){throw new Error("_update is not implemented")};$n.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};$n.prototype._digest=function(){throw new Error("_digest is not implemented")};Sb.exports=$n});var Zh=P((iD,Pb)=>{"use strict";p();var $h=Nt().Buffer,rB=Fe(),Tb=Eb(),nB=new Array(16),Us=[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],Fs=[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],qs=[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],js=[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],Hs=[0,1518500249,1859775393,2400959708,2840853838],Ks=[1352829926,1548603684,1836072691,2053994217,0];function Di(e,t){return e<<t|e>>>32-t}function xb(e,t,r,n,i,o,s,a){return Di(e+(t^r^n)+o+s|0,a)+i|0}function Ib(e,t,r,n,i,o,s,a){return Di(e+(t&r|~t&n)+o+s|0,a)+i|0}function Ab(e,t,r,n,i,o,s,a){return Di(e+((t|~r)^n)+o+s|0,a)+i|0}function Ob(e,t,r,n,i,o,s,a){return Di(e+(t&n|r&~n)+o+s|0,a)+i|0}function Rb(e,t,r,n,i,o,s,a){return Di(e+(t^(r|~n))+o+s|0,a)+i|0}function cf(){Tb.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}rB(cf,Tb);cf.prototype._update=function(){for(var e=nB,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._a|0,f=this._b|0,l=this._c|0,m=this._d|0,g=this._e|0,v=0;v<80;v+=1){var E,T;v<16?(E=xb(r,n,i,o,s,e[Us[v]],Hs[0],qs[v]),T=Rb(a,f,l,m,g,e[Fs[v]],Ks[0],js[v])):v<32?(E=Ib(r,n,i,o,s,e[Us[v]],Hs[1],qs[v]),T=Ob(a,f,l,m,g,e[Fs[v]],Ks[1],js[v])):v<48?(E=Ab(r,n,i,o,s,e[Us[v]],Hs[2],qs[v]),T=Ab(a,f,l,m,g,e[Fs[v]],Ks[2],js[v])):v<64?(E=Ob(r,n,i,o,s,e[Us[v]],Hs[3],qs[v]),T=Ib(a,f,l,m,g,e[Fs[v]],Ks[3],js[v])):(E=Rb(r,n,i,o,s,e[Us[v]],Hs[4],qs[v]),T=xb(a,f,l,m,g,e[Fs[v]],Ks[4],js[v])),r=s,s=o,o=Di(i,10),i=n,n=E,a=g,g=m,m=Di(l,10),l=f,f=T}var N=this._b+i+m|0;this._b=this._c+o+g|0,this._c=this._d+s+a|0,this._d=this._e+r+f|0,this._e=this._a+n+l|0,this._a=N};cf.prototype._digest=function(){this._block[this._blockOffset]=128,this._blockOffset+=1,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=$h.alloc?$h.alloc(20):new $h(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};Pb.exports=cf});var Ui=P((sD,Bb)=>{"use strict";p();var iB=Gt().Buffer,oB=Xu();function lf(e,t){this._block=iB.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}lf.prototype.update=function(e,t){e=oB(e,t||"utf8");for(var r=this._block,n=this._blockSize,i=e.length,o=this._len,s=0;s<i;){for(var a=o%n,f=Math.min(i-s,n-a),l=0;l<f;l++)r[a+l]=e[s+l];o+=f,s+=f,o%n===0&&this._update(r)}return this._len+=i,this};lf.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o};lf.prototype._update=function(){throw new Error("_update must be implemented by subclass")};Bb.exports=lf});var kb=P((uD,Mb)=>{"use strict";p();var sB=Fe(),Nb=Ui(),aB=Gt().Buffer,uB=[1518500249,1859775393,-1894007588,-899497514],fB=new Array(80);function Gs(){this.init(),this._w=fB,Nb.call(this,64,56)}sB(Gs,Nb);Gs.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function cB(e){return e<<5|e>>>27}function lB(e){return e<<30|e>>>2}function hB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Gs.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=t[a-3]^t[a-8]^t[a-14]^t[a-16];for(var f=0;f<80;++f){var l=~~(f/20),m=cB(r)+hB(l,n,i,o)+s+t[f]+uB[l]|0;s=o,o=i,i=lB(n),n=r,r=m}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};Gs.prototype._hash=function(){var e=aB.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};Mb.exports=Gs});var Db=P((cD,Lb)=>{"use strict";p();var dB=Fe(),Cb=Ui(),pB=Gt().Buffer,gB=[1518500249,1859775393,-1894007588,-899497514],yB=new Array(80);function Vs(){this.init(),this._w=yB,Cb.call(this,64,56)}dB(Vs,Cb);Vs.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function mB(e){return e<<1|e>>>31}function vB(e){return e<<5|e>>>27}function bB(e){return e<<30|e>>>2}function _B(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Vs.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=mB(t[a-3]^t[a-8]^t[a-14]^t[a-16]);for(var f=0;f<80;++f){var l=~~(f/20),m=vB(r)+_B(l,n,i,o)+s+t[f]+gB[l]|0;s=o,o=i,i=bB(n),n=r,r=m}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};Vs.prototype._hash=function(){var e=pB.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};Lb.exports=Vs});var Xh=P((hD,Fb)=>{"use strict";p();var wB=Fe(),Ub=Ui(),SB=Gt().Buffer,EB=[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],xB=new Array(64);function Ws(){this.init(),this._w=xB,Ub.call(this,64,56)}wB(Ws,Ub);Ws.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function IB(e,t,r){return r^e&(t^r)}function AB(e,t,r){return e&t|r&(e|t)}function OB(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function RB(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function TB(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function PB(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Ws.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._f|0,f=this._g|0,l=this._h|0,m=0;m<16;++m)t[m]=e.readInt32BE(m*4);for(;m<64;++m)t[m]=PB(t[m-2])+t[m-7]+TB(t[m-15])+t[m-16]|0;for(var g=0;g<64;++g){var v=l+RB(s)+IB(s,a,f)+EB[g]+t[g]|0,E=OB(r)+AB(r,n,i)|0;l=f,f=a,a=s,s=o+v|0,o=i,i=n,n=r,r=v+E|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=a+this._f|0,this._g=f+this._g|0,this._h=l+this._h|0};Ws.prototype._hash=function(){var e=SB.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};Fb.exports=Ws});var jb=P((pD,qb)=>{"use strict";p();var BB=Fe(),NB=Xh(),MB=Ui(),kB=Gt().Buffer,CB=new Array(64);function hf(){this.init(),this._w=CB,MB.call(this,64,56)}BB(hf,NB);hf.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};hf.prototype._hash=function(){var e=kB.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};qb.exports=hf});var Jh=P((yD,Yb)=>{"use strict";p();var LB=Fe(),zb=Ui(),DB=Gt().Buffer,Hb=[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],UB=new Array(160);function zs(){this.init(),this._w=UB,zb.call(this,128,112)}LB(zs,zb);zs.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Kb(e,t,r){return r^e&(t^r)}function Gb(e,t,r){return e&t|r&(e|t)}function Vb(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function Wb(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function FB(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function qB(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function jB(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function HB(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function qt(e,t){return e>>>0<t>>>0?1:0}zs.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,o=this._dh|0,s=this._eh|0,a=this._fh|0,f=this._gh|0,l=this._hh|0,m=this._al|0,g=this._bl|0,v=this._cl|0,E=this._dl|0,T=this._el|0,N=this._fl|0,L=this._gl|0,F=this._hl|0,V=0;V<32;V+=2)t[V]=e.readInt32BE(V*4),t[V+1]=e.readInt32BE(V*4+4);for(;V<160;V+=2){var z=t[V-30],W=t[V-30+1],ie=FB(z,W),ee=qB(W,z);z=t[V-4],W=t[V-4+1];var ge=jB(z,W),ce=HB(W,z),me=t[V-14],x=t[V-14+1],u=t[V-32],h=t[V-32+1],y=ee+x|0,w=ie+me+qt(y,ee)|0;y=y+ce|0,w=w+ge+qt(y,ce)|0,y=y+h|0,w=w+u+qt(y,h)|0,t[V]=w,t[V+1]=y}for(var S=0;S<160;S+=2){w=t[S],y=t[S+1];var R=Gb(r,n,i),A=Gb(m,g,v),_=Vb(r,m),c=Vb(m,r),b=Wb(s,T),k=Wb(T,s),D=Hb[S],K=Hb[S+1],G=Kb(s,a,f),X=Kb(T,N,L),Z=F+k|0,le=l+b+qt(Z,F)|0;Z=Z+X|0,le=le+G+qt(Z,X)|0,Z=Z+K|0,le=le+D+qt(Z,K)|0,Z=Z+y|0,le=le+w+qt(Z,y)|0;var se=c+A|0,O=_+R+qt(se,c)|0;l=f,F=L,f=a,L=N,a=s,N=T,T=E+Z|0,s=o+le+qt(T,E)|0,o=i,E=v,i=n,v=g,n=r,g=m,m=Z+se|0,r=le+O+qt(m,Z)|0}this._al=this._al+m|0,this._bl=this._bl+g|0,this._cl=this._cl+v|0,this._dl=this._dl+E|0,this._el=this._el+T|0,this._fl=this._fl+N|0,this._gl=this._gl+L|0,this._hl=this._hl+F|0,this._ah=this._ah+r+qt(this._al,m)|0,this._bh=this._bh+n+qt(this._bl,g)|0,this._ch=this._ch+i+qt(this._cl,v)|0,this._dh=this._dh+o+qt(this._dl,E)|0,this._eh=this._eh+s+qt(this._el,T)|0,this._fh=this._fh+a+qt(this._fl,N)|0,this._gh=this._gh+f+qt(this._gl,L)|0,this._hh=this._hh+l+qt(this._hl,F)|0};zs.prototype._hash=function(){var e=DB.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};Yb.exports=zs});var Zb=P((vD,$b)=>{"use strict";p();var KB=Fe(),GB=Jh(),VB=Ui(),WB=Gt().Buffer,zB=new Array(160);function df(){this.init(),this._w=zB,VB.call(this,128,112)}KB(df,GB);df.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};df.prototype._hash=function(){var e=WB.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};$b.exports=df});var Qh=P((_D,Sn)=>{"use strict";p();Sn.exports=function(t){var r=t.toLowerCase(),n=Sn.exports[r];if(!n)throw new Error(r+" is not supported (we accept pull requests)");return new n};Sn.exports.sha=kb();Sn.exports.sha1=Db();Sn.exports.sha224=jb();Sn.exports.sha256=Xh();Sn.exports.sha384=Zb();Sn.exports.sha512=Jh()});var pf=P((SD,Jb)=>{"use strict";p();var YB=Gt().Buffer,Xb=Ph().Transform,$B=Ro().StringDecoder,ZB=Fe(),XB=Xu();function Br(e){Xb.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}ZB(Br,Xb);Br.prototype.update=function(e,t,r){var n=XB(e,t),i=this._update(n);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)};Br.prototype.setAutoPadding=function(){};Br.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Br.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Br.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Br.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(i){n=i}finally{r(n)}};Br.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};Br.prototype._finalOrDigest=function(e){var t=this.__final()||YB.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Br.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new $B(t),this._encoding=t),this._encoding!==t)throw new Error("can\u2019t switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n};Jb.exports=Br});var t_=P((xD,e_)=>{"use strict";p();var JB=Fe(),QB=Bh(),eN=Zh(),tN=Qh(),Qb=pf();function gf(e){Qb.call(this,"digest"),this._hash=e}JB(gf,Qb);gf.prototype._update=function(e){this._hash.update(e)};gf.prototype._final=function(){return this._hash.digest()};e_.exports=function(t){return t=t.toLowerCase(),t==="md5"?new QB:t==="rmd160"||t==="ripemd160"?new eN:new gf(tN(t))}});var i_=P((AD,n_)=>{"use strict";p();var rN=Fe(),Fi=Gt().Buffer,r_=pf(),nN=Fi.alloc(128),Lo=64;function yf(e,t){r_.call(this,"digest"),typeof t=="string"&&(t=Fi.from(t)),this._alg=e,this._key=t,t.length>Lo?t=e(t):t.length<Lo&&(t=Fi.concat([t,nN],Lo));for(var r=this._ipad=Fi.allocUnsafe(Lo),n=this._opad=Fi.allocUnsafe(Lo),i=0;i<Lo;i++)r[i]=t[i]^54,n[i]=t[i]^92;this._hash=[r]}rN(yf,r_);yf.prototype._update=function(e){this._hash.push(e)};yf.prototype._final=function(){var e=this._alg(Fi.concat(this._hash));return this._alg(Fi.concat([this._opad,e]))};n_.exports=yf});var s_=P((RD,o_)=>{p();var iN=Bh();o_.exports=function(e){return new iN().update(e).digest()}});var f_=P((PD,u_)=>{"use strict";p();var oN=Fe(),sN=i_(),a_=pf(),Ys=Gt().Buffer,aN=s_(),ed=Zh(),td=Qh(),uN=Ys.alloc(128);function $s(e,t){a_.call(this,"digest"),typeof t=="string"&&(t=Ys.from(t));var r=e==="sha512"||e==="sha384"?128:64;if(this._alg=e,this._key=t,t.length>r){var n=e==="rmd160"?new ed:td(e);t=n.update(t).digest()}else t.length<r&&(t=Ys.concat([t,uN],r));for(var i=this._ipad=Ys.allocUnsafe(r),o=this._opad=Ys.allocUnsafe(r),s=0;s<r;s++)i[s]=t[s]^54,o[s]=t[s]^92;this._hash=e==="rmd160"?new ed:td(e),this._hash.update(i)}oN($s,a_);$s.prototype._update=function(e){this._hash.update(e)};$s.prototype._final=function(){var e=this._hash.digest(),t=this._alg==="rmd160"?new ed:td(this._alg);return t.update(this._opad).update(e).digest()};u_.exports=function(t,r){return t=t.toLowerCase(),t==="rmd160"||t==="ripemd160"?new $s("rmd160",r):t==="md5"?new sN(aN,r):new $s(t,r)}});var c_=P((ND,nd)=>{"use strict";p();var rd=65536,fN=4294967295;function cN(){throw new Error(`Secure random number generation is not supported by this browser.
11
- Use Chrome, Firefox or Internet Explorer 11`)}var lN=Gt().Buffer,mf=globalThis.crypto||globalThis.msCrypto;mf&&mf.getRandomValues?nd.exports=hN:nd.exports=cN;function hN(e,t){if(e>fN)throw new RangeError("requested too many random bytes");var r=lN.allocUnsafe(e);if(e>0)if(e>rd)for(var n=0;n<e;n+=rd)mf.getRandomValues(r.slice(n,n+rd));else mf.getRandomValues(r);return typeof t=="function"?I.default.nextTick(function(){t(null,r)}):r}});var Zs=P(vf=>{"use strict";p();vf.createHash=t_();vf.createHmac=f_();vf.randomBytes=c_()});var Xs=P((LD,h_)=>{"use strict";p();var l_=65536;function qi(){}qi.getRandomBuffer=function(e){var t=typeof globalThis<"u"?globalThis.crypto:void 0;if(t&&typeof t.getRandomValues=="function")return qi._fromGetRandomValues(t,e);try{var r=Zs();if(r&&typeof r.randomBytes=="function")return r.randomBytes(e)}catch{}throw new Error("bsv: no CSPRNG available in this environment (needs globalThis.crypto.getRandomValues or node crypto)")};qi._fromGetRandomValues=function(e,t){for(var r=d.Buffer.alloc(t),n=0;n<t;n+=l_){var i=new Uint8Array(Math.min(l_,t-n));e.getRandomValues(i),d.Buffer.from(i).copy(r,n)}return r};qi.getRandomBufferNode=function(e){var t=Zs();return t.randomBytes(e)};qi.getRandomBufferBrowser=function(e){var t=typeof globalThis<"u"?globalThis:{},r=null;if(t.crypto&&typeof t.crypto.getRandomValues=="function"?r=t.crypto:t.msCrypto&&typeof t.msCrypto.getRandomValues=="function"&&(r=t.msCrypto),!r)throw new Error("window.crypto.getRandomValues not available");return qi._fromGetRandomValues(r,e)};h_.exports=qi});var ze=P((UD,d_)=>{"use strict";p();var dN=Xs(),We={};We.isArray=e=>Array.isArray(e);We.isNumber=e=>typeof e=="number";We.isObject=e=>e&&typeof e=="object";We.isString=e=>typeof e=="string";We.isUndefined=e=>typeof e>"u";We.isFunction=e=>typeof e=="function";We.isNull=e=>e===null;We.isDate=e=>e instanceof Date;We.extend=(e,t)=>Object.assign(e,t);We.noop=()=>{};We.every=(e,t)=>e.every(t||(r=>r));We.map=(e,t)=>Array.from(e).map(t||(r=>r));We.includes=(e,t)=>e.includes(t);We.each=(e,t)=>e.forEach(t);We.clone=e=>Object.assign({},e);We.pick=(e,t)=>{let r={};return t.forEach(n=>{typeof e[n]<"u"&&(r[n]=e[n])}),r};We.values=e=>Object.values(e);We.filter=(e,t)=>e.filter(t);We.reduce=(e,t,r)=>e.reduce(t,r);We.without=(e,t)=>e.filter(r=>r!==t);We.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let i=dN.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(i*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};We.difference=(e,t)=>e.filter(r=>!t.includes(r));We.findIndex=(e,t)=>e.findIndex(t);We.some=(e,t)=>e.some(t);We.range=e=>[...Array(e).keys()];d_.exports=We});var g_=P((qD,p_)=>{"use strict";p();var pN="https://docs.moneybutton.com/";p_.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+pN+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]});var Zn=P((HD,od)=>{"use strict";p();var id=ze();function gN(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var y_=function(e,t){var r=function(){if(id.isString(t.message))this.message=gN(t.message,arguments);else if(id.isFunction(t.message))this.message=t.message.apply(null,arguments);else throw new Error("Invalid error definition for "+t.name);this.stack=this.message+`
12
- `+new Error().stack};return r.prototype=Object.create(e.prototype),r.prototype.name=e.prototype.name+t.name,e[t.name]=r,t.errors&&m_(r,t.errors),r},m_=function(e,t){id.each(t,function(r){y_(e,r)})},yN=function(e,t){return m_(e,t),e},Do={};Do.Error=function(){this.message="Internal error",this.stack=this.message+`
13
- `+new Error().stack};Do.Error.prototype=Object.create(Error.prototype);Do.Error.prototype.name="bsv.Error";var mN=g_();yN(Do.Error,mN);od.exports=Do.Error;od.exports.extend=function(e){return y_(Do.Error,e)}});var Le=P((GD,v_)=>{"use strict";p();var Js=Zn(),vN=ze();v_.exports={checkState:function(e,t){if(!e)throw new Js.InvalidState(t)},checkArgument:function(e,t,r,n){if(!e)throw new Js.InvalidArgument(t,r,n)},checkArgumentType:function(e,t,r){if(r=r||"(unknown name)",vN.isString(t)){if(t==="Buffer"){var n=Nt();if(!n.Buffer.isBuffer(e))throw new Js.InvalidArgumentType(e,t,r)}else if(typeof e!==t)throw new Js.InvalidArgumentType(e,t,r)}else if(!(e instanceof t))throw new Js.InvalidArgumentType(e,t.name,r)}}});var Sr=P((WD,S_)=>{"use strict";p();var Me=T0(),__=Le(),w_=ze(),bf=function(e){for(var t=d.Buffer.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};Me.Zero=new Me(0);Me.One=new Me(1);Me.Minus1=new Me(-1);Me.fromNumber=function(e){return __.checkArgument(w_.isNumber(e)),new Me(e)};Me.fromString=function(e,t){return __.checkArgument(w_.isString(e)),new Me(e,t)};Me.fromBuffer=function(e,t){typeof t<"u"&&t.endian==="little"&&(e=bf(e));var r=e.toString("hex"),n=new Me(r,16);return n};Me.fromSM=function(e,t){var r;if(e.length===0)return Me.fromBuffer(d.Buffer.from([0]));var n="big";return t&&(n=t.endian),n==="little"&&(e=bf(e)),e[0]&128?(e[0]=e[0]&127,r=Me.fromBuffer(e),r.neg().copy(r)):r=Me.fromBuffer(e),r};Me.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Me.prototype.toBuffer=function(e){var t,r;if(e&&e.size){r=this.toString(16,2);var n=r.length/2;t=d.Buffer.from(r,"hex"),n===e.size||(n>e.size?t=Me.trim(t,n):n<e.size&&(t=Me.pad(t,n,e.size)))}else r=this.toString(16,2),t=d.Buffer.from(r,"hex");return typeof e<"u"&&e.endian==="little"&&(t=bf(t)),t};Me.prototype.toSMBigEndian=function(){var e;return this.cmp(Me.Zero)===-1?(e=this.neg().toBuffer(),e[0]&128?e=d.Buffer.concat([d.Buffer.from([128]),e]):e[0]=e[0]|128):(e=this.toBuffer(),e[0]&128&&(e=d.Buffer.concat([d.Buffer.from([0]),e]))),e.length===1&&e[0]===0&&(e=d.Buffer.from([])),e};Me.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return t==="little"&&(r=bf(r)),r};function b_(e,t){var r=new Error(e);return r.scriptErr=t,r}Me.fromScriptNumBuffer=function(e,t,r){var n=r||4;if(e.length>n)throw b_("script number overflow","SCRIPT_ERR_SCRIPTNUM_OVERFLOW");if(t&&e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))throw b_("non-minimally encoded script number","SCRIPT_ERR_SCRIPTNUM_MINENCODE");return Me.fromSM(e,{endian:"little"})};Me.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};Me.trim=function(e,t){return e.slice(t-e.length,e.length)};Me.pad=function(e,t,r){for(var n=d.Buffer.alloc(r),i=0;i<e.length;i++)n[n.length-1-i]=e[e.length-1-i];for(i=0;i<r-t;i++)n[i]=0;return n};Me.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")};Me.fromHex=function(e,...t){return Me.fromBuffer(d.Buffer.from(e,"hex"),...t)};S_.exports=Me});function bN(e,t=!1){return t?{h:Number(e&_f),l:Number(e>>E_&_f)}:{h:Number(e>>E_&_f)|0,l:Number(e&_f)|0}}function x_(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=bN(e[o],t);[n[o],i[o]]=[s,a]}return[n,i]}function I_(e,t,r,n){let i=_N(r),o=wN(r);e.setUint32(t,n?o:i,n),e.setUint32(t+4,n?i:o,n)}function tn(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var _f,E_,_N,wN,sd,ad,ji,Hi,Qs,ea,A_,O_,R_,T_,P_,B_,ud=Wt(()=>{p();_f=BigInt(4294967295),E_=BigInt(32);_N=e=>e/2**32|0,wN=e=>e>>>0;sd=(e,t,r)=>e>>>r,ad=(e,t,r)=>e<<32-r|t>>>r,ji=(e,t,r)=>e>>>r|t<<32-r,Hi=(e,t,r)=>e<<32-r|t>>>r,Qs=(e,t,r)=>e<<64-r|t>>>r-32,ea=(e,t,r)=>e>>>r-32|t<<64-r;A_=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),O_=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,R_=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),T_=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,P_=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),B_=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0});function wf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function En(e,t=""){if(typeof e!="number")throw new TypeError(fd(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(fd(t)+"expected integer >= 0, got "+e);return e}function rn(e,t,r=""){if(wf(e)&&(t===void 0||e.length===t))return e;t!==void 0&&En(t,"length");let n=wf(e),i=t!==void 0?` of length ${t}`:"",o=n?`length=${e.length}`:`type=${typeof e}`,s=fd(r)+"expected Uint8Array"+i+", got "+o;throw n?new RangeError(s):new TypeError(s)}function Sf(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(En(e.outputLen),En(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}function Uo(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Ef(e,t){rn(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function ar(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function xf(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Nr(e,t){return e<<32-t|e>>>t}function xn(e,t){return e<<t|e>>>32-t>>>0}function If(e){if(rn(e),k_)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=EN[e[r]];return t}function M_(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function cd(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(k_)try{return Uint8Array.fromHex(e)}catch(i){throw i instanceof SyntaxError?new RangeError(i.message):i}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=M_(e.charCodeAt(o)),a=M_(e.charCodeAt(o+1));if(s===void 0||a===void 0){let f=e[o]+e[o+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+o)}n[i]=s*16+a}return n}function In(e){if(typeof e!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function C_(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];rn(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let o=e[n];r.set(o,i),i+=o.length}return r}function xN(e,t,r="opts"){return N_(e,"defaults"),t!==void 0&&N_(t,r),Object.assign(e,t)}function Mr(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=xN({},t,"info");let r=(i,o)=>e(o).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}function ta(e=32){En(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var fd,N_,k_,EN,Ki,An=Wt(()=>{p();fd=e=>e?`"${e}" `:"";N_=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)};k_=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",EN=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Ki=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})});function Fo(e,t,r){return e&t^~e&r}function Af(e,t,r){return e&t^e&r^t&r}var On,L_,D_,U_,F_,ld=Wt(()=>{p();ud();An();On=class{constructor(t,r,n,i){$(this,"blockLen");$(this,"outputLen");$(this,"canXOF",!1);$(this,"padOffset");$(this,"isLE");$(this,"buffer");$(this,"view");$(this,"finished",!1);$(this,"length",0);$(this,"pos",0);$(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=xf(this.buffer)}update(t){Uo(this),rn(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length,s=!1;for(let a=0;a<o;){let f=Math.min(i-this.pos,o-a);if(f===i){let l=xf(t);for(;i<=o-a;a+=i)this.process(l,a);s=!0;continue}n.set(a===0&&f===o?t:t.subarray(a,a+f),this.pos),this.pos+=f,a+=f,this.pos===i&&(this.process(r,0),this.pos=0,s=!0)}return this.length+=t.length,s&&this.roundClean(),this}digestInto(t){Uo(this),Ef(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,r.fill(0,s),this.padOffset>i-s&&(this.process(n,0),r.fill(0)),I_(n,i-8,this.length*8,o),this.process(n,0),this.roundClean();let a=t===r?n:xf(t),f=this.outputLen,l=f/4,m=this.get();if(f%4||l>m.length)throw new Error("invalid outputLen");for(let g=0;g<l;g++)a.setUint32(4*g,m[g],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.destroyed=o,t.finished=i,t.length=n,t.pos=s,s&&t.buffer.set(r),t}clone(){return this._cloneInto()}},L_=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),D_=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),U_=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),F_=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});var j_={};ol(j_,{_SHA224:()=>Tf,_SHA256:()=>Rf,_SHA384:()=>Bf,_SHA512:()=>Pf,_SHA512_224:()=>Nf,_SHA512_256:()=>Mf,sha224:()=>PN,sha256:()=>ei,sha384:()=>NN,sha512:()=>BN,sha512_224:()=>kN,sha512_256:()=>MN});var IN,Xn,Of,Rf,Tf,q_,AN,ON,Jn,Qn,qo,Pf,Bf,RN,TN,Nf,Mf,ei,PN,BN,NN,MN,kN,hd=Wt(()=>{p();ld();ud();An();IN=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Xn=new Uint32Array(64),Of=class extends On{constructor(r,n){super(64,r,8,!1);$(this,"A",0);$(this,"B",0);$(this,"C",0);$(this,"D",0);$(this,"E",0);$(this,"F",0);$(this,"G",0);$(this,"H",0);this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:r,B:n,C:i,D:o,E:s,F:a,G:f,H:l}=this;return[r,n,i,o,s,a,f,l]}set(r,n,i,o,s,a,f,l){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0,this.F=a|0,this.G=f|0,this.H=l|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let v=0;v<16;v++,n+=4)Xn[v]=r.getUint32(n,!1);for(let v=16;v<64;v++){let E=Xn[v-15],T=Xn[v-2],N=Nr(E,7)^Nr(E,18)^E>>>3,L=Nr(T,17)^Nr(T,19)^T>>>10;Xn[v]=L+Xn[v-7]+N+Xn[v-16]|0}let{A:i,B:o,C:s,D:a,E:f,F:l,G:m,H:g}=this;for(let v=0;v<64;v++){let E=Nr(f,6)^Nr(f,11)^Nr(f,25),T=g+E+Fo(f,l,m)+IN[v]+Xn[v]|0,L=(Nr(i,2)^Nr(i,13)^Nr(i,22))+Af(i,o,s)|0;g=m,m=l,l=f,f=a+T|0,a=s,s=o,o=i,i=T+L|0}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,f=f+this.E|0,l=l+this.F|0,m=m+this.G|0,g=g+this.H|0,this.set(i,o,s,a,f,l,m,g)}roundClean(){ar(Xn)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),ar(this.buffer)}},Rf=class extends Of{constructor(){super(32,L_)}},Tf=class extends Of{constructor(){super(28,D_)}},q_=x_(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),AN=q_[0],ON=q_[1],Jn=new Uint32Array(80),Qn=new Uint32Array(80),qo=class extends On{constructor(r,n){super(128,r,16,!1);$(this,"Ah",0);$(this,"Al",0);$(this,"Bh",0);$(this,"Bl",0);$(this,"Ch",0);$(this,"Cl",0);$(this,"Dh",0);$(this,"Dl",0);$(this,"Eh",0);$(this,"El",0);$(this,"Fh",0);$(this,"Fl",0);$(this,"Gh",0);$(this,"Gl",0);$(this,"Hh",0);$(this,"Hl",0);this.Ah=n[0]|0,this.Al=n[1]|0,this.Bh=n[2]|0,this.Bl=n[3]|0,this.Ch=n[4]|0,this.Cl=n[5]|0,this.Dh=n[6]|0,this.Dl=n[7]|0,this.Eh=n[8]|0,this.El=n[9]|0,this.Fh=n[10]|0,this.Fl=n[11]|0,this.Gh=n[12]|0,this.Gl=n[13]|0,this.Hh=n[14]|0,this.Hl=n[15]|0}get(){let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:f,Dl:l,Eh:m,El:g,Fh:v,Fl:E,Gh:T,Gl:N,Hh:L,Hl:F}=this;return[r,n,i,o,s,a,f,l,m,g,v,E,T,N,L,F]}set(r,n,i,o,s,a,f,l,m,g,v,E,T,N,L,F){this.Ah=r|0,this.Al=n|0,this.Bh=i|0,this.Bl=o|0,this.Ch=s|0,this.Cl=a|0,this.Dh=f|0,this.Dl=l|0,this.Eh=m|0,this.El=g|0,this.Fh=v|0,this.Fl=E|0,this.Gh=T|0,this.Gl=N|0,this.Hh=L|0,this.Hl=F|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let W=0;W<16;W++,n+=4)Jn[W]=r.getUint32(n),Qn[W]=r.getUint32(n+=4);for(let W=16;W<80;W++){let ie=Jn[W-15]|0,ee=Qn[W-15]|0,ge=ji(ie,ee,1)^ji(ie,ee,8)^sd(ie,ee,7),ce=Hi(ie,ee,1)^Hi(ie,ee,8)^ad(ie,ee,7),me=Jn[W-2]|0,x=Qn[W-2]|0,u=ji(me,x,19)^Qs(me,x,61)^sd(me,x,6),h=Hi(me,x,19)^ea(me,x,61)^ad(me,x,6),y=R_(ce,h,Qn[W-7],Qn[W-16]),w=T_(y,ge,u,Jn[W-7],Jn[W-16]);Jn[W]=w|0,Qn[W]=y|0}let{Ah:i,Al:o,Bh:s,Bl:a,Ch:f,Cl:l,Dh:m,Dl:g,Eh:v,El:E,Fh:T,Fl:N,Gh:L,Gl:F,Hh:V,Hl:z}=this;for(let W=0;W<80;W++){let ie=ji(v,E,14)^ji(v,E,18)^Qs(v,E,41),ee=Hi(v,E,14)^Hi(v,E,18)^ea(v,E,41),ge=v&T^~v&L,ce=E&N^~E&F,me=P_(z,ee,ce,ON[W],Qn[W]),x=B_(me,V,ie,ge,AN[W],Jn[W]),u=me|0,h=ji(i,o,28)^Qs(i,o,34)^Qs(i,o,39),y=Hi(i,o,28)^ea(i,o,34)^ea(i,o,39),w=i&s^i&f^s&f,S=o&a^o&l^a&l;V=L|0,z=F|0,L=T|0,F=N|0,T=v|0,N=E|0,{h:v,l:E}=tn(m|0,g|0,x|0,u|0),m=f|0,g=l|0,f=s|0,l=a|0,s=i|0,a=o|0;let R=A_(u,y,S);i=O_(R,x,h,w),o=R|0}({h:i,l:o}=tn(this.Ah|0,this.Al|0,i|0,o|0)),{h:s,l:a}=tn(this.Bh|0,this.Bl|0,s|0,a|0),{h:f,l}=tn(this.Ch|0,this.Cl|0,f|0,l|0),{h:m,l:g}=tn(this.Dh|0,this.Dl|0,m|0,g|0),{h:v,l:E}=tn(this.Eh|0,this.El|0,v|0,E|0),{h:T,l:N}=tn(this.Fh|0,this.Fl|0,T|0,N|0),{h:L,l:F}=tn(this.Gh|0,this.Gl|0,L|0,F|0),{h:V,l:z}=tn(this.Hh|0,this.Hl|0,V|0,z|0),this.set(i,o,s,a,f,l,m,g,v,E,T,N,L,F,V,z)}roundClean(){ar(Jn,Qn)}destroy(){this.destroyed=!0,ar(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Pf=class extends qo{constructor(){super(64,F_)}},Bf=class extends qo{constructor(){super(48,U_)}},RN=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),TN=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),Nf=class extends qo{constructor(){super(28,RN)}},Mf=class extends qo{constructor(){super(32,TN)}},ei=Mr(()=>new Rf,Ki(1)),PN=Mr(()=>new Tf,Ki(4)),BN=Mr(()=>new Pf,Ki(3)),NN=Mr(()=>new Bf,Ki(2)),MN=Mr(()=>new Mf,Ki(6)),kN=Mr(()=>new Nf,Ki(5))});function rt(e,t,r=()=>{}){if(!Array.isArray(e))throw new TypeError(`"${t}" expected array, got type=${typeof e}`);for(let n=0;n<e.length;n++)r(e[n],`${t}[${n}]`);return e}function ra(e,t=""){if(typeof e!="string"){let r=t&&`"${t}" `;throw new TypeError(r+"expected string, got type="+typeof e)}return e}function ti(e,t="object"){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(t==="object"?"expected valid options object":`"${t}" expected object, got type=${typeof e}`);return e}function Gi(e,t){if(typeof e!="function")throw new TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}function on(e,t=""){if(typeof e!="boolean")throw new TypeError(CN(t)+"expected boolean, got type="+typeof e);return e}function Cf(e){if(typeof e=="bigint"){if(!ri(e))throw new RangeError("positive bigint expected, got "+e)}else dd(e);return e}function nt(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function na(e){let t=Cf(e).toString(16);return t.length&1?"0"+t:t}function K_(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?kf:BigInt("0x"+e)}function Mt(e){return K_(If(e))}function Ho(e){return K_(If(Df(rn(e)).reverse()))}function Lf(e,t){if(En(t),t===0)throw new Error("zero output length is invalid");e=Cf(e);let r=t*2,n=e.toString(16);if(n.length>r)throw new RangeError("number is too large");return cd(n.padStart(r,"0"))}function pd(e,t){return Lf(e,t).reverse()}function Df(e){return Uint8Array.from(we(e))}function Ko(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}function ri(e){return typeof e=="bigint"&&kf<=e}function gd(e,t,r){return ri(e)&&ri(t)&&ri(r)&&t<=e&&e<r}function yd(e,t,r,n){if(!gd(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Go(e){if(e<kf)throw new Error("expected non-negative bigint, got "+e);return e===kf?0:e.toString(2).length}function G_(e,t,r){if(En(e,"hashLen"),En(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=L=>new Uint8Array(L),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,f=n(e),l=n(e),m=0,g=()=>{f.fill(1),l.fill(0),m=0},v=(...L)=>r(l,Ce(f,...L)),E=(L=i)=>{l=v(o,L),f=v(),L.length!==0&&(l=v(s,L),f=v())},T=()=>{if(m++>=a)throw new Error("drbg: tried max amount of iterations");let L=0,F=[];for(;L<t;){f=v();let V=f.slice();F.push(V),L+=f.length}return Ce(...F)};return(L,F)=>{g(),E(L);let V;for(;(V=F(T()))===void 0;)E();return g(),V}}function qe(e,t={},r={},n="object"){ti(e,n),ti(t,"fields"),ti(r,"optFields");function i(s,a,f){let l=n==="object"?`param "${String(s)}"`:`"${n}.${String(s)}"`,m=e[s];if(!Object.hasOwn(e,s)&&(f?m!==void 0:a!=="function"))throw new TypeError(`${l} is invalid: expected own property`);if(f&&m===void 0)return;let g=typeof m;if(g!==a||m===null)throw new TypeError(`${l} is invalid: expected ${a}, got ${g}`)}let o=(s,a)=>Object.entries(s).forEach(([f,l])=>i(f,l,a));o(t,!1),o(r,!0)}var we,dd,Rn,Ce,jo,nn,Qt,kf,H_,CN,ia,ni=Wt(()=>{p();An();we=(e,t,r)=>rn(e,t,r),dd=En;Rn=If,Ce=(...e)=>C_(...e),jo=e=>cd(e),nn=wf,Qt=e=>ta(e),kf=BigInt(0),H_=BigInt(1),CN=e=>e?`"${e}" `:"";ia=e=>(nt(e,"n"),(H_<<BigInt(e))-H_)});function er(e,t){if(t<=kt)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=kt?r:t+r}function X_(e,t,r){if(r<=Ue)throw new Error("pow: expected modulus > 1, got "+r);if(typeof t!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof t);if(t<kt)throw new Error("invalid exponent, negatives unsupported");if(t===kt)return Ue;if(t===Ue)return e;let n=e%r;if(n<kt&&(n+=r),t<FN){let a=Ue;for(;t>kt;)t&Ue&&(a=a*n%r),n=n*n%r,t>>=Ue;return a}let i=[];for(;t>kt;)i.push(Number(t&UN)),t>>=vd;let o=new Array(16);o[0]=Ue,o[1]=n;for(let a=2;a<16;a++)o[a]=o[a-1]*n%r;let s=o[i[i.length-1]];for(let a=i.length-2;a>=0;a--){s=s*s%r,s=s*s%r,s=s*s%r,s=s*s%r;let f=i[a];f!==0&&(s=s*o[f]%r)}return s}function hr(e,t,r){if(r<=Ue)throw new Error("pow2: expected modulus > 1, got "+r);if(t<kt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >kt;)n*=n,n%=r;return n}function V_(e,t){if(e===kt)throw new Error("invert: expected non-zero number");if(t<=Ue)throw new Error("invert: expected modulus > 1, got "+t);let r=er(e,t),n=t,i=kt,o=Ue;for(;r!==kt;){let a=n/r,f=n-r*a,l=i-o*a;n=r,r=f,i=o,o=l}if(n!==Ue)throw new Error("invert: does not exist");return er(i,t)}function J_(e,t){if(t<=Ue)throw new Error("invertCt: expected prime modulus > 1, got "+t);let r=er(e,t);if(r===kt)throw new Error("invertCt: expected non-zero number");let n=X_(r,t-ii,t);if(er(r*n,t)!==Ue)throw new Error("invertCt: does not exist");return n}function bd(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function _d(e,t){if((e&Ue)===kt)throw new Error(t+": expected odd modulus, got "+e)}function Q_(e,t){let r=e,n=(r.ORDER+Ue)/vd,i=r.pow(t,n);return bd(r,i,t),i}function qN(e,t){let r=e,n=(r.ORDER-Y_)/$_,i=r.mul(t,ii),o=r.pow(i,n),s=r.mul(t,o),a=r.mul(r.mul(s,ii),o),f=r.mul(s,r.sub(a,r.ONE));return bd(r,f,t),f}function jN(e){let t=Wo(e),r=ew(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+LN)/Z_;return((a,f)=>{let l=a,m=l.pow(f,s),g=l.mul(m,n),v=l.mul(m,i),E=l.mul(m,o),T=l.eql(l.sqr(g),f),N=l.eql(l.sqr(v),f);m=l.cmov(m,g,T),g=l.cmov(E,v,N);let L=l.eql(l.sqr(g),f),F=l.cmov(m,g,L);return bd(l,F,f),F})}function ew(e){if(e<z_)throw new Error("sqrt is not defined for small field");_d(e,"tonelliShanks");let t=e-Ue,r=0;for(;t%ii===kt;)t/=ii,r++;let n=ii,i=Wo(e);for(;md(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Q_;let o=i.pow(n,t),s=(t+Ue)/ii;return function(f,l){let m=f;if(m.is0(l))return l;if(md(m,l)!==1)throw new Error("Cannot find square root");let g=r,v=m.mul(m.ONE,o),E=m.pow(l,t),T=m.pow(l,s);for(;!m.eql(E,m.ONE);){if(m.is0(E))throw new Error("Cannot find square root: probably non-prime P");let N=1,L=m.sqr(E);for(;!m.eql(L,m.ONE);)if(N++,L=m.sqr(L),N===g)throw new Error("Cannot find square root");let F=Ue<<BigInt(g-N-1),V=m.pow(v,F);g=N,v=m.sqr(V),E=m.mul(E,v),T=m.mul(T,V)}return T}}function HN(e){return _d(e,"Fp.sqrt"),e%vd===z_?Q_:e%$_===Y_?qN:e%Z_===DN?jN(e):ew(e)}function Er(e){if(ti(e,"field"),typeof e.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof e.ORDER);nt(e.BYTES,"BYTES"),nt(e.BITS,"BITS");for(let t of KN)Gi(e[t],"field."+t);if(e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Ue)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Vo(e,t,r=!1){Er(e),rt(t,"nums"),on(r,"passZero");let n=e,i=new Array(t.length).fill(r?n.ZERO:void 0),o=t.reduce((a,f,l)=>n.is0(f)?a:(i[l]=a,n.mul(a,f)),n.ONE),s=n.inv(o);return t.reduceRight((a,f,l)=>n.is0(f)?a:(i[l]=n.mul(a,i[l]),n.mul(a,f)),s),i}function md(e,t){Er(e);let r=e;_d(r.ORDER,"FpLegendre");let n=(r.ORDER-Ue)/ii,i=r.pow(t,n),o=r.eql(i,r.ONE),s=r.eql(i,r.ZERO),a=r.eql(i,r.neg(r.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function wd(e,t){return md(e,t)!==-1}function GN(e,t){if(t!==void 0&&dd(t),e<=kt)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Go(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${r})`);let n=t!==void 0?t:r,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}function Wo(e,t={}){return Object.freeze(Uf.prototype),new Uf(e,t)}function tw(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=Ue)throw new Error("field order must be greater than 1");let t=Go(e-Ue);return Math.ceil(t/8)}function zo(e){let t=tw(e);return t+Math.ceil(t/2)}function Vi(e,t,r=!1){we(e);let n=e.length,i=tw(t),o=Math.max(zo(t),16);if(n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?Ho(e):Mt(e),a=er(s,t-Ue)+Ue;return r?pd(a,i):Lf(a,i)}var kt,Ue,ii,z_,vd,Y_,LN,$_,DN,UN,Z_,FN,KN,W_,Uf,Wi=Wt(()=>{p();ni();kt=BigInt(0),Ue=BigInt(1),ii=BigInt(2),z_=BigInt(3),vd=BigInt(4),Y_=BigInt(5),LN=BigInt(7),$_=BigInt(8),DN=BigInt(9),UN=BigInt(15),Z_=BigInt(16),FN=BigInt("0x10000000000000000");KN=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];W_=new WeakMap,Uf=class{constructor(t,r={}){$(this,"ORDER");$(this,"BITS");$(this,"BYTES");$(this,"isLE");$(this,"ZERO",kt);$(this,"ONE",Ue);$(this,"_lengths");$(this,"_mod");if(t<=Ue)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:i,nByteLength:o}=GN(t,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=i,this.BYTES=o,Object.freeze(this)}create(t){return er(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return kt<=t&&t<this.ORDER}is0(t){return t===kt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&Ue)===Ue}neg(t){return er(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return er(t*t,this.ORDER)}add(t,r){return er(t+r,this.ORDER)}sub(t,r){return er(t-r,this.ORDER)}mul(t,r){return er(t*r,this.ORDER)}pow(t,r){return X_(t,r,this.ORDER)}div(t,r){return er(t*V_(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return V_(t,this.ORDER)}sqrt(t){let r=W_.get(this);return r||W_.set(this,r=HN(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?pd(t,this.BYTES):Lf(t,this.BYTES)}fromBytes(t,r=!1){we(t);let{_lengths:n,BYTES:i,isLE:o,ORDER:s,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>i)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(i);l.set(t,o?0:l.length-t.length),t=l}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let f=o?Ho(t):Mt(t);if(a&&(f=er(f,s)),!r&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(t){return Vo(this,t,!0)}cmov(t,r,n){return on(n,"condition"),n?r:t}}});function oi(e){let t=e;if(typeof t!="function")throw new TypeError('"Point" expected constructor, got type='+typeof e);Gi(t.fromAffine,"Point.fromAffine"),Gi(t.fromBytes,"Point.fromBytes"),Gi(t.fromHex,"Point.fromHex"),ti(t.BASE,"Point.BASE"),ti(t.ZERO,"Point.ZERO"),Er(t.Fp),Er(t.Fn)}function ow(e,t){oi(e),sw(t,e);let r=Vo(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function zN(e,t,r=1){if(!Number.isSafeInteger(e)||e<r||e>t)throw new Error("invalid window size, expected ["+r+".."+t+"], got W="+e)}function YN(e,t){let r=e*(4*t+128);if(r>nw)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+nw/2**20+" MiB")}function Id(e,t){if(e!==void 0){Gi(e,"randomBytes");try{let r=e(t);if(!nn(r)||r.length!==t)return}catch{return}return e}}function sw(e,t){rt(e,"points"),e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function $N(e,t,r){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,i)=>{if(!(r===void 0?t.isValid(n):ri(n)&&n<r))throw new Error("invalid scalar at index "+i)})}function Ed(e){return aw.get(e)||1}function ZN(e,t){let r=e.double(),n=[e];for(let i=1;i<t;i++)n.push(n[i-1].add(r));return n}function XN(e,t){let r=2**t,n=r/2,i=BigInt(r-1),o=[];for(;e>xd;){let s=0;e&oa&&(s=Number(e&i),s>=n&&(s-=r),e-=BigInt(s)),o.push(s),e>>=oa}return o}function JN(e,t,r){let n=2**t,i=n/2,o=BigInt(n-1),s=BigInt(t),a=[];for(let f=0;f<r;f++){let l=Number(e&o);e>>=s,l>i&&(l-=n,e+=oa),a.push(l)}if(e!==xd)throw new Error("invalid wnaf");return a}function QN(e,t,r){let n=0;for(let o of r)n=Math.max(n,o.length);let i=e;for(let o=n-1;o>=0;o--){o!==n-1&&(i=i.double());for(let s=0;s<r.length;s++){let a=r[s][o];if(a){let f=t[s][Math.abs(a)-1>>1];i=i.add(a<0?f.negate():f)}}}return i}function Yo(e,t,r,n=!1){if(oi(e),sw(t,e),on(n,"allowOversized"),$N(r,e.Fn,n?e.Fn.ORDER**VN:void 0),t.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let i=t.map(s=>ZN(s,4)),o=r.map(s=>XN(s,4));return QN(e.ZERO,i,o)}function iw(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Er(t),t}else return Wo(e,{isLE:r})}function uw(e,t,r={},n){if(e!=="weierstrass"&&e!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);qe(r);for(let f of["p","n","h"]){let l=t[f];if(!(ri(l)&&l!==xd))throw new Error(`CURVE.${f} must be positive bigint`)}let i=iw(t.p,r.Fp,n),o=iw(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let f of a)if(!i.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function qf(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var xd,oa,VN,Sd,rw,WN,nw,aw,Ff,jf=Wt(()=>{p();ni();Wi();xd=BigInt(0),oa=BigInt(1),VN=BigInt(4),Sd=16,rw=128,WN=5,nw=2**31;aw=new WeakMap;Ff=class{constructor(t,r){$(this,"Point");$(this,"BASE");$(this,"ZERO");$(this,"randomBytes");$(this,"wnafPrecomputes",new WeakMap);$(this,"baseCanBeBlinded");$(this,"bits");oi(t),this.randomBytes=Id(r,Sd),this.Point=t,this.BASE=t.BASE,this.ZERO=t.ZERO,this.bits=t.Fn.BITS}buildWnafTable(t,r,n){let i=Math.ceil(n/r)+1,o=2**(r-1),s=[],a=t;for(let f=0;f<i;f++){let l=a;for(let m=0;m<o;m++)s.push(l),l=l.add(a);a=s[s.length-1].double()}return{W:r,bits:n,windows:i,comp:s}}wnafCachedCT(t,r){let{W:n,windows:i,comp:o}=t,s=2**(n-1),a=JN(r,n,i),f=this.ZERO,l=this.BASE;for(let m=0;m<i;m++){let g=a[m],v=m*s,E=Math.abs(g)-1,T=o[v];for(let L=1;L<s;L++)T=L===E?o[v+L]:T;let N=T.negate();g===0?l=l.add(o[v]):f=f.add(g<0?N:T)}return{p:f,f:l}}getWnafPrecomputes(t,r,n,i){let o=this.wnafPrecomputes.get(r),s=o?.find(a=>a.W===t&&a.bits===n);return s||(s=this.buildWnafTable(r,t,n),typeof i=="function"&&(s={...s,comp:i(s.comp)}),o||(o=[],this.wnafPrecomputes.set(r,o)),o.push(s)),s}assertPoint(t){if(!(t instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof t)}validateMulInput(t,r){if(this.assertPoint(t),!gd(r,oa,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,r,n,i){let o=Ed(t);return o===1?this.fixedWindowCT(t,r,n):this.wnafCachedCT(this.getWnafPrecomputes(o,t,n,i),r)}mulCT(t,r,n){return this.validateMulInput(t,r),this.runCT(t,r,this.bits,n)}mulCTBlinded(t,r,n){if(this.validateMulInput(t,r),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let i=this.Point.Fn.BITS+rw,o=this.randomBytes(Sd);if(!nn(o)||o.length!==Sd)throw new Error("randomBytes returned invalid byte array");o[0]=o[0]&63|128;let s=r+Mt(o)*this.Point.Fn.ORDER;return this.runCT(t,s,i,n)}fixedWindowCT(t,r,n){let i=WN,o=1<<i,s=ia(i),a=new Array(o);a[0]=this.ZERO;for(let m=1;m<o;m++)a[m]=a[m-1].add(t);let f=Math.ceil(n/i),l=this.ZERO;for(let m=f-1;m>=0;m--){if(m!==f-1)for(let E=0;E<i;E++)l=l.double();let g=Number(r>>BigInt(m*i)&s),v=a[0];for(let E=1;E<o;E++)v=E===g?a[E]:v;l=l.add(v)}return{p:l,f:l}}shouldBlind(t,r){return this.randomBytes===void 0?!1:r===oa?!0:t!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(t,r,n,i){return this.shouldBlind(t,n)?this.mulCTBlinded(t,r,i):this.mulCT(t,r,i)}mulUnsafe(t,r,n){if(this.assertPoint(t),!ri(r))throw new Error("invalid scalar");let i=Ed(t);if(i===1||r>=this.Point.Fn.ORDER)return Yo(this.Point,[t],[r],!0);let o=this.getWnafPrecomputes(i,t,this.bits,n);return this.wnafCachedCT(o,r).p}setWindowSize(t,r){this.assertPoint(t),zN(r,this.bits);let n=Math.ceil((this.bits+rw)/r)+1;YN(n*2**(r-1),this.Point.Fp.BYTES),aw.set(t,r),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return Ed(t)!==1}}});function Ad(e,t="n"){if(typeof e!="number")throw new TypeError(`wrong u32 integer "${t}": expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new RangeError(`wrong u32 integer "${t}": expected 0..4294967295, got ${e}`);return e}function fw(e){return Ad(e,"x"),(e&e-1)===0&&e!==0}function eM(e){if(Ad(e),e<=1)return 1;if(e>2147483648)throw new Error("nextPowerOfTwo overflow: result does not fit u32");return 1<<Hf(e-1)+1>>>0}function Hf(e){return Ad(e),31-Math.clz32(e)}function cw(e,t,r,n,i){Er(e);let o=e,s=r||((g,v)=>new Array(g).fill(v??o.ZERO)),a=g=>{if(Array.isArray(g))return!0;if(!ArrayBuffer.isView(g))return!1;let v=g;return typeof v.length=="number"&&typeof v.slice=="function"&&typeof v[Symbol.iterator]=="function"},f=(g,v)=>{if(!a(v))throw new TypeError(`"${g}" expected polynomial, got type=${typeof v}`)},l=(g,v)=>{f("a",g);let E=g.length;if(v!==void 0&&(f("b",v),v.length!==E))throw new Error(`poly: mismatched lengths ${E} vs ${v.length}`);if(i!==void 0&&E!==i)throw new Error(`poly: expected fixed length ${i}, got ${E}`);return E};function m(g,v,E=!1,T){if(!fw(v))throw new Error("poly.lagrange: expected power of two length, got "+v);let N=T||(E?t.brp(Hf(v)):t.roots(Hf(v)));for(let L=0;L<v;L++)if(o.eql(g,N[L]))return L;return-1}return{roots:t,create:s,length:i,extend:(g,v)=>{l(g);let E=s(v,o.ZERO);for(let T=0;T<Math.min(g.length,v);T++)E[T]=g[T];return E},degree:g=>{l(g);for(let v=g.length-1;v>=0;v--)if(!o.is0(g[v]))return v;return-1},add:(g,v)=>{let E=l(g,v),T=s(E);for(let N=0;N<E;N++)T[N]=o.add(g[N],v[N]);return T},sub:(g,v)=>{let E=l(g,v),T=s(E);for(let N=0;N<E;N++)T[N]=o.sub(g[N],v[N]);return T},dot:(g,v)=>{let E=l(g,v),T=s(E);for(let N=0;N<E;N++)T[N]=o.mul(g[N],v[N]);return T},mul:(g,v)=>{if(a(v)){let E=l(g,v);if(n){let T=n.direct(g,!1,!0),N=n.direct(v,!1,!0);for(let L=0;L<T.length;L++)T[L]=o.mul(T[L],N[L]);return n.inverse(T,!0,!1)}else{let T=s(E);for(let N=0;N<E;N++)for(let L=0;L<E;L++){let F=(N+L)%E;T[F]=o.add(T[F],o.mul(g[N],v[L]))}return T}}else{let E=s(l(g));for(let T=0;T<E.length;T++)E[T]=o.mul(g[T],v);return E}},convolve(g,v){f("a",g),f("b",v);let E=eM(g.length+v.length-1);return this.mul(this.extend(g,E),this.extend(v,E))},shift(g,v){f("p",g);let E=s(g.length);if(i!==void 0&&g.length!==i)throw new Error(`poly: expected fixed length ${i}, got ${g.length}`);if(!g.length)return E;E[0]=g[0];for(let T=1,N=o.ONE;T<g.length;T++)N=o.mul(N,v),E[T]=o.mul(g[T],N);return E},clone:g=>{l(g);let v=s(g.length);for(let E=0;E<g.length;E++)v[E]=g[E];return v},eval:(g,v)=>{l(g,v);let E=o.ZERO;for(let T=0;T<g.length;T++)E=o.add(E,o.mul(g[T],v[T]));return E},monomial:{basis:(g,v)=>{let E=s(v),T=o.ONE;for(let N=0;N<v;N++)E[N]=T,T=o.mul(T,g);return E},eval:(g,v)=>{l(g);let E=o.ZERO;for(let T=g.length-1;T>=0;T--)E=o.add(o.mul(E,v),g[T]);return E}},lagrange:{basis:(g,v,E=!1,T)=>{if(!fw(v))throw new Error("poly.lagrange: expected power of two length, got "+v);let N=Hf(v),L=T||(E?t.brp(N):t.roots(N)),F=s(v),V=m(g,v,E,T);if(V!==-1)return F[V]=o.ONE,F;let z=o.pow(g,BigInt(v)),W=o.mul(o.sub(z,o.ONE),o.inv(BigInt(v))),ie=s(v);for(let ge=0;ge<v;ge++)ie[ge]=o.sub(g,L[ge]);let ee=o.invertBatch(ie);for(let ge=0;ge<v;ge++)F[ge]=o.mul(W,o.mul(L[ge],ee[ge]));return F},eval(g,v,E=!1){l(g);let T=m(v,g.length,E);if(T!==-1)return g[T];let N=this.basis(v,g.length,E),L=o.ZERO;for(let F=0;F<g.length;F++)o.is0(g[F])||(L=o.add(L,o.mul(g[F],N[F])));return L}},vanishing(g){if(f("roots",g),i!==void 0&&g.length!==i)throw new Error(`poly: expected fixed length ${i}, got ${g.length}`);let v=s(g.length+1,o.ZERO);v[0]=o.ONE;for(let E of g){let T=o.neg(E);for(let N=v.length-1;N>0;N--)v[N]=o.add(o.mul(v[N],T),v[N-1]);v[0]=o.mul(v[0],T)}return v}}}var lw=Wt(()=>{p();Wi()});function zi(e,t){if(nt(e),nt(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function rM(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function gw(e){if(!nn(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?Ko(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function nM(e,t,r,n){if(we(e),nt(r),typeof n!="function")throw new Error("expand_message_xmd: expected hash function");nt(n.outputLen,"hash.outputLen"),nt(n.blockLen,"hash.blockLen"),t=gw(t),t.length>255&&(t=n(Ce(Ko("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(r>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=Ce(t,zi(t.length,1)),f=new Uint8Array(o),l=zi(r,2),m=new Array(s),g=n(Ce(f,e,l,zi(0,1),a));m[0]=n(Ce(g,zi(1,1),a));for(let E=1;E<s;E++){let T=[rM(g,m[E-1]),zi(E+1,1),a];m[E]=n(Ce(...T))}return Ce(...m).slice(0,r)}function iM(e,t,r,n,i){if(we(e),nt(r),nt(n,"k"),n<0)throw new Error("expand_message_xof: invalid k");if(typeof i!="function")throw new Error("expand_message_xof: expected XOF function");if(typeof i.create!="function")throw new Error("expand_message_xof: expected XOF create");if(t=gw(t),r<0||r>65535)throw new Error("expand_message_xof: invalid lenInBytes");if(t.length>255){let o=Math.ceil(2*n/8);t=i.create({dkLen:o}).update(Ko("H2C-OVERSIZE-DST-")).update(t).digest()}if(t.length>255)throw new Error("expand_message_xof: invalid DST");return i.create({dkLen:r}).update(e).update(zi(r,2)).update(t).update(zi(t.length,1)).digest()}function Od(e,t,r){qe(r,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:n,k:i,m:o,hash:s,expand:a,DST:f}=r;if(nt(s.outputLen,"valid hash"),we(e),nt(t),nt(o,"m"),nt(i,"k"),n<=BigInt(1))throw new Error("hash_to_field: expected valid field characteristic");if(t<1)throw new Error("hash_to_field: expected count >= 1");if(o<1)throw new Error("hash_to_field: expected m >= 1");if(i<0)throw new Error("hash_to_field: invalid k");let l=n.toString(2).length,m=Math.ceil((l+i)/8),g=t*o*m,v;if(a==="xmd")v=nM(e,f,g,s);else if(a==="xof")v=iM(e,f,g,i,s);else if(a==="_internal_pass")v=e;else throw new Error('expand must be "xmd" or "xof"');let E=new Array(t);for(let T=0;T<t;T++){let N=new Array(o);for(let L=0;L<o;L++){let F=m*(L+T*o),V=v.subarray(F,F+m);N[L]=er(tM(V),n)}E[T]=N}return E}function yw(e,t){Er(e),rt(t,"map");let r=t.map((n,i)=>{if(rt(n,"map["+i+"]"),n.length<1)throw new Error("isogenyMap: expected non-empty coefficients");return Array.from(n).reverse()});return(n,i)=>{let[o,s,a,f]=r.map(v=>v.reduce((E,T)=>e.add(e.mul(E,n),T))),l=e.is0(s)||e.is0(f),[m,g]=Vo(e,[s,f],!0);return n=e.mul(o,m),i=e.mul(i,e.mul(a,g)),l?{x:e.ZERO,y:e.ZERO}:{x:n,y:i}}}function mw(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");qe(r);let n=f=>Object.freeze({...f,DST:nn(f.DST)?Df(f.DST):f.DST,...f.encodeDST===void 0?{}:{encodeDST:nn(f.encodeDST)?Df(f.encodeDST):f.encodeDST}}),i=n(r),o=f=>f&&f.DST!==void 0?{DST:f.DST}:void 0;function s(f){return e.fromAffine(t(f))}function a(f){let l=f.clearCofactor();return l.equals(e.ZERO)?e.ZERO:(l.assertValidity(),l)}return Object.freeze({get defaults(){return n(i)},Point:e,hashToCurve(f,l){let m=Object.assign({},i,o(l)),g=Od(f,2,m),v=s(g[0]),E=s(g[1]);return a(v.add(E))},encodeToCurve(f,l){let m=i.encodeDST===void 0?{}:{DST:i.encodeDST},g=Object.assign({},i,m,o(l)),v=Od(f,1,g),E=s(v[0]);return a(E)},mapToCurve(f){if(i.m===1){if(typeof f!="bigint")throw new Error("expected bigint (m=1)");return a(s([f]))}if(!Array.isArray(f))throw new Error("expected array of bigints");if(f.length!==i.m)throw new Error(`expected array of ${i.m} bigints`);for(let l of f)if(typeof l!="bigint")throw new Error("expected array of bigints");return a(s(f))},hashToScalar(f,l){let m=e.Fn.ORDER,g=Object.assign({},i,{DST:oM},o(l),{p:m,m:1});return Od(f,1,g)[0][0]}})}function sM(e,t){let r=Er(e),n=r.ORDER,i=hw;for(let N=n-sn;N%si===hw;N/=si)i+=sn;let o=i,s=si<<o-sn-sn,a=s*si,f=(n-sn)/a,l=(f-sn)/si,m=a-sn,g=s,v=r.pow(t,f),E=r.pow(t,(f+sn)/si),T=(N,L)=>{let F=v,V=r.pow(L,m),z=r.sqr(V);z=r.mul(z,L);let W=r.mul(N,z);W=r.pow(W,l),W=r.mul(W,V),V=r.mul(W,L),z=r.mul(W,N);let ie=r.mul(z,V);W=r.pow(ie,g);let ee=r.eql(W,r.ONE);V=r.mul(z,E),W=r.mul(ie,F),z=r.cmov(V,z,ee),ie=r.cmov(W,ie,ee);for(let ge=o;ge>sn;ge--){let ce=ge-si;ce=si<<ce-sn;let me=r.pow(ie,ce),x=r.eql(me,r.ONE);V=r.mul(z,F),F=r.mul(F,F),me=r.mul(ie,F),z=r.cmov(V,z,x),ie=r.cmov(me,ie,x)}return{isValid:!r.is0(L)&&(ee||r.is0(N)),value:z}};if(r.ORDER%pw===dw){let N=(r.ORDER-dw)/pw,L=r.sqrt(r.neg(t));T=(F,V)=>{let z=r.sqr(V),W=r.mul(F,V);z=r.mul(z,W);let ie=r.pow(z,N);ie=r.mul(ie,W);let ee=r.mul(ie,L),ge=r.mul(r.sqr(ie),V),ce=r.eql(ge,F),me=r.cmov(ee,ie,ce);return{isValid:!r.is0(V)&&ce,value:me}}}return T}function vw(e,t){let r=Er(e);qe(t,{},{},"opts");let{A:n,B:i,Z:o}=t;if(!r.isValidNot0(n)||!r.isValidNot0(i)||!r.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");if(r.eql(o,r.neg(r.ONE))||wd(r,o))throw new Error("mapToCurveSimpleSWU: invalid opts");let s=r.mul(i,r.inv(r.mul(o,n))),a=r.add(r.add(r.mul(r.sqr(s),s),r.mul(n,s)),i);if(!wd(r,a))throw new Error("mapToCurveSimpleSWU: invalid opts");let f=sM(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return l=>{let m,g,v,E,T,N,L,F;m=r.sqr(l),m=r.mul(m,o),g=r.sqr(m),g=r.add(g,m),v=r.add(g,r.ONE),v=r.mul(v,i),E=r.cmov(o,r.neg(g),!r.eql(g,r.ZERO)),E=r.mul(E,n),g=r.sqr(v),N=r.sqr(E),T=r.mul(N,n),g=r.add(g,T),g=r.mul(g,v),N=r.mul(N,E),T=r.mul(N,i),g=r.add(g,T),L=r.mul(m,v);let{isValid:V,value:z}=f(g,N);F=r.mul(m,l),F=r.mul(F,z),L=r.cmov(L,v,V),F=r.cmov(F,z,V);let W=r.isOdd(l)===r.isOdd(F);F=r.cmov(r.neg(F),F,W);let ie=Vo(r,[E],!0)[0];return L=r.mul(L,ie),{x:L,y:F}}}var hw,sn,si,dw,pw,tM,oM,bw=Wt(()=>{p();ni();Wi();hw=BigInt(0),sn=BigInt(1),si=BigInt(2),dw=BigInt(3),pw=BigInt(4),tM=Mt;oM="HashToScalar-"});function Rd(e){qe(e,{name:"string",hash:"function"},{hashToScalar:"function",validatePoint:"function",parsePublicKey:"function",adjustScalar:"function",adjustPoint:"function",challenge:"function",adjustNonces:"function",adjustSecret:"function",adjustPublic:"function",adjustGroupCommitmentShare:"function",adjustDKG:"function"}),oi(e.Point);let{Point:t}=e,r=e.Fn===void 0?t.Fn:e.Fn,n=e.hash,i=e.hashToScalar===void 0?(O,C={DST:new Uint8Array})=>{let U=n(Ce(C.DST,O));return r.create(r.isLE?Ho(U):Mt(U))}:e.hashToScalar,o=In(e.H1!==void 0?e.H1:e.name+"rho"),s=In(e.H2!==void 0?e.H2:e.name+"chal"),a=In(e.H3!==void 0?e.H3:e.name+"nonce"),f=In(e.H4!==void 0?e.H4:e.name+"msg"),l=In(e.H5!==void 0?e.H5:e.name+"com"),m=In(e.HDKG!==void 0?e.HDKG:e.name+"dkg"),g=In(e.HID!==void 0?e.HID:e.name+"id"),v=O=>i(O,{DST:o}),E=O=>i(O,{DST:s}),T=O=>i(O,{DST:a}),N=O=>n(Ce(f,O)),L=O=>n(Ce(l,O)),F=O=>i(O,{DST:m}),V=O=>i(O,{DST:g}),z=(O=Qt)=>{if(typeof O!="function")throw new TypeError('"rng" expected function, got type='+typeof O);let C=Vi(O(zo(r.ORDER)),r.ORDER,r.isLE);return r.isLE?Ho(C):Mt(C)},W=O=>O.toBytes(),ie=O=>{let C=t.fromBytes(O);return e.validatePoint&&e.validatePoint(C),C},ee=(O,C)=>({identifier:O,hiding:W(t.BASE.multiply(r.fromBytes(C.hiding))),binding:W(t.BASE.multiply(r.fromBytes(C.binding)))}),ge=e.adjustPoint===void 0?O=>O:e.adjustPoint,ce=O=>{if(!r.isValid(O)||r.is0(O))throw new Error("Invalid identifier "+O);return O},me=O=>Rn(r.toBytes(ce(O))),x=(O,C="identifier")=>{ra(O,C);let U=ce(r.fromBytes(jo(O)));if(me(U)!==O)throw new Error("expected canonical identifier hex");return U},u={encode:(O,C)=>{let U=Ce(W(O),r.toBytes(C));return e.adjustTx&&(U=e.adjustTx.encode(U)),U},decode:O=>{e.adjustTx&&(O=e.adjustTx.decode(O));let C=O.subarray(0,-r.BYTES),U=ie(C);if(W(U).length!==C.length)throw new Error("invalid signature encoding");let j=r.fromBytes(O.subarray(-r.BYTES));return{R:U,z:j}}},h=(O=Qt)=>{let C=z(O);e.adjustScalar&&(C=e.adjustScalar(C));let U=t.BASE.multiply(C);return{scalar:C,point:U}},y="roots are unavailable in FROST polynomial mode",w={info:{G:r.ZERO,oddFactor:r.ZERO,powerOfTwo:0},roots(){throw new Error(y)},brp(){throw new Error(y)},inverse(){throw new Error(y)},omega(){throw new Error(y)},clear(){}},S=cw(r,w),R=(O,C)=>Yo(t,O,C),A=(O,C)=>{if(!C.length)throw new Error("empty coefficients");return S.monomial.eval(C,O)},_=(O,C)=>{let U="invalid parameters";if(!O.some(te=>r.eql(te,C)))throw new Error(U);let j=new Set(O);if(j.size!==O.length)throw new Error(U);if(!j.has(C))throw new Error(U);let re=r.ONE,J=r.ONE;for(let te of O)r.eql(te,C)||(re=r.mul(re,te),J=r.mul(J,r.sub(te,C)));return r.div(re,J)},c=(O,C)=>{let U=S.monomial.basis(O,C.length);return R(C,U)},b=(O,C,U,j=Qt)=>{if(an(O),C!==void 0&&we(C,r.BYTES,"secret"),U!==void 0&&rt(U,"coeffs"),typeof j!="function")throw new TypeError('"rng" expected function, got type='+typeof j);let re=C===void 0?z(j):r.fromBytes(C);if(!U){U=[];for(let ae=0;ae<O.min-1;ae++)U.push(z(j))}if(U.length!==O.min-1)throw new Error("wrong coefficients length");let J=[re,...U],te=J.map(ae=>t.BASE.multiply(ae));return{coefficients:J,commitment:te,secret:re}},k={challenge:(O,C,U)=>F(Ce(r.toBytes(O),W(C),W(U))),compute(O,C,U,j=Qt){if(C.length<1)throw new Error("coefficients should have at least one element");let{point:re,scalar:J}=h(j),te=U[0],ae=this.challenge(O,te,re),oe=r.add(J,r.mul(C[0],ae));return u.encode(re,oe)},validate(O,C,U){if(C.length<1)throw new Error("commitment should have at least one element");let{R:j,z:re}=u.decode(U),J=ie(C[0]),te=this.challenge(O,J,j);if(!j.equals(t.BASE.multiplyUnsafe(re).subtract(J.multiplyUnsafe(te))))throw new Error("invalid proof of knowledge")}},D={challenge:(O,C,U)=>e.challenge?e.challenge(O,C,U):E(Ce(W(O),W(C),U)),sign(O,C,U=Qt){let{point:j,scalar:re}=h(U),J=t.BASE.multiply(C),te=this.challenge(j,J,O),ae=r.add(re,r.mul(te,C));return[j,ae]},verify(O,C,U,j){e.adjustPoint&&(j=e.adjustPoint(j)),e.adjustPoint&&(C=e.adjustPoint(C));let re=this.challenge(C,j,O),J=t.BASE.multiplyUnsafe(U),te=j.multiplyUnsafe(re),ae=J.subtract(te).subtract(C);return ae.clearCofactor&&(ae=ae.clearCofactor()),t.ZERO.equals(ae)}},K=(O,C,U)=>{if(!t.BASE.multiply(U).equals(c(O,C)))throw new Error("invalid secret share")},G={fromNumber(O){if(!Number.isSafeInteger(O))throw new Error("expected safe interger");return me(BigInt(O))},derive(O){return ra(O,"s"),me(V(In(O)))}},X=(O,C=Qt)=>T(Ce(C(32),r.toBytes(O))),Z=(O,C,U)=>{let j=C.map(de=>[de.identifier,x(de.identifier),ie(de.hiding),ie(de.binding)]);j.sort((de,be)=>de[1]<be[1]?-1:de[1]>be[1]?1:0);let re=[];for(let[de,be,xe,or]of j)re.push(r.toBytes(be),W(xe),W(or));let J=L(Ce(...re)),te=Ce(W(O),N(U),J),ae={};for(let[de,be]of j)ae[de]=v(Ce(te,r.toBytes(be)));let oe=t.ZERO,ue=[],_e=[];for(let[de,be,xe,or]of j){if(t.ZERO.equals(xe)||t.ZERO.equals(or))throw new Error("infinity commitment");oe=oe.add(xe),ue.push(or),_e.push(ae[de])}let Se=oe.add(R(ue,_e));return{identifiers:j.map(de=>de[1]),groupCommitment:Se,bindingFactors:ae}},le=(O,C,U,j)=>{let re=ge(ie(O)),J=x(j),{identifiers:te,groupCommitment:ae,bindingFactors:oe}=Z(re,C,U),ue=oe[j],_e=_(te,J),Se=D.challenge(ae,re,U);return{lambda:_e,challenge:Se,bindingFactor:ue,groupCommitment:ae}};Object.freeze(G);let se={Identifier:G,DKG:Object.freeze({round1:(O,C,U,j=Qt)=>{let re=x(O,"id");an(C);let{coefficients:J,commitment:te}=b(C,U,void 0,j),ae=k.compute(re,J,te,j),oe=te.map(W),ue={identifier:me(re),commitment:oe,proofOfKnowledge:ae},_e={identifier:re,coefficients:J,commitment:te.map(W),signers:{min:C.min,max:C.max},step:1};return{public:ue,secret:_e}},round2:(O,C)=>{if(qe(O,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),an(O.signers,"secret.signers"),rt(C,"others"),C.length!==O.signers.max-1)throw new Error("wrong number of round1 packages");if(!O.coefficients||O.step===3)throw new Error("round3 package used in round2");if(O.round2Cache!==void 0)return O.round2Cache;let U={};for(let j of C){if(j.commitment.length!==O.signers.min)throw new Error("wrong number of commitments");let re=x(j.identifier);if(re===O.identifier)throw new Error("duplicate id="+me(re));k.validate(re,j.commitment,j.proofOfKnowledge);for(let te of j.commitment)ie(te);if(U[j.identifier])throw new Error("Duplicate id="+re);let J=r.toBytes(A(re,O.coefficients));U[j.identifier]={identifier:me(O.identifier),signingShare:J}}return O.round2Cache=U,O.step=2,U},round3:(O,C,U)=>{if(qe(O,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),an(O.signers,"secret.signers"),rt(C,"round1"),rt(U,"round2"),C.length!==O.signers.max-1)throw new Error("wrong length of round1 packages");if(!O.coefficients||O.step!==2)throw new Error("round2 package used in round3");if(U.length!==C.length)throw new Error("wrong length of round2 packages");let j={};for(let de of C){if(!de.identifier||!de.commitment)throw new Error("wrong round1 share");j[de.identifier]={...de}}for(let de of U){if(!de.identifier||!de.signingShare)throw new Error("wrong round2 share");if(!j[de.identifier])throw new Error("round1 share for "+de.identifier+" is missing");j[de.identifier].signingShare=de.signingShare}if(Object.keys(j).length!==C.length)throw new Error("mismatch identifiers between rounds");let re=r.ZERO;if(O.commitment.length!==O.signers.min)throw new Error("wrong commitments length");let J=O.commitment.map(ie),te=A(O.identifier,O.coefficients);K(O.identifier,J,te);let ae=J.map(W),oe={[me(O.identifier)]:ae};for(let de in j){let be=j[de];if(!be.signingShare||!be.commitment)throw new Error("mismatch identifiers");let xe=x(de),or=r.fromBytes(be.signingShare),Ze=be.commitment.map(ie);K(O.identifier,Ze,or),re=r.add(re,or);let Ve=me(xe);if(oe[Ve])throw new Error("duplicated id="+Ve);oe[Ve]=be.commitment}re=r.add(re,te);let ue=new Array(O.signers.min).fill(t.ZERO);for(let de in oe){let be=oe[de];if(be.length!==O.signers.min)throw new Error("wrong commitments length");for(let xe=0;xe<be.length;xe++)ue[xe]=ue[xe].add(ie(be[xe]))}let _e=ue.map(W),Se={};for(let de in oe)Se[de]=W(c(x(de),ue));let fe={public:{signers:{min:O.signers.min,max:O.signers.max},commitments:_e,verifyingShares:Object.fromEntries(Object.entries(Se).map(([de,be])=>[de,be.slice()]))},secret:{identifier:me(O.identifier),signingShare:r.toBytes(re)}};e.adjustDKG&&(fe=e.adjustDKG(fe));for(let de=0;de<O.coefficients.length;de++)O.coefficients[de]-=O.coefficients[de];return delete O.coefficients,delete O.round2Cache,O.step=3,fe},clean(O){if(qe(O,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),O.identifier-=O.identifier,O.coefficients)for(let C=0;C<O.coefficients.length;C++)O.coefficients[C]-=O.coefficients[C];delete O.round2Cache,O.step=3}}),trustedDealer(O,C,U,j=Qt){if(an(O),C===void 0){C=[];for(let ue=1;ue<=O.max;ue++)C.push(G.fromNumber(ue))}else if(rt(C,"identifiers"),C.length!==O.max)throw new Error("identifiers should be array of "+O.max);let re={};for(let ue of C){let _e=x(ue);if(ue in re)throw new Error("duplicated id="+ue);re[ue]=_e}let J=b(O,U,void 0,j),te=J.commitment.map(W),ae={},oe={};for(let ue of C){let _e=A(re[ue],J.coefficients);oe[ue]=W(t.BASE.multiply(_e)),ae[ue]={identifier:ue,signingShare:r.toBytes(_e)}}return{public:{signers:{min:O.min,max:O.max},commitments:te,verifyingShares:oe},secretShares:ae}},validateSecret(O,C){qe(O,{identifier:"string",signingShare:"object"},{},"secret"),we(O.signingShare,r.BYTES,"secret.signingShare"),qe(C,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),an(C.signers,"pub.signers"),rt(C.commitments,"pub.commitments");let U=x(O.identifier),j=C.commitments.map(ie),re=r.fromBytes(O.signingShare);K(U,j,re)},commit(O,C=Qt){if(qe(O,{identifier:"string",signingShare:"object"},{},"secret"),we(O.signingShare,r.BYTES,"secret.signingShare"),typeof C!="function")throw new TypeError('"rng" expected function, got type='+typeof C);let U=r.fromBytes(O.signingShare),j=X(U,C),re=X(U,C),J={hiding:r.toBytes(j),binding:r.toBytes(re)};return{nonces:J,commitments:ee(O.identifier,J)}},signShare(O,C,U,j,re){qe(O,{identifier:"string",signingShare:"object"},{},"secret"),we(O.signingShare,r.BYTES,"secret.signingShare"),qe(C,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),an(C.signers,"pub.signers"),rt(C.commitments,"pub.commitments"),qe(U,{hiding:"object",binding:"object"},{},"nonces"),we(U.hiding,r.BYTES,"nonces.hiding"),we(U.binding,r.BYTES,"nonces.binding"),rt(j,"commitmentList"),we(re,void 0,"msg"),_w(C.signers,j.length);let J=r.fromBytes(U.hiding),te=r.fromBytes(U.binding);if(r.is0(J)||r.is0(te))throw new Error("signing nonces already used");let ae={identifier:O.identifier,hiding:W(t.BASE.multiply(J)),binding:W(t.BASE.multiply(te))},oe=j.find(Je=>Je.identifier===O.identifier);if(!oe)throw new Error("missing signer commitment");if(Rn(oe.hiding)!==Rn(ae.hiding)||Rn(oe.binding)!==Rn(ae.binding))throw new Error("incorrect signer commitment");e.adjustSecret&&(O=e.adjustSecret(O,C)),e.adjustPublic&&(C=e.adjustPublic(C));let ue=r.fromBytes(O.signingShare),{lambda:_e,challenge:Se,bindingFactor:fe,groupCommitment:de}=le(C.commitments[0],j,re,O.identifier),be=e.adjustNonces?e.adjustNonces(de,U):U,xe=e.adjustNonces?r.fromBytes(be.hiding):J,or=e.adjustNonces?r.fromBytes(be.binding):te,Ze=r.mul(r.mul(_e,ue),Se),Ve=r.mul(or,fe),Ya=r.toBytes(r.add(r.add(xe,Ve),Ze));return U.hiding.fill(0),U.binding.fill(0),Ya},verifyShare(O,C,U,j,re){qe(O,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),an(O.signers,"pub.signers"),rt(O.commitments,"pub.commitments"),rt(C,"commitmentList"),we(U,void 0,"msg"),x(j),we(re,r.BYTES,"sigShare"),e.adjustPublic&&(O=e.adjustPublic(O));let J=C.find(or=>or.identifier===j);if(!J)throw new Error("cannot find identifier commitment");let te=ie(O.verifyingShares[j]),ae=ie(J.hiding),oe=ie(J.binding),{lambda:ue,challenge:_e,bindingFactor:Se,groupCommitment:fe}=le(O.commitments[0],C,U,j),de=ae.add(oe.multiplyUnsafe(Se));e.adjustGroupCommitmentShare&&(de=e.adjustGroupCommitmentShare(fe,de));let be=t.BASE.multiplyUnsafe(r.fromBytes(re)),xe=de.add(te.multiplyUnsafe(r.mul(_e,ue)));return be.equals(xe)},aggregate(O,C,U,j){qe(O,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),an(O.signers,"pub.signers"),rt(O.commitments,"pub.commitments"),rt(C,"commitmentList"),we(U,void 0,"msg"),qe(j,{},{},"sigShares");let re=O;e.adjustPublic&&(O=e.adjustPublic(O));try{_w(O.signers,C.length)}catch{throw new Yi("aggregation failed",[])}let J=C.map(_e=>_e.identifier),te=new Set;for(let _e of J){if(te.has(_e))throw new Yi("aggregation failed",[]);te.add(_e)}if(J.length!==Object.keys(j).length)throw new Yi("aggregation failed",[]);for(let _e of J)if(!(_e in j)||!(_e in O.verifyingShares))throw new Yi("aggregation failed",[]);let ae=ie(O.commitments[0]),{groupCommitment:oe}=Z(ae,C,U),ue=r.ZERO;for(let _e of J)ue=r.add(ue,r.fromBytes(j[_e]));if(!D.verify(U,oe,ue,ae)){let _e=[];for(let Se of J)this.verifyShare(re,C,U,Se,j[Se])||_e.push(Se);throw new Yi("aggregation failed",_e)}return u.encode(oe,ue)},sign(O,C){let U=r.fromBytes(C);e.adjustScalar&&(U=e.adjustScalar(U));let[j,re]=D.sign(O,U);return u.encode(j,re)},verify(O,C,U){let j=e.parsePublicKey?e.parsePublicKey(U):ie(U),{R:re,z:J}=u.decode(O);return D.verify(C,re,J,j)},combineSecret(O,C){if(rt(O,"shares"),an(C),O.length<C.min||O.length>C.max)throw new Error("wrong secret shares array");let U=[],j={};for(let te of O){let ae=x(te.identifier),oe=me(ae);if(j[oe])throw new Error("duplicated id="+oe);j[oe]=!0,U.push([ae,r.fromBytes(te.signingShare)])}let re=U.map(([te])=>te),J=r.ZERO;for(let[te,ae]of U)J=r.add(J,r.mul(ae,_(re,te)));return r.toBytes(J)},utils:Object.freeze({Fn:r,randomScalar:(O=Qt)=>r.toBytes(h(O).scalar),generateSecretPolynomial:(O,C,U,j)=>{let re=b(O,C,U,j);return{...re,commitment:re.commitment.map(W)}}})};return Object.freeze(se)}var an,_w,Yi,ww=Wt(()=>{p();An();ni();jf();lw();Wi();an=(e,t="signers")=>{if(qe(e,{min:"number",max:"number"},{},t),nt(e.min,t+".min"),nt(e.max,t+".max"),e.min<2||e.max<2||e.min>e.max)throw new Error("Wrong signers info: min="+e.min+" max="+e.max)},_w=(e,t)=>{if(t<e.min||t>e.max)throw new Error("Wrong number of commitments="+t)},Yi=class extends Error{constructor(r,n){super(r);$(this,"cheaters");this.cheaters=n}}});var Kf,Sw,Ew=Wt(()=>{p();An();Kf=class{constructor(t,r){$(this,"oHash");$(this,"iHash");$(this,"blockLen");$(this,"outputLen");$(this,"canXOF",!1);$(this,"finished",!1);$(this,"destroyed",!1);if(Sf(t),rn(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),ar(i)}update(t){return Uo(this),this.iHash.update(t),this}digestInto(t){Uo(this),Ef(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a,canXOF:f}=this;return t=t,t.finished=i,t.destroyed=o,t.blockLen=s,t.outputLen=a,t.canXOF=f,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Sw=(()=>{let e=((t,r,n)=>new Kf(t,r).update(n).digest());return e.create=(t,r)=>new Kf(t,r),e})()});var aM,Td,Tn,Pd,xw=Wt(()=>{p();ni();aM=BigInt(0),Td=class extends Error{constructor(t=""){super(t)}},Tn={Err:Td,_tlv:{encode:(e,t)=>{let{Err:r}=Tn;if(nt(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(ra(t,"data"),t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=na(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?na(i.length/2|128):"";return na(e)+o+i+t},decode(e,t){let{Err:r}=Tn;t=we(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.decode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],o=!!(i&128),s=0;if(!o)s=i;else{let f=i&127;if(!f)throw new r("tlv.decode(long): indefinite length not supported");if(f>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+f);if(l.length!==f)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let m of l)s=s<<8|m;if(n+=f,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=Tn;if(Cf(e),e<aM)throw new t("integer: negative integers are not allowed");let r=na(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Tn;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Mt(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Tn,i=we(e,void 0,"signature"),{v:o,l:s}=n.decode(48,i);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:f}=n.decode(2,o),{v:l,l:m}=n.decode(2,f);if(m.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=Tn;qe(e,{r:"bigint",s:"bigint"},{},"sig");let n=t.encode(2,r.encode(e.r)),i=t.encode(2,r.encode(e.s)),o=n+i;return t.encode(48,o)}},Pd=(Object.freeze(Tn._tlv),Object.freeze(Tn._int),Object.freeze(Tn))});function uM(e,t,r){yd("scalar",e,Pn,r);let[[n,i],[o,s]]=t,a=Iw(s*e,r),f=Iw(-i*e,r),l=e-a*n-f*o,m=-a*i-f*s,g=l<Pn,v=m<Pn;g&&(l=-l),v&&(m=-m);let E=ia(Math.ceil(Go(r)/2))+$i;if(l<Pn||l>=E||m<Pn||m>=E)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:g,k1:l,k2neg:v,k2:m}}function Md(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Bd(e,t){qe(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return on(r.lowS,"lowS"),on(r.prehash,"prehash"),r.format!==void 0&&Md(r.format),r}function Ow(e,t={}){let r=uw("weierstrass",e,t),n=r.Fp,i=r.Fn,o=r.CURVE,{h:s,n:a}=o;qe(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:f,allowInfinityPoint:l}=t,m=t.randomBytes===void 0?Qt:t.randomBytes;if(f&&(!n.is0(o.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let g=Tw(n,i);function v(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function E(R,A,_){if(l&&A.is0())return Uint8Array.of(0);let{x:c,y:b}=A.toAffine(),k=n.toBytes(c);if(on(_,"isCompressed"),_){v();let D=!n.isOdd(b);return Ce(Rw(D),k)}else return Ce(Uint8Array.of(4),k,n.toBytes(b))}function T(R){we(R,void 0,"Point");let{publicKey:A,publicKeyUncompressed:_}=g,c=R.length,b=R[0],k=R.subarray(1);if(l&&c===1&&b===0)return{x:n.ZERO,y:n.ZERO};if(c===A&&(b===2||b===3)){let D=n.fromBytes(k);if(!n.isValid(D))throw new Error("bad point: is not on curve, wrong x");let K=z(D),G;try{G=n.sqrt(K)}catch(le){let se=le instanceof Error?": "+le.message:"";throw new Error("bad point: is not on curve, sqrt error"+se)}v();let X=n.isOdd(G);return(b&1)===1!==X&&(G=n.neg(G)),{x:D,y:G}}else if(c===_&&b===4){let D=n.BYTES,K=n.fromBytes(k.subarray(0,D)),G=n.fromBytes(k.subarray(D,D*2));if(!W(K,G))throw new Error("bad point: is not on curve");return{x:K,y:G}}else throw new Error(`bad point: got length ${c}, expected compressed=${A} or uncompressed=${_}`)}let N=t.toBytes===void 0?E:t.toBytes,L=t.fromBytes===void 0?T:t.fromBytes,F=n.mul(o.b,Nd),V=n.is0(o.a)?R=>n.ZERO:R=>n.mul(o.a,R);function z(R){let A=n.sqr(R),_=n.mul(A,R);return n.add(n.add(_,n.mul(R,o.a)),o.b)}function W(R,A){let _=n.sqr(A),c=z(R);return n.eql(_,c)}if(!W(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let ie=n.mul(n.pow(o.a,Nd),fM),ee=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(ie,ee)))throw new Error("bad curve params: a or b");function ge(R,A,_=!1){if(!n.isValid(A)||_&&n.is0(A))throw new Error(`bad point coordinate ${R}`);return A}function ce(R){if(!(R instanceof h))throw new Error("Weierstrass Point expected")}function me(R){if(!f||!f.basises)throw new Error("no endo");return uM(R,f.basises,i.ORDER)}function x(R,A,_,c){if(!i.isValid(c))throw new RangeError("invalid scalar: out of range");if(f){let{k1neg:b,k1:k,k2neg:D,k2:K}=me(c),G=new h(n.mul(_.X,f.beta),_.Y,_.Z);R.push(b?_.negate():_,D?G.negate():G),A.push(k,K)}else R.push(_),A.push(c)}let u=new WeakSet,S=class S{constructor(A,_,c){$(this,"X");$(this,"Y");$(this,"Z");this.X=ge("x",A),this.Y=ge("y",_,!0),this.Z=ge("z",c),Object.freeze(this)}static CURVE(){return o}static fromAffine(A){let{x:_,y:c}=A||{};if(!A||!n.isValid(_)||!n.isValid(c))throw new Error("invalid affine point");if(A instanceof S)throw new Error("projective point not allowed");return n.is0(_)&&n.is0(c)?S.ZERO:new S(_,c,n.ONE)}static fromBytes(A){let _=S.fromAffine(L(we(A,void 0,"point")));return _.assertValidity(),_}static fromHex(A){return S.fromBytes(jo(A))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(A=6,_=!0){return w.setWindowSize(this,A),_||this.multiply(Nd),this}assertValidity(){let A=this;if(A.is0()){if(t.allowInfinityPoint&&n.is0(A.X)&&n.eql(A.Y,n.ONE)&&n.is0(A.Z))return;throw new Error("bad point: ZERO")}if(u.has(A))return;let{x:_,y:c}=A.toAffine();if(!n.isValid(_)||!n.isValid(c))throw new Error("bad point: x or y not field elements");if(!W(_,c))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");u.add(A)}hasEvenY(){let{y:A}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(A)}equals(A){ce(A);let{X:_,Y:c,Z:b}=this,{X:k,Y:D,Z:K}=A,G=n.eql(n.mul(_,K),n.mul(k,b)),X=n.eql(n.mul(c,K),n.mul(D,b));return G&&X}negate(){return new S(this.X,n.neg(this.Y),this.Z)}double(){let{X:A,Y:_,Z:c}=this,b=n.ZERO,k=n.ZERO,D=n.ZERO,K=n.mul(A,A),G=n.mul(_,_),X=n.mul(c,c),Z=n.mul(A,_);return Z=n.add(Z,Z),D=n.mul(A,c),D=n.add(D,D),b=V(D),k=n.mul(F,X),k=n.add(b,k),b=n.sub(G,k),k=n.add(G,k),k=n.mul(b,k),b=n.mul(Z,b),D=n.mul(F,D),X=V(X),Z=n.sub(K,X),Z=V(Z),Z=n.add(Z,D),D=n.add(K,K),K=n.add(D,K),K=n.add(K,X),K=n.mul(K,Z),k=n.add(k,K),X=n.mul(_,c),X=n.add(X,X),K=n.mul(X,Z),b=n.sub(b,K),D=n.mul(X,G),D=n.add(D,D),D=n.add(D,D),new S(b,k,D)}add(A){ce(A);let{X:_,Y:c,Z:b}=this,{X:k,Y:D,Z:K}=A,G=n.ZERO,X=n.ZERO,Z=n.ZERO,le=n.mul(_,k),se=n.mul(c,D),O=n.mul(b,K),C=n.add(_,c),U=n.add(k,D);C=n.mul(C,U),U=n.add(le,se),C=n.sub(C,U),U=n.add(_,b);let j=n.add(k,K);return U=n.mul(U,j),j=n.add(le,O),U=n.sub(U,j),j=n.add(c,b),G=n.add(D,K),j=n.mul(j,G),G=n.add(se,O),j=n.sub(j,G),Z=V(U),G=n.mul(F,O),Z=n.add(G,Z),G=n.sub(se,Z),Z=n.add(se,Z),X=n.mul(G,Z),se=n.add(le,le),se=n.add(se,le),O=V(O),U=n.mul(F,U),se=n.add(se,O),O=n.sub(le,O),O=V(O),U=n.add(U,O),le=n.mul(se,U),X=n.add(X,le),le=n.mul(j,U),G=n.mul(C,G),G=n.sub(G,le),le=n.mul(C,se),Z=n.mul(j,Z),Z=n.add(Z,le),new S(G,X,Z)}subtract(A){return ce(A),this.add(A.negate())}is0(){return this.equals(S.ZERO)}multiply(A){if(!i.isValidNot0(A))throw new RangeError("invalid scalar: out of range");let{p:_,f:c}=w.mulSecret(this,A,s,y);return y([_,c])[0]}multiplyUnsafe(A){let _=this,c=A;if(!i.isValid(c))throw new RangeError("invalid scalar: out of range");if(c===Pn||_.is0())return S.ZERO;if(c===$i)return _;if(w.hasWindowSize(this))return w.mulUnsafe(_,c,y);let b=[],k=[];return x(b,k,_,c),Yo(S,b,k)}mulAddUnsafe(A,_,c){ce(_);let b=[],k=[];return x(b,k,this,A),x(b,k,_,c),Yo(S,b,k)}toAffine(A){let _=this,c=A;if(c!=null&&!n.isValid(c))throw new RangeError('"invertedZ" expected valid field element');let{X:b,Y:k,Z:D}=_;if(n.eql(D,n.ONE))return{x:b,y:k};let K=_.is0();c==null&&(c=K?n.ONE:n.inv(D));let G=n.mul(b,c),X=n.mul(k,c),Z=n.mul(D,c);if(K)return{x:n.ZERO,y:n.ZERO};if(!n.eql(Z,n.ONE))throw new Error("invZ was invalid");return{x:G,y:X}}isTorsionFree(){let{isTorsionFree:A}=t;return s===$i?!0:A?A(S,this):w.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:A}=t;return s===$i?this:A?A(S,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===$i?this.is0():this.clearCofactor().is0()}toBytes(A=!0){return on(A,"isCompressed"),this.assertValidity(),N(S,this,A)}toHex(A=!0){return Rn(this.toBytes(A))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};$(S,"BASE",new S(o.Gx,o.Gy,n.ONE)),$(S,"ZERO",new S(n.ZERO,n.ONE,n.ZERO)),$(S,"Fp",n),$(S,"Fn",i);let h=S,y=R=>ow(h,R),w=new Ff(h,m);return w.bits>=6&&h.BASE.precompute(6),Object.freeze(h.prototype),Object.freeze(h),h}function Rw(e){return Uint8Array.of(e?2:3)}function Tw(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function cM(e,t={}){oi(e);let{Fn:r}=e,n=t.randomBytes===void 0?Qt:t.randomBytes,i=Object.assign(Tw(e.Fp,r),{seed:Math.max(zo(r.ORDER),16)});function o(E){try{let T=r.fromBytes(E);return r.isValidNot0(T)}catch{return!1}}function s(E,T){let{publicKey:N,publicKeyUncompressed:L}=i;try{let F=E.length;return T===!0&&F!==N||T===!1&&F!==L?!1:!!e.fromBytes(E)}catch{return!1}}function a(E){return E=E===void 0?n(i.seed):E,Vi(we(E,i.seed,"seed"),r.ORDER)}function f(E,T=!0){return e.BASE.multiply(r.fromBytes(E)).toBytes(T)}function l(E){let{secretKey:T,publicKey:N,publicKeyUncompressed:L}=i,F=r._lengths;if(!nn(E))return;let V=we(E,void 0,"key").length,z=V===N||V===L,W=V===T||!!F?.includes(V);if(!(z&&W))return z}function m(E,T,N=!0){if(l(E)===!0)throw new Error("first arg must be private key");if(l(T)===!1)throw new Error("second arg must be public key");let L=r.fromBytes(E);return e.fromBytes(T).multiply(L).toBytes(N)}let g={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},v=qf(a,f);return Object.freeze(g),Object.freeze(i),Object.freeze({getPublicKey:f,getSharedSecret:m,keygen:v,Point:e,utils:g,lengths:i})}function Pw(e,t,r={}){oi(e);let n=t;Sf(n),qe(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let i=Object.assign({},r),o=i.randomBytes===void 0?Qt:i.randomBytes,s=i.hmac===void 0?(b,k)=>Sw(n,b,k):i.hmac,{Fp:a,Fn:f}=e,{ORDER:l,BITS:m}=f,g=zo(l),v=Id(o,g),{keygen:E,getPublicKey:T,getSharedSecret:N,utils:L,lengths:F}=cM(e,i),V={prehash:!0,lowS:typeof i.lowS=="boolean"?i.lowS:!0,format:"compact",extraEntropy:!1},z=l*Aw+$i<a.ORDER;function W(b){let k=l>>$i;return b>k}function ie(b,k){if(!f.isValidNot0(k))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return k}function ee(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function ge(b,k,D){return ee(),(b===D?0:2)|Number(a.isOdd(k))}function ce(){if(z)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function me(b,k){Md(k);let D=F.signature,K=k==="compact"?D:k==="recovered"?D+1:void 0;return we(b,K)}class x{constructor(k,D,K){$(this,"r");$(this,"s");$(this,"recovery");if(this.r=ie("r",k),this.s=ie("s",D),K!=null){if(ce(),![0,1,2,3].includes(K))throw new Error("invalid recovery id");this.recovery=K}Object.freeze(this)}static fromBytes(k,D=V.format){me(k,D);let K;if(D==="der"){let{r:le,s:se}=Pd.toSig(we(k));return new x(le,se)}D==="recovered"&&(K=k[0],D="compact",k=k.subarray(1));let G=F.signature/2,X=k.subarray(0,G),Z=k.subarray(G,G*2);return new x(f.fromBytes(X),f.fromBytes(Z),K)}static fromHex(k,D){return this.fromBytes(jo(k),D)}assertRecovery(){let{recovery:k}=this;if(k==null)throw new Error("invalid recovery id: must be present");return k}addRecoveryBit(k){return new x(this.r,this.s,k)}recoverPublicKey(k){let{r:D,s:K}=this,G=this.assertRecovery(),X=G===2||G===3?D+l:D;if(!a.isValid(X))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let Z=a.toBytes(X),le=e.fromBytes(Ce(Rw((G&1)===0),Z)),se=f.inv(X),O=h(we(k,void 0,"msgHash")),C=f.create(-O*se),U=f.create(K*se),j=e.BASE.mulAddUnsafe(C,le,U);if(j.is0())throw new Error("invalid recovery: point at infinify");return j.assertValidity(),j}hasHighS(){return W(this.s)}toBytes(k=V.format){if(Md(k),k==="der")return jo(Pd.hexFromSig(this));let{r:D,s:K}=this,G=f.toBytes(D),X=f.toBytes(K);return k==="recovered"?(ce(),Ce(Uint8Array.of(this.assertRecovery()),G,X)):Ce(G,X)}toHex(k){return Rn(this.toBytes(k))}}Object.freeze(x.prototype),Object.freeze(x);let u=i.bits2int===void 0?function(k){if(k.length>8192)throw new Error("input is too large");let D=Mt(k),K=k.length*8-m;return K>0?D>>BigInt(K):D}:i.bits2int,h=i.bits2int_modN===void 0?function(k){return f.create(u(k))}:i.bits2int_modN,y=ia(m);function w(b){return yd("num < 2^"+m,b,Pn,y),f.toBytes(b)}function S(b,k){return we(b,void 0,"message"),k?we(n(b),void 0,"prehashed message"):b}function R(b,k,D){let{lowS:K,prehash:G,extraEntropy:X}=Bd(D,V);b=S(b,G);let Z=h(b),le=f.fromBytes(k);if(!f.isValidNot0(le))throw new Error("invalid private key");let se=[w(le),w(Z)];if(X!=null&&X!==!1){let j=X===!0?o(F.secretKey):X;se.push(we(j,void 0,"extraEntropy"))}let O=Ce(...se),C=Z;function U(j){let re=u(j);if(!f.isValidNot0(re))return;let J=e.BASE.multiply(re).toAffine(),te=f.create(J.x);if(te===Pn)return;let ae;if(v!==void 0){let _e=Mt(Vi(v(g),l)),Se=f.inv(f.mul(_e,re)),fe=f.mul(_e,C),de=f.mul(_e,le);ae=f.create(Se*f.create(fe+de*te))}else{let _e=J_(re,l);ae=f.create(_e*f.create(C+te*le))}if(ae===Pn)return;let oe=ge(J.x,J.y,te),ue=ae;return K&&W(ae)&&(ue=f.neg(ae),oe^=1),new x(te,ue,z?void 0:oe)}return{seed:O,k2sig:U}}function A(b,k,D={}){let{seed:K,k2sig:G}=R(b,k,D);return G_(n.outputLen,f.BYTES,s)(K,G).toBytes(D.format)}function _(b,k,D,K={}){let{lowS:G,prehash:X,format:Z}=Bd(K,V);if(D=we(D,void 0,"publicKey"),k=S(k,X),!nn(b)){let le=b instanceof x?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+le)}me(b,Z);try{let le=x.fromBytes(b,Z),se=e.fromBytes(D);if(G&&le.hasHighS())return!1;let{r:O,s:C}=le,U=h(k),j=f.inv(C),re=f.create(U*j),J=f.create(O*j),te=e.BASE.mulAddUnsafe(re,se,J);if(te.is0())return!1;let ae=te.toAffine();return!(f.create(ae.x)!==O||Z==="recovered"&&le.recovery!==ge(ae.x,ae.y,O))}catch{return!1}}function c(b,k,D={}){let{prehash:K}=Bd(D,V);return k=S(k,K),x.fromBytes(b,"recovered").recoverPublicKey(k).toBytes()}return Object.freeze({keygen:E,getPublicKey:T,getSharedSecret:N,utils:L,lengths:F,Point:e,sign:A,verify:_,recoverPublicKey:c,Signature:x,hash:n})}var Iw,Pn,$i,Aw,Nd,fM,Bw=Wt(()=>{p();Ew();An();ni();jf();xw();Wi();Iw=(e,t)=>(e+(e>=0?t:-t)/Aw)/t;Pn=BigInt(0),$i=BigInt(1),Aw=BigInt(2),Nd=BigInt(3),fM=BigInt(4)});var Kw={};ol(Kw,{__TEST:()=>gM,schnorr:()=>yM,schnorr_FROST:()=>wM,secp256k1:()=>dM,secp256k1_FROST:()=>bM,secp256k1_hasher:()=>Ld});function hM(e){let t=Gf.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),f=BigInt(88),l=e*e*e%t,m=l*l*e%t,g=hr(m,r,t)*m%t,v=hr(g,r,t)*m%t,E=hr(v,Nw,t)*l%t,T=hr(E,i,t)*E%t,N=hr(T,o,t)*T%t,L=hr(N,a,t)*N%t,F=hr(L,f,t)*L%t,V=hr(F,a,t)*N%t,z=hr(V,r,t)*m%t,W=hr(z,s,t)*T%t,ie=hr(W,n,t)*l%t,ee=hr(ie,Nw,t);if(!kr.eql(kr.sqr(ee),e))throw new Error("Cannot find square root");return ee}function sa(e,...t){let r=Mw[e];if(r===void 0){let n=ei(Ko(e));r=Ce(n,n),Mw[e]=r}return ei(Ce(r,...t))}function Dw(e){let{Fn:t,BASE:r}=je,n=t.fromBytes(we(e,32,"secretKey")),o=r.multiply(n).toAffine();return{scalar:un(o.y)?n:t.neg(n),bytes:Lw(o)}}function Vf(e){let t=kr;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x \u2265 p");let r=t.sqr(e),n=t.add(t.mulN(r,e),BigInt(7)),i=t.sqrt(n);un(i)||(i=t.neg(i));let o=je.fromAffine({x:e,y:i});return o.assertValidity(),o}function Cd(...e){return je.Fn.create($o(sa("BIP0340/challenge",...e)))}function kw(e){return Dw(e).bytes}function pM(e,t,r=ta(32)){let{Fn:n,BASE:i}=je,o=we(e,void 0,"message"),{bytes:s,scalar:a}=Dw(t),f=we(r,32,"auxRand"),l=n.toBytes(a^$o(sa("BIP0340/aux",f))),m=sa("BIP0340/nonce",l,s,o),g=n.create($o(m));if(g===kd)throw new Error("sign failed: k is zero");let E=i.multiply(g).toAffine(),T=un(E.y)?g:n.neg(g),N=Lw(E),L=Cd(N,s,o),F=new Uint8Array(64);if(F.set(N,0),F.set(n.toBytes(n.create(T+L*a)),32),!Uw(F,o,s))throw new Error("sign: Invalid signature produced");return F}function Uw(e,t,r){let{Fp:n,Fn:i,BASE:o}=je,s=we(e,64,"signature"),a=we(t,void 0,"message"),f=we(r,32,"publicKey");try{let l=Vf($o(f)),m=s.subarray(0,32),g=$o(m);if(!n.isValidNot0(g))return!1;let v=$o(s.subarray(32,64));if(!i.isValidNot0(v))return!1;let E=Cd(m,aa(l),a),T=o.mulAddUnsafe(v,l,i.neg(E)),{x:N,y:L}=T.toAffine();return!(T.is0()||!un(L)||!n.eql(N,g))}catch{return!1}}function Fw(e,t){if(t===void 0)return kd;let r=aa(e),n=Mt(sa("TapTweak",r,t));if(!je.Fn.isValid(n))throw new Error("invalid TapTweak hash");return n}function Dd(e){let t=je.fromBytes(e.commitments[0]);return un(t.y)?e:{signers:{min:e.signers.min,max:e.signers.max},commitments:e.commitments.map(r=>je.fromBytes(r).negate().toBytes()),verifyingShares:Object.fromEntries(Object.entries(e.verifyingShares).map(([r,n])=>[r,je.fromBytes(n).negate().toBytes()]))}}function qw(e,t){let r=je.fromBytes(t.commitments[0]);if(un(r.y))return e;let n=je.Fn;return{...e,signingShare:n.toBytes(n.neg(n.fromBytes(e.signingShare)))}}function _M(e,t){if(un(e.y))return t;let r=je.Fn;return{binding:r.toBytes(r.neg(r.fromBytes(t.binding))),hiding:r.toBytes(r.neg(r.fromBytes(t.hiding)))}}function jw(e,t,r){let n=je.Fn,i=qw(e,t),o=Dd(t),s=Fw(je.fromBytes(o.commitments[0]),r),a=n.toBytes(n.add(n.fromBytes(i.signingShare),s));return{identifier:i.identifier,signingShare:a}}function Hw(e,t){let r=Dd(e),n=Fw(je.fromBytes(r.commitments[0]),t);if(n===kd)return r;let i=je.BASE.multiply(n),o=r.commitments.map((a,f)=>(f===0?je.fromBytes(a).add(i):je.fromBytes(a)).toBytes()),s={};for(let a in r.verifyingShares)s[a]=je.fromBytes(r.verifyingShares[a]).add(i).toBytes();return{signers:{min:r.signers.min,max:r.signers.max},commitments:o,verifyingShares:s}}var Gf,lM,kd,Nw,kr,je,dM,Mw,aa,Lw,un,$o,gM,yM,mM,Cw,vM,Ld,bM,wM,Gw=Wt(()=>{p();hd();An();jf();ww();bw();Wi();Bw();ni();Gf={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},lM={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},kd=BigInt(0),Nw=BigInt(2);kr=Wo(Gf.p,{sqrt:hM}),je=Ow(Gf,{Fp:kr,endo:lM}),dM=Pw(je,ei),Mw=Object.create(null);aa=e=>e.toBytes(!0).slice(1),Lw=({x:e})=>kr.toBytes(e),un=e=>!kr.isOdd(e);$o=Mt;gM=Object.freeze({lift_x:Vf,frostTweakPublic:Hw,frostTweakSecret:jw}),yM=(()=>{let r=n=>(n=n===void 0?ta(48):n,Vi(we(n,48,"seed"),Gf.n));return Object.freeze({keygen:qf(r,kw),getPublicKey:kw,sign:pM,verify:Uw,Point:je,utils:Object.freeze({randomSecretKey:r,taggedHash:sa,lift_x:Vf,pointToBytes:aa}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),mM=yw(kr,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),vM=()=>Cw||(Cw=vw(kr,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:kr.create(BigInt("-11"))})),Ld=mw(je,e=>{let{x:t,y:r}=vM()(kr.create(e[0]));return mM(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:kr.ORDER,m:1,k:128,expand:"xmd",hash:ei}),bM=Rd({name:"FROST-secp256k1-SHA256-v1",Point:je,hashToScalar:Ld.hashToScalar,hash:ei});wM=Rd({name:"FROST-secp256k1-SHA256-TR-v1",Point:je,hashToScalar:Ld.hashToScalar,hash:ei,parsePublicKey(e){if(e.length===32)return Vf(Mt(e));if(e.length===33)return je.fromBytes(e);throw new Error(`expected x-only or compressed public key, got length=${e.length}`)},adjustScalar(e){let t=je.BASE.multiply(e);return un(t.y)?e:je.Fn.neg(e)},adjustPoint:e=>un(e.y)?e:e.negate(),challenge(e,t,r){return Cd(aa(e),aa(t),r)},adjustNonces:_M,adjustGroupCommitmentShare:(e,t)=>un(e.y)?t:t.negate(),adjustPublic:Dd,adjustSecret:qw,adjustTx:{encode:e=>e.subarray(1),decode:e=>Ce(Uint8Array.of(2),e)},adjustDKG:e=>{let t=new Uint8Array(0);return{public:Hw(e.public,t),secret:jw(e.secret,e.public,t)}}})});var ai=P((iF,Yw)=>{"use strict";p();var Vw=Sr(),{secp256k1:SM}=(Gw(),sl(Kw)),fa=SM.Point,Wf=fa.Fn.ORDER;function EM(e){return BigInt("0x"+(e.toString(16)||"0"))}function Ud(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new Vw(t,16)}function zf(e){if(e==null)throw new Error("Invalid Point");if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(e);if(typeof e=="string")return BigInt(e.indexOf("0x")===0?e:"0x"+e);if(typeof e.toString=="function")return EM(e);throw new Error("Invalid Point")}function ua(e){var t=Object.create(He.prototype);return t._p=e,t}function Ww(e,t){var r=zf(t).toString(16).padStart(64,"0");return fa.fromHex((e?"03":"02")+r)}function zw(e,t){var r;try{r=Ww((t&1n)===1n,e)}catch{throw new Error("Point does not lie on the curve")}if(r.toAffine().y!==t)throw new Error("Invalid y value for curve.")}function He(e,t,r){if(!(this instanceof He))return new He(e,t,r);var n,i;try{n=zf(e),i=zf(t)}catch{throw new Error("Invalid Point")}zw(n,i);try{this._p=fa.fromAffine({x:n,y:i})}catch{throw new Error("Invalid Point")}return this}He.fromX=function(t,r){try{var n=ua(Ww(t,r))}catch{throw new Error("Invalid X")}return n.validate(),n};He.getG=function(){return ua(fa.BASE)};He.getN=function(){return Ud(Wf)};He.prototype.getX=function(){return Ud(this._p.toAffine().x)};He.prototype.getY=function(){return Ud(this._p.toAffine().y)};Object.defineProperty(He.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}});Object.defineProperty(He.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}});He.prototype.mul=function(t){var r=(zf(t)%Wf+Wf)%Wf;return r===0n||this._p.is0()?ua(fa.ZERO):ua(this._p.multiply(r))};He.prototype.add=function(t){return ua(this._p.add(t._p))};He.prototype.mulAdd=function(t,r,n){return this.mul(t).add(r.mul(n))};He.prototype.eq=function(t){return this._p.equals(t._p)};He.prototype.isInfinity=function(){return this._p.is0()};He.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t=this._p.toAffine();return zw(t.x,t.y),this};He.pointToCompressed=function(t){var r=t.getX().toBuffer({size:32}),n=t.getY().toBuffer({size:32}),i,o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])};He.pointFromCompressed=function(e){if(e.length!==33)throw new Error("invalid buffer length");var t=e[0],r;if(t===3)r=!0;else if(t===2)r=!1;else throw new Error("invalid value of compressed prefix");var n=Vw.fromBuffer(e.slice(1,33));return He.fromX(r,n)};He.prototype.toBuffer=function(){return He.pointToCompressed(this)};He.prototype.toHex=function(){return this.toBuffer().toString("hex")};He.fromBuffer=function(e){return He.pointFromCompressed(e)};He.fromHex=function(e){return He.fromBuffer(d.Buffer.from(e,"hex"))};Yw.exports=He});var Zw=P((sF,$w)=>{"use strict";p();var Yf=Zs(),Bn=Le(),Rt=$w.exports;Rt.sha1=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Yf.createHash("sha1").update(e).digest()};Rt.sha1.blocksize=512;Rt.sha256=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Yf.createHash("sha256").update(e).digest()};Rt.sha256.blocksize=512;Rt.sha256sha256=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Rt.sha256(Rt.sha256(e))};Rt.ripemd160=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Yf.createHash("ripemd160").update(e).digest()};Rt.sha256ripemd160=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Rt.ripemd160(Rt.sha256(e))};Rt.sha512=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Yf.createHash("sha512").update(e).digest()};Rt.sha512.blocksize=1024;Rt.hmac=function(e,t,r){Bn.checkArgument(d.Buffer.isBuffer(t)),Bn.checkArgument(d.Buffer.isBuffer(r)),Bn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),f=d.Buffer.alloc(n),l=0;l<n;l++)a[l]=o[l]^r[l],f[l]=s[l]^r[l];return e(d.Buffer.concat([a,e(d.Buffer.concat([f,t]))]))};Rt.sha256hmac=function(e,t){return Rt.hmac(Rt.sha256,e,t)};Rt.sha512hmac=function(e,t){return Rt.hmac(Rt.sha512,e,t)}});var nS={};ol(nS,{_MD5:()=>Jf,_RIPEMD160:()=>Qf,_SHA1:()=>Xf,md5:()=>RM,ripemd160:()=>CM,sha1:()=>xM});function Xw(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}var Zo,ui,Xf,xM,IM,AM,$f,Fd,OM,Jf,RM,TM,Jw,PM,Qw,eS,tS,rS,BM,NM,MM,kM,Zf,Qf,CM,iS=Wt(()=>{p();ld();An();Zo=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),ui=new Uint32Array(80),Xf=class extends On{constructor(){super(64,20,8,!1);$(this,"A",Zo[0]|0);$(this,"B",Zo[1]|0);$(this,"C",Zo[2]|0);$(this,"D",Zo[3]|0);$(this,"E",Zo[4]|0)}get(){let{A:r,B:n,C:i,D:o,E:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let l=0;l<16;l++,n+=4)ui[l]=r.getUint32(n,!1);for(let l=16;l<80;l++)ui[l]=xn(ui[l-3]^ui[l-8]^ui[l-14]^ui[l-16],1);let{A:i,B:o,C:s,D:a,E:f}=this;for(let l=0;l<80;l++){let m,g;l<20?(m=Fo(o,s,a),g=1518500249):l<40?(m=o^s^a,g=1859775393):l<60?(m=Af(o,s,a),g=2400959708):(m=o^s^a,g=3395469782);let v=xn(i,5)+m+f+g+ui[l]|0;f=a,a=s,s=xn(o,30),o=i,i=v}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,f=f+this.E|0,this.set(i,o,s,a,f)}roundClean(){ar(ui)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0),ar(this.buffer)}},xM=Mr(()=>new Xf),IM=Math.pow(2,32),AM=Array.from({length:64},(e,t)=>Math.floor(IM*Math.abs(Math.sin(t+1)))),$f=Zo.slice(0,4),Fd=new Uint32Array(16),OM=(()=>{let e=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];return Uint8Array.from({length:64},(t,r)=>e[Math.floor(r/16)][r%4])})(),Jf=class extends On{constructor(){super(64,16,8,!0);$(this,"A",$f[0]|0);$(this,"B",$f[1]|0);$(this,"C",$f[2]|0);$(this,"D",$f[3]|0)}get(){let{A:r,B:n,C:i,D:o}=this;return[r,n,i,o]}set(r,n,i,o){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let f=0;f<16;f++,n+=4)Fd[f]=r.getUint32(n,!0);let{A:i,B:o,C:s,D:a}=this;for(let f=0;f<64;f++){let l,m;f<16?(l=Fo(o,s,a),m=f):f<32?(l=Fo(a,o,s),m=(5*f+1)%16):f<48?(l=o^s^a,m=(3*f+5)%16):(l=s^(o|~a),m=7*f%16),l=l+i+AM[f]+Fd[m],i=a,a=s,s=o,o=o+xn(l,OM[f])}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,this.set(i,o,s,a)}roundClean(){ar(Fd)}destroy(){this.destroyed=!0,this.set(0,0,0,0),ar(this.buffer)}},RM=Mr(()=>new Jf),TM=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Jw=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),PM=Jw.map(e=>(9*e+5)%16),Qw=(()=>{let r=[[Jw],[PM]];for(let n=0;n<4;n++)for(let i of r)i.push(i[n].map(o=>TM[o]));return r})(),eS=Qw[0],tS=Qw[1],rS=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),BM=eS.map((e,t)=>e.map(r=>rS[t][r])),NM=tS.map((e,t)=>e.map(r=>rS[t][r])),MM=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),kM=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);Zf=new Uint32Array(16),Qf=class extends On{constructor(){super(64,20,8,!0);$(this,"h0",1732584193);$(this,"h1",-271733879);$(this,"h2",-1732584194);$(this,"h3",271733878);$(this,"h4",-1009589776)}get(){let{h0:r,h1:n,h2:i,h3:o,h4:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.h0=r|0,this.h1=n|0,this.h2=i|0,this.h3=o|0,this.h4=s|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let T=0;T<16;T++,n+=4)Zf[T]=r.getUint32(n,!0);let i=this.h0|0,o=i,s=this.h1|0,a=s,f=this.h2|0,l=f,m=this.h3|0,g=m,v=this.h4|0,E=v;for(let T=0;T<5;T++){let N=4-T,L=MM[T],F=kM[T],V=eS[T],z=tS[T],W=BM[T],ie=NM[T];for(let ee=0;ee<16;ee++){let ge=xn(i+Xw(T,s,f,m)+Zf[V[ee]]+L,W[ee])+v|0;i=v,v=m,m=xn(f,10)|0,f=s,s=ge}for(let ee=0;ee<16;ee++){let ge=xn(o+Xw(N,a,l,g)+Zf[z[ee]]+F,ie[ee])+E|0;o=E,E=g,g=xn(l,10)|0,l=a,a=ge}}this.set(this.h1+f+g|0,this.h2+m+E|0,this.h3+v+o|0,this.h4+i+a|0,this.h0+s+l|0)}roundClean(){ar(Zf)}destroy(){this.destroyed=!0,ar(this.buffer),this.set(0,0,0,0,0)}},CM=Mr(()=>new Qf)});var sS=P((hF,oS)=>{"use strict";p();var{sha256:LM,sha512:DM}=(hd(),sl(j_)),{sha1:UM,ripemd160:FM}=(iS(),sl(nS)),Nn=Le(),Tt=oS.exports;Tt.sha1=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(UM(e))};Tt.sha1.blocksize=512;Tt.sha256=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(LM(e))};Tt.sha256.blocksize=512;Tt.sha256sha256=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),Tt.sha256(Tt.sha256(e))};Tt.ripemd160=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(FM(e))};Tt.sha256ripemd160=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),Tt.ripemd160(Tt.sha256(e))};Tt.sha512=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(DM(e))};Tt.sha512.blocksize=1024;Tt.hmac=function(e,t,r){Nn.checkArgument(d.Buffer.isBuffer(t)),Nn.checkArgument(d.Buffer.isBuffer(r)),Nn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),f=d.Buffer.alloc(n),l=0;l<n;l++)a[l]=o[l]^r[l],f[l]=s[l]^r[l];return e(d.Buffer.concat([a,e(d.Buffer.concat([f,t]))]))};Tt.sha256hmac=function(e,t){return Tt.hmac(Tt.sha256,e,t)};Tt.sha512hmac=function(e,t){return Tt.hmac(Tt.sha512,e,t)}});var Jt=P((pF,uS)=>{"use strict";p();var aS={sha1:"a9993e364706816aba3e25717850c26c9cd0d89d",sha256:"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",sha512:"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",ripemd160:"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"};function qM(){var e;try{e=Zs()}catch{return!1}if(!e||typeof e.createHash!="function")return!1;for(var t=Object.keys(aS),r=0;r<t.length;r++){var n=t[r];try{if(e.createHash(n).update("abc").digest("hex")!==aS[n])return!1}catch{return!1}}return!0}uS.exports=qM()?Zw():sS()});var dr=P((yF,lS)=>{"use strict";p();var cS=ze(),jM=Le(),fS=function(t){return cS.isString(t)?/^[0-9a-fA-F]+$/.test(t):!1};lS.exports={isValidJSON:function(t){var r;if(!cS.isString(t))return!1;try{r=JSON.parse(t)}catch{return!1}return typeof r=="object"},isHexa:fS,isHexaString:fS,defineImmutable:function(t,r){return Object.keys(r).forEach(function(n){Object.defineProperty(t,n,{configurable:!1,enumerable:!0,value:r[n]})}),t},isNaturalNumber:function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){jM.checkArgumentType(t,"number","integer");let r=d.Buffer.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}});var pa=P((vF,pS)=>{"use strict";p();var Mn=ze(),ca=dr(),Zi=[],la={};function hS(){}hS.prototype.toString=function(){return this.name};function ha(e,t){if(~Zi.indexOf(e))return e;if(t){Mn.isArray(t)||(t=[t]);for(var r=0;r<Zi.length;r++){var n=Zi[r],i=Mn.pick(n,t),o=Mn.values(i);if(~o.indexOf(e))return n}return}return la[e]}function ec(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&31);return t}function da(e){var t=new hS;ca.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey});var r=e.indexBy||Object.keys(e);return e.cashAddrPrefix&&Mn.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:ec(e.cashAddrPrefix)}),e.networkMagic&&Mn.extend(t,{networkMagic:ca.integerAsBuffer(e.networkMagic)}),e.port&&Mn.extend(t,{port:e.port}),e.dnsSeeds&&Mn.extend(t,{dnsSeeds:e.dnsSeeds}),Zi.push(t),HM(t,r),t}function HM(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=e[n];!Mn.isUndefined(i)&&!Mn.isObject(i)&&(la[i]=e)}}function KM(e,t){for(var r=0;r<t.length;r++){var n=t[r];la[n]===e&&delete la[n]}}function GM(e){for(var t=0;t<Zi.length;t++)Zi[t]===e&&Zi.splice(t,1);KM(e,Object.keys(la))}var tc={livenet:3823236072,testnet:4108710900,regtest:3669344250,stn:4224632057},dS=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],fi={PORT:18333,NETWORK_MAGIC:tc.testnet,DNS_SEEDS:dS,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},kn={PORT:18444,NETWORK_MAGIC:tc.regtest,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},ci={PORT:9333,NETWORK_MAGIC:tc.stn,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},VM={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:tc.livenet,port:8333,dnsSeeds:dS},WM={name:"testnet",prefix:fi.PREFIX,cashAddrPrefix:fi.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:fi.NETWORK_MAGIC},zM={name:"regtest",prefix:kn.PREFIX,cashAddrPrefix:kn.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:kn.NETWORK_MAGIC,port:kn.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},YM={name:"stn",prefix:ci.PREFIX,cashAddrPrefix:ci.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:ci.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};da(WM);da(YM);da(zM);da(VM);var qd=ha("livenet"),$M=ha("regtest"),fn=ha("testnet"),ZM=ha("stn");Object.defineProperty(fn,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?kn.PORT:this.stnEnabled?ci.PORT:fi.PORT}});Object.defineProperty(fn,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?ca.integerAsBuffer(kn.NETWORK_MAGIC):this.stnEnabled?ca.integerAsBuffer(ci.NETWORK_MAGIC):ca.integerAsBuffer(fi.NETWORK_MAGIC)}});Object.defineProperty(fn,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?kn.DNS_SEEDS:this.stnEnabled?ci.DNS_SEEDS:fi.DNS_SEEDS}});Object.defineProperty(fn,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?kn.CASHADDRPREFIX:this.stnEnabled?ci.CASHADDRPREFIX:fi.CASHADDRPREFIX}});Object.defineProperty(fn,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?ec(kn.CASHADDRPREFIX):this.stnEnabled?ec(ci.CASHADDRPREFIX):ec(fi.CASHADDRPREFIX)}});function XM(){fn.regtestEnabled=!0}function JM(){fn.regtestEnabled=!1}function QM(){fn.stnEnabled=!0}function e3(){fn.stnEnabled=!1}pS.exports={add:da,remove:GM,defaultNetwork:qd,livenet:qd,mainnet:qd,testnet:fn,regtest:$M,stn:ZM,get:ha,enableRegtest:XM,disableRegtest:JM,enableStn:QM,disableStn:e3}});var vS=P((_F,mS)=>{"use strict";p();var jd=ze(),gS=Nt(),Xo="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),yS={};for(ga=0;ga<Xo.length;ga++)yS[Xo[ga]]=ga;var ga;function t3(e){if(e.length===0)return"";var t=[0],r,n,i;for(r=0;r<e.length;r++){for(n=0,i=e[r];n<t.length;n++)i+=t[n]<<8,t[n]=i%58,i=i/58|0;for(;i>0;)t.push(i%58),i=i/58|0}var o="";for(r=0;e[r]===0&&r<e.length-1;r++)o+=Xo[0];for(r=t.length-1;r>=0;r--)o+=Xo[t[r]];return o}function r3(e){if(e.length===0)return d.Buffer.alloc(0);var t=[0],r,n,i;for(r=0;r<e.length;r++){var o=yS[e[r]];if(o===void 0)throw new Error("Non-base58 character");for(n=0,i=o;n<t.length;n++)i+=t[n]*58,t[n]=i&255,i>>=8;for(;i>0;)t.push(i&255),i>>=8}for(r=0;e[r]===Xo[0]&&r<e.length-1;r++)t.push(0);return d.Buffer.from(t.reverse())}var jt=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};jt.validCharacters=function(t){return gS.Buffer.isBuffer(t)&&(t=t.toString()),jd.every(jd.map(t,function(r){return jd.includes(Xo,r)}))};jt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};jt.encode=function(e){if(!gS.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return t3(e)};jt.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return r3(e)};jt.prototype.fromBuffer=function(e){return this.buf=e,this};jt.fromBuffer=function(e){return new jt().fromBuffer(e)};jt.fromHex=function(e){return jt.fromBuffer(d.Buffer.from(e,"hex"))};jt.prototype.fromString=function(e){var t=jt.decode(e);return this.buf=t,this};jt.fromString=function(e){return new jt().fromString(e)};jt.prototype.toBuffer=function(){return this.buf};jt.prototype.toHex=function(){return this.toBuffer().toString("hex")};jt.prototype.toString=function(){return jt.encode(this.buf)};mS.exports=jt});var Hd=P((SF,SS)=>{"use strict";p();var bS=ze(),rc=vS(),_S=Nt(),wS=Jt().sha256sha256,et=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};et.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};et.validChecksum=function(t,r){return bS.isString(t)&&(t=_S.Buffer.from(rc.decode(t))),bS.isString(r)&&(r=_S.Buffer.from(rc.decode(r))),r||(r=t.slice(-4),t=t.slice(0,-4)),et.checksum(t).toString("hex")===r.toString("hex")};et.decode=function(e){if(typeof e!="string")throw new Error("Input must be a string");var t=d.Buffer.from(rc.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),n=t.slice(-4),i=wS(r),o=i.slice(0,4);if(n.toString("hex")!==o.toString("hex"))throw new Error("Checksum mismatch");return r};et.checksum=function(e){return wS(e).slice(0,4)};et.encode=function(e){if(!d.Buffer.isBuffer(e))throw new Error("Input must be a buffer");var t=d.Buffer.alloc(e.length+4),r=et.checksum(e);return e.copy(t),r.copy(t,e.length),rc.encode(t)};et.prototype.fromBuffer=function(e){return this.buf=e,this};et.fromBuffer=function(e){return new et().fromBuffer(e)};et.fromHex=function(e){return et.fromBuffer(d.Buffer.from(e,"hex"))};et.prototype.fromString=function(e){var t=et.decode(e);return this.buf=t,this};et.fromString=function(e){var t=et.decode(e);return new et(t)};et.prototype.toBuffer=function(){return this.buf};et.prototype.toHex=function(){return this.toBuffer().toString("hex")};et.prototype.toString=function(){return et.encode(this.buf)};SS.exports=et});var ma=P((xF,xS)=>{"use strict";p();var ya=ze(),ES=Le(),Jo=Sr(),it=function e(t){if(!(this instanceof e))return new e(t);if(!ya.isUndefined(t))if(d.Buffer.isBuffer(t))this.set({buf:t});else if(ya.isString(t)){var r=d.Buffer.from(t,"hex");if(r.length*2!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else if(ya.isObject(t)){var n=t;this.set(n)}else throw new TypeError("Unrecognized argument for BufferReader")};it.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this};it.prototype.eof=function(){return this.pos>=this.buf.length};it.prototype.finished=it.prototype.eof;it.prototype.read=function(e){ES.checkArgument(!ya.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t};it.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e};it.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e};it.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e};it.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e};it.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e};it.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e};it.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e};it.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=Jo.fromBuffer(e);return this.pos=this.pos+8,t};it.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=t*4294967296+e,n;if(r<=9007199254740991)n=new Jo(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);n=new Jo(i,10,"le")}return this.pos=this.pos+8,n};it.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return e}};it.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return ES.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t};it.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);switch(e){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}};it.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new Jo(this.readUInt16LE());case 254:return new Jo(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new Jo(e)}};it.prototype.reverse=function(){for(var e=d.Buffer.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this};it.prototype.readReverse=function(e){ya.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,d.Buffer.from(t).reverse()};xS.exports=it});var Vd=P((AF,RS)=>{"use strict";p();function li(e){"@babel/helpers - typeof";return li=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},li(e)}function IS(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i3(n.key),n)}}function n3(e,t,r){return t&&IS(e.prototype,t),r&&IS(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function i3(e){var t=o3(e,"string");return li(t)==="symbol"?t:String(t)}function o3(e,t){if(li(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(li(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function s3(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a3(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Gd(e,t)}function Gd(e,t){return Gd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Gd(e,t)}function u3(e){var t=l3();return function(){var n=nc(e),i;if(t){var o=nc(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return f3(this,i)}}function f3(e,t){if(t&&(li(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return c3(e)}function c3(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l3(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function nc(e){return nc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},nc(e)}var OS={},Qo,Kd;function va(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){a3(a,o);var s=u3(a);function a(f,l,m){var g;return s3(this,a),g=s.call(this,n(f,l,m)),g.code=e,g}return n3(a)})(r);OS[e]=i}function AS(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function h3(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function d3(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function p3(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}va("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);va("ERR_INVALID_ARG_TYPE",function(e,t,r){Qo===void 0&&(Qo=ic()),Qo(typeof e=="string","'name' must be a string");var n;typeof t=="string"&&h3(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(d3(e," argument"))i="The ".concat(e," ").concat(n," ").concat(AS(t,"type"));else{var o=p3(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(AS(t,"type"))}return i+=". Received type ".concat(li(r)),i},TypeError);va("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";Kd===void 0&&(Kd=Xr());var n=Kd.inspect(t);return n.length>128&&(n="".concat(n.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(n)},TypeError,RangeError);va("ERR_INVALID_RETURN_VALUE",function(e,t,r){var n;return r&&r.constructor&&r.constructor.name?n="instance of ".concat(r.constructor.name):n="type ".concat(li(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")},TypeError);va("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];Qo===void 0&&(Qo=ic()),Qo(t.length>0,"At least one arg needs to be specified");var n="The ",i=t.length;switch(t=t.map(function(o){return'"'.concat(o,'"')}),i){case 1:n+="".concat(t[0]," argument");break;case 2:n+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:n+=t.slice(0,i-1).join(", "),n+=", and ".concat(t[i-1]," arguments");break}return"".concat(n," must be specified")},TypeError);RS.exports.codes=OS});var US=P((RF,DS)=>{"use strict";p();function TS(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function PS(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?TS(Object(r),!0).forEach(function(n){g3(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):TS(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function g3(e,t,r){return t=kS(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function y3(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function BS(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,kS(n.key),n)}}function m3(e,t,r){return t&&BS(e.prototype,t),r&&BS(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function kS(e){var t=v3(e,"string");return ur(t)==="symbol"?t:String(t)}function v3(e,t){if(ur(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(ur(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function b3(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Sa(e,t)}function _3(e){var t=LS();return function(){var n=Ea(e),i;if(t){var o=Ea(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return CS(this,i)}}function CS(e,t){if(t&&(ur(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wd(e)}function Wd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function zd(e){var t=typeof Map=="function"?new Map:void 0;return zd=function(n){if(n===null||!w3(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return oc(n,arguments,Ea(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Sa(i,n)},zd(e)}function oc(e,t,r){return LS()?oc=Reflect.construct.bind():oc=function(i,o,s){var a=[null];a.push.apply(a,o);var f=Function.bind.apply(i,a),l=new f;return s&&Sa(l,s.prototype),l},oc.apply(null,arguments)}function LS(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function w3(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function Sa(e,t){return Sa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Sa(e,t)}function Ea(e){return Ea=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ea(e)}function ur(e){"@babel/helpers - typeof";return ur=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ur(e)}var S3=Xr(),Yd=S3.inspect,E3=Vd(),x3=E3.codes.ERR_INVALID_ARG_TYPE;function NS(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function I3(e,t){if(t=Math.floor(t),e.length==0||t==0)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+=e.substring(0,r-e.length),e}var Cr="",ba="",_a="",Vt="",Xi={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:"},A3=10;function MS(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(n){r[n]=e[n]}),Object.defineProperty(r,"message",{value:e.message}),r}function wa(e){return Yd(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function O3(e,t,r){var n="",i="",o=0,s="",a=!1,f=wa(e),l=f.split(`
14
- `),m=wa(t).split(`
10
+ `)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}Ae.types=hm();function mm(e){return Array.isArray(e)}Ae.isArray=mm;function eh(e){return typeof e=="boolean"}Ae.isBoolean=eh;function Nu(e){return e===null}Ae.isNull=Nu;function vR(e){return e==null}Ae.isNullOrUndefined=vR;function vm(e){return typeof e=="number"}Ae.isNumber=vm;function Mu(e){return typeof e=="string"}Ae.isString=Mu;function bR(e){return typeof e=="symbol"}Ae.isSymbol=bR;function Ti(e){return e===void 0}Ae.isUndefined=Ti;function ws(e){return xo(e)&&th(e)==="[object RegExp]"}Ae.isRegExp=ws;Ae.types.isRegExp=ws;function xo(e){return typeof e=="object"&&e!==null}Ae.isObject=xo;function Bu(e){return xo(e)&&th(e)==="[object Date]"}Ae.isDate=Bu;Ae.types.isDate=Bu;function Es(e){return xo(e)&&(th(e)==="[object Error]"||e instanceof Error)}Ae.isError=Es;Ae.types.isNativeError=Es;function Tu(e){return typeof e=="function"}Ae.isFunction=Tu;function _R(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}Ae.isPrimitive=_R;Ae.isBuffer=pm();function th(e){return Object.prototype.toString.call(e)}function Jl(e){return e<10?"0"+e.toString(10):e.toString(10)}var SR=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function wR(){var e=new Date,t=[Jl(e.getHours()),Jl(e.getMinutes()),Jl(e.getSeconds())].join(":");return[e.getDate(),SR[e.getMonth()],t].join(" ")}Ae.log=function(){console.log("%s - %s",wR(),Ae.format.apply(Ae,arguments))};Ae.inherits=Fe();Ae._extend=function(e,t){if(!t||!xo(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};function bm(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Ri=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;Ae.promisify=function(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');if(Ri&&t[Ri]){var r=t[Ri];if(typeof r!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(r,Ri,{value:r,enumerable:!1,writable:!1,configurable:!0}),r}function r(){for(var n,i,o=new Promise(function(f,l){n=f,i=l}),s=[],a=0;a<arguments.length;a++)s.push(arguments[a]);s.push(function(f,l){f?i(f):n(l)});try{t.apply(this,s)}catch(f){i(f)}return o}return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),Ri&&Object.defineProperty(r,Ri,{value:r,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(r,gm(t))};Ae.promisify.custom=Ri;function ER(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}function xR(e){if(typeof e!="function")throw new TypeError('The "original" argument must be of type Function');function t(){for(var r=[],n=0;n<arguments.length;n++)r.push(arguments[n]);var i=r.pop();if(typeof i!="function")throw new TypeError("The last argument must be of type Function");var o=this,s=function(){return i.apply(o,arguments)};e.apply(this,r).then(function(a){x.default.nextTick(s.bind(null,null,a))},function(a){x.default.nextTick(ER.bind(null,a,s))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,gm(e)),t}Ae.callbackify=xR});var Im=B((qL,xm)=>{"use strict";p();function _m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Sm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?_m(Object(r),!0).forEach(function(n){IR(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_m(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function IR(e,t,r){return t=Em(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function OR(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wm(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Em(n.key),n)}}function AR(e,t,r){return t&&wm(e.prototype,t),r&&wm(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Em(e){var t=RR(e,"string");return typeof t=="symbol"?t:String(t)}function RR(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var TR=Nt(),ku=TR.Buffer,PR=Xr(),rh=PR.inspect,BR=rh&&rh.custom||"inspect";function NR(e,t,r){ku.prototype.copy.call(e,t,r)}xm.exports=(function(){function e(){OR(this,e),this.head=null,this.tail=null,this.length=0}return AR(e,[{key:"push",value:function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length}},{key:"unshift",value:function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i}},{key:"concat",value:function(r){if(this.length===0)return ku.alloc(0);for(var n=ku.allocUnsafe(r>>>0),i=this.head,o=0;i;)NR(i.data,n,o),o+=i.data.length,i=i.next;return n}},{key:"consume",value:function(r,n){var i;return r<this.head.data.length?(i=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?i=this.shift():i=n?this._getString(r):this._getBuffer(r),i}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(r){var n=this.head,i=1,o=n.data;for(r-=o.length;n=n.next;){var s=n.data,a=r>s.length?s.length:r;if(a===s.length?o+=s:o+=s.slice(0,r),r-=a,r===0){a===s.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=s.slice(a));break}++i}return this.length-=i,o}},{key:"_getBuffer",value:function(r){var n=ku.allocUnsafe(r),i=this.head,o=1;for(i.data.copy(n),r-=i.data.length;i=i.next;){var s=i.data,a=r>s.length?s.length:r;if(s.copy(n,n.length-r,0,a),r-=a,r===0){a===s.length?(++o,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=s.slice(a));break}++o}return this.length-=o,n}},{key:BR,value:function(r,n){return rh(this,Sm(Sm({},n),{},{depth:0,customInspect:!1}))}}]),e})()});var ih=B((HL,Am)=>{"use strict";p();function MR(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,x.default.nextTick(nh,this,e)):x.default.nextTick(nh,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted?x.default.nextTick(Cu,r):(r._writableState.errorEmitted=!0,x.default.nextTick(Om,r,o)):x.default.nextTick(Om,r,o):t?(x.default.nextTick(Cu,r),t(o)):x.default.nextTick(Cu,r)}),this)}function Om(e,t){nh(e,t),Cu(e)}function Cu(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function kR(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function nh(e,t){e.emit("error",t)}function CR(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}Am.exports={destroy:MR,undestroy:kR,errorOrDestroy:CR}});var Pi=B((GL,Pm)=>{"use strict";p();function LR(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Tm={};function _r(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){LR(s,o);function s(a,f,l){return o.call(this,n(a,f,l))||this}return s})(r);i.prototype.name=r.name,i.prototype.code=e,Tm[e]=i}function Rm(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function DR(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function UR(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function FR(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}_r("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);_r("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&DR(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(UR(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Rm(t,"type"));else{var o=FR(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(Rm(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);_r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");_r("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});_r("ERR_STREAM_PREMATURE_CLOSE","Premature close");_r("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" 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(e){return"Unknown encoding: "+e},TypeError);_r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Pm.exports.codes=Tm});var oh=B((WL,Bm)=>{"use strict";p();var qR=Pi().codes.ERR_INVALID_OPT_VALUE;function jR(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function HR(e,t,r,n){var i=jR(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new qR(o,i)}return Math.floor(i)}return e.objectMode?16:16*1024}Bm.exports={getHighWaterMark:HR}});var ah=B((YL,Nm)=>{p();Nm.exports=KR;function KR(e,t){if(sh("noDeprecation"))return e;var r=!1;function n(){if(!r){if(sh("throwDeprecation"))throw new Error(t);sh("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function sh(e){try{if(!globalThis.localStorage)return!1}catch{return!1}var t=globalThis.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}});var ch=B((ZL,Um)=>{"use strict";p();Um.exports=Qe;function km(e){var t=this;this.next=null,this.entry=null,this.finish=function(){yT(t,e)}}var Io;Qe.WritableState=Is;var GR={deprecate:ah()},Cm=El(),Du=Nt().Buffer,VR=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function WR(e){return Du.from(e)}function zR(e){return Du.isBuffer(e)||e instanceof VR}var fh=ih(),YR=oh(),$R=YR.getHighWaterMark,Gn=Pi().codes,ZR=Gn.ERR_INVALID_ARG_TYPE,XR=Gn.ERR_METHOD_NOT_IMPLEMENTED,JR=Gn.ERR_MULTIPLE_CALLBACK,QR=Gn.ERR_STREAM_CANNOT_PIPE,eT=Gn.ERR_STREAM_DESTROYED,tT=Gn.ERR_STREAM_NULL_VALUES,rT=Gn.ERR_STREAM_WRITE_AFTER_END,nT=Gn.ERR_UNKNOWN_ENCODING,Oo=fh.errorOrDestroy;Fe()(Qe,Cm);function iT(){}function Is(e,t,r){Io=Io||Bi(),e=e||{},typeof r!="boolean"&&(r=t instanceof Io),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=$R(this,e,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=e.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){lT(t,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new km(this)}Is.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Is.prototype,"buffer",{get:GR.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var Lu;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Lu=Function.prototype[Symbol.hasInstance],Object.defineProperty(Qe,Symbol.hasInstance,{value:function(t){return Lu.call(this,t)?!0:this!==Qe?!1:t&&t._writableState instanceof Is}})):Lu=function(t){return t instanceof this};function Qe(e){Io=Io||Bi();var t=this instanceof Io;if(!t&&!Lu.call(Qe,this))return new Qe(e);this._writableState=new Is(e,this,t),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),Cm.call(this)}Qe.prototype.pipe=function(){Oo(this,new QR)};function oT(e,t){var r=new rT;Oo(e,r),x.default.nextTick(t,r)}function sT(e,t,r,n){var i;return r===null?i=new tT:typeof r!="string"&&!t.objectMode&&(i=new ZR("chunk",["string","Buffer"],r)),i?(Oo(e,i),x.default.nextTick(n,i),!1):!0}Qe.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&zR(e);return o&&!Du.isBuffer(e)&&(e=WR(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=iT),n.ending?oT(this,r):(o||sT(this,n,e,r))&&(n.pendingcb++,i=uT(this,n,o,e,t,r)),i};Qe.prototype.cork=function(){this._writableState.corked++};Qe.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&Lm(this,e))};Qe.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new nT(t);return this._writableState.defaultEncoding=t,this};Object.defineProperty(Qe.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function aT(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=Du.from(t,r)),t}Object.defineProperty(Qe.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function uT(e,t,r,n,i,o){if(!r){var s=aT(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var f=t.length<t.highWaterMark;if(f||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else uh(e,t,!1,a,n,i,o);return f}function uh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new eT("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function fT(e,t,r,n,i){--t.pendingcb,r?(x.default.nextTick(i,n),x.default.nextTick(xs,e,t),e._writableState.errorEmitted=!0,Oo(e,n)):(i(n),e._writableState.errorEmitted=!0,Oo(e,n),xs(e,t))}function cT(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function lT(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new JR;if(cT(r),t)fT(e,r,n,t,i);else{var o=Dm(r)||e.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Lm(e,r),n?x.default.nextTick(Mm,e,r,o,i):Mm(e,r,o,i)}}function Mm(e,t,r,n){r||hT(e,t),t.pendingcb--,n(),xs(e,t)}function hT(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Lm(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,uh(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new km(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,m=r.callback,g=t.objectMode?1:f.length;if(uh(e,t,!1,g,f,l,m),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Qe.prototype._write=function(e,t,r){r(new XR("_write()"))};Qe.prototype._writev=null;Qe.prototype.end=function(e,t,r){var n=this._writableState;return typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||gT(this,n,r),this};Object.defineProperty(Qe.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Dm(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function dT(e,t){e._final(function(r){t.pendingcb--,r&&Oo(e,r),t.prefinished=!0,e.emit("prefinish"),xs(e,t)})}function pT(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,x.default.nextTick(dT,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function xs(e,t){var r=Dm(t);if(r&&(pT(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return r}function gT(e,t,r){t.ending=!0,xs(e,t),r&&(t.finished?x.default.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function yT(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(Qe.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}});Qe.prototype.destroy=fh.destroy;Qe.prototype._undestroy=fh.undestroy;Qe.prototype._destroy=function(e,t){t(e)}});var Bi=B((JL,qm)=>{"use strict";p();var mT=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};qm.exports=Jr;var Fm=dh(),hh=ch();Fe()(Jr,Fm);for(lh=mT(hh.prototype),Uu=0;Uu<lh.length;Uu++)Fu=lh[Uu],Jr.prototype[Fu]||(Jr.prototype[Fu]=hh.prototype[Fu]);var lh,Fu,Uu;function Jr(e){if(!(this instanceof Jr))return new Jr(e);Fm.call(this,e),hh.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",vT)))}Object.defineProperty(Jr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(Jr.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(Jr.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function vT(){this._writableState.ended||x.default.nextTick(bT,this)}function bT(e){e.end()}Object.defineProperty(Jr.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(t){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=t,this._writableState.destroyed=t)}})});var Km=B((ph,Hm)=>{p();var qu=Nt(),mn=qu.Buffer;function jm(e,t){for(var r in e)t[r]=e[r]}mn.from&&mn.alloc&&mn.allocUnsafe&&mn.allocUnsafeSlow?Hm.exports=qu:(jm(qu,ph),ph.Buffer=Ao);function Ao(e,t,r){return mn(e,t,r)}jm(mn,Ao);Ao.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return mn(e,t,r)};Ao.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=mn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Ao.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return mn(e)};Ao.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return qu.SlowBuffer(e)}});var Ro=B(Vm=>{"use strict";p();var yh=Km().Buffer,Gm=yh.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function _T(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function ST(e){var t=_T(e);if(typeof t!="string"&&(yh.isEncoding===Gm||!Gm(e)))throw new Error("Unknown encoding: "+e);return t||e}Vm.StringDecoder=Os;function Os(e){this.encoding=ST(e);var t;switch(this.encoding){case"utf16le":this.text=AT,this.end=RT,t=4;break;case"utf8":this.fillLast=xT,t=4;break;case"base64":this.text=TT,this.end=PT,t=3;break;default:this.write=BT,this.end=NT;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=yh.allocUnsafe(t)}Os.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Os.prototype.end=OT;Os.prototype.text=IT;Os.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function gh(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function wT(e,t,r){var n=t.length-1;if(n<r)return 0;var i=gh(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=gh(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=gh(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function ET(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function xT(e){var t=this.lastTotal-this.lastNeed,r=ET(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function IT(e,t){var r=wT(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function OT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function AT(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function RT(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function TT(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function PT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function BT(e){return e.toString(this.encoding)}function NT(e){return e&&e.length?this.write(e):""}});var ju=B((n4,Ym)=>{"use strict";p();var Wm=Pi().codes.ERR_STREAM_PREMATURE_CLOSE;function MT(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e.apply(this,n)}}}function kT(){}function CT(e){return e.setHeader&&typeof e.abort=="function"}function zm(e,t,r){if(typeof t=="function")return zm(e,null,t);t||(t={}),r=MT(r||kT);var n=t.readable||t.readable!==!1&&e.readable,i=t.writable||t.writable!==!1&&e.writable,o=function(){e.writable||a()},s=e._writableState&&e._writableState.finished,a=function(){i=!1,s=!0,n||r.call(e)},f=e._readableState&&e._readableState.endEmitted,l=function(){n=!1,f=!0,i||r.call(e)},m=function(T){r.call(e,T)},g=function(){var T;if(n&&!f)return(!e._readableState||!e._readableState.ended)&&(T=new Wm),r.call(e,T);if(i&&!s)return(!e._writableState||!e._writableState.ended)&&(T=new Wm),r.call(e,T)},v=function(){e.req.on("finish",a)};return CT(e)?(e.on("complete",a),e.on("abort",g),e.req?v():e.on("request",v)):i&&!e._writableState&&(e.on("end",o),e.on("close",o)),e.on("end",l),e.on("finish",a),t.error!==!1&&e.on("error",m),e.on("close",g),function(){e.removeListener("complete",a),e.removeListener("abort",g),e.removeListener("request",v),e.req&&e.req.removeListener("finish",a),e.removeListener("end",o),e.removeListener("close",o),e.removeListener("finish",a),e.removeListener("end",l),e.removeListener("error",m),e.removeListener("close",g)}}Ym.exports=zm});var Zm=B((o4,$m)=>{"use strict";p();var Hu;function Vn(e,t,r){return t=LT(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function LT(e){var t=DT(e,"string");return typeof t=="symbol"?t:String(t)}function DT(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var UT=ju(),Wn=Symbol("lastResolve"),Ni=Symbol("lastReject"),As=Symbol("error"),Ku=Symbol("ended"),Mi=Symbol("lastPromise"),mh=Symbol("handlePromise"),ki=Symbol("stream");function zn(e,t){return{value:e,done:t}}function FT(e){var t=e[Wn];if(t!==null){var r=e[ki].read();r!==null&&(e[Mi]=null,e[Wn]=null,e[Ni]=null,t(zn(r,!1)))}}function qT(e){x.default.nextTick(FT,e)}function jT(e,t){return function(r,n){e.then(function(){if(t[Ku]){r(zn(void 0,!0));return}t[mh](r,n)},n)}}var HT=Object.getPrototypeOf(function(){}),KT=Object.setPrototypeOf((Hu={get stream(){return this[ki]},next:function(){var t=this,r=this[As];if(r!==null)return Promise.reject(r);if(this[Ku])return Promise.resolve(zn(void 0,!0));if(this[ki].destroyed)return new Promise(function(s,a){x.default.nextTick(function(){t[As]?a(t[As]):s(zn(void 0,!0))})});var n=this[Mi],i;if(n)i=new Promise(jT(n,this));else{var o=this[ki].read();if(o!==null)return Promise.resolve(zn(o,!1));i=new Promise(this[mh])}return this[Mi]=i,i}},Vn(Hu,Symbol.asyncIterator,function(){return this}),Vn(Hu,"return",function(){var t=this;return new Promise(function(r,n){t[ki].destroy(null,function(i){if(i){n(i);return}r(zn(void 0,!0))})})}),Hu),HT),GT=function(t){var r,n=Object.create(KT,(r={},Vn(r,ki,{value:t,writable:!0}),Vn(r,Wn,{value:null,writable:!0}),Vn(r,Ni,{value:null,writable:!0}),Vn(r,As,{value:null,writable:!0}),Vn(r,Ku,{value:t._readableState.endEmitted,writable:!0}),Vn(r,mh,{value:function(o,s){var a=n[ki].read();a?(n[Mi]=null,n[Wn]=null,n[Ni]=null,o(zn(a,!1))):(n[Wn]=o,n[Ni]=s)},writable:!0}),r));return n[Mi]=null,UT(t,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[Ni];o!==null&&(n[Mi]=null,n[Wn]=null,n[Ni]=null,o(i)),n[As]=i;return}var s=n[Wn];s!==null&&(n[Mi]=null,n[Wn]=null,n[Ni]=null,s(zn(void 0,!0))),n[Ku]=!0}),t.on("readable",qT.bind(null,n)),n};$m.exports=GT});var Jm=B((a4,Xm)=>{p();Xm.exports=function(){throw new Error("Readable.from is not available in the browser")}});var dh=B((c4,uv)=>{"use strict";p();uv.exports=Be;var To;Be.ReadableState=rv;var f4=go().EventEmitter,tv=function(t,r){return t.listeners(r).length},Ts=El(),Gu=Nt().Buffer,VT=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function WT(e){return Gu.from(e)}function zT(e){return Gu.isBuffer(e)||e instanceof VT}var vh=Xr(),Ee;vh&&vh.debuglog?Ee=vh.debuglog("stream"):Ee=function(){};var YT=Im(),Ih=ih(),$T=oh(),ZT=$T.getHighWaterMark,Vu=Pi().codes,XT=Vu.ERR_INVALID_ARG_TYPE,JT=Vu.ERR_STREAM_PUSH_AFTER_EOF,QT=Vu.ERR_METHOD_NOT_IMPLEMENTED,e2=Vu.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,Po,bh,_h;Fe()(Be,Ts);var Rs=Ih.errorOrDestroy,Sh=["error","close","destroy","pause","resume"];function t2(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function rv(e,t,r){To=To||Bi(),e=e||{},typeof r!="boolean"&&(r=t instanceof To),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=ZT(this,e,"readableHighWaterMark",r),this.buffer=new YT,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Po||(Po=Ro().StringDecoder),this.decoder=new Po(e.encoding),this.encoding=e.encoding)}function Be(e){if(To=To||Bi(),!(this instanceof Be))return new Be(e);var t=this instanceof To;this._readableState=new rv(e,this,t),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Ts.call(this)}Object.defineProperty(Be.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});Be.prototype.destroy=Ih.destroy;Be.prototype._undestroy=Ih.undestroy;Be.prototype._destroy=function(e,t){t(e)};Be.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Gu.from(e,t),t=""),n=!0),nv(this,e,t,!1,n)};Be.prototype.unshift=function(e){return nv(this,e,null,!0,!1)};function nv(e,t,r,n,i){Ee("readableAddChunk",t);var o=e._readableState;if(t===null)o.reading=!1,i2(e,o);else{var s;if(i||(s=r2(o,t)),s)Rs(e,s);else if(o.objectMode||t&&t.length>0)if(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Gu.prototype&&(t=WT(t)),n)o.endEmitted?Rs(e,new e2):wh(e,o,t,!0);else if(o.ended)Rs(e,new JT);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?wh(e,o,t,!1):xh(e,o)):wh(e,o,t,!1)}else n||(o.reading=!1,xh(e,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function wh(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Wu(e)),xh(e,t)}function r2(e,t){var r;return!zT(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new XT("chunk",["string","Buffer","Uint8Array"],t)),r}Be.prototype.isPaused=function(){return this._readableState.flowing===!1};Be.prototype.setEncoding=function(e){Po||(Po=Ro().StringDecoder);var t=new Po(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";r!==null;)n+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),n!==""&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var Qm=1073741824;function n2(e){return e>=Qm?e=Qm:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function ev(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=n2(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Be.prototype.read=function(e){Ee("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark!==0?t.length>=t.highWaterMark:t.length>0)||t.ended))return Ee("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Eh(this):Wu(this),null;if(e=ev(e,t),e===0&&t.ended)return t.length===0&&Eh(this),null;var n=t.needReadable;Ee("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,Ee("length less than watermark",n)),t.ended||t.reading?(n=!1,Ee("reading or ended",n)):n&&(Ee("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=ev(r,t)));var i;return e>0?i=sv(e,t):i=null,i===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Eh(this)),i!==null&&this.emit("data",i),i};function i2(e,t){if(Ee("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?Wu(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,iv(e)))}}function Wu(e){var t=e._readableState;Ee("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(Ee("emitReadable",t.flowing),t.emittedReadable=!0,x.default.nextTick(iv,e))}function iv(e){var t=e._readableState;Ee("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,Oh(e)}function xh(e,t){t.readingMore||(t.readingMore=!0,x.default.nextTick(o2,e,t))}function o2(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var r=t.length;if(Ee("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}Be.prototype._read=function(e){Rs(this,new QT("_read()"))};Be.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,Ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==x.default.stdout&&e!==x.default.stderr,o=i?a:N;n.endEmitted?x.default.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(L,F){Ee("onunpipe"),L===r&&F&&F.hasUnpiped===!1&&(F.hasUnpiped=!0,m())}function a(){Ee("onend"),e.end()}var f=s2(r);e.on("drain",f);var l=!1;function m(){Ee("cleanup"),e.removeListener("close",E),e.removeListener("finish",T),e.removeListener("drain",f),e.removeListener("error",v),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",N),r.removeListener("data",g),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}r.on("data",g);function g(L){Ee("ondata");var F=e.write(L);Ee("dest.write",F),F===!1&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&av(n.pipes,e)!==-1)&&!l&&(Ee("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function v(L){Ee("onerror",L),N(),e.removeListener("error",v),tv(e,"error")===0&&Rs(e,L)}t2(e,"error",v);function E(){e.removeListener("finish",T),N()}e.once("close",E);function T(){Ee("onfinish"),e.removeListener("close",E),N()}e.once("finish",T);function N(){Ee("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(Ee("pipe resume"),r.resume()),e};function s2(e){return function(){var r=e._readableState;Ee("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&tv(e,"data")&&(r.flowing=!0,Oh(e))}}Be.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=av(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};Be.prototype.on=function(e,t){var r=Ts.prototype.on.call(this,e,t),n=this._readableState;return e==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):e==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Ee("on readable",n.length,n.reading),n.length?Wu(this):n.reading||x.default.nextTick(a2,this)),r};Be.prototype.addListener=Be.prototype.on;Be.prototype.removeListener=function(e,t){var r=Ts.prototype.removeListener.call(this,e,t);return e==="readable"&&x.default.nextTick(ov,this),r};Be.prototype.removeAllListeners=function(e){var t=Ts.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&x.default.nextTick(ov,this),t};function ov(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function a2(e){Ee("readable nexttick read 0"),e.read(0)}Be.prototype.resume=function(){var e=this._readableState;return e.flowing||(Ee("resume"),e.flowing=!e.readableListening,u2(this,e)),e.paused=!1,this};function u2(e,t){t.resumeScheduled||(t.resumeScheduled=!0,x.default.nextTick(f2,e,t))}function f2(e,t){Ee("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),Oh(e),t.flowing&&!t.reading&&e.read(0)}Be.prototype.pause=function(){return Ee("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Ee("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Oh(e){var t=e._readableState;for(Ee("flow",t.flowing);t.flowing&&e.read()!==null;);}Be.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(Ee("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(Ee("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(a){return function(){return e[a].apply(e,arguments)}})(i));for(var o=0;o<Sh.length;o++)e.on(Sh[o],this.emit.bind(this,Sh[o]));return this._read=function(s){Ee("wrapped _read",s),n&&(n=!1,e.resume())},this};typeof Symbol=="function"&&(Be.prototype[Symbol.asyncIterator]=function(){return bh===void 0&&(bh=Zm()),bh(this)});Object.defineProperty(Be.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(Be.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(Be.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}});Be._fromList=sv;Object.defineProperty(Be.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function sv(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.first():r=t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}function Eh(e){var t=e._readableState;Ee("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,x.default.nextTick(c2,t,e))}function c2(e,t){if(Ee("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}typeof Symbol=="function"&&(Be.from=function(e,t){return _h===void 0&&(_h=Jm()),_h(Be,e,t)});function av(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Ah=B((h4,cv)=>{"use strict";p();cv.exports=vn;var zu=Pi().codes,l2=zu.ERR_METHOD_NOT_IMPLEMENTED,h2=zu.ERR_MULTIPLE_CALLBACK,d2=zu.ERR_TRANSFORM_ALREADY_TRANSFORMING,p2=zu.ERR_TRANSFORM_WITH_LENGTH_0,Yu=Bi();Fe()(vn,Yu);function g2(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new h2);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function vn(e){if(!(this instanceof vn))return new vn(e);Yu.call(this,e),this._transformState={afterTransform:g2.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",y2)}function y2(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){fv(e,t,r)}):fv(this,null,null)}vn.prototype.push=function(e,t){return this._transformState.needTransform=!1,Yu.prototype.push.call(this,e,t)};vn.prototype._transform=function(e,t,r){r(new l2("_transform()"))};vn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};vn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};vn.prototype._destroy=function(e,t){Yu.prototype._destroy.call(this,e,function(r){t(r)})};function fv(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new p2;if(e._transformState.transforming)throw new d2;return e.push(null)}});var dv=B((p4,hv)=>{"use strict";p();hv.exports=Ps;var lv=Ah();Fe()(Ps,lv);function Ps(e){if(!(this instanceof Ps))return new Ps(e);lv.call(this,e)}Ps.prototype._transform=function(e,t,r){r(null,e)}});var vv=B((y4,mv)=>{"use strict";p();var Rh;function m2(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var yv=Pi().codes,v2=yv.ERR_MISSING_ARGS,b2=yv.ERR_STREAM_DESTROYED;function pv(e){if(e)throw e}function _2(e){return e.setHeader&&typeof e.abort=="function"}function S2(e,t,r,n){n=m2(n);var i=!1;e.on("close",function(){i=!0}),Rh===void 0&&(Rh=ju()),Rh(e,{readable:t,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,_2(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(s||new b2("pipe"))}}}function gv(e){e()}function w2(e,t){return e.pipe(t)}function E2(e){return!e.length||typeof e[e.length-1]!="function"?pv:e.pop()}function x2(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=E2(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new v2("streams");var i,o=t.map(function(s,a){var f=a<t.length-1,l=a>0;return S2(s,f,l,function(m){i||(i=m),m&&o.forEach(gv),!f&&(o.forEach(gv),n(i))})});return t.reduce(w2)}mv.exports=x2});var Ph=B((v4,bv)=>{p();bv.exports=Sr;var Th=go().EventEmitter,I2=Fe();I2(Sr,Th);Sr.Readable=dh();Sr.Writable=ch();Sr.Duplex=Bi();Sr.Transform=Ah();Sr.PassThrough=dv();Sr.finished=ju();Sr.pipeline=vv();Sr.Stream=Sr;function Sr(){Th.call(this)}Sr.prototype.pipe=function(e,t){var r=this;function n(m){e.writable&&e.write(m)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}e.on("drain",i),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",s),r.on("close",a));var o=!1;function s(){o||(o=!0,e.end())}function a(){o||(o=!0,typeof e.destroy=="function"&&e.destroy())}function f(m){if(l(),Th.listenerCount(this,"error")===0)throw m}r.on("error",f),e.on("error",f);function l(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",f),e.removeListener("error",f),r.removeListener("end",l),r.removeListener("close",l),e.removeListener("close",l)}return r.on("end",l),r.on("close",l),e.on("close",l),e.emit("pipe",r),e}});var wv=B((_4,Sv)=>{"use strict";p();var Qr=Gt().Buffer,_v=Ph().Transform,O2=Fe();function Yn(e){_v.call(this),this._block=Qr.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}O2(Yn,_v);Yn.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};Yn.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};var A2=typeof Uint8Array<"u",R2=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(Qr.prototype instanceof Uint8Array||Qr.TYPED_ARRAY_SUPPORT);function T2(e,t){if(e instanceof Qr)return e;if(typeof e=="string")return Qr.from(e,t);if(R2&&ArrayBuffer.isView(e)){if(e.byteLength===0)return Qr.alloc(0);var r=Qr.from(e.buffer,e.byteOffset,e.byteLength);if(r.byteLength===e.byteLength)return r}if(A2&&e instanceof Uint8Array||Qr.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return Qr.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}Yn.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");e=T2(e,t);for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var o=0,s=e.length*8;s>0;++o)this._length[o]+=s,s=this._length[o]/4294967296|0,s>0&&(this._length[o]-=4294967296*s);return this};Yn.prototype._update=function(){throw new Error("_update is not implemented")};Yn.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};Yn.prototype._digest=function(){throw new Error("_digest is not implemented")};Sv.exports=Yn});var Bh=B((w4,xv)=>{"use strict";p();var P2=Fe(),Ev=wv(),B2=Gt().Buffer,N2=new Array(16);function $u(){Ev.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}P2($u,Ev);$u.prototype._update=function(){for(var e=N2,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,n=this._b,i=this._c,o=this._d;r=zt(r,n,i,o,e[0],3614090360,7),o=zt(o,r,n,i,e[1],3905402710,12),i=zt(i,o,r,n,e[2],606105819,17),n=zt(n,i,o,r,e[3],3250441966,22),r=zt(r,n,i,o,e[4],4118548399,7),o=zt(o,r,n,i,e[5],1200080426,12),i=zt(i,o,r,n,e[6],2821735955,17),n=zt(n,i,o,r,e[7],4249261313,22),r=zt(r,n,i,o,e[8],1770035416,7),o=zt(o,r,n,i,e[9],2336552879,12),i=zt(i,o,r,n,e[10],4294925233,17),n=zt(n,i,o,r,e[11],2304563134,22),r=zt(r,n,i,o,e[12],1804603682,7),o=zt(o,r,n,i,e[13],4254626195,12),i=zt(i,o,r,n,e[14],2792965006,17),n=zt(n,i,o,r,e[15],1236535329,22),r=Yt(r,n,i,o,e[1],4129170786,5),o=Yt(o,r,n,i,e[6],3225465664,9),i=Yt(i,o,r,n,e[11],643717713,14),n=Yt(n,i,o,r,e[0],3921069994,20),r=Yt(r,n,i,o,e[5],3593408605,5),o=Yt(o,r,n,i,e[10],38016083,9),i=Yt(i,o,r,n,e[15],3634488961,14),n=Yt(n,i,o,r,e[4],3889429448,20),r=Yt(r,n,i,o,e[9],568446438,5),o=Yt(o,r,n,i,e[14],3275163606,9),i=Yt(i,o,r,n,e[3],4107603335,14),n=Yt(n,i,o,r,e[8],1163531501,20),r=Yt(r,n,i,o,e[13],2850285829,5),o=Yt(o,r,n,i,e[2],4243563512,9),i=Yt(i,o,r,n,e[7],1735328473,14),n=Yt(n,i,o,r,e[12],2368359562,20),r=$t(r,n,i,o,e[5],4294588738,4),o=$t(o,r,n,i,e[8],2272392833,11),i=$t(i,o,r,n,e[11],1839030562,16),n=$t(n,i,o,r,e[14],4259657740,23),r=$t(r,n,i,o,e[1],2763975236,4),o=$t(o,r,n,i,e[4],1272893353,11),i=$t(i,o,r,n,e[7],4139469664,16),n=$t(n,i,o,r,e[10],3200236656,23),r=$t(r,n,i,o,e[13],681279174,4),o=$t(o,r,n,i,e[0],3936430074,11),i=$t(i,o,r,n,e[3],3572445317,16),n=$t(n,i,o,r,e[6],76029189,23),r=$t(r,n,i,o,e[9],3654602809,4),o=$t(o,r,n,i,e[12],3873151461,11),i=$t(i,o,r,n,e[15],530742520,16),n=$t(n,i,o,r,e[2],3299628645,23),r=Zt(r,n,i,o,e[0],4096336452,6),o=Zt(o,r,n,i,e[7],1126891415,10),i=Zt(i,o,r,n,e[14],2878612391,15),n=Zt(n,i,o,r,e[5],4237533241,21),r=Zt(r,n,i,o,e[12],1700485571,6),o=Zt(o,r,n,i,e[3],2399980690,10),i=Zt(i,o,r,n,e[10],4293915773,15),n=Zt(n,i,o,r,e[1],2240044497,21),r=Zt(r,n,i,o,e[8],1873313359,6),o=Zt(o,r,n,i,e[15],4264355552,10),i=Zt(i,o,r,n,e[6],2734768916,15),n=Zt(n,i,o,r,e[13],1309151649,21),r=Zt(r,n,i,o,e[4],4149444226,6),o=Zt(o,r,n,i,e[11],3174756917,10),i=Zt(i,o,r,n,e[2],718787259,15),n=Zt(n,i,o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0};$u.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=B2.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function Zu(e,t){return e<<t|e>>>32-t}function zt(e,t,r,n,i,o,s){return Zu(e+(t&r|~t&n)+i+o|0,s)+t|0}function Yt(e,t,r,n,i,o,s){return Zu(e+(t&n|r&~n)+i+o|0,s)+t|0}function $t(e,t,r,n,i,o,s){return Zu(e+(t^r^n)+i+o|0,s)+t|0}function Zt(e,t,r,n,i,o,s){return Zu(e+(r^(t|~n))+i+o|0,s)+t|0}xv.exports=$u});var Ov=B((x4,Iv)=>{p();var M2={}.toString;Iv.exports=Array.isArray||function(e){return M2.call(e)=="[object Array]"}});var Rv=B((O4,Av)=>{"use strict";p();var k2=Ii(),C2=Hn(),L2=C2("TypedArray.prototype.buffer",!0),D2=Yl();Av.exports=L2||function(t){if(!D2(t))throw new k2("Not a Typed Array");return t.buffer}});var Xu=B((R4,Pv)=>{"use strict";p();var Pr=Gt().Buffer,U2=Ov(),F2=Rv(),q2=ArrayBuffer.isView||function(t){try{return F2(t),!0}catch{return!1}},j2=typeof Uint8Array<"u",Tv=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",H2=Tv&&(Pr.prototype instanceof Uint8Array||Pr.TYPED_ARRAY_SUPPORT);Pv.exports=function(t,r){if(Pr.isBuffer(t))return t.constructor&&!("isBuffer"in t)?Pr.from(t):t;if(typeof t=="string")return Pr.from(t,r);if(Tv&&q2(t)){if(t.byteLength===0)return Pr.alloc(0);if(H2){var n=Pr.from(t.buffer,t.byteOffset,t.byteLength);if(n.byteLength===t.byteLength)return n}var i=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=Pr.from(i);if(o.length===t.byteLength)return o}if(j2&&t instanceof Uint8Array)return Pr.from(t);var s=U2(t);if(s)for(var a=0;a<t.length;a+=1){var f=t[a];if(typeof f!="number"||f<0||f>255||~~f!==f)throw new RangeError("Array items must be numbers in the range 0-255.")}if(s||Pr.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return Pr.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var kv=B((P4,Mv)=>{"use strict";p();var K2=Gt().Buffer,G2=Xu(),Nv=typeof Uint8Array<"u",V2=Nv&&typeof ArrayBuffer<"u",Bv=V2&&ArrayBuffer.isView;Mv.exports=function(e,t){if(typeof e=="string"||K2.isBuffer(e)||Nv&&e instanceof Uint8Array||Bv&&Bv(e))return G2(e,t);throw new TypeError('The "data" argument must be a string, a Buffer, a Uint8Array, or a DataView')}});var Bs=B((N4,Nh)=>{"use strict";p();typeof x.default>"u"||!x.default.version||x.default.version.indexOf("v0.")===0||x.default.version.indexOf("v1.")===0&&x.default.version.indexOf("v1.8.")!==0?Nh.exports={nextTick:W2}:Nh.exports=x.default;function W2(e,t,r,n){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,o,s;switch(i){case 0:case 1:return x.default.nextTick(e);case 2:return x.default.nextTick(function(){e.call(null,t)});case 3:return x.default.nextTick(function(){e.call(null,t,r)});case 4:return x.default.nextTick(function(){e.call(null,t,r,n)});default:for(o=new Array(i-1),s=0;s<o.length;)o[s++]=arguments[s];return x.default.nextTick(function(){e.apply(null,o)})}}});var Lv=B((k4,Cv)=>{p();var z2={}.toString;Cv.exports=Array.isArray||function(e){return z2.call(e)=="[object Array]"}});var Mh=B((L4,Dv)=>{p();Dv.exports=go().EventEmitter});var Qu=B((kh,Fv)=>{p();var Ju=Nt(),bn=Ju.Buffer;function Uv(e,t){for(var r in e)t[r]=e[r]}bn.from&&bn.alloc&&bn.allocUnsafe&&bn.allocUnsafeSlow?Fv.exports=Ju:(Uv(Ju,kh),kh.Buffer=Bo);function Bo(e,t,r){return bn(e,t,r)}Uv(bn,Bo);Bo.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return bn(e,t,r)};Bo.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=bn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Bo.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return bn(e)};Bo.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Ju.SlowBuffer(e)}});var No=B(Xt=>{p();function Y2(e){return Array.isArray?Array.isArray(e):ef(e)==="[object Array]"}Xt.isArray=Y2;function $2(e){return typeof e=="boolean"}Xt.isBoolean=$2;function Z2(e){return e===null}Xt.isNull=Z2;function X2(e){return e==null}Xt.isNullOrUndefined=X2;function J2(e){return typeof e=="number"}Xt.isNumber=J2;function Q2(e){return typeof e=="string"}Xt.isString=Q2;function eP(e){return typeof e=="symbol"}Xt.isSymbol=eP;function tP(e){return e===void 0}Xt.isUndefined=tP;function rP(e){return ef(e)==="[object RegExp]"}Xt.isRegExp=rP;function nP(e){return typeof e=="object"&&e!==null}Xt.isObject=nP;function iP(e){return ef(e)==="[object Date]"}Xt.isDate=iP;function oP(e){return ef(e)==="[object Error]"||e instanceof Error}Xt.isError=oP;function sP(e){return typeof e=="function"}Xt.isFunction=sP;function aP(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}Xt.isPrimitive=aP;Xt.isBuffer=Nt().Buffer.isBuffer;function ef(e){return Object.prototype.toString.call(e)}});var jv=B((j4,Ch)=>{"use strict";p();function uP(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var qv=Qu().Buffer,Ns=Xr();function fP(e,t,r){e.copy(t,r)}Ch.exports=(function(){function e(){uP(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},e.prototype.concat=function(r){if(this.length===0)return qv.alloc(0);for(var n=qv.allocUnsafe(r>>>0),i=this.head,o=0;i;)fP(i.data,n,o),o+=i.data.length,i=i.next;return n},e})();Ns&&Ns.inspect&&Ns.inspect.custom&&(Ch.exports.prototype[Ns.inspect.custom]=function(){var e=Ns.inspect({length:this.length});return this.constructor.name+" "+e})});var Lh=B((K4,Hv)=>{"use strict";p();var tf=Bs();function cP(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,tf.nextTick(rf,this,e)):tf.nextTick(rf,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,tf.nextTick(rf,r,o)):tf.nextTick(rf,r,o):t&&t(o)}),this)}function lP(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function rf(e,t){e.emit("error",t)}Hv.exports={destroy:cP,undestroy:lP}});var Uh=B((V4,Zv)=>{"use strict";p();var Ci=Bs();Zv.exports=At;function Gv(e){var t=this;this.next=null,this.entry=null,this.finish=function(){TP(t,e)}}var hP=!x.default.browser&&["v0.10","v0.9."].indexOf(x.default.version.slice(0,5))>-1?setImmediate:Ci.nextTick,Mo;At.WritableState=ks;var Vv=Object.create(No());Vv.inherits=Fe();var dP={deprecate:ah()},Wv=Mh(),of=Qu().Buffer,pP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function gP(e){return of.from(e)}function yP(e){return of.isBuffer(e)||e instanceof pP}var zv=Lh();Vv.inherits(At,Wv);function mP(){}function ks(e,t){Mo=Mo||Li(),e=e||{};var r=t instanceof Mo;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){xP(t,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Gv(this)}ks.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(ks.prototype,"buffer",{get:dP.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var nf;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(nf=Function.prototype[Symbol.hasInstance],Object.defineProperty(At,Symbol.hasInstance,{value:function(e){return nf.call(this,e)?!0:this!==At?!1:e&&e._writableState instanceof ks}})):nf=function(e){return e instanceof this};function At(e){if(Mo=Mo||Li(),!nf.call(At,this)&&!(this instanceof Mo))return new At(e);this._writableState=new ks(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),Wv.call(this)}At.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function vP(e,t){var r=new Error("write after end");e.emit("error",r),Ci.nextTick(t,r)}function bP(e,t,r,n){var i=!0,o=!1;return r===null?o=new TypeError("May not write null values to stream"):typeof r!="string"&&r!==void 0&&!t.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Ci.nextTick(n,o),i=!1),i}At.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&yP(e);return o&&!of.isBuffer(e)&&(e=gP(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=mP),n.ended?vP(this,r):(o||bP(this,n,e,r))&&(n.pendingcb++,i=SP(this,n,o,e,t,r)),i};At.prototype.cork=function(){var e=this._writableState;e.corked++};At.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&Yv(this,e))};At.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function _P(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=of.from(t,r)),t}Object.defineProperty(At.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function SP(e,t,r,n,i,o){if(!r){var s=_P(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var f=t.length<t.highWaterMark;if(f||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Dh(e,t,!1,a,n,i,o);return f}function Dh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function wP(e,t,r,n,i){--t.pendingcb,r?(Ci.nextTick(i,n),Ci.nextTick(Ms,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ms(e,t))}function EP(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function xP(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(EP(r),t)wP(e,r,n,t,i);else{var o=$v(r);!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Yv(e,r),n?hP(Kv,e,r,o,i):Kv(e,r,o,i)}}function Kv(e,t,r,n){r||IP(e,t),t.pendingcb--,n(),Ms(e,t)}function IP(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Yv(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,Dh(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Gv(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,m=r.callback,g=t.objectMode?1:f.length;if(Dh(e,t,!1,g,f,l,m),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}At.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};At.prototype._writev=null;At.prototype.end=function(e,t,r){var n=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||RP(this,n,r)};function $v(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function OP(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ms(e,t)})}function AP(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,Ci.nextTick(OP,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Ms(e,t){var r=$v(t);return r&&(AP(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function RP(e,t,r){t.ending=!0,Ms(e,t),r&&(t.finished?Ci.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function TP(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(At.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});At.prototype.destroy=zv.destroy;At.prototype._undestroy=zv.undestroy;At.prototype._destroy=function(e,t){this.end(),t(e)}});var Li=B((z4,eb)=>{"use strict";p();var Xv=Bs(),PP=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};eb.exports=_n;var Jv=Object.create(No());Jv.inherits=Fe();var Qv=jh(),qh=Uh();Jv.inherits(_n,Qv);for(Fh=PP(qh.prototype),sf=0;sf<Fh.length;sf++)af=Fh[sf],_n.prototype[af]||(_n.prototype[af]=qh.prototype[af]);var Fh,af,sf;function _n(e){if(!(this instanceof _n))return new _n(e);Qv.call(this,e),qh.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",BP)}Object.defineProperty(_n.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function BP(){this.allowHalfOpen||this._writableState.ended||Xv.nextTick(NP,this)}function NP(e){e.end()}Object.defineProperty(_n.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}});_n.prototype._destroy=function(e,t){this.push(null),this.end(),Xv.nextTick(t,e)}});var jh=B((Z4,hb)=>{"use strict";p();var Co=Bs();hb.exports=$e;var MP=Lv(),Cs;$e.ReadableState=ab;var $4=go().EventEmitter,ib=function(e,t){return e.listeners(t).length},Wh=Mh(),Ls=Qu().Buffer,kP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function CP(e){return Ls.from(e)}function LP(e){return Ls.isBuffer(e)||e instanceof kP}var ob=Object.create(No());ob.inherits=Fe();var Hh=Xr(),ke=void 0;Hh&&Hh.debuglog?ke=Hh.debuglog("stream"):ke=function(){};var DP=jv(),sb=Lh(),ko;ob.inherits($e,Wh);var Kh=["error","close","destroy","pause","resume"];function UP(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):MP(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function ab(e,t){Cs=Cs||Li(),e=e||{};var r=t instanceof Cs;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,i=e.readableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new DP,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(ko||(ko=Ro().StringDecoder),this.decoder=new ko(e.encoding),this.encoding=e.encoding)}function $e(e){if(Cs=Cs||Li(),!(this instanceof $e))return new $e(e);this._readableState=new ab(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Wh.call(this)}Object.defineProperty($e.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});$e.prototype.destroy=sb.destroy;$e.prototype._undestroy=sb.undestroy;$e.prototype._destroy=function(e,t){this.push(null),t(e)};$e.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Ls.from(e,t),t=""),n=!0),ub(this,e,t,!1,n)};$e.prototype.unshift=function(e){return ub(this,e,null,!0,!1)};function ub(e,t,r,n,i){var o=e._readableState;if(t===null)o.reading=!1,HP(e,o);else{var s;i||(s=FP(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Ls.prototype&&(t=CP(t)),n?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):Gh(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Gh(e,o,t,!1):fb(e,o)):Gh(e,o,t,!1))):n||(o.reading=!1)}return qP(o)}function Gh(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&uf(e)),fb(e,t)}function FP(e,t){var r;return!LP(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function qP(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}$e.prototype.isPaused=function(){return this._readableState.flowing===!1};$e.prototype.setEncoding=function(e){return ko||(ko=Ro().StringDecoder),this._readableState.decoder=new ko(e),this._readableState.encoding=e,this};var tb=8388608;function jP(e){return e>=tb?e=tb:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function rb(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=jP(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}$e.prototype.read=function(e){ke("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return ke("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Vh(this):uf(this),null;if(e=rb(e,t),e===0&&t.ended)return t.length===0&&Vh(this),null;var n=t.needReadable;ke("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,ke("length less than watermark",n)),t.ended||t.reading?(n=!1,ke("reading or ended",n)):n&&(ke("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=rb(r,t)));var i;return e>0?i=cb(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Vh(this)),i!==null&&this.emit("data",i),i};function HP(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,uf(e)}}function uf(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ke("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Co.nextTick(nb,e):nb(e))}function nb(e){ke("emit readable"),e.emit("readable"),zh(e)}function fb(e,t){t.readingMore||(t.readingMore=!0,Co.nextTick(KP,e,t))}function KP(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(ke("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}$e.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};$e.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,ke("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==x.default.stdout&&e!==x.default.stderr,o=i?a:L;n.endEmitted?Co.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(F,V){ke("onunpipe"),F===r&&V&&V.hasUnpiped===!1&&(V.hasUnpiped=!0,m())}function a(){ke("onend"),e.end()}var f=GP(r);e.on("drain",f);var l=!1;function m(){ke("cleanup"),e.removeListener("close",T),e.removeListener("finish",N),e.removeListener("drain",f),e.removeListener("error",E),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",L),r.removeListener("data",v),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}var g=!1;r.on("data",v);function v(F){ke("ondata"),g=!1;var V=e.write(F);V===!1&&!g&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&lb(n.pipes,e)!==-1)&&!l&&(ke("false write response, pause",n.awaitDrain),n.awaitDrain++,g=!0),r.pause())}function E(F){ke("onerror",F),L(),e.removeListener("error",E),ib(e,"error")===0&&e.emit("error",F)}UP(e,"error",E);function T(){e.removeListener("finish",N),L()}e.once("close",T);function N(){ke("onfinish"),e.removeListener("close",T),L()}e.once("finish",N);function L(){ke("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(ke("pipe resume"),r.resume()),e};function GP(e){return function(){var t=e._readableState;ke("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&ib(e,"data")&&(t.flowing=!0,zh(e))}}$e.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=lb(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};$e.prototype.on=function(e,t){var r=Wh.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var n=this._readableState;!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&uf(this):Co.nextTick(VP,this))}return r};$e.prototype.addListener=$e.prototype.on;function VP(e){ke("readable nexttick read 0"),e.read(0)}$e.prototype.resume=function(){var e=this._readableState;return e.flowing||(ke("resume"),e.flowing=!0,WP(this,e)),this};function WP(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Co.nextTick(zP,e,t))}function zP(e,t){t.reading||(ke("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),zh(e),t.flowing&&!t.reading&&e.read(0)}$e.prototype.pause=function(){return ke("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(ke("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function zh(e){var t=e._readableState;for(ke("flow",t.flowing);t.flowing&&e.read()!==null;);}$e.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(ke("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(ke("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(s){return function(){return e[s].apply(e,arguments)}})(i));for(var o=0;o<Kh.length;o++)e.on(Kh[o],this.emit.bind(this,Kh[o]));return this._read=function(s){ke("wrapped _read",s),n&&(n=!1,e.resume())},this};Object.defineProperty($e.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});$e._fromList=cb;function cb(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=YP(e,t.buffer,t.decoder),r}function YP(e,t,r){var n;return e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?n=t.shift():n=r?$P(e,t):ZP(e,t),n}function $P(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),e-=s,e===0){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}function ZP(e,t){var r=Ls.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),e-=s,e===0){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}function Vh(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Co.nextTick(XP,t,e))}function XP(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function lb(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Yh=B((J4,gb)=>{"use strict";p();gb.exports=Sn;var ff=Li(),pb=Object.create(No());pb.inherits=Fe();pb.inherits(Sn,ff);function JP(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function Sn(e){if(!(this instanceof Sn))return new Sn(e);ff.call(this,e),this._transformState={afterTransform:JP.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",QP)}function QP(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){db(e,t,r)}):db(this,null,null)}Sn.prototype.push=function(e,t){return this._transformState.needTransform=!1,ff.prototype.push.call(this,e,t)};Sn.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")};Sn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};Sn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};Sn.prototype._destroy=function(e,t){var r=this;ff.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function db(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var bb=B((eD,vb)=>{"use strict";p();vb.exports=Ds;var yb=Yh(),mb=Object.create(No());mb.inherits=Fe();mb.inherits(Ds,yb);function Ds(e){if(!(this instanceof Ds))return new Ds(e);yb.call(this,e)}Ds.prototype._transform=function(e,t,r){r(null,e)}});var Sb=B((en,_b)=>{p();en=_b.exports=jh();en.Stream=en;en.Readable=en;en.Writable=Uh();en.Duplex=Li();en.Transform=Yh();en.PassThrough=bb()});var xb=B((nD,Eb)=>{"use strict";p();var eB=Gt().Buffer,tB=kv(),wb=Sb().Transform,rB=Fe();function $n(e){wb.call(this),this._block=eB.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}rB($n,wb);$n.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};$n.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};$n.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");for(var r=tB(e,t),n=this._block,i=0;this._blockOffset+r.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)n[o]=r[i],o+=1,i+=1;this._update(),this._blockOffset=0}for(;i<r.length;)n[this._blockOffset]=r[i],this._blockOffset+=1,i+=1;for(var s=0,a=r.length*8;a>0;++s)this._length[s]+=a,a=this._length[s]/4294967296|0,a>0&&(this._length[s]-=4294967296*a);return this};$n.prototype._update=function(){throw new Error("_update is not implemented")};$n.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};$n.prototype._digest=function(){throw new Error("_digest is not implemented")};Eb.exports=$n});var Zh=B((oD,Bb)=>{"use strict";p();var $h=Nt().Buffer,nB=Fe(),Pb=xb(),iB=new Array(16),Us=[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],Fs=[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],qs=[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],js=[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],Hs=[0,1518500249,1859775393,2400959708,2840853838],Ks=[1352829926,1548603684,1836072691,2053994217,0];function Di(e,t){return e<<t|e>>>32-t}function Ib(e,t,r,n,i,o,s,a){return Di(e+(t^r^n)+o+s|0,a)+i|0}function Ob(e,t,r,n,i,o,s,a){return Di(e+(t&r|~t&n)+o+s|0,a)+i|0}function Ab(e,t,r,n,i,o,s,a){return Di(e+((t|~r)^n)+o+s|0,a)+i|0}function Rb(e,t,r,n,i,o,s,a){return Di(e+(t&n|r&~n)+o+s|0,a)+i|0}function Tb(e,t,r,n,i,o,s,a){return Di(e+(t^(r|~n))+o+s|0,a)+i|0}function cf(){Pb.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}nB(cf,Pb);cf.prototype._update=function(){for(var e=iB,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._a|0,f=this._b|0,l=this._c|0,m=this._d|0,g=this._e|0,v=0;v<80;v+=1){var E,T;v<16?(E=Ib(r,n,i,o,s,e[Us[v]],Hs[0],qs[v]),T=Tb(a,f,l,m,g,e[Fs[v]],Ks[0],js[v])):v<32?(E=Ob(r,n,i,o,s,e[Us[v]],Hs[1],qs[v]),T=Rb(a,f,l,m,g,e[Fs[v]],Ks[1],js[v])):v<48?(E=Ab(r,n,i,o,s,e[Us[v]],Hs[2],qs[v]),T=Ab(a,f,l,m,g,e[Fs[v]],Ks[2],js[v])):v<64?(E=Rb(r,n,i,o,s,e[Us[v]],Hs[3],qs[v]),T=Ob(a,f,l,m,g,e[Fs[v]],Ks[3],js[v])):(E=Tb(r,n,i,o,s,e[Us[v]],Hs[4],qs[v]),T=Ib(a,f,l,m,g,e[Fs[v]],Ks[4],js[v])),r=s,s=o,o=Di(i,10),i=n,n=E,a=g,g=m,m=Di(l,10),l=f,f=T}var N=this._b+i+m|0;this._b=this._c+o+g|0,this._c=this._d+s+a|0,this._d=this._e+r+f|0,this._e=this._a+n+l|0,this._a=N};cf.prototype._digest=function(){this._block[this._blockOffset]=128,this._blockOffset+=1,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=$h.alloc?$h.alloc(20):new $h(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};Bb.exports=cf});var Ui=B((aD,Nb)=>{"use strict";p();var oB=Gt().Buffer,sB=Xu();function lf(e,t){this._block=oB.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}lf.prototype.update=function(e,t){e=sB(e,t||"utf8");for(var r=this._block,n=this._blockSize,i=e.length,o=this._len,s=0;s<i;){for(var a=o%n,f=Math.min(i-s,n-a),l=0;l<f;l++)r[a+l]=e[s+l];o+=f,s+=f,o%n===0&&this._update(r)}return this._len+=i,this};lf.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o};lf.prototype._update=function(){throw new Error("_update must be implemented by subclass")};Nb.exports=lf});var Cb=B((fD,kb)=>{"use strict";p();var aB=Fe(),Mb=Ui(),uB=Gt().Buffer,fB=[1518500249,1859775393,-1894007588,-899497514],cB=new Array(80);function Gs(){this.init(),this._w=cB,Mb.call(this,64,56)}aB(Gs,Mb);Gs.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function lB(e){return e<<5|e>>>27}function hB(e){return e<<30|e>>>2}function dB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Gs.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=t[a-3]^t[a-8]^t[a-14]^t[a-16];for(var f=0;f<80;++f){var l=~~(f/20),m=lB(r)+dB(l,n,i,o)+s+t[f]+fB[l]|0;s=o,o=i,i=hB(n),n=r,r=m}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};Gs.prototype._hash=function(){var e=uB.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};kb.exports=Gs});var Ub=B((lD,Db)=>{"use strict";p();var pB=Fe(),Lb=Ui(),gB=Gt().Buffer,yB=[1518500249,1859775393,-1894007588,-899497514],mB=new Array(80);function Vs(){this.init(),this._w=mB,Lb.call(this,64,56)}pB(Vs,Lb);Vs.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function vB(e){return e<<1|e>>>31}function bB(e){return e<<5|e>>>27}function _B(e){return e<<30|e>>>2}function SB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Vs.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=vB(t[a-3]^t[a-8]^t[a-14]^t[a-16]);for(var f=0;f<80;++f){var l=~~(f/20),m=bB(r)+SB(l,n,i,o)+s+t[f]+yB[l]|0;s=o,o=i,i=_B(n),n=r,r=m}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};Vs.prototype._hash=function(){var e=gB.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};Db.exports=Vs});var Xh=B((dD,qb)=>{"use strict";p();var wB=Fe(),Fb=Ui(),EB=Gt().Buffer,xB=[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],IB=new Array(64);function Ws(){this.init(),this._w=IB,Fb.call(this,64,56)}wB(Ws,Fb);Ws.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function OB(e,t,r){return r^e&(t^r)}function AB(e,t,r){return e&t|r&(e|t)}function RB(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function TB(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function PB(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function BB(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Ws.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._f|0,f=this._g|0,l=this._h|0,m=0;m<16;++m)t[m]=e.readInt32BE(m*4);for(;m<64;++m)t[m]=BB(t[m-2])+t[m-7]+PB(t[m-15])+t[m-16]|0;for(var g=0;g<64;++g){var v=l+TB(s)+OB(s,a,f)+xB[g]+t[g]|0,E=RB(r)+AB(r,n,i)|0;l=f,f=a,a=s,s=o+v|0,o=i,i=n,n=r,r=v+E|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=a+this._f|0,this._g=f+this._g|0,this._h=l+this._h|0};Ws.prototype._hash=function(){var e=EB.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};qb.exports=Ws});var Hb=B((gD,jb)=>{"use strict";p();var NB=Fe(),MB=Xh(),kB=Ui(),CB=Gt().Buffer,LB=new Array(64);function hf(){this.init(),this._w=LB,kB.call(this,64,56)}NB(hf,MB);hf.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};hf.prototype._hash=function(){var e=CB.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};jb.exports=hf});var Jh=B((mD,$b)=>{"use strict";p();var DB=Fe(),Yb=Ui(),UB=Gt().Buffer,Kb=[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],FB=new Array(160);function zs(){this.init(),this._w=FB,Yb.call(this,128,112)}DB(zs,Yb);zs.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Gb(e,t,r){return r^e&(t^r)}function Vb(e,t,r){return e&t|r&(e|t)}function Wb(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function zb(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function qB(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function jB(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function HB(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function KB(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function qt(e,t){return e>>>0<t>>>0?1:0}zs.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,o=this._dh|0,s=this._eh|0,a=this._fh|0,f=this._gh|0,l=this._hh|0,m=this._al|0,g=this._bl|0,v=this._cl|0,E=this._dl|0,T=this._el|0,N=this._fl|0,L=this._gl|0,F=this._hl|0,V=0;V<32;V+=2)t[V]=e.readInt32BE(V*4),t[V+1]=e.readInt32BE(V*4+4);for(;V<160;V+=2){var z=t[V-30],W=t[V-30+1],ie=qB(z,W),ee=jB(W,z);z=t[V-4],W=t[V-4+1];var ge=HB(z,W),ce=KB(W,z),me=t[V-14],I=t[V-14+1],u=t[V-32],h=t[V-32+1],y=ee+I|0,S=ie+me+qt(y,ee)|0;y=y+ce|0,S=S+ge+qt(y,ce)|0,y=y+h|0,S=S+u+qt(y,h)|0,t[V]=S,t[V+1]=y}for(var w=0;w<160;w+=2){S=t[w],y=t[w+1];var R=Vb(r,n,i),O=Vb(m,g,v),_=Wb(r,m),c=Wb(m,r),b=zb(s,T),k=zb(T,s),D=Kb[w],K=Kb[w+1],G=Gb(s,a,f),X=Gb(T,N,L),Z=F+k|0,le=l+b+qt(Z,F)|0;Z=Z+X|0,le=le+G+qt(Z,X)|0,Z=Z+K|0,le=le+D+qt(Z,K)|0,Z=Z+y|0,le=le+S+qt(Z,y)|0;var se=c+O|0,A=_+R+qt(se,c)|0;l=f,F=L,f=a,L=N,a=s,N=T,T=E+Z|0,s=o+le+qt(T,E)|0,o=i,E=v,i=n,v=g,n=r,g=m,m=Z+se|0,r=le+A+qt(m,Z)|0}this._al=this._al+m|0,this._bl=this._bl+g|0,this._cl=this._cl+v|0,this._dl=this._dl+E|0,this._el=this._el+T|0,this._fl=this._fl+N|0,this._gl=this._gl+L|0,this._hl=this._hl+F|0,this._ah=this._ah+r+qt(this._al,m)|0,this._bh=this._bh+n+qt(this._bl,g)|0,this._ch=this._ch+i+qt(this._cl,v)|0,this._dh=this._dh+o+qt(this._dl,E)|0,this._eh=this._eh+s+qt(this._el,T)|0,this._fh=this._fh+a+qt(this._fl,N)|0,this._gh=this._gh+f+qt(this._gl,L)|0,this._hh=this._hh+l+qt(this._hl,F)|0};zs.prototype._hash=function(){var e=UB.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};$b.exports=zs});var Xb=B((bD,Zb)=>{"use strict";p();var GB=Fe(),VB=Jh(),WB=Ui(),zB=Gt().Buffer,YB=new Array(160);function df(){this.init(),this._w=YB,WB.call(this,128,112)}GB(df,VB);df.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};df.prototype._hash=function(){var e=zB.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};Zb.exports=df});var Qh=B((SD,wn)=>{"use strict";p();wn.exports=function(t){var r=t.toLowerCase(),n=wn.exports[r];if(!n)throw new Error(r+" is not supported (we accept pull requests)");return new n};wn.exports.sha=Cb();wn.exports.sha1=Ub();wn.exports.sha224=Hb();wn.exports.sha256=Xh();wn.exports.sha384=Xb();wn.exports.sha512=Jh()});var pf=B((ED,Qb)=>{"use strict";p();var $B=Gt().Buffer,Jb=Ph().Transform,ZB=Ro().StringDecoder,XB=Fe(),JB=Xu();function Br(e){Jb.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}XB(Br,Jb);Br.prototype.update=function(e,t,r){var n=JB(e,t),i=this._update(n);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)};Br.prototype.setAutoPadding=function(){};Br.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Br.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Br.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Br.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(i){n=i}finally{r(n)}};Br.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};Br.prototype._finalOrDigest=function(e){var t=this.__final()||$B.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Br.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new ZB(t),this._encoding=t),this._encoding!==t)throw new Error("can\u2019t switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n};Qb.exports=Br});var r_=B((ID,t_)=>{"use strict";p();var QB=Fe(),eN=Bh(),tN=Zh(),rN=Qh(),e_=pf();function gf(e){e_.call(this,"digest"),this._hash=e}QB(gf,e_);gf.prototype._update=function(e){this._hash.update(e)};gf.prototype._final=function(){return this._hash.digest()};t_.exports=function(t){return t=t.toLowerCase(),t==="md5"?new eN:t==="rmd160"||t==="ripemd160"?new tN:new gf(rN(t))}});var o_=B((AD,i_)=>{"use strict";p();var nN=Fe(),Fi=Gt().Buffer,n_=pf(),iN=Fi.alloc(128),Lo=64;function yf(e,t){n_.call(this,"digest"),typeof t=="string"&&(t=Fi.from(t)),this._alg=e,this._key=t,t.length>Lo?t=e(t):t.length<Lo&&(t=Fi.concat([t,iN],Lo));for(var r=this._ipad=Fi.allocUnsafe(Lo),n=this._opad=Fi.allocUnsafe(Lo),i=0;i<Lo;i++)r[i]=t[i]^54,n[i]=t[i]^92;this._hash=[r]}nN(yf,n_);yf.prototype._update=function(e){this._hash.push(e)};yf.prototype._final=function(){var e=this._alg(Fi.concat(this._hash));return this._alg(Fi.concat([this._opad,e]))};i_.exports=yf});var a_=B((TD,s_)=>{p();var oN=Bh();s_.exports=function(e){return new oN().update(e).digest()}});var c_=B((BD,f_)=>{"use strict";p();var sN=Fe(),aN=o_(),u_=pf(),Ys=Gt().Buffer,uN=a_(),ed=Zh(),td=Qh(),fN=Ys.alloc(128);function $s(e,t){u_.call(this,"digest"),typeof t=="string"&&(t=Ys.from(t));var r=e==="sha512"||e==="sha384"?128:64;if(this._alg=e,this._key=t,t.length>r){var n=e==="rmd160"?new ed:td(e);t=n.update(t).digest()}else t.length<r&&(t=Ys.concat([t,fN],r));for(var i=this._ipad=Ys.allocUnsafe(r),o=this._opad=Ys.allocUnsafe(r),s=0;s<r;s++)i[s]=t[s]^54,o[s]=t[s]^92;this._hash=e==="rmd160"?new ed:td(e),this._hash.update(i)}sN($s,u_);$s.prototype._update=function(e){this._hash.update(e)};$s.prototype._final=function(){var e=this._hash.digest(),t=this._alg==="rmd160"?new ed:td(this._alg);return t.update(this._opad).update(e).digest()};f_.exports=function(t,r){return t=t.toLowerCase(),t==="rmd160"||t==="ripemd160"?new $s("rmd160",r):t==="md5"?new aN(uN,r):new $s(t,r)}});var l_=B((MD,nd)=>{"use strict";p();var rd=65536,cN=4294967295;function lN(){throw new Error(`Secure random number generation is not supported by this browser.
11
+ Use Chrome, Firefox or Internet Explorer 11`)}var hN=Gt().Buffer,mf=globalThis.crypto||globalThis.msCrypto;mf&&mf.getRandomValues?nd.exports=dN:nd.exports=lN;function dN(e,t){if(e>cN)throw new RangeError("requested too many random bytes");var r=hN.allocUnsafe(e);if(e>0)if(e>rd)for(var n=0;n<e;n+=rd)mf.getRandomValues(r.slice(n,n+rd));else mf.getRandomValues(r);return typeof t=="function"?x.default.nextTick(function(){t(null,r)}):r}});var Zs=B(vf=>{"use strict";p();vf.createHash=r_();vf.createHmac=c_();vf.randomBytes=l_()});var Xs=B((DD,d_)=>{"use strict";p();var h_=65536;function qi(){}qi.getRandomBuffer=function(e){var t=typeof globalThis<"u"?globalThis.crypto:void 0;if(t&&typeof t.getRandomValues=="function")return qi._fromGetRandomValues(t,e);try{var r=Zs();if(r&&typeof r.randomBytes=="function")return r.randomBytes(e)}catch{}throw new Error("bsv: no CSPRNG available in this environment (needs globalThis.crypto.getRandomValues or node crypto)")};qi._fromGetRandomValues=function(e,t){for(var r=d.Buffer.alloc(t),n=0;n<t;n+=h_){var i=new Uint8Array(Math.min(h_,t-n));e.getRandomValues(i),d.Buffer.from(i).copy(r,n)}return r};qi.getRandomBufferNode=function(e){var t=Zs();return t.randomBytes(e)};qi.getRandomBufferBrowser=function(e){var t=typeof globalThis<"u"?globalThis:{},r=null;if(t.crypto&&typeof t.crypto.getRandomValues=="function"?r=t.crypto:t.msCrypto&&typeof t.msCrypto.getRandomValues=="function"&&(r=t.msCrypto),!r)throw new Error("window.crypto.getRandomValues not available");return qi._fromGetRandomValues(r,e)};d_.exports=qi});var ze=B((FD,p_)=>{"use strict";p();var pN=Xs(),We={};We.isArray=e=>Array.isArray(e);We.isNumber=e=>typeof e=="number";We.isObject=e=>e&&typeof e=="object";We.isString=e=>typeof e=="string";We.isUndefined=e=>typeof e>"u";We.isFunction=e=>typeof e=="function";We.isNull=e=>e===null;We.isDate=e=>e instanceof Date;We.extend=(e,t)=>Object.assign(e,t);We.noop=()=>{};We.every=(e,t)=>e.every(t||(r=>r));We.map=(e,t)=>Array.from(e).map(t||(r=>r));We.includes=(e,t)=>e.includes(t);We.each=(e,t)=>e.forEach(t);We.clone=e=>Object.assign({},e);We.pick=(e,t)=>{let r={};return t.forEach(n=>{typeof e[n]<"u"&&(r[n]=e[n])}),r};We.values=e=>Object.values(e);We.filter=(e,t)=>e.filter(t);We.reduce=(e,t,r)=>e.reduce(t,r);We.without=(e,t)=>e.filter(r=>r!==t);We.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let i=pN.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(i*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};We.difference=(e,t)=>e.filter(r=>!t.includes(r));We.findIndex=(e,t)=>e.findIndex(t);We.some=(e,t)=>e.some(t);We.range=e=>[...Array(e).keys()];p_.exports=We});var y_=B((jD,g_)=>{"use strict";p();var gN="https://docs.moneybutton.com/";g_.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+gN+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]});var Zn=B((KD,od)=>{"use strict";p();var id=ze();function yN(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var m_=function(e,t){var r=function(){if(id.isString(t.message))this.message=yN(t.message,arguments);else if(id.isFunction(t.message))this.message=t.message.apply(null,arguments);else throw new Error("Invalid error definition for "+t.name);this.stack=this.message+`
12
+ `+new Error().stack};return r.prototype=Object.create(e.prototype),r.prototype.name=e.prototype.name+t.name,e[t.name]=r,t.errors&&v_(r,t.errors),r},v_=function(e,t){id.each(t,function(r){m_(e,r)})},mN=function(e,t){return v_(e,t),e},Do={};Do.Error=function(){this.message="Internal error",this.stack=this.message+`
13
+ `+new Error().stack};Do.Error.prototype=Object.create(Error.prototype);Do.Error.prototype.name="bsv.Error";var vN=y_();mN(Do.Error,vN);od.exports=Do.Error;od.exports.extend=function(e){return m_(Do.Error,e)}});var Le=B((VD,b_)=>{"use strict";p();var Js=Zn(),bN=ze();b_.exports={checkState:function(e,t){if(!e)throw new Js.InvalidState(t)},checkArgument:function(e,t,r,n){if(!e)throw new Js.InvalidArgument(t,r,n)},checkArgumentType:function(e,t,r){if(r=r||"(unknown name)",bN.isString(t)){if(t==="Buffer"){var n=Nt();if(!n.Buffer.isBuffer(e))throw new Js.InvalidArgumentType(e,t,r)}else if(typeof e!==t)throw new Js.InvalidArgumentType(e,t,r)}else if(!(e instanceof t))throw new Js.InvalidArgumentType(e,t.name,r)}}});var wr=B((zD,E_)=>{"use strict";p();var Me=P0(),S_=Le(),w_=ze(),bf=function(e){for(var t=d.Buffer.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};Me.Zero=new Me(0);Me.One=new Me(1);Me.Minus1=new Me(-1);Me.fromNumber=function(e){return S_.checkArgument(w_.isNumber(e)),new Me(e)};Me.fromString=function(e,t){return S_.checkArgument(w_.isString(e)),new Me(e,t)};Me.fromBuffer=function(e,t){typeof t<"u"&&t.endian==="little"&&(e=bf(e));var r=e.toString("hex"),n=new Me(r,16);return n};Me.fromSM=function(e,t){var r;if(e.length===0)return Me.fromBuffer(d.Buffer.from([0]));var n="big";return t&&(n=t.endian),n==="little"&&(e=bf(e)),e[0]&128?(e[0]=e[0]&127,r=Me.fromBuffer(e),r.neg().copy(r)):r=Me.fromBuffer(e),r};Me.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Me.prototype.toBuffer=function(e){var t,r;if(e&&e.size){r=this.toString(16,2);var n=r.length/2;t=d.Buffer.from(r,"hex"),n===e.size||(n>e.size?t=Me.trim(t,n):n<e.size&&(t=Me.pad(t,n,e.size)))}else r=this.toString(16,2),t=d.Buffer.from(r,"hex");return typeof e<"u"&&e.endian==="little"&&(t=bf(t)),t};Me.prototype.toSMBigEndian=function(){var e;return this.cmp(Me.Zero)===-1?(e=this.neg().toBuffer(),e[0]&128?e=d.Buffer.concat([d.Buffer.from([128]),e]):e[0]=e[0]|128):(e=this.toBuffer(),e[0]&128&&(e=d.Buffer.concat([d.Buffer.from([0]),e]))),e.length===1&&e[0]===0&&(e=d.Buffer.from([])),e};Me.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return t==="little"&&(r=bf(r)),r};function __(e,t){var r=new Error(e);return r.scriptErr=t,r}Me.fromScriptNumBuffer=function(e,t,r){var n=r||4;if(e.length>n)throw __("script number overflow","SCRIPT_ERR_SCRIPTNUM_OVERFLOW");if(t&&e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))throw __("non-minimally encoded script number","SCRIPT_ERR_SCRIPTNUM_MINENCODE");return Me.fromSM(e,{endian:"little"})};Me.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};Me.trim=function(e,t){return e.slice(t-e.length,e.length)};Me.pad=function(e,t,r){for(var n=d.Buffer.alloc(r),i=0;i<e.length;i++)n[n.length-1-i]=e[e.length-1-i];for(i=0;i<r-t;i++)n[i]=0;return n};Me.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")};Me.fromHex=function(e,...t){return Me.fromBuffer(d.Buffer.from(e,"hex"),...t)};E_.exports=Me});function _N(e,t=!1){return t?{h:Number(e&_f),l:Number(e>>x_&_f)}:{h:Number(e>>x_&_f)|0,l:Number(e&_f)|0}}function I_(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=_N(e[o],t);[n[o],i[o]]=[s,a]}return[n,i]}function O_(e,t,r,n){let i=SN(r),o=wN(r);e.setUint32(t,n?o:i,n),e.setUint32(t+4,n?i:o,n)}function tn(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var _f,x_,SN,wN,sd,ad,ji,Hi,Qs,ea,A_,R_,T_,P_,B_,N_,ud=Wt(()=>{p();_f=BigInt(4294967295),x_=BigInt(32);SN=e=>e/2**32|0,wN=e=>e>>>0;sd=(e,t,r)=>e>>>r,ad=(e,t,r)=>e<<32-r|t>>>r,ji=(e,t,r)=>e>>>r|t<<32-r,Hi=(e,t,r)=>e<<32-r|t>>>r,Qs=(e,t,r)=>e<<64-r|t>>>r-32,ea=(e,t,r)=>e>>>r-32|t<<64-r;A_=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),R_=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,T_=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),P_=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,B_=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),N_=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0});function Sf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function En(e,t=""){if(typeof e!="number")throw new TypeError(fd(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(fd(t)+"expected integer >= 0, got "+e);return e}function rn(e,t,r=""){if(Sf(e)&&(t===void 0||e.length===t))return e;t!==void 0&&En(t,"length");let n=Sf(e),i=t!==void 0?` of length ${t}`:"",o=n?`length=${e.length}`:`type=${typeof e}`,s=fd(r)+"expected Uint8Array"+i+", got "+o;throw n?new RangeError(s):new TypeError(s)}function wf(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(En(e.outputLen),En(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}function Uo(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Ef(e,t){rn(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function ar(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function xf(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Nr(e,t){return e<<32-t|e>>>t}function xn(e,t){return e<<t|e>>>32-t>>>0}function If(e){if(rn(e),C_)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=xN[e[r]];return t}function k_(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function cd(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(C_)try{return Uint8Array.fromHex(e)}catch(i){throw i instanceof SyntaxError?new RangeError(i.message):i}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=k_(e.charCodeAt(o)),a=k_(e.charCodeAt(o+1));if(s===void 0||a===void 0){let f=e[o]+e[o+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+o)}n[i]=s*16+a}return n}function In(e){if(typeof e!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function L_(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];rn(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let o=e[n];r.set(o,i),i+=o.length}return r}function IN(e,t,r="opts"){return M_(e,"defaults"),t!==void 0&&M_(t,r),Object.assign(e,t)}function Mr(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=IN({},t,"info");let r=(i,o)=>e(o).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}function ta(e=32){En(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var fd,M_,C_,xN,Ki,On=Wt(()=>{p();fd=e=>e?`"${e}" `:"";M_=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)};C_=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",xN=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Ki=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})});function Fo(e,t,r){return e&t^~e&r}function Of(e,t,r){return e&t^e&r^t&r}var An,D_,U_,F_,q_,ld=Wt(()=>{p();ud();On();An=class{constructor(t,r,n,i){$(this,"blockLen");$(this,"outputLen");$(this,"canXOF",!1);$(this,"padOffset");$(this,"isLE");$(this,"buffer");$(this,"view");$(this,"finished",!1);$(this,"length",0);$(this,"pos",0);$(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=xf(this.buffer)}update(t){Uo(this),rn(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length,s=!1;for(let a=0;a<o;){let f=Math.min(i-this.pos,o-a);if(f===i){let l=xf(t);for(;i<=o-a;a+=i)this.process(l,a);s=!0;continue}n.set(a===0&&f===o?t:t.subarray(a,a+f),this.pos),this.pos+=f,a+=f,this.pos===i&&(this.process(r,0),this.pos=0,s=!0)}return this.length+=t.length,s&&this.roundClean(),this}digestInto(t){Uo(this),Ef(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,r.fill(0,s),this.padOffset>i-s&&(this.process(n,0),r.fill(0)),O_(n,i-8,this.length*8,o),this.process(n,0),this.roundClean();let a=t===r?n:xf(t),f=this.outputLen,l=f/4,m=this.get();if(f%4||l>m.length)throw new Error("invalid outputLen");for(let g=0;g<l;g++)a.setUint32(4*g,m[g],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.destroyed=o,t.finished=i,t.length=n,t.pos=s,s&&t.buffer.set(r),t}clone(){return this._cloneInto()}},D_=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),U_=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),F_=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),q_=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});var H_={};ol(H_,{_SHA224:()=>Tf,_SHA256:()=>Rf,_SHA384:()=>Bf,_SHA512:()=>Pf,_SHA512_224:()=>Nf,_SHA512_256:()=>Mf,sha224:()=>BN,sha256:()=>ei,sha384:()=>MN,sha512:()=>NN,sha512_224:()=>CN,sha512_256:()=>kN});var ON,Xn,Af,Rf,Tf,j_,AN,RN,Jn,Qn,qo,Pf,Bf,TN,PN,Nf,Mf,ei,BN,NN,MN,kN,CN,hd=Wt(()=>{p();ld();ud();On();ON=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Xn=new Uint32Array(64),Af=class extends An{constructor(r,n){super(64,r,8,!1);$(this,"A",0);$(this,"B",0);$(this,"C",0);$(this,"D",0);$(this,"E",0);$(this,"F",0);$(this,"G",0);$(this,"H",0);this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:r,B:n,C:i,D:o,E:s,F:a,G:f,H:l}=this;return[r,n,i,o,s,a,f,l]}set(r,n,i,o,s,a,f,l){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0,this.F=a|0,this.G=f|0,this.H=l|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let v=0;v<16;v++,n+=4)Xn[v]=r.getUint32(n,!1);for(let v=16;v<64;v++){let E=Xn[v-15],T=Xn[v-2],N=Nr(E,7)^Nr(E,18)^E>>>3,L=Nr(T,17)^Nr(T,19)^T>>>10;Xn[v]=L+Xn[v-7]+N+Xn[v-16]|0}let{A:i,B:o,C:s,D:a,E:f,F:l,G:m,H:g}=this;for(let v=0;v<64;v++){let E=Nr(f,6)^Nr(f,11)^Nr(f,25),T=g+E+Fo(f,l,m)+ON[v]+Xn[v]|0,L=(Nr(i,2)^Nr(i,13)^Nr(i,22))+Of(i,o,s)|0;g=m,m=l,l=f,f=a+T|0,a=s,s=o,o=i,i=T+L|0}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,f=f+this.E|0,l=l+this.F|0,m=m+this.G|0,g=g+this.H|0,this.set(i,o,s,a,f,l,m,g)}roundClean(){ar(Xn)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),ar(this.buffer)}},Rf=class extends Af{constructor(){super(32,D_)}},Tf=class extends Af{constructor(){super(28,U_)}},j_=I_(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),AN=j_[0],RN=j_[1],Jn=new Uint32Array(80),Qn=new Uint32Array(80),qo=class extends An{constructor(r,n){super(128,r,16,!1);$(this,"Ah",0);$(this,"Al",0);$(this,"Bh",0);$(this,"Bl",0);$(this,"Ch",0);$(this,"Cl",0);$(this,"Dh",0);$(this,"Dl",0);$(this,"Eh",0);$(this,"El",0);$(this,"Fh",0);$(this,"Fl",0);$(this,"Gh",0);$(this,"Gl",0);$(this,"Hh",0);$(this,"Hl",0);this.Ah=n[0]|0,this.Al=n[1]|0,this.Bh=n[2]|0,this.Bl=n[3]|0,this.Ch=n[4]|0,this.Cl=n[5]|0,this.Dh=n[6]|0,this.Dl=n[7]|0,this.Eh=n[8]|0,this.El=n[9]|0,this.Fh=n[10]|0,this.Fl=n[11]|0,this.Gh=n[12]|0,this.Gl=n[13]|0,this.Hh=n[14]|0,this.Hl=n[15]|0}get(){let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:f,Dl:l,Eh:m,El:g,Fh:v,Fl:E,Gh:T,Gl:N,Hh:L,Hl:F}=this;return[r,n,i,o,s,a,f,l,m,g,v,E,T,N,L,F]}set(r,n,i,o,s,a,f,l,m,g,v,E,T,N,L,F){this.Ah=r|0,this.Al=n|0,this.Bh=i|0,this.Bl=o|0,this.Ch=s|0,this.Cl=a|0,this.Dh=f|0,this.Dl=l|0,this.Eh=m|0,this.El=g|0,this.Fh=v|0,this.Fl=E|0,this.Gh=T|0,this.Gl=N|0,this.Hh=L|0,this.Hl=F|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let W=0;W<16;W++,n+=4)Jn[W]=r.getUint32(n),Qn[W]=r.getUint32(n+=4);for(let W=16;W<80;W++){let ie=Jn[W-15]|0,ee=Qn[W-15]|0,ge=ji(ie,ee,1)^ji(ie,ee,8)^sd(ie,ee,7),ce=Hi(ie,ee,1)^Hi(ie,ee,8)^ad(ie,ee,7),me=Jn[W-2]|0,I=Qn[W-2]|0,u=ji(me,I,19)^Qs(me,I,61)^sd(me,I,6),h=Hi(me,I,19)^ea(me,I,61)^ad(me,I,6),y=T_(ce,h,Qn[W-7],Qn[W-16]),S=P_(y,ge,u,Jn[W-7],Jn[W-16]);Jn[W]=S|0,Qn[W]=y|0}let{Ah:i,Al:o,Bh:s,Bl:a,Ch:f,Cl:l,Dh:m,Dl:g,Eh:v,El:E,Fh:T,Fl:N,Gh:L,Gl:F,Hh:V,Hl:z}=this;for(let W=0;W<80;W++){let ie=ji(v,E,14)^ji(v,E,18)^Qs(v,E,41),ee=Hi(v,E,14)^Hi(v,E,18)^ea(v,E,41),ge=v&T^~v&L,ce=E&N^~E&F,me=B_(z,ee,ce,RN[W],Qn[W]),I=N_(me,V,ie,ge,AN[W],Jn[W]),u=me|0,h=ji(i,o,28)^Qs(i,o,34)^Qs(i,o,39),y=Hi(i,o,28)^ea(i,o,34)^ea(i,o,39),S=i&s^i&f^s&f,w=o&a^o&l^a&l;V=L|0,z=F|0,L=T|0,F=N|0,T=v|0,N=E|0,{h:v,l:E}=tn(m|0,g|0,I|0,u|0),m=f|0,g=l|0,f=s|0,l=a|0,s=i|0,a=o|0;let R=A_(u,y,w);i=R_(R,I,h,S),o=R|0}({h:i,l:o}=tn(this.Ah|0,this.Al|0,i|0,o|0)),{h:s,l:a}=tn(this.Bh|0,this.Bl|0,s|0,a|0),{h:f,l}=tn(this.Ch|0,this.Cl|0,f|0,l|0),{h:m,l:g}=tn(this.Dh|0,this.Dl|0,m|0,g|0),{h:v,l:E}=tn(this.Eh|0,this.El|0,v|0,E|0),{h:T,l:N}=tn(this.Fh|0,this.Fl|0,T|0,N|0),{h:L,l:F}=tn(this.Gh|0,this.Gl|0,L|0,F|0),{h:V,l:z}=tn(this.Hh|0,this.Hl|0,V|0,z|0),this.set(i,o,s,a,f,l,m,g,v,E,T,N,L,F,V,z)}roundClean(){ar(Jn,Qn)}destroy(){this.destroyed=!0,ar(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Pf=class extends qo{constructor(){super(64,q_)}},Bf=class extends qo{constructor(){super(48,F_)}},TN=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),PN=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),Nf=class extends qo{constructor(){super(28,TN)}},Mf=class extends qo{constructor(){super(32,PN)}},ei=Mr(()=>new Rf,Ki(1)),BN=Mr(()=>new Tf,Ki(4)),NN=Mr(()=>new Pf,Ki(3)),MN=Mr(()=>new Bf,Ki(2)),kN=Mr(()=>new Mf,Ki(6)),CN=Mr(()=>new Nf,Ki(5))});function rt(e,t,r=()=>{}){if(!Array.isArray(e))throw new TypeError(`"${t}" expected array, got type=${typeof e}`);for(let n=0;n<e.length;n++)r(e[n],`${t}[${n}]`);return e}function ra(e,t=""){if(typeof e!="string"){let r=t&&`"${t}" `;throw new TypeError(r+"expected string, got type="+typeof e)}return e}function ti(e,t="object"){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(t==="object"?"expected valid options object":`"${t}" expected object, got type=${typeof e}`);return e}function Gi(e,t){if(typeof e!="function")throw new TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}function on(e,t=""){if(typeof e!="boolean")throw new TypeError(LN(t)+"expected boolean, got type="+typeof e);return e}function Cf(e){if(typeof e=="bigint"){if(!ri(e))throw new RangeError("positive bigint expected, got "+e)}else dd(e);return e}function nt(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function na(e){let t=Cf(e).toString(16);return t.length&1?"0"+t:t}function G_(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?kf:BigInt("0x"+e)}function Mt(e){return G_(If(e))}function Ho(e){return G_(If(Df(rn(e)).reverse()))}function Lf(e,t){if(En(t),t===0)throw new Error("zero output length is invalid");e=Cf(e);let r=t*2,n=e.toString(16);if(n.length>r)throw new RangeError("number is too large");return cd(n.padStart(r,"0"))}function pd(e,t){return Lf(e,t).reverse()}function Df(e){return Uint8Array.from(Se(e))}function Ko(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}function ri(e){return typeof e=="bigint"&&kf<=e}function gd(e,t,r){return ri(e)&&ri(t)&&ri(r)&&t<=e&&e<r}function yd(e,t,r,n){if(!gd(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Go(e){if(e<kf)throw new Error("expected non-negative bigint, got "+e);return e===kf?0:e.toString(2).length}function V_(e,t,r){if(En(e,"hashLen"),En(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=L=>new Uint8Array(L),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,f=n(e),l=n(e),m=0,g=()=>{f.fill(1),l.fill(0),m=0},v=(...L)=>r(l,Ce(f,...L)),E=(L=i)=>{l=v(o,L),f=v(),L.length!==0&&(l=v(s,L),f=v())},T=()=>{if(m++>=a)throw new Error("drbg: tried max amount of iterations");let L=0,F=[];for(;L<t;){f=v();let V=f.slice();F.push(V),L+=f.length}return Ce(...F)};return(L,F)=>{g(),E(L);let V;for(;(V=F(T()))===void 0;)E();return g(),V}}function qe(e,t={},r={},n="object"){ti(e,n),ti(t,"fields"),ti(r,"optFields");function i(s,a,f){let l=n==="object"?`param "${String(s)}"`:`"${n}.${String(s)}"`,m=e[s];if(!Object.hasOwn(e,s)&&(f?m!==void 0:a!=="function"))throw new TypeError(`${l} is invalid: expected own property`);if(f&&m===void 0)return;let g=typeof m;if(g!==a||m===null)throw new TypeError(`${l} is invalid: expected ${a}, got ${g}`)}let o=(s,a)=>Object.entries(s).forEach(([f,l])=>i(f,l,a));o(t,!1),o(r,!0)}var Se,dd,Rn,Ce,jo,nn,Qt,kf,K_,LN,ia,ni=Wt(()=>{p();On();Se=(e,t,r)=>rn(e,t,r),dd=En;Rn=If,Ce=(...e)=>L_(...e),jo=e=>cd(e),nn=Sf,Qt=e=>ta(e),kf=BigInt(0),K_=BigInt(1),LN=e=>e?`"${e}" `:"";ia=e=>(nt(e,"n"),(K_<<BigInt(e))-K_)});function er(e,t){if(t<=kt)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=kt?r:t+r}function J_(e,t,r){if(r<=Ue)throw new Error("pow: expected modulus > 1, got "+r);if(typeof t!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof t);if(t<kt)throw new Error("invalid exponent, negatives unsupported");if(t===kt)return Ue;if(t===Ue)return e;let n=e%r;if(n<kt&&(n+=r),t<qN){let a=Ue;for(;t>kt;)t&Ue&&(a=a*n%r),n=n*n%r,t>>=Ue;return a}let i=[];for(;t>kt;)i.push(Number(t&FN)),t>>=vd;let o=new Array(16);o[0]=Ue,o[1]=n;for(let a=2;a<16;a++)o[a]=o[a-1]*n%r;let s=o[i[i.length-1]];for(let a=i.length-2;a>=0;a--){s=s*s%r,s=s*s%r,s=s*s%r,s=s*s%r;let f=i[a];f!==0&&(s=s*o[f]%r)}return s}function hr(e,t,r){if(r<=Ue)throw new Error("pow2: expected modulus > 1, got "+r);if(t<kt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >kt;)n*=n,n%=r;return n}function W_(e,t){if(e===kt)throw new Error("invert: expected non-zero number");if(t<=Ue)throw new Error("invert: expected modulus > 1, got "+t);let r=er(e,t),n=t,i=kt,o=Ue;for(;r!==kt;){let a=n/r,f=n-r*a,l=i-o*a;n=r,r=f,i=o,o=l}if(n!==Ue)throw new Error("invert: does not exist");return er(i,t)}function Q_(e,t){if(t<=Ue)throw new Error("invertCt: expected prime modulus > 1, got "+t);let r=er(e,t);if(r===kt)throw new Error("invertCt: expected non-zero number");let n=J_(r,t-ii,t);if(er(r*n,t)!==Ue)throw new Error("invertCt: does not exist");return n}function bd(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function _d(e,t){if((e&Ue)===kt)throw new Error(t+": expected odd modulus, got "+e)}function eS(e,t){let r=e,n=(r.ORDER+Ue)/vd,i=r.pow(t,n);return bd(r,i,t),i}function jN(e,t){let r=e,n=(r.ORDER-$_)/Z_,i=r.mul(t,ii),o=r.pow(i,n),s=r.mul(t,o),a=r.mul(r.mul(s,ii),o),f=r.mul(s,r.sub(a,r.ONE));return bd(r,f,t),f}function HN(e){let t=Wo(e),r=tS(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+DN)/X_;return((a,f)=>{let l=a,m=l.pow(f,s),g=l.mul(m,n),v=l.mul(m,i),E=l.mul(m,o),T=l.eql(l.sqr(g),f),N=l.eql(l.sqr(v),f);m=l.cmov(m,g,T),g=l.cmov(E,v,N);let L=l.eql(l.sqr(g),f),F=l.cmov(m,g,L);return bd(l,F,f),F})}function tS(e){if(e<Y_)throw new Error("sqrt is not defined for small field");_d(e,"tonelliShanks");let t=e-Ue,r=0;for(;t%ii===kt;)t/=ii,r++;let n=ii,i=Wo(e);for(;md(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return eS;let o=i.pow(n,t),s=(t+Ue)/ii;return function(f,l){let m=f;if(m.is0(l))return l;if(md(m,l)!==1)throw new Error("Cannot find square root");let g=r,v=m.mul(m.ONE,o),E=m.pow(l,t),T=m.pow(l,s);for(;!m.eql(E,m.ONE);){if(m.is0(E))throw new Error("Cannot find square root: probably non-prime P");let N=1,L=m.sqr(E);for(;!m.eql(L,m.ONE);)if(N++,L=m.sqr(L),N===g)throw new Error("Cannot find square root");let F=Ue<<BigInt(g-N-1),V=m.pow(v,F);g=N,v=m.sqr(V),E=m.mul(E,v),T=m.mul(T,V)}return T}}function KN(e){return _d(e,"Fp.sqrt"),e%vd===Y_?eS:e%Z_===$_?jN:e%X_===UN?HN(e):tS(e)}function Er(e){if(ti(e,"field"),typeof e.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof e.ORDER);nt(e.BYTES,"BYTES"),nt(e.BITS,"BITS");for(let t of GN)Gi(e[t],"field."+t);if(e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Ue)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Vo(e,t,r=!1){Er(e),rt(t,"nums"),on(r,"passZero");let n=e,i=new Array(t.length).fill(r?n.ZERO:void 0),o=t.reduce((a,f,l)=>n.is0(f)?a:(i[l]=a,n.mul(a,f)),n.ONE),s=n.inv(o);return t.reduceRight((a,f,l)=>n.is0(f)?a:(i[l]=n.mul(a,i[l]),n.mul(a,f)),s),i}function md(e,t){Er(e);let r=e;_d(r.ORDER,"FpLegendre");let n=(r.ORDER-Ue)/ii,i=r.pow(t,n),o=r.eql(i,r.ONE),s=r.eql(i,r.ZERO),a=r.eql(i,r.neg(r.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function Sd(e,t){return md(e,t)!==-1}function VN(e,t){if(t!==void 0&&dd(t),e<=kt)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Go(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${r})`);let n=t!==void 0?t:r,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}function Wo(e,t={}){return Object.freeze(Uf.prototype),new Uf(e,t)}function rS(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=Ue)throw new Error("field order must be greater than 1");let t=Go(e-Ue);return Math.ceil(t/8)}function zo(e){let t=rS(e);return t+Math.ceil(t/2)}function Vi(e,t,r=!1){Se(e);let n=e.length,i=rS(t),o=Math.max(zo(t),16);if(n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?Ho(e):Mt(e),a=er(s,t-Ue)+Ue;return r?pd(a,i):Lf(a,i)}var kt,Ue,ii,Y_,vd,$_,DN,Z_,UN,FN,X_,qN,GN,z_,Uf,Wi=Wt(()=>{p();ni();kt=BigInt(0),Ue=BigInt(1),ii=BigInt(2),Y_=BigInt(3),vd=BigInt(4),$_=BigInt(5),DN=BigInt(7),Z_=BigInt(8),UN=BigInt(9),FN=BigInt(15),X_=BigInt(16),qN=BigInt("0x10000000000000000");GN=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];z_=new WeakMap,Uf=class{constructor(t,r={}){$(this,"ORDER");$(this,"BITS");$(this,"BYTES");$(this,"isLE");$(this,"ZERO",kt);$(this,"ONE",Ue);$(this,"_lengths");$(this,"_mod");if(t<=Ue)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:i,nByteLength:o}=VN(t,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=i,this.BYTES=o,Object.freeze(this)}create(t){return er(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return kt<=t&&t<this.ORDER}is0(t){return t===kt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&Ue)===Ue}neg(t){return er(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return er(t*t,this.ORDER)}add(t,r){return er(t+r,this.ORDER)}sub(t,r){return er(t-r,this.ORDER)}mul(t,r){return er(t*r,this.ORDER)}pow(t,r){return J_(t,r,this.ORDER)}div(t,r){return er(t*W_(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return W_(t,this.ORDER)}sqrt(t){let r=z_.get(this);return r||z_.set(this,r=KN(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?pd(t,this.BYTES):Lf(t,this.BYTES)}fromBytes(t,r=!1){Se(t);let{_lengths:n,BYTES:i,isLE:o,ORDER:s,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>i)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(i);l.set(t,o?0:l.length-t.length),t=l}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let f=o?Ho(t):Mt(t);if(a&&(f=er(f,s)),!r&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(t){return Vo(this,t,!0)}cmov(t,r,n){return on(n,"condition"),n?r:t}}});function oi(e){let t=e;if(typeof t!="function")throw new TypeError('"Point" expected constructor, got type='+typeof e);Gi(t.fromAffine,"Point.fromAffine"),Gi(t.fromBytes,"Point.fromBytes"),Gi(t.fromHex,"Point.fromHex"),ti(t.BASE,"Point.BASE"),ti(t.ZERO,"Point.ZERO"),Er(t.Fp),Er(t.Fn)}function sS(e,t){oi(e),aS(t,e);let r=Vo(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function YN(e,t,r=1){if(!Number.isSafeInteger(e)||e<r||e>t)throw new Error("invalid window size, expected ["+r+".."+t+"], got W="+e)}function $N(e,t){let r=e*(4*t+128);if(r>iS)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+iS/2**20+" MiB")}function Id(e,t){if(e!==void 0){Gi(e,"randomBytes");try{let r=e(t);if(!nn(r)||r.length!==t)return}catch{return}return e}}function aS(e,t){rt(e,"points"),e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function ZN(e,t,r){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,i)=>{if(!(r===void 0?t.isValid(n):ri(n)&&n<r))throw new Error("invalid scalar at index "+i)})}function Ed(e){return uS.get(e)||1}function XN(e,t){let r=e.double(),n=[e];for(let i=1;i<t;i++)n.push(n[i-1].add(r));return n}function JN(e,t){let r=2**t,n=r/2,i=BigInt(r-1),o=[];for(;e>xd;){let s=0;e&oa&&(s=Number(e&i),s>=n&&(s-=r),e-=BigInt(s)),o.push(s),e>>=oa}return o}function QN(e,t,r){let n=2**t,i=n/2,o=BigInt(n-1),s=BigInt(t),a=[];for(let f=0;f<r;f++){let l=Number(e&o);e>>=s,l>i&&(l-=n,e+=oa),a.push(l)}if(e!==xd)throw new Error("invalid wnaf");return a}function eM(e,t,r){let n=0;for(let o of r)n=Math.max(n,o.length);let i=e;for(let o=n-1;o>=0;o--){o!==n-1&&(i=i.double());for(let s=0;s<r.length;s++){let a=r[s][o];if(a){let f=t[s][Math.abs(a)-1>>1];i=i.add(a<0?f.negate():f)}}}return i}function Yo(e,t,r,n=!1){if(oi(e),aS(t,e),on(n,"allowOversized"),ZN(r,e.Fn,n?e.Fn.ORDER**WN:void 0),t.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let i=t.map(s=>XN(s,4)),o=r.map(s=>JN(s,4));return eM(e.ZERO,i,o)}function oS(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Er(t),t}else return Wo(e,{isLE:r})}function fS(e,t,r={},n){if(e!=="weierstrass"&&e!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);qe(r);for(let f of["p","n","h"]){let l=t[f];if(!(ri(l)&&l!==xd))throw new Error(`CURVE.${f} must be positive bigint`)}let i=oS(t.p,r.Fp,n),o=oS(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let f of a)if(!i.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function qf(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var xd,oa,WN,wd,nS,zN,iS,uS,Ff,jf=Wt(()=>{p();ni();Wi();xd=BigInt(0),oa=BigInt(1),WN=BigInt(4),wd=16,nS=128,zN=5,iS=2**31;uS=new WeakMap;Ff=class{constructor(t,r){$(this,"Point");$(this,"BASE");$(this,"ZERO");$(this,"randomBytes");$(this,"wnafPrecomputes",new WeakMap);$(this,"baseCanBeBlinded");$(this,"bits");oi(t),this.randomBytes=Id(r,wd),this.Point=t,this.BASE=t.BASE,this.ZERO=t.ZERO,this.bits=t.Fn.BITS}buildWnafTable(t,r,n){let i=Math.ceil(n/r)+1,o=2**(r-1),s=[],a=t;for(let f=0;f<i;f++){let l=a;for(let m=0;m<o;m++)s.push(l),l=l.add(a);a=s[s.length-1].double()}return{W:r,bits:n,windows:i,comp:s}}wnafCachedCT(t,r){let{W:n,windows:i,comp:o}=t,s=2**(n-1),a=QN(r,n,i),f=this.ZERO,l=this.BASE;for(let m=0;m<i;m++){let g=a[m],v=m*s,E=Math.abs(g)-1,T=o[v];for(let L=1;L<s;L++)T=L===E?o[v+L]:T;let N=T.negate();g===0?l=l.add(o[v]):f=f.add(g<0?N:T)}return{p:f,f:l}}getWnafPrecomputes(t,r,n,i){let o=this.wnafPrecomputes.get(r),s=o?.find(a=>a.W===t&&a.bits===n);return s||(s=this.buildWnafTable(r,t,n),typeof i=="function"&&(s={...s,comp:i(s.comp)}),o||(o=[],this.wnafPrecomputes.set(r,o)),o.push(s)),s}assertPoint(t){if(!(t instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof t)}validateMulInput(t,r){if(this.assertPoint(t),!gd(r,oa,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,r,n,i){let o=Ed(t);return o===1?this.fixedWindowCT(t,r,n):this.wnafCachedCT(this.getWnafPrecomputes(o,t,n,i),r)}mulCT(t,r,n){return this.validateMulInput(t,r),this.runCT(t,r,this.bits,n)}mulCTBlinded(t,r,n){if(this.validateMulInput(t,r),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let i=this.Point.Fn.BITS+nS,o=this.randomBytes(wd);if(!nn(o)||o.length!==wd)throw new Error("randomBytes returned invalid byte array");o[0]=o[0]&63|128;let s=r+Mt(o)*this.Point.Fn.ORDER;return this.runCT(t,s,i,n)}fixedWindowCT(t,r,n){let i=zN,o=1<<i,s=ia(i),a=new Array(o);a[0]=this.ZERO;for(let m=1;m<o;m++)a[m]=a[m-1].add(t);let f=Math.ceil(n/i),l=this.ZERO;for(let m=f-1;m>=0;m--){if(m!==f-1)for(let E=0;E<i;E++)l=l.double();let g=Number(r>>BigInt(m*i)&s),v=a[0];for(let E=1;E<o;E++)v=E===g?a[E]:v;l=l.add(v)}return{p:l,f:l}}shouldBlind(t,r){return this.randomBytes===void 0?!1:r===oa?!0:t!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(t,r,n,i){return this.shouldBlind(t,n)?this.mulCTBlinded(t,r,i):this.mulCT(t,r,i)}mulUnsafe(t,r,n){if(this.assertPoint(t),!ri(r))throw new Error("invalid scalar");let i=Ed(t);if(i===1||r>=this.Point.Fn.ORDER)return Yo(this.Point,[t],[r],!0);let o=this.getWnafPrecomputes(i,t,this.bits,n);return this.wnafCachedCT(o,r).p}setWindowSize(t,r){this.assertPoint(t),YN(r,this.bits);let n=Math.ceil((this.bits+nS)/r)+1;$N(n*2**(r-1),this.Point.Fp.BYTES),uS.set(t,r),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return Ed(t)!==1}}});function Od(e,t="n"){if(typeof e!="number")throw new TypeError(`wrong u32 integer "${t}": expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new RangeError(`wrong u32 integer "${t}": expected 0..4294967295, got ${e}`);return e}function cS(e){return Od(e,"x"),(e&e-1)===0&&e!==0}function tM(e){if(Od(e),e<=1)return 1;if(e>2147483648)throw new Error("nextPowerOfTwo overflow: result does not fit u32");return 1<<Hf(e-1)+1>>>0}function Hf(e){return Od(e),31-Math.clz32(e)}function lS(e,t,r,n,i){Er(e);let o=e,s=r||((g,v)=>new Array(g).fill(v??o.ZERO)),a=g=>{if(Array.isArray(g))return!0;if(!ArrayBuffer.isView(g))return!1;let v=g;return typeof v.length=="number"&&typeof v.slice=="function"&&typeof v[Symbol.iterator]=="function"},f=(g,v)=>{if(!a(v))throw new TypeError(`"${g}" expected polynomial, got type=${typeof v}`)},l=(g,v)=>{f("a",g);let E=g.length;if(v!==void 0&&(f("b",v),v.length!==E))throw new Error(`poly: mismatched lengths ${E} vs ${v.length}`);if(i!==void 0&&E!==i)throw new Error(`poly: expected fixed length ${i}, got ${E}`);return E};function m(g,v,E=!1,T){if(!cS(v))throw new Error("poly.lagrange: expected power of two length, got "+v);let N=T||(E?t.brp(Hf(v)):t.roots(Hf(v)));for(let L=0;L<v;L++)if(o.eql(g,N[L]))return L;return-1}return{roots:t,create:s,length:i,extend:(g,v)=>{l(g);let E=s(v,o.ZERO);for(let T=0;T<Math.min(g.length,v);T++)E[T]=g[T];return E},degree:g=>{l(g);for(let v=g.length-1;v>=0;v--)if(!o.is0(g[v]))return v;return-1},add:(g,v)=>{let E=l(g,v),T=s(E);for(let N=0;N<E;N++)T[N]=o.add(g[N],v[N]);return T},sub:(g,v)=>{let E=l(g,v),T=s(E);for(let N=0;N<E;N++)T[N]=o.sub(g[N],v[N]);return T},dot:(g,v)=>{let E=l(g,v),T=s(E);for(let N=0;N<E;N++)T[N]=o.mul(g[N],v[N]);return T},mul:(g,v)=>{if(a(v)){let E=l(g,v);if(n){let T=n.direct(g,!1,!0),N=n.direct(v,!1,!0);for(let L=0;L<T.length;L++)T[L]=o.mul(T[L],N[L]);return n.inverse(T,!0,!1)}else{let T=s(E);for(let N=0;N<E;N++)for(let L=0;L<E;L++){let F=(N+L)%E;T[F]=o.add(T[F],o.mul(g[N],v[L]))}return T}}else{let E=s(l(g));for(let T=0;T<E.length;T++)E[T]=o.mul(g[T],v);return E}},convolve(g,v){f("a",g),f("b",v);let E=tM(g.length+v.length-1);return this.mul(this.extend(g,E),this.extend(v,E))},shift(g,v){f("p",g);let E=s(g.length);if(i!==void 0&&g.length!==i)throw new Error(`poly: expected fixed length ${i}, got ${g.length}`);if(!g.length)return E;E[0]=g[0];for(let T=1,N=o.ONE;T<g.length;T++)N=o.mul(N,v),E[T]=o.mul(g[T],N);return E},clone:g=>{l(g);let v=s(g.length);for(let E=0;E<g.length;E++)v[E]=g[E];return v},eval:(g,v)=>{l(g,v);let E=o.ZERO;for(let T=0;T<g.length;T++)E=o.add(E,o.mul(g[T],v[T]));return E},monomial:{basis:(g,v)=>{let E=s(v),T=o.ONE;for(let N=0;N<v;N++)E[N]=T,T=o.mul(T,g);return E},eval:(g,v)=>{l(g);let E=o.ZERO;for(let T=g.length-1;T>=0;T--)E=o.add(o.mul(E,v),g[T]);return E}},lagrange:{basis:(g,v,E=!1,T)=>{if(!cS(v))throw new Error("poly.lagrange: expected power of two length, got "+v);let N=Hf(v),L=T||(E?t.brp(N):t.roots(N)),F=s(v),V=m(g,v,E,T);if(V!==-1)return F[V]=o.ONE,F;let z=o.pow(g,BigInt(v)),W=o.mul(o.sub(z,o.ONE),o.inv(BigInt(v))),ie=s(v);for(let ge=0;ge<v;ge++)ie[ge]=o.sub(g,L[ge]);let ee=o.invertBatch(ie);for(let ge=0;ge<v;ge++)F[ge]=o.mul(W,o.mul(L[ge],ee[ge]));return F},eval(g,v,E=!1){l(g);let T=m(v,g.length,E);if(T!==-1)return g[T];let N=this.basis(v,g.length,E),L=o.ZERO;for(let F=0;F<g.length;F++)o.is0(g[F])||(L=o.add(L,o.mul(g[F],N[F])));return L}},vanishing(g){if(f("roots",g),i!==void 0&&g.length!==i)throw new Error(`poly: expected fixed length ${i}, got ${g.length}`);let v=s(g.length+1,o.ZERO);v[0]=o.ONE;for(let E of g){let T=o.neg(E);for(let N=v.length-1;N>0;N--)v[N]=o.add(o.mul(v[N],T),v[N-1]);v[0]=o.mul(v[0],T)}return v}}}var hS=Wt(()=>{p();Wi()});function zi(e,t){if(nt(e),nt(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function nM(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function yS(e){if(!nn(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?Ko(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function iM(e,t,r,n){if(Se(e),nt(r),typeof n!="function")throw new Error("expand_message_xmd: expected hash function");nt(n.outputLen,"hash.outputLen"),nt(n.blockLen,"hash.blockLen"),t=yS(t),t.length>255&&(t=n(Ce(Ko("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(r>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=Ce(t,zi(t.length,1)),f=new Uint8Array(o),l=zi(r,2),m=new Array(s),g=n(Ce(f,e,l,zi(0,1),a));m[0]=n(Ce(g,zi(1,1),a));for(let E=1;E<s;E++){let T=[nM(g,m[E-1]),zi(E+1,1),a];m[E]=n(Ce(...T))}return Ce(...m).slice(0,r)}function oM(e,t,r,n,i){if(Se(e),nt(r),nt(n,"k"),n<0)throw new Error("expand_message_xof: invalid k");if(typeof i!="function")throw new Error("expand_message_xof: expected XOF function");if(typeof i.create!="function")throw new Error("expand_message_xof: expected XOF create");if(t=yS(t),r<0||r>65535)throw new Error("expand_message_xof: invalid lenInBytes");if(t.length>255){let o=Math.ceil(2*n/8);t=i.create({dkLen:o}).update(Ko("H2C-OVERSIZE-DST-")).update(t).digest()}if(t.length>255)throw new Error("expand_message_xof: invalid DST");return i.create({dkLen:r}).update(e).update(zi(r,2)).update(t).update(zi(t.length,1)).digest()}function Ad(e,t,r){qe(r,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:n,k:i,m:o,hash:s,expand:a,DST:f}=r;if(nt(s.outputLen,"valid hash"),Se(e),nt(t),nt(o,"m"),nt(i,"k"),n<=BigInt(1))throw new Error("hash_to_field: expected valid field characteristic");if(t<1)throw new Error("hash_to_field: expected count >= 1");if(o<1)throw new Error("hash_to_field: expected m >= 1");if(i<0)throw new Error("hash_to_field: invalid k");let l=n.toString(2).length,m=Math.ceil((l+i)/8),g=t*o*m,v;if(a==="xmd")v=iM(e,f,g,s);else if(a==="xof")v=oM(e,f,g,i,s);else if(a==="_internal_pass")v=e;else throw new Error('expand must be "xmd" or "xof"');let E=new Array(t);for(let T=0;T<t;T++){let N=new Array(o);for(let L=0;L<o;L++){let F=m*(L+T*o),V=v.subarray(F,F+m);N[L]=er(rM(V),n)}E[T]=N}return E}function mS(e,t){Er(e),rt(t,"map");let r=t.map((n,i)=>{if(rt(n,"map["+i+"]"),n.length<1)throw new Error("isogenyMap: expected non-empty coefficients");return Array.from(n).reverse()});return(n,i)=>{let[o,s,a,f]=r.map(v=>v.reduce((E,T)=>e.add(e.mul(E,n),T))),l=e.is0(s)||e.is0(f),[m,g]=Vo(e,[s,f],!0);return n=e.mul(o,m),i=e.mul(i,e.mul(a,g)),l?{x:e.ZERO,y:e.ZERO}:{x:n,y:i}}}function vS(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");qe(r);let n=f=>Object.freeze({...f,DST:nn(f.DST)?Df(f.DST):f.DST,...f.encodeDST===void 0?{}:{encodeDST:nn(f.encodeDST)?Df(f.encodeDST):f.encodeDST}}),i=n(r),o=f=>f&&f.DST!==void 0?{DST:f.DST}:void 0;function s(f){return e.fromAffine(t(f))}function a(f){let l=f.clearCofactor();return l.equals(e.ZERO)?e.ZERO:(l.assertValidity(),l)}return Object.freeze({get defaults(){return n(i)},Point:e,hashToCurve(f,l){let m=Object.assign({},i,o(l)),g=Ad(f,2,m),v=s(g[0]),E=s(g[1]);return a(v.add(E))},encodeToCurve(f,l){let m=i.encodeDST===void 0?{}:{DST:i.encodeDST},g=Object.assign({},i,m,o(l)),v=Ad(f,1,g),E=s(v[0]);return a(E)},mapToCurve(f){if(i.m===1){if(typeof f!="bigint")throw new Error("expected bigint (m=1)");return a(s([f]))}if(!Array.isArray(f))throw new Error("expected array of bigints");if(f.length!==i.m)throw new Error(`expected array of ${i.m} bigints`);for(let l of f)if(typeof l!="bigint")throw new Error("expected array of bigints");return a(s(f))},hashToScalar(f,l){let m=e.Fn.ORDER,g=Object.assign({},i,{DST:sM},o(l),{p:m,m:1});return Ad(f,1,g)[0][0]}})}function aM(e,t){let r=Er(e),n=r.ORDER,i=dS;for(let N=n-sn;N%si===dS;N/=si)i+=sn;let o=i,s=si<<o-sn-sn,a=s*si,f=(n-sn)/a,l=(f-sn)/si,m=a-sn,g=s,v=r.pow(t,f),E=r.pow(t,(f+sn)/si),T=(N,L)=>{let F=v,V=r.pow(L,m),z=r.sqr(V);z=r.mul(z,L);let W=r.mul(N,z);W=r.pow(W,l),W=r.mul(W,V),V=r.mul(W,L),z=r.mul(W,N);let ie=r.mul(z,V);W=r.pow(ie,g);let ee=r.eql(W,r.ONE);V=r.mul(z,E),W=r.mul(ie,F),z=r.cmov(V,z,ee),ie=r.cmov(W,ie,ee);for(let ge=o;ge>sn;ge--){let ce=ge-si;ce=si<<ce-sn;let me=r.pow(ie,ce),I=r.eql(me,r.ONE);V=r.mul(z,F),F=r.mul(F,F),me=r.mul(ie,F),z=r.cmov(V,z,I),ie=r.cmov(me,ie,I)}return{isValid:!r.is0(L)&&(ee||r.is0(N)),value:z}};if(r.ORDER%gS===pS){let N=(r.ORDER-pS)/gS,L=r.sqrt(r.neg(t));T=(F,V)=>{let z=r.sqr(V),W=r.mul(F,V);z=r.mul(z,W);let ie=r.pow(z,N);ie=r.mul(ie,W);let ee=r.mul(ie,L),ge=r.mul(r.sqr(ie),V),ce=r.eql(ge,F),me=r.cmov(ee,ie,ce);return{isValid:!r.is0(V)&&ce,value:me}}}return T}function bS(e,t){let r=Er(e);qe(t,{},{},"opts");let{A:n,B:i,Z:o}=t;if(!r.isValidNot0(n)||!r.isValidNot0(i)||!r.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");if(r.eql(o,r.neg(r.ONE))||Sd(r,o))throw new Error("mapToCurveSimpleSWU: invalid opts");let s=r.mul(i,r.inv(r.mul(o,n))),a=r.add(r.add(r.mul(r.sqr(s),s),r.mul(n,s)),i);if(!Sd(r,a))throw new Error("mapToCurveSimpleSWU: invalid opts");let f=aM(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return l=>{let m,g,v,E,T,N,L,F;m=r.sqr(l),m=r.mul(m,o),g=r.sqr(m),g=r.add(g,m),v=r.add(g,r.ONE),v=r.mul(v,i),E=r.cmov(o,r.neg(g),!r.eql(g,r.ZERO)),E=r.mul(E,n),g=r.sqr(v),N=r.sqr(E),T=r.mul(N,n),g=r.add(g,T),g=r.mul(g,v),N=r.mul(N,E),T=r.mul(N,i),g=r.add(g,T),L=r.mul(m,v);let{isValid:V,value:z}=f(g,N);F=r.mul(m,l),F=r.mul(F,z),L=r.cmov(L,v,V),F=r.cmov(F,z,V);let W=r.isOdd(l)===r.isOdd(F);F=r.cmov(r.neg(F),F,W);let ie=Vo(r,[E],!0)[0];return L=r.mul(L,ie),{x:L,y:F}}}var dS,sn,si,pS,gS,rM,sM,_S=Wt(()=>{p();ni();Wi();dS=BigInt(0),sn=BigInt(1),si=BigInt(2),pS=BigInt(3),gS=BigInt(4),rM=Mt;sM="HashToScalar-"});function Rd(e){qe(e,{name:"string",hash:"function"},{hashToScalar:"function",validatePoint:"function",parsePublicKey:"function",adjustScalar:"function",adjustPoint:"function",challenge:"function",adjustNonces:"function",adjustSecret:"function",adjustPublic:"function",adjustGroupCommitmentShare:"function",adjustDKG:"function"}),oi(e.Point);let{Point:t}=e,r=e.Fn===void 0?t.Fn:e.Fn,n=e.hash,i=e.hashToScalar===void 0?(A,C={DST:new Uint8Array})=>{let U=n(Ce(C.DST,A));return r.create(r.isLE?Ho(U):Mt(U))}:e.hashToScalar,o=In(e.H1!==void 0?e.H1:e.name+"rho"),s=In(e.H2!==void 0?e.H2:e.name+"chal"),a=In(e.H3!==void 0?e.H3:e.name+"nonce"),f=In(e.H4!==void 0?e.H4:e.name+"msg"),l=In(e.H5!==void 0?e.H5:e.name+"com"),m=In(e.HDKG!==void 0?e.HDKG:e.name+"dkg"),g=In(e.HID!==void 0?e.HID:e.name+"id"),v=A=>i(A,{DST:o}),E=A=>i(A,{DST:s}),T=A=>i(A,{DST:a}),N=A=>n(Ce(f,A)),L=A=>n(Ce(l,A)),F=A=>i(A,{DST:m}),V=A=>i(A,{DST:g}),z=(A=Qt)=>{if(typeof A!="function")throw new TypeError('"rng" expected function, got type='+typeof A);let C=Vi(A(zo(r.ORDER)),r.ORDER,r.isLE);return r.isLE?Ho(C):Mt(C)},W=A=>A.toBytes(),ie=A=>{let C=t.fromBytes(A);return e.validatePoint&&e.validatePoint(C),C},ee=(A,C)=>({identifier:A,hiding:W(t.BASE.multiply(r.fromBytes(C.hiding))),binding:W(t.BASE.multiply(r.fromBytes(C.binding)))}),ge=e.adjustPoint===void 0?A=>A:e.adjustPoint,ce=A=>{if(!r.isValid(A)||r.is0(A))throw new Error("Invalid identifier "+A);return A},me=A=>Rn(r.toBytes(ce(A))),I=(A,C="identifier")=>{ra(A,C);let U=ce(r.fromBytes(jo(A)));if(me(U)!==A)throw new Error("expected canonical identifier hex");return U},u={encode:(A,C)=>{let U=Ce(W(A),r.toBytes(C));return e.adjustTx&&(U=e.adjustTx.encode(U)),U},decode:A=>{e.adjustTx&&(A=e.adjustTx.decode(A));let C=A.subarray(0,-r.BYTES),U=ie(C);if(W(U).length!==C.length)throw new Error("invalid signature encoding");let j=r.fromBytes(A.subarray(-r.BYTES));return{R:U,z:j}}},h=(A=Qt)=>{let C=z(A);e.adjustScalar&&(C=e.adjustScalar(C));let U=t.BASE.multiply(C);return{scalar:C,point:U}},y="roots are unavailable in FROST polynomial mode",S={info:{G:r.ZERO,oddFactor:r.ZERO,powerOfTwo:0},roots(){throw new Error(y)},brp(){throw new Error(y)},inverse(){throw new Error(y)},omega(){throw new Error(y)},clear(){}},w=lS(r,S),R=(A,C)=>Yo(t,A,C),O=(A,C)=>{if(!C.length)throw new Error("empty coefficients");return w.monomial.eval(C,A)},_=(A,C)=>{let U="invalid parameters";if(!A.some(te=>r.eql(te,C)))throw new Error(U);let j=new Set(A);if(j.size!==A.length)throw new Error(U);if(!j.has(C))throw new Error(U);let re=r.ONE,J=r.ONE;for(let te of A)r.eql(te,C)||(re=r.mul(re,te),J=r.mul(J,r.sub(te,C)));return r.div(re,J)},c=(A,C)=>{let U=w.monomial.basis(A,C.length);return R(C,U)},b=(A,C,U,j=Qt)=>{if(an(A),C!==void 0&&Se(C,r.BYTES,"secret"),U!==void 0&&rt(U,"coeffs"),typeof j!="function")throw new TypeError('"rng" expected function, got type='+typeof j);let re=C===void 0?z(j):r.fromBytes(C);if(!U){U=[];for(let ae=0;ae<A.min-1;ae++)U.push(z(j))}if(U.length!==A.min-1)throw new Error("wrong coefficients length");let J=[re,...U],te=J.map(ae=>t.BASE.multiply(ae));return{coefficients:J,commitment:te,secret:re}},k={challenge:(A,C,U)=>F(Ce(r.toBytes(A),W(C),W(U))),compute(A,C,U,j=Qt){if(C.length<1)throw new Error("coefficients should have at least one element");let{point:re,scalar:J}=h(j),te=U[0],ae=this.challenge(A,te,re),oe=r.add(J,r.mul(C[0],ae));return u.encode(re,oe)},validate(A,C,U){if(C.length<1)throw new Error("commitment should have at least one element");let{R:j,z:re}=u.decode(U),J=ie(C[0]),te=this.challenge(A,J,j);if(!j.equals(t.BASE.multiplyUnsafe(re).subtract(J.multiplyUnsafe(te))))throw new Error("invalid proof of knowledge")}},D={challenge:(A,C,U)=>e.challenge?e.challenge(A,C,U):E(Ce(W(A),W(C),U)),sign(A,C,U=Qt){let{point:j,scalar:re}=h(U),J=t.BASE.multiply(C),te=this.challenge(j,J,A),ae=r.add(re,r.mul(te,C));return[j,ae]},verify(A,C,U,j){e.adjustPoint&&(j=e.adjustPoint(j)),e.adjustPoint&&(C=e.adjustPoint(C));let re=this.challenge(C,j,A),J=t.BASE.multiplyUnsafe(U),te=j.multiplyUnsafe(re),ae=J.subtract(te).subtract(C);return ae.clearCofactor&&(ae=ae.clearCofactor()),t.ZERO.equals(ae)}},K=(A,C,U)=>{if(!t.BASE.multiply(U).equals(c(A,C)))throw new Error("invalid secret share")},G={fromNumber(A){if(!Number.isSafeInteger(A))throw new Error("expected safe interger");return me(BigInt(A))},derive(A){return ra(A,"s"),me(V(In(A)))}},X=(A,C=Qt)=>T(Ce(C(32),r.toBytes(A))),Z=(A,C,U)=>{let j=C.map(de=>[de.identifier,I(de.identifier),ie(de.hiding),ie(de.binding)]);j.sort((de,be)=>de[1]<be[1]?-1:de[1]>be[1]?1:0);let re=[];for(let[de,be,xe,or]of j)re.push(r.toBytes(be),W(xe),W(or));let J=L(Ce(...re)),te=Ce(W(A),N(U),J),ae={};for(let[de,be]of j)ae[de]=v(Ce(te,r.toBytes(be)));let oe=t.ZERO,ue=[],_e=[];for(let[de,be,xe,or]of j){if(t.ZERO.equals(xe)||t.ZERO.equals(or))throw new Error("infinity commitment");oe=oe.add(xe),ue.push(or),_e.push(ae[de])}let we=oe.add(R(ue,_e));return{identifiers:j.map(de=>de[1]),groupCommitment:we,bindingFactors:ae}},le=(A,C,U,j)=>{let re=ge(ie(A)),J=I(j),{identifiers:te,groupCommitment:ae,bindingFactors:oe}=Z(re,C,U),ue=oe[j],_e=_(te,J),we=D.challenge(ae,re,U);return{lambda:_e,challenge:we,bindingFactor:ue,groupCommitment:ae}};Object.freeze(G);let se={Identifier:G,DKG:Object.freeze({round1:(A,C,U,j=Qt)=>{let re=I(A,"id");an(C);let{coefficients:J,commitment:te}=b(C,U,void 0,j),ae=k.compute(re,J,te,j),oe=te.map(W),ue={identifier:me(re),commitment:oe,proofOfKnowledge:ae},_e={identifier:re,coefficients:J,commitment:te.map(W),signers:{min:C.min,max:C.max},step:1};return{public:ue,secret:_e}},round2:(A,C)=>{if(qe(A,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),an(A.signers,"secret.signers"),rt(C,"others"),C.length!==A.signers.max-1)throw new Error("wrong number of round1 packages");if(!A.coefficients||A.step===3)throw new Error("round3 package used in round2");if(A.round2Cache!==void 0)return A.round2Cache;let U={};for(let j of C){if(j.commitment.length!==A.signers.min)throw new Error("wrong number of commitments");let re=I(j.identifier);if(re===A.identifier)throw new Error("duplicate id="+me(re));k.validate(re,j.commitment,j.proofOfKnowledge);for(let te of j.commitment)ie(te);if(U[j.identifier])throw new Error("Duplicate id="+re);let J=r.toBytes(O(re,A.coefficients));U[j.identifier]={identifier:me(A.identifier),signingShare:J}}return A.round2Cache=U,A.step=2,U},round3:(A,C,U)=>{if(qe(A,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),an(A.signers,"secret.signers"),rt(C,"round1"),rt(U,"round2"),C.length!==A.signers.max-1)throw new Error("wrong length of round1 packages");if(!A.coefficients||A.step!==2)throw new Error("round2 package used in round3");if(U.length!==C.length)throw new Error("wrong length of round2 packages");let j={};for(let de of C){if(!de.identifier||!de.commitment)throw new Error("wrong round1 share");j[de.identifier]={...de}}for(let de of U){if(!de.identifier||!de.signingShare)throw new Error("wrong round2 share");if(!j[de.identifier])throw new Error("round1 share for "+de.identifier+" is missing");j[de.identifier].signingShare=de.signingShare}if(Object.keys(j).length!==C.length)throw new Error("mismatch identifiers between rounds");let re=r.ZERO;if(A.commitment.length!==A.signers.min)throw new Error("wrong commitments length");let J=A.commitment.map(ie),te=O(A.identifier,A.coefficients);K(A.identifier,J,te);let ae=J.map(W),oe={[me(A.identifier)]:ae};for(let de in j){let be=j[de];if(!be.signingShare||!be.commitment)throw new Error("mismatch identifiers");let xe=I(de),or=r.fromBytes(be.signingShare),Ze=be.commitment.map(ie);K(A.identifier,Ze,or),re=r.add(re,or);let Ve=me(xe);if(oe[Ve])throw new Error("duplicated id="+Ve);oe[Ve]=be.commitment}re=r.add(re,te);let ue=new Array(A.signers.min).fill(t.ZERO);for(let de in oe){let be=oe[de];if(be.length!==A.signers.min)throw new Error("wrong commitments length");for(let xe=0;xe<be.length;xe++)ue[xe]=ue[xe].add(ie(be[xe]))}let _e=ue.map(W),we={};for(let de in oe)we[de]=W(c(I(de),ue));let fe={public:{signers:{min:A.signers.min,max:A.signers.max},commitments:_e,verifyingShares:Object.fromEntries(Object.entries(we).map(([de,be])=>[de,be.slice()]))},secret:{identifier:me(A.identifier),signingShare:r.toBytes(re)}};e.adjustDKG&&(fe=e.adjustDKG(fe));for(let de=0;de<A.coefficients.length;de++)A.coefficients[de]-=A.coefficients[de];return delete A.coefficients,delete A.round2Cache,A.step=3,fe},clean(A){if(qe(A,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),A.identifier-=A.identifier,A.coefficients)for(let C=0;C<A.coefficients.length;C++)A.coefficients[C]-=A.coefficients[C];delete A.round2Cache,A.step=3}}),trustedDealer(A,C,U,j=Qt){if(an(A),C===void 0){C=[];for(let ue=1;ue<=A.max;ue++)C.push(G.fromNumber(ue))}else if(rt(C,"identifiers"),C.length!==A.max)throw new Error("identifiers should be array of "+A.max);let re={};for(let ue of C){let _e=I(ue);if(ue in re)throw new Error("duplicated id="+ue);re[ue]=_e}let J=b(A,U,void 0,j),te=J.commitment.map(W),ae={},oe={};for(let ue of C){let _e=O(re[ue],J.coefficients);oe[ue]=W(t.BASE.multiply(_e)),ae[ue]={identifier:ue,signingShare:r.toBytes(_e)}}return{public:{signers:{min:A.min,max:A.max},commitments:te,verifyingShares:oe},secretShares:ae}},validateSecret(A,C){qe(A,{identifier:"string",signingShare:"object"},{},"secret"),Se(A.signingShare,r.BYTES,"secret.signingShare"),qe(C,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),an(C.signers,"pub.signers"),rt(C.commitments,"pub.commitments");let U=I(A.identifier),j=C.commitments.map(ie),re=r.fromBytes(A.signingShare);K(U,j,re)},commit(A,C=Qt){if(qe(A,{identifier:"string",signingShare:"object"},{},"secret"),Se(A.signingShare,r.BYTES,"secret.signingShare"),typeof C!="function")throw new TypeError('"rng" expected function, got type='+typeof C);let U=r.fromBytes(A.signingShare),j=X(U,C),re=X(U,C),J={hiding:r.toBytes(j),binding:r.toBytes(re)};return{nonces:J,commitments:ee(A.identifier,J)}},signShare(A,C,U,j,re){qe(A,{identifier:"string",signingShare:"object"},{},"secret"),Se(A.signingShare,r.BYTES,"secret.signingShare"),qe(C,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),an(C.signers,"pub.signers"),rt(C.commitments,"pub.commitments"),qe(U,{hiding:"object",binding:"object"},{},"nonces"),Se(U.hiding,r.BYTES,"nonces.hiding"),Se(U.binding,r.BYTES,"nonces.binding"),rt(j,"commitmentList"),Se(re,void 0,"msg"),SS(C.signers,j.length);let J=r.fromBytes(U.hiding),te=r.fromBytes(U.binding);if(r.is0(J)||r.is0(te))throw new Error("signing nonces already used");let ae={identifier:A.identifier,hiding:W(t.BASE.multiply(J)),binding:W(t.BASE.multiply(te))},oe=j.find(Je=>Je.identifier===A.identifier);if(!oe)throw new Error("missing signer commitment");if(Rn(oe.hiding)!==Rn(ae.hiding)||Rn(oe.binding)!==Rn(ae.binding))throw new Error("incorrect signer commitment");e.adjustSecret&&(A=e.adjustSecret(A,C)),e.adjustPublic&&(C=e.adjustPublic(C));let ue=r.fromBytes(A.signingShare),{lambda:_e,challenge:we,bindingFactor:fe,groupCommitment:de}=le(C.commitments[0],j,re,A.identifier),be=e.adjustNonces?e.adjustNonces(de,U):U,xe=e.adjustNonces?r.fromBytes(be.hiding):J,or=e.adjustNonces?r.fromBytes(be.binding):te,Ze=r.mul(r.mul(_e,ue),we),Ve=r.mul(or,fe),Ya=r.toBytes(r.add(r.add(xe,Ve),Ze));return U.hiding.fill(0),U.binding.fill(0),Ya},verifyShare(A,C,U,j,re){qe(A,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),an(A.signers,"pub.signers"),rt(A.commitments,"pub.commitments"),rt(C,"commitmentList"),Se(U,void 0,"msg"),I(j),Se(re,r.BYTES,"sigShare"),e.adjustPublic&&(A=e.adjustPublic(A));let J=C.find(or=>or.identifier===j);if(!J)throw new Error("cannot find identifier commitment");let te=ie(A.verifyingShares[j]),ae=ie(J.hiding),oe=ie(J.binding),{lambda:ue,challenge:_e,bindingFactor:we,groupCommitment:fe}=le(A.commitments[0],C,U,j),de=ae.add(oe.multiplyUnsafe(we));e.adjustGroupCommitmentShare&&(de=e.adjustGroupCommitmentShare(fe,de));let be=t.BASE.multiplyUnsafe(r.fromBytes(re)),xe=de.add(te.multiplyUnsafe(r.mul(_e,ue)));return be.equals(xe)},aggregate(A,C,U,j){qe(A,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),an(A.signers,"pub.signers"),rt(A.commitments,"pub.commitments"),rt(C,"commitmentList"),Se(U,void 0,"msg"),qe(j,{},{},"sigShares");let re=A;e.adjustPublic&&(A=e.adjustPublic(A));try{SS(A.signers,C.length)}catch{throw new Yi("aggregation failed",[])}let J=C.map(_e=>_e.identifier),te=new Set;for(let _e of J){if(te.has(_e))throw new Yi("aggregation failed",[]);te.add(_e)}if(J.length!==Object.keys(j).length)throw new Yi("aggregation failed",[]);for(let _e of J)if(!(_e in j)||!(_e in A.verifyingShares))throw new Yi("aggregation failed",[]);let ae=ie(A.commitments[0]),{groupCommitment:oe}=Z(ae,C,U),ue=r.ZERO;for(let _e of J)ue=r.add(ue,r.fromBytes(j[_e]));if(!D.verify(U,oe,ue,ae)){let _e=[];for(let we of J)this.verifyShare(re,C,U,we,j[we])||_e.push(we);throw new Yi("aggregation failed",_e)}return u.encode(oe,ue)},sign(A,C){let U=r.fromBytes(C);e.adjustScalar&&(U=e.adjustScalar(U));let[j,re]=D.sign(A,U);return u.encode(j,re)},verify(A,C,U){let j=e.parsePublicKey?e.parsePublicKey(U):ie(U),{R:re,z:J}=u.decode(A);return D.verify(C,re,J,j)},combineSecret(A,C){if(rt(A,"shares"),an(C),A.length<C.min||A.length>C.max)throw new Error("wrong secret shares array");let U=[],j={};for(let te of A){let ae=I(te.identifier),oe=me(ae);if(j[oe])throw new Error("duplicated id="+oe);j[oe]=!0,U.push([ae,r.fromBytes(te.signingShare)])}let re=U.map(([te])=>te),J=r.ZERO;for(let[te,ae]of U)J=r.add(J,r.mul(ae,_(re,te)));return r.toBytes(J)},utils:Object.freeze({Fn:r,randomScalar:(A=Qt)=>r.toBytes(h(A).scalar),generateSecretPolynomial:(A,C,U,j)=>{let re=b(A,C,U,j);return{...re,commitment:re.commitment.map(W)}}})};return Object.freeze(se)}var an,SS,Yi,wS=Wt(()=>{p();On();ni();jf();hS();Wi();an=(e,t="signers")=>{if(qe(e,{min:"number",max:"number"},{},t),nt(e.min,t+".min"),nt(e.max,t+".max"),e.min<2||e.max<2||e.min>e.max)throw new Error("Wrong signers info: min="+e.min+" max="+e.max)},SS=(e,t)=>{if(t<e.min||t>e.max)throw new Error("Wrong number of commitments="+t)},Yi=class extends Error{constructor(r,n){super(r);$(this,"cheaters");this.cheaters=n}}});var Kf,ES,xS=Wt(()=>{p();On();Kf=class{constructor(t,r){$(this,"oHash");$(this,"iHash");$(this,"blockLen");$(this,"outputLen");$(this,"canXOF",!1);$(this,"finished",!1);$(this,"destroyed",!1);if(wf(t),rn(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),ar(i)}update(t){return Uo(this),this.iHash.update(t),this}digestInto(t){Uo(this),Ef(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a,canXOF:f}=this;return t=t,t.finished=i,t.destroyed=o,t.blockLen=s,t.outputLen=a,t.canXOF=f,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ES=(()=>{let e=((t,r,n)=>new Kf(t,r).update(n).digest());return e.create=(t,r)=>new Kf(t,r),e})()});var uM,Td,Tn,Pd,IS=Wt(()=>{p();ni();uM=BigInt(0),Td=class extends Error{constructor(t=""){super(t)}},Tn={Err:Td,_tlv:{encode:(e,t)=>{let{Err:r}=Tn;if(nt(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(ra(t,"data"),t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=na(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?na(i.length/2|128):"";return na(e)+o+i+t},decode(e,t){let{Err:r}=Tn;t=Se(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.decode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],o=!!(i&128),s=0;if(!o)s=i;else{let f=i&127;if(!f)throw new r("tlv.decode(long): indefinite length not supported");if(f>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+f);if(l.length!==f)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let m of l)s=s<<8|m;if(n+=f,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=Tn;if(Cf(e),e<uM)throw new t("integer: negative integers are not allowed");let r=na(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Tn;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Mt(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Tn,i=Se(e,void 0,"signature"),{v:o,l:s}=n.decode(48,i);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:f}=n.decode(2,o),{v:l,l:m}=n.decode(2,f);if(m.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=Tn;qe(e,{r:"bigint",s:"bigint"},{},"sig");let n=t.encode(2,r.encode(e.r)),i=t.encode(2,r.encode(e.s)),o=n+i;return t.encode(48,o)}},Pd=(Object.freeze(Tn._tlv),Object.freeze(Tn._int),Object.freeze(Tn))});function fM(e,t,r){yd("scalar",e,Pn,r);let[[n,i],[o,s]]=t,a=OS(s*e,r),f=OS(-i*e,r),l=e-a*n-f*o,m=-a*i-f*s,g=l<Pn,v=m<Pn;g&&(l=-l),v&&(m=-m);let E=ia(Math.ceil(Go(r)/2))+$i;if(l<Pn||l>=E||m<Pn||m>=E)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:g,k1:l,k2neg:v,k2:m}}function Md(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Bd(e,t){qe(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return on(r.lowS,"lowS"),on(r.prehash,"prehash"),r.format!==void 0&&Md(r.format),r}function RS(e,t={}){let r=fS("weierstrass",e,t),n=r.Fp,i=r.Fn,o=r.CURVE,{h:s,n:a}=o;qe(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:f,allowInfinityPoint:l}=t,m=t.randomBytes===void 0?Qt:t.randomBytes;if(f&&(!n.is0(o.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let g=PS(n,i);function v(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function E(R,O,_){if(l&&O.is0())return Uint8Array.of(0);let{x:c,y:b}=O.toAffine(),k=n.toBytes(c);if(on(_,"isCompressed"),_){v();let D=!n.isOdd(b);return Ce(TS(D),k)}else return Ce(Uint8Array.of(4),k,n.toBytes(b))}function T(R){Se(R,void 0,"Point");let{publicKey:O,publicKeyUncompressed:_}=g,c=R.length,b=R[0],k=R.subarray(1);if(l&&c===1&&b===0)return{x:n.ZERO,y:n.ZERO};if(c===O&&(b===2||b===3)){let D=n.fromBytes(k);if(!n.isValid(D))throw new Error("bad point: is not on curve, wrong x");let K=z(D),G;try{G=n.sqrt(K)}catch(le){let se=le instanceof Error?": "+le.message:"";throw new Error("bad point: is not on curve, sqrt error"+se)}v();let X=n.isOdd(G);return(b&1)===1!==X&&(G=n.neg(G)),{x:D,y:G}}else if(c===_&&b===4){let D=n.BYTES,K=n.fromBytes(k.subarray(0,D)),G=n.fromBytes(k.subarray(D,D*2));if(!W(K,G))throw new Error("bad point: is not on curve");return{x:K,y:G}}else throw new Error(`bad point: got length ${c}, expected compressed=${O} or uncompressed=${_}`)}let N=t.toBytes===void 0?E:t.toBytes,L=t.fromBytes===void 0?T:t.fromBytes,F=n.mul(o.b,Nd),V=n.is0(o.a)?R=>n.ZERO:R=>n.mul(o.a,R);function z(R){let O=n.sqr(R),_=n.mul(O,R);return n.add(n.add(_,n.mul(R,o.a)),o.b)}function W(R,O){let _=n.sqr(O),c=z(R);return n.eql(_,c)}if(!W(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let ie=n.mul(n.pow(o.a,Nd),cM),ee=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(ie,ee)))throw new Error("bad curve params: a or b");function ge(R,O,_=!1){if(!n.isValid(O)||_&&n.is0(O))throw new Error(`bad point coordinate ${R}`);return O}function ce(R){if(!(R instanceof h))throw new Error("Weierstrass Point expected")}function me(R){if(!f||!f.basises)throw new Error("no endo");return fM(R,f.basises,i.ORDER)}function I(R,O,_,c){if(!i.isValid(c))throw new RangeError("invalid scalar: out of range");if(f){let{k1neg:b,k1:k,k2neg:D,k2:K}=me(c),G=new h(n.mul(_.X,f.beta),_.Y,_.Z);R.push(b?_.negate():_,D?G.negate():G),O.push(k,K)}else R.push(_),O.push(c)}let u=new WeakSet,w=class w{constructor(O,_,c){$(this,"X");$(this,"Y");$(this,"Z");this.X=ge("x",O),this.Y=ge("y",_,!0),this.Z=ge("z",c),Object.freeze(this)}static CURVE(){return o}static fromAffine(O){let{x:_,y:c}=O||{};if(!O||!n.isValid(_)||!n.isValid(c))throw new Error("invalid affine point");if(O instanceof w)throw new Error("projective point not allowed");return n.is0(_)&&n.is0(c)?w.ZERO:new w(_,c,n.ONE)}static fromBytes(O){let _=w.fromAffine(L(Se(O,void 0,"point")));return _.assertValidity(),_}static fromHex(O){return w.fromBytes(jo(O))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(O=6,_=!0){return S.setWindowSize(this,O),_||this.multiply(Nd),this}assertValidity(){let O=this;if(O.is0()){if(t.allowInfinityPoint&&n.is0(O.X)&&n.eql(O.Y,n.ONE)&&n.is0(O.Z))return;throw new Error("bad point: ZERO")}if(u.has(O))return;let{x:_,y:c}=O.toAffine();if(!n.isValid(_)||!n.isValid(c))throw new Error("bad point: x or y not field elements");if(!W(_,c))throw new Error("bad point: equation left != right");if(!O.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");u.add(O)}hasEvenY(){let{y:O}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(O)}equals(O){ce(O);let{X:_,Y:c,Z:b}=this,{X:k,Y:D,Z:K}=O,G=n.eql(n.mul(_,K),n.mul(k,b)),X=n.eql(n.mul(c,K),n.mul(D,b));return G&&X}negate(){return new w(this.X,n.neg(this.Y),this.Z)}double(){let{X:O,Y:_,Z:c}=this,b=n.ZERO,k=n.ZERO,D=n.ZERO,K=n.mul(O,O),G=n.mul(_,_),X=n.mul(c,c),Z=n.mul(O,_);return Z=n.add(Z,Z),D=n.mul(O,c),D=n.add(D,D),b=V(D),k=n.mul(F,X),k=n.add(b,k),b=n.sub(G,k),k=n.add(G,k),k=n.mul(b,k),b=n.mul(Z,b),D=n.mul(F,D),X=V(X),Z=n.sub(K,X),Z=V(Z),Z=n.add(Z,D),D=n.add(K,K),K=n.add(D,K),K=n.add(K,X),K=n.mul(K,Z),k=n.add(k,K),X=n.mul(_,c),X=n.add(X,X),K=n.mul(X,Z),b=n.sub(b,K),D=n.mul(X,G),D=n.add(D,D),D=n.add(D,D),new w(b,k,D)}add(O){ce(O);let{X:_,Y:c,Z:b}=this,{X:k,Y:D,Z:K}=O,G=n.ZERO,X=n.ZERO,Z=n.ZERO,le=n.mul(_,k),se=n.mul(c,D),A=n.mul(b,K),C=n.add(_,c),U=n.add(k,D);C=n.mul(C,U),U=n.add(le,se),C=n.sub(C,U),U=n.add(_,b);let j=n.add(k,K);return U=n.mul(U,j),j=n.add(le,A),U=n.sub(U,j),j=n.add(c,b),G=n.add(D,K),j=n.mul(j,G),G=n.add(se,A),j=n.sub(j,G),Z=V(U),G=n.mul(F,A),Z=n.add(G,Z),G=n.sub(se,Z),Z=n.add(se,Z),X=n.mul(G,Z),se=n.add(le,le),se=n.add(se,le),A=V(A),U=n.mul(F,U),se=n.add(se,A),A=n.sub(le,A),A=V(A),U=n.add(U,A),le=n.mul(se,U),X=n.add(X,le),le=n.mul(j,U),G=n.mul(C,G),G=n.sub(G,le),le=n.mul(C,se),Z=n.mul(j,Z),Z=n.add(Z,le),new w(G,X,Z)}subtract(O){return ce(O),this.add(O.negate())}is0(){return this.equals(w.ZERO)}multiply(O){if(!i.isValidNot0(O))throw new RangeError("invalid scalar: out of range");let{p:_,f:c}=S.mulSecret(this,O,s,y);return y([_,c])[0]}multiplyUnsafe(O){let _=this,c=O;if(!i.isValid(c))throw new RangeError("invalid scalar: out of range");if(c===Pn||_.is0())return w.ZERO;if(c===$i)return _;if(S.hasWindowSize(this))return S.mulUnsafe(_,c,y);let b=[],k=[];return I(b,k,_,c),Yo(w,b,k)}mulAddUnsafe(O,_,c){ce(_);let b=[],k=[];return I(b,k,this,O),I(b,k,_,c),Yo(w,b,k)}toAffine(O){let _=this,c=O;if(c!=null&&!n.isValid(c))throw new RangeError('"invertedZ" expected valid field element');let{X:b,Y:k,Z:D}=_;if(n.eql(D,n.ONE))return{x:b,y:k};let K=_.is0();c==null&&(c=K?n.ONE:n.inv(D));let G=n.mul(b,c),X=n.mul(k,c),Z=n.mul(D,c);if(K)return{x:n.ZERO,y:n.ZERO};if(!n.eql(Z,n.ONE))throw new Error("invZ was invalid");return{x:G,y:X}}isTorsionFree(){let{isTorsionFree:O}=t;return s===$i?!0:O?O(w,this):S.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:O}=t;return s===$i?this:O?O(w,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===$i?this.is0():this.clearCofactor().is0()}toBytes(O=!0){return on(O,"isCompressed"),this.assertValidity(),N(w,this,O)}toHex(O=!0){return Rn(this.toBytes(O))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};$(w,"BASE",new w(o.Gx,o.Gy,n.ONE)),$(w,"ZERO",new w(n.ZERO,n.ONE,n.ZERO)),$(w,"Fp",n),$(w,"Fn",i);let h=w,y=R=>sS(h,R),S=new Ff(h,m);return S.bits>=6&&h.BASE.precompute(6),Object.freeze(h.prototype),Object.freeze(h),h}function TS(e){return Uint8Array.of(e?2:3)}function PS(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function lM(e,t={}){oi(e);let{Fn:r}=e,n=t.randomBytes===void 0?Qt:t.randomBytes,i=Object.assign(PS(e.Fp,r),{seed:Math.max(zo(r.ORDER),16)});function o(E){try{let T=r.fromBytes(E);return r.isValidNot0(T)}catch{return!1}}function s(E,T){let{publicKey:N,publicKeyUncompressed:L}=i;try{let F=E.length;return T===!0&&F!==N||T===!1&&F!==L?!1:!!e.fromBytes(E)}catch{return!1}}function a(E){return E=E===void 0?n(i.seed):E,Vi(Se(E,i.seed,"seed"),r.ORDER)}function f(E,T=!0){return e.BASE.multiply(r.fromBytes(E)).toBytes(T)}function l(E){let{secretKey:T,publicKey:N,publicKeyUncompressed:L}=i,F=r._lengths;if(!nn(E))return;let V=Se(E,void 0,"key").length,z=V===N||V===L,W=V===T||!!F?.includes(V);if(!(z&&W))return z}function m(E,T,N=!0){if(l(E)===!0)throw new Error("first arg must be private key");if(l(T)===!1)throw new Error("second arg must be public key");let L=r.fromBytes(E);return e.fromBytes(T).multiply(L).toBytes(N)}let g={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},v=qf(a,f);return Object.freeze(g),Object.freeze(i),Object.freeze({getPublicKey:f,getSharedSecret:m,keygen:v,Point:e,utils:g,lengths:i})}function BS(e,t,r={}){oi(e);let n=t;wf(n),qe(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let i=Object.assign({},r),o=i.randomBytes===void 0?Qt:i.randomBytes,s=i.hmac===void 0?(b,k)=>ES(n,b,k):i.hmac,{Fp:a,Fn:f}=e,{ORDER:l,BITS:m}=f,g=zo(l),v=Id(o,g),{keygen:E,getPublicKey:T,getSharedSecret:N,utils:L,lengths:F}=lM(e,i),V={prehash:!0,lowS:typeof i.lowS=="boolean"?i.lowS:!0,format:"compact",extraEntropy:!1},z=l*AS+$i<a.ORDER;function W(b){let k=l>>$i;return b>k}function ie(b,k){if(!f.isValidNot0(k))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return k}function ee(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function ge(b,k,D){return ee(),(b===D?0:2)|Number(a.isOdd(k))}function ce(){if(z)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function me(b,k){Md(k);let D=F.signature,K=k==="compact"?D:k==="recovered"?D+1:void 0;return Se(b,K)}class I{constructor(k,D,K){$(this,"r");$(this,"s");$(this,"recovery");if(this.r=ie("r",k),this.s=ie("s",D),K!=null){if(ce(),![0,1,2,3].includes(K))throw new Error("invalid recovery id");this.recovery=K}Object.freeze(this)}static fromBytes(k,D=V.format){me(k,D);let K;if(D==="der"){let{r:le,s:se}=Pd.toSig(Se(k));return new I(le,se)}D==="recovered"&&(K=k[0],D="compact",k=k.subarray(1));let G=F.signature/2,X=k.subarray(0,G),Z=k.subarray(G,G*2);return new I(f.fromBytes(X),f.fromBytes(Z),K)}static fromHex(k,D){return this.fromBytes(jo(k),D)}assertRecovery(){let{recovery:k}=this;if(k==null)throw new Error("invalid recovery id: must be present");return k}addRecoveryBit(k){return new I(this.r,this.s,k)}recoverPublicKey(k){let{r:D,s:K}=this,G=this.assertRecovery(),X=G===2||G===3?D+l:D;if(!a.isValid(X))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let Z=a.toBytes(X),le=e.fromBytes(Ce(TS((G&1)===0),Z)),se=f.inv(X),A=h(Se(k,void 0,"msgHash")),C=f.create(-A*se),U=f.create(K*se),j=e.BASE.mulAddUnsafe(C,le,U);if(j.is0())throw new Error("invalid recovery: point at infinify");return j.assertValidity(),j}hasHighS(){return W(this.s)}toBytes(k=V.format){if(Md(k),k==="der")return jo(Pd.hexFromSig(this));let{r:D,s:K}=this,G=f.toBytes(D),X=f.toBytes(K);return k==="recovered"?(ce(),Ce(Uint8Array.of(this.assertRecovery()),G,X)):Ce(G,X)}toHex(k){return Rn(this.toBytes(k))}}Object.freeze(I.prototype),Object.freeze(I);let u=i.bits2int===void 0?function(k){if(k.length>8192)throw new Error("input is too large");let D=Mt(k),K=k.length*8-m;return K>0?D>>BigInt(K):D}:i.bits2int,h=i.bits2int_modN===void 0?function(k){return f.create(u(k))}:i.bits2int_modN,y=ia(m);function S(b){return yd("num < 2^"+m,b,Pn,y),f.toBytes(b)}function w(b,k){return Se(b,void 0,"message"),k?Se(n(b),void 0,"prehashed message"):b}function R(b,k,D){let{lowS:K,prehash:G,extraEntropy:X}=Bd(D,V);b=w(b,G);let Z=h(b),le=f.fromBytes(k);if(!f.isValidNot0(le))throw new Error("invalid private key");let se=[S(le),S(Z)];if(X!=null&&X!==!1){let j=X===!0?o(F.secretKey):X;se.push(Se(j,void 0,"extraEntropy"))}let A=Ce(...se),C=Z;function U(j){let re=u(j);if(!f.isValidNot0(re))return;let J=e.BASE.multiply(re).toAffine(),te=f.create(J.x);if(te===Pn)return;let ae;if(v!==void 0){let _e=Mt(Vi(v(g),l)),we=f.inv(f.mul(_e,re)),fe=f.mul(_e,C),de=f.mul(_e,le);ae=f.create(we*f.create(fe+de*te))}else{let _e=Q_(re,l);ae=f.create(_e*f.create(C+te*le))}if(ae===Pn)return;let oe=ge(J.x,J.y,te),ue=ae;return K&&W(ae)&&(ue=f.neg(ae),oe^=1),new I(te,ue,z?void 0:oe)}return{seed:A,k2sig:U}}function O(b,k,D={}){let{seed:K,k2sig:G}=R(b,k,D);return V_(n.outputLen,f.BYTES,s)(K,G).toBytes(D.format)}function _(b,k,D,K={}){let{lowS:G,prehash:X,format:Z}=Bd(K,V);if(D=Se(D,void 0,"publicKey"),k=w(k,X),!nn(b)){let le=b instanceof I?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+le)}me(b,Z);try{let le=I.fromBytes(b,Z),se=e.fromBytes(D);if(G&&le.hasHighS())return!1;let{r:A,s:C}=le,U=h(k),j=f.inv(C),re=f.create(U*j),J=f.create(A*j),te=e.BASE.mulAddUnsafe(re,se,J);if(te.is0())return!1;let ae=te.toAffine();return!(f.create(ae.x)!==A||Z==="recovered"&&le.recovery!==ge(ae.x,ae.y,A))}catch{return!1}}function c(b,k,D={}){let{prehash:K}=Bd(D,V);return k=w(k,K),I.fromBytes(b,"recovered").recoverPublicKey(k).toBytes()}return Object.freeze({keygen:E,getPublicKey:T,getSharedSecret:N,utils:L,lengths:F,Point:e,sign:O,verify:_,recoverPublicKey:c,Signature:I,hash:n})}var OS,Pn,$i,AS,Nd,cM,NS=Wt(()=>{p();xS();On();ni();jf();IS();Wi();OS=(e,t)=>(e+(e>=0?t:-t)/AS)/t;Pn=BigInt(0),$i=BigInt(1),AS=BigInt(2),Nd=BigInt(3),cM=BigInt(4)});var GS={};ol(GS,{__TEST:()=>yM,schnorr:()=>mM,schnorr_FROST:()=>wM,secp256k1:()=>pM,secp256k1_FROST:()=>_M,secp256k1_hasher:()=>Ld});function dM(e){let t=Gf.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),f=BigInt(88),l=e*e*e%t,m=l*l*e%t,g=hr(m,r,t)*m%t,v=hr(g,r,t)*m%t,E=hr(v,MS,t)*l%t,T=hr(E,i,t)*E%t,N=hr(T,o,t)*T%t,L=hr(N,a,t)*N%t,F=hr(L,f,t)*L%t,V=hr(F,a,t)*N%t,z=hr(V,r,t)*m%t,W=hr(z,s,t)*T%t,ie=hr(W,n,t)*l%t,ee=hr(ie,MS,t);if(!kr.eql(kr.sqr(ee),e))throw new Error("Cannot find square root");return ee}function sa(e,...t){let r=kS[e];if(r===void 0){let n=ei(Ko(e));r=Ce(n,n),kS[e]=r}return ei(Ce(r,...t))}function US(e){let{Fn:t,BASE:r}=je,n=t.fromBytes(Se(e,32,"secretKey")),o=r.multiply(n).toAffine();return{scalar:un(o.y)?n:t.neg(n),bytes:DS(o)}}function Vf(e){let t=kr;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x \u2265 p");let r=t.sqr(e),n=t.add(t.mulN(r,e),BigInt(7)),i=t.sqrt(n);un(i)||(i=t.neg(i));let o=je.fromAffine({x:e,y:i});return o.assertValidity(),o}function Cd(...e){return je.Fn.create($o(sa("BIP0340/challenge",...e)))}function CS(e){return US(e).bytes}function gM(e,t,r=ta(32)){let{Fn:n,BASE:i}=je,o=Se(e,void 0,"message"),{bytes:s,scalar:a}=US(t),f=Se(r,32,"auxRand"),l=n.toBytes(a^$o(sa("BIP0340/aux",f))),m=sa("BIP0340/nonce",l,s,o),g=n.create($o(m));if(g===kd)throw new Error("sign failed: k is zero");let E=i.multiply(g).toAffine(),T=un(E.y)?g:n.neg(g),N=DS(E),L=Cd(N,s,o),F=new Uint8Array(64);if(F.set(N,0),F.set(n.toBytes(n.create(T+L*a)),32),!FS(F,o,s))throw new Error("sign: Invalid signature produced");return F}function FS(e,t,r){let{Fp:n,Fn:i,BASE:o}=je,s=Se(e,64,"signature"),a=Se(t,void 0,"message"),f=Se(r,32,"publicKey");try{let l=Vf($o(f)),m=s.subarray(0,32),g=$o(m);if(!n.isValidNot0(g))return!1;let v=$o(s.subarray(32,64));if(!i.isValidNot0(v))return!1;let E=Cd(m,aa(l),a),T=o.mulAddUnsafe(v,l,i.neg(E)),{x:N,y:L}=T.toAffine();return!(T.is0()||!un(L)||!n.eql(N,g))}catch{return!1}}function qS(e,t){if(t===void 0)return kd;let r=aa(e),n=Mt(sa("TapTweak",r,t));if(!je.Fn.isValid(n))throw new Error("invalid TapTweak hash");return n}function Dd(e){let t=je.fromBytes(e.commitments[0]);return un(t.y)?e:{signers:{min:e.signers.min,max:e.signers.max},commitments:e.commitments.map(r=>je.fromBytes(r).negate().toBytes()),verifyingShares:Object.fromEntries(Object.entries(e.verifyingShares).map(([r,n])=>[r,je.fromBytes(n).negate().toBytes()]))}}function jS(e,t){let r=je.fromBytes(t.commitments[0]);if(un(r.y))return e;let n=je.Fn;return{...e,signingShare:n.toBytes(n.neg(n.fromBytes(e.signingShare)))}}function SM(e,t){if(un(e.y))return t;let r=je.Fn;return{binding:r.toBytes(r.neg(r.fromBytes(t.binding))),hiding:r.toBytes(r.neg(r.fromBytes(t.hiding)))}}function HS(e,t,r){let n=je.Fn,i=jS(e,t),o=Dd(t),s=qS(je.fromBytes(o.commitments[0]),r),a=n.toBytes(n.add(n.fromBytes(i.signingShare),s));return{identifier:i.identifier,signingShare:a}}function KS(e,t){let r=Dd(e),n=qS(je.fromBytes(r.commitments[0]),t);if(n===kd)return r;let i=je.BASE.multiply(n),o=r.commitments.map((a,f)=>(f===0?je.fromBytes(a).add(i):je.fromBytes(a)).toBytes()),s={};for(let a in r.verifyingShares)s[a]=je.fromBytes(r.verifyingShares[a]).add(i).toBytes();return{signers:{min:r.signers.min,max:r.signers.max},commitments:o,verifyingShares:s}}var Gf,hM,kd,MS,kr,je,pM,kS,aa,DS,un,$o,yM,mM,vM,LS,bM,Ld,_M,wM,VS=Wt(()=>{p();hd();On();jf();wS();_S();Wi();NS();ni();Gf={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},hM={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},kd=BigInt(0),MS=BigInt(2);kr=Wo(Gf.p,{sqrt:dM}),je=RS(Gf,{Fp:kr,endo:hM}),pM=BS(je,ei),kS=Object.create(null);aa=e=>e.toBytes(!0).slice(1),DS=({x:e})=>kr.toBytes(e),un=e=>!kr.isOdd(e);$o=Mt;yM=Object.freeze({lift_x:Vf,frostTweakPublic:KS,frostTweakSecret:HS}),mM=(()=>{let r=n=>(n=n===void 0?ta(48):n,Vi(Se(n,48,"seed"),Gf.n));return Object.freeze({keygen:qf(r,CS),getPublicKey:CS,sign:gM,verify:FS,Point:je,utils:Object.freeze({randomSecretKey:r,taggedHash:sa,lift_x:Vf,pointToBytes:aa}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),vM=mS(kr,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),bM=()=>LS||(LS=bS(kr,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:kr.create(BigInt("-11"))})),Ld=vS(je,e=>{let{x:t,y:r}=bM()(kr.create(e[0]));return vM(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:kr.ORDER,m:1,k:128,expand:"xmd",hash:ei}),_M=Rd({name:"FROST-secp256k1-SHA256-v1",Point:je,hashToScalar:Ld.hashToScalar,hash:ei});wM=Rd({name:"FROST-secp256k1-SHA256-TR-v1",Point:je,hashToScalar:Ld.hashToScalar,hash:ei,parsePublicKey(e){if(e.length===32)return Vf(Mt(e));if(e.length===33)return je.fromBytes(e);throw new Error(`expected x-only or compressed public key, got length=${e.length}`)},adjustScalar(e){let t=je.BASE.multiply(e);return un(t.y)?e:je.Fn.neg(e)},adjustPoint:e=>un(e.y)?e:e.negate(),challenge(e,t,r){return Cd(aa(e),aa(t),r)},adjustNonces:SM,adjustGroupCommitmentShare:(e,t)=>un(e.y)?t:t.negate(),adjustPublic:Dd,adjustSecret:jS,adjustTx:{encode:e=>e.subarray(1),decode:e=>Ce(Uint8Array.of(2),e)},adjustDKG:e=>{let t=new Uint8Array(0);return{public:KS(e.public,t),secret:HS(e.secret,e.public,t)}}})});var ai=B((oF,$S)=>{"use strict";p();var WS=wr(),{secp256k1:EM}=(VS(),sl(GS)),fa=EM.Point,Wf=fa.Fn.ORDER;function xM(e){return BigInt("0x"+(e.toString(16)||"0"))}function Ud(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new WS(t,16)}function zf(e){if(e==null)throw new Error("Invalid Point");if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(e);if(typeof e=="string")return BigInt(e.indexOf("0x")===0?e:"0x"+e);if(typeof e.toString=="function")return xM(e);throw new Error("Invalid Point")}function ua(e){var t=Object.create(He.prototype);return t._p=e,t}function zS(e,t){var r=zf(t).toString(16).padStart(64,"0");return fa.fromHex((e?"03":"02")+r)}function YS(e,t){var r;try{r=zS((t&1n)===1n,e)}catch{throw new Error("Point does not lie on the curve")}if(r.toAffine().y!==t)throw new Error("Invalid y value for curve.")}function He(e,t,r){if(!(this instanceof He))return new He(e,t,r);var n,i;try{n=zf(e),i=zf(t)}catch{throw new Error("Invalid Point")}YS(n,i);try{this._p=fa.fromAffine({x:n,y:i})}catch{throw new Error("Invalid Point")}return this}He.fromX=function(t,r){try{var n=ua(zS(t,r))}catch{throw new Error("Invalid X")}return n.validate(),n};He.getG=function(){return ua(fa.BASE)};He.getN=function(){return Ud(Wf)};He.prototype.getX=function(){return Ud(this._p.toAffine().x)};He.prototype.getY=function(){return Ud(this._p.toAffine().y)};Object.defineProperty(He.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}});Object.defineProperty(He.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}});He.prototype.mul=function(t){var r=(zf(t)%Wf+Wf)%Wf;return r===0n||this._p.is0()?ua(fa.ZERO):ua(this._p.multiply(r))};He.prototype.add=function(t){return ua(this._p.add(t._p))};He.prototype.mulAdd=function(t,r,n){return this.mul(t).add(r.mul(n))};He.prototype.eq=function(t){return this._p.equals(t._p)};He.prototype.isInfinity=function(){return this._p.is0()};He.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t=this._p.toAffine();return YS(t.x,t.y),this};He.pointToCompressed=function(t){var r=t.getX().toBuffer({size:32}),n=t.getY().toBuffer({size:32}),i,o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])};He.pointFromCompressed=function(e){if(e.length!==33)throw new Error("invalid buffer length");var t=e[0],r;if(t===3)r=!0;else if(t===2)r=!1;else throw new Error("invalid value of compressed prefix");var n=WS.fromBuffer(e.slice(1,33));return He.fromX(r,n)};He.prototype.toBuffer=function(){return He.pointToCompressed(this)};He.prototype.toHex=function(){return this.toBuffer().toString("hex")};He.fromBuffer=function(e){return He.pointFromCompressed(e)};He.fromHex=function(e){return He.fromBuffer(d.Buffer.from(e,"hex"))};$S.exports=He});var XS=B((aF,ZS)=>{"use strict";p();var Yf=Zs(),Bn=Le(),Rt=ZS.exports;Rt.sha1=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Yf.createHash("sha1").update(e).digest()};Rt.sha1.blocksize=512;Rt.sha256=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Yf.createHash("sha256").update(e).digest()};Rt.sha256.blocksize=512;Rt.sha256sha256=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Rt.sha256(Rt.sha256(e))};Rt.ripemd160=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Yf.createHash("ripemd160").update(e).digest()};Rt.sha256ripemd160=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Rt.ripemd160(Rt.sha256(e))};Rt.sha512=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Yf.createHash("sha512").update(e).digest()};Rt.sha512.blocksize=1024;Rt.hmac=function(e,t,r){Bn.checkArgument(d.Buffer.isBuffer(t)),Bn.checkArgument(d.Buffer.isBuffer(r)),Bn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),f=d.Buffer.alloc(n),l=0;l<n;l++)a[l]=o[l]^r[l],f[l]=s[l]^r[l];return e(d.Buffer.concat([a,e(d.Buffer.concat([f,t]))]))};Rt.sha256hmac=function(e,t){return Rt.hmac(Rt.sha256,e,t)};Rt.sha512hmac=function(e,t){return Rt.hmac(Rt.sha512,e,t)}});var iw={};ol(iw,{_MD5:()=>Jf,_RIPEMD160:()=>Qf,_SHA1:()=>Xf,md5:()=>TM,ripemd160:()=>LM,sha1:()=>IM});function JS(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}var Zo,ui,Xf,IM,OM,AM,$f,Fd,RM,Jf,TM,PM,QS,BM,ew,tw,rw,nw,NM,MM,kM,CM,Zf,Qf,LM,ow=Wt(()=>{p();ld();On();Zo=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),ui=new Uint32Array(80),Xf=class extends An{constructor(){super(64,20,8,!1);$(this,"A",Zo[0]|0);$(this,"B",Zo[1]|0);$(this,"C",Zo[2]|0);$(this,"D",Zo[3]|0);$(this,"E",Zo[4]|0)}get(){let{A:r,B:n,C:i,D:o,E:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let l=0;l<16;l++,n+=4)ui[l]=r.getUint32(n,!1);for(let l=16;l<80;l++)ui[l]=xn(ui[l-3]^ui[l-8]^ui[l-14]^ui[l-16],1);let{A:i,B:o,C:s,D:a,E:f}=this;for(let l=0;l<80;l++){let m,g;l<20?(m=Fo(o,s,a),g=1518500249):l<40?(m=o^s^a,g=1859775393):l<60?(m=Of(o,s,a),g=2400959708):(m=o^s^a,g=3395469782);let v=xn(i,5)+m+f+g+ui[l]|0;f=a,a=s,s=xn(o,30),o=i,i=v}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,f=f+this.E|0,this.set(i,o,s,a,f)}roundClean(){ar(ui)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0),ar(this.buffer)}},IM=Mr(()=>new Xf),OM=Math.pow(2,32),AM=Array.from({length:64},(e,t)=>Math.floor(OM*Math.abs(Math.sin(t+1)))),$f=Zo.slice(0,4),Fd=new Uint32Array(16),RM=(()=>{let e=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];return Uint8Array.from({length:64},(t,r)=>e[Math.floor(r/16)][r%4])})(),Jf=class extends An{constructor(){super(64,16,8,!0);$(this,"A",$f[0]|0);$(this,"B",$f[1]|0);$(this,"C",$f[2]|0);$(this,"D",$f[3]|0)}get(){let{A:r,B:n,C:i,D:o}=this;return[r,n,i,o]}set(r,n,i,o){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let f=0;f<16;f++,n+=4)Fd[f]=r.getUint32(n,!0);let{A:i,B:o,C:s,D:a}=this;for(let f=0;f<64;f++){let l,m;f<16?(l=Fo(o,s,a),m=f):f<32?(l=Fo(a,o,s),m=(5*f+1)%16):f<48?(l=o^s^a,m=(3*f+5)%16):(l=s^(o|~a),m=7*f%16),l=l+i+AM[f]+Fd[m],i=a,a=s,s=o,o=o+xn(l,RM[f])}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,this.set(i,o,s,a)}roundClean(){ar(Fd)}destroy(){this.destroyed=!0,this.set(0,0,0,0),ar(this.buffer)}},TM=Mr(()=>new Jf),PM=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),QS=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),BM=QS.map(e=>(9*e+5)%16),ew=(()=>{let r=[[QS],[BM]];for(let n=0;n<4;n++)for(let i of r)i.push(i[n].map(o=>PM[o]));return r})(),tw=ew[0],rw=ew[1],nw=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),NM=tw.map((e,t)=>e.map(r=>nw[t][r])),MM=rw.map((e,t)=>e.map(r=>nw[t][r])),kM=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),CM=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);Zf=new Uint32Array(16),Qf=class extends An{constructor(){super(64,20,8,!0);$(this,"h0",1732584193);$(this,"h1",-271733879);$(this,"h2",-1732584194);$(this,"h3",271733878);$(this,"h4",-1009589776)}get(){let{h0:r,h1:n,h2:i,h3:o,h4:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.h0=r|0,this.h1=n|0,this.h2=i|0,this.h3=o|0,this.h4=s|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let T=0;T<16;T++,n+=4)Zf[T]=r.getUint32(n,!0);let i=this.h0|0,o=i,s=this.h1|0,a=s,f=this.h2|0,l=f,m=this.h3|0,g=m,v=this.h4|0,E=v;for(let T=0;T<5;T++){let N=4-T,L=kM[T],F=CM[T],V=tw[T],z=rw[T],W=NM[T],ie=MM[T];for(let ee=0;ee<16;ee++){let ge=xn(i+JS(T,s,f,m)+Zf[V[ee]]+L,W[ee])+v|0;i=v,v=m,m=xn(f,10)|0,f=s,s=ge}for(let ee=0;ee<16;ee++){let ge=xn(o+JS(N,a,l,g)+Zf[z[ee]]+F,ie[ee])+E|0;o=E,E=g,g=xn(l,10)|0,l=a,a=ge}}this.set(this.h1+f+g|0,this.h2+m+E|0,this.h3+v+o|0,this.h4+i+a|0,this.h0+s+l|0)}roundClean(){ar(Zf)}destroy(){this.destroyed=!0,ar(this.buffer),this.set(0,0,0,0,0)}},LM=Mr(()=>new Qf)});var aw=B((dF,sw)=>{"use strict";p();var{sha256:DM,sha512:UM}=(hd(),sl(H_)),{sha1:FM,ripemd160:qM}=(ow(),sl(iw)),Nn=Le(),Tt=sw.exports;Tt.sha1=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(FM(e))};Tt.sha1.blocksize=512;Tt.sha256=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(DM(e))};Tt.sha256.blocksize=512;Tt.sha256sha256=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),Tt.sha256(Tt.sha256(e))};Tt.ripemd160=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(qM(e))};Tt.sha256ripemd160=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),Tt.ripemd160(Tt.sha256(e))};Tt.sha512=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(UM(e))};Tt.sha512.blocksize=1024;Tt.hmac=function(e,t,r){Nn.checkArgument(d.Buffer.isBuffer(t)),Nn.checkArgument(d.Buffer.isBuffer(r)),Nn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),f=d.Buffer.alloc(n),l=0;l<n;l++)a[l]=o[l]^r[l],f[l]=s[l]^r[l];return e(d.Buffer.concat([a,e(d.Buffer.concat([f,t]))]))};Tt.sha256hmac=function(e,t){return Tt.hmac(Tt.sha256,e,t)};Tt.sha512hmac=function(e,t){return Tt.hmac(Tt.sha512,e,t)}});var Jt=B((gF,fw)=>{"use strict";p();var uw={sha1:"a9993e364706816aba3e25717850c26c9cd0d89d",sha256:"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",sha512:"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",ripemd160:"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"};function jM(){var e;try{e=Zs()}catch{return!1}if(!e||typeof e.createHash!="function")return!1;for(var t=Object.keys(uw),r=0;r<t.length;r++){var n=t[r];try{if(e.createHash(n).update("abc").digest("hex")!==uw[n])return!1}catch{return!1}}return!0}fw.exports=jM()?XS():aw()});var dr=B((mF,hw)=>{"use strict";p();var lw=ze(),HM=Le(),cw=function(t){return lw.isString(t)?/^[0-9a-fA-F]+$/.test(t):!1};hw.exports={isValidJSON:function(t){var r;if(!lw.isString(t))return!1;try{r=JSON.parse(t)}catch{return!1}return typeof r=="object"},isHexa:cw,isHexaString:cw,defineImmutable:function(t,r){return Object.keys(r).forEach(function(n){Object.defineProperty(t,n,{configurable:!1,enumerable:!0,value:r[n]})}),t},isNaturalNumber:function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){HM.checkArgumentType(t,"number","integer");let r=d.Buffer.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}});var pa=B((bF,gw)=>{"use strict";p();var Mn=ze(),ca=dr(),Zi=[],la={};function dw(){}dw.prototype.toString=function(){return this.name};function ha(e,t){if(~Zi.indexOf(e))return e;if(t){Mn.isArray(t)||(t=[t]);for(var r=0;r<Zi.length;r++){var n=Zi[r],i=Mn.pick(n,t),o=Mn.values(i);if(~o.indexOf(e))return n}return}return la[e]}function ec(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&31);return t}function da(e){var t=new dw;ca.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey});var r=e.indexBy||Object.keys(e);return e.cashAddrPrefix&&Mn.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:ec(e.cashAddrPrefix)}),e.networkMagic&&Mn.extend(t,{networkMagic:ca.integerAsBuffer(e.networkMagic)}),e.port&&Mn.extend(t,{port:e.port}),e.dnsSeeds&&Mn.extend(t,{dnsSeeds:e.dnsSeeds}),Zi.push(t),KM(t,r),t}function KM(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=e[n];!Mn.isUndefined(i)&&!Mn.isObject(i)&&(la[i]=e)}}function GM(e,t){for(var r=0;r<t.length;r++){var n=t[r];la[n]===e&&delete la[n]}}function VM(e){for(var t=0;t<Zi.length;t++)Zi[t]===e&&Zi.splice(t,1);GM(e,Object.keys(la))}var tc={livenet:3823236072,testnet:4108710900,regtest:3669344250,stn:4224632057},pw=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],fi={PORT:18333,NETWORK_MAGIC:tc.testnet,DNS_SEEDS:pw,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},kn={PORT:18444,NETWORK_MAGIC:tc.regtest,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},ci={PORT:9333,NETWORK_MAGIC:tc.stn,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},WM={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:tc.livenet,port:8333,dnsSeeds:pw},zM={name:"testnet",prefix:fi.PREFIX,cashAddrPrefix:fi.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:fi.NETWORK_MAGIC},YM={name:"regtest",prefix:kn.PREFIX,cashAddrPrefix:kn.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:kn.NETWORK_MAGIC,port:kn.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},$M={name:"stn",prefix:ci.PREFIX,cashAddrPrefix:ci.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:ci.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};da(zM);da($M);da(YM);da(WM);var qd=ha("livenet"),ZM=ha("regtest"),fn=ha("testnet"),XM=ha("stn");Object.defineProperty(fn,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?kn.PORT:this.stnEnabled?ci.PORT:fi.PORT}});Object.defineProperty(fn,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?ca.integerAsBuffer(kn.NETWORK_MAGIC):this.stnEnabled?ca.integerAsBuffer(ci.NETWORK_MAGIC):ca.integerAsBuffer(fi.NETWORK_MAGIC)}});Object.defineProperty(fn,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?kn.DNS_SEEDS:this.stnEnabled?ci.DNS_SEEDS:fi.DNS_SEEDS}});Object.defineProperty(fn,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?kn.CASHADDRPREFIX:this.stnEnabled?ci.CASHADDRPREFIX:fi.CASHADDRPREFIX}});Object.defineProperty(fn,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?ec(kn.CASHADDRPREFIX):this.stnEnabled?ec(ci.CASHADDRPREFIX):ec(fi.CASHADDRPREFIX)}});function JM(){fn.regtestEnabled=!0}function QM(){fn.regtestEnabled=!1}function e3(){fn.stnEnabled=!0}function t3(){fn.stnEnabled=!1}gw.exports={add:da,remove:VM,defaultNetwork:qd,livenet:qd,mainnet:qd,testnet:fn,regtest:ZM,stn:XM,get:ha,enableRegtest:JM,disableRegtest:QM,enableStn:e3,disableStn:t3}});var bw=B((SF,vw)=>{"use strict";p();var jd=ze(),yw=Nt(),Xo="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),mw={};for(ga=0;ga<Xo.length;ga++)mw[Xo[ga]]=ga;var ga;function r3(e){if(e.length===0)return"";var t=[0],r,n,i;for(r=0;r<e.length;r++){for(n=0,i=e[r];n<t.length;n++)i+=t[n]<<8,t[n]=i%58,i=i/58|0;for(;i>0;)t.push(i%58),i=i/58|0}var o="";for(r=0;e[r]===0&&r<e.length-1;r++)o+=Xo[0];for(r=t.length-1;r>=0;r--)o+=Xo[t[r]];return o}function n3(e){if(e.length===0)return d.Buffer.alloc(0);var t=[0],r,n,i;for(r=0;r<e.length;r++){var o=mw[e[r]];if(o===void 0)throw new Error("Non-base58 character");for(n=0,i=o;n<t.length;n++)i+=t[n]*58,t[n]=i&255,i>>=8;for(;i>0;)t.push(i&255),i>>=8}for(r=0;e[r]===Xo[0]&&r<e.length-1;r++)t.push(0);return d.Buffer.from(t.reverse())}var jt=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};jt.validCharacters=function(t){return yw.Buffer.isBuffer(t)&&(t=t.toString()),jd.every(jd.map(t,function(r){return jd.includes(Xo,r)}))};jt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};jt.encode=function(e){if(!yw.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return r3(e)};jt.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return n3(e)};jt.prototype.fromBuffer=function(e){return this.buf=e,this};jt.fromBuffer=function(e){return new jt().fromBuffer(e)};jt.fromHex=function(e){return jt.fromBuffer(d.Buffer.from(e,"hex"))};jt.prototype.fromString=function(e){var t=jt.decode(e);return this.buf=t,this};jt.fromString=function(e){return new jt().fromString(e)};jt.prototype.toBuffer=function(){return this.buf};jt.prototype.toHex=function(){return this.toBuffer().toString("hex")};jt.prototype.toString=function(){return jt.encode(this.buf)};vw.exports=jt});var Hd=B((EF,Ew)=>{"use strict";p();var _w=ze(),rc=bw(),Sw=Nt(),ww=Jt().sha256sha256,et=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};et.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};et.validChecksum=function(t,r){return _w.isString(t)&&(t=Sw.Buffer.from(rc.decode(t))),_w.isString(r)&&(r=Sw.Buffer.from(rc.decode(r))),r||(r=t.slice(-4),t=t.slice(0,-4)),et.checksum(t).toString("hex")===r.toString("hex")};et.decode=function(e){if(typeof e!="string")throw new Error("Input must be a string");var t=d.Buffer.from(rc.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),n=t.slice(-4),i=ww(r),o=i.slice(0,4);if(n.toString("hex")!==o.toString("hex"))throw new Error("Checksum mismatch");return r};et.checksum=function(e){return ww(e).slice(0,4)};et.encode=function(e){if(!d.Buffer.isBuffer(e))throw new Error("Input must be a buffer");var t=d.Buffer.alloc(e.length+4),r=et.checksum(e);return e.copy(t),r.copy(t,e.length),rc.encode(t)};et.prototype.fromBuffer=function(e){return this.buf=e,this};et.fromBuffer=function(e){return new et().fromBuffer(e)};et.fromHex=function(e){return et.fromBuffer(d.Buffer.from(e,"hex"))};et.prototype.fromString=function(e){var t=et.decode(e);return this.buf=t,this};et.fromString=function(e){var t=et.decode(e);return new et(t)};et.prototype.toBuffer=function(){return this.buf};et.prototype.toHex=function(){return this.toBuffer().toString("hex")};et.prototype.toString=function(){return et.encode(this.buf)};Ew.exports=et});var ma=B((IF,Iw)=>{"use strict";p();var ya=ze(),xw=Le(),Jo=wr(),it=function e(t){if(!(this instanceof e))return new e(t);if(!ya.isUndefined(t))if(d.Buffer.isBuffer(t))this.set({buf:t});else if(ya.isString(t)){var r=d.Buffer.from(t,"hex");if(r.length*2!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else if(ya.isObject(t)){var n=t;this.set(n)}else throw new TypeError("Unrecognized argument for BufferReader")};it.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this};it.prototype.eof=function(){return this.pos>=this.buf.length};it.prototype.finished=it.prototype.eof;it.prototype.read=function(e){xw.checkArgument(!ya.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t};it.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e};it.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e};it.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e};it.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e};it.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e};it.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e};it.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e};it.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=Jo.fromBuffer(e);return this.pos=this.pos+8,t};it.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=t*4294967296+e,n;if(r<=9007199254740991)n=new Jo(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);n=new Jo(i,10,"le")}return this.pos=this.pos+8,n};it.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return e}};it.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return xw.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t};it.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);switch(e){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}};it.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new Jo(this.readUInt16LE());case 254:return new Jo(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new Jo(e)}};it.prototype.reverse=function(){for(var e=d.Buffer.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this};it.prototype.readReverse=function(e){ya.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,d.Buffer.from(t).reverse()};Iw.exports=it});var Vd=B((AF,Tw)=>{"use strict";p();function li(e){"@babel/helpers - typeof";return li=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},li(e)}function Ow(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o3(n.key),n)}}function i3(e,t,r){return t&&Ow(e.prototype,t),r&&Ow(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o3(e){var t=s3(e,"string");return li(t)==="symbol"?t:String(t)}function s3(e,t){if(li(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(li(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function a3(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u3(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Gd(e,t)}function Gd(e,t){return Gd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Gd(e,t)}function f3(e){var t=h3();return function(){var n=nc(e),i;if(t){var o=nc(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return c3(this,i)}}function c3(e,t){if(t&&(li(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return l3(e)}function l3(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h3(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function nc(e){return nc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},nc(e)}var Rw={},Qo,Kd;function va(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){u3(a,o);var s=f3(a);function a(f,l,m){var g;return a3(this,a),g=s.call(this,n(f,l,m)),g.code=e,g}return i3(a)})(r);Rw[e]=i}function Aw(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function d3(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function p3(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function g3(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}va("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);va("ERR_INVALID_ARG_TYPE",function(e,t,r){Qo===void 0&&(Qo=ic()),Qo(typeof e=="string","'name' must be a string");var n;typeof t=="string"&&d3(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(p3(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Aw(t,"type"));else{var o=g3(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(Aw(t,"type"))}return i+=". Received type ".concat(li(r)),i},TypeError);va("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";Kd===void 0&&(Kd=Xr());var n=Kd.inspect(t);return n.length>128&&(n="".concat(n.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(n)},TypeError,RangeError);va("ERR_INVALID_RETURN_VALUE",function(e,t,r){var n;return r&&r.constructor&&r.constructor.name?n="instance of ".concat(r.constructor.name):n="type ".concat(li(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")},TypeError);va("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];Qo===void 0&&(Qo=ic()),Qo(t.length>0,"At least one arg needs to be specified");var n="The ",i=t.length;switch(t=t.map(function(o){return'"'.concat(o,'"')}),i){case 1:n+="".concat(t[0]," argument");break;case 2:n+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:n+=t.slice(0,i-1).join(", "),n+=", and ".concat(t[i-1]," arguments");break}return"".concat(n," must be specified")},TypeError);Tw.exports.codes=Rw});var Fw=B((TF,Uw)=>{"use strict";p();function Pw(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Bw(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Pw(Object(r),!0).forEach(function(n){y3(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Pw(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function y3(e,t,r){return t=Cw(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m3(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Nw(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Cw(n.key),n)}}function v3(e,t,r){return t&&Nw(e.prototype,t),r&&Nw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Cw(e){var t=b3(e,"string");return ur(t)==="symbol"?t:String(t)}function b3(e,t){if(ur(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(ur(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function _3(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&wa(e,t)}function S3(e){var t=Dw();return function(){var n=Ea(e),i;if(t){var o=Ea(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return Lw(this,i)}}function Lw(e,t){if(t&&(ur(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wd(e)}function Wd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function zd(e){var t=typeof Map=="function"?new Map:void 0;return zd=function(n){if(n===null||!w3(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return oc(n,arguments,Ea(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),wa(i,n)},zd(e)}function oc(e,t,r){return Dw()?oc=Reflect.construct.bind():oc=function(i,o,s){var a=[null];a.push.apply(a,o);var f=Function.bind.apply(i,a),l=new f;return s&&wa(l,s.prototype),l},oc.apply(null,arguments)}function Dw(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function w3(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function wa(e,t){return wa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},wa(e,t)}function Ea(e){return Ea=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ea(e)}function ur(e){"@babel/helpers - typeof";return ur=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ur(e)}var E3=Xr(),Yd=E3.inspect,x3=Vd(),I3=x3.codes.ERR_INVALID_ARG_TYPE;function Mw(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function O3(e,t){if(t=Math.floor(t),e.length==0||t==0)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+=e.substring(0,r-e.length),e}var Cr="",ba="",_a="",Vt="",Xi={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:"},A3=10;function kw(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(n){r[n]=e[n]}),Object.defineProperty(r,"message",{value:e.message}),r}function Sa(e){return Yd(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function R3(e,t,r){var n="",i="",o=0,s="",a=!1,f=Sa(e),l=f.split(`
14
+ `),m=Sa(t).split(`
15
15
  `),g=0,v="";if(r==="strictEqual"&&ur(e)==="object"&&ur(t)==="object"&&e!==null&&t!==null&&(r="strictEqualObject"),l.length===1&&m.length===1&&l[0]!==m[0]){var E=l[0].length+m[0].length;if(E<=A3){if((ur(e)!=="object"||e===null)&&(ur(t)!=="object"||t===null)&&(e!==0||t!==0))return"".concat(Xi[r],`
16
16
 
17
17
  `)+"".concat(l[0]," !== ").concat(m[0],`
18
- `)}else if(r!=="strictEqualObject"){var T=I.default.stderr&&I.default.stderr.isTTY?I.default.stderr.columns:80;if(E<T){for(;l[0][g]===m[0][g];)g++;g>2&&(v=`
19
- `.concat(I3(" ",g),"^"),g=0)}}}for(var N=l[l.length-1],L=m[m.length-1];N===L&&(g++<2?s=`
18
+ `)}else if(r!=="strictEqualObject"){var T=x.default.stderr&&x.default.stderr.isTTY?x.default.stderr.columns:80;if(E<T){for(;l[0][g]===m[0][g];)g++;g>2&&(v=`
19
+ `.concat(O3(" ",g),"^"),g=0)}}}for(var N=l[l.length-1],L=m[m.length-1];N===L&&(g++<2?s=`
20
20
  `.concat(N).concat(s):n=N,l.pop(),m.pop(),!(l.length===0||m.length===0));)N=l[l.length-1],L=m[m.length-1];var F=Math.max(l.length,m.length);if(F===0){var V=f.split(`
21
21
  `);if(V.length>30)for(V[26]="".concat(Cr,"...").concat(Vt);V.length>27;)V.pop();return"".concat(Xi.notIdentical,`
22
22
 
@@ -33,7 +33,7 @@ Use Chrome, Firefox or Internet Explorer 11`)}var lN=Gt().Buffer,mf=globalThis.c
33
33
  `.concat(Cr,"...").concat(Vt),a=!0):ee>3&&(i+=`
34
34
  `.concat(l[g-2]),z++),i+=`
35
35
  `.concat(l[g-1]),z++),o=g,i+=`
36
- `.concat(ba,"+").concat(Vt," ").concat(l[g]),z++;else{var ge=m[g],ce=l[g],me=ce!==ge&&(!NS(ce,",")||ce.slice(0,-1)!==ge);me&&NS(ge,",")&&ge.slice(0,-1)===ce&&(me=!1,ce+=","),me?(ee>1&&g>2&&(ee>4?(i+=`
36
+ `.concat(ba,"+").concat(Vt," ").concat(l[g]),z++;else{var ge=m[g],ce=l[g],me=ce!==ge&&(!Mw(ce,",")||ce.slice(0,-1)!==ge);me&&Mw(ge,",")&&ge.slice(0,-1)===ce&&(me=!1,ce+=","),me?(ee>1&&g>2&&(ee>4?(i+=`
37
37
  `.concat(Cr,"...").concat(Vt),a=!0):ee>3&&(i+=`
38
38
  `.concat(l[g-2]),z++),i+=`
39
39
  `.concat(l[g-1]),z++),o=g,i+=`
@@ -43,28 +43,33 @@ Use Chrome, Firefox or Internet Explorer 11`)}var lN=Gt().Buffer,mf=globalThis.c
43
43
  `).concat(i,`
44
44
  `).concat(Cr,"...").concat(Vt).concat(n,`
45
45
  `)+"".concat(Cr,"...").concat(Vt)}return"".concat(W).concat(a?ie:"",`
46
- `).concat(i).concat(n).concat(s).concat(v)}var R3=(function(e,t){b3(n,e);var r=_3(n);function n(i){var o;if(y3(this,n),ur(i)!=="object"||i===null)throw new x3("options","Object",i);var s=i.message,a=i.operator,f=i.stackStartFn,l=i.actual,m=i.expected,g=Error.stackTraceLimit;if(Error.stackTraceLimit=0,s!=null)o=r.call(this,String(s));else if(I.default.stderr&&I.default.stderr.isTTY&&(I.default.stderr&&I.default.stderr.getColorDepth&&I.default.stderr.getColorDepth()!==1?(Cr="\x1B[34m",ba="\x1B[32m",Vt="\x1B[39m",_a="\x1B[31m"):(Cr="",ba="",Vt="",_a="")),ur(l)==="object"&&l!==null&&ur(m)==="object"&&m!==null&&"stack"in l&&l instanceof Error&&"stack"in m&&m instanceof Error&&(l=MS(l),m=MS(m)),a==="deepStrictEqual"||a==="strictEqual")o=r.call(this,O3(l,m,a));else if(a==="notDeepStrictEqual"||a==="notStrictEqual"){var v=Xi[a],E=wa(l).split(`
46
+ `).concat(i).concat(n).concat(s).concat(v)}var T3=(function(e,t){_3(n,e);var r=S3(n);function n(i){var o;if(m3(this,n),ur(i)!=="object"||i===null)throw new I3("options","Object",i);var s=i.message,a=i.operator,f=i.stackStartFn,l=i.actual,m=i.expected,g=Error.stackTraceLimit;if(Error.stackTraceLimit=0,s!=null)o=r.call(this,String(s));else if(x.default.stderr&&x.default.stderr.isTTY&&(x.default.stderr&&x.default.stderr.getColorDepth&&x.default.stderr.getColorDepth()!==1?(Cr="\x1B[34m",ba="\x1B[32m",Vt="\x1B[39m",_a="\x1B[31m"):(Cr="",ba="",Vt="",_a="")),ur(l)==="object"&&l!==null&&ur(m)==="object"&&m!==null&&"stack"in l&&l instanceof Error&&"stack"in m&&m instanceof Error&&(l=kw(l),m=kw(m)),a==="deepStrictEqual"||a==="strictEqual")o=r.call(this,R3(l,m,a));else if(a==="notDeepStrictEqual"||a==="notStrictEqual"){var v=Xi[a],E=Sa(l).split(`
47
47
  `);if(a==="notStrictEqual"&&ur(l)==="object"&&l!==null&&(v=Xi.notStrictEqualObject),E.length>30)for(E[26]="".concat(Cr,"...").concat(Vt);E.length>27;)E.pop();E.length===1?o=r.call(this,"".concat(v," ").concat(E[0])):o=r.call(this,"".concat(v,`
48
48
 
49
49
  `).concat(E.join(`
50
50
  `),`
51
- `))}else{var T=wa(l),N="",L=Xi[a];a==="notDeepEqual"||a==="notEqual"?(T="".concat(Xi[a],`
51
+ `))}else{var T=Sa(l),N="",L=Xi[a];a==="notDeepEqual"||a==="notEqual"?(T="".concat(Xi[a],`
52
52
 
53
- `).concat(T),T.length>1024&&(T="".concat(T.slice(0,1021),"..."))):(N="".concat(wa(m)),T.length>512&&(T="".concat(T.slice(0,509),"...")),N.length>512&&(N="".concat(N.slice(0,509),"...")),a==="deepEqual"||a==="equal"?T="".concat(L,`
53
+ `).concat(T),T.length>1024&&(T="".concat(T.slice(0,1021),"..."))):(N="".concat(Sa(m)),T.length>512&&(T="".concat(T.slice(0,509),"...")),N.length>512&&(N="".concat(N.slice(0,509),"...")),a==="deepEqual"||a==="equal"?T="".concat(L,`
54
54
 
55
55
  `).concat(T,`
56
56
 
57
57
  should equal
58
58
 
59
- `):N=" ".concat(a," ").concat(N)),o=r.call(this,"".concat(T).concat(N))}return Error.stackTraceLimit=g,o.generatedMessage=!s,Object.defineProperty(Wd(o),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),o.code="ERR_ASSERTION",o.actual=l,o.expected=m,o.operator=a,Error.captureStackTrace&&Error.captureStackTrace(Wd(o),f),o.stack,o.name="AssertionError",CS(o)}return m3(n,[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:t,value:function(o,s){return Yd(this,PS(PS({},s),{},{customInspect:!1,depth:0}))}}]),n})(zd(Error),Yd.custom);DS.exports=R3});var $d=P((PF,qS)=>{"use strict";p();var FS=Object.prototype.toString;qS.exports=function(t){var r=FS.call(t),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&FS.call(t.callee)==="[object Function]"),n}});var $S=P((NF,YS)=>{"use strict";p();var zS;Object.keys||(xa=Object.prototype.hasOwnProperty,Zd=Object.prototype.toString,jS=$d(),Xd=Object.prototype.propertyIsEnumerable,HS=!Xd.call({toString:null},"toString"),KS=Xd.call(function(){},"prototype"),Ia=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],sc=function(e){var t=e.constructor;return t&&t.prototype===e},GS={$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},VS=(function(){if(typeof window>"u")return!1;for(var e in window)try{if(!GS["$"+e]&&xa.call(window,e)&&window[e]!==null&&typeof window[e]=="object")try{sc(window[e])}catch{return!0}}catch{return!0}return!1})(),WS=function(e){if(typeof window>"u"||!VS)return sc(e);try{return sc(e)}catch{return!1}},zS=function(t){var r=t!==null&&typeof t=="object",n=Zd.call(t)==="[object Function]",i=jS(t),o=r&&Zd.call(t)==="[object String]",s=[];if(!r&&!n&&!i)throw new TypeError("Object.keys called on a non-object");var a=KS&&n;if(o&&t.length>0&&!xa.call(t,0))for(var f=0;f<t.length;++f)s.push(String(f));if(i&&t.length>0)for(var l=0;l<t.length;++l)s.push(String(l));else for(var m in t)!(a&&m==="prototype")&&xa.call(t,m)&&s.push(String(m));if(HS)for(var g=WS(t),v=0;v<Ia.length;++v)!(g&&Ia[v]==="constructor")&&xa.call(t,Ia[v])&&s.push(Ia[v]);return s});var xa,Zd,jS,Xd,HS,KS,Ia,sc,GS,VS,WS;YS.exports=zS});var Jd=P((kF,JS)=>{"use strict";p();var T3=Array.prototype.slice,P3=$d(),ZS=Object.keys,ac=ZS?function(t){return ZS(t)}:$S(),XS=Object.keys;ac.shim=function(){if(Object.keys){var t=(function(){var r=Object.keys(arguments);return r&&r.length===arguments.length})(1,2);t||(Object.keys=function(n){return P3(n)?XS(T3.call(n)):XS(n)})}else Object.keys=ac;return Object.keys||ac};JS.exports=ac});var nE=P((LF,rE)=>{"use strict";p();var B3=Jd(),eE=ru()(),tE=Hn(),uc=nu(),N3=tE("Array.prototype.push"),QS=tE("Object.prototype.propertyIsEnumerable"),M3=eE?uc.getOwnPropertySymbols:null;rE.exports=function(t,r){if(t==null)throw new TypeError("target must be an object");var n=uc(t);if(arguments.length===1)return n;for(var i=1;i<arguments.length;++i){var o=uc(arguments[i]),s=B3(o),a=eE&&(uc.getOwnPropertySymbols||M3);if(a)for(var f=a(o),l=0;l<f.length;++l){var m=f[l];QS(o,m)&&N3(s,m)}for(var g=0;g<s.length;++g){var v=s[g];if(QS(o,v)){var E=o[v];n[v]=E}}}return n}});var oE=P((UF,iE)=>{"use strict";p();var Qd=nE(),k3=function(){if(!Object.assign)return!1;for(var e="abcdefghijklmnopqrst",t=e.split(""),r={},n=0;n<t.length;++n)r[t[n]]=t[n];var i=Object.assign({},r),o="";for(var s in i)o+=s;return e!==o},C3=function(){if(!Object.assign||!Object.preventExtensions)return!1;var e=Object.preventExtensions({1:2});try{Object.assign(e,"xy")}catch{return e[1]==="y"}return!1};iE.exports=function(){return!Object.assign||k3()||C3()?Qd:Object.assign}});var ep=P((qF,aE)=>{"use strict";p();var sE=function(e){return e!==e};aE.exports=function(t,r){return t===0&&r===0?1/t===1/r:!!(t===r||sE(t)&&sE(r))}});var fc=P((HF,uE)=>{"use strict";p();var L3=ep();uE.exports=function(){return typeof Object.is=="function"?Object.is:L3}});var hE=P((GF,lE)=>{"use strict";p();var fE=hu(),cE=bs(),D3=cE(fE("String.prototype.indexOf"));lE.exports=function(t,r){var n=fE(t,!!r);return typeof n=="function"&&D3(t,".prototype.")>-1?cE(n):n}});var Aa=P((WF,yE)=>{"use strict";p();var U3=Jd(),F3=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",q3=Object.prototype.toString,j3=Array.prototype.concat,dE=jl(),H3=function(e){return typeof e=="function"&&q3.call(e)==="[object Function]"},pE=Kl()(),K3=function(e,t,r,n){if(t in e){if(n===!0){if(e[t]===r)return}else if(!H3(n)||!n())return}pE?dE(e,t,r,!0):dE(e,t,r)},gE=function(e,t){var r=arguments.length>2?arguments[2]:{},n=U3(t);F3&&(n=j3.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)K3(e,n[i],t[n[i]],r[n[i]])};gE.supportsDescriptors=!!pE;yE.exports=gE});var vE=P((YF,mE)=>{"use strict";p();var G3=fc(),V3=Aa();mE.exports=function(){var t=G3();return V3(Object,{is:t},{is:function(){return Object.is!==t}}),t}});var SE=P((ZF,wE)=>{"use strict";p();var W3=Aa(),z3=bs(),Y3=ep(),bE=fc(),$3=vE(),_E=z3(bE(),Object);W3(_E,{getPolyfill:bE,implementation:Y3,shim:$3});wE.exports=_E});var tp=P((JF,EE)=>{"use strict";p();EE.exports=function(t){return t!==t}});var rp=P((e5,xE)=>{"use strict";p();var Z3=tp();xE.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:Z3}});var AE=P((r5,IE)=>{"use strict";p();var X3=Aa(),J3=rp();IE.exports=function(){var t=J3();return X3(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}});var PE=P((i5,TE)=>{"use strict";p();var Q3=bs(),e6=Aa(),t6=tp(),OE=rp(),r6=AE(),RE=Q3(OE(),Number);e6(RE,{getPolyfill:OE,implementation:t6,shim:r6});TE.exports=RE});var ZE=P((s5,$E)=>{"use strict";p();function BE(e,t){return s6(e)||o6(e,t)||i6(e,t)||n6()}function n6(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
60
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function i6(e,t){if(e){if(typeof e=="string")return NE(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return NE(e,t)}}function NE(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function o6(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,i,o,s,a=[],f=!0,l=!1;try{if(o=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;f=!1}else for(;!(f=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);f=!0);}catch(m){l=!0,i=m}finally{try{if(!f&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw i}}return a}}function s6(e){if(Array.isArray(e))return e}function xr(e){"@babel/helpers - typeof";return xr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xr(e)}var a6=/a/g.flags!==void 0,yc=function(t){var r=[];return t.forEach(function(n){return r.push(n)}),r},ME=function(t){var r=[];return t.forEach(function(n,i){return r.push([i,n])}),r},GE=Object.is?Object.is:SE(),pc=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},np=Number.isNaN?Number.isNaN:PE();function op(e){return e.call.bind(e)}var Ra=op(Object.prototype.hasOwnProperty),gc=op(Object.prototype.propertyIsEnumerable),kE=op(Object.prototype.toString),tr=Xr().types,u6=tr.isAnyArrayBuffer,f6=tr.isArrayBufferView,CE=tr.isDate,cc=tr.isMap,LE=tr.isRegExp,lc=tr.isSet,c6=tr.isNativeError,l6=tr.isBoxedPrimitive,DE=tr.isNumberObject,UE=tr.isStringObject,FE=tr.isBooleanObject,qE=tr.isBigIntObject,h6=tr.isSymbolObject,d6=tr.isFloat32Array,p6=tr.isFloat64Array;function g6(e){if(e.length===0||e.length>10)return!0;for(var t=0;t<e.length;t++){var r=e.charCodeAt(t);if(r<48||r>57)return!0}return e.length===10&&e>=Math.pow(2,32)}function hc(e){return Object.keys(e).filter(g6).concat(pc(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}function VE(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}var dc=void 0,y6=!0,m6=!1,ip=0,sp=1,WE=2,zE=3;function v6(e,t){return a6?e.source===t.source&&e.flags===t.flags:RegExp.prototype.toString.call(e)===RegExp.prototype.toString.call(t)}function b6(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function _6(e,t){return e.byteLength!==t.byteLength?!1:VE(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))===0}function w6(e,t){return e.byteLength===t.byteLength&&VE(new Uint8Array(e),new Uint8Array(t))===0}function S6(e,t){return DE(e)?DE(t)&&GE(Number.prototype.valueOf.call(e),Number.prototype.valueOf.call(t)):UE(e)?UE(t)&&String.prototype.valueOf.call(e)===String.prototype.valueOf.call(t):FE(e)?FE(t)&&Boolean.prototype.valueOf.call(e)===Boolean.prototype.valueOf.call(t):qE(e)?qE(t)&&BigInt.prototype.valueOf.call(e)===BigInt.prototype.valueOf.call(t):h6(t)&&Symbol.prototype.valueOf.call(e)===Symbol.prototype.valueOf.call(t)}function Ir(e,t,r,n){if(e===t)return e!==0?!0:r?GE(e,t):!0;if(r){if(xr(e)!=="object")return typeof e=="number"&&np(e)&&np(t);if(xr(t)!=="object"||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1}else{if(e===null||xr(e)!=="object")return t===null||xr(t)!=="object"?e==t:!1;if(t===null||xr(t)!=="object")return!1}var i=kE(e),o=kE(t);if(i!==o)return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;var s=hc(e,dc),a=hc(t,dc);return s.length!==a.length?!1:Oa(e,t,r,n,sp,s)}if(i==="[object Object]"&&(!cc(e)&&cc(t)||!lc(e)&&lc(t)))return!1;if(CE(e)){if(!CE(t)||Date.prototype.getTime.call(e)!==Date.prototype.getTime.call(t))return!1}else if(LE(e)){if(!LE(t)||!v6(e,t))return!1}else if(c6(e)||e instanceof Error){if(e.message!==t.message||e.name!==t.name)return!1}else if(f6(e)){if(!r&&(d6(e)||p6(e))){if(!b6(e,t))return!1}else if(!_6(e,t))return!1;var f=hc(e,dc),l=hc(t,dc);return f.length!==l.length?!1:Oa(e,t,r,n,ip,f)}else{if(lc(e))return!lc(t)||e.size!==t.size?!1:Oa(e,t,r,n,WE);if(cc(e))return!cc(t)||e.size!==t.size?!1:Oa(e,t,r,n,zE);if(u6(e)){if(!w6(e,t))return!1}else if(l6(e)&&!S6(e,t))return!1}return Oa(e,t,r,n,ip)}function jE(e,t){return t.filter(function(r){return gc(e,r)})}function Oa(e,t,r,n,i,o){if(arguments.length===5){o=Object.keys(e);var s=Object.keys(t);if(o.length!==s.length)return!1}for(var a=0;a<o.length;a++)if(!Ra(t,o[a]))return!1;if(r&&arguments.length===5){var f=pc(e);if(f.length!==0){var l=0;for(a=0;a<f.length;a++){var m=f[a];if(gc(e,m)){if(!gc(t,m))return!1;o.push(m),l++}else if(gc(t,m))return!1}var g=pc(t);if(f.length!==g.length&&jE(t,g).length!==l)return!1}else{var v=pc(t);if(v.length!==0&&jE(t,v).length!==0)return!1}}if(o.length===0&&(i===ip||i===sp&&e.length===0||e.size===0))return!0;if(n===void 0)n={val1:new Map,val2:new Map,position:0};else{var E=n.val1.get(e);if(E!==void 0){var T=n.val2.get(t);if(T!==void 0)return E===T}n.position++}n.val1.set(e,n.position),n.val2.set(t,n.position);var N=O6(e,t,r,o,n,i);return n.val1.delete(e),n.val2.delete(t),N}function HE(e,t,r,n){for(var i=yc(e),o=0;o<i.length;o++){var s=i[o];if(Ir(t,s,r,n))return e.delete(s),!0}return!1}function YE(e){switch(xr(e)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":e=+e;case"number":if(np(e))return!1}return!0}function E6(e,t,r){var n=YE(r);return n??(t.has(n)&&!e.has(n))}function x6(e,t,r,n,i){var o=YE(r);if(o!=null)return o;var s=t.get(o);return s===void 0&&!t.has(o)||!Ir(n,s,!1,i)?!1:!e.has(o)&&Ir(n,s,!1,i)}function I6(e,t,r,n){for(var i=null,o=yc(e),s=0;s<o.length;s++){var a=o[s];if(xr(a)==="object"&&a!==null)i===null&&(i=new Set),i.add(a);else if(!t.has(a)){if(r||!E6(e,t,a))return!1;i===null&&(i=new Set),i.add(a)}}if(i!==null){for(var f=yc(t),l=0;l<f.length;l++){var m=f[l];if(xr(m)==="object"&&m!==null){if(!HE(i,m,r,n))return!1}else if(!r&&!e.has(m)&&!HE(i,m,r,n))return!1}return i.size===0}return!0}function KE(e,t,r,n,i,o){for(var s=yc(e),a=0;a<s.length;a++){var f=s[a];if(Ir(r,f,i,o)&&Ir(n,t.get(f),i,o))return e.delete(f),!0}return!1}function A6(e,t,r,n){for(var i=null,o=ME(e),s=0;s<o.length;s++){var a=BE(o[s],2),f=a[0],l=a[1];if(xr(f)==="object"&&f!==null)i===null&&(i=new Set),i.add(f);else{var m=t.get(f);if(m===void 0&&!t.has(f)||!Ir(l,m,r,n)){if(r||!x6(e,t,f,l,n))return!1;i===null&&(i=new Set),i.add(f)}}}if(i!==null){for(var g=ME(t),v=0;v<g.length;v++){var E=BE(g[v],2),T=E[0],N=E[1];if(xr(T)==="object"&&T!==null){if(!KE(i,e,T,N,r,n))return!1}else if(!r&&(!e.has(T)||!Ir(e.get(T),N,!1,n))&&!KE(i,e,T,N,!1,n))return!1}return i.size===0}return!0}function O6(e,t,r,n,i,o){var s=0;if(o===WE){if(!I6(e,t,r,i))return!1}else if(o===zE){if(!A6(e,t,r,i))return!1}else if(o===sp)for(;s<e.length;s++)if(Ra(e,s)){if(!Ra(t,s)||!Ir(e[s],t[s],r,i))return!1}else{if(Ra(t,s))return!1;for(var a=Object.keys(e);s<a.length;s++){var f=a[s];if(!Ra(t,f)||!Ir(e[f],t[f],r,i))return!1}return a.length===Object.keys(t).length}for(s=0;s<n.length;s++){var l=n[s];if(!Ir(e[l],t[l],r,i))return!1}return!0}function R6(e,t){return Ir(e,t,m6)}function T6(e,t){return Ir(e,t,y6)}$E.exports={isDeepEqual:R6,isDeepStrictEqual:T6}});var ic=P((u5,p1)=>{"use strict";p();function Lr(e){"@babel/helpers - typeof";return Lr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lr(e)}function XE(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,B6(n.key),n)}}function P6(e,t,r){return t&&XE(e.prototype,t),r&&XE(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function B6(e){var t=N6(e,"string");return Lr(t)==="symbol"?t:String(t)}function N6(e,t){if(Lr(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(Lr(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function M6(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var k6=Vd(),Ta=k6.codes,JE=Ta.ERR_AMBIGUOUS_ARGUMENT,es=Ta.ERR_INVALID_ARG_TYPE,C6=Ta.ERR_INVALID_ARG_VALUE,L6=Ta.ERR_INVALID_RETURN_VALUE,di=Ta.ERR_MISSING_ARGS,pi=US(),D6=Xr(),mc=D6.inspect,r1=Xr().types,U6=r1.isPromise,vc=r1.isRegExp,F6=oE()(),n1=fc()(),bc=hE()("RegExp.prototype.test"),hi,_c;function Pa(){var e=ZE();hi=e.isDeepEqual,_c=e.isDeepStrictEqual}var QE=!1,Ye=p1.exports=ap,wc={};function Dr(e){throw e.message instanceof Error?e.message:new pi(e)}function i1(e,t,r,n,i){var o=arguments.length,s;if(o===0)s="Failed";else if(o===1)r=e,e=void 0;else{if(QE===!1){QE=!0;var a=I.default.emitWarning?I.default.emitWarning:console.warn.bind(console);a("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")}o===2&&(n="!=")}if(r instanceof Error)throw r;var f={actual:e,expected:t,operator:n===void 0?"fail":n,stackStartFn:i||i1};r!==void 0&&(f.message=r);var l=new pi(f);throw s&&(l.message=s,l.generatedMessage=!0),l}Ye.fail=i1;Ye.AssertionError=pi;function o1(e,t,r,n){if(!r){var i=!1;if(t===0)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new pi({actual:r,expected:!0,message:n,operator:"==",stackStartFn:e});throw o.generatedMessage=i,o}}function ap(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];o1.apply(void 0,[ap,t.length].concat(t))}Ye.ok=ap;Ye.equal=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");t!=r&&Dr({actual:t,expected:r,message:n,operator:"==",stackStartFn:e})};Ye.notEqual=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");t==r&&Dr({actual:t,expected:r,message:n,operator:"!=",stackStartFn:e})};Ye.deepEqual=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");hi===void 0&&Pa(),hi(t,r)||Dr({actual:t,expected:r,message:n,operator:"deepEqual",stackStartFn:e})};Ye.notDeepEqual=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");hi===void 0&&Pa(),hi(t,r)&&Dr({actual:t,expected:r,message:n,operator:"notDeepEqual",stackStartFn:e})};Ye.deepStrictEqual=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");hi===void 0&&Pa(),_c(t,r)||Dr({actual:t,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:e})};Ye.notDeepStrictEqual=s1;function s1(e,t,r){if(arguments.length<2)throw new di("actual","expected");hi===void 0&&Pa(),_c(e,t)&&Dr({actual:e,expected:t,message:r,operator:"notDeepStrictEqual",stackStartFn:s1})}Ye.strictEqual=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");n1(t,r)||Dr({actual:t,expected:r,message:n,operator:"strictEqual",stackStartFn:e})};Ye.notStrictEqual=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");n1(t,r)&&Dr({actual:t,expected:r,message:n,operator:"notStrictEqual",stackStartFn:e})};var e1=P6(function e(t,r,n){var i=this;M6(this,e),r.forEach(function(o){o in t&&(n!==void 0&&typeof n[o]=="string"&&vc(t[o])&&bc(t[o],n[o])?i[o]=n[o]:i[o]=t[o])})});function q6(e,t,r,n,i,o){if(!(r in e)||!_c(e[r],t[r])){if(!n){var s=new e1(e,i),a=new e1(t,i,e),f=new pi({actual:s,expected:a,operator:"deepStrictEqual",stackStartFn:o});throw f.actual=e,f.expected=t,f.operator=o.name,f}Dr({actual:e,expected:t,message:n,operator:o.name,stackStartFn:o})}}function a1(e,t,r,n){if(typeof t!="function"){if(vc(t))return bc(t,e);if(arguments.length===2)throw new es("expected",["Function","RegExp"],t);if(Lr(e)!=="object"||e===null){var i=new pi({actual:e,expected:t,message:r,operator:"deepStrictEqual",stackStartFn:n});throw i.operator=n.name,i}var o=Object.keys(t);if(t instanceof Error)o.push("name","message");else if(o.length===0)throw new C6("error",t,"may not be an empty object");return hi===void 0&&Pa(),o.forEach(function(s){typeof e[s]=="string"&&vc(t[s])&&bc(t[s],e[s])||q6(e,t,s,r,o,n)}),!0}return t.prototype!==void 0&&e instanceof t?!0:Error.isPrototypeOf(t)?!1:t.call({},e)===!0}function u1(e){if(typeof e!="function")throw new es("fn","Function",e);try{e()}catch(t){return t}return wc}function t1(e){return U6(e)||e!==null&&Lr(e)==="object"&&typeof e.then=="function"&&typeof e.catch=="function"}function f1(e){return Promise.resolve().then(function(){var t;if(typeof e=="function"){if(t=e(),!t1(t))throw new L6("instance of Promise","promiseFn",t)}else if(t1(e))t=e;else throw new es("promiseFn",["Function","Promise"],e);return Promise.resolve().then(function(){return t}).then(function(){return wc}).catch(function(r){return r})})}function c1(e,t,r,n){if(typeof r=="string"){if(arguments.length===4)throw new es("error",["Object","Error","Function","RegExp"],r);if(Lr(t)==="object"&&t!==null){if(t.message===r)throw new JE("error/message",'The error message "'.concat(t.message,'" is identical to the message.'))}else if(t===r)throw new JE("error/message",'The error "'.concat(t,'" is identical to the message.'));n=r,r=void 0}else if(r!=null&&Lr(r)!=="object"&&typeof r!="function")throw new es("error",["Object","Error","Function","RegExp"],r);if(t===wc){var i="";r&&r.name&&(i+=" (".concat(r.name,")")),i+=n?": ".concat(n):".";var o=e.name==="rejects"?"rejection":"exception";Dr({actual:void 0,expected:r,operator:e.name,message:"Missing expected ".concat(o).concat(i),stackStartFn:e})}if(r&&!a1(t,r,n,e))throw t}function l1(e,t,r,n){if(t!==wc){if(typeof r=="string"&&(n=r,r=void 0),!r||a1(t,r)){var i=n?": ".concat(n):".",o=e.name==="doesNotReject"?"rejection":"exception";Dr({actual:t,expected:r,operator:e.name,message:"Got unwanted ".concat(o).concat(i,`
61
- `)+'Actual message: "'.concat(t&&t.message,'"'),stackStartFn:e})}throw t}}Ye.throws=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];c1.apply(void 0,[e,u1(t)].concat(n))};Ye.rejects=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return f1(t).then(function(o){return c1.apply(void 0,[e,o].concat(n))})};Ye.doesNotThrow=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];l1.apply(void 0,[e,u1(t)].concat(n))};Ye.doesNotReject=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return f1(t).then(function(o){return l1.apply(void 0,[e,o].concat(n))})};Ye.ifError=function e(t){if(t!=null){var r="ifError got unwanted exception: ";Lr(t)==="object"&&typeof t.message=="string"?t.message.length===0&&t.constructor?r+=t.constructor.name:r+=t.message:r+=mc(t);var n=new pi({actual:t,expected:null,operator:"ifError",message:r,stackStartFn:e}),i=t.stack;if(typeof i=="string"){var o=i.split(`
59
+ `):N=" ".concat(a," ").concat(N)),o=r.call(this,"".concat(T).concat(N))}return Error.stackTraceLimit=g,o.generatedMessage=!s,Object.defineProperty(Wd(o),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),o.code="ERR_ASSERTION",o.actual=l,o.expected=m,o.operator=a,Error.captureStackTrace&&Error.captureStackTrace(Wd(o),f),o.stack,o.name="AssertionError",Lw(o)}return v3(n,[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:t,value:function(o,s){return Yd(this,Bw(Bw({},s),{},{customInspect:!1,depth:0}))}}]),n})(zd(Error),Yd.custom);Uw.exports=T3});var $d=B((BF,jw)=>{"use strict";p();var qw=Object.prototype.toString;jw.exports=function(t){var r=qw.call(t),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&qw.call(t.callee)==="[object Function]"),n}});var Zw=B((MF,$w)=>{"use strict";p();var Yw;Object.keys||(xa=Object.prototype.hasOwnProperty,Zd=Object.prototype.toString,Hw=$d(),Xd=Object.prototype.propertyIsEnumerable,Kw=!Xd.call({toString:null},"toString"),Gw=Xd.call(function(){},"prototype"),Ia=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],sc=function(e){var t=e.constructor;return t&&t.prototype===e},Vw={$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},Ww=(function(){if(typeof window>"u")return!1;for(var e in window)try{if(!Vw["$"+e]&&xa.call(window,e)&&window[e]!==null&&typeof window[e]=="object")try{sc(window[e])}catch{return!0}}catch{return!0}return!1})(),zw=function(e){if(typeof window>"u"||!Ww)return sc(e);try{return sc(e)}catch{return!1}},Yw=function(t){var r=t!==null&&typeof t=="object",n=Zd.call(t)==="[object Function]",i=Hw(t),o=r&&Zd.call(t)==="[object String]",s=[];if(!r&&!n&&!i)throw new TypeError("Object.keys called on a non-object");var a=Gw&&n;if(o&&t.length>0&&!xa.call(t,0))for(var f=0;f<t.length;++f)s.push(String(f));if(i&&t.length>0)for(var l=0;l<t.length;++l)s.push(String(l));else for(var m in t)!(a&&m==="prototype")&&xa.call(t,m)&&s.push(String(m));if(Kw)for(var g=zw(t),v=0;v<Ia.length;++v)!(g&&Ia[v]==="constructor")&&xa.call(t,Ia[v])&&s.push(Ia[v]);return s});var xa,Zd,Hw,Xd,Kw,Gw,Ia,sc,Vw,Ww,zw;$w.exports=Yw});var Jd=B((CF,Qw)=>{"use strict";p();var P3=Array.prototype.slice,B3=$d(),Xw=Object.keys,ac=Xw?function(t){return Xw(t)}:Zw(),Jw=Object.keys;ac.shim=function(){if(Object.keys){var t=(function(){var r=Object.keys(arguments);return r&&r.length===arguments.length})(1,2);t||(Object.keys=function(n){return B3(n)?Jw(P3.call(n)):Jw(n)})}else Object.keys=ac;return Object.keys||ac};Qw.exports=ac});var iE=B((DF,nE)=>{"use strict";p();var N3=Jd(),tE=ru()(),rE=Hn(),uc=nu(),M3=rE("Array.prototype.push"),eE=rE("Object.prototype.propertyIsEnumerable"),k3=tE?uc.getOwnPropertySymbols:null;nE.exports=function(t,r){if(t==null)throw new TypeError("target must be an object");var n=uc(t);if(arguments.length===1)return n;for(var i=1;i<arguments.length;++i){var o=uc(arguments[i]),s=N3(o),a=tE&&(uc.getOwnPropertySymbols||k3);if(a)for(var f=a(o),l=0;l<f.length;++l){var m=f[l];eE(o,m)&&M3(s,m)}for(var g=0;g<s.length;++g){var v=s[g];if(eE(o,v)){var E=o[v];n[v]=E}}}return n}});var sE=B((FF,oE)=>{"use strict";p();var Qd=iE(),C3=function(){if(!Object.assign)return!1;for(var e="abcdefghijklmnopqrst",t=e.split(""),r={},n=0;n<t.length;++n)r[t[n]]=t[n];var i=Object.assign({},r),o="";for(var s in i)o+=s;return e!==o},L3=function(){if(!Object.assign||!Object.preventExtensions)return!1;var e=Object.preventExtensions({1:2});try{Object.assign(e,"xy")}catch{return e[1]==="y"}return!1};oE.exports=function(){return!Object.assign||C3()||L3()?Qd:Object.assign}});var ep=B((jF,uE)=>{"use strict";p();var aE=function(e){return e!==e};uE.exports=function(t,r){return t===0&&r===0?1/t===1/r:!!(t===r||aE(t)&&aE(r))}});var fc=B((KF,fE)=>{"use strict";p();var D3=ep();fE.exports=function(){return typeof Object.is=="function"?Object.is:D3}});var dE=B((VF,hE)=>{"use strict";p();var cE=hu(),lE=bs(),U3=lE(cE("String.prototype.indexOf"));hE.exports=function(t,r){var n=cE(t,!!r);return typeof n=="function"&&U3(t,".prototype.")>-1?lE(n):n}});var Oa=B((zF,mE)=>{"use strict";p();var F3=Jd(),q3=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",j3=Object.prototype.toString,H3=Array.prototype.concat,pE=jl(),K3=function(e){return typeof e=="function"&&j3.call(e)==="[object Function]"},gE=Kl()(),G3=function(e,t,r,n){if(t in e){if(n===!0){if(e[t]===r)return}else if(!K3(n)||!n())return}gE?pE(e,t,r,!0):pE(e,t,r)},yE=function(e,t){var r=arguments.length>2?arguments[2]:{},n=F3(t);q3&&(n=H3.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)G3(e,n[i],t[n[i]],r[n[i]])};yE.supportsDescriptors=!!gE;mE.exports=yE});var bE=B(($F,vE)=>{"use strict";p();var V3=fc(),W3=Oa();vE.exports=function(){var t=V3();return W3(Object,{is:t},{is:function(){return Object.is!==t}}),t}});var EE=B((XF,wE)=>{"use strict";p();var z3=Oa(),Y3=bs(),$3=ep(),_E=fc(),Z3=bE(),SE=Y3(_E(),Object);z3(SE,{getPolyfill:_E,implementation:$3,shim:Z3});wE.exports=SE});var tp=B((QF,xE)=>{"use strict";p();xE.exports=function(t){return t!==t}});var rp=B((t5,IE)=>{"use strict";p();var X3=tp();IE.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:X3}});var AE=B((n5,OE)=>{"use strict";p();var J3=Oa(),Q3=rp();OE.exports=function(){var t=Q3();return J3(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}});var BE=B((o5,PE)=>{"use strict";p();var e6=bs(),t6=Oa(),r6=tp(),RE=rp(),n6=AE(),TE=e6(RE(),Number);t6(TE,{getPolyfill:RE,implementation:r6,shim:n6});PE.exports=TE});var XE=B((a5,ZE)=>{"use strict";p();function NE(e,t){return a6(e)||s6(e,t)||o6(e,t)||i6()}function i6(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
60
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function o6(e,t){if(e){if(typeof e=="string")return ME(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ME(e,t)}}function ME(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function s6(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,i,o,s,a=[],f=!0,l=!1;try{if(o=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;f=!1}else for(;!(f=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);f=!0);}catch(m){l=!0,i=m}finally{try{if(!f&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw i}}return a}}function a6(e){if(Array.isArray(e))return e}function xr(e){"@babel/helpers - typeof";return xr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xr(e)}var u6=/a/g.flags!==void 0,yc=function(t){var r=[];return t.forEach(function(n){return r.push(n)}),r},kE=function(t){var r=[];return t.forEach(function(n,i){return r.push([i,n])}),r},VE=Object.is?Object.is:EE(),pc=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},np=Number.isNaN?Number.isNaN:BE();function op(e){return e.call.bind(e)}var Ra=op(Object.prototype.hasOwnProperty),gc=op(Object.prototype.propertyIsEnumerable),CE=op(Object.prototype.toString),tr=Xr().types,f6=tr.isAnyArrayBuffer,c6=tr.isArrayBufferView,LE=tr.isDate,cc=tr.isMap,DE=tr.isRegExp,lc=tr.isSet,l6=tr.isNativeError,h6=tr.isBoxedPrimitive,UE=tr.isNumberObject,FE=tr.isStringObject,qE=tr.isBooleanObject,jE=tr.isBigIntObject,d6=tr.isSymbolObject,p6=tr.isFloat32Array,g6=tr.isFloat64Array;function y6(e){if(e.length===0||e.length>10)return!0;for(var t=0;t<e.length;t++){var r=e.charCodeAt(t);if(r<48||r>57)return!0}return e.length===10&&e>=Math.pow(2,32)}function hc(e){return Object.keys(e).filter(y6).concat(pc(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}function WE(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}var dc=void 0,m6=!0,v6=!1,ip=0,sp=1,zE=2,YE=3;function b6(e,t){return u6?e.source===t.source&&e.flags===t.flags:RegExp.prototype.toString.call(e)===RegExp.prototype.toString.call(t)}function _6(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function S6(e,t){return e.byteLength!==t.byteLength?!1:WE(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))===0}function w6(e,t){return e.byteLength===t.byteLength&&WE(new Uint8Array(e),new Uint8Array(t))===0}function E6(e,t){return UE(e)?UE(t)&&VE(Number.prototype.valueOf.call(e),Number.prototype.valueOf.call(t)):FE(e)?FE(t)&&String.prototype.valueOf.call(e)===String.prototype.valueOf.call(t):qE(e)?qE(t)&&Boolean.prototype.valueOf.call(e)===Boolean.prototype.valueOf.call(t):jE(e)?jE(t)&&BigInt.prototype.valueOf.call(e)===BigInt.prototype.valueOf.call(t):d6(t)&&Symbol.prototype.valueOf.call(e)===Symbol.prototype.valueOf.call(t)}function Ir(e,t,r,n){if(e===t)return e!==0?!0:r?VE(e,t):!0;if(r){if(xr(e)!=="object")return typeof e=="number"&&np(e)&&np(t);if(xr(t)!=="object"||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1}else{if(e===null||xr(e)!=="object")return t===null||xr(t)!=="object"?e==t:!1;if(t===null||xr(t)!=="object")return!1}var i=CE(e),o=CE(t);if(i!==o)return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;var s=hc(e,dc),a=hc(t,dc);return s.length!==a.length?!1:Aa(e,t,r,n,sp,s)}if(i==="[object Object]"&&(!cc(e)&&cc(t)||!lc(e)&&lc(t)))return!1;if(LE(e)){if(!LE(t)||Date.prototype.getTime.call(e)!==Date.prototype.getTime.call(t))return!1}else if(DE(e)){if(!DE(t)||!b6(e,t))return!1}else if(l6(e)||e instanceof Error){if(e.message!==t.message||e.name!==t.name)return!1}else if(c6(e)){if(!r&&(p6(e)||g6(e))){if(!_6(e,t))return!1}else if(!S6(e,t))return!1;var f=hc(e,dc),l=hc(t,dc);return f.length!==l.length?!1:Aa(e,t,r,n,ip,f)}else{if(lc(e))return!lc(t)||e.size!==t.size?!1:Aa(e,t,r,n,zE);if(cc(e))return!cc(t)||e.size!==t.size?!1:Aa(e,t,r,n,YE);if(f6(e)){if(!w6(e,t))return!1}else if(h6(e)&&!E6(e,t))return!1}return Aa(e,t,r,n,ip)}function HE(e,t){return t.filter(function(r){return gc(e,r)})}function Aa(e,t,r,n,i,o){if(arguments.length===5){o=Object.keys(e);var s=Object.keys(t);if(o.length!==s.length)return!1}for(var a=0;a<o.length;a++)if(!Ra(t,o[a]))return!1;if(r&&arguments.length===5){var f=pc(e);if(f.length!==0){var l=0;for(a=0;a<f.length;a++){var m=f[a];if(gc(e,m)){if(!gc(t,m))return!1;o.push(m),l++}else if(gc(t,m))return!1}var g=pc(t);if(f.length!==g.length&&HE(t,g).length!==l)return!1}else{var v=pc(t);if(v.length!==0&&HE(t,v).length!==0)return!1}}if(o.length===0&&(i===ip||i===sp&&e.length===0||e.size===0))return!0;if(n===void 0)n={val1:new Map,val2:new Map,position:0};else{var E=n.val1.get(e);if(E!==void 0){var T=n.val2.get(t);if(T!==void 0)return E===T}n.position++}n.val1.set(e,n.position),n.val2.set(t,n.position);var N=R6(e,t,r,o,n,i);return n.val1.delete(e),n.val2.delete(t),N}function KE(e,t,r,n){for(var i=yc(e),o=0;o<i.length;o++){var s=i[o];if(Ir(t,s,r,n))return e.delete(s),!0}return!1}function $E(e){switch(xr(e)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":e=+e;case"number":if(np(e))return!1}return!0}function x6(e,t,r){var n=$E(r);return n??(t.has(n)&&!e.has(n))}function I6(e,t,r,n,i){var o=$E(r);if(o!=null)return o;var s=t.get(o);return s===void 0&&!t.has(o)||!Ir(n,s,!1,i)?!1:!e.has(o)&&Ir(n,s,!1,i)}function O6(e,t,r,n){for(var i=null,o=yc(e),s=0;s<o.length;s++){var a=o[s];if(xr(a)==="object"&&a!==null)i===null&&(i=new Set),i.add(a);else if(!t.has(a)){if(r||!x6(e,t,a))return!1;i===null&&(i=new Set),i.add(a)}}if(i!==null){for(var f=yc(t),l=0;l<f.length;l++){var m=f[l];if(xr(m)==="object"&&m!==null){if(!KE(i,m,r,n))return!1}else if(!r&&!e.has(m)&&!KE(i,m,r,n))return!1}return i.size===0}return!0}function GE(e,t,r,n,i,o){for(var s=yc(e),a=0;a<s.length;a++){var f=s[a];if(Ir(r,f,i,o)&&Ir(n,t.get(f),i,o))return e.delete(f),!0}return!1}function A6(e,t,r,n){for(var i=null,o=kE(e),s=0;s<o.length;s++){var a=NE(o[s],2),f=a[0],l=a[1];if(xr(f)==="object"&&f!==null)i===null&&(i=new Set),i.add(f);else{var m=t.get(f);if(m===void 0&&!t.has(f)||!Ir(l,m,r,n)){if(r||!I6(e,t,f,l,n))return!1;i===null&&(i=new Set),i.add(f)}}}if(i!==null){for(var g=kE(t),v=0;v<g.length;v++){var E=NE(g[v],2),T=E[0],N=E[1];if(xr(T)==="object"&&T!==null){if(!GE(i,e,T,N,r,n))return!1}else if(!r&&(!e.has(T)||!Ir(e.get(T),N,!1,n))&&!GE(i,e,T,N,!1,n))return!1}return i.size===0}return!0}function R6(e,t,r,n,i,o){var s=0;if(o===zE){if(!O6(e,t,r,i))return!1}else if(o===YE){if(!A6(e,t,r,i))return!1}else if(o===sp)for(;s<e.length;s++)if(Ra(e,s)){if(!Ra(t,s)||!Ir(e[s],t[s],r,i))return!1}else{if(Ra(t,s))return!1;for(var a=Object.keys(e);s<a.length;s++){var f=a[s];if(!Ra(t,f)||!Ir(e[f],t[f],r,i))return!1}return a.length===Object.keys(t).length}for(s=0;s<n.length;s++){var l=n[s];if(!Ir(e[l],t[l],r,i))return!1}return!0}function T6(e,t){return Ir(e,t,v6)}function P6(e,t){return Ir(e,t,m6)}ZE.exports={isDeepEqual:T6,isDeepStrictEqual:P6}});var ic=B((f5,g1)=>{"use strict";p();function Lr(e){"@babel/helpers - typeof";return Lr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lr(e)}function JE(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,N6(n.key),n)}}function B6(e,t,r){return t&&JE(e.prototype,t),r&&JE(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function N6(e){var t=M6(e,"string");return Lr(t)==="symbol"?t:String(t)}function M6(e,t){if(Lr(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(Lr(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function k6(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var C6=Vd(),Ta=C6.codes,QE=Ta.ERR_AMBIGUOUS_ARGUMENT,es=Ta.ERR_INVALID_ARG_TYPE,L6=Ta.ERR_INVALID_ARG_VALUE,D6=Ta.ERR_INVALID_RETURN_VALUE,di=Ta.ERR_MISSING_ARGS,pi=Fw(),U6=Xr(),mc=U6.inspect,n1=Xr().types,F6=n1.isPromise,vc=n1.isRegExp,q6=sE()(),i1=fc()(),bc=dE()("RegExp.prototype.test"),hi,_c;function Pa(){var e=XE();hi=e.isDeepEqual,_c=e.isDeepStrictEqual}var e1=!1,Ye=g1.exports=ap,Sc={};function Dr(e){throw e.message instanceof Error?e.message:new pi(e)}function o1(e,t,r,n,i){var o=arguments.length,s;if(o===0)s="Failed";else if(o===1)r=e,e=void 0;else{if(e1===!1){e1=!0;var a=x.default.emitWarning?x.default.emitWarning:console.warn.bind(console);a("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")}o===2&&(n="!=")}if(r instanceof Error)throw r;var f={actual:e,expected:t,operator:n===void 0?"fail":n,stackStartFn:i||o1};r!==void 0&&(f.message=r);var l=new pi(f);throw s&&(l.message=s,l.generatedMessage=!0),l}Ye.fail=o1;Ye.AssertionError=pi;function s1(e,t,r,n){if(!r){var i=!1;if(t===0)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new pi({actual:r,expected:!0,message:n,operator:"==",stackStartFn:e});throw o.generatedMessage=i,o}}function ap(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];s1.apply(void 0,[ap,t.length].concat(t))}Ye.ok=ap;Ye.equal=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");t!=r&&Dr({actual:t,expected:r,message:n,operator:"==",stackStartFn:e})};Ye.notEqual=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");t==r&&Dr({actual:t,expected:r,message:n,operator:"!=",stackStartFn:e})};Ye.deepEqual=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");hi===void 0&&Pa(),hi(t,r)||Dr({actual:t,expected:r,message:n,operator:"deepEqual",stackStartFn:e})};Ye.notDeepEqual=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");hi===void 0&&Pa(),hi(t,r)&&Dr({actual:t,expected:r,message:n,operator:"notDeepEqual",stackStartFn:e})};Ye.deepStrictEqual=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");hi===void 0&&Pa(),_c(t,r)||Dr({actual:t,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:e})};Ye.notDeepStrictEqual=a1;function a1(e,t,r){if(arguments.length<2)throw new di("actual","expected");hi===void 0&&Pa(),_c(e,t)&&Dr({actual:e,expected:t,message:r,operator:"notDeepStrictEqual",stackStartFn:a1})}Ye.strictEqual=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");i1(t,r)||Dr({actual:t,expected:r,message:n,operator:"strictEqual",stackStartFn:e})};Ye.notStrictEqual=function e(t,r,n){if(arguments.length<2)throw new di("actual","expected");i1(t,r)&&Dr({actual:t,expected:r,message:n,operator:"notStrictEqual",stackStartFn:e})};var t1=B6(function e(t,r,n){var i=this;k6(this,e),r.forEach(function(o){o in t&&(n!==void 0&&typeof n[o]=="string"&&vc(t[o])&&bc(t[o],n[o])?i[o]=n[o]:i[o]=t[o])})});function j6(e,t,r,n,i,o){if(!(r in e)||!_c(e[r],t[r])){if(!n){var s=new t1(e,i),a=new t1(t,i,e),f=new pi({actual:s,expected:a,operator:"deepStrictEqual",stackStartFn:o});throw f.actual=e,f.expected=t,f.operator=o.name,f}Dr({actual:e,expected:t,message:n,operator:o.name,stackStartFn:o})}}function u1(e,t,r,n){if(typeof t!="function"){if(vc(t))return bc(t,e);if(arguments.length===2)throw new es("expected",["Function","RegExp"],t);if(Lr(e)!=="object"||e===null){var i=new pi({actual:e,expected:t,message:r,operator:"deepStrictEqual",stackStartFn:n});throw i.operator=n.name,i}var o=Object.keys(t);if(t instanceof Error)o.push("name","message");else if(o.length===0)throw new L6("error",t,"may not be an empty object");return hi===void 0&&Pa(),o.forEach(function(s){typeof e[s]=="string"&&vc(t[s])&&bc(t[s],e[s])||j6(e,t,s,r,o,n)}),!0}return t.prototype!==void 0&&e instanceof t?!0:Error.isPrototypeOf(t)?!1:t.call({},e)===!0}function f1(e){if(typeof e!="function")throw new es("fn","Function",e);try{e()}catch(t){return t}return Sc}function r1(e){return F6(e)||e!==null&&Lr(e)==="object"&&typeof e.then=="function"&&typeof e.catch=="function"}function c1(e){return Promise.resolve().then(function(){var t;if(typeof e=="function"){if(t=e(),!r1(t))throw new D6("instance of Promise","promiseFn",t)}else if(r1(e))t=e;else throw new es("promiseFn",["Function","Promise"],e);return Promise.resolve().then(function(){return t}).then(function(){return Sc}).catch(function(r){return r})})}function l1(e,t,r,n){if(typeof r=="string"){if(arguments.length===4)throw new es("error",["Object","Error","Function","RegExp"],r);if(Lr(t)==="object"&&t!==null){if(t.message===r)throw new QE("error/message",'The error message "'.concat(t.message,'" is identical to the message.'))}else if(t===r)throw new QE("error/message",'The error "'.concat(t,'" is identical to the message.'));n=r,r=void 0}else if(r!=null&&Lr(r)!=="object"&&typeof r!="function")throw new es("error",["Object","Error","Function","RegExp"],r);if(t===Sc){var i="";r&&r.name&&(i+=" (".concat(r.name,")")),i+=n?": ".concat(n):".";var o=e.name==="rejects"?"rejection":"exception";Dr({actual:void 0,expected:r,operator:e.name,message:"Missing expected ".concat(o).concat(i),stackStartFn:e})}if(r&&!u1(t,r,n,e))throw t}function h1(e,t,r,n){if(t!==Sc){if(typeof r=="string"&&(n=r,r=void 0),!r||u1(t,r)){var i=n?": ".concat(n):".",o=e.name==="doesNotReject"?"rejection":"exception";Dr({actual:t,expected:r,operator:e.name,message:"Got unwanted ".concat(o).concat(i,`
61
+ `)+'Actual message: "'.concat(t&&t.message,'"'),stackStartFn:e})}throw t}}Ye.throws=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];l1.apply(void 0,[e,f1(t)].concat(n))};Ye.rejects=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return c1(t).then(function(o){return l1.apply(void 0,[e,o].concat(n))})};Ye.doesNotThrow=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];h1.apply(void 0,[e,f1(t)].concat(n))};Ye.doesNotReject=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return c1(t).then(function(o){return h1.apply(void 0,[e,o].concat(n))})};Ye.ifError=function e(t){if(t!=null){var r="ifError got unwanted exception: ";Lr(t)==="object"&&typeof t.message=="string"?t.message.length===0&&t.constructor?r+=t.constructor.name:r+=t.message:r+=mc(t);var n=new pi({actual:t,expected:null,operator:"ifError",message:r,stackStartFn:e}),i=t.stack;if(typeof i=="string"){var o=i.split(`
62
62
  `);o.shift();for(var s=n.stack.split(`
63
63
  `),a=0;a<o.length;a++){var f=s.indexOf(o[a]);if(f!==-1){s=s.slice(0,f);break}}n.stack="".concat(s.join(`
64
64
  `),`
65
65
  `).concat(o.join(`
66
- `))}throw n}};function h1(e,t,r,n,i){if(!vc(t))throw new es("regexp","RegExp",t);var o=i==="match";if(typeof e!="string"||bc(t,e)!==o){if(r instanceof Error)throw r;var s=!r;r=r||(typeof e!="string"?'The "string" argument must be of type string. Received type '+"".concat(Lr(e)," (").concat(mc(e),")"):(o?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(mc(t),`. Input:
66
+ `))}throw n}};function d1(e,t,r,n,i){if(!vc(t))throw new es("regexp","RegExp",t);var o=i==="match";if(typeof e!="string"||bc(t,e)!==o){if(r instanceof Error)throw r;var s=!r;r=r||(typeof e!="string"?'The "string" argument must be of type string. Received type '+"".concat(Lr(e)," (").concat(mc(e),")"):(o?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(mc(t),`. Input:
67
67
 
68
68
  `).concat(mc(e),`
69
- `));var a=new pi({actual:e,expected:t,message:r,operator:i,stackStartFn:n});throw a.generatedMessage=s,a}}Ye.match=function e(t,r,n){h1(t,r,n,e,"match")};Ye.doesNotMatch=function e(t,r,n){h1(t,r,n,e,"doesNotMatch")};function d1(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];o1.apply(void 0,[d1,t.length].concat(t))}Ye.strict=F6(d1,Ye,{equal:Ye.strictEqual,deepEqual:Ye.deepStrictEqual,notEqual:Ye.notStrictEqual,notDeepEqual:Ye.notDeepStrictEqual});Ye.strict.strict=Ye.strict});var Ji=P((c5,y1)=>{"use strict";p();var g1=ic(),ot=function e(t){if(!(this instanceof e))return new e(t);this.bufLen=0,t?this.set(t):this.bufs=[]};ot.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this.bufLen=this.bufs.reduce(function(t,r){return t+r.length},0),this};ot.prototype.toBuffer=function(){return this.concat()};ot.prototype.concat=function(){return d.Buffer.concat(this.bufs,this.bufLen)};ot.prototype.write=function(e){return g1(d.Buffer.isBuffer(e)),this.bufs.push(e),this.bufLen+=e.length,this};ot.prototype.writeReverse=function(e){return g1(d.Buffer.isBuffer(e)),this.bufs.push(d.Buffer.from(e).reverse()),this.bufLen+=e.length,this};ot.prototype.writeUInt8=function(e){var t=d.Buffer.alloc(1);return t.writeUInt8(e,0),this.write(t),this};ot.prototype.writeUInt16BE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this};ot.prototype.writeUInt16LE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this};ot.prototype.writeUInt32BE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this};ot.prototype.writeInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e,0),this.write(t),this};ot.prototype.writeUInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this};ot.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this};ot.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this};ot.prototype.writeVarintNum=function(e){var t=ot.varintBufNum(e);return this.write(t),this};ot.prototype.writeVarintBN=function(e){var t=ot.varintBufBN(e);return this.write(t),this};ot.varintBufNum=function(e){var t;return e<253?(t=d.Buffer.alloc(1),t.writeUInt8(e,0)):e<65536?(t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?(t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=d.Buffer.alloc(9),t.writeUInt8(255,0),t.writeInt32LE(e&-1,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t};ot.varintBufBN=function(e){var t,r=e.toNumber();if(r<253)t=d.Buffer.alloc(1),t.writeUInt8(r,0);else if(r<65536)t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(r,1);else if(r<4294967296)t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(r,1);else{var n=new ot;n.writeUInt8(255),n.writeUInt64LEBN(e),t=n.concat()}return t};y1.exports=ot});var fp=P((h5,m1)=>{"use strict";p();var ts=ze(),Ba=Le(),j6=dr();function Ne(e){if(!(this instanceof Ne))return new Ne(e);var t;if(ts.isNumber(e))t=e;else if(ts.isString(e))t=Ne.map[e];else throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');return j6.defineImmutable(this,{num:t}),this}Ne.fromBuffer=function(e){return Ba.checkArgument(d.Buffer.isBuffer(e)),new Ne(+("0x"+e.toString("hex")))};Ne.fromNumber=function(e){return Ba.checkArgument(ts.isNumber(e)),new Ne(e)};Ne.fromString=function(e){Ba.checkArgument(ts.isString(e));var t=Ne.map[e];if(typeof t>"u")throw new TypeError("Invalid opcodestr");return new Ne(t)};Ne.prototype.toHex=function(){return this.num.toString(16)};Ne.prototype.toBuffer=function(){return d.Buffer.from(this.toHex(),"hex")};Ne.prototype.toNumber=function(){return this.num};Ne.prototype.toString=function(){var e=Ne.reverseMap[this.num];if(typeof e>"u")throw new Error("Opcode does not have a string representation");return e};Ne.smallInt=function(e){return Ba.checkArgument(ts.isNumber(e),"Invalid Argument: n should be number"),Ba.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),e===0?Ne("OP_0"):new Ne(Ne.map.OP_1+e-1)};Ne.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_LSHIFTNUM:182,OP_RSHIFTNUM:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};Ne.reverseMap=[];for(up in Ne.map)Ne.reverseMap[Ne.map[up]]=up;var up;ts.extend(Ne,Ne.map);Ne.isSmallIntOp=function(e){return e instanceof Ne&&(e=e.toNumber()),e===Ne.map.OP_0||e>=Ne.map.OP_1&&e<=Ne.map.OP_16};Ne.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"};m1.exports=Ne});var nr=P((p5,b1)=>{"use strict";p();var Qi=Sr(),H6=ze(),rr=Le(),K6=dr(),Re=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof Qi)this.set({r:t,s:r});else if(t){var n=t;this.set(n)}};Re.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=typeof e.i<"u"?e.i:this.i,this.compressed=typeof e.compressed<"u"?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this};Re.fromCompact=function(e){rr.checkArgument(d.Buffer.isBuffer(e),"Argument is expected to be a Buffer");var t=new Re,r=!0,n=e.slice(0,1)[0]-27-4;n<0&&(r=!1,n=n+4);var i=e.slice(1,33),o=e.slice(33,65);return rr.checkArgument(n===0||n===1||n===2||n===3,new Error("i must be 0, 1, 2, or 3")),rr.checkArgument(i.length===32,new Error("r must be 32 bytes")),rr.checkArgument(o.length===32,new Error("s must be 32 bytes")),t.compressed=r,t.i=n,t.r=Qi.fromBuffer(i),t.s=Qi.fromBuffer(o),t};Re.fromDER=Re.fromBuffer=function(e,t){var r=Re.parseDER(e,t),n=new Re;return n.r=r.r,n.s=r.s,n};Re.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),n=Re.fromDER(r,!1);return n.nhashtype=t,n};Re.fromString=function(e){var t=d.Buffer.from(e,"hex");return Re.fromDER(t)};function v1(e,t){rr.checkArgument(t.length>0,new Error("Length of "+e+" is zero")),rr.checkArgument(!(t[0]&128),new Error("Value of "+e+" is negative")),rr.checkArgument(!(t.length>1&&t[0]===0&&!(t[1]&128)),new Error("Value of "+e+" is excessively padded"))}Re.parseDER=function(e,t){rr.checkArgument(d.Buffer.isBuffer(e),new Error("DER formatted signature should be a buffer")),H6.isUndefined(t)&&(t=!0);var r=e[0];rr.checkArgument(r===48,new Error("Header byte should be 0x30"));var n=e[1],i=e.slice(2).length;rr.checkArgument(!t||n===i,new Error("Length byte should length of what follows")),n=n<i?n:i;var o=e[2];rr.checkArgument(o===2,new Error("Integer byte for r should be 0x02"));var s=e[3],a=e.slice(4,4+s),f=Qi.fromBuffer(a),l=e[4]===0;rr.checkArgument(s===a.length,new Error("Length of r incorrect"));var m=e[4+s+0];rr.checkArgument(m===2,new Error("Integer byte for s should be 0x02"));var g=e[4+s+1],v=e.slice(4+s+2,4+s+2+g),E=Qi.fromBuffer(v),T=e[4+s+2]===0;rr.checkArgument(g===v.length,new Error("Length of s incorrect"));var N=4+s+2+g;rr.checkArgument(n===N-2,new Error("Length of signature incorrect")),t&&(v1("r",a),v1("s",v));var L={header:r,length:n,rheader:o,rlength:s,rneg:l,rbuf:a,r:f,sheader:m,slength:g,sneg:T,sbuf:v,s:E};return L};Re.prototype.toCompact=function(e,t){if(e=typeof e=="number"?e:this.i,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;t===!1&&(r=r-4);var n=d.Buffer.from([r]),i=this.r.toBuffer({size:32}),o=this.s.toBuffer({size:32});return d.Buffer.concat([n,i,o])};Re.prototype.toBuffer=Re.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(e[0]&128),n=!!(t[0]&128),i=r?d.Buffer.concat([d.Buffer.from([0]),e]):e,o=n?d.Buffer.concat([d.Buffer.from([0]),t]):t,s=i.length,a=o.length,f=2+s+2+a,l=2,m=2,g=48,v=d.Buffer.concat([d.Buffer.from([g,f,l,s]),i,d.Buffer.from([m,a]),o]);return v};Re.prototype.toString=function(){var e=this.toDER();return e.toString("hex")};Re.isTxDER=function(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var n=e.slice(4);if(e[2]!==2||t===0||n[0]&128||t>1&&n[0]===0&&!(n[1]&128))return!1;var i=e.slice(6+t);return!(e[6+t-2]!==2||r===0||i[0]&128||r>1&&i[0]===0&&!(i[1]&128))};Re.prototype.hasLowS=function(){return!(this.s.lt(new Qi(1))||this.s.gt(new Qi("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))};Re.prototype.hasDefinedHashtype=function(){if(!K6.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&31;return!(e<Re.SIGHASH_ALL||e>Re.SIGHASH_SINGLE)};Re.prototype.toTxFormat=function(){var e=this.toDER(),t=d.Buffer.alloc(1);return t.writeUInt8(this.nhashtype,0),d.Buffer.concat([e,t])};Re.SIGHASH_ALL=1;Re.SIGHASH_NONE=2;Re.SIGHASH_SINGLE=3;Re.SIGHASH_CHRONICLE=32;Re.SIGHASH_FORKID=64;Re.SIGHASH_ANYONECANPAY=128;Re.prototype.isCanonical=function(){var e=ai(),t=e.getN().shrn(1);return this.s.lte(t)};Re.prototype.toCanonical=function(){if(this.isCanonical())return new Re({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=ai(),t=e.getN(),r=t.sub(this.s);return new Re({r:this.r,s:r,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})};Re.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=ai(),t=e.getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0};Re.prototype.isValid=function(){try{return this.validate(),!0}catch{return!1}};Re.prototype.applySecurityPatches=function(){var e=ai(),t=e.getN(),r=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");if(this.s.gt(r))throw new Error("Invalid signature: non-canonical (high) s");return this};b1.exports=Re});var hp=P((y5,S1)=>{"use strict";p();var Ur=ro(),G6=ma(),V6=Ji(),cp=Jt(),Q=fp(),to=Ar(),eo=nr(),_1=pa(),Xe=Le(),Te=ze(),lp=Zn(),w1=Nt(),W6=dr(),q=function e(t){if(!(this instanceof e))return new e(t);if(this.chunks=[],d.Buffer.isBuffer(t))return e.fromBuffer(t);if(t instanceof Ur)return e.fromAddress(t);if(t instanceof e)return e.fromBuffer(t.toBuffer());if(Te.isString(t))return e.fromString(t);Te.isObject(t)&&Te.isArray(t.chunks)&&this.set(t)};q.prototype.set=function(e){return Xe.checkArgument(Te.isObject(e)),Xe.checkArgument(Te.isArray(e.chunks)),this.chunks=e.chunks,this};q.fromBuffer=function(e){var t=new q;t.chunks=[];for(var r=new G6(e);!r.finished();)try{var n=r.readUInt8(),i,o;n>0&&n<Q.OP_PUSHDATA1?(i=n,t.chunks.push({buf:r.read(i),len:i,opcodenum:n})):n===Q.OP_PUSHDATA1?(i=r.readUInt8(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===Q.OP_PUSHDATA2?(i=r.readUInt16LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===Q.OP_PUSHDATA4?(i=r.readUInt32LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):t.chunks.push({opcodenum:n})}catch(s){throw s instanceof RangeError?new lp.Script.InvalidBuffer(e.toString("hex")):s}return t};q.prototype.toBuffer=function(){for(var e=new V6,t=0;t<this.chunks.length;t++){var r=this.chunks[t],n=r.opcodenum;e.writeUInt8(r.opcodenum),r.buf&&(n<Q.OP_PUSHDATA1?e.write(r.buf):n===Q.OP_PUSHDATA1?(e.writeUInt8(r.len),e.write(r.buf)):n===Q.OP_PUSHDATA2?(e.writeUInt16LE(r.len),e.write(r.buf)):n===Q.OP_PUSHDATA4&&(e.writeUInt32LE(r.len),e.write(r.buf)))}return e.concat()};q.fromASM=function(e){var t=new q;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=Q(i),s=o.toNumber();if(i==="0")s=0,t.chunks.push({opcodenum:s}),n=n+1;else if(i==="-1")s=Q.OP_1NEGATE,t.chunks.push({opcodenum:s}),n=n+1;else if(Te.isUndefined(s)){var a=d.Buffer.from(r[n],"hex");if(a.toString("hex")!==r[n])throw new Error("invalid hex string in script");var f=a.length;f>=0&&f<Q.OP_PUSHDATA1?s=f:f<Math.pow(2,8)?s=Q.OP_PUSHDATA1:f<Math.pow(2,16)?s=Q.OP_PUSHDATA2:f<Math.pow(2,32)&&(s=Q.OP_PUSHDATA4),t.chunks.push({buf:a,len:a.length,opcodenum:s}),n=n+1}else t.chunks.push({opcodenum:s}),n=n+1}return t};q.fromHex=function(e){return new q(w1.Buffer.from(e,"hex"))};q.fromString=function(e){if(W6.isHexa(e)||e.length===0)return new q(w1.Buffer.from(e,"hex"));var t=new q;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=Q(i),s=o.toNumber();if(Te.isUndefined(s))if(s=parseInt(i),s>0&&s<Q.OP_PUSHDATA1)t.chunks.push({buf:d.Buffer.from(r[n+1].slice(2),"hex"),len:s,opcodenum:s}),n=n+2;else throw new Error("Invalid script: "+JSON.stringify(e));else if(s===Q.OP_PUSHDATA1||s===Q.OP_PUSHDATA2||s===Q.OP_PUSHDATA4){if(r[n+2].slice(0,2)!=="0x")throw new Error("Pushdata data must start with 0x");t.chunks.push({buf:d.Buffer.from(r[n+2].slice(2),"hex"),len:parseInt(r[n+1]),opcodenum:s}),n=n+3}else t.chunks.push({opcodenum:s}),n=n+1}return t};q.prototype._chunkToString=function(e,t){var r=e.opcodenum,n=t==="asm",i="";if(e.buf)!n&&(r===Q.OP_PUSHDATA1||r===Q.OP_PUSHDATA2||r===Q.OP_PUSHDATA4)&&(i=i+" "+Q(r).toString()),e.len>0&&(n?i=i+" "+e.buf.toString("hex"):i=i+" "+e.len+" 0x"+e.buf.toString("hex"));else if(typeof Q.reverseMap[r]<"u")n?r===0?i=i+" 0":r===79?i=i+" -1":i=i+" "+Q(r).toString():i=i+" "+Q(r).toString();else{var o=r.toString(16);o.length%2!==0&&(o="0"+o),n?i=i+" "+o:i=i+" 0x"+o}return i};q.prototype.toASM=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r,"asm")}return e.substr(1)};q.prototype.toString=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r)}return e.substr(1)};q.prototype.toHex=function(){return this.toBuffer().toString("hex")};q.prototype.inspect=function(){return"<Script: "+this.toString()+">"};q.prototype.isPublicKeyHashOut=function(){return!!(this.chunks.length===5&&this.chunks[0].opcodenum===Q.OP_DUP&&this.chunks[1].opcodenum===Q.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===Q.OP_EQUALVERIFY&&this.chunks[4].opcodenum===Q.OP_CHECKSIG)};q.prototype.isPublicKeyHashOutPrefix=function(){return!!(this.chunks.length>=5&&this.chunks[0].opcodenum===Q.OP_DUP&&this.chunks[1].opcodenum===Q.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===Q.OP_EQUALVERIFY&&this.chunks[4].opcodenum===Q.OP_CHECKSIG)};q.prototype.isPublicKeyHashIn=function(){if(this.chunks.length===2){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&e[0]===48&&t&&t.length){var r=t[0];if((r===4||r===6||r===7)&&t.length===65)return!0;if((r===3||r===2)&&t.length===33)return!0}}return!1};q.prototype.getPublicKey=function(){return Xe.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf};q.prototype.getPublicKeyHash=function(){return Xe.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf};q.prototype.isPublicKeyOut=function(){if(this.chunks.length===2&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===Q.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if(((t===4||t===6||t===7)&&e.length===65||(t===3||t===2)&&e.length===33)&&(r=!0),r)return to.isValid(e)}return!1};q.prototype.isPublicKeyIn=function(){if(this.chunks.length===1){var e=this.chunks[0].buf;if(e&&e.length&&e[0]===48)return!0}return!1};q.prototype.isScriptHashOut=function(){var e=this.toBuffer();return e.length===23&&e[0]===Q.OP_HASH160&&e[1]===20&&e[e.length-1]===Q.OP_EQUAL};q.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e=this.chunks[this.chunks.length-1],t=e.buf;if(!t)return!1;var r;try{r=q.fromBuffer(t)}catch(i){if(i instanceof lp.Script.InvalidBuffer)return!1;throw i}var n=r.classify();return n!==q.types.UNKNOWN};q.prototype.isMultisigOut=function(){return this.chunks.length>3&&Q.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)})&&Q.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===Q.OP_CHECKMULTISIG};q.prototype.isMultisigIn=function(){return this.chunks.length>=2&&this.chunks[0].opcodenum===0&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)&&eo.isTxDER(e.buf)})};q.prototype.isDataOut=function(){var e=this.chunks.length>=1&&this.chunks[0].opcodenum===Q.OP_RETURN;if(!e)return!1;var t=this.chunks.slice(1),r=new q({chunks:t});return r.isPushOnly()};q.prototype.isSafeDataOut=function(){if(this.chunks.length<2||this.chunks[0].opcodenum!==Q.OP_FALSE)return!1;var e=this.chunks.slice(1),t=new q({chunks:e});return t.isDataOut()};q.prototype.getData=function(){if(this.isSafeDataOut()){var e=this.chunks.slice(2),t=e.map(r=>r.buf);return t}if(this.isDataOut()||this.isScriptHashOut())return Te.isUndefined(this.chunks[1])?d.Buffer.alloc(0):d.Buffer.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return d.Buffer.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")};q.prototype.isPushOnly=function(){return Te.every(this.chunks,function(e){return e.opcodenum<=Q.OP_16||e.opcodenum===Q.OP_PUSHDATA1||e.opcodenum===Q.OP_PUSHDATA2||e.opcodenum===Q.OP_PUSHDATA4})};q.types={};q.types.UNKNOWN="Unknown";q.types.PUBKEY_OUT="Pay to public key";q.types.PUBKEY_IN="Spend from public key";q.types.PUBKEYHASH_OUT="Pay to public key hash";q.types.PUBKEYHASH_IN="Spend from public key hash";q.types.SCRIPTHASH_OUT="Pay to script hash";q.types.SCRIPTHASH_IN="Spend from script hash";q.types.MULTISIG_OUT="Pay to multisig";q.types.MULTISIG_IN="Spend from multisig";q.types.DATA_OUT="Data push";q.types.SAFE_DATA_OUT="Safe data push";q.OP_RETURN_STANDARD_SIZE=220;q.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!==q.types.UNKNOWN?e:this.classifyInput()};q.outputIdentifiers={};q.outputIdentifiers.PUBKEY_OUT=q.prototype.isPublicKeyOut;q.outputIdentifiers.PUBKEYHASH_OUT=q.prototype.isPublicKeyHashOut;q.outputIdentifiers.MULTISIG_OUT=q.prototype.isMultisigOut;q.outputIdentifiers.SCRIPTHASH_OUT=q.prototype.isScriptHashOut;q.outputIdentifiers.DATA_OUT=q.prototype.isDataOut;q.outputIdentifiers.SAFE_DATA_OUT=q.prototype.isSafeDataOut;q.prototype.classifyOutput=function(){for(var e in q.outputIdentifiers)if(q.outputIdentifiers[e].bind(this)())return q.types[e];return q.types.UNKNOWN};q.inputIdentifiers={};q.inputIdentifiers.PUBKEY_IN=q.prototype.isPublicKeyIn;q.inputIdentifiers.PUBKEYHASH_IN=q.prototype.isPublicKeyHashIn;q.inputIdentifiers.MULTISIG_IN=q.prototype.isMultisigIn;q.inputIdentifiers.SCRIPTHASH_IN=q.prototype.isScriptHashIn;q.prototype.classifyInput=function(){for(var e in q.inputIdentifiers)if(q.inputIdentifiers[e].bind(this)())return q.types[e];return q.types.UNKNOWN};q.prototype.isStandard=function(){return this.classify()!==q.types.UNKNOWN};q.prototype.prepend=function(e){return this._addByType(e,!0),this};q.prototype.equals=function(e){if(Xe.checkState(e instanceof q,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t<this.chunks.length;t++){if(d.Buffer.isBuffer(this.chunks[t].buf)&&!d.Buffer.isBuffer(e.chunks[t].buf)||d.Buffer.isBuffer(this.chunks[t].buf)&&!this.chunks[t].buf.equals(e.chunks[t].buf))return!1;if(this.chunks[t].opcodenum!==e.chunks[t].opcodenum)return!1}return!0};q.prototype.add=function(e){return this._addByType(e,!1),this};q.prototype._addByType=function(e,t){if(typeof e=="string")this._addOpcode(e,t);else if(typeof e=="number")this._addOpcode(e,t);else if(e instanceof Q)this._addOpcode(e,t);else if(d.Buffer.isBuffer(e))this._addBuffer(e,t);else if(e instanceof q)this.chunks=this.chunks.concat(e.chunks);else if(typeof e=="object")this._insertAtPosition(e,t);else throw new Error("Invalid script chunk")};q.prototype._insertAtPosition=function(e,t){t?this.chunks.unshift(e):this.chunks.push(e)};q.prototype._addOpcode=function(e,t){var r;return typeof e=="number"?r=e:e instanceof Q?r=e.toNumber():r=Q(e).toNumber(),this._insertAtPosition({opcodenum:r},t),this};q.prototype._addBuffer=function(e,t){var r,n=e.length;if(n>=0&&n<Q.OP_PUSHDATA1)r=n;else if(n<Math.pow(2,8))r=Q.OP_PUSHDATA1;else if(n<Math.pow(2,16))r=Q.OP_PUSHDATA2;else if(n<Math.pow(2,32))r=Q.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this._insertAtPosition({buf:e,len:n,opcodenum:r},t),this};q.prototype.removeCodeseparators=function(){for(var e=[],t=0;t<this.chunks.length;t++)this.chunks[t].opcodenum!==Q.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this};q.buildMultisigOut=function(e,t,r){Xe.checkArgument(t<=e.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var n=new q;n.add(Q.smallInt(t)),e=Te.map(e,to);var i=e;r.noSorting||(i=e.map(a=>a.toString("hex")).sort().map(a=>new to(a)));for(var o=0;o<i.length;o++){var s=i[o];n.add(s.toBuffer())}return n.add(Q.smallInt(e.length)),n.add(Q.OP_CHECKMULTISIG),n};q.buildMultisigIn=function(e,t,r,n){Xe.checkArgument(Te.isArray(e)),Xe.checkArgument(Te.isNumber(t)),Xe.checkArgument(Te.isArray(r)),n=n||{};var i=new q;return i.add(Q.OP_0),Te.each(r,function(o){Xe.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i};q.buildP2SHMultisigIn=function(e,t,r,n){Xe.checkArgument(Te.isArray(e)),Xe.checkArgument(Te.isNumber(t)),Xe.checkArgument(Te.isArray(r)),n=n||{};var i=new q;return i.add(Q.OP_0),Te.each(r,function(o){Xe.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i.add((n.cachedMultisig||q.buildMultisigOut(e,t,n)).toBuffer()),i};q.buildPublicKeyHashOut=function(e){Xe.checkArgument(!Te.isUndefined(e)),Xe.checkArgument(e instanceof to||e instanceof Ur||Te.isString(e)),e instanceof to?e=e.toAddress():Te.isString(e)&&(e=new Ur(e));var t=new q;return t.add(Q.OP_DUP).add(Q.OP_HASH160).add(e.hashBuffer).add(Q.OP_EQUALVERIFY).add(Q.OP_CHECKSIG),t._network=e.network,t};q.buildPublicKeyOut=function(e){Xe.checkArgument(e instanceof to);var t=new q;return t.add(e.toBuffer()).add(Q.OP_CHECKSIG),t};q.buildDataOut=function(e,t){Xe.checkArgument(Te.isUndefined(e)||Te.isString(e)||Te.isArray(e)||d.Buffer.isBuffer(e));var r=e;Te.isArray(r)||(r=[e]);var n=new q;n.add(Q.OP_RETURN);for(let i of r)Xe.checkArgument(Te.isUndefined(i)||Te.isString(i)||d.Buffer.isBuffer(i)),Te.isString(i)&&(i=d.Buffer.from(i,t)),Te.isUndefined(i)||n.add(i);return n};q.buildSafeDataOut=function(e,t){var r=q.buildDataOut(e,t),n=new q;return n.add(Q.OP_FALSE),n.add(r),n};q.buildScriptHashOut=function(e){Xe.checkArgument(e instanceof q||e instanceof Ur&&e.isPayToScriptHash());var t=new q;return t.add(Q.OP_HASH160).add(e instanceof Ur?e.hashBuffer:cp.sha256ripemd160(e.toBuffer())).add(Q.OP_EQUAL),t._network=e._network||e.network,t};q.buildPublicKeyIn=function(e,t){Xe.checkArgument(e instanceof eo||d.Buffer.isBuffer(e)),Xe.checkArgument(Te.isUndefined(t)||Te.isNumber(t)),e instanceof eo&&(e=e.toBuffer());var r=new q;return r.add(d.Buffer.concat([e,d.Buffer.from([(t||eo.SIGHASH_ALL)&255])])),r};q.buildPublicKeyHashIn=function(e,t,r){Xe.checkArgument(t instanceof eo||d.Buffer.isBuffer(t)),Xe.checkArgument(Te.isUndefined(r)||Te.isNumber(r)),t instanceof eo&&(t=t.toBuffer());var n=new q().add(d.Buffer.concat([t,d.Buffer.from([(r||eo.SIGHASH_ALL)&255])])).add(new to(e).toBuffer());return n};q.empty=function(){return new q};q.prototype.toScriptHashOut=function(){return q.buildScriptHashOut(this)};q.fromAddress=function(e){if(e=Ur(e),e.isPayToScriptHash())return q.buildScriptHashOut(e);if(e.isPayToPublicKeyHash())return q.buildPublicKeyHashOut(e);throw new lp.Script.UnrecognizedAddress(e)};q.prototype.getAddressInfo=function(e){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var t=this._getOutputAddressInfo();return t||this._getInputAddressInfo()};q.prototype._getOutputAddressInfo=function(){var e={};if(this.isScriptHashOut())e.hashBuffer=this.getData(),e.type=Ur.PayToScriptHash;else if(this.isPublicKeyHashOut())e.hashBuffer=this.getData(),e.type=Ur.PayToPublicKeyHash;else return!1;return e};q.prototype._getInputAddressInfo=function(){var e={};if(this.isPublicKeyHashIn())e.hashBuffer=cp.sha256ripemd160(this.chunks[1].buf),e.type=Ur.PayToPublicKeyHash;else if(this.isScriptHashIn())e.hashBuffer=cp.sha256ripemd160(this.chunks[this.chunks.length-1].buf),e.type=Ur.PayToScriptHash;else return!1;return e};q.prototype.toAddress=function(e){var t=this.getAddressInfo();return t?(t.network=_1.get(e)||this._network||_1.defaultNetwork,new Ur(t)):!1};q.prototype.findAndDelete=function(e){for(var t=e.toBuffer(),r=t.toString("hex"),n=0;n<this.chunks.length;n++){var i=q({chunks:[this.chunks[n]]}),o=i.toBuffer(),s=o.toString("hex");r===s&&this.chunks.splice(n,1)}return this};q.prototype.checkMinimalPush=function(e){var t=this.chunks[e],r=t.buf,n=t.opcodenum;return r?r.length===0?n===Q.OP_0:r.length===1&&r[0]>=1&&r[0]<=16?n===Q.OP_1+(r[0]-1):r.length===1&&r[0]===129?n===Q.OP_1NEGATE:r.length<=75?n===r.length:r.length<=255?n===Q.OP_PUSHDATA1:r.length<=65535?n===Q.OP_PUSHDATA2:!0:!0};q.prototype._decodeOP_N=function(e){if(e===Q.OP_0)return 0;if(e>=Q.OP_1&&e<=Q.OP_16)return e-(Q.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))};q.prototype.getSignatureOperationsCount=function(e){e=Te.isUndefined(e)?!0:e;var t=this,r=0,n=Q.OP_INVALIDOPCODE;return Te.each(t.chunks,function(o){var s=o.opcodenum;s===Q.OP_CHECKSIG||s===Q.OP_CHECKSIGVERIFY?r++:(s===Q.OP_CHECKMULTISIG||s===Q.OP_CHECKMULTISIGVERIFY)&&(e&&n>=Q.OP_1&&n<=Q.OP_16?r+=t._decodeOP_N(n):r+=20),n=s}),r};S1.exports=q});var Na=P((v5,I1)=>{"use strict";p();var E1=Ji(),x1=ma(),z6=Sr(),Fr=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t))this.buf=t;else if(typeof t=="number"){var r=t;this.fromNumber(r)}else if(t instanceof z6){var n=t;this.fromBN(n)}else if(t){var i=t;this.set(i)}};Fr.prototype.set=function(e){return this.buf=e.buf||this.buf,this};Fr.prototype.fromString=function(e){return this.set({buf:d.Buffer.from(e,"hex")}),this};Fr.prototype.toString=function(){return this.buf.toString("hex")};Fr.prototype.fromBuffer=function(e){return this.buf=e,this};Fr.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this};Fr.prototype.fromBN=function(e){return this.buf=E1().writeVarintBN(e).concat(),this};Fr.prototype.fromNumber=function(e){return this.buf=E1().writeVarintNum(e).concat(),this};Fr.prototype.toBuffer=function(){return this.buf};Fr.prototype.toBN=function(){return x1(this.buf).readVarintBN()};Fr.prototype.toNumber=function(){return x1(this.buf).readVarintNum()};I1.exports=Fr});var Cn=P((_5,O1)=>{"use strict";p();var Sc=ze(),dp=Sr(),A1=Nt(),Ec=dr(),Y6=Ji(),$6=Na(),pp=qr(),gp=Le(),Z6=Zn(),X6=9007199254740991;function Ht(e){if(!(this instanceof Ht))return new Ht(e);if(Sc.isObject(e))if(this.satoshis=e.satoshis,d.Buffer.isBuffer(e.script))this._scriptBuffer=e.script;else{var t;Sc.isString(e.script)&&Ec.isHexa(e.script)?t=A1.Buffer.from(e.script,"hex"):t=e.script,this.setScript(t)}else throw new TypeError("Unrecognized argument for Output")}Object.defineProperty(Ht.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}});Object.defineProperty(Ht.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof dp?(this._satoshisBN=e,this._satoshis=e.toNumber()):Sc.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=dp.fromNumber(this._satoshis)):(gp.checkArgument(Ec.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=dp.fromNumber(e),this._satoshis=e),gp.checkState(Ec.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Ht.prototype.invalidSatoshis=function(){return this._satoshis>X6?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0?"transaction txout negative":!1};Object.defineProperty(Ht.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),gp.checkState(Ec.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Ht.prototype.toObject=Ht.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t};Ht.fromObject=function(e){return new Ht(e)};Ht.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=pp.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(t instanceof Z6.Script.InvalidBuffer)this._script=null;else throw t}};Ht.prototype.setScript=function(e){if(e instanceof pp)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(Sc.isString(e))this._script=pp.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else if(d.Buffer.isBuffer(e))this.setScriptFromBuffer(e);else throw new TypeError("Invalid argument type: script");return this};Ht.prototype.inspect=function(){var e;return this.script?e=this.script.inspect():e=this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+e+">"};Ht.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return r!==0?t.script=e.read(r):t.script=A1.Buffer.from([]),new Ht(t)};Ht.prototype.toBufferWriter=function(e){e||(e=new Y6),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e};Ht.prototype.getSize=function(){var e=this.script.toBuffer().length,t=$6(e).toBuffer().length;return 8+t+e};O1.exports=Ht});var Ma=P((S5,R1)=>{"use strict";p();var pr=Sr(),cn=ai(),J6=nr(),Q6=Ar(),ek=Xs(),gi=Jt(),tk=ze(),yp=Le(),Ke=function e(t){if(!(this instanceof e))return new e(t);t&&this.set(t)};Object.defineProperty(Ke.prototype,"k",{get:function(){return this._k},set:function(e){this._k=e,this._kFresh=!0},enumerable:!0,configurable:!0});Ke.prototype.set=function(e){if(this.hashbuf=e.hashbuf||this.hashbuf,this.endian=e.endian||this.endian,this.privkey=e.privkey||this.privkey,this.pubkey=e.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),e.sig)if(d.Buffer.isBuffer(e.sig)){var t=nr();this.sig=t.fromDER(e.sig)}else this.sig=e.sig;else this.sig=this.sig;return e.k&&(this.k=e.k),this.verified=e.verified||this.verified,this};Ke.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()};Ke.prototype.calci=function(){for(var e=0;e<4;e++){this.sig.i=e;var t;try{t=this.toPublicKey()}catch(r){console.error(r);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")};Ke.fromString=function(e){var t=JSON.parse(e);return new Ke(t)};Ke.prototype.randomK=function(){var e=cn.getN(),t;do t=pr.fromBuffer(ek.getRandomBuffer(32));while(!(t.lt(e)&&t.gt(pr.Zero)));return this.k=t,this};Ke.prototype.deterministicK=function(e){tk.isUndefined(e)&&(e=0);var t=d.Buffer.alloc(32);t.fill(1);var r=d.Buffer.alloc(32);r.fill(0);var n=this.privkey.bn.toBuffer({size:32}),i=this.endian==="little"?d.Buffer.from(this.hashbuf).reverse():this.hashbuf;r=gi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0]),n,i]),r),t=gi.sha256hmac(t,r),r=gi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([1]),n,i]),r),t=gi.sha256hmac(t,r),t=gi.sha256hmac(t,r);for(var o=pr.fromBuffer(t),s=cn.getN(),a=0;a<e||!(o.lt(s)&&o.gt(pr.Zero));a++)r=gi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0])]),r),t=gi.sha256hmac(t,r),t=gi.sha256hmac(t,r),o=pr.fromBuffer(t);return this.k=o,this};Ke.prototype.toPublicKey=function(){var e=this.sig.i;yp.checkArgument(e===0||e===1||e===2||e===3,new Error("i must be equal to 0, 1, 2, or 3"));var t=pr.fromBuffer(this.hashbuf),r=this.sig.r,n=this.sig.s,i=e&1,o=e>>1,s=cn.getN(),a=cn.getG(),f=o?r.add(s):r,l=cn.fromX(i,f),m=l.mul(s);if(!m.isInfinity())throw new Error("nR is not a valid curve point");var g=t.neg().umod(s),v=r.invm(s),E=l.mul(n).add(a.mul(g)).mul(v),T=Q6.fromPoint(E,this.sig.compressed);return T};Ke.prototype.sigError=function(){if(!d.Buffer.isBuffer(this.hashbuf)||this.hashbuf.length!==32)return"hashbuf must be a 32 byte buffer";var e=this.sig.r,t=this.sig.s,r=cn.getN();try{if(e.lte(pr.Zero)||t.lte(pr.Zero)||e.gte(r)||t.gte(r))return"r and s not in range";var n=pr.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),i=t.invm(r),o=i.mul(n).umod(r),s=i.mul(e).umod(r),a=cn.getG().mulAdd(o,this.pubkey.point,s);return a.isInfinity()?"p is infinity":a.getX().umod(r).cmp(e)!==0?"Invalid signature":!1}catch(f){return"Signature security validation failed: "+f.message}};Ke.toLowS=function(e){return e.gt(pr.fromBuffer(d.Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=cn.getN().sub(e)),e};Ke.prototype._findSignature=function(e,t){var r=cn.getN(),n=cn.getG(),i=0,o,s,a,f;do(!this.k||!this._kFresh||i>0)&&this.deterministicK(i),i++,o=this.k,s=n.mul(o),a=s.x.umod(r),f=o.invm(r).mul(t.add(e.mul(a))).umod(r);while(a.cmp(pr.Zero)<=0||f.cmp(pr.Zero)<=0);return this._kFresh=!1,f=Ke.toLowS(f),{s:f,r:a}};Ke.prototype.sign=function(){var e=this.hashbuf,t=this.privkey,r=t.bn;yp.checkState(e&&t&&r,new Error("invalid parameters")),yp.checkState(d.Buffer.isBuffer(e)&&e.length===32,new Error("hashbuf must be a 32 byte buffer"));var n=pr.fromBuffer(e,this.endian?{endian:this.endian}:void 0),i=this._findSignature(r,n);return i.compressed=this.pubkey.compressed,this.sig=new J6(i),this};Ke.prototype.signRandomK=function(){return this.randomK(),this.sign()};Ke.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)};Ke.prototype.verify=function(){return this.verified=!this.sigError(),this.verified};Ke.prototype.verifyBool=function(){return this.verify()===!0};Ke.sign=function(e,t,r){return Ke().set({hashbuf:e,endian:r,privkey:t}).sign().sig};Ke.signWithCalcI=function(e,t,r){return Ke().set({hashbuf:e,endian:r,privkey:t}).sign().calci().sig};Ke.signRandomK=function(e,t,r){return Ke().set({hashbuf:e,endian:r,privkey:t}).signRandomK().sig};Ke.verify=function(e,t,r,n){return Ke().set({hashbuf:e,endian:n,sig:t,pubkey:r}).verify()};R1.exports=Ke});var rs=P((x5,N1)=>{"use strict";p();var yi=ze(),rk=Le(),ka=Zn(),nk=Ji(),mp=Nt(),P1=dr(),xc=qr(),ik=mi(),T1=Cn(),Ic=4294967295,ok=Ic-2,B1=Ic,sk=Ic-1;function Ge(e){if(!(this instanceof Ge))return new Ge(e);if(e)return this._fromObject(e)}Ge.MAXINT=Ic;Ge.DEFAULT_SEQNUMBER=B1;Ge.DEFAULT_LOCKTIME_SEQNUMBER=sk;Ge.DEFAULT_RBF_SEQNUMBER=ok;Ge.BASE_SIZE=40;Object.defineProperty(Ge.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new xc(this._scriptBuffer),this._script._isInput=!0),this._script)}});Ge.fromObject=function(e){rk.checkArgument(yi.isObject(e));var t=new Ge;return t._fromObject(e)};Ge.prototype._fromObject=function(e){var t;if(yi.isString(e.prevTxId)&&P1.isHexa(e.prevTxId)?t=mp.Buffer.from(e.prevTxId,"hex"):t=e.prevTxId,this.output=e.output?e.output instanceof T1?e.output:new T1(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=yi.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=yi.isUndefined(e.sequenceNumber)?yi.isUndefined(e.seqnum)?B1:e.seqnum:e.sequenceNumber,yi.isUndefined(e.script)&&yi.isUndefined(e.scriptBuffer))throw new ka.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this};Ge.prototype.toObject=Ge.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t};Ge.fromBufferReader=function(e){var t=new Ge;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t};Ge.prototype.toBufferWriter=function(e){e||(e=new nk),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e};Ge.prototype.setScript=function(e){if(this._script=null,e instanceof xc)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(e===null)this._script=xc.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(P1.isHexa(e))this._scriptBuffer=mp.Buffer.from(e,"hex");else if(yi.isString(e))this._script=new xc(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(d.Buffer.isBuffer(e))this._scriptBuffer=mp.Buffer.from(e);else throw new TypeError("Invalid argument type: script");return this};Ge.prototype.getSignatures=function(){throw new ka.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))};Ge.prototype.isFullySigned=function(){throw new ka.AbstractMethodInvoked("Input#isFullySigned")};Ge.prototype.isFinal=function(){return this.sequenceNumber===Ge.MAXINT};Ge.prototype.addSignature=function(){throw new ka.AbstractMethodInvoked("Input#addSignature")};Ge.prototype.clearSignatures=function(){throw new ka.AbstractMethodInvoked("Input#clearSignatures")};Ge.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,ik.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Ge.prototype.isNull=function(){return this.prevTxId.toString("hex")==="0000000000000000000000000000000000000000000000000000000000000000"&&this.outputIndex===4294967295};Ge.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length};N1.exports=Ge});var ns=P((A5,M1)=>{"use strict";p();M1.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}});var os=P((R5,L1)=>{"use strict";p();var is=ze(),Or=Le(),ak=ns(),k1=dr(),C1=Ar(),uk=Zn(),Ca=nr();function jr(e){if(!(this instanceof jr))return new jr(e);if(e instanceof jr)return e;if(is.isObject(e))return this._fromObject(e);throw new uk.InvalidArgument("TransactionSignatures must be instantiated from an object")}ak(jr,Ca);jr.prototype._fromObject=function(e){return this._checkObjectArgs(e),this.publicKey=new C1(e.publicKey),this.prevTxId=d.Buffer.isBuffer(e.prevTxId)?e.prevTxId:d.Buffer.from(e.prevTxId,"hex"),this.outputIndex=e.outputIndex,this.inputIndex=e.inputIndex,this.signature=e.signature instanceof Ca?e.signature:d.Buffer.isBuffer(e.signature)?Ca.fromBuffer(e.signature):Ca.fromString(e.signature),this.sigtype=e.sigtype,this};jr.prototype._checkObjectArgs=function(e){Or.checkArgument(C1(e.publicKey),"publicKey"),Or.checkArgument(!is.isUndefined(e.inputIndex),"inputIndex"),Or.checkArgument(!is.isUndefined(e.outputIndex),"outputIndex"),Or.checkState(is.isNumber(e.inputIndex),"inputIndex must be a number"),Or.checkState(is.isNumber(e.outputIndex),"outputIndex must be a number"),Or.checkArgument(e.signature,"signature"),Or.checkArgument(e.prevTxId,"prevTxId"),Or.checkState(e.signature instanceof Ca||d.Buffer.isBuffer(e.signature)||k1.isHexa(e.signature),"signature must be a buffer or hexa value"),Or.checkState(d.Buffer.isBuffer(e.prevTxId)||k1.isHexa(e.prevTxId),"prevTxId must be a buffer or hexa value"),Or.checkArgument(e.sigtype,"sigtype"),Or.checkState(is.isNumber(e.sigtype),"sigtype must be a number")};jr.prototype.toObject=jr.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}};jr.fromObject=function(e){return Or.checkArgument(e),new jr(e)};L1.exports=jr});var j1=P((P5,q1)=>{"use strict";p();var fk=ns(),U1=Le(),vp=rs(),ck=Cn(),lk=mi(),F1=qr(),D1=nr(),hk=os();function Ln(){vp.apply(this,arguments)}fk(Ln,vp);Ln.prototype.getSignatures=function(e,t,r,n){U1.checkState(this.output instanceof ck),n=n||D1.SIGHASH_ALL|D1.SIGHASH_FORKID;var i=t.toPublicKey();return i.toString()===this.output.script.getPublicKey().toString("hex")?[new hk({publicKey:i,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:lk.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Ln.prototype.addSignature=function(e,t){return U1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(F1.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this};Ln.prototype.clearSignatures=function(){return this.setScript(F1.empty()),this};Ln.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()};Ln.SCRIPT_MAX_SIZE=74;Ln.prototype._estimateSize=function(){return vp.BASE_SIZE+Ln.SCRIPT_MAX_SIZE};q1.exports=Ln});var W1=P((N5,V1)=>{"use strict";p();var dk=ns(),K1=Le(),pk=Jt(),bp=rs(),gk=Cn(),yk=mi(),G1=qr(),H1=nr(),mk=os();function Dn(){bp.apply(this,arguments)}dk(Dn,bp);Dn.prototype.getSignatures=function(e,t,r,n,i){K1.checkState(this.output instanceof gk),i=i||pk.sha256ripemd160(t.publicKey.toBuffer()),n=n||H1.SIGHASH_ALL|H1.SIGHASH_FORKID;var o=this.output.script.chunks[2]&&this.output.script.chunks[2].buf;return o&&i.equals(o)?[new mk({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:yk.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Dn.prototype.addSignature=function(e,t){return K1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(G1.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this};Dn.prototype.clearSignatures=function(){return this.setScript(G1.empty()),this};Dn.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()};Dn.SCRIPT_MAX_SIZE=108;Dn.prototype._estimateSize=function(){return bp.BASE_SIZE+Dn.SCRIPT_MAX_SIZE};V1.exports=Dn});var $1=P((k5,Y1)=>{"use strict";p();var Hr=ze(),vk=ns(),Oc=rs(),bk=Cn(),La=Le(),z1=qr(),Ac=nr(),_p=mi(),wp=os(),_k=Ar(),wk=Na();function Ct(e,t,r,n){Oc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new _k(o)),La.checkState(z1.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},Hr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}vk(Ct,Oc);Ct.prototype.toObject=function(){var e=Oc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Hr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Ct.prototype._deserializeSignatures=function(e){return Hr.map(e,function(t){if(t)return new wp(t)})};Ct.prototype._serializeSignatures=function(){return Hr.map(this.signatures,function(e){if(e)return e.toObject()})};Ct.prototype.getSignatures=function(e,t,r,n){La.checkState(this.output instanceof bk),n=n||Ac.SIGHASH_ALL|Ac.SIGHASH_FORKID;var i=this,o=[];return Hr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new wp({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:_p.sign(e,t,n,r,i.output.script,i.output.satoshisBN),sigtype:n}))}),o};Ct.prototype.addSignature=function(e,t){return La.checkState(!this.isFullySigned(),"All needed signatures have already been added"),La.checkArgument(!Hr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),La.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Ct.prototype._updateScript=function(){return this.setScript(z1.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this};Ct.prototype._createSignatures=function(){return Hr.map(Hr.filter(this.signatures,function(e){return!Hr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Ct.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Ct.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Ct.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Ct.prototype.countSignatures=function(){return Hr.reduce(this.signatures,function(e,t){return e+!!t},0)};Ct.prototype.publicKeysWithoutSignature=function(){var e=this;return Hr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Ct.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,_p.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Ct.normalizeSignatures=function(e,t,r,n,i){return i.map(function(o){var s=null;return n=n.filter(function(a){if(s)return!0;var f=new wp({signature:Ac.fromTxFormat(a),publicKey:o,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:Ac.SIGHASH_ALL});f.signature.nhashtype=f.sigtype;var l=_p.verify(e,f.signature,f.publicKey,f.inputIndex,t.output.script);return l?(s=f,!1):!0}),s||null})};Ct.SIGNATURE_SIZE=73;Ct.prototype._estimateSize=function(){var e=1+this.threshold*Ct.SIGNATURE_SIZE;return Oc.BASE_SIZE+wk(e).toBuffer().length+e};Y1.exports=Ct});var ex=P((L5,Q1)=>{"use strict";p();var Kr=ze(),Sk=ns(),Rc=rs(),Ek=Cn(),Da=Le(),Sp=qr(),Z1=nr(),X1=mi(),J1=os(),xk=Ar(),Ik=Na();function Pt(e,t,r,n){Rc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new xk(o)),this.redeemScript=Sp.buildMultisigOut(this.publicKeys,r),Da.checkState(Sp.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},Kr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}Sk(Pt,Rc);Pt.prototype.toObject=function(){var e=Rc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Kr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Pt.prototype._deserializeSignatures=function(e){return Kr.map(e,function(t){if(t)return new J1(t)})};Pt.prototype._serializeSignatures=function(){return Kr.map(this.signatures,function(e){if(e)return e.toObject()})};Pt.prototype.getSignatures=function(e,t,r,n){Da.checkState(this.output instanceof Ek),n=n||Z1.SIGHASH_ALL|Z1.SIGHASH_FORKID;var i=this,o=[];return Kr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new J1({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:X1.sign(e,t,n,r,i.redeemScript,i.output.satoshisBN),sigtype:n}))}),o};Pt.prototype.addSignature=function(e,t){return Da.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Da.checkArgument(!Kr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Da.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Pt.prototype._updateScript=function(){return this.setScript(Sp.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this};Pt.prototype._createSignatures=function(){return Kr.map(Kr.filter(this.signatures,function(e){return!Kr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Pt.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Pt.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Pt.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Pt.prototype.countSignatures=function(){return Kr.reduce(this.signatures,function(e,t){return e+!!t},0)};Pt.prototype.publicKeysWithoutSignature=function(){var e=this;return Kr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Pt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,X1.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)};Pt.SIGNATURE_SIZE=73;Pt.PUBKEY_SIZE=34;Pt.prototype._estimateSize=function(){var e=this.publicKeys.length*Pt.PUBKEY_SIZE,t=this.threshold*Pt.SIGNATURE_SIZE,r=3+e,n=r<=75?1:r<=255?2:3,i=t+1+n+r;return Rc.BASE_SIZE+Ik(i).toBuffer().length+i};Q1.exports=Pt});var Tc=P((U5,ss)=>{p();ss.exports=rs();ss.exports.PublicKey=j1();ss.exports.PublicKeyHash=W1();ss.exports.MultiSig=$1();ss.exports.MultiSigScriptHash=ex()});var mi=P((q5,ox)=>{"use strict";p();var Ak=Nt(),fr=nr(),Ep=qr(),Ok=Cn(),Rk=ma(),Ua=Ji(),tx=Sr(),Pc=Jt(),rx=Ma(),xp=Le(),Ip=Bc(),vi=ze(),nx=d.Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),Tk="ffffffffffffffff",Pk=Ip.SCRIPT_ENABLE_SIGHASH_FORKID,Bk=function(e,t,r,n,i){var o=e.inputs[r];xp.checkArgument(i instanceof tx,"For ForkId=0 signatures, satoshis or complete input must be provided");function s(N){var L=new Ua;vi.each(N.inputs,function(z){L.writeReverse(z.prevTxId),L.writeUInt32LE(z.outputIndex)});var F=L.toBuffer(),V=Pc.sha256sha256(F);return V}function a(N){var L=new Ua;vi.each(N.inputs,function(z){L.writeUInt32LE(z.sequenceNumber)});var F=L.toBuffer(),V=Pc.sha256sha256(F);return V}function f(N,L){var F=new Ua;vi.isUndefined(L)?vi.each(N.outputs,function(W){W.toBufferWriter(F)}):N.outputs[L].toBufferWriter(F);var V=F.toBuffer(),z=Pc.sha256sha256(V);return z}var l=d.Buffer.alloc(32),m=d.Buffer.alloc(32),g=d.Buffer.alloc(32);t&fr.SIGHASH_ANYONECANPAY||(l=s(e)),!(t&fr.SIGHASH_ANYONECANPAY)&&(t&31)!==fr.SIGHASH_SINGLE&&(t&31)!==fr.SIGHASH_NONE&&(m=a(e)),(t&31)!==fr.SIGHASH_SINGLE&&(t&31)!==fr.SIGHASH_NONE?g=f(e):(t&31)===fr.SIGHASH_SINGLE&&r<e.outputs.length&&(g=f(e,r));var v=new Ua;v.writeInt32LE(e.version),v.write(l),v.write(m),v.writeReverse(o.prevTxId),v.writeUInt32LE(o.outputIndex),v.writeVarintNum(n.toBuffer().length),v.write(n.toBuffer()),v.writeUInt64LEBN(i);var E=o.sequenceNumber;v.writeUInt32LE(E),v.write(g),v.writeUInt32LE(e.nLockTime),v.writeUInt32LE(t>>>0);var T=v.toBuffer();return T},ix=function(t,r,n,i,o,s){var a=Op(),f=Tc();vi.isUndefined(s)&&(s=Pk);var l=a.shallowCopy(t);if(i=new Ep(i),s&Ip.SCRIPT_ENABLE_REPLAY_PROTECTION){var m=r>>8,g=16711680|m^57005;r=g<<8|r&255}if(r&fr.SIGHASH_FORKID&&!(r&fr.SIGHASH_CHRONICLE)&&s&Ip.SCRIPT_ENABLE_SIGHASH_FORKID)return Bk(l,r,n,i,o);i.removeCodeseparators();var v;for(v=0;v<l.inputs.length;v++)l.inputs[v]=new f(l.inputs[v]).setScript(Ep.empty());if(l.inputs[n]=new f(l.inputs[n]).setScript(i),(r&31)===fr.SIGHASH_NONE||(r&31)===fr.SIGHASH_SINGLE)for(v=0;v<l.inputs.length;v++)v!==n&&(l.inputs[v].sequenceNumber=0);if((r&31)===fr.SIGHASH_NONE)l.outputs=[];else if((r&31)===fr.SIGHASH_SINGLE){if(n>=l.outputs.length)return nx;for(l.outputs.length=n+1,v=0;v<n;v++)l.outputs[v]=new Ok({satoshis:tx.fromBuffer(Ak.Buffer.from(Tk,"hex")),script:Ep.empty()})}r&fr.SIGHASH_ANYONECANPAY&&(l.inputs=[l.inputs[n]]);var E=new Ua().write(l.toBuffer()).writeInt32LE(r).toBuffer();return E},Ap=function(t,r,n,i,o,s){var a=ix(t,r,n,i,o,s);if(a.compare(nx)===0)return a;var f=Pc.sha256sha256(a);return f=new Rk(f).readReverse(),f};function Nk(e,t,r,n,i,o,s){var a=Ap(e,r,n,i,o,s),f=rx.sign(a,t,"little").set({nhashtype:r});return f}function Mk(e,t,r,n,i,o,s){xp.checkArgument(!vi.isUndefined(e)),xp.checkArgument(!vi.isUndefined(t)&&!vi.isUndefined(t.nhashtype));var a=Ap(e,t.nhashtype,n,i,o,s);return rx.verify(a,t,r,"little")}ox.exports={sighashPreimage:ix,sighash:Ap,sign:Nk,verify:Mk}});var Rp=P((H5,ax)=>{"use strict";p();var Un=ze(),Nc=Le(),sx=dr(),kk=qr(),Ck=ro();function Fn(e){if(!(this instanceof Fn))return new Fn(e);Nc.checkArgument(Un.isObject(e),"Must provide an object from where to extract data");var t=e.address?new Ck(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!sx.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var n=Un.isUndefined(e.vout)?e.outputIndex:e.vout;if(!Un.isNumber(n))throw new Error("Invalid outputIndex, received "+n);Nc.checkArgument(!Un.isUndefined(e.scriptPubKey)||!Un.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var i=new kk(e.scriptPubKey||e.script);Nc.checkArgument(!Un.isUndefined(e.amount)||!Un.isUndefined(e.satoshis),"Must provide an amount for the output");var o=Un.isUndefined(e.amount)?e.satoshis:Math.round(e.amount*1e8);Nc.checkArgument(Un.isNumber(o),"Amount must be a number"),sx.defineImmutable(this,{address:t,txId:r,outputIndex:n,script:i,satoshis:o})}Fn.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"};Fn.prototype.toString=function(){return this.txId+":"+this.outputIndex};Fn.fromObject=function(e){return new Fn(e)};Fn.prototype.toObject=Fn.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}};ax.exports=Fn});var Op=P((G5,gx)=>{"use strict";p();var ye=ze(),Kt=Le(),Lk=Nt(),Dt=Zn(),fx=dr(),cx=ma(),Dk=Ji(),ux=Na(),lx=Jt(),kc=nr(),hx=mi(),Uk=ro(),dx=Rp(),Lt=Tc(),Fk=Lt.PublicKeyHash,qk=Lt.PublicKey,jk=Lt.MultiSigScriptHash,Hk=Lt.MultiSig,Gr=Cn(),ln=qr(),Kk=no(),Mc=Sr(),Gk=Bc(),Vk=Gk.SCRIPT_ENABLE_SIGHASH_FORKID;function Y(e){if(!(this instanceof Y))return new Y(e);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof Y)return Y.shallowCopy(e);if(fx.isHexa(e))this.fromString(e);else if(d.Buffer.isBuffer(e))this.fromBuffer(e);else if(ye.isObject(e))this.fromObject(e);else throw new Dt.InvalidArgument("Must provide an object or string to deserialize a transaction")}else this._newTransaction()}var Wk=1,zk=0,Yk=1e6;Y.DUST_AMOUNT=546;Y.FEE_SECURITY_MARGIN=150;Y.MAX_MONEY=21e6*1e8;Y.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8;Y.NLOCKTIME_MAX_VALUE=4294967295;Y.FEE_PER_KB=500;Y.CHANGE_OUTPUT_MAX_SIZE=62;Y.shallowCopy=function(e){var t=new Y(e.toBuffer());return t};var px={configurable:!1,enumerable:!0,get:function(){return this._hash=new cx(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(Y.prototype,"hash",px);Object.defineProperty(Y.prototype,"id",px);var Tp={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(Y.prototype,"inputAmount",Tp);Tp.get=function(){return this._getOutputAmount()};Object.defineProperty(Y.prototype,"outputAmount",Tp);Y.prototype._getHash=function(){return lx.sha256sha256(this.toBuffer())};Y.prototype.serialize=function(e){return e===!0||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)};Y.prototype.uncheckedSerialize=Y.prototype.toString=function(){return this.toBuffer().toString("hex")};Y.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",t;return this.uncheckedSerialize()};Y.prototype.invalidSatoshis=function(){for(var e=!1,t=0;t<this.outputs.length;t++)this.outputs[t].invalidSatoshis()&&(e=!0);return e};Y.prototype.getSerializationError=function(e){if(e=e||{},this.invalidSatoshis())return new Dt.Transaction.InvalidSatoshis;var t=this._getUnspentValue(),r;return t<0?e.disableMoreOutputThanInput||(r=new Dt.Transaction.InvalidOutputAmountSum):r=this._hasFeeError(e,t),r||this._hasDustOutputs(e)||this._isMissingSignatures(e)};Y.prototype._hasFeeError=function(e,t){if(!ye.isUndefined(this._fee)&&this._fee!==t)return new Dt.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=Math.floor(Y.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new Dt.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new Dt.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}};Y.prototype._missingChange=function(){return!this._changeScript};Y.prototype._hasDustOutputs=function(e){if(!e.disableDustOutputs){var t,r;for(t in this.outputs)if(r=this.outputs[t],r.satoshis<Y.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new Dt.Transaction.DustOutputs}};Y.prototype._isMissingSignatures=function(e){if(!e.disableIsFullySigned&&!this.isFullySigned())return new Dt.Transaction.MissingSignatures};Y.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"};Y.prototype.toBuffer=function(){var e=new Dk;return this.toBufferWriter(e).toBuffer()};Y.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),ye.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),ye.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e};Y.prototype.fromBuffer=function(e){var t=new cx(e);return this.fromBufferReader(t)};Y.prototype.fromBufferReader=function(e){Kt.checkArgument(!e.finished(),"No transaction data received");var t,r,n;for(this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t<r;t++){var i=Lt.fromBufferReader(e);this.inputs.push(i)}for(n=e.readVarintNum(),t=0;t<n;t++)this.outputs.push(Gr.fromBufferReader(e));return this.nLockTime=e.readUInt32LE(),this};Y.prototype.toObject=Y.prototype.toJSON=function(){var t=[];this.inputs.forEach(function(i){t.push(i.toObject())});var r=[];this.outputs.forEach(function(i){r.push(i.toObject())});var n={hash:this.hash,version:this.version,inputs:t,outputs:r,nLockTime:this.nLockTime};return this._changeScript&&(n.changeScript=this._changeScript.toString()),ye.isUndefined(this._changeIndex)||(n.changeIndex=this._changeIndex),ye.isUndefined(this._fee)||(n.fee=this._fee),n};Y.prototype.fromObject=function(t){Kt.checkArgument(ye.isObject(t)||t instanceof Y);var r=this,n;return t instanceof Y?n=t.toObject():n=t,ye.each(n.inputs,function(i){if(!i.output||!i.output.script){r.uncheckedAddInput(new Lt(i));return}var o=new ln(i.output.script),s;if(o.isPublicKeyHashOut())s=new Lt.PublicKeyHash(i);else if(o.isScriptHashOut()&&i.publicKeys&&i.threshold)s=new Lt.MultiSigScriptHash(i,i.publicKeys,i.threshold,i.signatures);else if(o.isPublicKeyOut())s=new Lt.PublicKey(i);else throw new Dt.Transaction.Input.UnsupportedScript(i.output.script);r.addInput(s)}),ye.each(n.outputs,function(i){r.addOutput(new Gr(i))}),n.changeIndex&&(this._changeIndex=n.changeIndex),n.changeScript&&(this._changeScript=new ln(n.changeScript)),n.fee&&(this._fee=n.fee),this.nLockTime=n.nLockTime,this.version=n.version,this._checkConsistency(t),this};Y.prototype._checkConsistency=function(e){ye.isUndefined(this._changeIndex)||(Kt.checkState(this._changeScript,"Change script is expected."),Kt.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),Kt.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),e&&e.hash&&Kt.checkState(e.hash===this.hash,"Hash in object does not match transaction hash.")};Y.prototype.lockUntilDate=function(e){if(Kt.checkArgument(e),ye.isNumber(e)&&e<Y.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Dt.Transaction.LockTimeTooEarly;ye.isDate(e)&&(e=e.getTime()/1e3);for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Lt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Lt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};Y.prototype.lockUntilBlockHeight=function(e){if(Kt.checkArgument(ye.isNumber(e)),e>=Y.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Dt.Transaction.BlockHeightTooHigh;if(e<0)throw new Dt.Transaction.NLockTimeOutOfRange;for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Lt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Lt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};Y.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<Y.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null};Y.prototype.fromString=function(e){this.fromBuffer(Lk.Buffer.from(e,"hex"))};Y.prototype._newTransaction=function(){this.version=Wk,this.nLockTime=zk};Y.prototype.from=function(e,t,r){if(ye.isArray(e)){var n=this;return ye.each(e,function(o){n.from(o,t,r)}),this}var i=ye.some(this.inputs,function(o){return o.prevTxId.toString("hex")===e.txId&&o.outputIndex===e.outputIndex});return i?this:(t&&r?this._fromMultisigUtxo(e,t,r):this._fromNonP2SH(e),this)};Y.prototype._fromNonP2SH=function(e){var t;e=new dx(e),e.script.isPublicKeyHashOutPrefix()?t=Fk:e.script.isPublicKeyOut()?t=qk:t=Lt,this.addInput(new t({output:new Gr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:ln.empty()}))};Y.prototype._fromMultisigUtxo=function(e,t,r){Kt.checkArgument(r<=t.length,"Number of required signatures must be greater than the number of public keys");var n;if(e=new dx(e),e.script.isMultisigOut())n=Hk;else if(e.script.isScriptHashOut())n=jk;else throw new Dt.Transaction.Input.UnsupportedScript(e.script.toString());this.addInput(new n({output:new Gr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:ln.empty()},t,r))};Y.prototype.addInput=function(e,t,r){if(Kt.checkArgumentType(e,Lt,"input"),!e.output&&(ye.isUndefined(t)||ye.isUndefined(r)))throw new Dt.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return!e.output&&t&&!ye.isUndefined(r)&&(t=t instanceof ln?t:new ln(t),Kt.checkArgumentType(r,"number","satoshis"),e.output=new Gr({script:t,satoshis:r})),this.uncheckedAddInput(e)};Y.prototype.uncheckedAddInput=function(e){return Kt.checkArgumentType(e,Lt,"input"),this.inputs.push(e),this._inputAmount=void 0,this._updateChangeOutput(),this};Y.prototype.hasAllUtxoInfo=function(){return ye.every(this.inputs.map(function(e){return!!e.output}))};Y.prototype.fee=function(e){return Kt.checkArgument(ye.isNumber(e),"amount must be a number"),this._fee=e,this._updateChangeOutput(),this};Y.prototype.feePerKb=function(e){return Kt.checkArgument(ye.isNumber(e),"amount must be a number"),this._feePerKb=e,this._updateChangeOutput(),this};Y.prototype.change=function(e){return Kt.checkArgument(e,"address is required"),this._changeScript=ln.fromAddress(e),this._updateChangeOutput(),this};Y.prototype.getChangeOutput=function(){return ye.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]};Y.prototype.to=function(e,t){if(ye.isArray(e)){var r=this;return ye.each(e,function(n){r.to(n.address,n.satoshis)}),this}return Kt.checkArgument(fx.isNaturalNumber(t),"Amount is expected to be a positive integer"),this.addOutput(new Gr({script:ln(new Uk(e)),satoshis:t})),this};Y.prototype.addData=function(e){return this.addOutput(new Gr({script:ln.buildDataOut(e),satoshis:0})),this};Y.prototype.addSafeData=function(e){return this.addOutput(new Gr({script:ln.buildSafeDataOut(e),satoshis:0})),this};Y.prototype.addOutput=function(e){return Kt.checkArgumentType(e,Gr,"output"),this._addOutput(e),this._updateChangeOutput(),this};Y.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this};Y.prototype._addOutput=function(e){this.outputs.push(e),this._outputAmount=void 0};Y.prototype._getOutputAmount=function(){if(ye.isUndefined(this._outputAmount)){var e=this;this._outputAmount=0,ye.each(this.outputs,function(t){e._outputAmount+=t.satoshis})}return this._outputAmount};Y.prototype._getInputAmount=function(){if(ye.isUndefined(this._inputAmount)){var e=this;this._inputAmount=0,ye.each(this.inputs,function(t){if(ye.isUndefined(t.output))throw new Dt.Transaction.Input.MissingPreviousOutput;e._inputAmount+=t.output.satoshis})}return this._inputAmount};Y.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),ye.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new Gr({script:this._changeScript,satoshis:0}));var e=this._getUnspentValue(),t=this.getFee(),r=e-t;this._removeOutput(this._changeIndex),this._changeIndex=void 0,r>=Y.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new Gr({script:this._changeScript,satoshis:r})))}};Y.prototype.getFee=function(){return this.isCoinbase()?0:ye.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee};Y.prototype._estimateFee=function(){var e=this._estimateSize();return Math.ceil(e/1e3*(this._feePerKb||Y.FEE_PER_KB))};Y.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()};Y.prototype._clearSignatures=function(){ye.each(this.inputs,function(e){e.clearSignatures!==Lt.prototype.clearSignatures&&e.clearSignatures()})};Y.prototype._estimateSize=function(){var e=8;return e+=ux(this.inputs.length).toBuffer().length,e+=ux(this.outputs.length).toBuffer().length,ye.each(this.inputs,function(t){e+=t._estimateSize()}),ye.each(this.outputs,function(t){e+=t.getSize()}),e};Y.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=ye.without(this.outputs,t),this._outputAmount=void 0};Y.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()};Y.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.prevTxId.compare(n.prevTxId)||r.outputIndex-n.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.satoshis-n.satoshis||r.script.toBuffer().compare(n.script.toBuffer())}),t}),this};Y.prototype.shuffleOutputs=function(){return this.sortOutputs(ye.shuffle)};Y.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)};Y.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this};Y.prototype._newOutputOrder=function(e){var t=this.outputs.length!==e.length||ye.difference(this.outputs,e).length!==0;if(t)throw new Dt.Transaction.InvalidSorting;if(!ye.isUndefined(this._changeIndex)){var r=this.outputs[this._changeIndex];this._changeIndex=e.indexOf(r)}return this.outputs=e,this};Y.prototype.removeInput=function(e,t){var r;if(!t&&ye.isNumber(e)?r=e:r=ye.findIndex(this.inputs,function(i){return i.prevTxId.toString("hex")===e&&i.outputIndex===t}),r<0||r>=this.inputs.length)throw new Dt.Transaction.InvalidIndex(r,this.inputs.length);var n=this.inputs[r];this.inputs=ye.without(this.inputs,n),this._inputAmount=void 0,this._updateChangeOutput()};Y.prototype.sign=function(e,t){Kt.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return ye.isArray(e)?(ye.each(e,function(n){r.sign(n,t)}),this):(ye.each(this.getSignatures(e,t),function(n){r.applySignature(n)}),this)};Y.prototype.getSignatures=function(e,t){e=new Kk(e),t=t||kc.SIGHASH_ALL|kc.SIGHASH_FORKID;var r=this,n=[],i=lx.sha256ripemd160(e.publicKey.toBuffer());return ye.each(this.inputs,function(s,a){ye.each(s.getSignatures(r,e,a,t,i),function(f){n.push(f)})}),n};Y.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this};Y.prototype.isFullySigned=function(){return ye.each(this.inputs,function(e){if(e.isFullySigned===Lt.prototype.isFullySigned)throw new Dt.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),ye.every(ye.map(this.inputs,function(e){return e.isFullySigned()}))};Y.prototype.isValidSignature=function(e){var t=this;if(this.inputs[e.inputIndex].isValidSignature===Lt.prototype.isValidSignature)throw new Dt.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(t,e)};Y.prototype.verifySignature=function(e,t,r,n,i,o){return hx.verify(this,e,t,r,n,i,o)};Y.prototype.verify=function(){if(this.inputs.length===0)return"transaction txins empty";if(this.outputs.length===0)return"transaction txouts empty";for(var e=new Mc(0),t=0;t<this.outputs.length;t++){var r=this.outputs[t];if(r.invalidSatoshis())return"transaction txout "+t+" satoshis is invalid";if(r._satoshisBN.gt(new Mc(Y.MAX_MONEY,10)))return"transaction txout "+t+" greater than MAX_MONEY";if(e=e.add(r._satoshisBN),e.gt(new Mc(Y.MAX_MONEY)))return"transaction txout "+t+" total output greater than MAX_MONEY"}if(this.toBuffer().length>Yk)return"transaction over the maximum block size";var n={};for(t=0;t<this.inputs.length;t++){var i=this.inputs[t],o=i.prevTxId+":"+i.outputIndex;if(!ye.isUndefined(n[o]))return"transaction input "+t+" duplicate input";n[o]=!0}var s=this.isCoinbase();if(s){var a=this.inputs[0]._scriptBuffer;if(a.length<2||a.length>100)return"coinbase transaction script size invalid"}else for(t=0;t<this.inputs.length;t++)if(this.inputs[t].isNull())return"transaction input "+t+" has null input";return!0};Y.prototype.isCoinbase=function(){return this.inputs.length===1&&this.inputs[0].isNull()};Y.prototype.sighash=function(e,t,r,n,i){t=t||kc.SIGHASH_ALL|kc.SIGHASH_FORKID;var o=this.inputs[e];if(!o)throw new Error("Input index "+e+" does not exist");return!r&&o.output&&(r=o.output.script),!n&&o.output&&(n=new Mc(o.output.satoshis)),i=i||Vk,hx.sighash(this,t,e,r,n,i)};gx.exports=Y});var Pp=P((W5,io)=>{p();io.exports=Op();io.exports.Input=Tc();io.exports.Output=Cn();io.exports.UnspentOutput=Rp();io.exports.Signature=os();io.exports.Sighash=mi()});var Bc=P((Y5,vx)=>{"use strict";p();var Cc=ze(),qa=hp(),M=fp(),he=Sr(),Fa=Jt(),bi=nr(),Bp=Ar();function yx(e){return e.map(function(t){return d.Buffer.isBuffer(t)?d.Buffer.from(t):t})}var B=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};B.prototype.verify=function(e,t,r,n,i,o){var s=Pp();if(Cc.isUndefined(r)&&(r=new s),Cc.isUndefined(n)&&(n=0),Cc.isUndefined(i)&&(i=B.currentConsensusFlags(),o||(i&=~B.SCRIPT_ENABLE_SIGHASH_FORKID)),i&B.SCRIPT_ENABLE_SIGHASH_FORKID&&(i|=B.SCRIPT_VERIFY_STRICTENC,!o))throw new Error("internal error - need satoshisBN to verify FORKID transactions");this.set({script:e,tx:r,nin:n,flags:i,satoshisBN:o});var a;if((i&B.SCRIPT_VERIFY_SIGPUSHONLY)!==0&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;var f=(i&B.SCRIPT_VERIFY_P2SH)!==0&&(i&B.SCRIPT_UTXO_AFTER_GENESIS)===0;f&&(a=this.stack.slice());var l=this.stack;if(this.initialize(),this.set({script:t,stack:l,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(this.stack.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var m=this.stack[this.stack.length-1];if(!B.castToBool(m))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(f&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(a.length===0)throw new Error("internal error - stack copy empty");var g=a[a.length-1],v=qa.fromBuffer(g);if(a.pop(),this.initialize(),this.set({script:v,stack:a,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(a.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!B.castToBool(a[a.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if((i&B.SCRIPT_VERIFY_CLEANSTACK)!==0){if((i&B.SCRIPT_VERIFY_P2SH)===0&&(i&B.SCRIPT_UTXO_AFTER_GENESIS)===0)throw new Error("internal error - CLEANSTACK without P2SH");if(this.stack.length!==1)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0};vx.exports=B;B.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.returned=!1,this.nonTopLevelReturnAfterGenesis=!1,this.vfExec=[],this.vfElse=[],this.errstr="",this.flags=0};B.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=typeof e.nin<"u"?e.nin:this.nin,this.satoshisBN=e.satoshisBN||this.satoshisBN,this.stack=e.stack||this.stack,this.altstack=e.altstack||this.altstack,this.pc=typeof e.pc<"u"?e.pc:this.pc,this.pbegincodehash=typeof e.pbegincodehash<"u"?e.pbegincodehash:this.pbegincodehash,this.nOpCount=typeof e.nOpCount<"u"?e.nOpCount:this.nOpCount,this.returned=typeof e.returned<"u"?e.returned:this.returned,this.nonTopLevelReturnAfterGenesis=typeof e.nonTopLevelReturnAfterGenesis<"u"?e.nonTopLevelReturnAfterGenesis:this.nonTopLevelReturnAfterGenesis,this.vfExec=e.vfExec||this.vfExec,this.vfElse=e.vfElse||this.vfElse,this.errstr=e.errstr||this.errstr,this.flags=typeof e.flags<"u"?e.flags:this.flags};B.true=d.Buffer.from([1]);B.false=d.Buffer.from([]);B.MAX_SCRIPT_ELEMENT_SIZE=520;B.MAXIMUM_ELEMENT_SIZE=4;B.MAX_OPS_PER_SCRIPT=500;B.MAX_SCRIPT_SIZE=1e4;B.UNLIMITED=Number.MAX_SAFE_INTEGER;B.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS=75e4;B.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE=32e6;B.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS=4294967295;B.LOCKTIME_THRESHOLD=5e8;B.LOCKTIME_THRESHOLD_BN=new he(B.LOCKTIME_THRESHOLD);B.useGenesisLimits=function(e){return e=e||2147483647,B.MAX_SCRIPT_ELEMENT_SIZE=e,B.MAX_OPS_PER_SCRIPT=e,B.MAX_SCRIPT_SIZE=e,B};B.getLimits=function(){return{maxScriptElementSize:B.MAX_SCRIPT_ELEMENT_SIZE,maximumElementSize:B.MAXIMUM_ELEMENT_SIZE,maxOpsPerScript:B.MAX_OPS_PER_SCRIPT,maxScriptSize:B.MAX_SCRIPT_SIZE}};B.setLimits=function(e){return e=e||{},e.maxScriptElementSize!=null&&(B.MAX_SCRIPT_ELEMENT_SIZE=e.maxScriptElementSize),e.maximumElementSize!=null&&(B.MAXIMUM_ELEMENT_SIZE=e.maximumElementSize),e.maxOpsPerScript!=null&&(B.MAX_OPS_PER_SCRIPT=e.maxOpsPerScript),e.maxScriptSize!=null&&(B.MAX_SCRIPT_SIZE=e.maxScriptSize),B};B.SCRIPT_VERIFY_NONE=0;B.SCRIPT_VERIFY_P2SH=1;B.SCRIPT_VERIFY_STRICTENC=2;B.SCRIPT_VERIFY_DERSIG=4;B.SCRIPT_VERIFY_LOW_S=8;B.SCRIPT_VERIFY_NULLDUMMY=16;B.SCRIPT_VERIFY_SIGPUSHONLY=32;B.SCRIPT_VERIFY_MINIMALDATA=64;B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128;B.SCRIPT_VERIFY_CLEANSTACK=256;B.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512;B.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024;B.SCRIPT_VERIFY_MINIMALIF=8192;B.SCRIPT_VERIFY_NULLFAIL=16384;B.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768;B.SCRIPT_ENABLE_SIGHASH_FORKID=65536;B.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17;B.SCRIPT_ENABLE_MONOLITH_OPCODES=2048;B.SCRIPT_ENABLE_MAGNETIC_OPCODES=4096;B.SCRIPT_GENESIS=1<<18;B.SCRIPT_UTXO_AFTER_GENESIS=1<<19;B.SCRIPT_ENABLE_CHRONICLE=1<<20;B.SCRIPT_CHRONICLE=B.SCRIPT_ENABLE_CHRONICLE;B.SCRIPT_UTXO_AFTER_CHRONICLE=1<<21;B.CHRONICLE_ACTIVATION_HEIGHT=943816;B.mainnetFlags=function(e){e=e||{};var t=B.SCRIPT_VERIFY_P2SH|B.SCRIPT_VERIFY_STRICTENC|B.SCRIPT_VERIFY_DERSIG|B.SCRIPT_VERIFY_LOW_S|B.SCRIPT_VERIFY_NULLFAIL|B.SCRIPT_VERIFY_MINIMALDATA|B.SCRIPT_ENABLE_SIGHASH_FORKID|B.SCRIPT_ENABLE_MAGNETIC_OPCODES|B.SCRIPT_ENABLE_MONOLITH_OPCODES|B.SCRIPT_GENESIS|B.SCRIPT_UTXO_AFTER_GENESIS;return e.afterChronicle!==!1&&(t|=B.SCRIPT_ENABLE_CHRONICLE|B.SCRIPT_UTXO_AFTER_CHRONICLE),t};B.currentConsensusFlags=function(){return B.SCRIPT_ENABLE_MONOLITH_OPCODES|B.SCRIPT_ENABLE_MAGNETIC_OPCODES|B.SCRIPT_GENESIS|B.SCRIPT_UTXO_AFTER_GENESIS|B.SCRIPT_ENABLE_CHRONICLE|B.SCRIPT_UTXO_AFTER_CHRONICLE|B.SCRIPT_ENABLE_SIGHASH_FORKID};B.useMainnetConsensus=function(e){return e=e||{},B.useGenesisLimits(e.max),B.mainnetFlags(e)};B.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31;B.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22;B.SEQUENCE_LOCKTIME_MASK=65535;B.castToBool=function(e){for(var t=0;t<e.length;t++)if(e[t]!==0)return!(t===e.length-1&&e[t]===128);return!1};B.prototype.checkSignatureEncoding=function(e){var t;if(e.length===0)return!0;if((this.flags&(B.SCRIPT_VERIFY_DERSIG|B.SCRIPT_VERIFY_LOW_S|B.SCRIPT_VERIFY_STRICTENC))!==0&&!bi.isTxDER(e))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if((this.flags&B.SCRIPT_VERIFY_LOW_S)!==0){if(t=bi.fromTxFormat(e),!t.hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if((this.flags&B.SCRIPT_VERIFY_STRICTENC)!==0){if(t=bi.fromTxFormat(e),!t.hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&B.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nhashtype&bi.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(!(this.flags&B.SCRIPT_CHRONICLE)&&t.nhashtype&bi.SIGHASH_CHRONICLE)return this.errstr="SCRIPT_ERR_ILLEGAL_CHRONICLE",!1;if(this.flags&B.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nhashtype&bi.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0};B.prototype.checkPubkeyEncoding=function(e){return(this.flags&B.SCRIPT_VERIFY_STRICTENC)!==0&&!Bp.isValid(e)?(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1):!0};B.prototype.isAfterGenesis=function(){return(this.flags&B.SCRIPT_UTXO_AFTER_GENESIS)!==0};B.prototype.isAfterChronicle=function(){return(this.flags&(B.SCRIPT_UTXO_AFTER_CHRONICLE|B.SCRIPT_ENABLE_CHRONICLE))!==0};B.prototype.maxScriptElementSize=function(){return this.isAfterGenesis()?B.UNLIMITED:B.MAX_SCRIPT_ELEMENT_SIZE};B.prototype.maxScriptSize=function(){return this.isAfterGenesis()?B.UNLIMITED:B.MAX_SCRIPT_SIZE};B.prototype.maxOpsPerScript=function(){return this.isAfterGenesis()?B.UNLIMITED:B.MAX_OPS_PER_SCRIPT};B.prototype.maxScriptNumLength=function(){return this.isAfterChronicle()?B.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE:this.isAfterGenesis()?B.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS:B.MAXIMUM_ELEMENT_SIZE};B.prototype.maxPubKeysPerMultisig=function(){return this.isAfterGenesis()?B.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS:20};B._isMinimallyEncoded=function(e,t){return t=t||B.MAXIMUM_ELEMENT_SIZE,!(e.length>t||e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))};B._minimallyEncode=function(e){if(e.length===0)return e;var t=e[e.length-1];if(t&127)return e;if(e.length===1)return d.Buffer.from("");if(e[e.length-2]&128)return e;for(var r=e.length-1;r>0;r--)if(e[r-1]!==0)return e[r-1]&128?e[r++]=t:e[r-1]|=t,e.slice(0,r);return d.Buffer.from("")};B.prototype.evaluate=function(){if(this.script.toBuffer().length>this.maxScriptSize())return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let t={pc:this.pc,opcode:M.fromNumber(this.script.chunks[this.pc].opcodenum)};var e=this.step();if(!e)return!1;if(this._callbackStep(t),this.returned)return!0}if(this.stack.length+this.altstack.length>1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(t){return this.errstr=t.scriptErr||"SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return this.vfExec.length>0?(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1):!0};B.prototype._callbackStep=function(e){if(typeof this.stepListener=="function")try{this.stepListener(e,yx(this.stack),yx(this.altstack))}catch(t){console.log(`Error in Step callback:${t}`)}};B.prototype.checkLockTime=function(e){if(!(this.tx.nLockTime<B.LOCKTIME_THRESHOLD&&e.lt(B.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=B.LOCKTIME_THRESHOLD&&e.gte(B.LOCKTIME_THRESHOLD_BN))||e.gt(new he(this.tx.nLockTime)))return!1;var t=this.tx.inputs[this.nin];return!(!t||t.isFinal())};B.prototype.checkSequence=function(e){var t=this.tx.inputs[this.nin];if(!t)return!1;var r=t.sequenceNumber;if(this.tx.version<2||r&B.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var n=B.SEQUENCE_LOCKTIME_TYPE_FLAG|B.SEQUENCE_LOCKTIME_MASK,i=new he(r&n),o=e.and(new he(n)),s=new he(B.SEQUENCE_LOCKTIME_TYPE_FLAG);return!(!(i.lt(s)&&o.lt(s)||i.gte(s)&&o.gte(s))||o.gt(i))};function $k(e,t){let r=e;for(;r.length<t;)r=d.Buffer.concat([d.Buffer.from([0]),r]);return r}function mx(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e|0,0),t}B.prototype.step=function(){var e=this;function t(fe){return e.stack[e.stack.length+fe]}function r(fe){switch(fe){case M.OP_2MUL:case M.OP_2DIV:if(!e.isAfterChronicle())return!0;break;case M.OP_INVERT:case M.OP_MUL:case M.OP_LSHIFT:case M.OP_RSHIFT:if((e.flags&B.SCRIPT_ENABLE_MAGNETIC_OPCODES)===0)return!0;break;case M.OP_DIV:case M.OP_MOD:case M.OP_SPLIT:case M.OP_CAT:case M.OP_AND:case M.OP_OR:case M.OP_XOR:case M.OP_BIN2NUM:case M.OP_NUM2BIN:return!1;default:break}return!1}var n=(this.flags&B.SCRIPT_VERIFY_MINIMALDATA)!==0,i,o,s,a,f,l,m,g,v,E,T,N,L,F,V,z,W,ie=this.script.chunks[this.pc];this.pc++;var ee=ie.opcodenum,ge=this.vfExec.indexOf(!1)===-1&&(!this.nonTopLevelReturnAfterGenesis||ee===M.OP_RETURN);if(Cc.isUndefined(ee))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(ie.buf&&ie.buf.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(ee>M.OP_16&&++this.nOpCount>this.maxOpsPerScript())return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(r(ee)&&(!this.isAfterGenesis()||ge))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(ge&&ee>=0&&ee<=M.OP_PUSHDATA4){if(n&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(!ie.buf)this.stack.push(B.false);else{if(ie.len!==ie.buf.length)return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;this.stack.push(ie.buf)}}else if(ge||M.OP_IF<=ee&&ee<=M.OP_ENDIF)switch(ee){case M.OP_1NEGATE:case M.OP_1:case M.OP_2:case M.OP_3:case M.OP_4:case M.OP_5:case M.OP_6:case M.OP_7:case M.OP_8:case M.OP_9:case M.OP_10:case M.OP_11:case M.OP_12:case M.OP_13:case M.OP_14:case M.OP_15:case M.OP_16:f=ee-(M.OP_1-1),i=new he(f).toScriptNumBuffer(),this.stack.push(i);break;case M.OP_NOP:break;case M.OP_NOP2:case M.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&B.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)||this.isAfterGenesis()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var ce=he.fromScriptNumBuffer(this.stack[this.stack.length-1],n,5);if(ce.lt(new he(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(ce))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case M.OP_NOP3:case M.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&B.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)||this.isAfterGenesis()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var me=he.fromScriptNumBuffer(t(-1),n,5);if(me.lt(new he(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if((me&B.SEQUENCE_LOCKTIME_DISABLE_FLAG)!==0)break;if(!this.checkSequence(me))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case M.OP_NOP1:case M.OP_NOP9:case M.OP_NOP10:if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case M.OP_LSHIFTNUM:case M.OP_RSHIFTNUM:if(!this.isAfterChronicle()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var x=this.maxScriptNumLength(),u=he.fromScriptNumBuffer(t(-1),n,x);if(u.isNeg())return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop();var h=he.fromScriptNumBuffer(t(-1),n,x);this.stack.pop();var y=u.toNumber(),w=h.isNeg(),S=h.abs(),R;if(ee===M.OP_LSHIFTNUM){var A=h.toScriptNumBuffer().length;if(A+Math.floor(y/8)>x)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;R=S.shln(y)}else R=y>=S.bitLength()?new he(0):S.shrn(y);if(w&&!R.isZero()&&(R=R.neg()),R.toScriptNumBuffer().length>x)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;this.stack.push(R.toScriptNumBuffer());break;case M.OP_VER:if(!this.isAfterChronicle())return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;this.stack.push(mx(this.tx.version));break;case M.OP_VERIF:case M.OP_VERNOTIF:if(!this.isAfterChronicle()){if(this.isAfterGenesis()&&!ge)break;return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}if(z=!1,ge){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;i=t(-1),z=i.length===4&&i.equals(mx(this.tx.version)),ee===M.OP_VERNOTIF&&(z=!z),this.stack.pop()}this.vfExec.push(z),this.vfElse.push(!1);break;case M.OP_IF:case M.OP_NOTIF:if(z=!1,ge){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(i=t(-1),this.flags&B.SCRIPT_VERIFY_MINIMALIF){if(i.length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(i.length===1&&i[0]!==1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1}z=B.castToBool(i),ee===M.OP_NOTIF&&(z=!z),this.stack.pop()}this.vfExec.push(z),this.vfElse.push(!1);break;case M.OP_ELSE:if(this.vfExec.length===0||this.vfElse[this.vfElse.length-1]&&this.isAfterGenesis())return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1],this.vfElse[this.vfElse.length-1]=!0;break;case M.OP_ENDIF:if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop(),this.vfElse.pop();break;case M.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),z=B.castToBool(i),z)this.stack.pop();else return this.errstr="SCRIPT_ERR_VERIFY",!1;break;case M.OP_RETURN:if(this.isAfterGenesis()){if(this.vfExec.length===0){this.returned=!0;break}this.nonTopLevelReturnAfterGenesis=!0;break}return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case M.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case M.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case M.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case M.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case M.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3),s=t(-2);var _=t(-1);this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(_));break;case M.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-4),s=t(-3),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case M.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-6,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case M.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-4,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case M.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1),z=B.castToBool(i),z&&this.stack.push(d.Buffer.from(i));break;case M.OP_DEPTH:i=new he(this.stack.length).toScriptNumBuffer(),this.stack.push(i);break;case M.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case M.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-1)));break;case M.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case M.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-2)));break;case M.OP_PICK:case M.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),g=he.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),f=g.toNumber(),this.stack.pop(),f<0||f>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-f-1),ee===M.OP_ROLL&&this.stack.splice(this.stack.length-f-1,1),this.stack.push(d.Buffer.from(i));break;case M.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-3),m=t(-2);var c=t(-1);this.stack[this.stack.length-3]=m,this.stack[this.stack.length-2]=c,this.stack[this.stack.length-1]=l;break;case M.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-2),m=t(-1),this.stack[this.stack.length-2]=m,this.stack[this.stack.length-1]=l;break;case M.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,d.Buffer.from(t(-1)));break;case M.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;g=new he(t(-1).length),this.stack.push(g.toScriptNumBuffer());break;case M.OP_AND:case M.OP_OR:case M.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),s=t(-1),o.length!==s.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(ee){case M.OP_AND:for(let fe=0;fe<o.length;fe++)o[fe]&=s[fe];break;case M.OP_OR:for(let fe=0;fe<o.length;fe++)o[fe]|=s[fe];break;case M.OP_XOR:for(let fe=0;fe<o.length;fe++)o[fe]^=s[fe];break;default:break}this.stack.pop();break;case M.OP_INVERT:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1);for(let fe=0;fe<i.length;fe++)i[fe]=~i[fe];break;case M.OP_LSHIFT:case M.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),o.length===0)this.stack.pop();else{if(v=new he(o),E=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),f=E.toNumber(),f<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop();let fe;ee===M.OP_LSHIFT&&(fe=v.ushln(f)),ee===M.OP_RSHIFT&&(fe=v.ushrn(f));let de=$k(d.Buffer.from(fe.toArray().slice(o.length*-1)),o.length);this.stack.push(de)}break;case M.OP_EQUAL:case M.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1);var b=o.toString("hex")===s.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(b?B.true:B.false),ee===M.OP_EQUALVERIFY)if(b)this.stack.pop();else return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;break;case M.OP_2MUL:case M.OP_2DIV:case M.OP_1ADD:case M.OP_1SUB:case M.OP_NEGATE:case M.OP_ABS:case M.OP_NOT:case M.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(i=t(-1),g=he.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),ee){case M.OP_2MUL:g=g.mul(new he(2));break;case M.OP_2DIV:g=g.div(new he(2));break;case M.OP_1ADD:g=g.add(he.One);break;case M.OP_1SUB:g=g.sub(he.One);break;case M.OP_NEGATE:g=g.neg();break;case M.OP_ABS:g.cmp(he.Zero)<0&&(g=g.neg());break;case M.OP_NOT:g=new he((g.cmp(he.Zero)===0)+0);break;case M.OP_0NOTEQUAL:g=new he((g.cmp(he.Zero)!==0)+0);break}this.stack.pop(),this.stack.push(g.toScriptNumBuffer());break;case M.OP_ADD:case M.OP_SUB:case M.OP_MUL:case M.OP_MOD:case M.OP_DIV:case M.OP_BOOLAND:case M.OP_BOOLOR:case M.OP_NUMEQUAL:case M.OP_NUMEQUALVERIFY:case M.OP_NUMNOTEQUAL:case M.OP_LESSTHAN:case M.OP_GREATERTHAN:case M.OP_LESSTHANOREQUAL:case M.OP_GREATERTHANOREQUAL:case M.OP_MIN:case M.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(v=he.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()),E=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),g=new he(0),ee){case M.OP_ADD:g=v.add(E);break;case M.OP_SUB:g=v.sub(E);break;case M.OP_MUL:g=v.mul(E);break;case M.OP_DIV:if(E.cmp(he.Zero)===0)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;g=v.div(E);break;case M.OP_MOD:if(E.cmp(he.Zero)===0)return this.errstr="SCRIPT_ERR_MOD_BY_ZERO",!1;g=v.mod(E);break;case M.OP_BOOLAND:g=new he((v.cmp(he.Zero)!==0&&E.cmp(he.Zero)!==0)+0);break;case M.OP_BOOLOR:g=new he((v.cmp(he.Zero)!==0||E.cmp(he.Zero)!==0)+0);break;case M.OP_NUMEQUAL:g=new he((v.cmp(E)===0)+0);break;case M.OP_NUMEQUALVERIFY:g=new he((v.cmp(E)===0)+0);break;case M.OP_NUMNOTEQUAL:g=new he((v.cmp(E)!==0)+0);break;case M.OP_LESSTHAN:g=new he((v.cmp(E)<0)+0);break;case M.OP_GREATERTHAN:g=new he((v.cmp(E)>0)+0);break;case M.OP_LESSTHANOREQUAL:g=new he((v.cmp(E)<=0)+0);break;case M.OP_GREATERTHANOREQUAL:g=new he((v.cmp(E)>=0)+0);break;case M.OP_MIN:g=v.cmp(E)<0?v:E;break;case M.OP_MAX:g=v.cmp(E)>0?v:E;break}if(this.stack.pop(),this.stack.pop(),this.stack.push(g.toScriptNumBuffer()),ee===M.OP_NUMEQUALVERIFY)if(B.castToBool(t(-1)))this.stack.pop();else return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;break;case M.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;v=he.fromScriptNumBuffer(t(-3),n,this.maxScriptNumLength()),E=he.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength());var k=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength());z=E.cmp(v)<=0&&v.cmp(k)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(z?B.true:B.false);break;case M.OP_RIPEMD160:case M.OP_SHA1:case M.OP_SHA256:case M.OP_HASH160:case M.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1);var D;ee===M.OP_RIPEMD160?D=Fa.ripemd160(i):ee===M.OP_SHA1?D=Fa.sha1(i):ee===M.OP_SHA256?D=Fa.sha256(i):ee===M.OP_HASH160?D=Fa.sha256ripemd160(i):ee===M.OP_HASH256&&(D=Fa.sha256sha256(i)),this.stack.pop(),this.stack.push(D);break;case M.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case M.OP_CHECKSIG:case M.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(T=t(-2),N=t(-1),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(N))return!1;L=new qa().set({chunks:this.script.chunks.slice(this.pbegincodehash)});var K=new qa().add(T);L.findAndDelete(K);try{F=bi.fromTxFormat(T),V=Bp.fromBuffer(N,!1),W=this.tx.verifySignature(F,V,this.nin,L,this.satoshisBN,this.flags)}catch{W=!1}if(!W&&this.flags&B.SCRIPT_VERIFY_NULLFAIL&&T.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(W?B.true:B.false),ee===M.OP_CHECKSIGVERIFY)if(W)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;break;case M.OP_CHECKMULTISIG:case M.OP_CHECKMULTISIGVERIFY:var G=1;if(this.stack.length<G)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var X=he.fromScriptNumBuffer(t(-G),n,this.maxScriptNumLength()).toNumber();if(X<0||X>this.maxPubKeysPerMultisig())return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=X,this.nOpCount>B.MAX_OPS_PER_SCRIPT)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var Z=++G;G+=X;var le=X+2;if(this.stack.length<G)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var se=he.fromScriptNumBuffer(t(-G),n,this.maxScriptNumLength()).toNumber();if(se<0||se>X)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var O=++G;if(G+=se,this.stack.length<G)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;L=new qa().set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var C=0;C<se;C++)T=t(-O-C),L.findAndDelete(new qa().add(T));for(W=!0;W&&se>0;){if(T=t(-O),N=t(-Z),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(N))return!1;var U;try{F=bi.fromTxFormat(T),V=Bp.fromBuffer(N,!1),U=this.tx.verifySignature(F,V,this.nin,L,this.satoshisBN,this.flags)}catch{U=!1}U&&(O++,se--),Z++,X--,se>X&&(W=!1)}for(;G-- >1;){if(!W&&this.flags&B.SCRIPT_VERIFY_NULLFAIL&&!le&&t(-1).length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;le>0&&le--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&B.SCRIPT_VERIFY_NULLDUMMY&&t(-1).length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(W?B.true:B.false),ee===M.OP_CHECKMULTISIGVERIFY)if(W)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;break;case M.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),s=t(-1),o.length+s.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=d.Buffer.concat([o,s]),this.stack.pop();break;case M.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2);var j=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(j<0||j>o.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var re=d.Buffer.from(o);this.stack[this.stack.length-2]=re.slice(0,j),this.stack[this.stack.length-1]=re.slice(j);break;case M.OP_LEFT:case M.OP_RIGHT:if(!this.isAfterChronicle()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),f=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),f<0||f>o.length)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),ee===M.OP_LEFT?this.stack[this.stack.length-1]=d.Buffer.from(o).slice(0,f):this.stack[this.stack.length-1]=d.Buffer.from(o).slice(o.length-f);break;case M.OP_SUBSTR:if(!this.isAfterChronicle()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3);var J=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),te=he.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()).toNumber();if(te<0||te>=o.length||J<0||J>o.length-te)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop(),this.stack[this.stack.length-1]=d.Buffer.from(o).slice(te,te+J);break;case M.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var ae=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(ae<0||ae>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var oe=t(-1);if(oe=B._minimallyEncode(oe),oe.length>ae)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(oe.length===ae){this.stack[this.stack.length-1]=oe;break}var ue=0;oe.length>0&&(ue=oe[oe.length-1]&128,oe[oe.length-1]&=127);var _e=d.Buffer.alloc(ae);oe.copy(_e,0);for(var Se=oe.length-1;Se++<ae-2;)_e[Se]=0;_e[Se]=ue,this.stack[this.stack.length-1]=_e;break;case M.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-1),s=B._minimallyEncode(o),this.stack[this.stack.length-1]=s,!B._isMinimallyEncoded(s))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}});var qr=P((Z5,Np)=>{p();Np.exports=hp();Np.exports.Interpreter=Bc()});var ro=P((J5,Sx)=>{"use strict";p();var Mp=ze(),qn=Le(),Zk=Zn(),bx=Hd(),Rr=pa(),_x=Jt(),wx=dr(),kp=Ar();function ne(e,t,r){if(!(this instanceof ne))return new ne(e,t,r);if(Mp.isArray(e)&&Mp.isNumber(t))return ne.createMultisig(e,t,r);if(e instanceof ne)return e;if(qn.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!Rr.get(t))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==ne.PayToPublicKeyHash&&r!==ne.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var n=this._classifyArguments(e,t,r);return n.network=n.network||Rr.get(t)||Rr.defaultNetwork,n.type=n.type||r||ne.PayToPublicKeyHash,wx.defineImmutable(this,{hashBuffer:n.hashBuffer,network:n.network,type:n.type}),this}ne.prototype._classifyArguments=function(e,t,r){if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===20)return ne._transformHash(e);if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===21)return ne._transformBuffer(e,t,r);if(e instanceof kp)return ne._transformPublicKey(e);if(e instanceof ja())return ne._transformScript(e,t);if(typeof e=="string")return ne._transformString(e,t,r);if(Mp.isObject(e))return ne._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")};ne.PayToPublicKeyHash="pubkeyhash";ne.PayToScriptHash="scripthash";ne._transformHash=function(e){var t={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==20)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return t.hashBuffer=e,t};ne._transformObject=function(e){return qn.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),qn.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?d.Buffer.from(e.hash,"hex"):e.hashBuffer,network:Rr.get(e.network)||Rr.defaultNetwork,type:e.type}};ne._classifyFromVersion=function(e){var t={},r=Rr.get(e[0],"pubkeyhash"),n=Rr.get(e[0],"scripthash");return r?(t.network=r,t.type=ne.PayToPublicKeyHash):n&&(t.network=n,t.type=ne.PayToScriptHash),t};ne._transformBuffer=function(e,t,r){var n={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==21)throw new TypeError("Address buffers must be exactly 21 bytes.");var i=Rr.get(t),o=ne._classifyFromVersion(e);if(t&&!i)throw new TypeError("Unknown network");if(!o.network||i&&i!==o.network)throw new TypeError("Address has mismatched network type.");if(!o.type||r&&r!==o.type)throw new TypeError("Address has mismatched type.");return n.hashBuffer=e.slice(1),n.network=o.network,n.type=o.type,n};ne._transformPublicKey=function(e){var t={};if(!(e instanceof kp))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=_x.sha256ripemd160(e.toBuffer()),t.type=ne.PayToPublicKeyHash,t};ne._transformScript=function(e,t){qn.checkArgument(e instanceof ja(),"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new Zk.Script.CantDeriveAddress(e);return r};ne.createMultisig=function(e,t,r){return r=r||e[0].network||Rr.defaultNetwork,ne.payingTo(ja().buildMultisigOut(e,t),r)};ne._transformString=function(e,t,r){if(typeof e!="string")throw new TypeError("data parameter supplied is not a string.");if(e.length<27)throw new Error("Invalid Address string provided");e=e.trim();var n=Rr.get(t);if(t&&!n)throw new TypeError("Unknown network");var i=bx.decode(e);return ne._transformBuffer(i,t,r)};ne.fromPublicKey=function(e,t){var r=ne._transformPublicKey(e);return t=t||Rr.defaultNetwork,new ne(r.hashBuffer,t,r.type)};ne.fromPrivateKey=function(e,t){let r=kp.fromPrivateKey(e);return t=t||e.network||Rr.defaultNetwork,ne.fromPublicKey(r,t)};ne.fromPublicKeyHash=function(e,t){var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToPublicKeyHash)};ne.fromScriptHash=function(e,t){qn.checkArgument(e,"hash parameter is required");var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToScriptHash)};ne.payingTo=function(e,t){return qn.checkArgument(e,"script is required"),qn.checkArgument(e instanceof ja(),"script must be instance of Script"),ne.fromScriptHash(_x.sha256ripemd160(e.toBuffer()),t)};ne.fromScript=function(e,t){qn.checkArgument(e instanceof ja(),"script must be a Script instance");var r=ne._transformScript(e,t);return new ne(r.hashBuffer,t,r.type)};ne.fromBuffer=function(e,t,r){var n=ne._transformBuffer(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromHex=function(e,t,r){return ne.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ne.fromString=function(e,t,r){var n=ne._transformString(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromObject=function(t){qn.checkState(wx.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.');var r=d.Buffer.from(t.hash,"hex");return new ne(r,t.network,t.type)};ne.getValidationError=function(e,t,r){var n;try{new ne(e,t,r)}catch(i){n=i}return n};ne.isValid=function(e,t,r){return!ne.getValidationError(e,t,r)};ne.prototype.isPayToPublicKeyHash=function(){return this.type===ne.PayToPublicKeyHash};ne.prototype.isPayToScriptHash=function(){return this.type===ne.PayToScriptHash};ne.prototype.toBuffer=function(){var e=d.Buffer.from([this.network[this.type]]),t=d.Buffer.concat([e,this.hashBuffer]);return t};ne.prototype.toHex=function(){return this.toBuffer().toString("hex")};ne.prototype.toObject=ne.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}};ne.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"};ne.prototype.toString=function(){return bx.encode(this.toBuffer())};Sx.exports=ne;function ja(){return qr()}});var no=P((eq,Ax)=>{"use strict";p();var Lc=ze(),Xk=ro(),Ex=Hd(),_i=Sr(),xx=dr(),hn=pa(),Lp=ai(),Jk=Ar(),Qk=Xs(),Ix=Le(),Cp="[REDACTED]";function ve(e,t){if(!(this instanceof ve))return new ve(e,t);if(e instanceof ve)return e;var r=this._classifyArguments(e,t);if(!r.bn||r.bn.cmp(new _i(0))===0)throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(Lp.getN()))throw new TypeError("Number must be less than N");if(typeof r.network>"u")throw new TypeError('Must specify the network ("livenet" or "testnet")');return xx.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}ve.prototype._classifyArguments=function(e,t){var r={compressed:!0,network:t?hn.get(t):hn.defaultNetwork};if(Lc.isUndefined(e)||Lc.isNull(e))r.bn=ve._getRandomBN();else if(e instanceof _i)r.bn=e;else if(e instanceof d.Buffer||e instanceof Uint8Array)r=ve._transformBuffer(e,t);else if(e.bn&&e.network)r=ve._transformObject(e);else if(!t&&hn.get(e))r.bn=ve._getRandomBN(),r.network=hn.get(e);else if(typeof e=="string")xx.isHexa(e)?r.bn=new _i(d.Buffer.from(e,"hex")):r=ve._transformWIF(e,t);else throw new TypeError("First argument is an unrecognized data type.");return r};ve._getRandomBN=function(){var e,t;do{var r=Qk.getRandomBuffer(32);t=_i.fromBuffer(r),e=t.lt(Lp.getN())}while(!e);return t};ve._transformBuffer=function(e,t){var r={};if(e.length===32)return ve._transformBNBuffer(e,t);if(r.network=hn.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==hn.get(t))throw new TypeError("Private key network mismatch");if(e.length===34&&e[33]===1)r.compressed=!0;else if(e.length===33)r.compressed=!1;else throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");return r.bn=_i.fromBuffer(e.slice(1,33)),r};ve._transformBNBuffer=function(e,t,r){var n={};return n.network=hn.get(t)||hn.defaultNetwork,n.bn=_i.fromBuffer(e),n.compressed=r===void 0?!0:!!r,n};ve._transformWIF=function(e,t){return ve._transformBuffer(Ex.decode(e),t)};ve.fromBuffer=function(e,t,r){return r!==void 0&&e&&e.length===32?new ve(ve._transformBNBuffer(e,t,r)):new ve(e,t)};ve.fromHex=function(e,t,r){return ve.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ve._transformObject=function(e){if(e.bn instanceof _i)return{bn:e.bn,network:hn.get(e.network),compressed:e.compressed};if(typeof e.bn!="string"||!e.bn.length)throw new TypeError("Invalid private key: `bn` must be a hex string");if(e.bn===Cp)throw new TypeError('Invalid private key: `bn` is "'+Cp+'". JSON.stringify() redacts the secret on purpose \u2014 use toObject() for a round-trippable export, or toWIF().');if(!/^[0-9a-fA-F]+$/.test(e.bn))throw new TypeError("Invalid private key: `bn` is not hexadecimal");var t=new _i(e.bn,"hex");if(t.isZero()||t.gte(Lp.getN()))throw new TypeError("Invalid private key: outside the range of valid keys");var r=hn.get(e.network);return{bn:t,network:r,compressed:e.compressed}};ve.fromString=ve.fromWIF=function(e,t){return Ix.checkArgument(Lc.isString(e),"First argument is expected to be a string."),new ve(e,t)};ve.fromObject=ve.fromJSON=function(e){return Ix.checkArgument(Lc.isObject(e),"First argument is expected to be an object."),new ve(e)};ve.fromRandom=function(e){var t=ve._getRandomBN();return new ve(t,e)};ve.getValidationError=function(e,t){var r;try{new ve(e,t)}catch(n){r=n}return r};ve.isValid=function(e,t){return e?!ve.getValidationError(e,t):!1};ve.prototype.toString=function(){return this.toWIF()};ve.prototype.toWIF=function(){var e=this.network,t=this.compressed,r;return t?r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32}),d.Buffer.from([1])]):r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32})]),Ex.encode(r)};ve.prototype.toBigNumber=function(){return this.bn};ve.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})};ve.prototype.toHex=function(){return this.toBuffer().toString("hex")};ve.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=Jk.fromPrivateKey(this)),this._pubkey};ve.prototype.toAddress=function(e){var t=this.toPublicKey();return Xk.fromPublicKey(t,e||this.network)};ve.prototype.toObject=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}};ve.prototype.toJSON=function(){return{bn:Cp,compressed:this.compressed,network:this.network.toString()}};ve.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+e+">"};Ax.exports=ve});var Ar=P((rq,Rx)=>{"use strict";p();var as=Sr(),us=ai(),eC=Jt(),tC=dr(),Ox=pa(),Dp=ze(),oo=Le();function pe(e,t){if(!(this instanceof pe))return new pe(e,t);if(oo.checkArgument(e,"First argument is required, please include public key data."),e instanceof pe)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),tC.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||Ox.defaultNetwork}),this}pe.prototype._classifyArgs=function(e,t){var r={compressed:Dp.isUndefined(t.compressed)||t.compressed};if(e instanceof us)r.point=e;else if(e.x&&e.y)r=pe._transformObject(e);else if(typeof e=="string")r=pe._transformDER(d.Buffer.from(e,"hex"));else if(pe._isBuffer(e))r=pe._transformDER(e);else if(pe._isPrivateKey(e))r=pe._transformPrivateKey(e);else throw new TypeError("First argument is an unrecognized data format.");return r.network||(r.network=Dp.isUndefined(t.network)?void 0:Ox.get(t.network)),r};pe._isPrivateKey=function(e){var t=no();return e instanceof t};pe._isBuffer=function(e){return e instanceof d.Buffer||e instanceof Uint8Array};pe._transformPrivateKey=function(e){oo.checkArgument(pe._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=us.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t};pe._transformDER=function(e,t){oo.checkArgument(pe._isBuffer(e),"Must be a buffer of DER encoded public key");var r={};t=Dp.isUndefined(t)?!0:t;var n,i,o,s;if(e[0]===4||!t&&(e[0]===6||e[0]===7)){if(o=e.slice(1,33),s=e.slice(33,65),o.length!==32||s.length!==32||e.length!==65)throw new TypeError("Length of x and y must be 32 bytes");n=new as(o),i=new as(s),r.point=new us(n,i),r.compressed=!1}else if(e[0]===3)o=e.slice(1),n=new as(o),r=pe._transformX(!0,n),r.compressed=!0;else if(e[0]===2)o=e.slice(1),n=new as(o),r=pe._transformX(!1,n),r.compressed=!0;else throw new TypeError("Invalid DER format public key");return r};pe._transformX=function(e,t){oo.checkArgument(typeof e=="boolean","Must specify whether y is odd or not (true or false)");var r={};return r.point=us.fromX(e,t),r};pe._transformObject=function(e){var t=new as(e.x,"hex"),r=new as(e.y,"hex"),n=new us(t,r);return new pe(n,{compressed:e.compressed})};pe.fromPrivateKey=function(e){oo.checkArgument(pe._isPrivateKey(e),"Must be an instance of PrivateKey");var t=pe._transformPrivateKey(e);return new pe(t.point,{compressed:t.compressed,network:t.network})};pe.fromDER=pe.fromBuffer=function(e,t){oo.checkArgument(pe._isBuffer(e),"Must be a buffer of DER encoded public key");var r=pe._transformDER(e,t);return new pe(r.point,{compressed:r.compressed})};pe.fromPoint=function(e,t){return oo.checkArgument(e instanceof us,"First argument must be an instance of Point."),new pe(e,{compressed:t})};pe.fromHex=pe.fromString=function(e,t){var r=d.Buffer.from(e,t||"hex"),n=pe._transformDER(r);return new pe(n.point,{compressed:n.compressed})};pe.fromX=function(e,t){var r=pe._transformX(e,t);return new pe(r.point,{compressed:r.compressed})};pe.getValidationError=function(e){var t;try{new pe(e)}catch(r){t=r}return t};pe.isValid=function(e){return!pe.getValidationError(e)};pe.prototype.toObject=pe.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}};pe.prototype.toBuffer=pe.prototype.toDER=function(){var e=this.point.getX(),t=this.point.getY(),r=e.toBuffer({size:32}),n=t.toBuffer({size:32}),i;if(this.compressed){var o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])}else return i=d.Buffer.from([4]),d.Buffer.concat([i,r,n])};pe.prototype._getID=function(){return eC.sha256ripemd160(this.toBuffer())};pe.prototype.toAddress=function(e){var t=ro();return t.fromPublicKey(this,e||this.network)};pe.prototype.toString=pe.prototype.toHex=function(){return this.toDER().toString("hex")};pe.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"};Rx.exports=pe});var Ha=P((iq,Px)=>{"use strict";p();var Tx=Xs();function rC(){var e=Tx.getRandomBuffer(16);e[6]=e[6]&15|64,e[8]=e[8]&63|128;var t=e.toString("hex");return[t.substring(0,8),t.substring(8,12),t.substring(12,16),t.substring(16,20),t.substring(20,32)].join("-")}function nC(e){return Tx.getRandomBuffer(Math.ceil(e/2)).toString("hex").substring(0,e)}Px.exports={uuid4:rC,randomHex:nC}});var Cx=P((aq,kx)=>{"use strict";p();var Ka=Ar(),Up=Jt(),Fp=Ma(),Bx=nr(),qp=no(),Bt=Le(),sq=ze(),iC=Ha();function Nx(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Ka?t.issuerPublicKey:Ka.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Ka.fromString(n):null}catch{return null}}var fs={PROPERTY_TITLE:"PropertyTitle",VEHICLE_TITLE:"VehicleTitle",INTELLECTUAL_PROPERTY:"IntellectualProperty",MUSIC_LICENSE:"MusicLicense",SOFTWARE_LICENSE:"SoftwareLicense",FINANCIAL_INSTRUMENT:"FinancialInstrument",PROMISSORY_NOTE:"PromissoryNote",BOND:"Bond",EQUITY_SHARE:"EquityShare",PROFESSIONAL_LICENSE:"ProfessionalLicense",REGULATORY_PERMIT:"RegulatoryPermit",ACCESS_RIGHT:"AccessRight",VOTING_RIGHT:"VotingRight",ROYALTY_RIGHT:"RoyaltyRight",USAGE_RIGHT:"UsageRight"},Mx={create:function(e,t,r,n,i,o){o=o||{},Bt.checkArgument(typeof e=="string","Right type must be string"),Bt.checkArgument(typeof t=="string","Issuer DID must be string"),Bt.checkArgument(typeof r=="string","Subject DID must be string"),Bt.checkArgument(n&&typeof n=="object","Claim must be object");var s=Object.values(fs);Bt.checkArgument(s.includes(e),"Invalid right type: "+e);var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,rightType:e,claim:n,jurisdiction:o.jurisdiction||"US",purpose:o.purpose||"legal_right",validFrom:o.validFrom||new Date().toISOString(),validUntil:o.validUntil||null,transferable:o.transferable!==!1,revocable:o.revocable!==!1}};return o.metadata&&(a.credentialSubject.metadata=o.metadata),a},prepareRightToken:function(e,t,r,n,i,o){o=o||{},Bt.checkArgument(typeof e=="string","Right type must be string"),Bt.checkArgument(typeof t=="string","Issuer DID must be string"),Bt.checkArgument(typeof r=="string","Subject DID must be string"),Bt.checkArgument(n&&typeof n=="object","Claim must be object"),Bt.checkArgument(i instanceof qp,"Invalid issuer private key");var s=Object.values(fs);Bt.checkArgument(s.includes(e),"Invalid right type: "+e);try{var a=this.create(e,t,r,n,i,o),f=this._signToken(a,i);return{success:!0,rightToken:f,tokenHash:f.tokenHash,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction},externalOperations:{storeToken:{endpoint:"POST /rights/tokens",data:{token:f,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction}}},indexToken:{endpoint:"POST /rights/index",data:{tokenId:f.id,tokenHash:f.tokenHash,type:e,issuer:t,subject:r,issuedAt:f.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:f.id,issuer:t,subject:r,rightType:e}}}}}catch(l){return{success:!1,error:l.message}}},prepareRightTokenVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateRightType(e,r),t.requireJurisdiction&&this._validateJurisdiction(e,t.allowedJurisdictions,r);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,subjectDID:e.credentialSubject?e.credentialSubject.id:null,rightType:e.credentialSubject?e.credentialSubject.rightType:null,transferable:e.credentialSubject?e.credentialSubject.transferable:null,revocable:e.credentialSubject?e.credentialSubject.revocable:null,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /rights/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/right-verification",data:{tokenId:e.id,rightType:i.rightType,issuer:i.issuerDID,subject:i.subjectDID,result:i.valid,verifiedAt:i.verifiedAt}},updateTokenStatus:i.valid?{endpoint:"PUT /rights/tokens/"+e.id+"/status",data:{status:"VERIFIED",verifiedAt:i.verifiedAt}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareRightTokenTransfer:function(e,t,r,n){n=n||{},Bt.checkArgument(e&&typeof e=="object","Invalid token"),Bt.checkArgument(typeof t=="string","New owner DID must be string"),Bt.checkArgument(r instanceof qp,"Invalid current owner key");try{var i=this.prepareRightTokenVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot transfer invalid token: "+i.verification.errors.join(", ")};if(!e.credentialSubject.transferable)return{success:!1,error:"Token is not transferable"};var o=e.credentialSubject&&e.credentialSubject.id,s=Nx({issuer:o},{issuerPublicKey:n.currentOwnerPublicKey});if(!s)return{success:!1,error:"Cannot resolve current owner public key from token.credentialSubject.id; pass options.currentOwnerPublicKey"};if(r.toPublicKey().toString()!==s.toString())return{success:!1,error:"Unauthorized transfer: signing key does not match the current owner"};var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightTransfer"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,originalToken:e.id,transferFrom:e.credentialSubject.id,transferTo:t,transferDate:new Date().toISOString(),transferReason:n.reason||"ownership_transfer",consideration:n.consideration||null}},f=this._signToken(a,r),l=JSON.parse(JSON.stringify(e));l.id="urn:uuid:"+this._generateUUID(),l.issuanceDate=new Date().toISOString(),l.credentialSubject.id=t,l.credentialSubject.transferHistory=l.credentialSubject.transferHistory||[],l.credentialSubject.transferHistory.push({transferId:f.id,transferDate:f.issuanceDate,from:e.credentialSubject.id,to:t}),delete l.proof;var m=this._signToken(l,r);return{success:!0,newToken:m,transferProof:f,transferId:f.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:e.id,newTokenId:m.id,transferProof:f,fromOwner:e.credentialSubject.id,toOwner:t,transferDate:f.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+e.id+"/ownership",data:{newOwner:t,transferId:f.id,transferDate:f.issuanceDate,previousOwner:e.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:e.id,newTokenId:m.id,fromOwner:e.credentialSubject.id,toOwner:t,rightType:e.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:e.id,newTokenId:m.id,transferId:f.id,fromOwner:e.credentialSubject.id,toOwner:t,transferredAt:f.issuanceDate}}}}}catch(g){return{success:!1,error:g.message}}},prepareObligationToken:function(e,t,r,n){Bt.checkArgument(e&&typeof e=="object","Invalid right token"),Bt.checkArgument(typeof t=="string","Obligor DID must be string"),Bt.checkArgument(r&&typeof r=="object","Obligation must be object"),Bt.checkArgument(n instanceof qp,"Invalid issuer key");try{var i={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken"],issuer:e.issuer,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,obligationType:"correlative_obligation",correlativeRight:e.id,rightHolder:e.credentialSubject.id,obligation:r,jurisdiction:e.credentialSubject.jurisdiction,purpose:e.credentialSubject.purpose}},o=this._signToken(i,n);return{success:!0,obligationToken:o,correlativeRight:e.id,externalOperations:{storeObligation:{endpoint:"POST /obligations/tokens",data:{obligationToken:o,correlativeRightId:e.id,obligor:t,rightHolder:e.credentialSubject.id}},linkToRight:{endpoint:"POST /rights/tokens/"+e.id+"/obligations",data:{obligationId:o.id,obligor:t,obligationType:"correlative_obligation"}},notifyObligor:{endpoint:"POST /notifications/obligation-created",data:{obligationId:o.id,obligor:t,rightHolder:e.credentialSubject.id,correlativeRight:e.id}}}}}catch(s){return{success:!1,error:s.message}}},prepareRightTypeValidation:function(e){Bt.checkArgument(typeof e=="string","Right type must be string");var t=Object.values(fs),r=t.includes(e);return{success:!0,validation:{type:e,valid:r,availableTypes:t,category:this._categorizeRightType(e),description:this._getRightTypeDescription(e)},externalOperations:{validateType:{endpoint:"POST /rights/validate-type",data:{type:e,valid:r}}}}},_categorizeRightType:function(e){var t={PropertyTitle:"PROPERTY_RIGHT",VehicleTitle:"PROPERTY_RIGHT",IntellectualProperty:"IP_RIGHT",MusicLicense:"IP_RIGHT",SoftwareLicense:"IP_RIGHT",FinancialInstrument:"FINANCIAL_RIGHT",PromissoryNote:"FINANCIAL_RIGHT",Bond:"FINANCIAL_RIGHT",EquityShare:"FINANCIAL_RIGHT",ProfessionalLicense:"LICENSE_RIGHT",RegulatoryPermit:"LICENSE_RIGHT",AccessRight:"ACCESS_RIGHT",VotingRight:"GOVERNANCE_RIGHT",RoyaltyRight:"IP_RIGHT",UsageRight:"ACCESS_RIGHT"};return t[e]||"UNKNOWN"},_getRightTypeDescription:function(e){var t={PropertyTitle:"Legal ownership of real estate property",VehicleTitle:"Legal ownership of motor vehicle",IntellectualProperty:"Rights to intellectual property assets",MusicLicense:"License for music performance and usage",SoftwareLicense:"License for software usage and distribution",FinancialInstrument:"Rights related to financial instruments",PromissoryNote:"Promise to pay a specified amount",Bond:"Debt security representing loan",EquityShare:"Ownership stake in company",ProfessionalLicense:"License for professional practice",RegulatoryPermit:"Permit for regulated activities",AccessRight:"Right to access resources or locations",VotingRight:"Right to participate in governance",RoyaltyRight:"Right to receive royalty payments",UsageRight:"Right to use specific assets or services"};return t[e]||"Unknown right type"},getRightTypes:function(){return fs},verifyToken:function(e,t){var r=[];try{if(Bt.checkArgument(e&&typeof e=="object","Invalid token"),!e.proof||!e.proof.jws)return r.push("Missing signature proof"),{valid:!1,errors:r};var n=t instanceof Ka?t:Ka.fromString(t),i=this._canonicalizeToken(e),o=Up.sha256(d.Buffer.from(i));if(e.tokenHash&&e.tokenHash!==o.toString("hex"))return r.push("Token hash mismatch"),{valid:!1,errors:r};var s=e.proof.jws.split(".");if(s.length!==3||!s[2])return r.push("Malformed JWS"),{valid:!1,errors:r};var a=Bx.fromDER(d.Buffer.from(s[2],"base64url")),f=new Fp;return f.hashbuf=o,f.sig=a,f.pubkey=n,f.verify()||r.push("Signature verification failed"),{valid:r.length===0,errors:r,tokenHash:o.toString("hex"),verifiedAt:new Date().toISOString()}}catch(l){return r.push(l.message),{valid:!1,errors:r}}},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Up.sha256(d.Buffer.from(r)),i=new Fp;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=t.toDER().toString("base64url");return n+".."+i},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Up.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=Nx(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=Bx.fromDER(d.Buffer.from(s[2],"base64url")),f=new Fp;f.hashbuf=i,f.sig=a,f.pubkey=o,f.verify()!==!0&&t.push("Signature verification failed")}catch(l){t.push("Signature verification failed: "+l.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.validFrom){var o=new Date(e.credentialSubject.validFrom);n<o&&r.push("Token not yet valid")}if(e.credentialSubject.validUntil){var s=new Date(e.credentialSubject.validUntil);n>s&&t.push("Token expired")}},_validateRightType:function(e,t){if(!e.credentialSubject.rightType){t.push("Missing rightType");return}var r=Object.values(fs);r.includes(e.credentialSubject.rightType)||t.push("Invalid right type: "+e.credentialSubject.rightType)},_validateJurisdiction:function(e,t,r){if(!e.credentialSubject.jurisdiction){r.push("Missing jurisdiction");return}t&&Array.isArray(t)&&(t.includes(e.credentialSubject.jurisdiction)||r.push("Jurisdiction not allowed: "+e.credentialSubject.jurisdiction))},_generateUUID:function(){return iC.uuid4()}};Mx.RightTypes=fs;kx.exports=Mx});var Dx=P((fq,Lx)=>{"use strict";p();var Ga=Jt(),gr=Le(),oC=Ha(),so={PropertyTitle:{title:"Property Title",description:"Real estate property ownership title",type:"object",required:["propertyId","address","ownershipType"],properties:{propertyId:{type:"string",description:"Unique property identifier"},address:{type:"object",required:["street","city","state","country"],properties:{street:{type:"string"},city:{type:"string"},state:{type:"string"},country:{type:"string"},postalCode:{type:"string"}}},ownershipType:{type:"string",enum:["fee_simple","leasehold","joint_tenancy","tenancy_in_common"]},titleNumber:{type:"string"},registeredDate:{type:"string",format:"date-time"},legalDescription:{type:"string"},encumbrances:{type:"array",items:{type:"object",properties:{type:{type:"string"},amount:{type:"number"},description:{type:"string"}}}}}},VehicleTitle:{title:"Vehicle Title",description:"Motor vehicle ownership title",type:"object",required:["vin","make","model","year"],properties:{vin:{type:"string",pattern:"^[A-HJ-NPR-Z0-9]{17}$",description:"Vehicle Identification Number"},make:{type:"string"},model:{type:"string"},year:{type:"integer",minimum:1900,maximum:2030},titleNumber:{type:"string"},registeredState:{type:"string"},mileage:{type:"integer",minimum:0},color:{type:"string"},fuelType:{type:"string",enum:["gasoline","diesel","electric","hybrid","other"]},liens:{type:"array",items:{type:"object",properties:{lienholderName:{type:"string"},lienAmount:{type:"number"},lienDate:{type:"string",format:"date"}}}}}},PromissoryNote:{title:"Promissory Note",description:"Legal promise to pay a specified amount",type:"object",required:["principal","interestRate","maturityDate","borrower","lender"],properties:{principalAmount:{type:"number",minimum:0,description:"Principal amount in base currency units"},currency:{type:"string",default:"USD"},interestRate:{type:"number",minimum:0,maximum:100,description:"Annual interest rate percentage"},maturityDate:{type:"string",format:"date",description:"Date when principal and interest are due"},payee:{type:"string",description:"DID of the payee (creditor)"},payor:{type:"string",description:"DID of the payor (debtor)"},paymentSchedule:{type:"string",enum:["lump_sum","monthly","quarterly","annually"]},collateral:{type:"array",items:{type:"object",properties:{description:{type:"string"},value:{type:"number"},type:{type:"string"}}}},defaultProvisions:{type:"string"},governingLaw:{type:"string"}}},IntellectualProperty:{title:"Intellectual Property",description:"Intellectual property rights and licensing",type:"object",required:["ipType","title","registrationNumber"],properties:{ipType:{type:"string",enum:["patent","trademark","copyright","trade_secret"]},title:{type:"string"},creator:{type:"string",description:"Creator DID"},registrationNumber:{type:"string"},registrationDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},jurisdiction:{type:"string"},description:{type:"string"},claims:{type:"array",items:{type:"string"}},priorArt:{type:"array",items:{type:"object",properties:{reference:{type:"string"},date:{type:"string",format:"date"},relevance:{type:"string"}}}}}},ProfessionalLicense:{title:"Professional License",description:"Professional practice license or certification",type:"object",required:["licenseType","licenseNumber","issuingAuthority","expirationDate"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},licensee:{type:"string",description:"Licensee DID"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},renewalDate:{type:"string",format:"date"},jurisdiction:{type:"string"},scope:{type:"string"},restrictions:{type:"array",items:{type:"string"}},continuing_education:{type:"object",properties:{hours_required:{type:"integer"},deadline:{type:"string",format:"date"},completed_hours:{type:"integer"}}}}},MusicLicense:{title:"Music License",description:"Music performance and usage licensing",type:"object",required:["songTitle","artist","licenseType","royaltyRate"],properties:{workTitle:{type:"string"},composer:{type:"string",description:"Composer DID"},performer:{type:"string",description:"Performer DID"},licenseType:{type:"string",enum:["mechanical","performance","synchronization","master_use"]},territory:{type:"string"},duration:{type:"string"},royaltyRate:{type:"number",minimum:0,maximum:100},advancePayment:{type:"number",minimum:0},exclusivity:{type:"boolean"},mediaTypes:{type:"array",items:{type:"string",enum:["cd","vinyl","digital","streaming","broadcast","film","tv"]}},usage_restrictions:{type:"string"},copyrightNotice:{type:"string"}}}},sC={prepareClaimValidation:function(e,t){try{gr.checkArgument(e&&typeof e=="object","Invalid claim"),gr.checkArgument(typeof t=="string","Schema name must be string");var r=so[t];if(!r)return{success:!1,error:"Unknown schema: "+t};var n=[],i=[];this._validateObject(e,r,"",n,i);var o={valid:n.length===0,errors:n,warnings:i,schema:t,claimHash:this.hash(e),canonical:this.canonicalize(e)};return{success:!0,validation:o,claim:e,schema:r,externalOperations:{store:{endpoint:"POST /claims/validate",data:{claim:e,validation:o,schema:t}},index:{endpoint:"POST /claims/index",data:{claimHash:o.claimHash,schemaName:t,valid:o.valid}}}}}catch(s){return{success:!1,error:"Validation preparation failed: "+s.message}}},prepareClaimAttestation:function(e,t,r){try{gr.checkArgument(e&&typeof e=="object","Invalid claim"),gr.checkArgument(typeof t=="string","Schema name must be string"),gr.checkArgument(r&&typeof r=="object","Invalid attestor");var n=this.prepareClaimValidation(e,t);if(!n.success||!n.validation.valid)return{success:!1,error:"Cannot attest invalid claim",validation:n};var i={type:"LTP_CLAIM_ATTESTATION",claimHash:n.validation.claimHash,schemaName:t,attestor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},attestedAt:new Date().toISOString(),confidence:r.confidence||100,evidence:r.evidence||null,notes:r.notes||null},o=Ga.sha256(d.Buffer.from(this.canonicalize(i))).toString("hex");return i.attestationHash=o,{success:!0,attestation:i,claim:e,validation:n.validation,externalOperations:{storeAttestation:{endpoint:"POST /claims/"+n.validation.claimHash+"/attestations",data:i},notifyStakeholders:{endpoint:"POST /notifications/claim-attested",data:{claimHash:n.validation.claimHash,attestorDid:i.attestor.did,attestationHash:o}}}}}catch(s){return{success:!1,error:"Attestation preparation failed: "+s.message}}},prepareClaimDispute:function(e,t,r){try{gr.checkArgument(typeof e=="string","Claim hash must be string"),gr.checkArgument(t&&typeof t=="object","Invalid disputant"),gr.checkArgument(r&&typeof r=="object","Invalid dispute");var n={type:"LTP_CLAIM_DISPUTE",claimHash:e,disputant:{did:t.did||t.id,name:t.name||"Unknown",jurisdiction:t.jurisdiction||null},dispute:{reason:r.reason||"UNSPECIFIED",category:r.category||"ACCURACY",description:r.description||"",evidence:r.evidence||null,requestedAction:r.requestedAction||"REVIEW"},disputedAt:new Date().toISOString(),status:"FILED",priority:r.priority||"NORMAL"},i=Ga.sha256(d.Buffer.from(this.canonicalize(n))).toString("hex");return n.disputeHash=i,{success:!0,dispute:n,disputeId:this._generateDisputeId(e),externalOperations:{fileDispute:{endpoint:"POST /claims/"+e+"/disputes",data:n},notifyStakeholders:{endpoint:"POST /notifications/claim-disputed",data:{claimHash:e,disputantDid:n.disputant.did,disputeHash:i}},escalate:{endpoint:"POST /disputes/escalate",data:{disputeHash:i,priority:n.priority}}}}}catch(o){return{success:!1,error:"Dispute preparation failed: "+o.message}}},prepareBulkClaimValidation:function(e,t){try{gr.checkArgument(Array.isArray(e),"Claims must be array"),gr.checkArgument(typeof t=="string","Schema name must be string");var r=[],n=[],i=0;e.forEach(function(a,f){try{var l=this.prepareClaimValidation(a,t);l.success&&l.validation.valid&&i++,r.push({index:f,result:l})}catch(m){n.push({index:f,error:m.message})}}.bind(this));var o=this._generateBatchId(),s=Ga.sha256(d.Buffer.from(JSON.stringify(r.map(a=>a.result.validation.claimHash)))).toString("hex");return{success:!0,batchId:o,batchHash:s,totalClaims:e.length,validClaims:i,invalidClaims:e.length-i,validations:r,errors:n,externalOperations:{storeBatch:{endpoint:"POST /claims/batch-validate",data:{batchId:o,batchHash:s,schemaName:t,validations:r}},generateReport:{endpoint:"POST /reports/bulk-validation",data:{batchId:o,summary:{total:e.length,valid:i,invalid:e.length-i}}}}}}catch(a){return{success:!1,error:"Bulk validation preparation failed: "+a.message}}},canonicalize:function(e){gr.checkArgument(e&&typeof e=="object","Invalid claim");var t=this._sortObjectKeys(e);return JSON.stringify(t)},hash:function(e){var t=this.canonicalize(e);return Ga.sha256(d.Buffer.from(t)).toString("hex")},prepareClaimTemplate:function(e,t){t=t||{};try{var r=so[e];if(!r)return{success:!1,error:"Unknown schema: "+e};var n=this._createTemplateFromSchema(r),i=this._generateFormStructure(r);return{success:!0,schemaName:e,template:n,schema:r,formStructure:i,validation:{required:r.required||[],patterns:this._extractPatterns(r),enums:this._extractEnums(r)},externalOperations:{generateForm:{endpoint:"POST /forms/generate",data:{schemaName:e,formStructure:i,template:n}},saveTemplate:{endpoint:"POST /templates/claim",data:{schemaName:e,template:n,customizations:t.customizations||{}}}}}}catch(o){return{success:!1,error:"Template preparation failed: "+o.message}}},getSchemas:function(){return so},getSchemaNames:function(){return Object.keys(so)},getSchema:function(e){return so[e]||null},addSchema:function(e,t){gr.checkArgument(typeof e=="string","Schema name must be string"),gr.checkArgument(t&&typeof t=="object","Invalid schema"),so[e]=t},createTemplate:function(e){var t=so[e];if(!t)throw new Error("Unknown schema: "+e);return this._createTemplateFromSchema(t)},_generateDisputeId:function(e){var t="dispute_"+e+"_"+Date.now();return Ga.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateBatchId:function(){return oC.randomHex(16)},_generateFormStructure:function(e){var t={type:"form",title:e.title||"Legal Claim Form",description:e.description||"",fields:[]};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r],i={name:r,label:this._humanizeFieldName(r),type:this._mapSchemaTypeToFormType(n),required:e.required&&e.required.includes(r),validation:this._extractFieldValidation(n)};n.enum&&(i.options=n.enum.map(function(o){return{value:o,label:this._humanizeValue(o)}}.bind(this))),t.fields.push(i)}.bind(this)),t},_extractPatterns:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.pattern&&(t[r]=n.pattern)}),t},_extractEnums:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.enum&&(t[r]=n.enum)}),t},_mapSchemaTypeToFormType:function(e){switch(e.type){case"string":return e.enum?"select":e.format==="date"?"date":e.format==="date-time"?"datetime":"text";case"number":case"integer":return"number";case"boolean":return"checkbox";case"array":return"list";case"object":return"fieldset";default:return"text"}},_extractFieldValidation:function(e){var t={};return e.pattern&&(t.pattern=e.pattern),e.minimum!==void 0&&(t.min=e.minimum),e.maximum!==void 0&&(t.max=e.maximum),e.format&&(t.format=e.format),t},_humanizeFieldName:function(e){return e.replace(/([A-Z])/g," $1").replace(/^./,function(t){return t.toUpperCase()}).replace(/_/g," ")},_humanizeValue:function(e){return e.replace(/_/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()})},_validateObject:function(e,t,r,n,i){t.type==="object"?(t.required&&Array.isArray(t.required)&&t.required.forEach(function(o){e.hasOwnProperty(o)||n.push("Missing required field: "+this._getFieldPath(r,o))}.bind(this)),t.properties&&Object.keys(e).forEach(function(o){var s=this._getFieldPath(r,o),a=t.properties[o];a?this._validateValue(e[o],a,s,n,i):i.push("Unknown field: "+s)}.bind(this))):this._validateValue(e,t,r,n,i)},_validateValue:function(e,t,r,n,i){if(t.type){var o=Array.isArray(e)?"array":typeof e;if(o!==t.type){n.push("Invalid type for "+r+": expected "+t.type+", got "+o);return}}if(t.type==="string"&&(t.pattern&&!new RegExp(t.pattern).test(e)&&n.push("Value does not match pattern for "+r),t.enum&&!t.enum.includes(e)&&n.push("Invalid enum value for "+r+": "+e),t.format==="date"&&!this._isValidDate(e)&&n.push("Invalid date format for "+r),t.format==="date-time"&&!this._isValidDateTime(e)&&n.push("Invalid date-time format for "+r)),(t.type==="number"||t.type==="integer")&&(t.minimum!==void 0&&e<t.minimum&&n.push("Value below minimum for "+r+": "+e+" < "+t.minimum),t.maximum!==void 0&&e>t.maximum&&n.push("Value above maximum for "+r+": "+e+" > "+t.maximum),t.type==="integer"&&!Number.isInteger(e)&&n.push("Value must be integer for "+r)),t.type==="array"&&t.items)for(var s=0;s<e.length;s++)this._validateValue(e[s],t.items,r+"["+s+"]",n,i);t.type==="object"&&this._validateObject(e,t,r,n,i)},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_createTemplateFromSchema:function(e){if(e.type==="object"){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];t[r]=this._getDefaultValue(n)}.bind(this)),t}return this._getDefaultValue(e)},_getDefaultValue:function(e){if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:e.format==="date"?"2023-01-01":e.format==="date-time"?new Date().toISOString():"PLACEHOLDER_STRING";case"number":case"integer":return e.minimum||0;case"boolean":return!1;case"array":return[];case"object":return this._createTemplateFromSchema(e);default:return null}},_getFieldPath:function(e,t){return e?e+"."+t:t},_isValidDate:function(e){var t=new Date(e);return!isNaN(t.getTime())&&e.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(e){var t=new Date(e);return!isNaN(t.getTime())}};Lx.exports=sC});var Fx=P((lq,Ux)=>{"use strict";p();var Va=Jt(),cs=Le(),aC={prepareTokenCommitment:function(e,t){t=t||{},cs.checkArgument(e&&typeof e=="object","Invalid token");try{var r=this._createCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,commitment:r,opReturnData:n,txTemplate:i,preparedAt:new Date().toISOString(),metadata:{tokenId:e.id,purpose:t.purpose||"legal_token_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},prepareBatchCommitment:function(e,t){t=t||{},cs.checkArgument(Array.isArray(e),"Tokens must be array");try{var r=this._createBatchCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,batchCommitment:r,opReturnData:n,txTemplate:i,tokenCount:e.length,preparedAt:new Date().toISOString(),metadata:{purpose:t.purpose||"legal_token_batch_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},verifyTokenAnchor:function(e,t,r){cs.checkArgument(e&&typeof e=="object","Invalid token"),cs.checkArgument(typeof t=="string","Transaction ID must be string");try{var n=this._createCommitment(e,{}),i=this._extractOpReturn(r);if(!i)return{valid:!1,error:"No OP_RETURN data found in transaction"};var o=this._verifyCommitment(n,i);return{valid:o,chainVerified:!1,txid:t,commitment:n,anchorData:i,verifiedAt:new Date().toISOString()}}catch(s){return{valid:!1,error:s.message}}},formatRevocation:function(e,t){cs.checkArgument(typeof e=="string","Token ID must be string"),cs.checkArgument(t&&typeof t=="object","Invalid revocation data");try{var r={type:"LTP_REVOCATION",tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null},n=Va.sha256(d.Buffer.from(JSON.stringify(r))).toString("hex");return{success:!0,revocation:r,revocationHash:n,opReturnData:this._formatOpReturn({hash:n,type:"REVOCATION"},{})}}catch(i){return{success:!1,error:i.message}}},_createCommitment:function(e,t){var r=this._canonicalizeToken(e),n={type:"LTP_TOKEN",tokenHash:Va.sha256(d.Buffer.from(r)).toString("hex"),tokenId:e.id,timestamp:new Date().toISOString(),purpose:t.purpose||"legal_token"},i=Va.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return{hash:i,data:n,canonical:r}},_createBatchCommitment:function(e,t){var r=[],n=[];e.forEach(function(a){var f=this._createCommitment(a,t);r.push(f.hash),n.push(a.id)}.bind(this));var i=this._createMerkleRoot(r),o={type:"LTP_BATCH",merkleRoot:i,tokenCount:e.length,tokenIds:n,timestamp:new Date().toISOString(),purpose:t.purpose||"batch_anchor"},s=Va.sha256(d.Buffer.from(JSON.stringify(o))).toString("hex");return{hash:s,data:o,merkleRoot:i,tokenHashes:r}},_formatOpReturn:function(e,t){var r=t.prefix||"LTP.v1",n=e.hash;return{prefix:r,data:n,full:r+"."+n,bytes:d.Buffer.from(r+"."+n,"utf8"),size:d.Buffer.from(r+"."+n,"utf8").length}},_createTxTemplate:function(e,t){try{var r={version:1,inputs:[],outputs:[{satoshis:0,script:"OP_RETURN "+e.data}],locktime:0};return t.feeOutput&&r.outputs.push(t.feeOutput),{template:r,opReturn:e,estimatedSize:this._estimateSize(r),instructions:{step1:"Add input UTXOs to cover fees",step2:"Add change output if needed",step3:"Sign transaction with appropriate keys",step4:"Broadcast to BSV network"}}}catch(n){throw new Error("Failed to create transaction template: "+n.message)}},_extractOpReturn:function(e){try{if(!e||!e.outputs)return null;for(var t=0;t<e.outputs.length;t++){var r=e.outputs[t];if(r.script&&r.script.startsWith("OP_RETURN")){var n=r.script.replace("OP_RETURN ","");return{raw:n,decoded:d.Buffer.from(n,"hex").toString("utf8")}}}return null}catch{return null}},_verifyCommitment:function(e,t){try{return!t||!t.decoded?!1:t.decoded.includes(e.hash)}catch{return!1}},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,delete t.anchorTx,delete t.anchorBlock,JSON.stringify(this._sortObjectKeys(t))},_createMerkleRoot:function(e){if(e.length===0)return null;if(e.length===1)return e[0];for(var t=e.slice();t.length>1;){for(var r=[],n=0;n<t.length;n+=2){var i=t[n],o=t[n+1]||i,s=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(o,"hex")]),a=Va.sha256(s).toString("hex");r.push(a)}t=r}return t[0]},_estimateSize:function(e){var t=10,r=e.outputs.length*34,n=148;return{base:t+r,withOneInput:t+r+n,bytesPerInput:n}},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};Ux.exports=aC});var Hx=P((dq,jx)=>{"use strict";p();var uC=Ar(),Vr=Jt(),qx=Ma(),fC=nr(),cC=no(),ir=Le(),lC={prepareSignatureProof:function(e,t,r){r=r||{},ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(t instanceof cC,"Invalid private key");try{var n=this._canonicalizeForSigning(e),i=Vr.sha256(d.Buffer.from(n)),o=new qx;o.hashbuf=i,o.privkey=t,o.pubkey=t.toPublicKey(),o.sign();var s=o.sig,a={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:r.purpose||"assertionMethod",jws:this._createJWS(i,s),proofValue:s.toDER().toString("hex")};return{success:!0,proof:a,tokenHash:i.toString("hex"),canonical:n,signingKey:{publicKey:t.toPublicKey().toString(),keyId:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1"},externalOperations:{storeProof:{endpoint:"POST /proofs/signature",data:{tokenHash:i.toString("hex"),proof:a,signingKey:t.toPublicKey().toString()}},verifyProof:{endpoint:"POST /proofs/verify-signature",data:{tokenHash:i.toString("hex"),signature:s.toDER().toString("hex"),publicKey:t.toPublicKey().toString()}}}}}catch(f){return{success:!1,error:f.message}}},prepareSignatureVerification:function(e,t){try{if(ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(typeof t=="string","Public key must be string"),!e.proof)return{success:!1,error:"No proof found in token"};var r=this._canonicalizeForSigning(e),n=Vr.sha256(d.Buffer.from(r)),i=fC.fromDER(d.Buffer.from(e.proof.proofValue,"hex")),o={tokenHash:n.toString("hex"),signature:i.toDER().toString("hex"),publicKey:t,proof:e.proof,canonical:r},s=new qx;s.hashbuf=n,s.sig=i,s.pubkey=uC.fromString(t);var a=s.verify()===!0;return{success:!0,verification:{valid:a,tokenHash:n.toString("hex"),signatureValid:a,publicKey:t,verifiedAt:new Date().toISOString()},verificationData:o,externalOperations:{recordVerification:{endpoint:"POST /proofs/verification-record",data:{tokenHash:n.toString("hex"),result:a,publicKey:t,verifiedAt:new Date().toISOString()}},auditVerification:{endpoint:"POST /audit/proof-verification",data:{tokenId:e.id,proofType:e.proof.type,result:a,verifier:t}}}}}catch(f){return{success:!1,error:f.message}}},prepareSelectiveDisclosure:function(e,t,r){ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(Array.isArray(t),"Revealed fields must be array"),ir.checkArgument(typeof r=="string","Nonce must be string");try{var n=this._createFieldCommitments(e,r),i=this._createMerkleTree(n),o=[],s=[];t.forEach(function(f){var l=this._getNestedValue(e,f),m=this._findFieldCommitment(n,f);if(m){o.push({path:f,value:l,commitment:m.hash,salt:m.salt});var g=this._generateMerkleProof(i,m.index);s.push({path:f,leafIndex:m.index,proof:g})}}.bind(this));var a={type:"LegalTokenSelectiveDisclosure",created:new Date().toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:e.proof?e.proof.verificationMethod:null,nonce:r,merkleRoot:i.root,disclosures:o,merkleProofs:s,totalFields:n.length};return{success:!0,proof:a,hiddenFieldCount:n.length-o.length,revealedFieldCount:o.length,externalOperations:{storeDisclosure:{endpoint:"POST /proofs/selective-disclosure",data:{tokenId:e.id,proof:a,merkleRoot:i.root}},verifyDisclosure:{endpoint:"POST /proofs/verify-disclosure",data:{proof:a,expectedNonce:r}},auditDisclosure:{endpoint:"POST /audit/selective-disclosure",data:{tokenId:e.id,revealedFields:t,totalFields:n.length,disclosedAt:new Date().toISOString()}}}}}catch(f){return{success:!1,error:f.message}}},prepareSelectiveDisclosureVerification:function(e,t){try{if(ir.checkArgument(e&&typeof e=="object","Invalid proof"),ir.checkArgument(typeof t=="string","Expected nonce must be string"),e.nonce!==t)return{success:!1,error:"Nonce mismatch"};var r=[],n=[];e.disclosures.forEach(function(o,s){var a=e.merkleProofs[s],f=this._hashField(o.path,o.value,o.salt);if(f!==o.commitment){n.push("Invalid commitment for field: "+o.path);return}var l=this._verifyMerkleProof(o.commitment,a.leafIndex,a.proof,e.merkleRoot);l?r.push({path:o.path,value:o.value,verified:!0}):n.push("Invalid Merkle proof for field: "+o.path)}.bind(this));var i={valid:n.length===0,errors:n,disclosures:r,merkleRoot:e.merkleRoot,totalFields:e.totalFields,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /proofs/disclosure-verification",data:{proofId:e.id||"unknown",result:i.valid,verifiedFields:r.length,totalFields:e.totalFields,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/disclosure-verification",data:{merkleRoot:e.merkleRoot,disclosuresVerified:r.length,errors:n.length,result:i.valid}}}}}catch(o){return{success:!1,error:o.message}}},prepareLegalValidityProof:function(e,t,r){ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(t&&typeof t=="object","Invalid jurisdiction"),ir.checkArgument(typeof r=="string","Nonce must be string");try{var n=t.requirements||[],i=[],o=!0;n.forEach(function(a){var f=this._checkLegalRequirement(e,a);i.push(f),f.satisfied||(o=!1)}.bind(this));var s={type:"LegalValidityProof",created:new Date().toISOString(),proofPurpose:"legalValidity",jurisdiction:t.code,nonce:r,valid:o,checks:i,complianceHash:this._hashCompliance(e,t,r)};return{success:!0,proof:s,valid:o,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o},externalOperations:{submitCompliance:{endpoint:"POST /compliance/legal-validity",data:{tokenId:e.id,jurisdiction:t.code,proof:s,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o}}},auditCompliance:{endpoint:"POST /audit/compliance-check",data:{tokenId:e.id,jurisdiction:t.code,result:o,checkedAt:new Date().toISOString(),requirements:i}},notifyRegulator:o?null:{endpoint:"POST /notifications/compliance-failure",data:{tokenId:e.id,jurisdiction:t.code,failedRequirements:i.filter(a=>!a.satisfied)}}}}}catch(a){return{success:!1,error:a.message}}},prepareZeroKnowledgeProof:function(e,t,r){ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(t&&typeof t=="object","Invalid statement"),ir.checkArgument(typeof r=="string","Nonce must be string");try{var n=Vr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+r)).toString("hex"),i={type:"LegalTokenZKProof",created:new Date().toISOString(),proofPurpose:"zeroKnowledge",statement:{claim:t.claim||"UNSPECIFIED",predicate:t.predicate||"SATISFIES",threshold:t.threshold||null},commitment:n,nonce:r,proofData:this._generateZKProofData(e,t,r)};return{success:!0,proof:i,commitment:n,externalOperations:{storeZKProof:{endpoint:"POST /proofs/zero-knowledge",data:{tokenId:e.id,proof:i,statement:t}},verifyZKProof:{endpoint:"POST /proofs/verify-zk",data:{proof:i,expectedNonce:r}},auditZKProof:{endpoint:"POST /audit/zk-proof",data:{tokenId:e.id,statement:t.claim,proofGenerated:new Date().toISOString()}}}}}catch(o){return{success:!1,error:o.message}}},_generateZKProofData:function(e,t,r){var n={challenge:Vr.sha256(d.Buffer.from(t.claim+r)).toString("hex"),response:Vr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+t.claim)).toString("hex"),witness:Vr.sha256(d.Buffer.from(r+e.id+t.predicate)).toString("hex")};return n},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeForSigning:function(e){var t=JSON.parse(JSON.stringify(e));delete t.proof,delete t.tokenHash;var r=this._sortObjectKeys(t);return JSON.stringify(r)},_createFieldCommitments:function(e,t){var r=[],n=0;return this._traverseObject(e,"",function(i,o){if(i!=="proof"&&i!=="tokenHash"){var s=Vr.sha256(d.Buffer.from(t+i+n)).toString("hex"),a=this._hashField(i,o,s);r.push({path:i,value:o,salt:s,hash:a,index:n}),n++}}.bind(this)),r},_hashField:function(e,t,r){var n=e+":"+JSON.stringify(t)+":"+r;return Vr.sha256(d.Buffer.from(n)).toString("hex")},_createMerkleTree:function(e){var t=e.map(function(m){return m.hash});if(t.length===0)return{root:null,levels:[]};for(var r=[t],n=t;n.length>1;){for(var i=[],o=0;o<n.length;o+=2){var s=n[o],a=n[o+1]||s,f=d.Buffer.concat([d.Buffer.from(s,"hex"),d.Buffer.from(a,"hex")]),l=Vr.sha256(f).toString("hex");i.push(l)}r.push(i),n=i}return{root:n[0],levels:r}},_generateMerkleProof:function(e,t){for(var r=[],n=t,i=0;i<e.levels.length-1;i++){var o=e.levels[i],s=n%2===0,a=s?n+1:n-1;a<o.length&&r.push({hash:o[a],isLeft:!s}),n=Math.floor(n/2)}return r},_verifyMerkleProof:function(e,t,r,n){for(var i=e,o=t,s=0;s<r.length;s++){var a=r[s],f=o%2===0,l;a.isLeft?l=d.Buffer.concat([d.Buffer.from(a.hash,"hex"),d.Buffer.from(i,"hex")]):l=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(a.hash,"hex")]),i=Vr.sha256(l).toString("hex"),o=Math.floor(o/2)}return i===n},_traverseObject:function(e,t,r){Array.isArray(e)?e.forEach(function(n,i){var o=t+"["+i+"]";this._traverseObject(n,o,r)}.bind(this)):e!==null&&typeof e=="object"?Object.keys(e).forEach(function(n){var i=t?t+"."+n:n;this._traverseObject(e[n],i,r)}.bind(this)):r(t,e)},_getNestedValue:function(e,t){return t.split(".").reduce(function(r,n){return r&&r[n]},e)},_findFieldCommitment:function(e,t){return e.find(function(r){return r.path===t})},_checkLegalRequirement:function(e,t){switch(t.type){case"field_present":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r!=null};case"field_value":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r===t.expectedValue};case"temporal_validity":var n=new Date,i=new Date(e.issuanceDate);return{requirement:t.type,satisfied:i<=n};default:return{requirement:t.type,satisfied:!1,error:"Unknown requirement type"}}},_hashCompliance:function(e,t,r){var n={tokenId:e.id,jurisdiction:t.code,nonce:r,timestamp:new Date().toISOString()};return Vr.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex")},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};jx.exports=lC});var Vx=P((mq,Gx)=>{"use strict";p();var Wa=Jt(),gq=ro(),yq=Pp(),cr=Le(),Kx=Ha(),hC={prepareRegistry:function(e){e=e||{},cr.checkArgument(typeof e=="object","Config must be object");var t={id:e.id||this._generateRegistryId(),name:e.name||"Legal Token Registry",jurisdiction:e.jurisdiction||"GLOBAL",authority:e.authority||null,created:new Date().toISOString(),version:"1.0.0",config:{allowPublicRegistration:e.allowPublicRegistration||!1,requireApproval:e.requireApproval||!0,enableRevocation:e.enableRevocation!==!1,enableAuditTrail:e.enableAuditTrail!==!1,retentionPeriod:e.retentionPeriod||"7Y",complianceLevel:e.complianceLevel||"STANDARD"},dataStructure:{tokens:"Map<tokenId, registrationRecord>",revocations:"Map<tokenId, revocationRecord>",auditLog:"Array<auditEntry>",statistics:{totalTokens:0,activeTokens:0,revokedTokens:0,registrations:0}},externalStorage:{required:!0,type:"database_or_blockchain",endpoints:{store:"POST /registry/{id}/tokens",retrieve:"GET /registry/{id}/tokens/{tokenId}",search:"GET /registry/{id}/search",revoke:"POST /registry/{id}/revocations"}}},r=this._prepareAuditEntry({action:"REGISTRY_CREATED",actor:e.authority,timestamp:t.created,metadata:{jurisdiction:t.jurisdiction,config:t.config}});return{success:!0,registry:t,initialAudit:r,instructions:{step1:"Store registry configuration in external system",step2:"Initialize token storage with provided data structure",step3:"Set up audit logging with provided templates",step4:"Configure external endpoints for registry operations"}}},prepareTokenRegistration:function(e,t,r){r=r||{},cr.checkArgument(e&&typeof e=="object","Invalid token"),cr.checkArgument(t&&typeof t=="object","Invalid registry config");try{var n=this._validateTokenForRegistration(e,t);if(!n.valid)return{success:!1,error:"Token validation failed: "+n.error};var i={tokenId:e.id,tokenHash:this._hashToken(e),token:e,status:t.requireApproval?"PENDING":"ACTIVE",registeredBy:r.registeredBy||"UNKNOWN",registeredAt:new Date().toISOString(),approvedBy:null,approvedAt:null,metadata:r.metadata||{},compliance:{jurisdiction:e.jurisdiction||t.jurisdiction,level:this._calculateComplianceLevel(e),checks:n.checks||[]}},o=this._prepareAuditEntry({action:"TOKEN_REGISTERED",actor:r.registeredBy,tokenId:e.id,timestamp:i.registeredAt,metadata:{status:i.status,tokenType:e.type,compliance:i.compliance}});return{success:!0,registrationRecord:i,auditEntry:o,registrationId:this._generateRegistrationId(e.id),validation:n,externalOperations:{store:{endpoint:"POST /registry/"+t.id+"/tokens",data:i},audit:{endpoint:"POST /registry/"+t.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenApproval:function(e,t,r){try{cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(typeof t=="string","Approver must be string"),cr.checkArgument(r&&typeof r=="object","Invalid registry config");var n={tokenId:e,status:"ACTIVE",approvedBy:t,approvedAt:new Date().toISOString()},i=this._prepareAuditEntry({action:"TOKEN_APPROVED",actor:t,tokenId:e,timestamp:n.approvedAt});return{success:!0,approvalData:n,auditEntry:i,externalOperations:{update:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:n},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:i}}}}catch(o){return{success:!1,error:o.message}}},prepareTokenRevocation:function(e,t,r){try{if(cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(t&&typeof t=="object","Invalid revocation"),cr.checkArgument(r&&typeof r=="object","Invalid registry config"),!r.enableRevocation)return{success:!1,error:"Revocation is disabled for this registry"};var n={tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null,revocationHash:this._generateRevocationHash(e,t)},i={tokenId:e,status:"REVOKED",revokedAt:n.revokedAt,revocationReason:n.reason},o=this._prepareAuditEntry({action:"TOKEN_REVOKED",actor:t.revokedBy,tokenId:e,timestamp:n.revokedAt,metadata:{reason:n.reason,legalBasis:n.legalBasis}});return{success:!0,revocationRecord:n,statusUpdate:i,auditEntry:o,revocationId:this._generateRevocationId(e),externalOperations:{storeRevocation:{endpoint:"POST /registry/"+r.id+"/revocations",data:n},updateStatus:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:i},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenStatusQuery:function(e,t){try{return cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(t&&typeof t=="object","Invalid registry config"),{success:!0,query:{tokenId:e,registryId:t.id},externalOperations:{retrieve:{endpoint:"GET /registry/"+t.id+"/tokens/"+e,method:"GET"},checkRevocation:{endpoint:"GET /registry/"+t.id+"/revocations/"+e,method:"GET"}},expectedResponse:{found:"boolean",status:"string (PENDING|ACTIVE|REVOKED)",registeredAt:"ISO datetime",registeredBy:"string",approvedAt:"ISO datetime or null",approvedBy:"string or null",revokedAt:"ISO datetime or null",revocationReason:"string or null",compliance:"object",revocation:"object or null"}}}catch(r){return{success:!1,error:r.message}}},prepareTokenSearch:function(e,t){e=e||{};try{cr.checkArgument(t&&typeof t=="object","Invalid registry config");var r=[];e.status&&r.push("status="+encodeURIComponent(e.status)),e.type&&r.push("type="+encodeURIComponent(e.type)),e.registeredBy&&r.push("registeredBy="+encodeURIComponent(e.registeredBy)),e.jurisdiction&&r.push("jurisdiction="+encodeURIComponent(e.jurisdiction)),e.dateFrom&&r.push("dateFrom="+encodeURIComponent(e.dateFrom)),e.dateTo&&r.push("dateTo="+encodeURIComponent(e.dateTo)),e.includeTokens&&r.push("includeTokens=true"),e.sortBy&&r.push("sortBy="+encodeURIComponent(e.sortBy)),e.sortOrder&&r.push("sortOrder="+encodeURIComponent(e.sortOrder));var n=e.offset||0,i=e.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,searchCriteria:e,externalOperations:{search:{endpoint:"GET /registry/"+t.id+"/search"+o,method:"GET"}},expectedResponse:{success:"boolean",results:"Array<tokenRecord>",totalCount:"number",totalRegistrations:"number",offset:"number",limit:"number",hasMore:"boolean"}}}catch(s){return{success:!1,error:s.message}}},prepareStatisticsQuery:function(e){return cr.checkArgument(e&&typeof e=="object","Invalid registry config"),{success:!0,query:{registryId:e.id},externalOperations:{getStatistics:{endpoint:"GET /registry/"+e.id+"/statistics",method:"GET"}},expectedResponse:{id:"string",name:"string",jurisdiction:"string",created:"ISO datetime",statistics:{totalTokens:"number",activeTokens:"number",revokedTokens:"number",registrations:"number"},auditEntries:"number",lastActivity:"ISO datetime"}}},prepareAuditLogQuery:function(e,t){if(t=t||{},cr.checkArgument(e&&typeof e=="object","Invalid registry config"),!e.enableAuditTrail)return{success:!1,error:"Audit trail is disabled"};var r=[];t.action&&r.push("action="+encodeURIComponent(t.action)),t.actor&&r.push("actor="+encodeURIComponent(t.actor)),t.tokenId&&r.push("tokenId="+encodeURIComponent(t.tokenId)),t.dateFrom&&r.push("dateFrom="+encodeURIComponent(t.dateFrom)),t.dateTo&&r.push("dateTo="+encodeURIComponent(t.dateTo));var n=t.offset||0,i=t.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,auditOptions:t,externalOperations:{getAuditLog:{endpoint:"GET /registry/"+e.id+"/audit"+o,method:"GET"}},expectedResponse:{success:"boolean",entries:"Array<auditEntry>",totalEntries:"number",offset:"number",limit:"number",hasMore:"boolean"}}},_generateRegistryId:function(){return"reg_"+Kx.randomHex(16)},_generateRegistrationId:function(e){var t="reg_"+e+"_"+Date.now();return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateRevocationId:function(e){var t="rev_"+e+"_"+Date.now();return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_hashToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,Wa.sha256(d.Buffer.from(JSON.stringify(t))).toString("hex")},_generateRevocationHash:function(e,t){var r=e+(t.reason||"")+(t.revokedBy||"")+Date.now();return Wa.sha256(d.Buffer.from(r)).toString("hex")},_validateTokenForRegistration:function(e,t){var r=[],n=!0;return e.id?r.push({field:"id",valid:!0}):(r.push({field:"id",valid:!1,error:"Missing token ID"}),n=!1),e.type?r.push({field:"type",valid:!0}):(r.push({field:"type",valid:!1,error:"Missing token type"}),n=!1),e.issuanceDate?r.push({field:"issuanceDate",valid:!0}):(r.push({field:"issuanceDate",valid:!1,error:"Missing issuance date"}),n=!1),e.proof?r.push({field:"proof",valid:!0}):(r.push({field:"proof",valid:!1,error:"Missing cryptographic proof"}),n=!1),{valid:n,checks:r}},_calculateComplianceLevel:function(e){var t="BASIC";return e.proof&&e.proof.type&&(t="STANDARD"),e.jurisdiction&&e.legalBasis&&(t="ENHANCED"),e.attestations&&e.attestations.length>0&&(t="PREMIUM"),t},_prepareAuditEntry:function(e){var t={id:this._generateAuditId(),action:e.action,actor:e.actor||"SYSTEM",tokenId:e.tokenId||null,timestamp:e.timestamp||new Date().toISOString(),metadata:e.metadata||{},hash:this._generateAuditHash(e)};return t},_generateAuditId:function(){return"audit_"+Kx.randomHex(32)},_generateAuditHash:function(e){var t=(e.action||"")+(e.actor||"")+(e.tokenId||"")+(e.timestamp||"");return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)}};Gx.exports=hC});var $x=P((bq,Yx)=>{"use strict";p();var jp=Ar(),Hp=Jt(),Wx=Ma(),dC=nr(),zx=no(),yr=Le(),pC=Ha();function gC(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof jp?t.issuerPublicKey:jp.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?jp.fromString(n):null}catch{return null}}var Dc={CORRELATIVE_OBLIGATION:"CorrelativeObligation",CONTRACTUAL_OBLIGATION:"ContractualObligation",PAYMENT_OBLIGATION:"PaymentObligation",DELIVERY_OBLIGATION:"DeliveryObligation",PERFORMANCE_OBLIGATION:"PerformanceObligation",MAINTENANCE_OBLIGATION:"MaintenanceObligation",COMPLIANCE_OBLIGATION:"ComplianceObligation",REPORTING_OBLIGATION:"ReportingObligation",CONFIDENTIALITY_OBLIGATION:"ConfidentialityObligation",NON_COMPETE_OBLIGATION:"NonCompeteObligation",INDEMNIFICATION_OBLIGATION:"IndemnificationObligation",WARRANTY_OBLIGATION:"WarrantyObligation",SUPPORT_OBLIGATION:"SupportObligation",REGULATORY_OBLIGATION:"RegulatoryObligation",FIDUCIARY_OBLIGATION:"FiduciaryObligation"},ls={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},lr={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},Uc={prepareObligationToken:function(e,t,r,n,i,o){o=o||{},yr.checkArgument(typeof e=="string","Obligation type must be string"),yr.checkArgument(typeof t=="string","Issuer DID must be string"),yr.checkArgument(typeof r=="string","Obligor DID must be string"),yr.checkArgument(n&&typeof n=="object","Obligation must be object"),yr.checkArgument(i instanceof zx,"Invalid issuer private key");var s=Object.values(Dc);yr.checkArgument(s.includes(e),"Invalid obligation type: "+e);try{var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,obligationType:e,obligation:n,jurisdiction:o.jurisdiction||"US",priority:o.priority||ls.MEDIUM,status:lr.PENDING,dueDate:o.dueDate||null,effectiveDate:o.effectiveDate||new Date().toISOString(),expirationDate:o.expirationDate||null,correlativeRight:o.correlativeRight||null,rightHolder:o.rightHolder||null,enforceable:o.enforceable!==!1,penalties:o.penalties||null,remedies:o.remedies||null}};o.metadata&&(a.credentialSubject.metadata=o.metadata);var f=this._signToken(a,i);return{success:!0,obligationToken:f,tokenHash:f.tokenHash,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight},externalOperations:{storeToken:{endpoint:"POST /obligations/tokens",data:{token:f,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight}}},indexToken:{endpoint:"POST /obligations/index",data:{tokenId:f.id,tokenHash:f.tokenHash,type:e,issuer:t,obligor:r,issuedAt:f.issuanceDate,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:f.id,issuer:t,obligor:r,obligationType:e,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},scheduleReminders:a.credentialSubject.dueDate?{endpoint:"POST /obligations/schedule-reminders",data:{tokenId:f.id,obligor:r,dueDate:a.credentialSubject.dueDate,reminderSchedule:o.reminderSchedule||["7d","3d","1d"]}}:null}}}catch(l){return{success:!1,error:l.message}}},prepareObligationVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateObligationType(e,r),this._validateObligationStatus(e,r,n),this._validateObligationPriority(e,n);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,obligorDID:e.credentialSubject?e.credentialSubject.id:null,obligationType:e.credentialSubject?e.credentialSubject.obligationType:null,status:e.credentialSubject?e.credentialSubject.status:null,priority:e.credentialSubject?e.credentialSubject.priority:null,isOverdue:this._checkIfOverdue(e),verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /obligations/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt,isOverdue:i.isOverdue}},auditVerification:{endpoint:"POST /audit/obligation-verification",data:{tokenId:e.id,obligationType:i.obligationType,issuer:i.issuerDID,obligor:i.obligorDID,result:i.valid,verifiedAt:i.verifiedAt}},updateStatus:i.isOverdue&&e.credentialSubject.status===lr.ACTIVE?{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:lr.OVERDUE,updatedAt:i.verifiedAt,reason:"Due date passed"}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareObligationFulfillment:function(e,t,r,n){n=n||{},yr.checkArgument(e&&typeof e=="object","Invalid token"),yr.checkArgument(t&&typeof t=="object","Invalid fulfillment"),yr.checkArgument(r instanceof zx,"Invalid obligor key");try{var i=this.prepareObligationVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot fulfill invalid obligation: "+i.verification.errors.join(", ")};if(e.credentialSubject.status===lr.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(e.credentialSubject.status===lr.TERMINATED)return{success:!1,error:"Obligation has been terminated"};var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationFulfillment"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,fulfillmentType:t.type||"FULL_FULFILLMENT",fulfillmentDate:new Date().toISOString(),evidence:t.evidence||null,description:t.description||"",completionPercentage:t.completionPercentage||100,attestations:t.attestations||[],notes:t.notes||null}},s=this._signToken(o,r),a=o.credentialSubject.completionPercentage>=100?lr.COMPLETED:lr.IN_PROGRESS;return{success:!0,fulfillmentRecord:s,newStatus:a,fulfillmentId:s.id,externalOperations:{recordFulfillment:{endpoint:"POST /obligations/fulfillments",data:{obligationId:e.id,fulfillmentRecord:s,obligor:e.credentialSubject.id,fulfillmentDate:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:a,fulfillmentId:s.id,updatedAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},notifyRightHolder:e.credentialSubject.rightHolder?{endpoint:"POST /notifications/obligation-fulfilled",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,completionPercentage:o.credentialSubject.completionPercentage,newStatus:a}}:null,auditFulfillment:{endpoint:"POST /audit/obligation-fulfillment",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,fulfilledAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}}}}}catch(f){return{success:!1,error:f.message}}},prepareObligationBreachAssessment:function(e,t,r){yr.checkArgument(e&&typeof e=="object","Invalid token"),yr.checkArgument(t&&typeof t=="object","Invalid breach details"),yr.checkArgument(r&&typeof r=="object","Invalid assessor");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationBreachAssessment"],issuer:r.did||r.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,breachType:t.type||"MATERIAL_BREACH",breachDate:t.date||new Date().toISOString(),description:t.description||"",severity:t.severity||"MODERATE",evidence:t.evidence||[],assessor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},damages:t.damages||null,recommendedRemedies:t.recommendedRemedies||[],assessmentDate:new Date().toISOString()}},i=Hp.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return n.credentialSubject.assessmentHash=i,{success:!0,breachAssessment:n,breachId:n.id,severity:t.severity||"MODERATE",externalOperations:{recordBreach:{endpoint:"POST /obligations/breaches",data:{obligationId:e.id,breachAssessment:n,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachDate:t.date||new Date().toISOString(),severity:t.severity||"MODERATE"}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:lr.BREACHED,breachId:n.id,breachDate:t.date||new Date().toISOString(),updatedAt:new Date().toISOString()}},notifyParties:{endpoint:"POST /notifications/obligation-breached",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachType:t.type||"MATERIAL_BREACH",severity:t.severity||"MODERATE"}},escalateBreach:t.severity==="CRITICAL"?{endpoint:"POST /legal/escalate-breach",data:{obligationId:e.id,breachId:n.id,severity:t.severity,jurisdiction:e.credentialSubject.jurisdiction}}:null,auditBreach:{endpoint:"POST /audit/obligation-breach",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,assessedAt:n.credentialSubject.assessmentDate,severity:t.severity||"MODERATE"}}}}}catch(o){return{success:!1,error:o.message}}},prepareObligationMonitoringReport:function(e,t){t=t||{},yr.checkArgument(Array.isArray(e),"Obligations must be array");try{var r={reportId:"rpt_"+this._generateUUID(),generatedAt:new Date().toISOString(),criteria:t,summary:{totalObligations:e.length,byStatus:{},byPriority:{},byType:{},overdue:0,dueSoon:0,completed:0},obligations:[],alerts:[],recommendations:[]},n=new Date,i=new Date(n.getTime()+10080*60*1e3);return e.forEach(function(o){var s={id:o.id,type:o.credentialSubject.obligationType,status:o.credentialSubject.status,priority:o.credentialSubject.priority,obligor:o.credentialSubject.id,dueDate:o.credentialSubject.dueDate,isOverdue:this._checkIfOverdue(o),isDueSoon:!1};if(o.credentialSubject.dueDate){var a=new Date(o.credentialSubject.dueDate);s.isDueSoon=a<=i&&a>n}r.summary.byStatus[s.status]=(r.summary.byStatus[s.status]||0)+1,r.summary.byPriority[s.priority]=(r.summary.byPriority[s.priority]||0)+1,r.summary.byType[s.type]=(r.summary.byType[s.type]||0)+1,s.isOverdue&&r.summary.overdue++,s.isDueSoon&&r.summary.dueSoon++,s.status===lr.COMPLETED&&r.summary.completed++,s.isOverdue&&s.priority===ls.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:o.id,message:"Critical obligation is overdue",priority:"HIGH"}),s.isDueSoon&&s.priority===ls.HIGH&&r.alerts.push({type:"HIGH_PRIORITY_DUE_SOON",obligationId:o.id,message:"High priority obligation due soon",priority:"MEDIUM"}),r.obligations.push(s)}.bind(this)),r.summary.overdue>0&&r.recommendations.push({type:"OVERDUE_MANAGEMENT",message:"Consider prioritizing overdue obligations",count:r.summary.overdue}),r.summary.dueSoon>5&&r.recommendations.push({type:"WORKLOAD_MANAGEMENT",message:"High number of obligations due soon - consider workload distribution",count:r.summary.dueSoon}),{success:!0,report:r,externalOperations:{storeReport:{endpoint:"POST /obligations/monitoring-reports",data:{report:r,generatedAt:r.generatedAt}},sendAlerts:r.alerts.length>0?{endpoint:"POST /notifications/obligation-alerts",data:{reportId:r.reportId,alerts:r.alerts,summary:r.summary}}:null,updateDashboard:{endpoint:"PUT /dashboard/obligation-metrics",data:{summary:r.summary,lastUpdated:r.generatedAt}}}}}catch(o){return{success:!1,error:o.message}}},getObligationTypes:function(){return Dc},getObligationPriority:function(){return ls},getObligationStatus:function(){return lr},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Hp.sha256(d.Buffer.from(r)),i=new Wx;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Hp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=gC(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=dC.fromDER(d.Buffer.from(s[2],"base64url")),f=new Wx;f.hashbuf=i,f.sig=a,f.pubkey=o,f.verify()!==!0&&t.push("Signature verification failed")}catch(l){t.push("Signature verification failed: "+l.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.effectiveDate){var o=new Date(e.credentialSubject.effectiveDate);n<o&&r.push("Obligation not yet effective")}if(e.credentialSubject.expirationDate){var s=new Date(e.credentialSubject.expirationDate);n>s&&t.push("Obligation expired")}},_validateObligationType:function(e,t){if(!e.credentialSubject.obligationType){t.push("Missing obligationType");return}var r=Object.values(Dc);r.includes(e.credentialSubject.obligationType)||t.push("Invalid obligation type: "+e.credentialSubject.obligationType)},_validateObligationStatus:function(e,t,r){if(!e.credentialSubject.status){t.push("Missing status");return}var n=Object.values(lr);n.includes(e.credentialSubject.status)||t.push("Invalid obligation status: "+e.credentialSubject.status),this._checkIfOverdue(e)&&e.credentialSubject.status===lr.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")},_validateObligationPriority:function(e,t){if(e.credentialSubject.priority){var r=Object.values(ls);r.includes(e.credentialSubject.priority)||t.push("Invalid obligation priority: "+e.credentialSubject.priority)}},_checkIfOverdue:function(e){if(!e.credentialSubject.dueDate)return!1;var t=new Date,r=new Date(e.credentialSubject.dueDate);return t>r&&e.credentialSubject.status!==lr.COMPLETED},_generateUUID:function(){return pC.uuid4()}};Uc.ObligationTypes=Dc;Uc.ObligationPriority=ls;Uc.ObligationStatus=lr;Yx.exports=Uc});var Xx=P((wq,Zx)=>{"use strict";p();var ao=Cx(),Fc=Dx(),za=Fx(),Kp=Hx(),dn=Vx(),yC=$x(),Gp=no(),mr=Le(),Pe=function(e){return this instanceof Pe?(this.config=e||{},this.registry=null,this.config.registry&&(this.registry=dn.createRegistry(this.config.registry)),this):new Pe(e)};Pe.prototype.createRightToken=function(e,t,r){mr.checkArgument(e&&typeof e=="object","Invalid right data"),mr.checkArgument(t instanceof Gp,"Invalid private key"),r=r||{};try{var n=ao.create(e.type,e.owner,e.owner,e,t,r);if(!n)return{success:!1,error:"Failed to create token"};if(r.addProof!==!1&&(n=ao._signToken(n,t)),r.anchor){var i=za.anchorToken(n,r.anchor);i.success&&(n.anchorTx=i.txid,n.anchorBlock=i.blockHeight)}if(this.registry&&r.register!==!1){var o=dn.registerToken(this.registry,n,{registeredBy:r.registeredBy||"SYSTEM"});o.success&&(n.registrationId=o.registrationId,n.registrationStatus=o.status)}return{success:!0,token:n,type:"LegalRightToken"}}catch(s){return{success:!1,error:s.message}}};Pe.prototype.validateClaim=function(e,t){return Fc.validate(e,t)};Pe.prototype.createSelectiveDisclosure=function(e,t,r){return Kp.prepareSelectiveDisclosure(e,t,r)};Pe.prototype.verifyToken=function(e,t){return!e||!e.proof?{valid:!1,error:"No proof found in token"}:ao.verifyToken(e,t)};Pe.prototype.transferRight=function(e,t,r,n){mr.checkArgument(e&&typeof e=="object","Invalid token"),mr.checkArgument(typeof t=="string","New owner must be string"),mr.checkArgument(r instanceof Gp,"Invalid owner key"),n=n||{};try{var i=this.verifyToken(e,r.toPublicKey().toString());if(!i.valid)return{success:!1,error:"Invalid token or ownership proof"};var o=ao.prepareRightTokenTransfer(e,t,r,n);if(!o.success)return{success:!1,error:o.error};var s=o.newToken,a=o.transferProof;if(n.anchor){var f=za.anchorToken(s,n.anchor);f.success&&(s.transferAnchorTx=f.txid)}if(this.registry){var l=dn.registerToken(this.registry,s,{registeredBy:n.registeredBy||t,metadata:{transferFrom:e.owner,transferTo:t,originalTokenId:e.id}});l.success&&(s.registrationId=l.registrationId)}return{success:!0,token:s,transferId:a.id,transferredAt:a.issuanceDate,transferProof:a}}catch(m){return{success:!1,error:m.message}}};Pe.prototype.createObligation=function(e,t,r){mr.checkArgument(e&&typeof e=="object","Invalid right token"),mr.checkArgument(t&&typeof t=="object","Invalid obligation data"),mr.checkArgument(r instanceof Gp,"Invalid private key");try{var n=ao.prepareObligationToken(e,t.obligor,t,r);return n.success?{success:!0,obligation:n.obligationToken,rightTokenId:e.id}:{success:!1,error:n.error}}catch(i){return{success:!1,error:i.message}}};Pe.prototype.revokeToken=function(e,t,r){return mr.checkArgument(typeof e=="string","Token ID must be string"),mr.checkArgument(t&&typeof t=="object","Invalid revocation data"),mr.checkArgument(typeof r=="string","Authority must be string"),this.registry?dn.revokeToken(this.registry,e,{reason:t.reason,revokedBy:r,legalBasis:t.legalBasis,evidence:t.evidence}):{success:!1,error:"No registry available for revocation"}};Pe.prototype.checkTokenStatus=function(e){return mr.checkArgument(typeof e=="string","Token ID must be string"),this.registry?dn.checkTokenStatus(this.registry,e):{found:!1,error:"No registry available"}};Pe.prototype.searchTokens=function(e){return this.registry?dn.searchTokens(this.registry,e):{success:!1,error:"No registry available"}};Pe.prototype.getRegistryStats=function(){return this.registry?dn.getStatistics(this.registry):{error:"No registry available"}};Pe.prototype.createLegalValidityProof=function(e,t,r){return Kp.prepareLegalValidityProof(e,t,r)};Pe.prototype.anchorTokenBatch=function(e,t){return za.anchorBatch(e,t)};Pe.prototype.verifyAnchor=function(e,t){return za.verifyAnchor(e,t)};Pe.prototype.getRightTypes=function(){return ao.getRightTypes()};Pe.prototype.getClaimSchemas=function(){return Fc.getSchemas()};Pe.prototype.createRegistry=function(e){return this.registry=dn.createRegistry(e),this.registry};Pe.prototype.setRegistry=function(e){mr.checkArgument(e&&typeof e=="object","Invalid registry"),this.registry=e};Pe.create=function(e){return new Pe(e)};Pe.createRightToken=function(e,t,r){var n=new Pe;return n.createRightToken(e,t,r)};Pe.validateClaim=function(e,t){return Fc.validate(e,t)};Pe.verifyToken=function(e,t){var r=new Pe;return r.verifyToken(e,t)};Pe.createRegistry=function(e){return dn.createRegistry(e)};Pe.Right=ao;Pe.Claim=Fc;Pe.Anchor=za;Pe.Proof=Kp;Pe.Registry=dn;Pe.Obligation=yC;Zx.exports=Pe});var mC=P((Eq,Jx)=>{p();Jx.exports=Xx()});return mC();})();
69
+ `));var a=new pi({actual:e,expected:t,message:r,operator:i,stackStartFn:n});throw a.generatedMessage=s,a}}Ye.match=function e(t,r,n){d1(t,r,n,e,"match")};Ye.doesNotMatch=function e(t,r,n){d1(t,r,n,e,"doesNotMatch")};function p1(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];s1.apply(void 0,[p1,t.length].concat(t))}Ye.strict=q6(p1,Ye,{equal:Ye.strictEqual,deepEqual:Ye.deepStrictEqual,notEqual:Ye.notStrictEqual,notDeepEqual:Ye.notDeepStrictEqual});Ye.strict.strict=Ye.strict});var Ji=B((l5,m1)=>{"use strict";p();var y1=ic(),ot=function e(t){if(!(this instanceof e))return new e(t);this.bufLen=0,t?this.set(t):this.bufs=[]};ot.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this.bufLen=this.bufs.reduce(function(t,r){return t+r.length},0),this};ot.prototype.toBuffer=function(){return this.concat()};ot.prototype.concat=function(){return d.Buffer.concat(this.bufs,this.bufLen)};ot.prototype.write=function(e){return y1(d.Buffer.isBuffer(e)),this.bufs.push(e),this.bufLen+=e.length,this};ot.prototype.writeReverse=function(e){return y1(d.Buffer.isBuffer(e)),this.bufs.push(d.Buffer.from(e).reverse()),this.bufLen+=e.length,this};ot.prototype.writeUInt8=function(e){var t=d.Buffer.alloc(1);return t.writeUInt8(e,0),this.write(t),this};ot.prototype.writeUInt16BE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this};ot.prototype.writeUInt16LE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this};ot.prototype.writeUInt32BE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this};ot.prototype.writeInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e,0),this.write(t),this};ot.prototype.writeUInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this};ot.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this};ot.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this};ot.prototype.writeVarintNum=function(e){var t=ot.varintBufNum(e);return this.write(t),this};ot.prototype.writeVarintBN=function(e){var t=ot.varintBufBN(e);return this.write(t),this};ot.varintBufNum=function(e){var t;return e<253?(t=d.Buffer.alloc(1),t.writeUInt8(e,0)):e<65536?(t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?(t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=d.Buffer.alloc(9),t.writeUInt8(255,0),t.writeInt32LE(e&-1,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t};ot.varintBufBN=function(e){var t,r=e.toNumber();if(r<253)t=d.Buffer.alloc(1),t.writeUInt8(r,0);else if(r<65536)t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(r,1);else if(r<4294967296)t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(r,1);else{var n=new ot;n.writeUInt8(255),n.writeUInt64LEBN(e),t=n.concat()}return t};m1.exports=ot});var fp=B((d5,v1)=>{"use strict";p();var ts=ze(),Ba=Le(),H6=dr();function Ne(e){if(!(this instanceof Ne))return new Ne(e);var t;if(ts.isNumber(e))t=e;else if(ts.isString(e))t=Ne.map[e];else throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');return H6.defineImmutable(this,{num:t}),this}Ne.fromBuffer=function(e){return Ba.checkArgument(d.Buffer.isBuffer(e)),new Ne(+("0x"+e.toString("hex")))};Ne.fromNumber=function(e){return Ba.checkArgument(ts.isNumber(e)),new Ne(e)};Ne.fromString=function(e){Ba.checkArgument(ts.isString(e));var t=Ne.map[e];if(typeof t>"u")throw new TypeError("Invalid opcodestr");return new Ne(t)};Ne.prototype.toHex=function(){return this.num.toString(16)};Ne.prototype.toBuffer=function(){return d.Buffer.from(this.toHex(),"hex")};Ne.prototype.toNumber=function(){return this.num};Ne.prototype.toString=function(){var e=Ne.reverseMap[this.num];if(typeof e>"u")throw new Error("Opcode does not have a string representation");return e};Ne.smallInt=function(e){return Ba.checkArgument(ts.isNumber(e),"Invalid Argument: n should be number"),Ba.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),e===0?Ne("OP_0"):new Ne(Ne.map.OP_1+e-1)};Ne.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_LSHIFTNUM:182,OP_RSHIFTNUM:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};Ne.reverseMap=[];for(up in Ne.map)Ne.reverseMap[Ne.map[up]]=up;var up;ts.extend(Ne,Ne.map);Ne.isSmallIntOp=function(e){return e instanceof Ne&&(e=e.toNumber()),e===Ne.map.OP_0||e>=Ne.map.OP_1&&e<=Ne.map.OP_16};Ne.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"};v1.exports=Ne});var nr=B((g5,_1)=>{"use strict";p();var Qi=wr(),K6=ze(),rr=Le(),G6=dr(),Re=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof Qi)this.set({r:t,s:r});else if(t){var n=t;this.set(n)}};Re.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=typeof e.i<"u"?e.i:this.i,this.compressed=typeof e.compressed<"u"?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this};Re.fromCompact=function(e){rr.checkArgument(d.Buffer.isBuffer(e),"Argument is expected to be a Buffer");var t=new Re,r=!0,n=e.slice(0,1)[0]-27-4;n<0&&(r=!1,n=n+4);var i=e.slice(1,33),o=e.slice(33,65);return rr.checkArgument(n===0||n===1||n===2||n===3,new Error("i must be 0, 1, 2, or 3")),rr.checkArgument(i.length===32,new Error("r must be 32 bytes")),rr.checkArgument(o.length===32,new Error("s must be 32 bytes")),t.compressed=r,t.i=n,t.r=Qi.fromBuffer(i),t.s=Qi.fromBuffer(o),t};Re.fromDER=Re.fromBuffer=function(e,t){var r=Re.parseDER(e,t),n=new Re;return n.r=r.r,n.s=r.s,n};Re.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),n=Re.fromDER(r,!1);return n.nhashtype=t,n};Re.fromString=function(e){var t=d.Buffer.from(e,"hex");return Re.fromDER(t)};function b1(e,t){rr.checkArgument(t.length>0,new Error("Length of "+e+" is zero")),rr.checkArgument(!(t[0]&128),new Error("Value of "+e+" is negative")),rr.checkArgument(!(t.length>1&&t[0]===0&&!(t[1]&128)),new Error("Value of "+e+" is excessively padded"))}Re.parseDER=function(e,t){rr.checkArgument(d.Buffer.isBuffer(e),new Error("DER formatted signature should be a buffer")),K6.isUndefined(t)&&(t=!0);var r=e[0];rr.checkArgument(r===48,new Error("Header byte should be 0x30"));var n=e[1],i=e.slice(2).length;rr.checkArgument(!t||n===i,new Error("Length byte should length of what follows")),n=n<i?n:i;var o=e[2];rr.checkArgument(o===2,new Error("Integer byte for r should be 0x02"));var s=e[3],a=e.slice(4,4+s),f=Qi.fromBuffer(a),l=e[4]===0;rr.checkArgument(s===a.length,new Error("Length of r incorrect"));var m=e[4+s+0];rr.checkArgument(m===2,new Error("Integer byte for s should be 0x02"));var g=e[4+s+1],v=e.slice(4+s+2,4+s+2+g),E=Qi.fromBuffer(v),T=e[4+s+2]===0;rr.checkArgument(g===v.length,new Error("Length of s incorrect"));var N=4+s+2+g;rr.checkArgument(n===N-2,new Error("Length of signature incorrect")),t&&(b1("r",a),b1("s",v));var L={header:r,length:n,rheader:o,rlength:s,rneg:l,rbuf:a,r:f,sheader:m,slength:g,sneg:T,sbuf:v,s:E};return L};Re.prototype.toCompact=function(e,t){if(e=typeof e=="number"?e:this.i,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;t===!1&&(r=r-4);var n=d.Buffer.from([r]),i=this.r.toBuffer({size:32}),o=this.s.toBuffer({size:32});return d.Buffer.concat([n,i,o])};Re.prototype.toBuffer=Re.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(e[0]&128),n=!!(t[0]&128),i=r?d.Buffer.concat([d.Buffer.from([0]),e]):e,o=n?d.Buffer.concat([d.Buffer.from([0]),t]):t,s=i.length,a=o.length,f=2+s+2+a,l=2,m=2,g=48,v=d.Buffer.concat([d.Buffer.from([g,f,l,s]),i,d.Buffer.from([m,a]),o]);return v};Re.prototype.toString=function(){var e=this.toDER();return e.toString("hex")};Re.isTxDER=function(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var n=e.slice(4);if(e[2]!==2||t===0||n[0]&128||t>1&&n[0]===0&&!(n[1]&128))return!1;var i=e.slice(6+t);return!(e[6+t-2]!==2||r===0||i[0]&128||r>1&&i[0]===0&&!(i[1]&128))};Re.prototype.hasLowS=function(){return!(this.s.lt(new Qi(1))||this.s.gt(new Qi("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))};Re.prototype.hasDefinedHashtype=function(){if(!G6.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&31;return!(e<Re.SIGHASH_ALL||e>Re.SIGHASH_SINGLE)};Re.prototype.toTxFormat=function(){var e=this.toDER(),t=d.Buffer.alloc(1);return t.writeUInt8(this.nhashtype,0),d.Buffer.concat([e,t])};Re.SIGHASH_ALL=1;Re.SIGHASH_NONE=2;Re.SIGHASH_SINGLE=3;Re.SIGHASH_CHRONICLE=32;Re.SIGHASH_FORKID=64;Re.SIGHASH_ANYONECANPAY=128;Re.prototype.isCanonical=function(){var e=ai(),t=e.getN().shrn(1);return this.s.lte(t)};Re.prototype.toCanonical=function(){if(this.isCanonical())return new Re({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=ai(),t=e.getN(),r=t.sub(this.s);return new Re({r:this.r,s:r,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})};Re.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=ai(),t=e.getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0};Re.prototype.isValid=function(){try{return this.validate(),!0}catch{return!1}};Re.prototype.applySecurityPatches=function(){var e=ai(),t=e.getN(),r=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");if(this.s.gt(r))throw new Error("Invalid signature: non-canonical (high) s");return this};_1.exports=Re});var hp=B((m5,E1)=>{"use strict";p();var Ur=ro(),V6=ma(),W6=Ji(),cp=Jt(),Q=fp(),to=Or(),eo=nr(),S1=pa(),Xe=Le(),Te=ze(),lp=Zn(),w1=Nt(),z6=dr(),q=function e(t){if(!(this instanceof e))return new e(t);if(this.chunks=[],d.Buffer.isBuffer(t))return e.fromBuffer(t);if(t instanceof Ur)return e.fromAddress(t);if(t instanceof e)return e.fromBuffer(t.toBuffer());if(Te.isString(t))return e.fromString(t);Te.isObject(t)&&Te.isArray(t.chunks)&&this.set(t)};q.prototype.set=function(e){return Xe.checkArgument(Te.isObject(e)),Xe.checkArgument(Te.isArray(e.chunks)),this.chunks=e.chunks,this};q.fromBuffer=function(e){var t=new q;t.chunks=[];for(var r=new V6(e);!r.finished();)try{var n=r.readUInt8(),i,o;n>0&&n<Q.OP_PUSHDATA1?(i=n,t.chunks.push({buf:r.read(i),len:i,opcodenum:n})):n===Q.OP_PUSHDATA1?(i=r.readUInt8(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===Q.OP_PUSHDATA2?(i=r.readUInt16LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===Q.OP_PUSHDATA4?(i=r.readUInt32LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):t.chunks.push({opcodenum:n})}catch(s){throw s instanceof RangeError?new lp.Script.InvalidBuffer(e.toString("hex")):s}return t};q.prototype.toBuffer=function(){for(var e=new W6,t=0;t<this.chunks.length;t++){var r=this.chunks[t],n=r.opcodenum;e.writeUInt8(r.opcodenum),r.buf&&(n<Q.OP_PUSHDATA1?e.write(r.buf):n===Q.OP_PUSHDATA1?(e.writeUInt8(r.len),e.write(r.buf)):n===Q.OP_PUSHDATA2?(e.writeUInt16LE(r.len),e.write(r.buf)):n===Q.OP_PUSHDATA4&&(e.writeUInt32LE(r.len),e.write(r.buf)))}return e.concat()};q.fromASM=function(e){var t=new q;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=Q(i),s=o.toNumber();if(i==="0")s=0,t.chunks.push({opcodenum:s}),n=n+1;else if(i==="-1")s=Q.OP_1NEGATE,t.chunks.push({opcodenum:s}),n=n+1;else if(Te.isUndefined(s)){var a=d.Buffer.from(r[n],"hex");if(a.toString("hex")!==r[n])throw new Error("invalid hex string in script");var f=a.length;f>=0&&f<Q.OP_PUSHDATA1?s=f:f<Math.pow(2,8)?s=Q.OP_PUSHDATA1:f<Math.pow(2,16)?s=Q.OP_PUSHDATA2:f<Math.pow(2,32)&&(s=Q.OP_PUSHDATA4),t.chunks.push({buf:a,len:a.length,opcodenum:s}),n=n+1}else t.chunks.push({opcodenum:s}),n=n+1}return t};q.fromHex=function(e){return new q(w1.Buffer.from(e,"hex"))};q.fromString=function(e){if(z6.isHexa(e)||e.length===0)return new q(w1.Buffer.from(e,"hex"));var t=new q;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=Q(i),s=o.toNumber();if(Te.isUndefined(s))if(s=parseInt(i),s>0&&s<Q.OP_PUSHDATA1)t.chunks.push({buf:d.Buffer.from(r[n+1].slice(2),"hex"),len:s,opcodenum:s}),n=n+2;else throw new Error("Invalid script: "+JSON.stringify(e));else if(s===Q.OP_PUSHDATA1||s===Q.OP_PUSHDATA2||s===Q.OP_PUSHDATA4){if(r[n+2].slice(0,2)!=="0x")throw new Error("Pushdata data must start with 0x");t.chunks.push({buf:d.Buffer.from(r[n+2].slice(2),"hex"),len:parseInt(r[n+1]),opcodenum:s}),n=n+3}else t.chunks.push({opcodenum:s}),n=n+1}return t};q.prototype._chunkToString=function(e,t){var r=e.opcodenum,n=t==="asm",i="";if(e.buf)!n&&(r===Q.OP_PUSHDATA1||r===Q.OP_PUSHDATA2||r===Q.OP_PUSHDATA4)&&(i=i+" "+Q(r).toString()),e.len>0&&(n?i=i+" "+e.buf.toString("hex"):i=i+" "+e.len+" 0x"+e.buf.toString("hex"));else if(typeof Q.reverseMap[r]<"u")n?r===0?i=i+" 0":r===79?i=i+" -1":i=i+" "+Q(r).toString():i=i+" "+Q(r).toString();else{var o=r.toString(16);o.length%2!==0&&(o="0"+o),n?i=i+" "+o:i=i+" 0x"+o}return i};q.prototype.toASM=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r,"asm")}return e.substr(1)};q.prototype.toString=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r)}return e.substr(1)};q.prototype.toHex=function(){return this.toBuffer().toString("hex")};q.prototype.inspect=function(){return"<Script: "+this.toString()+">"};q.prototype.isPublicKeyHashOut=function(){return!!(this.chunks.length===5&&this.chunks[0].opcodenum===Q.OP_DUP&&this.chunks[1].opcodenum===Q.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===Q.OP_EQUALVERIFY&&this.chunks[4].opcodenum===Q.OP_CHECKSIG)};q.prototype.isPublicKeyHashOutPrefix=function(){return!!(this.chunks.length>=5&&this.chunks[0].opcodenum===Q.OP_DUP&&this.chunks[1].opcodenum===Q.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===Q.OP_EQUALVERIFY&&this.chunks[4].opcodenum===Q.OP_CHECKSIG)};q.prototype.isPublicKeyHashIn=function(){if(this.chunks.length===2){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&e[0]===48&&t&&t.length){var r=t[0];if((r===4||r===6||r===7)&&t.length===65)return!0;if((r===3||r===2)&&t.length===33)return!0}}return!1};q.prototype.getPublicKey=function(){return Xe.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf};q.prototype.getPublicKeyHash=function(){return Xe.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf};q.prototype.isPublicKeyOut=function(){if(this.chunks.length===2&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===Q.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if(((t===4||t===6||t===7)&&e.length===65||(t===3||t===2)&&e.length===33)&&(r=!0),r)return to.isValid(e)}return!1};q.prototype.isPublicKeyIn=function(){if(this.chunks.length===1){var e=this.chunks[0].buf;if(e&&e.length&&e[0]===48)return!0}return!1};q.prototype.isScriptHashOut=function(){var e=this.toBuffer();return e.length===23&&e[0]===Q.OP_HASH160&&e[1]===20&&e[e.length-1]===Q.OP_EQUAL};q.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e=this.chunks[this.chunks.length-1],t=e.buf;if(!t)return!1;var r;try{r=q.fromBuffer(t)}catch(i){if(i instanceof lp.Script.InvalidBuffer)return!1;throw i}var n=r.classify();return n!==q.types.UNKNOWN};q.prototype.isMultisigOut=function(){return this.chunks.length>3&&Q.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)})&&Q.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===Q.OP_CHECKMULTISIG};q.prototype.isMultisigIn=function(){return this.chunks.length>=2&&this.chunks[0].opcodenum===0&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)&&eo.isTxDER(e.buf)})};q.prototype.isDataOut=function(){var e=this.chunks.length>=1&&this.chunks[0].opcodenum===Q.OP_RETURN;if(!e)return!1;var t=this.chunks.slice(1),r=new q({chunks:t});return r.isPushOnly()};q.prototype.isSafeDataOut=function(){if(this.chunks.length<2||this.chunks[0].opcodenum!==Q.OP_FALSE)return!1;var e=this.chunks.slice(1),t=new q({chunks:e});return t.isDataOut()};q.prototype.getData=function(){if(this.isSafeDataOut()){var e=this.chunks.slice(2),t=e.map(r=>r.buf);return t}if(this.isDataOut()||this.isScriptHashOut())return Te.isUndefined(this.chunks[1])?d.Buffer.alloc(0):d.Buffer.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return d.Buffer.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")};q.prototype.isPushOnly=function(){return Te.every(this.chunks,function(e){return e.opcodenum<=Q.OP_16||e.opcodenum===Q.OP_PUSHDATA1||e.opcodenum===Q.OP_PUSHDATA2||e.opcodenum===Q.OP_PUSHDATA4})};q.types={};q.types.UNKNOWN="Unknown";q.types.PUBKEY_OUT="Pay to public key";q.types.PUBKEY_IN="Spend from public key";q.types.PUBKEYHASH_OUT="Pay to public key hash";q.types.PUBKEYHASH_IN="Spend from public key hash";q.types.SCRIPTHASH_OUT="Pay to script hash";q.types.SCRIPTHASH_IN="Spend from script hash";q.types.MULTISIG_OUT="Pay to multisig";q.types.MULTISIG_IN="Spend from multisig";q.types.DATA_OUT="Data push";q.types.SAFE_DATA_OUT="Safe data push";q.OP_RETURN_STANDARD_SIZE=220;q.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!==q.types.UNKNOWN?e:this.classifyInput()};q.outputIdentifiers={};q.outputIdentifiers.PUBKEY_OUT=q.prototype.isPublicKeyOut;q.outputIdentifiers.PUBKEYHASH_OUT=q.prototype.isPublicKeyHashOut;q.outputIdentifiers.MULTISIG_OUT=q.prototype.isMultisigOut;q.outputIdentifiers.SCRIPTHASH_OUT=q.prototype.isScriptHashOut;q.outputIdentifiers.DATA_OUT=q.prototype.isDataOut;q.outputIdentifiers.SAFE_DATA_OUT=q.prototype.isSafeDataOut;q.prototype.classifyOutput=function(){for(var e in q.outputIdentifiers)if(q.outputIdentifiers[e].bind(this)())return q.types[e];return q.types.UNKNOWN};q.inputIdentifiers={};q.inputIdentifiers.PUBKEY_IN=q.prototype.isPublicKeyIn;q.inputIdentifiers.PUBKEYHASH_IN=q.prototype.isPublicKeyHashIn;q.inputIdentifiers.MULTISIG_IN=q.prototype.isMultisigIn;q.inputIdentifiers.SCRIPTHASH_IN=q.prototype.isScriptHashIn;q.prototype.classifyInput=function(){for(var e in q.inputIdentifiers)if(q.inputIdentifiers[e].bind(this)())return q.types[e];return q.types.UNKNOWN};q.prototype.isStandard=function(){return this.classify()!==q.types.UNKNOWN};q.prototype.prepend=function(e){return this._addByType(e,!0),this};q.prototype.equals=function(e){if(Xe.checkState(e instanceof q,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t<this.chunks.length;t++){if(d.Buffer.isBuffer(this.chunks[t].buf)&&!d.Buffer.isBuffer(e.chunks[t].buf)||d.Buffer.isBuffer(this.chunks[t].buf)&&!this.chunks[t].buf.equals(e.chunks[t].buf))return!1;if(this.chunks[t].opcodenum!==e.chunks[t].opcodenum)return!1}return!0};q.prototype.add=function(e){return this._addByType(e,!1),this};q.prototype._addByType=function(e,t){if(typeof e=="string")this._addOpcode(e,t);else if(typeof e=="number")this._addOpcode(e,t);else if(e instanceof Q)this._addOpcode(e,t);else if(d.Buffer.isBuffer(e))this._addBuffer(e,t);else if(e instanceof q)this.chunks=this.chunks.concat(e.chunks);else if(typeof e=="object")this._insertAtPosition(e,t);else throw new Error("Invalid script chunk")};q.prototype._insertAtPosition=function(e,t){t?this.chunks.unshift(e):this.chunks.push(e)};q.prototype._addOpcode=function(e,t){var r;return typeof e=="number"?r=e:e instanceof Q?r=e.toNumber():r=Q(e).toNumber(),this._insertAtPosition({opcodenum:r},t),this};q.prototype._addBuffer=function(e,t){var r,n=e.length;if(n>=0&&n<Q.OP_PUSHDATA1)r=n;else if(n<Math.pow(2,8))r=Q.OP_PUSHDATA1;else if(n<Math.pow(2,16))r=Q.OP_PUSHDATA2;else if(n<Math.pow(2,32))r=Q.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this._insertAtPosition({buf:e,len:n,opcodenum:r},t),this};q.prototype.removeCodeseparators=function(){for(var e=[],t=0;t<this.chunks.length;t++)this.chunks[t].opcodenum!==Q.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this};q.buildMultisigOut=function(e,t,r){Xe.checkArgument(t<=e.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var n=new q;n.add(Q.smallInt(t)),e=Te.map(e,to);var i=e;r.noSorting||(i=e.map(a=>a.toString("hex")).sort().map(a=>new to(a)));for(var o=0;o<i.length;o++){var s=i[o];n.add(s.toBuffer())}return n.add(Q.smallInt(e.length)),n.add(Q.OP_CHECKMULTISIG),n};q.buildMultisigIn=function(e,t,r,n){Xe.checkArgument(Te.isArray(e)),Xe.checkArgument(Te.isNumber(t)),Xe.checkArgument(Te.isArray(r)),n=n||{};var i=new q;return i.add(Q.OP_0),Te.each(r,function(o){Xe.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i};q.buildP2SHMultisigIn=function(e,t,r,n){Xe.checkArgument(Te.isArray(e)),Xe.checkArgument(Te.isNumber(t)),Xe.checkArgument(Te.isArray(r)),n=n||{};var i=new q;return i.add(Q.OP_0),Te.each(r,function(o){Xe.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i.add((n.cachedMultisig||q.buildMultisigOut(e,t,n)).toBuffer()),i};q.buildPublicKeyHashOut=function(e){Xe.checkArgument(!Te.isUndefined(e)),Xe.checkArgument(e instanceof to||e instanceof Ur||Te.isString(e)),e instanceof to?e=e.toAddress():Te.isString(e)&&(e=new Ur(e));var t=new q;return t.add(Q.OP_DUP).add(Q.OP_HASH160).add(e.hashBuffer).add(Q.OP_EQUALVERIFY).add(Q.OP_CHECKSIG),t._network=e.network,t};q.buildPublicKeyOut=function(e){Xe.checkArgument(e instanceof to);var t=new q;return t.add(e.toBuffer()).add(Q.OP_CHECKSIG),t};q.buildDataOut=function(e,t){Xe.checkArgument(Te.isUndefined(e)||Te.isString(e)||Te.isArray(e)||d.Buffer.isBuffer(e));var r=e;Te.isArray(r)||(r=[e]);var n=new q;n.add(Q.OP_RETURN);for(let i of r)Xe.checkArgument(Te.isUndefined(i)||Te.isString(i)||d.Buffer.isBuffer(i)),Te.isString(i)&&(i=d.Buffer.from(i,t)),Te.isUndefined(i)||n.add(i);return n};q.buildSafeDataOut=function(e,t){var r=q.buildDataOut(e,t),n=new q;return n.add(Q.OP_FALSE),n.add(r),n};q.buildScriptHashOut=function(e){Xe.checkArgument(e instanceof q||e instanceof Ur&&e.isPayToScriptHash());var t=new q;return t.add(Q.OP_HASH160).add(e instanceof Ur?e.hashBuffer:cp.sha256ripemd160(e.toBuffer())).add(Q.OP_EQUAL),t._network=e._network||e.network,t};q.buildPublicKeyIn=function(e,t){Xe.checkArgument(e instanceof eo||d.Buffer.isBuffer(e)),Xe.checkArgument(Te.isUndefined(t)||Te.isNumber(t)),e instanceof eo&&(e=e.toBuffer());var r=new q;return r.add(d.Buffer.concat([e,d.Buffer.from([(t||eo.SIGHASH_ALL)&255])])),r};q.buildPublicKeyHashIn=function(e,t,r){Xe.checkArgument(t instanceof eo||d.Buffer.isBuffer(t)),Xe.checkArgument(Te.isUndefined(r)||Te.isNumber(r)),t instanceof eo&&(t=t.toBuffer());var n=new q().add(d.Buffer.concat([t,d.Buffer.from([(r||eo.SIGHASH_ALL)&255])])).add(new to(e).toBuffer());return n};q.empty=function(){return new q};q.prototype.toScriptHashOut=function(){return q.buildScriptHashOut(this)};q.fromAddress=function(e){if(e=Ur(e),e.isPayToScriptHash())return q.buildScriptHashOut(e);if(e.isPayToPublicKeyHash())return q.buildPublicKeyHashOut(e);throw new lp.Script.UnrecognizedAddress(e)};q.prototype.getAddressInfo=function(e){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var t=this._getOutputAddressInfo();return t||this._getInputAddressInfo()};q.prototype._getOutputAddressInfo=function(){var e={};if(this.isScriptHashOut())e.hashBuffer=this.getData(),e.type=Ur.PayToScriptHash;else if(this.isPublicKeyHashOut())e.hashBuffer=this.getData(),e.type=Ur.PayToPublicKeyHash;else return!1;return e};q.prototype._getInputAddressInfo=function(){var e={};if(this.isPublicKeyHashIn())e.hashBuffer=cp.sha256ripemd160(this.chunks[1].buf),e.type=Ur.PayToPublicKeyHash;else if(this.isScriptHashIn())e.hashBuffer=cp.sha256ripemd160(this.chunks[this.chunks.length-1].buf),e.type=Ur.PayToScriptHash;else return!1;return e};q.prototype.toAddress=function(e){var t=this.getAddressInfo();return t?(t.network=S1.get(e)||this._network||S1.defaultNetwork,new Ur(t)):!1};q.prototype.findAndDelete=function(e){for(var t=e.toBuffer(),r=t.toString("hex"),n=0;n<this.chunks.length;n++){var i=q({chunks:[this.chunks[n]]}),o=i.toBuffer(),s=o.toString("hex");r===s&&this.chunks.splice(n,1)}return this};q.prototype.checkMinimalPush=function(e){var t=this.chunks[e],r=t.buf,n=t.opcodenum;return r?r.length===0?n===Q.OP_0:r.length===1&&r[0]>=1&&r[0]<=16?n===Q.OP_1+(r[0]-1):r.length===1&&r[0]===129?n===Q.OP_1NEGATE:r.length<=75?n===r.length:r.length<=255?n===Q.OP_PUSHDATA1:r.length<=65535?n===Q.OP_PUSHDATA2:!0:!0};q.prototype._decodeOP_N=function(e){if(e===Q.OP_0)return 0;if(e>=Q.OP_1&&e<=Q.OP_16)return e-(Q.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))};q.prototype.getSignatureOperationsCount=function(e){e=Te.isUndefined(e)?!0:e;var t=this,r=0,n=Q.OP_INVALIDOPCODE;return Te.each(t.chunks,function(o){var s=o.opcodenum;s===Q.OP_CHECKSIG||s===Q.OP_CHECKSIGVERIFY?r++:(s===Q.OP_CHECKMULTISIG||s===Q.OP_CHECKMULTISIGVERIFY)&&(e&&n>=Q.OP_1&&n<=Q.OP_16?r+=t._decodeOP_N(n):r+=20),n=s}),r};E1.exports=q});var Na=B((b5,O1)=>{"use strict";p();var x1=Ji(),I1=ma(),Y6=wr(),Fr=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t))this.buf=t;else if(typeof t=="number"){var r=t;this.fromNumber(r)}else if(t instanceof Y6){var n=t;this.fromBN(n)}else if(t){var i=t;this.set(i)}};Fr.prototype.set=function(e){return this.buf=e.buf||this.buf,this};Fr.prototype.fromString=function(e){return this.set({buf:d.Buffer.from(e,"hex")}),this};Fr.prototype.toString=function(){return this.buf.toString("hex")};Fr.prototype.fromBuffer=function(e){return this.buf=e,this};Fr.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this};Fr.prototype.fromBN=function(e){return this.buf=x1().writeVarintBN(e).concat(),this};Fr.prototype.fromNumber=function(e){return this.buf=x1().writeVarintNum(e).concat(),this};Fr.prototype.toBuffer=function(){return this.buf};Fr.prototype.toBN=function(){return I1(this.buf).readVarintBN()};Fr.prototype.toNumber=function(){return I1(this.buf).readVarintNum()};O1.exports=Fr});var Cn=B((S5,R1)=>{"use strict";p();var wc=ze(),dp=wr(),A1=Nt(),Ec=dr(),$6=Ji(),Z6=Na(),pp=qr(),gp=Le(),X6=Zn(),J6=9007199254740991;function Ht(e){if(!(this instanceof Ht))return new Ht(e);if(wc.isObject(e))if(this.satoshis=e.satoshis,d.Buffer.isBuffer(e.script))this._scriptBuffer=e.script;else{var t;wc.isString(e.script)&&Ec.isHexa(e.script)?t=A1.Buffer.from(e.script,"hex"):t=e.script,this.setScript(t)}else throw new TypeError("Unrecognized argument for Output")}Object.defineProperty(Ht.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}});Object.defineProperty(Ht.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof dp?(this._satoshisBN=e,this._satoshis=e.toNumber()):wc.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=dp.fromNumber(this._satoshis)):(gp.checkArgument(Ec.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=dp.fromNumber(e),this._satoshis=e),gp.checkState(Ec.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Ht.prototype.invalidSatoshis=function(){return this._satoshis>J6?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0?"transaction txout negative":!1};Object.defineProperty(Ht.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),gp.checkState(Ec.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Ht.prototype.toObject=Ht.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t};Ht.fromObject=function(e){return new Ht(e)};Ht.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=pp.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(t instanceof X6.Script.InvalidBuffer)this._script=null;else throw t}};Ht.prototype.setScript=function(e){if(e instanceof pp)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(wc.isString(e))this._script=pp.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else if(d.Buffer.isBuffer(e))this.setScriptFromBuffer(e);else throw new TypeError("Invalid argument type: script");return this};Ht.prototype.inspect=function(){var e;return this.script?e=this.script.inspect():e=this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+e+">"};Ht.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return r!==0?t.script=e.read(r):t.script=A1.Buffer.from([]),new Ht(t)};Ht.prototype.toBufferWriter=function(e){e||(e=new $6),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e};Ht.prototype.getSize=function(){var e=this.script.toBuffer().length,t=Z6(e).toBuffer().length;return 8+t+e};R1.exports=Ht});var Ma=B((E5,T1)=>{"use strict";p();var pr=wr(),cn=ai(),Q6=nr(),ek=Or(),tk=Xs(),gi=Jt(),rk=ze(),yp=Le(),Ke=function e(t){if(!(this instanceof e))return new e(t);t&&this.set(t)};Object.defineProperty(Ke.prototype,"k",{get:function(){return this._k},set:function(e){this._k=e,this._kFresh=!0},enumerable:!0,configurable:!0});Ke.prototype.set=function(e){if(this.hashbuf=e.hashbuf||this.hashbuf,this.endian=e.endian||this.endian,this.privkey=e.privkey||this.privkey,this.pubkey=e.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),e.sig)if(d.Buffer.isBuffer(e.sig)){var t=nr();this.sig=t.fromDER(e.sig)}else this.sig=e.sig;else this.sig=this.sig;return e.k&&(this.k=e.k),this.verified=e.verified||this.verified,this};Ke.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()};Ke.prototype.calci=function(){for(var e=0;e<4;e++){this.sig.i=e;var t;try{t=this.toPublicKey()}catch(r){console.error(r);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")};Ke.fromString=function(e){var t=JSON.parse(e);return new Ke(t)};Ke.prototype.randomK=function(){var e=cn.getN(),t;do t=pr.fromBuffer(tk.getRandomBuffer(32));while(!(t.lt(e)&&t.gt(pr.Zero)));return this.k=t,this};Ke.prototype.deterministicK=function(e){rk.isUndefined(e)&&(e=0);var t=d.Buffer.alloc(32);t.fill(1);var r=d.Buffer.alloc(32);r.fill(0);var n=this.privkey.bn.toBuffer({size:32}),i=this.endian==="little"?d.Buffer.from(this.hashbuf).reverse():this.hashbuf;r=gi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0]),n,i]),r),t=gi.sha256hmac(t,r),r=gi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([1]),n,i]),r),t=gi.sha256hmac(t,r),t=gi.sha256hmac(t,r);for(var o=pr.fromBuffer(t),s=cn.getN(),a=0;a<e||!(o.lt(s)&&o.gt(pr.Zero));a++)r=gi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0])]),r),t=gi.sha256hmac(t,r),t=gi.sha256hmac(t,r),o=pr.fromBuffer(t);return this.k=o,this};Ke.prototype.toPublicKey=function(){var e=this.sig.i;yp.checkArgument(e===0||e===1||e===2||e===3,new Error("i must be equal to 0, 1, 2, or 3"));var t=pr.fromBuffer(this.hashbuf),r=this.sig.r,n=this.sig.s,i=e&1,o=e>>1,s=cn.getN(),a=cn.getG(),f=o?r.add(s):r,l=cn.fromX(i,f),m=l.mul(s);if(!m.isInfinity())throw new Error("nR is not a valid curve point");var g=t.neg().umod(s),v=r.invm(s),E=l.mul(n).add(a.mul(g)).mul(v),T=ek.fromPoint(E,this.sig.compressed);return T};Ke.prototype.sigError=function(){if(!d.Buffer.isBuffer(this.hashbuf)||this.hashbuf.length!==32)return"hashbuf must be a 32 byte buffer";var e=this.sig.r,t=this.sig.s,r=cn.getN();try{if(e.lte(pr.Zero)||t.lte(pr.Zero)||e.gte(r)||t.gte(r))return"r and s not in range";var n=pr.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),i=t.invm(r),o=i.mul(n).umod(r),s=i.mul(e).umod(r),a=cn.getG().mulAdd(o,this.pubkey.point,s);return a.isInfinity()?"p is infinity":a.getX().umod(r).cmp(e)!==0?"Invalid signature":!1}catch(f){return"Signature security validation failed: "+f.message}};Ke.toLowS=function(e){return e.gt(pr.fromBuffer(d.Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=cn.getN().sub(e)),e};Ke.prototype._findSignature=function(e,t){var r=cn.getN(),n=cn.getG(),i=0,o,s,a,f;do(!this.k||!this._kFresh||i>0)&&this.deterministicK(i),i++,o=this.k,s=n.mul(o),a=s.x.umod(r),f=o.invm(r).mul(t.add(e.mul(a))).umod(r);while(a.cmp(pr.Zero)<=0||f.cmp(pr.Zero)<=0);return this._kFresh=!1,f=Ke.toLowS(f),{s:f,r:a}};Ke.prototype.sign=function(){var e=this.hashbuf,t=this.privkey,r=t.bn;yp.checkState(e&&t&&r,new Error("invalid parameters")),yp.checkState(d.Buffer.isBuffer(e)&&e.length===32,new Error("hashbuf must be a 32 byte buffer"));var n=pr.fromBuffer(e,this.endian?{endian:this.endian}:void 0),i=this._findSignature(r,n);return i.compressed=this.pubkey.compressed,this.sig=new Q6(i),this};Ke.prototype.signRandomK=function(){return this.randomK(),this.sign()};Ke.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)};Ke.prototype.verify=function(){return this.verified=!this.sigError(),this.verified};Ke.prototype.verifyBool=function(){return this.verify()===!0};Ke.sign=function(e,t,r){return Ke().set({hashbuf:e,endian:r,privkey:t}).sign().sig};Ke.signWithCalcI=function(e,t,r){return Ke().set({hashbuf:e,endian:r,privkey:t}).sign().calci().sig};Ke.signRandomK=function(e,t,r){return Ke().set({hashbuf:e,endian:r,privkey:t}).signRandomK().sig};Ke.verify=function(e,t,r,n){return Ke().set({hashbuf:e,endian:n,sig:t,pubkey:r}).verify()};T1.exports=Ke});var rs=B((I5,M1)=>{"use strict";p();var yi=ze(),nk=Le(),ka=Zn(),ik=Ji(),mp=Nt(),B1=dr(),xc=qr(),ok=mi(),P1=Cn(),Ic=4294967295,sk=Ic-2,N1=Ic,ak=Ic-1;function Ge(e){if(!(this instanceof Ge))return new Ge(e);if(e)return this._fromObject(e)}Ge.MAXINT=Ic;Ge.DEFAULT_SEQNUMBER=N1;Ge.DEFAULT_LOCKTIME_SEQNUMBER=ak;Ge.DEFAULT_RBF_SEQNUMBER=sk;Ge.BASE_SIZE=40;Object.defineProperty(Ge.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new xc(this._scriptBuffer),this._script._isInput=!0),this._script)}});Ge.fromObject=function(e){nk.checkArgument(yi.isObject(e));var t=new Ge;return t._fromObject(e)};Ge.prototype._fromObject=function(e){var t;if(yi.isString(e.prevTxId)&&B1.isHexa(e.prevTxId)?t=mp.Buffer.from(e.prevTxId,"hex"):t=e.prevTxId,this.output=e.output?e.output instanceof P1?e.output:new P1(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=yi.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=yi.isUndefined(e.sequenceNumber)?yi.isUndefined(e.seqnum)?N1:e.seqnum:e.sequenceNumber,yi.isUndefined(e.script)&&yi.isUndefined(e.scriptBuffer))throw new ka.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this};Ge.prototype.toObject=Ge.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t};Ge.fromBufferReader=function(e){var t=new Ge;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t};Ge.prototype.toBufferWriter=function(e){e||(e=new ik),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e};Ge.prototype.setScript=function(e){if(this._script=null,e instanceof xc)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(e===null)this._script=xc.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(B1.isHexa(e))this._scriptBuffer=mp.Buffer.from(e,"hex");else if(yi.isString(e))this._script=new xc(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(d.Buffer.isBuffer(e))this._scriptBuffer=mp.Buffer.from(e);else throw new TypeError("Invalid argument type: script");return this};Ge.prototype.getSignatures=function(){throw new ka.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))};Ge.prototype.isFullySigned=function(){throw new ka.AbstractMethodInvoked("Input#isFullySigned")};Ge.prototype.isFinal=function(){return this.sequenceNumber===Ge.MAXINT};Ge.prototype.addSignature=function(){throw new ka.AbstractMethodInvoked("Input#addSignature")};Ge.prototype.clearSignatures=function(){throw new ka.AbstractMethodInvoked("Input#clearSignatures")};Ge.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,ok.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Ge.prototype.isNull=function(){return this.prevTxId.toString("hex")==="0000000000000000000000000000000000000000000000000000000000000000"&&this.outputIndex===4294967295};Ge.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length};M1.exports=Ge});var ns=B((A5,k1)=>{"use strict";p();k1.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}});var os=B((T5,D1)=>{"use strict";p();var is=ze(),Ar=Le(),uk=ns(),C1=dr(),L1=Or(),fk=Zn(),Ca=nr();function jr(e){if(!(this instanceof jr))return new jr(e);if(e instanceof jr)return e;if(is.isObject(e))return this._fromObject(e);throw new fk.InvalidArgument("TransactionSignatures must be instantiated from an object")}uk(jr,Ca);jr.prototype._fromObject=function(e){return this._checkObjectArgs(e),this.publicKey=new L1(e.publicKey),this.prevTxId=d.Buffer.isBuffer(e.prevTxId)?e.prevTxId:d.Buffer.from(e.prevTxId,"hex"),this.outputIndex=e.outputIndex,this.inputIndex=e.inputIndex,this.signature=e.signature instanceof Ca?e.signature:d.Buffer.isBuffer(e.signature)?Ca.fromBuffer(e.signature):Ca.fromString(e.signature),this.sigtype=e.sigtype,this};jr.prototype._checkObjectArgs=function(e){Ar.checkArgument(L1(e.publicKey),"publicKey"),Ar.checkArgument(!is.isUndefined(e.inputIndex),"inputIndex"),Ar.checkArgument(!is.isUndefined(e.outputIndex),"outputIndex"),Ar.checkState(is.isNumber(e.inputIndex),"inputIndex must be a number"),Ar.checkState(is.isNumber(e.outputIndex),"outputIndex must be a number"),Ar.checkArgument(e.signature,"signature"),Ar.checkArgument(e.prevTxId,"prevTxId"),Ar.checkState(e.signature instanceof Ca||d.Buffer.isBuffer(e.signature)||C1.isHexa(e.signature),"signature must be a buffer or hexa value"),Ar.checkState(d.Buffer.isBuffer(e.prevTxId)||C1.isHexa(e.prevTxId),"prevTxId must be a buffer or hexa value"),Ar.checkArgument(e.sigtype,"sigtype"),Ar.checkState(is.isNumber(e.sigtype),"sigtype must be a number")};jr.prototype.toObject=jr.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}};jr.fromObject=function(e){return Ar.checkArgument(e),new jr(e)};D1.exports=jr});var H1=B((B5,j1)=>{"use strict";p();var ck=ns(),F1=Le(),vp=rs(),lk=Cn(),hk=mi(),q1=qr(),U1=nr(),dk=os();function Ln(){vp.apply(this,arguments)}ck(Ln,vp);Ln.prototype.getSignatures=function(e,t,r,n){F1.checkState(this.output instanceof lk),n=n||U1.SIGHASH_ALL|U1.SIGHASH_FORKID;var i=t.toPublicKey();return i.toString()===this.output.script.getPublicKey().toString("hex")?[new dk({publicKey:i,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:hk.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Ln.prototype.addSignature=function(e,t){return F1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(q1.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this};Ln.prototype.clearSignatures=function(){return this.setScript(q1.empty()),this};Ln.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()};Ln.SCRIPT_MAX_SIZE=74;Ln.prototype._estimateSize=function(){return vp.BASE_SIZE+Ln.SCRIPT_MAX_SIZE};j1.exports=Ln});var z1=B((M5,W1)=>{"use strict";p();var pk=ns(),G1=Le(),gk=Jt(),bp=rs(),yk=Cn(),mk=mi(),V1=qr(),K1=nr(),vk=os();function Dn(){bp.apply(this,arguments)}pk(Dn,bp);Dn.prototype.getSignatures=function(e,t,r,n,i){G1.checkState(this.output instanceof yk),i=i||gk.sha256ripemd160(t.publicKey.toBuffer()),n=n||K1.SIGHASH_ALL|K1.SIGHASH_FORKID;var o=this.output.script.chunks[2]&&this.output.script.chunks[2].buf;return o&&i.equals(o)?[new vk({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:mk.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Dn.prototype.addSignature=function(e,t){return G1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(V1.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this};Dn.prototype.clearSignatures=function(){return this.setScript(V1.empty()),this};Dn.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()};Dn.SCRIPT_MAX_SIZE=108;Dn.prototype._estimateSize=function(){return bp.BASE_SIZE+Dn.SCRIPT_MAX_SIZE};W1.exports=Dn});var Z1=B((C5,$1)=>{"use strict";p();var Hr=ze(),bk=ns(),Ac=rs(),_k=Cn(),La=Le(),Y1=qr(),Oc=nr(),_p=mi(),Sp=os(),Sk=Or(),wk=Na();function Ct(e,t,r,n){Ac.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new Sk(o)),La.checkState(Y1.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},Hr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}bk(Ct,Ac);Ct.prototype.toObject=function(){var e=Ac.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Hr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Ct.prototype._deserializeSignatures=function(e){return Hr.map(e,function(t){if(t)return new Sp(t)})};Ct.prototype._serializeSignatures=function(){return Hr.map(this.signatures,function(e){if(e)return e.toObject()})};Ct.prototype.getSignatures=function(e,t,r,n){La.checkState(this.output instanceof _k),n=n||Oc.SIGHASH_ALL|Oc.SIGHASH_FORKID;var i=this,o=[];return Hr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new Sp({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:_p.sign(e,t,n,r,i.output.script,i.output.satoshisBN),sigtype:n}))}),o};Ct.prototype.addSignature=function(e,t){return La.checkState(!this.isFullySigned(),"All needed signatures have already been added"),La.checkArgument(!Hr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),La.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Ct.prototype._updateScript=function(){return this.setScript(Y1.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this};Ct.prototype._createSignatures=function(){return Hr.map(Hr.filter(this.signatures,function(e){return!Hr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Ct.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Ct.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Ct.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Ct.prototype.countSignatures=function(){return Hr.reduce(this.signatures,function(e,t){return e+!!t},0)};Ct.prototype.publicKeysWithoutSignature=function(){var e=this;return Hr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Ct.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,_p.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Ct.normalizeSignatures=function(e,t,r,n,i){return i.map(function(o){var s=null;return n=n.filter(function(a){if(s)return!0;var f=new Sp({signature:Oc.fromTxFormat(a),publicKey:o,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:Oc.SIGHASH_ALL});f.signature.nhashtype=f.sigtype;var l=_p.verify(e,f.signature,f.publicKey,f.inputIndex,t.output.script);return l?(s=f,!1):!0}),s||null})};Ct.SIGNATURE_SIZE=73;Ct.prototype._estimateSize=function(){var e=1+this.threshold*Ct.SIGNATURE_SIZE;return Ac.BASE_SIZE+wk(e).toBuffer().length+e};$1.exports=Ct});var tx=B((D5,ex)=>{"use strict";p();var Kr=ze(),Ek=ns(),Rc=rs(),xk=Cn(),Da=Le(),wp=qr(),X1=nr(),J1=mi(),Q1=os(),Ik=Or(),Ok=Na();function Pt(e,t,r,n){Rc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new Ik(o)),this.redeemScript=wp.buildMultisigOut(this.publicKeys,r),Da.checkState(wp.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},Kr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}Ek(Pt,Rc);Pt.prototype.toObject=function(){var e=Rc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Kr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Pt.prototype._deserializeSignatures=function(e){return Kr.map(e,function(t){if(t)return new Q1(t)})};Pt.prototype._serializeSignatures=function(){return Kr.map(this.signatures,function(e){if(e)return e.toObject()})};Pt.prototype.getSignatures=function(e,t,r,n){Da.checkState(this.output instanceof xk),n=n||X1.SIGHASH_ALL|X1.SIGHASH_FORKID;var i=this,o=[];return Kr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new Q1({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:J1.sign(e,t,n,r,i.redeemScript,i.output.satoshisBN),sigtype:n}))}),o};Pt.prototype.addSignature=function(e,t){return Da.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Da.checkArgument(!Kr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Da.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Pt.prototype._updateScript=function(){return this.setScript(wp.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this};Pt.prototype._createSignatures=function(){return Kr.map(Kr.filter(this.signatures,function(e){return!Kr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Pt.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Pt.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Pt.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Pt.prototype.countSignatures=function(){return Kr.reduce(this.signatures,function(e,t){return e+!!t},0)};Pt.prototype.publicKeysWithoutSignature=function(){var e=this;return Kr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Pt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,J1.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)};Pt.SIGNATURE_SIZE=73;Pt.PUBKEY_SIZE=34;Pt.prototype._estimateSize=function(){var e=this.publicKeys.length*Pt.PUBKEY_SIZE,t=this.threshold*Pt.SIGNATURE_SIZE,r=3+e,n=r<=75?1:r<=255?2:3,i=t+1+n+r;return Rc.BASE_SIZE+Ok(i).toBuffer().length+i};ex.exports=Pt});var Tc=B((F5,ss)=>{p();ss.exports=rs();ss.exports.PublicKey=H1();ss.exports.PublicKeyHash=z1();ss.exports.MultiSig=Z1();ss.exports.MultiSigScriptHash=tx()});var mi=B((j5,sx)=>{"use strict";p();var Ak=Nt(),fr=nr(),Ep=qr(),Rk=Cn(),Tk=ma(),Ua=Ji(),rx=wr(),Pc=Jt(),nx=Ma(),xp=Le(),Ip=Bc(),vi=ze(),ix=d.Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),Pk="ffffffffffffffff",Bk=Ip.SCRIPT_ENABLE_SIGHASH_FORKID,Nk=function(e,t,r,n,i){var o=e.inputs[r];xp.checkArgument(i instanceof rx,"For ForkId=0 signatures, satoshis or complete input must be provided");function s(N){var L=new Ua;vi.each(N.inputs,function(z){L.writeReverse(z.prevTxId),L.writeUInt32LE(z.outputIndex)});var F=L.toBuffer(),V=Pc.sha256sha256(F);return V}function a(N){var L=new Ua;vi.each(N.inputs,function(z){L.writeUInt32LE(z.sequenceNumber)});var F=L.toBuffer(),V=Pc.sha256sha256(F);return V}function f(N,L){var F=new Ua;vi.isUndefined(L)?vi.each(N.outputs,function(W){W.toBufferWriter(F)}):N.outputs[L].toBufferWriter(F);var V=F.toBuffer(),z=Pc.sha256sha256(V);return z}var l=d.Buffer.alloc(32),m=d.Buffer.alloc(32),g=d.Buffer.alloc(32);t&fr.SIGHASH_ANYONECANPAY||(l=s(e)),!(t&fr.SIGHASH_ANYONECANPAY)&&(t&31)!==fr.SIGHASH_SINGLE&&(t&31)!==fr.SIGHASH_NONE&&(m=a(e)),(t&31)!==fr.SIGHASH_SINGLE&&(t&31)!==fr.SIGHASH_NONE?g=f(e):(t&31)===fr.SIGHASH_SINGLE&&r<e.outputs.length&&(g=f(e,r));var v=new Ua;v.writeInt32LE(e.version),v.write(l),v.write(m),v.writeReverse(o.prevTxId),v.writeUInt32LE(o.outputIndex),v.writeVarintNum(n.toBuffer().length),v.write(n.toBuffer()),v.writeUInt64LEBN(i);var E=o.sequenceNumber;v.writeUInt32LE(E),v.write(g),v.writeUInt32LE(e.nLockTime),v.writeUInt32LE(t>>>0);var T=v.toBuffer();return T},ox=function(t,r,n,i,o,s){var a=Ap(),f=Tc();vi.isUndefined(s)&&(s=Bk);var l=a.shallowCopy(t);if(i=new Ep(i),s&Ip.SCRIPT_ENABLE_REPLAY_PROTECTION){var m=r>>8,g=16711680|m^57005;r=g<<8|r&255}if(r&fr.SIGHASH_FORKID&&!(r&fr.SIGHASH_CHRONICLE)&&s&Ip.SCRIPT_ENABLE_SIGHASH_FORKID)return Nk(l,r,n,i,o);i.removeCodeseparators();var v;for(v=0;v<l.inputs.length;v++)l.inputs[v]=new f(l.inputs[v]).setScript(Ep.empty());if(l.inputs[n]=new f(l.inputs[n]).setScript(i),(r&31)===fr.SIGHASH_NONE||(r&31)===fr.SIGHASH_SINGLE)for(v=0;v<l.inputs.length;v++)v!==n&&(l.inputs[v].sequenceNumber=0);if((r&31)===fr.SIGHASH_NONE)l.outputs=[];else if((r&31)===fr.SIGHASH_SINGLE){if(n>=l.outputs.length)return ix;for(l.outputs.length=n+1,v=0;v<n;v++)l.outputs[v]=new Rk({satoshis:rx.fromBuffer(Ak.Buffer.from(Pk,"hex")),script:Ep.empty()})}r&fr.SIGHASH_ANYONECANPAY&&(l.inputs=[l.inputs[n]]);var E=new Ua().write(l.toBuffer()).writeInt32LE(r).toBuffer();return E},Op=function(t,r,n,i,o,s){var a=ox(t,r,n,i,o,s);if(a.compare(ix)===0)return a;var f=Pc.sha256sha256(a);return f=new Tk(f).readReverse(),f};function Mk(e,t,r,n,i,o,s){var a=Op(e,r,n,i,o,s),f=nx.sign(a,t,"little").set({nhashtype:r});return f}function kk(e,t,r,n,i,o,s){xp.checkArgument(!vi.isUndefined(e)),xp.checkArgument(!vi.isUndefined(t)&&!vi.isUndefined(t.nhashtype));var a=Op(e,t.nhashtype,n,i,o,s);return nx.verify(a,t,r,"little")}sx.exports={sighashPreimage:ox,sighash:Op,sign:Mk,verify:kk}});var Rp=B((K5,ux)=>{"use strict";p();var Un=ze(),Nc=Le(),ax=dr(),Ck=qr(),Lk=ro();function Fn(e){if(!(this instanceof Fn))return new Fn(e);Nc.checkArgument(Un.isObject(e),"Must provide an object from where to extract data");var t=e.address?new Lk(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!ax.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var n=Un.isUndefined(e.vout)?e.outputIndex:e.vout;if(!Un.isNumber(n))throw new Error("Invalid outputIndex, received "+n);Nc.checkArgument(!Un.isUndefined(e.scriptPubKey)||!Un.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var i=new Ck(e.scriptPubKey||e.script);Nc.checkArgument(!Un.isUndefined(e.amount)||!Un.isUndefined(e.satoshis),"Must provide an amount for the output");var o=Un.isUndefined(e.amount)?e.satoshis:Math.round(e.amount*1e8);Nc.checkArgument(Un.isNumber(o),"Amount must be a number"),ax.defineImmutable(this,{address:t,txId:r,outputIndex:n,script:i,satoshis:o})}Fn.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"};Fn.prototype.toString=function(){return this.txId+":"+this.outputIndex};Fn.fromObject=function(e){return new Fn(e)};Fn.prototype.toObject=Fn.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}};ux.exports=Fn});var Ap=B((V5,yx)=>{"use strict";p();var ye=ze(),Kt=Le(),Dk=Nt(),Dt=Zn(),cx=dr(),lx=ma(),Uk=Ji(),fx=Na(),hx=Jt(),kc=nr(),dx=mi(),Fk=ro(),px=Rp(),Lt=Tc(),qk=Lt.PublicKeyHash,jk=Lt.PublicKey,Hk=Lt.MultiSigScriptHash,Kk=Lt.MultiSig,Gr=Cn(),ln=qr(),Gk=no(),Mc=wr(),Vk=Bc(),Wk=Vk.SCRIPT_ENABLE_SIGHASH_FORKID;function Y(e){if(!(this instanceof Y))return new Y(e);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof Y)return Y.shallowCopy(e);if(cx.isHexa(e))this.fromString(e);else if(d.Buffer.isBuffer(e))this.fromBuffer(e);else if(ye.isObject(e))this.fromObject(e);else throw new Dt.InvalidArgument("Must provide an object or string to deserialize a transaction")}else this._newTransaction()}var zk=1,Yk=0,$k=1e6;Y.DUST_AMOUNT=546;Y.FEE_SECURITY_MARGIN=150;Y.MAX_MONEY=21e6*1e8;Y.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8;Y.NLOCKTIME_MAX_VALUE=4294967295;Y.FEE_PER_KB=500;Y.CHANGE_OUTPUT_MAX_SIZE=62;Y.shallowCopy=function(e){var t=new Y(e.toBuffer());return t};var gx={configurable:!1,enumerable:!0,get:function(){return this._hash=new lx(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(Y.prototype,"hash",gx);Object.defineProperty(Y.prototype,"id",gx);var Tp={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(Y.prototype,"inputAmount",Tp);Tp.get=function(){return this._getOutputAmount()};Object.defineProperty(Y.prototype,"outputAmount",Tp);Y.prototype._getHash=function(){return hx.sha256sha256(this.toBuffer())};Y.prototype.serialize=function(e){return e===!0||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)};Y.prototype.uncheckedSerialize=Y.prototype.toString=function(){return this.toBuffer().toString("hex")};Y.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",t;return this.uncheckedSerialize()};Y.prototype.invalidSatoshis=function(){for(var e=!1,t=0;t<this.outputs.length;t++)this.outputs[t].invalidSatoshis()&&(e=!0);return e};Y.prototype.getSerializationError=function(e){if(e=e||{},this.invalidSatoshis())return new Dt.Transaction.InvalidSatoshis;var t=this._getUnspentValue(),r;return t<0?e.disableMoreOutputThanInput||(r=new Dt.Transaction.InvalidOutputAmountSum):r=this._hasFeeError(e,t),r||this._hasDustOutputs(e)||this._isMissingSignatures(e)};Y.prototype._hasFeeError=function(e,t){if(!ye.isUndefined(this._fee)&&this._fee!==t)return new Dt.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=Math.floor(Y.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new Dt.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new Dt.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}};Y.prototype._missingChange=function(){return!this._changeScript};Y.prototype._hasDustOutputs=function(e){if(!e.disableDustOutputs){var t,r;for(t in this.outputs)if(r=this.outputs[t],r.satoshis<Y.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new Dt.Transaction.DustOutputs}};Y.prototype._isMissingSignatures=function(e){if(!e.disableIsFullySigned&&!this.isFullySigned())return new Dt.Transaction.MissingSignatures};Y.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"};Y.prototype.toBuffer=function(){var e=new Uk;return this.toBufferWriter(e).toBuffer()};Y.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),ye.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),ye.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e};Y.prototype.fromBuffer=function(e){var t=new lx(e);return this.fromBufferReader(t)};Y.prototype.fromBufferReader=function(e){Kt.checkArgument(!e.finished(),"No transaction data received");var t,r,n;for(this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t<r;t++){var i=Lt.fromBufferReader(e);this.inputs.push(i)}for(n=e.readVarintNum(),t=0;t<n;t++)this.outputs.push(Gr.fromBufferReader(e));return this.nLockTime=e.readUInt32LE(),this};Y.prototype.toObject=Y.prototype.toJSON=function(){var t=[];this.inputs.forEach(function(i){t.push(i.toObject())});var r=[];this.outputs.forEach(function(i){r.push(i.toObject())});var n={hash:this.hash,version:this.version,inputs:t,outputs:r,nLockTime:this.nLockTime};return this._changeScript&&(n.changeScript=this._changeScript.toString()),ye.isUndefined(this._changeIndex)||(n.changeIndex=this._changeIndex),ye.isUndefined(this._fee)||(n.fee=this._fee),n};Y.prototype.fromObject=function(t){Kt.checkArgument(ye.isObject(t)||t instanceof Y);var r=this,n;return t instanceof Y?n=t.toObject():n=t,ye.each(n.inputs,function(i){if(!i.output||!i.output.script){r.uncheckedAddInput(new Lt(i));return}var o=new ln(i.output.script),s;if(o.isPublicKeyHashOut())s=new Lt.PublicKeyHash(i);else if(o.isScriptHashOut()&&i.publicKeys&&i.threshold)s=new Lt.MultiSigScriptHash(i,i.publicKeys,i.threshold,i.signatures);else if(o.isPublicKeyOut())s=new Lt.PublicKey(i);else throw new Dt.Transaction.Input.UnsupportedScript(i.output.script);r.addInput(s)}),ye.each(n.outputs,function(i){r.addOutput(new Gr(i))}),n.changeIndex&&(this._changeIndex=n.changeIndex),n.changeScript&&(this._changeScript=new ln(n.changeScript)),n.fee&&(this._fee=n.fee),this.nLockTime=n.nLockTime,this.version=n.version,this._checkConsistency(t),this};Y.prototype._checkConsistency=function(e){ye.isUndefined(this._changeIndex)||(Kt.checkState(this._changeScript,"Change script is expected."),Kt.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),Kt.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),e&&e.hash&&Kt.checkState(e.hash===this.hash,"Hash in object does not match transaction hash.")};Y.prototype.lockUntilDate=function(e){if(Kt.checkArgument(e),ye.isNumber(e)&&e<Y.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Dt.Transaction.LockTimeTooEarly;ye.isDate(e)&&(e=e.getTime()/1e3);for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Lt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Lt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};Y.prototype.lockUntilBlockHeight=function(e){if(Kt.checkArgument(ye.isNumber(e)),e>=Y.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Dt.Transaction.BlockHeightTooHigh;if(e<0)throw new Dt.Transaction.NLockTimeOutOfRange;for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Lt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Lt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};Y.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<Y.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null};Y.prototype.fromString=function(e){this.fromBuffer(Dk.Buffer.from(e,"hex"))};Y.prototype._newTransaction=function(){this.version=zk,this.nLockTime=Yk};Y.prototype.from=function(e,t,r){if(ye.isArray(e)){var n=this;return ye.each(e,function(o){n.from(o,t,r)}),this}var i=ye.some(this.inputs,function(o){return o.prevTxId.toString("hex")===e.txId&&o.outputIndex===e.outputIndex});return i?this:(t&&r?this._fromMultisigUtxo(e,t,r):this._fromNonP2SH(e),this)};Y.prototype._fromNonP2SH=function(e){var t;e=new px(e),e.script.isPublicKeyHashOutPrefix()?t=qk:e.script.isPublicKeyOut()?t=jk:t=Lt,this.addInput(new t({output:new Gr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:ln.empty()}))};Y.prototype._fromMultisigUtxo=function(e,t,r){Kt.checkArgument(r<=t.length,"Number of required signatures must be greater than the number of public keys");var n;if(e=new px(e),e.script.isMultisigOut())n=Kk;else if(e.script.isScriptHashOut())n=Hk;else throw new Dt.Transaction.Input.UnsupportedScript(e.script.toString());this.addInput(new n({output:new Gr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:ln.empty()},t,r))};Y.prototype.addInput=function(e,t,r){if(Kt.checkArgumentType(e,Lt,"input"),!e.output&&(ye.isUndefined(t)||ye.isUndefined(r)))throw new Dt.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return!e.output&&t&&!ye.isUndefined(r)&&(t=t instanceof ln?t:new ln(t),Kt.checkArgumentType(r,"number","satoshis"),e.output=new Gr({script:t,satoshis:r})),this.uncheckedAddInput(e)};Y.prototype.uncheckedAddInput=function(e){return Kt.checkArgumentType(e,Lt,"input"),this.inputs.push(e),this._inputAmount=void 0,this._updateChangeOutput(),this};Y.prototype.hasAllUtxoInfo=function(){return ye.every(this.inputs.map(function(e){return!!e.output}))};Y.prototype.fee=function(e){return Kt.checkArgument(ye.isNumber(e),"amount must be a number"),this._fee=e,this._updateChangeOutput(),this};Y.prototype.feePerKb=function(e){return Kt.checkArgument(ye.isNumber(e),"amount must be a number"),this._feePerKb=e,this._updateChangeOutput(),this};Y.prototype.change=function(e){return Kt.checkArgument(e,"address is required"),this._changeScript=ln.fromAddress(e),this._updateChangeOutput(),this};Y.prototype.getChangeOutput=function(){return ye.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]};Y.prototype.to=function(e,t){if(ye.isArray(e)){var r=this;return ye.each(e,function(n){r.to(n.address,n.satoshis)}),this}return Kt.checkArgument(cx.isNaturalNumber(t),"Amount is expected to be a positive integer"),this.addOutput(new Gr({script:ln(new Fk(e)),satoshis:t})),this};Y.prototype.addData=function(e){return this.addOutput(new Gr({script:ln.buildDataOut(e),satoshis:0})),this};Y.prototype.addSafeData=function(e){return this.addOutput(new Gr({script:ln.buildSafeDataOut(e),satoshis:0})),this};Y.prototype.addOutput=function(e){return Kt.checkArgumentType(e,Gr,"output"),this._addOutput(e),this._updateChangeOutput(),this};Y.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this};Y.prototype._addOutput=function(e){this.outputs.push(e),this._outputAmount=void 0};Y.prototype._getOutputAmount=function(){if(ye.isUndefined(this._outputAmount)){var e=this;this._outputAmount=0,ye.each(this.outputs,function(t){e._outputAmount+=t.satoshis})}return this._outputAmount};Y.prototype._getInputAmount=function(){if(ye.isUndefined(this._inputAmount)){var e=this;this._inputAmount=0,ye.each(this.inputs,function(t){if(ye.isUndefined(t.output))throw new Dt.Transaction.Input.MissingPreviousOutput;e._inputAmount+=t.output.satoshis})}return this._inputAmount};Y.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),ye.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new Gr({script:this._changeScript,satoshis:0}));var e=this._getUnspentValue(),t=this.getFee(),r=e-t;this._removeOutput(this._changeIndex),this._changeIndex=void 0,r>=Y.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new Gr({script:this._changeScript,satoshis:r})))}};Y.prototype.getFee=function(){return this.isCoinbase()?0:ye.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee};Y.prototype._estimateFee=function(){var e=this._estimateSize();return Math.ceil(e/1e3*(this._feePerKb||Y.FEE_PER_KB))};Y.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()};Y.prototype._clearSignatures=function(){ye.each(this.inputs,function(e){e.clearSignatures!==Lt.prototype.clearSignatures&&e.clearSignatures()})};Y.prototype._estimateSize=function(){var e=8;return e+=fx(this.inputs.length).toBuffer().length,e+=fx(this.outputs.length).toBuffer().length,ye.each(this.inputs,function(t){e+=t._estimateSize()}),ye.each(this.outputs,function(t){e+=t.getSize()}),e};Y.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=ye.without(this.outputs,t),this._outputAmount=void 0};Y.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()};Y.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.prevTxId.compare(n.prevTxId)||r.outputIndex-n.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.satoshis-n.satoshis||r.script.toBuffer().compare(n.script.toBuffer())}),t}),this};Y.prototype.shuffleOutputs=function(){return this.sortOutputs(ye.shuffle)};Y.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)};Y.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this};Y.prototype._newOutputOrder=function(e){var t=this.outputs.length!==e.length||ye.difference(this.outputs,e).length!==0;if(t)throw new Dt.Transaction.InvalidSorting;if(!ye.isUndefined(this._changeIndex)){var r=this.outputs[this._changeIndex];this._changeIndex=e.indexOf(r)}return this.outputs=e,this};Y.prototype.removeInput=function(e,t){var r;if(!t&&ye.isNumber(e)?r=e:r=ye.findIndex(this.inputs,function(i){return i.prevTxId.toString("hex")===e&&i.outputIndex===t}),r<0||r>=this.inputs.length)throw new Dt.Transaction.InvalidIndex(r,this.inputs.length);var n=this.inputs[r];this.inputs=ye.without(this.inputs,n),this._inputAmount=void 0,this._updateChangeOutput()};Y.prototype.sign=function(e,t){Kt.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return ye.isArray(e)?(ye.each(e,function(n){r.sign(n,t)}),this):(ye.each(this.getSignatures(e,t),function(n){r.applySignature(n)}),this)};Y.prototype.getSignatures=function(e,t){e=new Gk(e),t=t||kc.SIGHASH_ALL|kc.SIGHASH_FORKID;var r=this,n=[],i=hx.sha256ripemd160(e.publicKey.toBuffer());return ye.each(this.inputs,function(s,a){ye.each(s.getSignatures(r,e,a,t,i),function(f){n.push(f)})}),n};Y.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this};Y.prototype.isFullySigned=function(){return ye.each(this.inputs,function(e){if(e.isFullySigned===Lt.prototype.isFullySigned)throw new Dt.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),ye.every(ye.map(this.inputs,function(e){return e.isFullySigned()}))};Y.prototype.isValidSignature=function(e){var t=this;if(this.inputs[e.inputIndex].isValidSignature===Lt.prototype.isValidSignature)throw new Dt.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(t,e)};Y.prototype.verifySignature=function(e,t,r,n,i,o){return dx.verify(this,e,t,r,n,i,o)};Y.prototype.verify=function(){if(this.inputs.length===0)return"transaction txins empty";if(this.outputs.length===0)return"transaction txouts empty";for(var e=new Mc(0),t=0;t<this.outputs.length;t++){var r=this.outputs[t];if(r.invalidSatoshis())return"transaction txout "+t+" satoshis is invalid";if(r._satoshisBN.gt(new Mc(Y.MAX_MONEY,10)))return"transaction txout "+t+" greater than MAX_MONEY";if(e=e.add(r._satoshisBN),e.gt(new Mc(Y.MAX_MONEY)))return"transaction txout "+t+" total output greater than MAX_MONEY"}if(this.toBuffer().length>$k)return"transaction over the maximum block size";var n={};for(t=0;t<this.inputs.length;t++){var i=this.inputs[t],o=i.prevTxId+":"+i.outputIndex;if(!ye.isUndefined(n[o]))return"transaction input "+t+" duplicate input";n[o]=!0}var s=this.isCoinbase();if(s){var a=this.inputs[0]._scriptBuffer;if(a.length<2||a.length>100)return"coinbase transaction script size invalid"}else for(t=0;t<this.inputs.length;t++)if(this.inputs[t].isNull())return"transaction input "+t+" has null input";return!0};Y.prototype.isCoinbase=function(){return this.inputs.length===1&&this.inputs[0].isNull()};Y.prototype.sighash=function(e,t,r,n,i){t=t||kc.SIGHASH_ALL|kc.SIGHASH_FORKID;var o=this.inputs[e];if(!o)throw new Error("Input index "+e+" does not exist");return!r&&o.output&&(r=o.output.script),!n&&o.output&&(n=new Mc(o.output.satoshis)),i=i||Wk,dx.sighash(this,t,e,r,n,i)};yx.exports=Y});var Pp=B((z5,io)=>{p();io.exports=Ap();io.exports.Input=Tc();io.exports.Output=Cn();io.exports.UnspentOutput=Rp();io.exports.Signature=os();io.exports.Sighash=mi()});var Bc=B(($5,bx)=>{"use strict";p();var Cc=ze(),qa=hp(),M=fp(),he=wr(),Fa=Jt(),bi=nr(),Bp=Or();function mx(e){return e.map(function(t){return d.Buffer.isBuffer(t)?d.Buffer.from(t):t})}var P=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};P.prototype._verifyCore=function(e,t,r,n,i,o){var s=Pp();if(Cc.isUndefined(r)&&(r=new s),Cc.isUndefined(n)&&(n=0),Cc.isUndefined(i)&&(i=P.currentConsensusFlags(),o||(i&=~P.SCRIPT_ENABLE_SIGHASH_FORKID)),i&P.SCRIPT_ENABLE_SIGHASH_FORKID&&(i|=P.SCRIPT_VERIFY_STRICTENC,!o))throw new Error("internal error - need satoshisBN to verify FORKID transactions");this.set({script:e,tx:r,nin:n,flags:i,satoshisBN:o});var a;if((i&P.SCRIPT_VERIFY_SIGPUSHONLY)!==0&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;var f=(i&P.SCRIPT_VERIFY_P2SH)!==0&&(i&P.SCRIPT_UTXO_AFTER_GENESIS)===0;f&&(a=this.stack.slice());var l=this.stack;if(this.initialize(),this.set({script:t,stack:l,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(this.stack.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var m=this.stack[this.stack.length-1];if(!P.castToBool(m))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(f&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(a.length===0)throw new Error("internal error - stack copy empty");var g=a[a.length-1],v=qa.fromBuffer(g);if(a.pop(),this.initialize(),this.set({script:v,stack:a,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(a.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!P.castToBool(a[a.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if((i&P.SCRIPT_VERIFY_CLEANSTACK)!==0){if((i&P.SCRIPT_VERIFY_P2SH)===0&&(i&P.SCRIPT_UTXO_AFTER_GENESIS)===0)throw new Error("internal error - CLEANSTACK without P2SH");if(this.stack.length!==1)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0};bx.exports=P;P.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.returned=!1,this.nonTopLevelReturnAfterGenesis=!1,this.vfExec=[],this.vfElse=[],this.errstr="",this.flags=0};P.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=typeof e.nin<"u"?e.nin:this.nin,this.satoshisBN=e.satoshisBN||this.satoshisBN,this.stack=e.stack||this.stack,this.altstack=e.altstack||this.altstack,this.pc=typeof e.pc<"u"?e.pc:this.pc,this.pbegincodehash=typeof e.pbegincodehash<"u"?e.pbegincodehash:this.pbegincodehash,this.nOpCount=typeof e.nOpCount<"u"?e.nOpCount:this.nOpCount,this.returned=typeof e.returned<"u"?e.returned:this.returned,this.nonTopLevelReturnAfterGenesis=typeof e.nonTopLevelReturnAfterGenesis<"u"?e.nonTopLevelReturnAfterGenesis:this.nonTopLevelReturnAfterGenesis,this.vfExec=e.vfExec||this.vfExec,this.vfElse=e.vfElse||this.vfElse,this.errstr=e.errstr||this.errstr,this.flags=typeof e.flags<"u"?e.flags:this.flags};P.true=d.Buffer.from([1]);P.false=d.Buffer.from([]);P.MAX_SCRIPT_ELEMENT_SIZE=520;P.MAXIMUM_ELEMENT_SIZE=4;P.MAX_OPS_PER_SCRIPT=500;P.MAX_SCRIPT_SIZE=1e4;P.UNLIMITED=Number.MAX_SAFE_INTEGER;P.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS=75e4;P.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE=32e6;P.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS=4294967295;P.LOCKTIME_THRESHOLD=5e8;P.LOCKTIME_THRESHOLD_BN=new he(P.LOCKTIME_THRESHOLD);P.useGenesisLimits=function(e){return e=e||2147483647,P.MAX_SCRIPT_ELEMENT_SIZE=e,P.MAX_OPS_PER_SCRIPT=e,P.MAX_SCRIPT_SIZE=e,P};P.getLimits=function(){return{maxScriptElementSize:P.MAX_SCRIPT_ELEMENT_SIZE,maximumElementSize:P.MAXIMUM_ELEMENT_SIZE,maxOpsPerScript:P.MAX_OPS_PER_SCRIPT,maxScriptSize:P.MAX_SCRIPT_SIZE}};P.setLimits=function(e){return e=e||{},e.maxScriptElementSize!=null&&(P.MAX_SCRIPT_ELEMENT_SIZE=e.maxScriptElementSize),e.maximumElementSize!=null&&(P.MAXIMUM_ELEMENT_SIZE=e.maximumElementSize),e.maxOpsPerScript!=null&&(P.MAX_OPS_PER_SCRIPT=e.maxOpsPerScript),e.maxScriptSize!=null&&(P.MAX_SCRIPT_SIZE=e.maxScriptSize),P};P.SCRIPT_VERIFY_NONE=0;P.SCRIPT_VERIFY_P2SH=1;P.SCRIPT_VERIFY_STRICTENC=2;P.SCRIPT_VERIFY_DERSIG=4;P.SCRIPT_VERIFY_LOW_S=8;P.SCRIPT_VERIFY_NULLDUMMY=16;P.SCRIPT_VERIFY_SIGPUSHONLY=32;P.SCRIPT_VERIFY_MINIMALDATA=64;P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128;P.SCRIPT_VERIFY_CLEANSTACK=256;P.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512;P.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024;P.SCRIPT_VERIFY_MINIMALIF=8192;P.SCRIPT_VERIFY_NULLFAIL=16384;P.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768;P.SCRIPT_ENABLE_SIGHASH_FORKID=65536;P.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17;P.SCRIPT_ENABLE_MONOLITH_OPCODES=2048;P.SCRIPT_ENABLE_MAGNETIC_OPCODES=4096;P.SCRIPT_GENESIS=1<<18;P.SCRIPT_UTXO_AFTER_GENESIS=1<<19;P.SCRIPT_ENABLE_CHRONICLE=1<<20;P.SCRIPT_CHRONICLE=P.SCRIPT_ENABLE_CHRONICLE;P.SCRIPT_UTXO_AFTER_CHRONICLE=1<<21;P.CHRONICLE_ACTIVATION_HEIGHT=943816;P.ERA_SENSITIVE_ERRORS={SCRIPT_ERR_PUSH_SIZE:{cap:"stack element size (capped at 520 bytes pre-Genesis, unbounded after)",lifts:P.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_SCRIPT_SIZE:{cap:"total script size (capped at 10,000 bytes pre-Genesis, unbounded after)",lifts:P.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_OP_COUNT:{cap:"opcode count (capped at 201 pre-Genesis, unbounded after)",lifts:P.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_SCRIPTNUM_OVERFLOW:{cap:"script number width (4 bytes pre-Genesis, 750,000 after Genesis, 32,000,000 after Chronicle)",lifts:P.SCRIPT_UTXO_AFTER_GENESIS|P.SCRIPT_UTXO_AFTER_CHRONICLE}};P.ERA_FLAGS=P.SCRIPT_GENESIS|P.SCRIPT_UTXO_AFTER_GENESIS|P.SCRIPT_ENABLE_CHRONICLE|P.SCRIPT_UTXO_AFTER_CHRONICLE;P.eraDiagnostics=!(typeof x.default<"u"&&x.default.env&&x.default.env.BSV_NO_ERA_HINT==="1");var Np=!1;P.prototype._eraDiagnose=function(e){if(e!==void 0){var t=P.ERA_SENSITIVE_ERRORS[this.errstr];if(t&&(e&t.lifts)===0){var r=t.cap;this.eraHint=this.errstr+" was produced under PRE-GENESIS limits: "+r+`.
70
+ The flags passed to verify() (0x`+(e>>>0).toString(16)+`) carry no era bit, so those caps applied regardless of which feature opcodes were enabled.
71
+ To validate against BSV as it is today, omit the flags argument or pass Interpreter.mainnetFlags(). If you are deliberately testing pre-Genesis consensus this failure is correct \u2014 set Interpreter.eraDiagnostics = false (or BSV_NO_ERA_HINT=1) to silence this.`,P.eraDiagnostics&&!Np&&(Np=!0,console.warn(`
72
+ [@smartledger/bsv] `+this.eraHint+`
73
+ (shown once per process)
74
+ `))}}};P.prototype.verify=function(e,t,r,n,i,o){this.eraHint=null;var s=this._verifyCore(e,t,r,n,i,o);return s||this._eraDiagnose(i),s};P._resetEraWarning=function(){Np=!1};P.mainnetFlags=function(e){e=e||{};var t=P.SCRIPT_VERIFY_P2SH|P.SCRIPT_VERIFY_STRICTENC|P.SCRIPT_VERIFY_DERSIG|P.SCRIPT_VERIFY_LOW_S|P.SCRIPT_VERIFY_NULLFAIL|P.SCRIPT_VERIFY_MINIMALDATA|P.SCRIPT_ENABLE_SIGHASH_FORKID|P.SCRIPT_ENABLE_MAGNETIC_OPCODES|P.SCRIPT_ENABLE_MONOLITH_OPCODES|P.SCRIPT_GENESIS|P.SCRIPT_UTXO_AFTER_GENESIS;return e.afterChronicle!==!1&&(t|=P.SCRIPT_ENABLE_CHRONICLE|P.SCRIPT_UTXO_AFTER_CHRONICLE),t};P.currentConsensusFlags=function(){return P.SCRIPT_ENABLE_MONOLITH_OPCODES|P.SCRIPT_ENABLE_MAGNETIC_OPCODES|P.SCRIPT_GENESIS|P.SCRIPT_UTXO_AFTER_GENESIS|P.SCRIPT_ENABLE_CHRONICLE|P.SCRIPT_UTXO_AFTER_CHRONICLE|P.SCRIPT_ENABLE_SIGHASH_FORKID};P.useMainnetConsensus=function(e){return e=e||{},P.useGenesisLimits(e.max),P.mainnetFlags(e)};P.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31;P.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22;P.SEQUENCE_LOCKTIME_MASK=65535;P.castToBool=function(e){for(var t=0;t<e.length;t++)if(e[t]!==0)return!(t===e.length-1&&e[t]===128);return!1};P.prototype.checkSignatureEncoding=function(e){var t;if(e.length===0)return!0;if((this.flags&(P.SCRIPT_VERIFY_DERSIG|P.SCRIPT_VERIFY_LOW_S|P.SCRIPT_VERIFY_STRICTENC))!==0&&!bi.isTxDER(e))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if((this.flags&P.SCRIPT_VERIFY_LOW_S)!==0){if(t=bi.fromTxFormat(e),!t.hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if((this.flags&P.SCRIPT_VERIFY_STRICTENC)!==0){if(t=bi.fromTxFormat(e),!t.hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&P.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nhashtype&bi.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(!(this.flags&P.SCRIPT_CHRONICLE)&&t.nhashtype&bi.SIGHASH_CHRONICLE)return this.errstr="SCRIPT_ERR_ILLEGAL_CHRONICLE",!1;if(this.flags&P.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nhashtype&bi.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0};P.prototype.checkPubkeyEncoding=function(e){return(this.flags&P.SCRIPT_VERIFY_STRICTENC)!==0&&!Bp.isValid(e)?(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1):!0};P.prototype.isAfterGenesis=function(){return(this.flags&P.SCRIPT_UTXO_AFTER_GENESIS)!==0};P.prototype.isAfterChronicle=function(){return(this.flags&(P.SCRIPT_UTXO_AFTER_CHRONICLE|P.SCRIPT_ENABLE_CHRONICLE))!==0};P.prototype.maxScriptElementSize=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_SCRIPT_ELEMENT_SIZE};P.prototype.maxScriptSize=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_SCRIPT_SIZE};P.prototype.maxOpsPerScript=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_OPS_PER_SCRIPT};P.prototype.maxScriptNumLength=function(){return this.isAfterChronicle()?P.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE:this.isAfterGenesis()?P.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS:P.MAXIMUM_ELEMENT_SIZE};P.prototype.maxPubKeysPerMultisig=function(){return this.isAfterGenesis()?P.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS:20};P._isMinimallyEncoded=function(e,t){return t=t||P.MAXIMUM_ELEMENT_SIZE,!(e.length>t||e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))};P._minimallyEncode=function(e){if(e.length===0)return e;var t=e[e.length-1];if(t&127)return e;if(e.length===1)return d.Buffer.from("");if(e[e.length-2]&128)return e;for(var r=e.length-1;r>0;r--)if(e[r-1]!==0)return e[r-1]&128?e[r++]=t:e[r-1]|=t,e.slice(0,r);return d.Buffer.from("")};P.prototype.evaluate=function(){if(this.script.toBuffer().length>this.maxScriptSize())return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let t={pc:this.pc,opcode:M.fromNumber(this.script.chunks[this.pc].opcodenum)};var e=this.step();if(!e)return!1;if(this._callbackStep(t),this.returned)return!0}if(this.stack.length+this.altstack.length>1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(t){return this.errstr=t.scriptErr||"SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return this.vfExec.length>0?(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1):!0};P.prototype._callbackStep=function(e){if(typeof this.stepListener=="function")try{this.stepListener(e,mx(this.stack),mx(this.altstack))}catch(t){console.log(`Error in Step callback:${t}`)}};P.prototype.checkLockTime=function(e){if(!(this.tx.nLockTime<P.LOCKTIME_THRESHOLD&&e.lt(P.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=P.LOCKTIME_THRESHOLD&&e.gte(P.LOCKTIME_THRESHOLD_BN))||e.gt(new he(this.tx.nLockTime)))return!1;var t=this.tx.inputs[this.nin];return!(!t||t.isFinal())};P.prototype.checkSequence=function(e){var t=this.tx.inputs[this.nin];if(!t)return!1;var r=t.sequenceNumber;if(this.tx.version<2||r&P.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var n=P.SEQUENCE_LOCKTIME_TYPE_FLAG|P.SEQUENCE_LOCKTIME_MASK,i=new he(r&n),o=e.and(new he(n)),s=new he(P.SEQUENCE_LOCKTIME_TYPE_FLAG);return!(!(i.lt(s)&&o.lt(s)||i.gte(s)&&o.gte(s))||o.gt(i))};function Zk(e,t){let r=e;for(;r.length<t;)r=d.Buffer.concat([d.Buffer.from([0]),r]);return r}function vx(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e|0,0),t}P.prototype.step=function(){var e=this;function t(fe){return e.stack[e.stack.length+fe]}function r(fe){switch(fe){case M.OP_2MUL:case M.OP_2DIV:if(!e.isAfterChronicle())return!0;break;case M.OP_INVERT:case M.OP_MUL:case M.OP_LSHIFT:case M.OP_RSHIFT:if((e.flags&P.SCRIPT_ENABLE_MAGNETIC_OPCODES)===0)return!0;break;case M.OP_DIV:case M.OP_MOD:case M.OP_SPLIT:case M.OP_CAT:case M.OP_AND:case M.OP_OR:case M.OP_XOR:case M.OP_BIN2NUM:case M.OP_NUM2BIN:return!1;default:break}return!1}var n=(this.flags&P.SCRIPT_VERIFY_MINIMALDATA)!==0,i,o,s,a,f,l,m,g,v,E,T,N,L,F,V,z,W,ie=this.script.chunks[this.pc];this.pc++;var ee=ie.opcodenum,ge=this.vfExec.indexOf(!1)===-1&&(!this.nonTopLevelReturnAfterGenesis||ee===M.OP_RETURN);if(Cc.isUndefined(ee))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(ie.buf&&ie.buf.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(ee>M.OP_16&&++this.nOpCount>this.maxOpsPerScript())return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(r(ee)&&(!this.isAfterGenesis()||ge))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(ge&&ee>=0&&ee<=M.OP_PUSHDATA4){if(n&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(!ie.buf)this.stack.push(P.false);else{if(ie.len!==ie.buf.length)return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;this.stack.push(ie.buf)}}else if(ge||M.OP_IF<=ee&&ee<=M.OP_ENDIF)switch(ee){case M.OP_1NEGATE:case M.OP_1:case M.OP_2:case M.OP_3:case M.OP_4:case M.OP_5:case M.OP_6:case M.OP_7:case M.OP_8:case M.OP_9:case M.OP_10:case M.OP_11:case M.OP_12:case M.OP_13:case M.OP_14:case M.OP_15:case M.OP_16:f=ee-(M.OP_1-1),i=new he(f).toScriptNumBuffer(),this.stack.push(i);break;case M.OP_NOP:break;case M.OP_NOP2:case M.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&P.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)||this.isAfterGenesis()){if(this.flags&P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var ce=he.fromScriptNumBuffer(this.stack[this.stack.length-1],n,5);if(ce.lt(new he(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(ce))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case M.OP_NOP3:case M.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&P.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)||this.isAfterGenesis()){if(this.flags&P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var me=he.fromScriptNumBuffer(t(-1),n,5);if(me.lt(new he(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if((me&P.SEQUENCE_LOCKTIME_DISABLE_FLAG)!==0)break;if(!this.checkSequence(me))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case M.OP_NOP1:case M.OP_NOP9:case M.OP_NOP10:if(this.flags&P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case M.OP_LSHIFTNUM:case M.OP_RSHIFTNUM:if(!this.isAfterChronicle()){if(this.flags&P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var I=this.maxScriptNumLength(),u=he.fromScriptNumBuffer(t(-1),n,I);if(u.isNeg())return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop();var h=he.fromScriptNumBuffer(t(-1),n,I);this.stack.pop();var y=u.toNumber(),S=h.isNeg(),w=h.abs(),R;if(ee===M.OP_LSHIFTNUM){var O=h.toScriptNumBuffer().length;if(O+Math.floor(y/8)>I)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;R=w.shln(y)}else R=y>=w.bitLength()?new he(0):w.shrn(y);if(S&&!R.isZero()&&(R=R.neg()),R.toScriptNumBuffer().length>I)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;this.stack.push(R.toScriptNumBuffer());break;case M.OP_VER:if(!this.isAfterChronicle())return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;this.stack.push(vx(this.tx.version));break;case M.OP_VERIF:case M.OP_VERNOTIF:if(!this.isAfterChronicle()){if(this.isAfterGenesis()&&!ge)break;return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}if(z=!1,ge){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;i=t(-1),z=i.length===4&&i.equals(vx(this.tx.version)),ee===M.OP_VERNOTIF&&(z=!z),this.stack.pop()}this.vfExec.push(z),this.vfElse.push(!1);break;case M.OP_IF:case M.OP_NOTIF:if(z=!1,ge){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(i=t(-1),this.flags&P.SCRIPT_VERIFY_MINIMALIF){if(i.length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(i.length===1&&i[0]!==1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1}z=P.castToBool(i),ee===M.OP_NOTIF&&(z=!z),this.stack.pop()}this.vfExec.push(z),this.vfElse.push(!1);break;case M.OP_ELSE:if(this.vfExec.length===0||this.vfElse[this.vfElse.length-1]&&this.isAfterGenesis())return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1],this.vfElse[this.vfElse.length-1]=!0;break;case M.OP_ENDIF:if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop(),this.vfElse.pop();break;case M.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),z=P.castToBool(i),z)this.stack.pop();else return this.errstr="SCRIPT_ERR_VERIFY",!1;break;case M.OP_RETURN:if(this.isAfterGenesis()){if(this.vfExec.length===0){this.returned=!0;break}this.nonTopLevelReturnAfterGenesis=!0;break}return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case M.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case M.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case M.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case M.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case M.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3),s=t(-2);var _=t(-1);this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(_));break;case M.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-4),s=t(-3),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case M.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-6,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case M.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-4,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case M.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1),z=P.castToBool(i),z&&this.stack.push(d.Buffer.from(i));break;case M.OP_DEPTH:i=new he(this.stack.length).toScriptNumBuffer(),this.stack.push(i);break;case M.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case M.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-1)));break;case M.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case M.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-2)));break;case M.OP_PICK:case M.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),g=he.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),f=g.toNumber(),this.stack.pop(),f<0||f>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-f-1),ee===M.OP_ROLL&&this.stack.splice(this.stack.length-f-1,1),this.stack.push(d.Buffer.from(i));break;case M.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-3),m=t(-2);var c=t(-1);this.stack[this.stack.length-3]=m,this.stack[this.stack.length-2]=c,this.stack[this.stack.length-1]=l;break;case M.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-2),m=t(-1),this.stack[this.stack.length-2]=m,this.stack[this.stack.length-1]=l;break;case M.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,d.Buffer.from(t(-1)));break;case M.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;g=new he(t(-1).length),this.stack.push(g.toScriptNumBuffer());break;case M.OP_AND:case M.OP_OR:case M.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),s=t(-1),o.length!==s.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(ee){case M.OP_AND:for(let fe=0;fe<o.length;fe++)o[fe]&=s[fe];break;case M.OP_OR:for(let fe=0;fe<o.length;fe++)o[fe]|=s[fe];break;case M.OP_XOR:for(let fe=0;fe<o.length;fe++)o[fe]^=s[fe];break;default:break}this.stack.pop();break;case M.OP_INVERT:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1);for(let fe=0;fe<i.length;fe++)i[fe]=~i[fe];break;case M.OP_LSHIFT:case M.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),o.length===0)this.stack.pop();else{if(v=new he(o),E=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),f=E.toNumber(),f<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop();let fe;ee===M.OP_LSHIFT&&(fe=v.ushln(f)),ee===M.OP_RSHIFT&&(fe=v.ushrn(f));let de=Zk(d.Buffer.from(fe.toArray().slice(o.length*-1)),o.length);this.stack.push(de)}break;case M.OP_EQUAL:case M.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1);var b=o.toString("hex")===s.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(b?P.true:P.false),ee===M.OP_EQUALVERIFY)if(b)this.stack.pop();else return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;break;case M.OP_2MUL:case M.OP_2DIV:case M.OP_1ADD:case M.OP_1SUB:case M.OP_NEGATE:case M.OP_ABS:case M.OP_NOT:case M.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(i=t(-1),g=he.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),ee){case M.OP_2MUL:g=g.mul(new he(2));break;case M.OP_2DIV:g=g.div(new he(2));break;case M.OP_1ADD:g=g.add(he.One);break;case M.OP_1SUB:g=g.sub(he.One);break;case M.OP_NEGATE:g=g.neg();break;case M.OP_ABS:g.cmp(he.Zero)<0&&(g=g.neg());break;case M.OP_NOT:g=new he((g.cmp(he.Zero)===0)+0);break;case M.OP_0NOTEQUAL:g=new he((g.cmp(he.Zero)!==0)+0);break}this.stack.pop(),this.stack.push(g.toScriptNumBuffer());break;case M.OP_ADD:case M.OP_SUB:case M.OP_MUL:case M.OP_MOD:case M.OP_DIV:case M.OP_BOOLAND:case M.OP_BOOLOR:case M.OP_NUMEQUAL:case M.OP_NUMEQUALVERIFY:case M.OP_NUMNOTEQUAL:case M.OP_LESSTHAN:case M.OP_GREATERTHAN:case M.OP_LESSTHANOREQUAL:case M.OP_GREATERTHANOREQUAL:case M.OP_MIN:case M.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(v=he.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()),E=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),g=new he(0),ee){case M.OP_ADD:g=v.add(E);break;case M.OP_SUB:g=v.sub(E);break;case M.OP_MUL:g=v.mul(E);break;case M.OP_DIV:if(E.cmp(he.Zero)===0)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;g=v.div(E);break;case M.OP_MOD:if(E.cmp(he.Zero)===0)return this.errstr="SCRIPT_ERR_MOD_BY_ZERO",!1;g=v.mod(E);break;case M.OP_BOOLAND:g=new he((v.cmp(he.Zero)!==0&&E.cmp(he.Zero)!==0)+0);break;case M.OP_BOOLOR:g=new he((v.cmp(he.Zero)!==0||E.cmp(he.Zero)!==0)+0);break;case M.OP_NUMEQUAL:g=new he((v.cmp(E)===0)+0);break;case M.OP_NUMEQUALVERIFY:g=new he((v.cmp(E)===0)+0);break;case M.OP_NUMNOTEQUAL:g=new he((v.cmp(E)!==0)+0);break;case M.OP_LESSTHAN:g=new he((v.cmp(E)<0)+0);break;case M.OP_GREATERTHAN:g=new he((v.cmp(E)>0)+0);break;case M.OP_LESSTHANOREQUAL:g=new he((v.cmp(E)<=0)+0);break;case M.OP_GREATERTHANOREQUAL:g=new he((v.cmp(E)>=0)+0);break;case M.OP_MIN:g=v.cmp(E)<0?v:E;break;case M.OP_MAX:g=v.cmp(E)>0?v:E;break}if(this.stack.pop(),this.stack.pop(),this.stack.push(g.toScriptNumBuffer()),ee===M.OP_NUMEQUALVERIFY)if(P.castToBool(t(-1)))this.stack.pop();else return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;break;case M.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;v=he.fromScriptNumBuffer(t(-3),n,this.maxScriptNumLength()),E=he.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength());var k=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength());z=E.cmp(v)<=0&&v.cmp(k)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(z?P.true:P.false);break;case M.OP_RIPEMD160:case M.OP_SHA1:case M.OP_SHA256:case M.OP_HASH160:case M.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1);var D;ee===M.OP_RIPEMD160?D=Fa.ripemd160(i):ee===M.OP_SHA1?D=Fa.sha1(i):ee===M.OP_SHA256?D=Fa.sha256(i):ee===M.OP_HASH160?D=Fa.sha256ripemd160(i):ee===M.OP_HASH256&&(D=Fa.sha256sha256(i)),this.stack.pop(),this.stack.push(D);break;case M.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case M.OP_CHECKSIG:case M.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(T=t(-2),N=t(-1),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(N))return!1;L=new qa().set({chunks:this.script.chunks.slice(this.pbegincodehash)});var K=new qa().add(T);L.findAndDelete(K);try{F=bi.fromTxFormat(T),V=Bp.fromBuffer(N,!1),W=this.tx.verifySignature(F,V,this.nin,L,this.satoshisBN,this.flags)}catch{W=!1}if(!W&&this.flags&P.SCRIPT_VERIFY_NULLFAIL&&T.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(W?P.true:P.false),ee===M.OP_CHECKSIGVERIFY)if(W)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;break;case M.OP_CHECKMULTISIG:case M.OP_CHECKMULTISIGVERIFY:var G=1;if(this.stack.length<G)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var X=he.fromScriptNumBuffer(t(-G),n,this.maxScriptNumLength()).toNumber();if(X<0||X>this.maxPubKeysPerMultisig())return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=X,this.nOpCount>P.MAX_OPS_PER_SCRIPT)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var Z=++G;G+=X;var le=X+2;if(this.stack.length<G)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var se=he.fromScriptNumBuffer(t(-G),n,this.maxScriptNumLength()).toNumber();if(se<0||se>X)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var A=++G;if(G+=se,this.stack.length<G)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;L=new qa().set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var C=0;C<se;C++)T=t(-A-C),L.findAndDelete(new qa().add(T));for(W=!0;W&&se>0;){if(T=t(-A),N=t(-Z),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(N))return!1;var U;try{F=bi.fromTxFormat(T),V=Bp.fromBuffer(N,!1),U=this.tx.verifySignature(F,V,this.nin,L,this.satoshisBN,this.flags)}catch{U=!1}U&&(A++,se--),Z++,X--,se>X&&(W=!1)}for(;G-- >1;){if(!W&&this.flags&P.SCRIPT_VERIFY_NULLFAIL&&!le&&t(-1).length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;le>0&&le--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&P.SCRIPT_VERIFY_NULLDUMMY&&t(-1).length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(W?P.true:P.false),ee===M.OP_CHECKMULTISIGVERIFY)if(W)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;break;case M.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),s=t(-1),o.length+s.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=d.Buffer.concat([o,s]),this.stack.pop();break;case M.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2);var j=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(j<0||j>o.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var re=d.Buffer.from(o);this.stack[this.stack.length-2]=re.slice(0,j),this.stack[this.stack.length-1]=re.slice(j);break;case M.OP_LEFT:case M.OP_RIGHT:if(!this.isAfterChronicle()){if(this.flags&P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),f=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),f<0||f>o.length)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),ee===M.OP_LEFT?this.stack[this.stack.length-1]=d.Buffer.from(o).slice(0,f):this.stack[this.stack.length-1]=d.Buffer.from(o).slice(o.length-f);break;case M.OP_SUBSTR:if(!this.isAfterChronicle()){if(this.flags&P.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3);var J=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),te=he.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()).toNumber();if(te<0||te>=o.length||J<0||J>o.length-te)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop(),this.stack[this.stack.length-1]=d.Buffer.from(o).slice(te,te+J);break;case M.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var ae=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(ae<0||ae>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var oe=t(-1);if(oe=P._minimallyEncode(oe),oe.length>ae)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(oe.length===ae){this.stack[this.stack.length-1]=oe;break}var ue=0;oe.length>0&&(ue=oe[oe.length-1]&128,oe[oe.length-1]&=127);var _e=d.Buffer.alloc(ae);oe.copy(_e,0);for(var we=oe.length-1;we++<ae-2;)_e[we]=0;_e[we]=ue,this.stack[this.stack.length-1]=_e;break;case M.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-1),s=P._minimallyEncode(o),this.stack[this.stack.length-1]=s,!P._isMinimallyEncoded(s))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}});var qr=B((X5,Mp)=>{p();Mp.exports=hp();Mp.exports.Interpreter=Bc()});var ro=B((Q5,Ex)=>{"use strict";p();var kp=ze(),qn=Le(),Xk=Zn(),_x=Hd(),Rr=pa(),Sx=Jt(),wx=dr(),Cp=Or();function ne(e,t,r){if(!(this instanceof ne))return new ne(e,t,r);if(kp.isArray(e)&&kp.isNumber(t))return ne.createMultisig(e,t,r);if(e instanceof ne)return e;if(qn.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!Rr.get(t))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==ne.PayToPublicKeyHash&&r!==ne.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var n=this._classifyArguments(e,t,r);return n.network=n.network||Rr.get(t)||Rr.defaultNetwork,n.type=n.type||r||ne.PayToPublicKeyHash,wx.defineImmutable(this,{hashBuffer:n.hashBuffer,network:n.network,type:n.type}),this}ne.prototype._classifyArguments=function(e,t,r){if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===20)return ne._transformHash(e);if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===21)return ne._transformBuffer(e,t,r);if(e instanceof Cp)return ne._transformPublicKey(e);if(e instanceof ja())return ne._transformScript(e,t);if(typeof e=="string")return ne._transformString(e,t,r);if(kp.isObject(e))return ne._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")};ne.PayToPublicKeyHash="pubkeyhash";ne.PayToScriptHash="scripthash";ne._transformHash=function(e){var t={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==20)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return t.hashBuffer=e,t};ne._transformObject=function(e){return qn.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),qn.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?d.Buffer.from(e.hash,"hex"):e.hashBuffer,network:Rr.get(e.network)||Rr.defaultNetwork,type:e.type}};ne._classifyFromVersion=function(e){var t={},r=Rr.get(e[0],"pubkeyhash"),n=Rr.get(e[0],"scripthash");return r?(t.network=r,t.type=ne.PayToPublicKeyHash):n&&(t.network=n,t.type=ne.PayToScriptHash),t};ne._transformBuffer=function(e,t,r){var n={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==21)throw new TypeError("Address buffers must be exactly 21 bytes.");var i=Rr.get(t),o=ne._classifyFromVersion(e);if(t&&!i)throw new TypeError("Unknown network");if(!o.network||i&&i!==o.network)throw new TypeError("Address has mismatched network type.");if(!o.type||r&&r!==o.type)throw new TypeError("Address has mismatched type.");return n.hashBuffer=e.slice(1),n.network=o.network,n.type=o.type,n};ne._transformPublicKey=function(e){var t={};if(!(e instanceof Cp))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=Sx.sha256ripemd160(e.toBuffer()),t.type=ne.PayToPublicKeyHash,t};ne._transformScript=function(e,t){qn.checkArgument(e instanceof ja(),"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new Xk.Script.CantDeriveAddress(e);return r};ne.createMultisig=function(e,t,r){return r=r||e[0].network||Rr.defaultNetwork,ne.payingTo(ja().buildMultisigOut(e,t),r)};ne._transformString=function(e,t,r){if(typeof e!="string")throw new TypeError("data parameter supplied is not a string.");if(e.length<27)throw new Error("Invalid Address string provided");e=e.trim();var n=Rr.get(t);if(t&&!n)throw new TypeError("Unknown network");var i=_x.decode(e);return ne._transformBuffer(i,t,r)};ne.fromPublicKey=function(e,t){var r=ne._transformPublicKey(e);return t=t||Rr.defaultNetwork,new ne(r.hashBuffer,t,r.type)};ne.fromPrivateKey=function(e,t){let r=Cp.fromPrivateKey(e);return t=t||e.network||Rr.defaultNetwork,ne.fromPublicKey(r,t)};ne.fromPublicKeyHash=function(e,t){var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToPublicKeyHash)};ne.fromScriptHash=function(e,t){qn.checkArgument(e,"hash parameter is required");var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToScriptHash)};ne.payingTo=function(e,t){return qn.checkArgument(e,"script is required"),qn.checkArgument(e instanceof ja(),"script must be instance of Script"),ne.fromScriptHash(Sx.sha256ripemd160(e.toBuffer()),t)};ne.fromScript=function(e,t){qn.checkArgument(e instanceof ja(),"script must be a Script instance");var r=ne._transformScript(e,t);return new ne(r.hashBuffer,t,r.type)};ne.fromBuffer=function(e,t,r){var n=ne._transformBuffer(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromHex=function(e,t,r){return ne.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ne.fromString=function(e,t,r){var n=ne._transformString(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromObject=function(t){qn.checkState(wx.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.');var r=d.Buffer.from(t.hash,"hex");return new ne(r,t.network,t.type)};ne.getValidationError=function(e,t,r){var n;try{new ne(e,t,r)}catch(i){n=i}return n};ne.isValid=function(e,t,r){return!ne.getValidationError(e,t,r)};ne.prototype.isPayToPublicKeyHash=function(){return this.type===ne.PayToPublicKeyHash};ne.prototype.isPayToScriptHash=function(){return this.type===ne.PayToScriptHash};ne.prototype.toBuffer=function(){var e=d.Buffer.from([this.network[this.type]]),t=d.Buffer.concat([e,this.hashBuffer]);return t};ne.prototype.toHex=function(){return this.toBuffer().toString("hex")};ne.prototype.toObject=ne.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}};ne.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"};ne.prototype.toString=function(){return _x.encode(this.toBuffer())};Ex.exports=ne;function ja(){return qr()}});var no=B((tq,Ax)=>{"use strict";p();var Lc=ze(),Jk=ro(),xx=Hd(),_i=wr(),Ix=dr(),hn=pa(),Dp=ai(),Qk=Or(),eC=Xs(),Ox=Le(),Lp="[REDACTED]";function ve(e,t){if(!(this instanceof ve))return new ve(e,t);if(e instanceof ve)return e;var r=this._classifyArguments(e,t);if(!r.bn||r.bn.cmp(new _i(0))===0)throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(Dp.getN()))throw new TypeError("Number must be less than N");if(typeof r.network>"u")throw new TypeError('Must specify the network ("livenet" or "testnet")');return Ix.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}ve.prototype._classifyArguments=function(e,t){var r={compressed:!0,network:t?hn.get(t):hn.defaultNetwork};if(Lc.isUndefined(e)||Lc.isNull(e))r.bn=ve._getRandomBN();else if(e instanceof _i)r.bn=e;else if(e instanceof d.Buffer||e instanceof Uint8Array)r=ve._transformBuffer(e,t);else if(e.bn&&e.network)r=ve._transformObject(e);else if(!t&&hn.get(e))r.bn=ve._getRandomBN(),r.network=hn.get(e);else if(typeof e=="string")Ix.isHexa(e)?r.bn=new _i(d.Buffer.from(e,"hex")):r=ve._transformWIF(e,t);else throw new TypeError("First argument is an unrecognized data type.");return r};ve._getRandomBN=function(){var e,t;do{var r=eC.getRandomBuffer(32);t=_i.fromBuffer(r),e=t.lt(Dp.getN())}while(!e);return t};ve._transformBuffer=function(e,t){var r={};if(e.length===32)return ve._transformBNBuffer(e,t);if(r.network=hn.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==hn.get(t))throw new TypeError("Private key network mismatch");if(e.length===34&&e[33]===1)r.compressed=!0;else if(e.length===33)r.compressed=!1;else throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");return r.bn=_i.fromBuffer(e.slice(1,33)),r};ve._transformBNBuffer=function(e,t,r){var n={};return n.network=hn.get(t)||hn.defaultNetwork,n.bn=_i.fromBuffer(e),n.compressed=r===void 0?!0:!!r,n};ve._transformWIF=function(e,t){return ve._transformBuffer(xx.decode(e),t)};ve.fromBuffer=function(e,t,r){return r!==void 0&&e&&e.length===32?new ve(ve._transformBNBuffer(e,t,r)):new ve(e,t)};ve.fromHex=function(e,t,r){return ve.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ve._transformObject=function(e){if(e.bn instanceof _i)return{bn:e.bn,network:hn.get(e.network),compressed:e.compressed};if(typeof e.bn!="string"||!e.bn.length)throw new TypeError("Invalid private key: `bn` must be a hex string");if(e.bn===Lp)throw new TypeError('Invalid private key: `bn` is "'+Lp+'". JSON.stringify() redacts the secret on purpose \u2014 use toObject() for a round-trippable export, or toWIF().');if(!/^[0-9a-fA-F]+$/.test(e.bn))throw new TypeError("Invalid private key: `bn` is not hexadecimal");var t=new _i(e.bn,"hex");if(t.isZero()||t.gte(Dp.getN()))throw new TypeError("Invalid private key: outside the range of valid keys");var r=hn.get(e.network);return{bn:t,network:r,compressed:e.compressed}};ve.fromString=ve.fromWIF=function(e,t){return Ox.checkArgument(Lc.isString(e),"First argument is expected to be a string."),new ve(e,t)};ve.fromObject=ve.fromJSON=function(e){return Ox.checkArgument(Lc.isObject(e),"First argument is expected to be an object."),new ve(e)};ve.fromRandom=function(e){var t=ve._getRandomBN();return new ve(t,e)};ve.getValidationError=function(e,t){var r;try{new ve(e,t)}catch(n){r=n}return r};ve.isValid=function(e,t){return e?!ve.getValidationError(e,t):!1};ve.prototype.toString=function(){return this.toWIF()};ve.prototype.toWIF=function(){var e=this.network,t=this.compressed,r;return t?r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32}),d.Buffer.from([1])]):r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32})]),xx.encode(r)};ve.prototype.toBigNumber=function(){return this.bn};ve.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})};ve.prototype.toHex=function(){return this.toBuffer().toString("hex")};ve.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=Qk.fromPrivateKey(this)),this._pubkey};ve.prototype.toAddress=function(e){var t=this.toPublicKey();return Jk.fromPublicKey(t,e||this.network)};ve.prototype.toObject=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}};ve.prototype.toJSON=function(){return{bn:Lp,compressed:this.compressed,network:this.network.toString()}};ve.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+e+">"};Ax.exports=ve});var Or=B((nq,Tx)=>{"use strict";p();var as=wr(),us=ai(),tC=Jt(),rC=dr(),Rx=pa(),Up=ze(),oo=Le();function pe(e,t){if(!(this instanceof pe))return new pe(e,t);if(oo.checkArgument(e,"First argument is required, please include public key data."),e instanceof pe)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),rC.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||Rx.defaultNetwork}),this}pe.prototype._classifyArgs=function(e,t){var r={compressed:Up.isUndefined(t.compressed)||t.compressed};if(e instanceof us)r.point=e;else if(e.x&&e.y)r=pe._transformObject(e);else if(typeof e=="string")r=pe._transformDER(d.Buffer.from(e,"hex"));else if(pe._isBuffer(e))r=pe._transformDER(e);else if(pe._isPrivateKey(e))r=pe._transformPrivateKey(e);else throw new TypeError("First argument is an unrecognized data format.");return r.network||(r.network=Up.isUndefined(t.network)?void 0:Rx.get(t.network)),r};pe._isPrivateKey=function(e){var t=no();return e instanceof t};pe._isBuffer=function(e){return e instanceof d.Buffer||e instanceof Uint8Array};pe._transformPrivateKey=function(e){oo.checkArgument(pe._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=us.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t};pe._transformDER=function(e,t){oo.checkArgument(pe._isBuffer(e),"Must be a buffer of DER encoded public key");var r={};t=Up.isUndefined(t)?!0:t;var n,i,o,s;if(e[0]===4||!t&&(e[0]===6||e[0]===7)){if(o=e.slice(1,33),s=e.slice(33,65),o.length!==32||s.length!==32||e.length!==65)throw new TypeError("Length of x and y must be 32 bytes");n=new as(o),i=new as(s),r.point=new us(n,i),r.compressed=!1}else if(e[0]===3)o=e.slice(1),n=new as(o),r=pe._transformX(!0,n),r.compressed=!0;else if(e[0]===2)o=e.slice(1),n=new as(o),r=pe._transformX(!1,n),r.compressed=!0;else throw new TypeError("Invalid DER format public key");return r};pe._transformX=function(e,t){oo.checkArgument(typeof e=="boolean","Must specify whether y is odd or not (true or false)");var r={};return r.point=us.fromX(e,t),r};pe._transformObject=function(e){var t=new as(e.x,"hex"),r=new as(e.y,"hex"),n=new us(t,r);return new pe(n,{compressed:e.compressed})};pe.fromPrivateKey=function(e){oo.checkArgument(pe._isPrivateKey(e),"Must be an instance of PrivateKey");var t=pe._transformPrivateKey(e);return new pe(t.point,{compressed:t.compressed,network:t.network})};pe.fromDER=pe.fromBuffer=function(e,t){oo.checkArgument(pe._isBuffer(e),"Must be a buffer of DER encoded public key");var r=pe._transformDER(e,t);return new pe(r.point,{compressed:r.compressed})};pe.fromPoint=function(e,t){return oo.checkArgument(e instanceof us,"First argument must be an instance of Point."),new pe(e,{compressed:t})};pe.fromHex=pe.fromString=function(e,t){var r=d.Buffer.from(e,t||"hex"),n=pe._transformDER(r);return new pe(n.point,{compressed:n.compressed})};pe.fromX=function(e,t){var r=pe._transformX(e,t);return new pe(r.point,{compressed:r.compressed})};pe.getValidationError=function(e){var t;try{new pe(e)}catch(r){t=r}return t};pe.isValid=function(e){return!pe.getValidationError(e)};pe.prototype.toObject=pe.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}};pe.prototype.toBuffer=pe.prototype.toDER=function(){var e=this.point.getX(),t=this.point.getY(),r=e.toBuffer({size:32}),n=t.toBuffer({size:32}),i;if(this.compressed){var o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])}else return i=d.Buffer.from([4]),d.Buffer.concat([i,r,n])};pe.prototype._getID=function(){return tC.sha256ripemd160(this.toBuffer())};pe.prototype.toAddress=function(e){var t=ro();return t.fromPublicKey(this,e||this.network)};pe.prototype.toString=pe.prototype.toHex=function(){return this.toDER().toString("hex")};pe.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"};Tx.exports=pe});var Ha=B((oq,Bx)=>{"use strict";p();var Px=Xs();function nC(){var e=Px.getRandomBuffer(16);e[6]=e[6]&15|64,e[8]=e[8]&63|128;var t=e.toString("hex");return[t.substring(0,8),t.substring(8,12),t.substring(12,16),t.substring(16,20),t.substring(20,32)].join("-")}function iC(e){return Px.getRandomBuffer(Math.ceil(e/2)).toString("hex").substring(0,e)}Bx.exports={uuid4:nC,randomHex:iC}});var Lx=B((uq,Cx)=>{"use strict";p();var Ka=Or(),Fp=Jt(),qp=Ma(),Nx=nr(),jp=no(),Bt=Le(),aq=ze(),oC=Ha();function Mx(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Ka?t.issuerPublicKey:Ka.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Ka.fromString(n):null}catch{return null}}var fs={PROPERTY_TITLE:"PropertyTitle",VEHICLE_TITLE:"VehicleTitle",INTELLECTUAL_PROPERTY:"IntellectualProperty",MUSIC_LICENSE:"MusicLicense",SOFTWARE_LICENSE:"SoftwareLicense",FINANCIAL_INSTRUMENT:"FinancialInstrument",PROMISSORY_NOTE:"PromissoryNote",BOND:"Bond",EQUITY_SHARE:"EquityShare",PROFESSIONAL_LICENSE:"ProfessionalLicense",REGULATORY_PERMIT:"RegulatoryPermit",ACCESS_RIGHT:"AccessRight",VOTING_RIGHT:"VotingRight",ROYALTY_RIGHT:"RoyaltyRight",USAGE_RIGHT:"UsageRight"},kx={create:function(e,t,r,n,i,o){o=o||{},Bt.checkArgument(typeof e=="string","Right type must be string"),Bt.checkArgument(typeof t=="string","Issuer DID must be string"),Bt.checkArgument(typeof r=="string","Subject DID must be string"),Bt.checkArgument(n&&typeof n=="object","Claim must be object");var s=Object.values(fs);Bt.checkArgument(s.includes(e),"Invalid right type: "+e);var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,rightType:e,claim:n,jurisdiction:o.jurisdiction||"US",purpose:o.purpose||"legal_right",validFrom:o.validFrom||new Date().toISOString(),validUntil:o.validUntil||null,transferable:o.transferable!==!1,revocable:o.revocable!==!1}};return o.metadata&&(a.credentialSubject.metadata=o.metadata),a},prepareRightToken:function(e,t,r,n,i,o){o=o||{},Bt.checkArgument(typeof e=="string","Right type must be string"),Bt.checkArgument(typeof t=="string","Issuer DID must be string"),Bt.checkArgument(typeof r=="string","Subject DID must be string"),Bt.checkArgument(n&&typeof n=="object","Claim must be object"),Bt.checkArgument(i instanceof jp,"Invalid issuer private key");var s=Object.values(fs);Bt.checkArgument(s.includes(e),"Invalid right type: "+e);try{var a=this.create(e,t,r,n,i,o),f=this._signToken(a,i);return{success:!0,rightToken:f,tokenHash:f.tokenHash,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction},externalOperations:{storeToken:{endpoint:"POST /rights/tokens",data:{token:f,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction}}},indexToken:{endpoint:"POST /rights/index",data:{tokenId:f.id,tokenHash:f.tokenHash,type:e,issuer:t,subject:r,issuedAt:f.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:f.id,issuer:t,subject:r,rightType:e}}}}}catch(l){return{success:!1,error:l.message}}},prepareRightTokenVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateRightType(e,r),t.requireJurisdiction&&this._validateJurisdiction(e,t.allowedJurisdictions,r);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,subjectDID:e.credentialSubject?e.credentialSubject.id:null,rightType:e.credentialSubject?e.credentialSubject.rightType:null,transferable:e.credentialSubject?e.credentialSubject.transferable:null,revocable:e.credentialSubject?e.credentialSubject.revocable:null,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /rights/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/right-verification",data:{tokenId:e.id,rightType:i.rightType,issuer:i.issuerDID,subject:i.subjectDID,result:i.valid,verifiedAt:i.verifiedAt}},updateTokenStatus:i.valid?{endpoint:"PUT /rights/tokens/"+e.id+"/status",data:{status:"VERIFIED",verifiedAt:i.verifiedAt}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareRightTokenTransfer:function(e,t,r,n){n=n||{},Bt.checkArgument(e&&typeof e=="object","Invalid token"),Bt.checkArgument(typeof t=="string","New owner DID must be string"),Bt.checkArgument(r instanceof jp,"Invalid current owner key");try{var i=this.prepareRightTokenVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot transfer invalid token: "+i.verification.errors.join(", ")};if(!e.credentialSubject.transferable)return{success:!1,error:"Token is not transferable"};var o=e.credentialSubject&&e.credentialSubject.id,s=Mx({issuer:o},{issuerPublicKey:n.currentOwnerPublicKey});if(!s)return{success:!1,error:"Cannot resolve current owner public key from token.credentialSubject.id; pass options.currentOwnerPublicKey"};if(r.toPublicKey().toString()!==s.toString())return{success:!1,error:"Unauthorized transfer: signing key does not match the current owner"};var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightTransfer"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,originalToken:e.id,transferFrom:e.credentialSubject.id,transferTo:t,transferDate:new Date().toISOString(),transferReason:n.reason||"ownership_transfer",consideration:n.consideration||null}},f=this._signToken(a,r),l=JSON.parse(JSON.stringify(e));l.id="urn:uuid:"+this._generateUUID(),l.issuanceDate=new Date().toISOString(),l.credentialSubject.id=t,l.credentialSubject.transferHistory=l.credentialSubject.transferHistory||[],l.credentialSubject.transferHistory.push({transferId:f.id,transferDate:f.issuanceDate,from:e.credentialSubject.id,to:t}),delete l.proof;var m=this._signToken(l,r);return{success:!0,newToken:m,transferProof:f,transferId:f.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:e.id,newTokenId:m.id,transferProof:f,fromOwner:e.credentialSubject.id,toOwner:t,transferDate:f.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+e.id+"/ownership",data:{newOwner:t,transferId:f.id,transferDate:f.issuanceDate,previousOwner:e.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:e.id,newTokenId:m.id,fromOwner:e.credentialSubject.id,toOwner:t,rightType:e.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:e.id,newTokenId:m.id,transferId:f.id,fromOwner:e.credentialSubject.id,toOwner:t,transferredAt:f.issuanceDate}}}}}catch(g){return{success:!1,error:g.message}}},prepareObligationToken:function(e,t,r,n){Bt.checkArgument(e&&typeof e=="object","Invalid right token"),Bt.checkArgument(typeof t=="string","Obligor DID must be string"),Bt.checkArgument(r&&typeof r=="object","Obligation must be object"),Bt.checkArgument(n instanceof jp,"Invalid issuer key");try{var i={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken"],issuer:e.issuer,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,obligationType:"correlative_obligation",correlativeRight:e.id,rightHolder:e.credentialSubject.id,obligation:r,jurisdiction:e.credentialSubject.jurisdiction,purpose:e.credentialSubject.purpose}},o=this._signToken(i,n);return{success:!0,obligationToken:o,correlativeRight:e.id,externalOperations:{storeObligation:{endpoint:"POST /obligations/tokens",data:{obligationToken:o,correlativeRightId:e.id,obligor:t,rightHolder:e.credentialSubject.id}},linkToRight:{endpoint:"POST /rights/tokens/"+e.id+"/obligations",data:{obligationId:o.id,obligor:t,obligationType:"correlative_obligation"}},notifyObligor:{endpoint:"POST /notifications/obligation-created",data:{obligationId:o.id,obligor:t,rightHolder:e.credentialSubject.id,correlativeRight:e.id}}}}}catch(s){return{success:!1,error:s.message}}},prepareRightTypeValidation:function(e){Bt.checkArgument(typeof e=="string","Right type must be string");var t=Object.values(fs),r=t.includes(e);return{success:!0,validation:{type:e,valid:r,availableTypes:t,category:this._categorizeRightType(e),description:this._getRightTypeDescription(e)},externalOperations:{validateType:{endpoint:"POST /rights/validate-type",data:{type:e,valid:r}}}}},_categorizeRightType:function(e){var t={PropertyTitle:"PROPERTY_RIGHT",VehicleTitle:"PROPERTY_RIGHT",IntellectualProperty:"IP_RIGHT",MusicLicense:"IP_RIGHT",SoftwareLicense:"IP_RIGHT",FinancialInstrument:"FINANCIAL_RIGHT",PromissoryNote:"FINANCIAL_RIGHT",Bond:"FINANCIAL_RIGHT",EquityShare:"FINANCIAL_RIGHT",ProfessionalLicense:"LICENSE_RIGHT",RegulatoryPermit:"LICENSE_RIGHT",AccessRight:"ACCESS_RIGHT",VotingRight:"GOVERNANCE_RIGHT",RoyaltyRight:"IP_RIGHT",UsageRight:"ACCESS_RIGHT"};return t[e]||"UNKNOWN"},_getRightTypeDescription:function(e){var t={PropertyTitle:"Legal ownership of real estate property",VehicleTitle:"Legal ownership of motor vehicle",IntellectualProperty:"Rights to intellectual property assets",MusicLicense:"License for music performance and usage",SoftwareLicense:"License for software usage and distribution",FinancialInstrument:"Rights related to financial instruments",PromissoryNote:"Promise to pay a specified amount",Bond:"Debt security representing loan",EquityShare:"Ownership stake in company",ProfessionalLicense:"License for professional practice",RegulatoryPermit:"Permit for regulated activities",AccessRight:"Right to access resources or locations",VotingRight:"Right to participate in governance",RoyaltyRight:"Right to receive royalty payments",UsageRight:"Right to use specific assets or services"};return t[e]||"Unknown right type"},getRightTypes:function(){return fs},verifyToken:function(e,t){var r=[];try{if(Bt.checkArgument(e&&typeof e=="object","Invalid token"),!e.proof||!e.proof.jws)return r.push("Missing signature proof"),{valid:!1,errors:r};var n=t instanceof Ka?t:Ka.fromString(t),i=this._canonicalizeToken(e),o=Fp.sha256(d.Buffer.from(i));if(e.tokenHash&&e.tokenHash!==o.toString("hex"))return r.push("Token hash mismatch"),{valid:!1,errors:r};var s=e.proof.jws.split(".");if(s.length!==3||!s[2])return r.push("Malformed JWS"),{valid:!1,errors:r};var a=Nx.fromDER(d.Buffer.from(s[2],"base64url")),f=new qp;return f.hashbuf=o,f.sig=a,f.pubkey=n,f.verify()||r.push("Signature verification failed"),{valid:r.length===0,errors:r,tokenHash:o.toString("hex"),verifiedAt:new Date().toISOString()}}catch(l){return r.push(l.message),{valid:!1,errors:r}}},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Fp.sha256(d.Buffer.from(r)),i=new qp;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=t.toDER().toString("base64url");return n+".."+i},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Fp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=Mx(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=Nx.fromDER(d.Buffer.from(s[2],"base64url")),f=new qp;f.hashbuf=i,f.sig=a,f.pubkey=o,f.verify()!==!0&&t.push("Signature verification failed")}catch(l){t.push("Signature verification failed: "+l.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.validFrom){var o=new Date(e.credentialSubject.validFrom);n<o&&r.push("Token not yet valid")}if(e.credentialSubject.validUntil){var s=new Date(e.credentialSubject.validUntil);n>s&&t.push("Token expired")}},_validateRightType:function(e,t){if(!e.credentialSubject.rightType){t.push("Missing rightType");return}var r=Object.values(fs);r.includes(e.credentialSubject.rightType)||t.push("Invalid right type: "+e.credentialSubject.rightType)},_validateJurisdiction:function(e,t,r){if(!e.credentialSubject.jurisdiction){r.push("Missing jurisdiction");return}t&&Array.isArray(t)&&(t.includes(e.credentialSubject.jurisdiction)||r.push("Jurisdiction not allowed: "+e.credentialSubject.jurisdiction))},_generateUUID:function(){return oC.uuid4()}};kx.RightTypes=fs;Cx.exports=kx});var Ux=B((cq,Dx)=>{"use strict";p();var Ga=Jt(),gr=Le(),sC=Ha(),so={PropertyTitle:{title:"Property Title",description:"Real estate property ownership title",type:"object",required:["propertyId","address","ownershipType"],properties:{propertyId:{type:"string",description:"Unique property identifier"},address:{type:"object",required:["street","city","state","country"],properties:{street:{type:"string"},city:{type:"string"},state:{type:"string"},country:{type:"string"},postalCode:{type:"string"}}},ownershipType:{type:"string",enum:["fee_simple","leasehold","joint_tenancy","tenancy_in_common"]},titleNumber:{type:"string"},registeredDate:{type:"string",format:"date-time"},legalDescription:{type:"string"},encumbrances:{type:"array",items:{type:"object",properties:{type:{type:"string"},amount:{type:"number"},description:{type:"string"}}}}}},VehicleTitle:{title:"Vehicle Title",description:"Motor vehicle ownership title",type:"object",required:["vin","make","model","year"],properties:{vin:{type:"string",pattern:"^[A-HJ-NPR-Z0-9]{17}$",description:"Vehicle Identification Number"},make:{type:"string"},model:{type:"string"},year:{type:"integer",minimum:1900,maximum:2030},titleNumber:{type:"string"},registeredState:{type:"string"},mileage:{type:"integer",minimum:0},color:{type:"string"},fuelType:{type:"string",enum:["gasoline","diesel","electric","hybrid","other"]},liens:{type:"array",items:{type:"object",properties:{lienholderName:{type:"string"},lienAmount:{type:"number"},lienDate:{type:"string",format:"date"}}}}}},PromissoryNote:{title:"Promissory Note",description:"Legal promise to pay a specified amount",type:"object",required:["principal","interestRate","maturityDate","borrower","lender"],properties:{principalAmount:{type:"number",minimum:0,description:"Principal amount in base currency units"},currency:{type:"string",default:"USD"},interestRate:{type:"number",minimum:0,maximum:100,description:"Annual interest rate percentage"},maturityDate:{type:"string",format:"date",description:"Date when principal and interest are due"},payee:{type:"string",description:"DID of the payee (creditor)"},payor:{type:"string",description:"DID of the payor (debtor)"},paymentSchedule:{type:"string",enum:["lump_sum","monthly","quarterly","annually"]},collateral:{type:"array",items:{type:"object",properties:{description:{type:"string"},value:{type:"number"},type:{type:"string"}}}},defaultProvisions:{type:"string"},governingLaw:{type:"string"}}},IntellectualProperty:{title:"Intellectual Property",description:"Intellectual property rights and licensing",type:"object",required:["ipType","title","registrationNumber"],properties:{ipType:{type:"string",enum:["patent","trademark","copyright","trade_secret"]},title:{type:"string"},creator:{type:"string",description:"Creator DID"},registrationNumber:{type:"string"},registrationDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},jurisdiction:{type:"string"},description:{type:"string"},claims:{type:"array",items:{type:"string"}},priorArt:{type:"array",items:{type:"object",properties:{reference:{type:"string"},date:{type:"string",format:"date"},relevance:{type:"string"}}}}}},ProfessionalLicense:{title:"Professional License",description:"Professional practice license or certification",type:"object",required:["licenseType","licenseNumber","issuingAuthority","expirationDate"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},licensee:{type:"string",description:"Licensee DID"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},renewalDate:{type:"string",format:"date"},jurisdiction:{type:"string"},scope:{type:"string"},restrictions:{type:"array",items:{type:"string"}},continuing_education:{type:"object",properties:{hours_required:{type:"integer"},deadline:{type:"string",format:"date"},completed_hours:{type:"integer"}}}}},MusicLicense:{title:"Music License",description:"Music performance and usage licensing",type:"object",required:["songTitle","artist","licenseType","royaltyRate"],properties:{workTitle:{type:"string"},composer:{type:"string",description:"Composer DID"},performer:{type:"string",description:"Performer DID"},licenseType:{type:"string",enum:["mechanical","performance","synchronization","master_use"]},territory:{type:"string"},duration:{type:"string"},royaltyRate:{type:"number",minimum:0,maximum:100},advancePayment:{type:"number",minimum:0},exclusivity:{type:"boolean"},mediaTypes:{type:"array",items:{type:"string",enum:["cd","vinyl","digital","streaming","broadcast","film","tv"]}},usage_restrictions:{type:"string"},copyrightNotice:{type:"string"}}}},aC={prepareClaimValidation:function(e,t){try{gr.checkArgument(e&&typeof e=="object","Invalid claim"),gr.checkArgument(typeof t=="string","Schema name must be string");var r=so[t];if(!r)return{success:!1,error:"Unknown schema: "+t};var n=[],i=[];this._validateObject(e,r,"",n,i);var o={valid:n.length===0,errors:n,warnings:i,schema:t,claimHash:this.hash(e),canonical:this.canonicalize(e)};return{success:!0,validation:o,claim:e,schema:r,externalOperations:{store:{endpoint:"POST /claims/validate",data:{claim:e,validation:o,schema:t}},index:{endpoint:"POST /claims/index",data:{claimHash:o.claimHash,schemaName:t,valid:o.valid}}}}}catch(s){return{success:!1,error:"Validation preparation failed: "+s.message}}},prepareClaimAttestation:function(e,t,r){try{gr.checkArgument(e&&typeof e=="object","Invalid claim"),gr.checkArgument(typeof t=="string","Schema name must be string"),gr.checkArgument(r&&typeof r=="object","Invalid attestor");var n=this.prepareClaimValidation(e,t);if(!n.success||!n.validation.valid)return{success:!1,error:"Cannot attest invalid claim",validation:n};var i={type:"LTP_CLAIM_ATTESTATION",claimHash:n.validation.claimHash,schemaName:t,attestor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},attestedAt:new Date().toISOString(),confidence:r.confidence||100,evidence:r.evidence||null,notes:r.notes||null},o=Ga.sha256(d.Buffer.from(this.canonicalize(i))).toString("hex");return i.attestationHash=o,{success:!0,attestation:i,claim:e,validation:n.validation,externalOperations:{storeAttestation:{endpoint:"POST /claims/"+n.validation.claimHash+"/attestations",data:i},notifyStakeholders:{endpoint:"POST /notifications/claim-attested",data:{claimHash:n.validation.claimHash,attestorDid:i.attestor.did,attestationHash:o}}}}}catch(s){return{success:!1,error:"Attestation preparation failed: "+s.message}}},prepareClaimDispute:function(e,t,r){try{gr.checkArgument(typeof e=="string","Claim hash must be string"),gr.checkArgument(t&&typeof t=="object","Invalid disputant"),gr.checkArgument(r&&typeof r=="object","Invalid dispute");var n={type:"LTP_CLAIM_DISPUTE",claimHash:e,disputant:{did:t.did||t.id,name:t.name||"Unknown",jurisdiction:t.jurisdiction||null},dispute:{reason:r.reason||"UNSPECIFIED",category:r.category||"ACCURACY",description:r.description||"",evidence:r.evidence||null,requestedAction:r.requestedAction||"REVIEW"},disputedAt:new Date().toISOString(),status:"FILED",priority:r.priority||"NORMAL"},i=Ga.sha256(d.Buffer.from(this.canonicalize(n))).toString("hex");return n.disputeHash=i,{success:!0,dispute:n,disputeId:this._generateDisputeId(e),externalOperations:{fileDispute:{endpoint:"POST /claims/"+e+"/disputes",data:n},notifyStakeholders:{endpoint:"POST /notifications/claim-disputed",data:{claimHash:e,disputantDid:n.disputant.did,disputeHash:i}},escalate:{endpoint:"POST /disputes/escalate",data:{disputeHash:i,priority:n.priority}}}}}catch(o){return{success:!1,error:"Dispute preparation failed: "+o.message}}},prepareBulkClaimValidation:function(e,t){try{gr.checkArgument(Array.isArray(e),"Claims must be array"),gr.checkArgument(typeof t=="string","Schema name must be string");var r=[],n=[],i=0;e.forEach(function(a,f){try{var l=this.prepareClaimValidation(a,t);l.success&&l.validation.valid&&i++,r.push({index:f,result:l})}catch(m){n.push({index:f,error:m.message})}}.bind(this));var o=this._generateBatchId(),s=Ga.sha256(d.Buffer.from(JSON.stringify(r.map(a=>a.result.validation.claimHash)))).toString("hex");return{success:!0,batchId:o,batchHash:s,totalClaims:e.length,validClaims:i,invalidClaims:e.length-i,validations:r,errors:n,externalOperations:{storeBatch:{endpoint:"POST /claims/batch-validate",data:{batchId:o,batchHash:s,schemaName:t,validations:r}},generateReport:{endpoint:"POST /reports/bulk-validation",data:{batchId:o,summary:{total:e.length,valid:i,invalid:e.length-i}}}}}}catch(a){return{success:!1,error:"Bulk validation preparation failed: "+a.message}}},canonicalize:function(e){gr.checkArgument(e&&typeof e=="object","Invalid claim");var t=this._sortObjectKeys(e);return JSON.stringify(t)},hash:function(e){var t=this.canonicalize(e);return Ga.sha256(d.Buffer.from(t)).toString("hex")},prepareClaimTemplate:function(e,t){t=t||{};try{var r=so[e];if(!r)return{success:!1,error:"Unknown schema: "+e};var n=this._createTemplateFromSchema(r),i=this._generateFormStructure(r);return{success:!0,schemaName:e,template:n,schema:r,formStructure:i,validation:{required:r.required||[],patterns:this._extractPatterns(r),enums:this._extractEnums(r)},externalOperations:{generateForm:{endpoint:"POST /forms/generate",data:{schemaName:e,formStructure:i,template:n}},saveTemplate:{endpoint:"POST /templates/claim",data:{schemaName:e,template:n,customizations:t.customizations||{}}}}}}catch(o){return{success:!1,error:"Template preparation failed: "+o.message}}},getSchemas:function(){return so},getSchemaNames:function(){return Object.keys(so)},getSchema:function(e){return so[e]||null},addSchema:function(e,t){gr.checkArgument(typeof e=="string","Schema name must be string"),gr.checkArgument(t&&typeof t=="object","Invalid schema"),so[e]=t},createTemplate:function(e){var t=so[e];if(!t)throw new Error("Unknown schema: "+e);return this._createTemplateFromSchema(t)},_generateDisputeId:function(e){var t="dispute_"+e+"_"+Date.now();return Ga.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateBatchId:function(){return sC.randomHex(16)},_generateFormStructure:function(e){var t={type:"form",title:e.title||"Legal Claim Form",description:e.description||"",fields:[]};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r],i={name:r,label:this._humanizeFieldName(r),type:this._mapSchemaTypeToFormType(n),required:e.required&&e.required.includes(r),validation:this._extractFieldValidation(n)};n.enum&&(i.options=n.enum.map(function(o){return{value:o,label:this._humanizeValue(o)}}.bind(this))),t.fields.push(i)}.bind(this)),t},_extractPatterns:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.pattern&&(t[r]=n.pattern)}),t},_extractEnums:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.enum&&(t[r]=n.enum)}),t},_mapSchemaTypeToFormType:function(e){switch(e.type){case"string":return e.enum?"select":e.format==="date"?"date":e.format==="date-time"?"datetime":"text";case"number":case"integer":return"number";case"boolean":return"checkbox";case"array":return"list";case"object":return"fieldset";default:return"text"}},_extractFieldValidation:function(e){var t={};return e.pattern&&(t.pattern=e.pattern),e.minimum!==void 0&&(t.min=e.minimum),e.maximum!==void 0&&(t.max=e.maximum),e.format&&(t.format=e.format),t},_humanizeFieldName:function(e){return e.replace(/([A-Z])/g," $1").replace(/^./,function(t){return t.toUpperCase()}).replace(/_/g," ")},_humanizeValue:function(e){return e.replace(/_/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()})},_validateObject:function(e,t,r,n,i){t.type==="object"?(t.required&&Array.isArray(t.required)&&t.required.forEach(function(o){e.hasOwnProperty(o)||n.push("Missing required field: "+this._getFieldPath(r,o))}.bind(this)),t.properties&&Object.keys(e).forEach(function(o){var s=this._getFieldPath(r,o),a=t.properties[o];a?this._validateValue(e[o],a,s,n,i):i.push("Unknown field: "+s)}.bind(this))):this._validateValue(e,t,r,n,i)},_validateValue:function(e,t,r,n,i){if(t.type){var o=Array.isArray(e)?"array":typeof e;if(o!==t.type){n.push("Invalid type for "+r+": expected "+t.type+", got "+o);return}}if(t.type==="string"&&(t.pattern&&!new RegExp(t.pattern).test(e)&&n.push("Value does not match pattern for "+r),t.enum&&!t.enum.includes(e)&&n.push("Invalid enum value for "+r+": "+e),t.format==="date"&&!this._isValidDate(e)&&n.push("Invalid date format for "+r),t.format==="date-time"&&!this._isValidDateTime(e)&&n.push("Invalid date-time format for "+r)),(t.type==="number"||t.type==="integer")&&(t.minimum!==void 0&&e<t.minimum&&n.push("Value below minimum for "+r+": "+e+" < "+t.minimum),t.maximum!==void 0&&e>t.maximum&&n.push("Value above maximum for "+r+": "+e+" > "+t.maximum),t.type==="integer"&&!Number.isInteger(e)&&n.push("Value must be integer for "+r)),t.type==="array"&&t.items)for(var s=0;s<e.length;s++)this._validateValue(e[s],t.items,r+"["+s+"]",n,i);t.type==="object"&&this._validateObject(e,t,r,n,i)},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_createTemplateFromSchema:function(e){if(e.type==="object"){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];t[r]=this._getDefaultValue(n)}.bind(this)),t}return this._getDefaultValue(e)},_getDefaultValue:function(e){if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:e.format==="date"?"2023-01-01":e.format==="date-time"?new Date().toISOString():"PLACEHOLDER_STRING";case"number":case"integer":return e.minimum||0;case"boolean":return!1;case"array":return[];case"object":return this._createTemplateFromSchema(e);default:return null}},_getFieldPath:function(e,t){return e?e+"."+t:t},_isValidDate:function(e){var t=new Date(e);return!isNaN(t.getTime())&&e.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(e){var t=new Date(e);return!isNaN(t.getTime())}};Dx.exports=aC});var qx=B((hq,Fx)=>{"use strict";p();var Va=Jt(),cs=Le(),uC={prepareTokenCommitment:function(e,t){t=t||{},cs.checkArgument(e&&typeof e=="object","Invalid token");try{var r=this._createCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,commitment:r,opReturnData:n,txTemplate:i,preparedAt:new Date().toISOString(),metadata:{tokenId:e.id,purpose:t.purpose||"legal_token_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},prepareBatchCommitment:function(e,t){t=t||{},cs.checkArgument(Array.isArray(e),"Tokens must be array");try{var r=this._createBatchCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,batchCommitment:r,opReturnData:n,txTemplate:i,tokenCount:e.length,preparedAt:new Date().toISOString(),metadata:{purpose:t.purpose||"legal_token_batch_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},verifyTokenAnchor:function(e,t,r){cs.checkArgument(e&&typeof e=="object","Invalid token"),cs.checkArgument(typeof t=="string","Transaction ID must be string");try{var n=this._createCommitment(e,{}),i=this._extractOpReturn(r);if(!i)return{valid:!1,error:"No OP_RETURN data found in transaction"};var o=this._verifyCommitment(n,i);return{valid:o,chainVerified:!1,txid:t,commitment:n,anchorData:i,verifiedAt:new Date().toISOString()}}catch(s){return{valid:!1,error:s.message}}},formatRevocation:function(e,t){cs.checkArgument(typeof e=="string","Token ID must be string"),cs.checkArgument(t&&typeof t=="object","Invalid revocation data");try{var r={type:"LTP_REVOCATION",tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null},n=Va.sha256(d.Buffer.from(JSON.stringify(r))).toString("hex");return{success:!0,revocation:r,revocationHash:n,opReturnData:this._formatOpReturn({hash:n,type:"REVOCATION"},{})}}catch(i){return{success:!1,error:i.message}}},_createCommitment:function(e,t){var r=this._canonicalizeToken(e),n={type:"LTP_TOKEN",tokenHash:Va.sha256(d.Buffer.from(r)).toString("hex"),tokenId:e.id,timestamp:new Date().toISOString(),purpose:t.purpose||"legal_token"},i=Va.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return{hash:i,data:n,canonical:r}},_createBatchCommitment:function(e,t){var r=[],n=[];e.forEach(function(a){var f=this._createCommitment(a,t);r.push(f.hash),n.push(a.id)}.bind(this));var i=this._createMerkleRoot(r),o={type:"LTP_BATCH",merkleRoot:i,tokenCount:e.length,tokenIds:n,timestamp:new Date().toISOString(),purpose:t.purpose||"batch_anchor"},s=Va.sha256(d.Buffer.from(JSON.stringify(o))).toString("hex");return{hash:s,data:o,merkleRoot:i,tokenHashes:r}},_formatOpReturn:function(e,t){var r=t.prefix||"LTP.v1",n=e.hash;return{prefix:r,data:n,full:r+"."+n,bytes:d.Buffer.from(r+"."+n,"utf8"),size:d.Buffer.from(r+"."+n,"utf8").length}},_createTxTemplate:function(e,t){try{var r={version:1,inputs:[],outputs:[{satoshis:0,script:"OP_RETURN "+e.data}],locktime:0};return t.feeOutput&&r.outputs.push(t.feeOutput),{template:r,opReturn:e,estimatedSize:this._estimateSize(r),instructions:{step1:"Add input UTXOs to cover fees",step2:"Add change output if needed",step3:"Sign transaction with appropriate keys",step4:"Broadcast to BSV network"}}}catch(n){throw new Error("Failed to create transaction template: "+n.message)}},_extractOpReturn:function(e){try{if(!e||!e.outputs)return null;for(var t=0;t<e.outputs.length;t++){var r=e.outputs[t];if(r.script&&r.script.startsWith("OP_RETURN")){var n=r.script.replace("OP_RETURN ","");return{raw:n,decoded:d.Buffer.from(n,"hex").toString("utf8")}}}return null}catch{return null}},_verifyCommitment:function(e,t){try{return!t||!t.decoded?!1:t.decoded.includes(e.hash)}catch{return!1}},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,delete t.anchorTx,delete t.anchorBlock,JSON.stringify(this._sortObjectKeys(t))},_createMerkleRoot:function(e){if(e.length===0)return null;if(e.length===1)return e[0];for(var t=e.slice();t.length>1;){for(var r=[],n=0;n<t.length;n+=2){var i=t[n],o=t[n+1]||i,s=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(o,"hex")]),a=Va.sha256(s).toString("hex");r.push(a)}t=r}return t[0]},_estimateSize:function(e){var t=10,r=e.outputs.length*34,n=148;return{base:t+r,withOneInput:t+r+n,bytesPerInput:n}},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};Fx.exports=uC});var Kx=B((pq,Hx)=>{"use strict";p();var fC=Or(),Vr=Jt(),jx=Ma(),cC=nr(),lC=no(),ir=Le(),hC={prepareSignatureProof:function(e,t,r){r=r||{},ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(t instanceof lC,"Invalid private key");try{var n=this._canonicalizeForSigning(e),i=Vr.sha256(d.Buffer.from(n)),o=new jx;o.hashbuf=i,o.privkey=t,o.pubkey=t.toPublicKey(),o.sign();var s=o.sig,a={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:r.purpose||"assertionMethod",jws:this._createJWS(i,s),proofValue:s.toDER().toString("hex")};return{success:!0,proof:a,tokenHash:i.toString("hex"),canonical:n,signingKey:{publicKey:t.toPublicKey().toString(),keyId:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1"},externalOperations:{storeProof:{endpoint:"POST /proofs/signature",data:{tokenHash:i.toString("hex"),proof:a,signingKey:t.toPublicKey().toString()}},verifyProof:{endpoint:"POST /proofs/verify-signature",data:{tokenHash:i.toString("hex"),signature:s.toDER().toString("hex"),publicKey:t.toPublicKey().toString()}}}}}catch(f){return{success:!1,error:f.message}}},prepareSignatureVerification:function(e,t){try{if(ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(typeof t=="string","Public key must be string"),!e.proof)return{success:!1,error:"No proof found in token"};var r=this._canonicalizeForSigning(e),n=Vr.sha256(d.Buffer.from(r)),i=cC.fromDER(d.Buffer.from(e.proof.proofValue,"hex")),o={tokenHash:n.toString("hex"),signature:i.toDER().toString("hex"),publicKey:t,proof:e.proof,canonical:r},s=new jx;s.hashbuf=n,s.sig=i,s.pubkey=fC.fromString(t);var a=s.verify()===!0;return{success:!0,verification:{valid:a,tokenHash:n.toString("hex"),signatureValid:a,publicKey:t,verifiedAt:new Date().toISOString()},verificationData:o,externalOperations:{recordVerification:{endpoint:"POST /proofs/verification-record",data:{tokenHash:n.toString("hex"),result:a,publicKey:t,verifiedAt:new Date().toISOString()}},auditVerification:{endpoint:"POST /audit/proof-verification",data:{tokenId:e.id,proofType:e.proof.type,result:a,verifier:t}}}}}catch(f){return{success:!1,error:f.message}}},prepareSelectiveDisclosure:function(e,t,r){ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(Array.isArray(t),"Revealed fields must be array"),ir.checkArgument(typeof r=="string","Nonce must be string");try{var n=this._createFieldCommitments(e,r),i=this._createMerkleTree(n),o=[],s=[];t.forEach(function(f){var l=this._getNestedValue(e,f),m=this._findFieldCommitment(n,f);if(m){o.push({path:f,value:l,commitment:m.hash,salt:m.salt});var g=this._generateMerkleProof(i,m.index);s.push({path:f,leafIndex:m.index,proof:g})}}.bind(this));var a={type:"LegalTokenSelectiveDisclosure",created:new Date().toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:e.proof?e.proof.verificationMethod:null,nonce:r,merkleRoot:i.root,disclosures:o,merkleProofs:s,totalFields:n.length};return{success:!0,proof:a,hiddenFieldCount:n.length-o.length,revealedFieldCount:o.length,externalOperations:{storeDisclosure:{endpoint:"POST /proofs/selective-disclosure",data:{tokenId:e.id,proof:a,merkleRoot:i.root}},verifyDisclosure:{endpoint:"POST /proofs/verify-disclosure",data:{proof:a,expectedNonce:r}},auditDisclosure:{endpoint:"POST /audit/selective-disclosure",data:{tokenId:e.id,revealedFields:t,totalFields:n.length,disclosedAt:new Date().toISOString()}}}}}catch(f){return{success:!1,error:f.message}}},prepareSelectiveDisclosureVerification:function(e,t){try{if(ir.checkArgument(e&&typeof e=="object","Invalid proof"),ir.checkArgument(typeof t=="string","Expected nonce must be string"),e.nonce!==t)return{success:!1,error:"Nonce mismatch"};var r=[],n=[];e.disclosures.forEach(function(o,s){var a=e.merkleProofs[s],f=this._hashField(o.path,o.value,o.salt);if(f!==o.commitment){n.push("Invalid commitment for field: "+o.path);return}var l=this._verifyMerkleProof(o.commitment,a.leafIndex,a.proof,e.merkleRoot);l?r.push({path:o.path,value:o.value,verified:!0}):n.push("Invalid Merkle proof for field: "+o.path)}.bind(this));var i={valid:n.length===0,errors:n,disclosures:r,merkleRoot:e.merkleRoot,totalFields:e.totalFields,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /proofs/disclosure-verification",data:{proofId:e.id||"unknown",result:i.valid,verifiedFields:r.length,totalFields:e.totalFields,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/disclosure-verification",data:{merkleRoot:e.merkleRoot,disclosuresVerified:r.length,errors:n.length,result:i.valid}}}}}catch(o){return{success:!1,error:o.message}}},prepareLegalValidityProof:function(e,t,r){ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(t&&typeof t=="object","Invalid jurisdiction"),ir.checkArgument(typeof r=="string","Nonce must be string");try{var n=t.requirements||[],i=[],o=!0;n.forEach(function(a){var f=this._checkLegalRequirement(e,a);i.push(f),f.satisfied||(o=!1)}.bind(this));var s={type:"LegalValidityProof",created:new Date().toISOString(),proofPurpose:"legalValidity",jurisdiction:t.code,nonce:r,valid:o,checks:i,complianceHash:this._hashCompliance(e,t,r)};return{success:!0,proof:s,valid:o,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o},externalOperations:{submitCompliance:{endpoint:"POST /compliance/legal-validity",data:{tokenId:e.id,jurisdiction:t.code,proof:s,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o}}},auditCompliance:{endpoint:"POST /audit/compliance-check",data:{tokenId:e.id,jurisdiction:t.code,result:o,checkedAt:new Date().toISOString(),requirements:i}},notifyRegulator:o?null:{endpoint:"POST /notifications/compliance-failure",data:{tokenId:e.id,jurisdiction:t.code,failedRequirements:i.filter(a=>!a.satisfied)}}}}}catch(a){return{success:!1,error:a.message}}},prepareZeroKnowledgeProof:function(e,t,r){ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(t&&typeof t=="object","Invalid statement"),ir.checkArgument(typeof r=="string","Nonce must be string");try{var n=Vr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+r)).toString("hex"),i={type:"LegalTokenZKProof",created:new Date().toISOString(),proofPurpose:"zeroKnowledge",statement:{claim:t.claim||"UNSPECIFIED",predicate:t.predicate||"SATISFIES",threshold:t.threshold||null},commitment:n,nonce:r,proofData:this._generateZKProofData(e,t,r)};return{success:!0,proof:i,commitment:n,externalOperations:{storeZKProof:{endpoint:"POST /proofs/zero-knowledge",data:{tokenId:e.id,proof:i,statement:t}},verifyZKProof:{endpoint:"POST /proofs/verify-zk",data:{proof:i,expectedNonce:r}},auditZKProof:{endpoint:"POST /audit/zk-proof",data:{tokenId:e.id,statement:t.claim,proofGenerated:new Date().toISOString()}}}}}catch(o){return{success:!1,error:o.message}}},_generateZKProofData:function(e,t,r){var n={challenge:Vr.sha256(d.Buffer.from(t.claim+r)).toString("hex"),response:Vr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+t.claim)).toString("hex"),witness:Vr.sha256(d.Buffer.from(r+e.id+t.predicate)).toString("hex")};return n},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeForSigning:function(e){var t=JSON.parse(JSON.stringify(e));delete t.proof,delete t.tokenHash;var r=this._sortObjectKeys(t);return JSON.stringify(r)},_createFieldCommitments:function(e,t){var r=[],n=0;return this._traverseObject(e,"",function(i,o){if(i!=="proof"&&i!=="tokenHash"){var s=Vr.sha256(d.Buffer.from(t+i+n)).toString("hex"),a=this._hashField(i,o,s);r.push({path:i,value:o,salt:s,hash:a,index:n}),n++}}.bind(this)),r},_hashField:function(e,t,r){var n=e+":"+JSON.stringify(t)+":"+r;return Vr.sha256(d.Buffer.from(n)).toString("hex")},_createMerkleTree:function(e){var t=e.map(function(m){return m.hash});if(t.length===0)return{root:null,levels:[]};for(var r=[t],n=t;n.length>1;){for(var i=[],o=0;o<n.length;o+=2){var s=n[o],a=n[o+1]||s,f=d.Buffer.concat([d.Buffer.from(s,"hex"),d.Buffer.from(a,"hex")]),l=Vr.sha256(f).toString("hex");i.push(l)}r.push(i),n=i}return{root:n[0],levels:r}},_generateMerkleProof:function(e,t){for(var r=[],n=t,i=0;i<e.levels.length-1;i++){var o=e.levels[i],s=n%2===0,a=s?n+1:n-1;a<o.length&&r.push({hash:o[a],isLeft:!s}),n=Math.floor(n/2)}return r},_verifyMerkleProof:function(e,t,r,n){for(var i=e,o=t,s=0;s<r.length;s++){var a=r[s],f=o%2===0,l;a.isLeft?l=d.Buffer.concat([d.Buffer.from(a.hash,"hex"),d.Buffer.from(i,"hex")]):l=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(a.hash,"hex")]),i=Vr.sha256(l).toString("hex"),o=Math.floor(o/2)}return i===n},_traverseObject:function(e,t,r){Array.isArray(e)?e.forEach(function(n,i){var o=t+"["+i+"]";this._traverseObject(n,o,r)}.bind(this)):e!==null&&typeof e=="object"?Object.keys(e).forEach(function(n){var i=t?t+"."+n:n;this._traverseObject(e[n],i,r)}.bind(this)):r(t,e)},_getNestedValue:function(e,t){return t.split(".").reduce(function(r,n){return r&&r[n]},e)},_findFieldCommitment:function(e,t){return e.find(function(r){return r.path===t})},_checkLegalRequirement:function(e,t){switch(t.type){case"field_present":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r!=null};case"field_value":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r===t.expectedValue};case"temporal_validity":var n=new Date,i=new Date(e.issuanceDate);return{requirement:t.type,satisfied:i<=n};default:return{requirement:t.type,satisfied:!1,error:"Unknown requirement type"}}},_hashCompliance:function(e,t,r){var n={tokenId:e.id,jurisdiction:t.code,nonce:r,timestamp:new Date().toISOString()};return Vr.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex")},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};Hx.exports=hC});var Wx=B((vq,Vx)=>{"use strict";p();var Wa=Jt(),yq=ro(),mq=Pp(),cr=Le(),Gx=Ha(),dC={prepareRegistry:function(e){e=e||{},cr.checkArgument(typeof e=="object","Config must be object");var t={id:e.id||this._generateRegistryId(),name:e.name||"Legal Token Registry",jurisdiction:e.jurisdiction||"GLOBAL",authority:e.authority||null,created:new Date().toISOString(),version:"1.0.0",config:{allowPublicRegistration:e.allowPublicRegistration||!1,requireApproval:e.requireApproval||!0,enableRevocation:e.enableRevocation!==!1,enableAuditTrail:e.enableAuditTrail!==!1,retentionPeriod:e.retentionPeriod||"7Y",complianceLevel:e.complianceLevel||"STANDARD"},dataStructure:{tokens:"Map<tokenId, registrationRecord>",revocations:"Map<tokenId, revocationRecord>",auditLog:"Array<auditEntry>",statistics:{totalTokens:0,activeTokens:0,revokedTokens:0,registrations:0}},externalStorage:{required:!0,type:"database_or_blockchain",endpoints:{store:"POST /registry/{id}/tokens",retrieve:"GET /registry/{id}/tokens/{tokenId}",search:"GET /registry/{id}/search",revoke:"POST /registry/{id}/revocations"}}},r=this._prepareAuditEntry({action:"REGISTRY_CREATED",actor:e.authority,timestamp:t.created,metadata:{jurisdiction:t.jurisdiction,config:t.config}});return{success:!0,registry:t,initialAudit:r,instructions:{step1:"Store registry configuration in external system",step2:"Initialize token storage with provided data structure",step3:"Set up audit logging with provided templates",step4:"Configure external endpoints for registry operations"}}},prepareTokenRegistration:function(e,t,r){r=r||{},cr.checkArgument(e&&typeof e=="object","Invalid token"),cr.checkArgument(t&&typeof t=="object","Invalid registry config");try{var n=this._validateTokenForRegistration(e,t);if(!n.valid)return{success:!1,error:"Token validation failed: "+n.error};var i={tokenId:e.id,tokenHash:this._hashToken(e),token:e,status:t.requireApproval?"PENDING":"ACTIVE",registeredBy:r.registeredBy||"UNKNOWN",registeredAt:new Date().toISOString(),approvedBy:null,approvedAt:null,metadata:r.metadata||{},compliance:{jurisdiction:e.jurisdiction||t.jurisdiction,level:this._calculateComplianceLevel(e),checks:n.checks||[]}},o=this._prepareAuditEntry({action:"TOKEN_REGISTERED",actor:r.registeredBy,tokenId:e.id,timestamp:i.registeredAt,metadata:{status:i.status,tokenType:e.type,compliance:i.compliance}});return{success:!0,registrationRecord:i,auditEntry:o,registrationId:this._generateRegistrationId(e.id),validation:n,externalOperations:{store:{endpoint:"POST /registry/"+t.id+"/tokens",data:i},audit:{endpoint:"POST /registry/"+t.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenApproval:function(e,t,r){try{cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(typeof t=="string","Approver must be string"),cr.checkArgument(r&&typeof r=="object","Invalid registry config");var n={tokenId:e,status:"ACTIVE",approvedBy:t,approvedAt:new Date().toISOString()},i=this._prepareAuditEntry({action:"TOKEN_APPROVED",actor:t,tokenId:e,timestamp:n.approvedAt});return{success:!0,approvalData:n,auditEntry:i,externalOperations:{update:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:n},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:i}}}}catch(o){return{success:!1,error:o.message}}},prepareTokenRevocation:function(e,t,r){try{if(cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(t&&typeof t=="object","Invalid revocation"),cr.checkArgument(r&&typeof r=="object","Invalid registry config"),!r.enableRevocation)return{success:!1,error:"Revocation is disabled for this registry"};var n={tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null,revocationHash:this._generateRevocationHash(e,t)},i={tokenId:e,status:"REVOKED",revokedAt:n.revokedAt,revocationReason:n.reason},o=this._prepareAuditEntry({action:"TOKEN_REVOKED",actor:t.revokedBy,tokenId:e,timestamp:n.revokedAt,metadata:{reason:n.reason,legalBasis:n.legalBasis}});return{success:!0,revocationRecord:n,statusUpdate:i,auditEntry:o,revocationId:this._generateRevocationId(e),externalOperations:{storeRevocation:{endpoint:"POST /registry/"+r.id+"/revocations",data:n},updateStatus:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:i},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenStatusQuery:function(e,t){try{return cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(t&&typeof t=="object","Invalid registry config"),{success:!0,query:{tokenId:e,registryId:t.id},externalOperations:{retrieve:{endpoint:"GET /registry/"+t.id+"/tokens/"+e,method:"GET"},checkRevocation:{endpoint:"GET /registry/"+t.id+"/revocations/"+e,method:"GET"}},expectedResponse:{found:"boolean",status:"string (PENDING|ACTIVE|REVOKED)",registeredAt:"ISO datetime",registeredBy:"string",approvedAt:"ISO datetime or null",approvedBy:"string or null",revokedAt:"ISO datetime or null",revocationReason:"string or null",compliance:"object",revocation:"object or null"}}}catch(r){return{success:!1,error:r.message}}},prepareTokenSearch:function(e,t){e=e||{};try{cr.checkArgument(t&&typeof t=="object","Invalid registry config");var r=[];e.status&&r.push("status="+encodeURIComponent(e.status)),e.type&&r.push("type="+encodeURIComponent(e.type)),e.registeredBy&&r.push("registeredBy="+encodeURIComponent(e.registeredBy)),e.jurisdiction&&r.push("jurisdiction="+encodeURIComponent(e.jurisdiction)),e.dateFrom&&r.push("dateFrom="+encodeURIComponent(e.dateFrom)),e.dateTo&&r.push("dateTo="+encodeURIComponent(e.dateTo)),e.includeTokens&&r.push("includeTokens=true"),e.sortBy&&r.push("sortBy="+encodeURIComponent(e.sortBy)),e.sortOrder&&r.push("sortOrder="+encodeURIComponent(e.sortOrder));var n=e.offset||0,i=e.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,searchCriteria:e,externalOperations:{search:{endpoint:"GET /registry/"+t.id+"/search"+o,method:"GET"}},expectedResponse:{success:"boolean",results:"Array<tokenRecord>",totalCount:"number",totalRegistrations:"number",offset:"number",limit:"number",hasMore:"boolean"}}}catch(s){return{success:!1,error:s.message}}},prepareStatisticsQuery:function(e){return cr.checkArgument(e&&typeof e=="object","Invalid registry config"),{success:!0,query:{registryId:e.id},externalOperations:{getStatistics:{endpoint:"GET /registry/"+e.id+"/statistics",method:"GET"}},expectedResponse:{id:"string",name:"string",jurisdiction:"string",created:"ISO datetime",statistics:{totalTokens:"number",activeTokens:"number",revokedTokens:"number",registrations:"number"},auditEntries:"number",lastActivity:"ISO datetime"}}},prepareAuditLogQuery:function(e,t){if(t=t||{},cr.checkArgument(e&&typeof e=="object","Invalid registry config"),!e.enableAuditTrail)return{success:!1,error:"Audit trail is disabled"};var r=[];t.action&&r.push("action="+encodeURIComponent(t.action)),t.actor&&r.push("actor="+encodeURIComponent(t.actor)),t.tokenId&&r.push("tokenId="+encodeURIComponent(t.tokenId)),t.dateFrom&&r.push("dateFrom="+encodeURIComponent(t.dateFrom)),t.dateTo&&r.push("dateTo="+encodeURIComponent(t.dateTo));var n=t.offset||0,i=t.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,auditOptions:t,externalOperations:{getAuditLog:{endpoint:"GET /registry/"+e.id+"/audit"+o,method:"GET"}},expectedResponse:{success:"boolean",entries:"Array<auditEntry>",totalEntries:"number",offset:"number",limit:"number",hasMore:"boolean"}}},_generateRegistryId:function(){return"reg_"+Gx.randomHex(16)},_generateRegistrationId:function(e){var t="reg_"+e+"_"+Date.now();return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateRevocationId:function(e){var t="rev_"+e+"_"+Date.now();return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_hashToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,Wa.sha256(d.Buffer.from(JSON.stringify(t))).toString("hex")},_generateRevocationHash:function(e,t){var r=e+(t.reason||"")+(t.revokedBy||"")+Date.now();return Wa.sha256(d.Buffer.from(r)).toString("hex")},_validateTokenForRegistration:function(e,t){var r=[],n=!0;return e.id?r.push({field:"id",valid:!0}):(r.push({field:"id",valid:!1,error:"Missing token ID"}),n=!1),e.type?r.push({field:"type",valid:!0}):(r.push({field:"type",valid:!1,error:"Missing token type"}),n=!1),e.issuanceDate?r.push({field:"issuanceDate",valid:!0}):(r.push({field:"issuanceDate",valid:!1,error:"Missing issuance date"}),n=!1),e.proof?r.push({field:"proof",valid:!0}):(r.push({field:"proof",valid:!1,error:"Missing cryptographic proof"}),n=!1),{valid:n,checks:r}},_calculateComplianceLevel:function(e){var t="BASIC";return e.proof&&e.proof.type&&(t="STANDARD"),e.jurisdiction&&e.legalBasis&&(t="ENHANCED"),e.attestations&&e.attestations.length>0&&(t="PREMIUM"),t},_prepareAuditEntry:function(e){var t={id:this._generateAuditId(),action:e.action,actor:e.actor||"SYSTEM",tokenId:e.tokenId||null,timestamp:e.timestamp||new Date().toISOString(),metadata:e.metadata||{},hash:this._generateAuditHash(e)};return t},_generateAuditId:function(){return"audit_"+Gx.randomHex(32)},_generateAuditHash:function(e){var t=(e.action||"")+(e.actor||"")+(e.tokenId||"")+(e.timestamp||"");return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)}};Vx.exports=dC});var Zx=B((_q,$x)=>{"use strict";p();var Hp=Or(),Kp=Jt(),zx=Ma(),pC=nr(),Yx=no(),yr=Le(),gC=Ha();function yC(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Hp?t.issuerPublicKey:Hp.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Hp.fromString(n):null}catch{return null}}var Dc={CORRELATIVE_OBLIGATION:"CorrelativeObligation",CONTRACTUAL_OBLIGATION:"ContractualObligation",PAYMENT_OBLIGATION:"PaymentObligation",DELIVERY_OBLIGATION:"DeliveryObligation",PERFORMANCE_OBLIGATION:"PerformanceObligation",MAINTENANCE_OBLIGATION:"MaintenanceObligation",COMPLIANCE_OBLIGATION:"ComplianceObligation",REPORTING_OBLIGATION:"ReportingObligation",CONFIDENTIALITY_OBLIGATION:"ConfidentialityObligation",NON_COMPETE_OBLIGATION:"NonCompeteObligation",INDEMNIFICATION_OBLIGATION:"IndemnificationObligation",WARRANTY_OBLIGATION:"WarrantyObligation",SUPPORT_OBLIGATION:"SupportObligation",REGULATORY_OBLIGATION:"RegulatoryObligation",FIDUCIARY_OBLIGATION:"FiduciaryObligation"},ls={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},lr={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},Uc={prepareObligationToken:function(e,t,r,n,i,o){o=o||{},yr.checkArgument(typeof e=="string","Obligation type must be string"),yr.checkArgument(typeof t=="string","Issuer DID must be string"),yr.checkArgument(typeof r=="string","Obligor DID must be string"),yr.checkArgument(n&&typeof n=="object","Obligation must be object"),yr.checkArgument(i instanceof Yx,"Invalid issuer private key");var s=Object.values(Dc);yr.checkArgument(s.includes(e),"Invalid obligation type: "+e);try{var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,obligationType:e,obligation:n,jurisdiction:o.jurisdiction||"US",priority:o.priority||ls.MEDIUM,status:lr.PENDING,dueDate:o.dueDate||null,effectiveDate:o.effectiveDate||new Date().toISOString(),expirationDate:o.expirationDate||null,correlativeRight:o.correlativeRight||null,rightHolder:o.rightHolder||null,enforceable:o.enforceable!==!1,penalties:o.penalties||null,remedies:o.remedies||null}};o.metadata&&(a.credentialSubject.metadata=o.metadata);var f=this._signToken(a,i);return{success:!0,obligationToken:f,tokenHash:f.tokenHash,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight},externalOperations:{storeToken:{endpoint:"POST /obligations/tokens",data:{token:f,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight}}},indexToken:{endpoint:"POST /obligations/index",data:{tokenId:f.id,tokenHash:f.tokenHash,type:e,issuer:t,obligor:r,issuedAt:f.issuanceDate,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:f.id,issuer:t,obligor:r,obligationType:e,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},scheduleReminders:a.credentialSubject.dueDate?{endpoint:"POST /obligations/schedule-reminders",data:{tokenId:f.id,obligor:r,dueDate:a.credentialSubject.dueDate,reminderSchedule:o.reminderSchedule||["7d","3d","1d"]}}:null}}}catch(l){return{success:!1,error:l.message}}},prepareObligationVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateObligationType(e,r),this._validateObligationStatus(e,r,n),this._validateObligationPriority(e,n);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,obligorDID:e.credentialSubject?e.credentialSubject.id:null,obligationType:e.credentialSubject?e.credentialSubject.obligationType:null,status:e.credentialSubject?e.credentialSubject.status:null,priority:e.credentialSubject?e.credentialSubject.priority:null,isOverdue:this._checkIfOverdue(e),verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /obligations/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt,isOverdue:i.isOverdue}},auditVerification:{endpoint:"POST /audit/obligation-verification",data:{tokenId:e.id,obligationType:i.obligationType,issuer:i.issuerDID,obligor:i.obligorDID,result:i.valid,verifiedAt:i.verifiedAt}},updateStatus:i.isOverdue&&e.credentialSubject.status===lr.ACTIVE?{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:lr.OVERDUE,updatedAt:i.verifiedAt,reason:"Due date passed"}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareObligationFulfillment:function(e,t,r,n){n=n||{},yr.checkArgument(e&&typeof e=="object","Invalid token"),yr.checkArgument(t&&typeof t=="object","Invalid fulfillment"),yr.checkArgument(r instanceof Yx,"Invalid obligor key");try{var i=this.prepareObligationVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot fulfill invalid obligation: "+i.verification.errors.join(", ")};if(e.credentialSubject.status===lr.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(e.credentialSubject.status===lr.TERMINATED)return{success:!1,error:"Obligation has been terminated"};var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationFulfillment"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,fulfillmentType:t.type||"FULL_FULFILLMENT",fulfillmentDate:new Date().toISOString(),evidence:t.evidence||null,description:t.description||"",completionPercentage:t.completionPercentage||100,attestations:t.attestations||[],notes:t.notes||null}},s=this._signToken(o,r),a=o.credentialSubject.completionPercentage>=100?lr.COMPLETED:lr.IN_PROGRESS;return{success:!0,fulfillmentRecord:s,newStatus:a,fulfillmentId:s.id,externalOperations:{recordFulfillment:{endpoint:"POST /obligations/fulfillments",data:{obligationId:e.id,fulfillmentRecord:s,obligor:e.credentialSubject.id,fulfillmentDate:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:a,fulfillmentId:s.id,updatedAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},notifyRightHolder:e.credentialSubject.rightHolder?{endpoint:"POST /notifications/obligation-fulfilled",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,completionPercentage:o.credentialSubject.completionPercentage,newStatus:a}}:null,auditFulfillment:{endpoint:"POST /audit/obligation-fulfillment",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,fulfilledAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}}}}}catch(f){return{success:!1,error:f.message}}},prepareObligationBreachAssessment:function(e,t,r){yr.checkArgument(e&&typeof e=="object","Invalid token"),yr.checkArgument(t&&typeof t=="object","Invalid breach details"),yr.checkArgument(r&&typeof r=="object","Invalid assessor");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationBreachAssessment"],issuer:r.did||r.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,breachType:t.type||"MATERIAL_BREACH",breachDate:t.date||new Date().toISOString(),description:t.description||"",severity:t.severity||"MODERATE",evidence:t.evidence||[],assessor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},damages:t.damages||null,recommendedRemedies:t.recommendedRemedies||[],assessmentDate:new Date().toISOString()}},i=Kp.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return n.credentialSubject.assessmentHash=i,{success:!0,breachAssessment:n,breachId:n.id,severity:t.severity||"MODERATE",externalOperations:{recordBreach:{endpoint:"POST /obligations/breaches",data:{obligationId:e.id,breachAssessment:n,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachDate:t.date||new Date().toISOString(),severity:t.severity||"MODERATE"}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:lr.BREACHED,breachId:n.id,breachDate:t.date||new Date().toISOString(),updatedAt:new Date().toISOString()}},notifyParties:{endpoint:"POST /notifications/obligation-breached",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachType:t.type||"MATERIAL_BREACH",severity:t.severity||"MODERATE"}},escalateBreach:t.severity==="CRITICAL"?{endpoint:"POST /legal/escalate-breach",data:{obligationId:e.id,breachId:n.id,severity:t.severity,jurisdiction:e.credentialSubject.jurisdiction}}:null,auditBreach:{endpoint:"POST /audit/obligation-breach",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,assessedAt:n.credentialSubject.assessmentDate,severity:t.severity||"MODERATE"}}}}}catch(o){return{success:!1,error:o.message}}},prepareObligationMonitoringReport:function(e,t){t=t||{},yr.checkArgument(Array.isArray(e),"Obligations must be array");try{var r={reportId:"rpt_"+this._generateUUID(),generatedAt:new Date().toISOString(),criteria:t,summary:{totalObligations:e.length,byStatus:{},byPriority:{},byType:{},overdue:0,dueSoon:0,completed:0},obligations:[],alerts:[],recommendations:[]},n=new Date,i=new Date(n.getTime()+10080*60*1e3);return e.forEach(function(o){var s={id:o.id,type:o.credentialSubject.obligationType,status:o.credentialSubject.status,priority:o.credentialSubject.priority,obligor:o.credentialSubject.id,dueDate:o.credentialSubject.dueDate,isOverdue:this._checkIfOverdue(o),isDueSoon:!1};if(o.credentialSubject.dueDate){var a=new Date(o.credentialSubject.dueDate);s.isDueSoon=a<=i&&a>n}r.summary.byStatus[s.status]=(r.summary.byStatus[s.status]||0)+1,r.summary.byPriority[s.priority]=(r.summary.byPriority[s.priority]||0)+1,r.summary.byType[s.type]=(r.summary.byType[s.type]||0)+1,s.isOverdue&&r.summary.overdue++,s.isDueSoon&&r.summary.dueSoon++,s.status===lr.COMPLETED&&r.summary.completed++,s.isOverdue&&s.priority===ls.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:o.id,message:"Critical obligation is overdue",priority:"HIGH"}),s.isDueSoon&&s.priority===ls.HIGH&&r.alerts.push({type:"HIGH_PRIORITY_DUE_SOON",obligationId:o.id,message:"High priority obligation due soon",priority:"MEDIUM"}),r.obligations.push(s)}.bind(this)),r.summary.overdue>0&&r.recommendations.push({type:"OVERDUE_MANAGEMENT",message:"Consider prioritizing overdue obligations",count:r.summary.overdue}),r.summary.dueSoon>5&&r.recommendations.push({type:"WORKLOAD_MANAGEMENT",message:"High number of obligations due soon - consider workload distribution",count:r.summary.dueSoon}),{success:!0,report:r,externalOperations:{storeReport:{endpoint:"POST /obligations/monitoring-reports",data:{report:r,generatedAt:r.generatedAt}},sendAlerts:r.alerts.length>0?{endpoint:"POST /notifications/obligation-alerts",data:{reportId:r.reportId,alerts:r.alerts,summary:r.summary}}:null,updateDashboard:{endpoint:"PUT /dashboard/obligation-metrics",data:{summary:r.summary,lastUpdated:r.generatedAt}}}}}catch(o){return{success:!1,error:o.message}}},getObligationTypes:function(){return Dc},getObligationPriority:function(){return ls},getObligationStatus:function(){return lr},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Kp.sha256(d.Buffer.from(r)),i=new zx;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Kp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=yC(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=pC.fromDER(d.Buffer.from(s[2],"base64url")),f=new zx;f.hashbuf=i,f.sig=a,f.pubkey=o,f.verify()!==!0&&t.push("Signature verification failed")}catch(l){t.push("Signature verification failed: "+l.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.effectiveDate){var o=new Date(e.credentialSubject.effectiveDate);n<o&&r.push("Obligation not yet effective")}if(e.credentialSubject.expirationDate){var s=new Date(e.credentialSubject.expirationDate);n>s&&t.push("Obligation expired")}},_validateObligationType:function(e,t){if(!e.credentialSubject.obligationType){t.push("Missing obligationType");return}var r=Object.values(Dc);r.includes(e.credentialSubject.obligationType)||t.push("Invalid obligation type: "+e.credentialSubject.obligationType)},_validateObligationStatus:function(e,t,r){if(!e.credentialSubject.status){t.push("Missing status");return}var n=Object.values(lr);n.includes(e.credentialSubject.status)||t.push("Invalid obligation status: "+e.credentialSubject.status),this._checkIfOverdue(e)&&e.credentialSubject.status===lr.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")},_validateObligationPriority:function(e,t){if(e.credentialSubject.priority){var r=Object.values(ls);r.includes(e.credentialSubject.priority)||t.push("Invalid obligation priority: "+e.credentialSubject.priority)}},_checkIfOverdue:function(e){if(!e.credentialSubject.dueDate)return!1;var t=new Date,r=new Date(e.credentialSubject.dueDate);return t>r&&e.credentialSubject.status!==lr.COMPLETED},_generateUUID:function(){return gC.uuid4()}};Uc.ObligationTypes=Dc;Uc.ObligationPriority=ls;Uc.ObligationStatus=lr;$x.exports=Uc});var Jx=B((wq,Xx)=>{"use strict";p();var ao=Lx(),Fc=Ux(),za=qx(),Gp=Kx(),dn=Wx(),mC=Zx(),Vp=no(),mr=Le(),Pe=function(e){return this instanceof Pe?(this.config=e||{},this.registry=null,this.config.registry&&(this.registry=dn.createRegistry(this.config.registry)),this):new Pe(e)};Pe.prototype.createRightToken=function(e,t,r){mr.checkArgument(e&&typeof e=="object","Invalid right data"),mr.checkArgument(t instanceof Vp,"Invalid private key"),r=r||{};try{var n=ao.create(e.type,e.owner,e.owner,e,t,r);if(!n)return{success:!1,error:"Failed to create token"};if(r.addProof!==!1&&(n=ao._signToken(n,t)),r.anchor){var i=za.anchorToken(n,r.anchor);i.success&&(n.anchorTx=i.txid,n.anchorBlock=i.blockHeight)}if(this.registry&&r.register!==!1){var o=dn.registerToken(this.registry,n,{registeredBy:r.registeredBy||"SYSTEM"});o.success&&(n.registrationId=o.registrationId,n.registrationStatus=o.status)}return{success:!0,token:n,type:"LegalRightToken"}}catch(s){return{success:!1,error:s.message}}};Pe.prototype.validateClaim=function(e,t){return Fc.validate(e,t)};Pe.prototype.createSelectiveDisclosure=function(e,t,r){return Gp.prepareSelectiveDisclosure(e,t,r)};Pe.prototype.verifyToken=function(e,t){return!e||!e.proof?{valid:!1,error:"No proof found in token"}:ao.verifyToken(e,t)};Pe.prototype.transferRight=function(e,t,r,n){mr.checkArgument(e&&typeof e=="object","Invalid token"),mr.checkArgument(typeof t=="string","New owner must be string"),mr.checkArgument(r instanceof Vp,"Invalid owner key"),n=n||{};try{var i=this.verifyToken(e,r.toPublicKey().toString());if(!i.valid)return{success:!1,error:"Invalid token or ownership proof"};var o=ao.prepareRightTokenTransfer(e,t,r,n);if(!o.success)return{success:!1,error:o.error};var s=o.newToken,a=o.transferProof;if(n.anchor){var f=za.anchorToken(s,n.anchor);f.success&&(s.transferAnchorTx=f.txid)}if(this.registry){var l=dn.registerToken(this.registry,s,{registeredBy:n.registeredBy||t,metadata:{transferFrom:e.owner,transferTo:t,originalTokenId:e.id}});l.success&&(s.registrationId=l.registrationId)}return{success:!0,token:s,transferId:a.id,transferredAt:a.issuanceDate,transferProof:a}}catch(m){return{success:!1,error:m.message}}};Pe.prototype.createObligation=function(e,t,r){mr.checkArgument(e&&typeof e=="object","Invalid right token"),mr.checkArgument(t&&typeof t=="object","Invalid obligation data"),mr.checkArgument(r instanceof Vp,"Invalid private key");try{var n=ao.prepareObligationToken(e,t.obligor,t,r);return n.success?{success:!0,obligation:n.obligationToken,rightTokenId:e.id}:{success:!1,error:n.error}}catch(i){return{success:!1,error:i.message}}};Pe.prototype.revokeToken=function(e,t,r){return mr.checkArgument(typeof e=="string","Token ID must be string"),mr.checkArgument(t&&typeof t=="object","Invalid revocation data"),mr.checkArgument(typeof r=="string","Authority must be string"),this.registry?dn.revokeToken(this.registry,e,{reason:t.reason,revokedBy:r,legalBasis:t.legalBasis,evidence:t.evidence}):{success:!1,error:"No registry available for revocation"}};Pe.prototype.checkTokenStatus=function(e){return mr.checkArgument(typeof e=="string","Token ID must be string"),this.registry?dn.checkTokenStatus(this.registry,e):{found:!1,error:"No registry available"}};Pe.prototype.searchTokens=function(e){return this.registry?dn.searchTokens(this.registry,e):{success:!1,error:"No registry available"}};Pe.prototype.getRegistryStats=function(){return this.registry?dn.getStatistics(this.registry):{error:"No registry available"}};Pe.prototype.createLegalValidityProof=function(e,t,r){return Gp.prepareLegalValidityProof(e,t,r)};Pe.prototype.anchorTokenBatch=function(e,t){return za.anchorBatch(e,t)};Pe.prototype.verifyAnchor=function(e,t){return za.verifyAnchor(e,t)};Pe.prototype.getRightTypes=function(){return ao.getRightTypes()};Pe.prototype.getClaimSchemas=function(){return Fc.getSchemas()};Pe.prototype.createRegistry=function(e){return this.registry=dn.createRegistry(e),this.registry};Pe.prototype.setRegistry=function(e){mr.checkArgument(e&&typeof e=="object","Invalid registry"),this.registry=e};Pe.create=function(e){return new Pe(e)};Pe.createRightToken=function(e,t,r){var n=new Pe;return n.createRightToken(e,t,r)};Pe.validateClaim=function(e,t){return Fc.validate(e,t)};Pe.verifyToken=function(e,t){var r=new Pe;return r.verifyToken(e,t)};Pe.createRegistry=function(e){return dn.createRegistry(e)};Pe.Right=ao;Pe.Claim=Fc;Pe.Anchor=za;Pe.Proof=Gp;Pe.Registry=dn;Pe.Obligation=mC;Xx.exports=Pe});var vC=B((xq,Qx)=>{p();Qx.exports=Jx()});return vC();})();
70
75
  if(typeof module!=="undefined"&&module.exports){module.exports=bsvLTP}else if(typeof define==="function"&&define.amd){define([],function(){return bsvLTP})}