@aptos-labs/ts-sdk 1.3.0 → 1.4.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 (165) hide show
  1. package/dist/browser/index.d.ts +2 -2
  2. package/dist/browser/index.global.js +2 -2
  3. package/dist/browser/index.global.js.map +1 -1
  4. package/dist/common/index.d.ts +2 -2
  5. package/dist/common/index.js +2 -2
  6. package/dist/common/index.js.map +1 -1
  7. package/dist/esm/api/account.mjs +1 -1
  8. package/dist/esm/api/ans.mjs +1 -1
  9. package/dist/esm/api/aptos.d.mts +1 -1
  10. package/dist/esm/api/aptos.mjs +1 -1
  11. package/dist/esm/api/coin.d.mts +2 -4
  12. package/dist/esm/api/coin.mjs +1 -1
  13. package/dist/esm/api/digitalAsset.mjs +1 -1
  14. package/dist/esm/api/event.mjs +1 -1
  15. package/dist/esm/api/faucet.mjs +1 -1
  16. package/dist/esm/api/fungibleAsset.mjs +1 -1
  17. package/dist/esm/api/general.mjs +1 -1
  18. package/dist/esm/api/index.mjs +1 -1
  19. package/dist/esm/api/staking.mjs +1 -1
  20. package/dist/esm/api/transaction.mjs +1 -1
  21. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  22. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  23. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  24. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  25. package/dist/esm/api/utils.mjs +1 -1
  26. package/dist/esm/bcs/index.mjs +1 -1
  27. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  28. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  29. package/dist/esm/{chunk-IZ4H63EF.mjs → chunk-2EQNGCPL.mjs} +2 -2
  30. package/dist/esm/{chunk-YVSIS6BA.mjs → chunk-3DM36HLF.mjs} +2 -2
  31. package/dist/esm/{chunk-63764T3K.mjs → chunk-3PPUHF6D.mjs} +2 -2
  32. package/dist/esm/{chunk-EK7YYYKL.mjs → chunk-457LDQ3A.mjs} +2 -2
  33. package/dist/esm/{chunk-UNSMG2E5.mjs → chunk-4BGNLZ5Y.mjs} +2 -2
  34. package/dist/esm/{chunk-ZLYF5TLK.mjs → chunk-4DEYLX4E.mjs} +2 -2
  35. package/dist/esm/{chunk-RNO5ZG3C.mjs → chunk-4OI7MPFH.mjs} +2 -2
  36. package/dist/esm/{chunk-5I4AJ6KA.mjs → chunk-4RFWMHWT.mjs} +2 -2
  37. package/dist/esm/{chunk-6EUKJGSP.mjs → chunk-7Z4DTVZN.mjs} +2 -2
  38. package/dist/esm/{chunk-OZ3JUNJX.mjs → chunk-ATV7SH7J.mjs} +2 -2
  39. package/dist/esm/{chunk-RSOBVX62.mjs → chunk-BBJ3YXGC.mjs} +2 -2
  40. package/dist/esm/{chunk-754CLAXM.mjs → chunk-CBMEWHLK.mjs} +2 -2
  41. package/dist/esm/chunk-CBMEWHLK.mjs.map +1 -0
  42. package/dist/esm/{chunk-TKRPOJH3.mjs → chunk-CHK4FLX4.mjs} +2 -2
  43. package/dist/esm/{chunk-RYX746TE.mjs → chunk-DHR4YEUH.mjs} +2 -2
  44. package/dist/esm/{chunk-526UH53R.mjs → chunk-F362Q4BJ.mjs} +2 -2
  45. package/dist/esm/{chunk-B7FGGGWZ.mjs → chunk-FW7B46XZ.mjs} +2 -2
  46. package/dist/esm/chunk-FXXTTZOI.mjs +2 -0
  47. package/dist/esm/chunk-FXXTTZOI.mjs.map +1 -0
  48. package/dist/esm/{chunk-E6NGWPZM.mjs → chunk-GGCQNE7J.mjs} +2 -2
  49. package/dist/esm/{chunk-GIM5LIAP.mjs → chunk-I4EKXYTB.mjs} +2 -2
  50. package/dist/esm/{chunk-AA4ETD22.mjs → chunk-JHKU4VAL.mjs} +2 -2
  51. package/dist/esm/{chunk-J2CXWDE7.mjs → chunk-KYI7YRRQ.mjs} +2 -2
  52. package/dist/esm/{chunk-UFMUQN35.mjs → chunk-LGC5FYCC.mjs} +2 -2
  53. package/dist/esm/{chunk-KZID24G2.mjs → chunk-LLONKHWW.mjs} +2 -2
  54. package/dist/esm/{chunk-7LEBWRPP.mjs → chunk-MJW4JGUR.mjs} +2 -2
  55. package/dist/esm/chunk-NXPN5XLB.mjs +2 -0
  56. package/dist/esm/{chunk-HGC2PEHW.mjs.map → chunk-NXPN5XLB.mjs.map} +1 -1
  57. package/dist/esm/{chunk-KVTWA3N3.mjs → chunk-O74RSNEJ.mjs} +2 -2
  58. package/dist/esm/{chunk-CKWHFVGW.mjs → chunk-PXNW26UO.mjs} +2 -2
  59. package/dist/esm/{chunk-5SU5YHP2.mjs → chunk-Q7B4KMTR.mjs} +2 -2
  60. package/dist/esm/{chunk-FIO7MFHJ.mjs → chunk-QLAW63UU.mjs} +2 -2
  61. package/dist/esm/{chunk-2MH57VSA.mjs → chunk-QQMEPYJ3.mjs} +2 -2
  62. package/dist/esm/{chunk-MSQ5V3EF.mjs → chunk-RKWCYC3Y.mjs} +2 -2
  63. package/dist/esm/chunk-RVQGLEBY.mjs +2 -0
  64. package/dist/esm/chunk-RVQGLEBY.mjs.map +1 -0
  65. package/dist/esm/{chunk-VO2CATMP.mjs → chunk-TJJSQSO3.mjs} +2 -2
  66. package/dist/esm/{chunk-M7PXZWVX.mjs → chunk-TN4RHL6A.mjs} +2 -2
  67. package/dist/esm/{chunk-7POEROH7.mjs → chunk-V6J34VOD.mjs} +2 -2
  68. package/dist/esm/{chunk-NI7GRYCP.mjs → chunk-XGM33CR7.mjs} +2 -2
  69. package/dist/esm/{chunk-T2P2T3OS.mjs → chunk-XSM3SOZY.mjs} +2 -2
  70. package/dist/esm/{chunk-U2YE33UN.mjs → chunk-YJQQF4GI.mjs} +2 -2
  71. package/dist/esm/client/core.mjs +1 -1
  72. package/dist/esm/client/get.mjs +1 -1
  73. package/dist/esm/client/index.mjs +1 -1
  74. package/dist/esm/client/post.mjs +1 -1
  75. package/dist/esm/core/account.mjs +1 -1
  76. package/dist/esm/core/accountAddress.mjs +1 -1
  77. package/dist/esm/core/authenticationKey.mjs +1 -1
  78. package/dist/esm/core/crypto/anyPublicKey.mjs +1 -1
  79. package/dist/esm/core/crypto/anySignature.mjs +1 -1
  80. package/dist/esm/core/crypto/asymmetricCrypto.mjs +1 -1
  81. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  82. package/dist/esm/core/crypto/index.mjs +1 -1
  83. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  84. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  85. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  86. package/dist/esm/core/index.mjs +1 -1
  87. package/dist/esm/index.mjs +1 -1
  88. package/dist/esm/internal/account.mjs +1 -1
  89. package/dist/esm/internal/ans.mjs +1 -1
  90. package/dist/esm/internal/coin.d.mts +2 -4
  91. package/dist/esm/internal/coin.mjs +1 -1
  92. package/dist/esm/internal/digitalAsset.mjs +1 -1
  93. package/dist/esm/internal/event.mjs +1 -1
  94. package/dist/esm/internal/faucet.mjs +1 -1
  95. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  96. package/dist/esm/internal/general.mjs +1 -1
  97. package/dist/esm/internal/staking.mjs +1 -1
  98. package/dist/esm/internal/transaction.mjs +1 -1
  99. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  100. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  101. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  102. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  103. package/dist/esm/transactions/index.mjs +1 -1
  104. package/dist/esm/transactions/instances/index.mjs +1 -1
  105. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  106. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  107. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  108. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  109. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  110. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  111. package/dist/esm/transactions/management/index.mjs +1 -1
  112. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  113. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  114. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  115. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  116. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  117. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  118. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  119. package/dist/esm/version.d.mts +1 -1
  120. package/dist/esm/version.mjs +1 -1
  121. package/package.json +1 -1
  122. package/src/api/aptos.ts +3 -2
  123. package/src/api/coin.ts +2 -2
  124. package/src/internal/coin.ts +3 -3
  125. package/src/version.ts +1 -1
  126. package/dist/esm/chunk-5M7VRRAU.mjs +0 -2
  127. package/dist/esm/chunk-5M7VRRAU.mjs.map +0 -1
  128. package/dist/esm/chunk-754CLAXM.mjs.map +0 -1
  129. package/dist/esm/chunk-BVQXUADY.mjs +0 -2
  130. package/dist/esm/chunk-BVQXUADY.mjs.map +0 -1
  131. package/dist/esm/chunk-HGC2PEHW.mjs +0 -2
  132. /package/dist/esm/{chunk-IZ4H63EF.mjs.map → chunk-2EQNGCPL.mjs.map} +0 -0
  133. /package/dist/esm/{chunk-YVSIS6BA.mjs.map → chunk-3DM36HLF.mjs.map} +0 -0
  134. /package/dist/esm/{chunk-63764T3K.mjs.map → chunk-3PPUHF6D.mjs.map} +0 -0
  135. /package/dist/esm/{chunk-EK7YYYKL.mjs.map → chunk-457LDQ3A.mjs.map} +0 -0
  136. /package/dist/esm/{chunk-UNSMG2E5.mjs.map → chunk-4BGNLZ5Y.mjs.map} +0 -0
  137. /package/dist/esm/{chunk-ZLYF5TLK.mjs.map → chunk-4DEYLX4E.mjs.map} +0 -0
  138. /package/dist/esm/{chunk-RNO5ZG3C.mjs.map → chunk-4OI7MPFH.mjs.map} +0 -0
  139. /package/dist/esm/{chunk-5I4AJ6KA.mjs.map → chunk-4RFWMHWT.mjs.map} +0 -0
  140. /package/dist/esm/{chunk-6EUKJGSP.mjs.map → chunk-7Z4DTVZN.mjs.map} +0 -0
  141. /package/dist/esm/{chunk-OZ3JUNJX.mjs.map → chunk-ATV7SH7J.mjs.map} +0 -0
  142. /package/dist/esm/{chunk-RSOBVX62.mjs.map → chunk-BBJ3YXGC.mjs.map} +0 -0
  143. /package/dist/esm/{chunk-TKRPOJH3.mjs.map → chunk-CHK4FLX4.mjs.map} +0 -0
  144. /package/dist/esm/{chunk-RYX746TE.mjs.map → chunk-DHR4YEUH.mjs.map} +0 -0
  145. /package/dist/esm/{chunk-526UH53R.mjs.map → chunk-F362Q4BJ.mjs.map} +0 -0
  146. /package/dist/esm/{chunk-B7FGGGWZ.mjs.map → chunk-FW7B46XZ.mjs.map} +0 -0
  147. /package/dist/esm/{chunk-E6NGWPZM.mjs.map → chunk-GGCQNE7J.mjs.map} +0 -0
  148. /package/dist/esm/{chunk-GIM5LIAP.mjs.map → chunk-I4EKXYTB.mjs.map} +0 -0
  149. /package/dist/esm/{chunk-AA4ETD22.mjs.map → chunk-JHKU4VAL.mjs.map} +0 -0
  150. /package/dist/esm/{chunk-J2CXWDE7.mjs.map → chunk-KYI7YRRQ.mjs.map} +0 -0
  151. /package/dist/esm/{chunk-UFMUQN35.mjs.map → chunk-LGC5FYCC.mjs.map} +0 -0
  152. /package/dist/esm/{chunk-KZID24G2.mjs.map → chunk-LLONKHWW.mjs.map} +0 -0
  153. /package/dist/esm/{chunk-7LEBWRPP.mjs.map → chunk-MJW4JGUR.mjs.map} +0 -0
  154. /package/dist/esm/{chunk-KVTWA3N3.mjs.map → chunk-O74RSNEJ.mjs.map} +0 -0
  155. /package/dist/esm/{chunk-CKWHFVGW.mjs.map → chunk-PXNW26UO.mjs.map} +0 -0
  156. /package/dist/esm/{chunk-5SU5YHP2.mjs.map → chunk-Q7B4KMTR.mjs.map} +0 -0
  157. /package/dist/esm/{chunk-FIO7MFHJ.mjs.map → chunk-QLAW63UU.mjs.map} +0 -0
  158. /package/dist/esm/{chunk-2MH57VSA.mjs.map → chunk-QQMEPYJ3.mjs.map} +0 -0
  159. /package/dist/esm/{chunk-MSQ5V3EF.mjs.map → chunk-RKWCYC3Y.mjs.map} +0 -0
  160. /package/dist/esm/{chunk-VO2CATMP.mjs.map → chunk-TJJSQSO3.mjs.map} +0 -0
  161. /package/dist/esm/{chunk-M7PXZWVX.mjs.map → chunk-TN4RHL6A.mjs.map} +0 -0
  162. /package/dist/esm/{chunk-7POEROH7.mjs.map → chunk-V6J34VOD.mjs.map} +0 -0
  163. /package/dist/esm/{chunk-NI7GRYCP.mjs.map → chunk-XGM33CR7.mjs.map} +0 -0
  164. /package/dist/esm/{chunk-T2P2T3OS.mjs.map → chunk-XSM3SOZY.mjs.map} +0 -0
  165. /package/dist/esm/{chunk-U2YE33UN.mjs.map → chunk-YJQQF4GI.mjs.map} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";var aptosSDK=(()=>{var Gp=Object.create;var Lo=Object.defineProperty;var Mu=Object.getOwnPropertyDescriptor;var Lp=Object.getOwnPropertyNames;var qp=Object.getPrototypeOf,Kp=Object.prototype.hasOwnProperty;var Gu=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Lu=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Gs=(r,t)=>{for(var e in t)Lo(r,e,{get:t[e],enumerable:!0})},qu=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Lp(t))!Kp.call(r,o)&&o!==e&&Lo(r,o,{get:()=>t[o],enumerable:!(n=Mu(t,o))||n.enumerable});return r};var Hp=(r,t,e)=>(e=r!=null?Gp(qp(r)):{},qu(t||!r||!r.__esModule?Lo(e,"default",{value:r,enumerable:!0}):e,r)),Fp=r=>qu(Lo({},"__esModule",{value:!0}),r),Et=(r,t,e,n)=>{for(var o=n>1?void 0:n?Mu(t,e):t,s=r.length-1,i;s>=0;s--)(i=r[s])&&(o=(n?i(t,e,o):i(o))||o);return n&&o&&Lo(t,e,o),o};var df=Lu(()=>{"use strict"});var lf=Lu(($0,ti)=>{"use strict";(function(r){"use strict";var t=function(u){var p,d=new Float64Array(16);if(u)for(p=0;p<u.length;p++)d[p]=u[p];return d},e=function(){throw new Error("no PRNG")},n=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var s=t(),i=t([1]),c=t([56129,1]),f=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),h=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),m=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),T=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function v(u,p,d,a){u[p]=d>>24&255,u[p+1]=d>>16&255,u[p+2]=d>>8&255,u[p+3]=d&255,u[p+4]=a>>24&255,u[p+5]=a>>16&255,u[p+6]=a>>8&255,u[p+7]=a&255}function b(u,p,d,a,g){var x,S=0;for(x=0;x<g;x++)S|=u[p+x]^d[a+x];return(1&S-1>>>8)-1}function y(u,p,d,a){return b(u,p,d,a,16)}function w(u,p,d,a){return b(u,p,d,a,32)}function E(u,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,x=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,S=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,O=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,q=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,ee=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,j=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,Re=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,Y=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,ce=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,ue=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,ge=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,pe=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,fe=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,le=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,de=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,Z=g,oe=x,Q=S,X=O,J=q,V=ee,C=j,U=Re,D=Y,R=ce,N=ue,G=ge,ie=pe,me=fe,he=le,ye=de,A,_e=0;_e<20;_e+=2)A=Z+ie|0,J^=A<<7|A>>>25,A=J+Z|0,D^=A<<9|A>>>23,A=D+J|0,ie^=A<<13|A>>>19,A=ie+D|0,Z^=A<<18|A>>>14,A=V+oe|0,R^=A<<7|A>>>25,A=R+V|0,me^=A<<9|A>>>23,A=me+R|0,oe^=A<<13|A>>>19,A=oe+me|0,V^=A<<18|A>>>14,A=N+C|0,he^=A<<7|A>>>25,A=he+N|0,Q^=A<<9|A>>>23,A=Q+he|0,C^=A<<13|A>>>19,A=C+Q|0,N^=A<<18|A>>>14,A=ye+G|0,X^=A<<7|A>>>25,A=X+ye|0,U^=A<<9|A>>>23,A=U+X|0,G^=A<<13|A>>>19,A=G+U|0,ye^=A<<18|A>>>14,A=Z+X|0,oe^=A<<7|A>>>25,A=oe+Z|0,Q^=A<<9|A>>>23,A=Q+oe|0,X^=A<<13|A>>>19,A=X+Q|0,Z^=A<<18|A>>>14,A=V+J|0,C^=A<<7|A>>>25,A=C+V|0,U^=A<<9|A>>>23,A=U+C|0,J^=A<<13|A>>>19,A=J+U|0,V^=A<<18|A>>>14,A=N+R|0,G^=A<<7|A>>>25,A=G+N|0,D^=A<<9|A>>>23,A=D+G|0,R^=A<<13|A>>>19,A=R+D|0,N^=A<<18|A>>>14,A=ye+he|0,ie^=A<<7|A>>>25,A=ie+ye|0,me^=A<<9|A>>>23,A=me+ie|0,he^=A<<13|A>>>19,A=he+me|0,ye^=A<<18|A>>>14;Z=Z+g|0,oe=oe+x|0,Q=Q+S|0,X=X+O|0,J=J+q|0,V=V+ee|0,C=C+j|0,U=U+Re|0,D=D+Y|0,R=R+ce|0,N=N+ue|0,G=G+ge|0,ie=ie+pe|0,me=me+fe|0,he=he+le|0,ye=ye+de|0,u[0]=Z>>>0&255,u[1]=Z>>>8&255,u[2]=Z>>>16&255,u[3]=Z>>>24&255,u[4]=oe>>>0&255,u[5]=oe>>>8&255,u[6]=oe>>>16&255,u[7]=oe>>>24&255,u[8]=Q>>>0&255,u[9]=Q>>>8&255,u[10]=Q>>>16&255,u[11]=Q>>>24&255,u[12]=X>>>0&255,u[13]=X>>>8&255,u[14]=X>>>16&255,u[15]=X>>>24&255,u[16]=J>>>0&255,u[17]=J>>>8&255,u[18]=J>>>16&255,u[19]=J>>>24&255,u[20]=V>>>0&255,u[21]=V>>>8&255,u[22]=V>>>16&255,u[23]=V>>>24&255,u[24]=C>>>0&255,u[25]=C>>>8&255,u[26]=C>>>16&255,u[27]=C>>>24&255,u[28]=U>>>0&255,u[29]=U>>>8&255,u[30]=U>>>16&255,u[31]=U>>>24&255,u[32]=D>>>0&255,u[33]=D>>>8&255,u[34]=D>>>16&255,u[35]=D>>>24&255,u[36]=R>>>0&255,u[37]=R>>>8&255,u[38]=R>>>16&255,u[39]=R>>>24&255,u[40]=N>>>0&255,u[41]=N>>>8&255,u[42]=N>>>16&255,u[43]=N>>>24&255,u[44]=G>>>0&255,u[45]=G>>>8&255,u[46]=G>>>16&255,u[47]=G>>>24&255,u[48]=ie>>>0&255,u[49]=ie>>>8&255,u[50]=ie>>>16&255,u[51]=ie>>>24&255,u[52]=me>>>0&255,u[53]=me>>>8&255,u[54]=me>>>16&255,u[55]=me>>>24&255,u[56]=he>>>0&255,u[57]=he>>>8&255,u[58]=he>>>16&255,u[59]=he>>>24&255,u[60]=ye>>>0&255,u[61]=ye>>>8&255,u[62]=ye>>>16&255,u[63]=ye>>>24&255}function k(u,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,x=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,S=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,O=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,q=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,ee=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,j=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,Re=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,Y=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,ce=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,ue=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,ge=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,pe=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,fe=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,le=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,de=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,Z=g,oe=x,Q=S,X=O,J=q,V=ee,C=j,U=Re,D=Y,R=ce,N=ue,G=ge,ie=pe,me=fe,he=le,ye=de,A,_e=0;_e<20;_e+=2)A=Z+ie|0,J^=A<<7|A>>>25,A=J+Z|0,D^=A<<9|A>>>23,A=D+J|0,ie^=A<<13|A>>>19,A=ie+D|0,Z^=A<<18|A>>>14,A=V+oe|0,R^=A<<7|A>>>25,A=R+V|0,me^=A<<9|A>>>23,A=me+R|0,oe^=A<<13|A>>>19,A=oe+me|0,V^=A<<18|A>>>14,A=N+C|0,he^=A<<7|A>>>25,A=he+N|0,Q^=A<<9|A>>>23,A=Q+he|0,C^=A<<13|A>>>19,A=C+Q|0,N^=A<<18|A>>>14,A=ye+G|0,X^=A<<7|A>>>25,A=X+ye|0,U^=A<<9|A>>>23,A=U+X|0,G^=A<<13|A>>>19,A=G+U|0,ye^=A<<18|A>>>14,A=Z+X|0,oe^=A<<7|A>>>25,A=oe+Z|0,Q^=A<<9|A>>>23,A=Q+oe|0,X^=A<<13|A>>>19,A=X+Q|0,Z^=A<<18|A>>>14,A=V+J|0,C^=A<<7|A>>>25,A=C+V|0,U^=A<<9|A>>>23,A=U+C|0,J^=A<<13|A>>>19,A=J+U|0,V^=A<<18|A>>>14,A=N+R|0,G^=A<<7|A>>>25,A=G+N|0,D^=A<<9|A>>>23,A=D+G|0,R^=A<<13|A>>>19,A=R+D|0,N^=A<<18|A>>>14,A=ye+he|0,ie^=A<<7|A>>>25,A=ie+ye|0,me^=A<<9|A>>>23,A=me+ie|0,he^=A<<13|A>>>19,A=he+me|0,ye^=A<<18|A>>>14;u[0]=Z>>>0&255,u[1]=Z>>>8&255,u[2]=Z>>>16&255,u[3]=Z>>>24&255,u[4]=V>>>0&255,u[5]=V>>>8&255,u[6]=V>>>16&255,u[7]=V>>>24&255,u[8]=N>>>0&255,u[9]=N>>>8&255,u[10]=N>>>16&255,u[11]=N>>>24&255,u[12]=ye>>>0&255,u[13]=ye>>>8&255,u[14]=ye>>>16&255,u[15]=ye>>>24&255,u[16]=C>>>0&255,u[17]=C>>>8&255,u[18]=C>>>16&255,u[19]=C>>>24&255,u[20]=U>>>0&255,u[21]=U>>>8&255,u[22]=U>>>16&255,u[23]=U>>>24&255,u[24]=D>>>0&255,u[25]=D>>>8&255,u[26]=D>>>16&255,u[27]=D>>>24&255,u[28]=R>>>0&255,u[29]=R>>>8&255,u[30]=R>>>16&255,u[31]=R>>>24&255}function P(u,p,d,a){E(u,p,d,a)}function $(u,p,d,a){k(u,p,d,a)}var M=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function z(u,p,d,a,g,x,S){var O=new Uint8Array(16),q=new Uint8Array(64),ee,j;for(j=0;j<16;j++)O[j]=0;for(j=0;j<8;j++)O[j]=x[j];for(;g>=64;){for(P(q,O,S,M),j=0;j<64;j++)u[p+j]=d[a+j]^q[j];for(ee=1,j=8;j<16;j++)ee=ee+(O[j]&255)|0,O[j]=ee&255,ee>>>=8;g-=64,p+=64,a+=64}if(g>0)for(P(q,O,S,M),j=0;j<g;j++)u[p+j]=d[a+j]^q[j];return 0}function L(u,p,d,a,g){var x=new Uint8Array(16),S=new Uint8Array(64),O,q;for(q=0;q<16;q++)x[q]=0;for(q=0;q<8;q++)x[q]=a[q];for(;d>=64;){for(P(S,x,g,M),q=0;q<64;q++)u[p+q]=S[q];for(O=1,q=8;q<16;q++)O=O+(x[q]&255)|0,x[q]=O&255,O>>>=8;d-=64,p+=64}if(d>0)for(P(S,x,g,M),q=0;q<d;q++)u[p+q]=S[q];return 0}function K(u,p,d,a,g){var x=new Uint8Array(32);$(x,a,g,M);for(var S=new Uint8Array(8),O=0;O<8;O++)S[O]=a[O+16];return L(u,p,d,S,x)}function we(u,p,d,a,g,x,S){var O=new Uint8Array(32);$(O,x,S,M);for(var q=new Uint8Array(8),ee=0;ee<8;ee++)q[ee]=x[ee+16];return z(u,p,d,a,g,q,O)}var te=function(u){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var p,d,a,g,x,S,O,q;p=u[0]&255|(u[1]&255)<<8,this.r[0]=p&8191,d=u[2]&255|(u[3]&255)<<8,this.r[1]=(p>>>13|d<<3)&8191,a=u[4]&255|(u[5]&255)<<8,this.r[2]=(d>>>10|a<<6)&7939,g=u[6]&255|(u[7]&255)<<8,this.r[3]=(a>>>7|g<<9)&8191,x=u[8]&255|(u[9]&255)<<8,this.r[4]=(g>>>4|x<<12)&255,this.r[5]=x>>>1&8190,S=u[10]&255|(u[11]&255)<<8,this.r[6]=(x>>>14|S<<2)&8191,O=u[12]&255|(u[13]&255)<<8,this.r[7]=(S>>>11|O<<5)&8065,q=u[14]&255|(u[15]&255)<<8,this.r[8]=(O>>>8|q<<8)&8191,this.r[9]=q>>>5&127,this.pad[0]=u[16]&255|(u[17]&255)<<8,this.pad[1]=u[18]&255|(u[19]&255)<<8,this.pad[2]=u[20]&255|(u[21]&255)<<8,this.pad[3]=u[22]&255|(u[23]&255)<<8,this.pad[4]=u[24]&255|(u[25]&255)<<8,this.pad[5]=u[26]&255|(u[27]&255)<<8,this.pad[6]=u[28]&255|(u[29]&255)<<8,this.pad[7]=u[30]&255|(u[31]&255)<<8};te.prototype.blocks=function(u,p,d){for(var a=this.fin?0:2048,g,x,S,O,q,ee,j,Re,Y,ce,ue,ge,pe,fe,le,de,Z,oe,Q,X=this.h[0],J=this.h[1],V=this.h[2],C=this.h[3],U=this.h[4],D=this.h[5],R=this.h[6],N=this.h[7],G=this.h[8],ie=this.h[9],me=this.r[0],he=this.r[1],ye=this.r[2],A=this.r[3],_e=this.r[4],Oe=this.r[5],Ne=this.r[6],be=this.r[7],Ue=this.r[8],Ie=this.r[9];d>=16;)g=u[p+0]&255|(u[p+1]&255)<<8,X+=g&8191,x=u[p+2]&255|(u[p+3]&255)<<8,J+=(g>>>13|x<<3)&8191,S=u[p+4]&255|(u[p+5]&255)<<8,V+=(x>>>10|S<<6)&8191,O=u[p+6]&255|(u[p+7]&255)<<8,C+=(S>>>7|O<<9)&8191,q=u[p+8]&255|(u[p+9]&255)<<8,U+=(O>>>4|q<<12)&8191,D+=q>>>1&8191,ee=u[p+10]&255|(u[p+11]&255)<<8,R+=(q>>>14|ee<<2)&8191,j=u[p+12]&255|(u[p+13]&255)<<8,N+=(ee>>>11|j<<5)&8191,Re=u[p+14]&255|(u[p+15]&255)<<8,G+=(j>>>8|Re<<8)&8191,ie+=Re>>>5|a,Y=0,ce=Y,ce+=X*me,ce+=J*(5*Ie),ce+=V*(5*Ue),ce+=C*(5*be),ce+=U*(5*Ne),Y=ce>>>13,ce&=8191,ce+=D*(5*Oe),ce+=R*(5*_e),ce+=N*(5*A),ce+=G*(5*ye),ce+=ie*(5*he),Y+=ce>>>13,ce&=8191,ue=Y,ue+=X*he,ue+=J*me,ue+=V*(5*Ie),ue+=C*(5*Ue),ue+=U*(5*be),Y=ue>>>13,ue&=8191,ue+=D*(5*Ne),ue+=R*(5*Oe),ue+=N*(5*_e),ue+=G*(5*A),ue+=ie*(5*ye),Y+=ue>>>13,ue&=8191,ge=Y,ge+=X*ye,ge+=J*he,ge+=V*me,ge+=C*(5*Ie),ge+=U*(5*Ue),Y=ge>>>13,ge&=8191,ge+=D*(5*be),ge+=R*(5*Ne),ge+=N*(5*Oe),ge+=G*(5*_e),ge+=ie*(5*A),Y+=ge>>>13,ge&=8191,pe=Y,pe+=X*A,pe+=J*ye,pe+=V*he,pe+=C*me,pe+=U*(5*Ie),Y=pe>>>13,pe&=8191,pe+=D*(5*Ue),pe+=R*(5*be),pe+=N*(5*Ne),pe+=G*(5*Oe),pe+=ie*(5*_e),Y+=pe>>>13,pe&=8191,fe=Y,fe+=X*_e,fe+=J*A,fe+=V*ye,fe+=C*he,fe+=U*me,Y=fe>>>13,fe&=8191,fe+=D*(5*Ie),fe+=R*(5*Ue),fe+=N*(5*be),fe+=G*(5*Ne),fe+=ie*(5*Oe),Y+=fe>>>13,fe&=8191,le=Y,le+=X*Oe,le+=J*_e,le+=V*A,le+=C*ye,le+=U*he,Y=le>>>13,le&=8191,le+=D*me,le+=R*(5*Ie),le+=N*(5*Ue),le+=G*(5*be),le+=ie*(5*Ne),Y+=le>>>13,le&=8191,de=Y,de+=X*Ne,de+=J*Oe,de+=V*_e,de+=C*A,de+=U*ye,Y=de>>>13,de&=8191,de+=D*he,de+=R*me,de+=N*(5*Ie),de+=G*(5*Ue),de+=ie*(5*be),Y+=de>>>13,de&=8191,Z=Y,Z+=X*be,Z+=J*Ne,Z+=V*Oe,Z+=C*_e,Z+=U*A,Y=Z>>>13,Z&=8191,Z+=D*ye,Z+=R*he,Z+=N*me,Z+=G*(5*Ie),Z+=ie*(5*Ue),Y+=Z>>>13,Z&=8191,oe=Y,oe+=X*Ue,oe+=J*be,oe+=V*Ne,oe+=C*Oe,oe+=U*_e,Y=oe>>>13,oe&=8191,oe+=D*A,oe+=R*ye,oe+=N*he,oe+=G*me,oe+=ie*(5*Ie),Y+=oe>>>13,oe&=8191,Q=Y,Q+=X*Ie,Q+=J*Ue,Q+=V*be,Q+=C*Ne,Q+=U*Oe,Y=Q>>>13,Q&=8191,Q+=D*_e,Q+=R*A,Q+=N*ye,Q+=G*he,Q+=ie*me,Y+=Q>>>13,Q&=8191,Y=(Y<<2)+Y|0,Y=Y+ce|0,ce=Y&8191,Y=Y>>>13,ue+=Y,X=ce,J=ue,V=ge,C=pe,U=fe,D=le,R=de,N=Z,G=oe,ie=Q,p+=16,d-=16;this.h[0]=X,this.h[1]=J,this.h[2]=V,this.h[3]=C,this.h[4]=U,this.h[5]=D,this.h[6]=R,this.h[7]=N,this.h[8]=G,this.h[9]=ie},te.prototype.finish=function(u,p){var d=new Uint16Array(10),a,g,x,S;if(this.leftover){for(S=this.leftover,this.buffer[S++]=1;S<16;S++)this.buffer[S]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(a=this.h[1]>>>13,this.h[1]&=8191,S=2;S<10;S++)this.h[S]+=a,a=this.h[S]>>>13,this.h[S]&=8191;for(this.h[0]+=a*5,a=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=a,a=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=a,d[0]=this.h[0]+5,a=d[0]>>>13,d[0]&=8191,S=1;S<10;S++)d[S]=this.h[S]+a,a=d[S]>>>13,d[S]&=8191;for(d[9]-=8192,g=(a^1)-1,S=0;S<10;S++)d[S]&=g;for(g=~g,S=0;S<10;S++)this.h[S]=this.h[S]&g|d[S];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,x=this.h[0]+this.pad[0],this.h[0]=x&65535,S=1;S<8;S++)x=(this.h[S]+this.pad[S]|0)+(x>>>16)|0,this.h[S]=x&65535;u[p+0]=this.h[0]>>>0&255,u[p+1]=this.h[0]>>>8&255,u[p+2]=this.h[1]>>>0&255,u[p+3]=this.h[1]>>>8&255,u[p+4]=this.h[2]>>>0&255,u[p+5]=this.h[2]>>>8&255,u[p+6]=this.h[3]>>>0&255,u[p+7]=this.h[3]>>>8&255,u[p+8]=this.h[4]>>>0&255,u[p+9]=this.h[4]>>>8&255,u[p+10]=this.h[5]>>>0&255,u[p+11]=this.h[5]>>>8&255,u[p+12]=this.h[6]>>>0&255,u[p+13]=this.h[6]>>>8&255,u[p+14]=this.h[7]>>>0&255,u[p+15]=this.h[7]>>>8&255},te.prototype.update=function(u,p,d){var a,g;if(this.leftover){for(g=16-this.leftover,g>d&&(g=d),a=0;a<g;a++)this.buffer[this.leftover+a]=u[p+a];if(d-=g,p+=g,this.leftover+=g,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(d>=16&&(g=d-d%16,this.blocks(u,p,g),p+=g,d-=g),d){for(a=0;a<d;a++)this.buffer[this.leftover+a]=u[p+a];this.leftover+=d}};function W(u,p,d,a,g,x){var S=new te(x);return S.update(d,a,g),S.finish(u,p),0}function ve(u,p,d,a,g,x){var S=new Uint8Array(16);return W(S,0,d,a,g,x),y(u,p,S,0)}function Ce(u,p,d,a,g){var x;if(d<32)return-1;for(we(u,0,p,0,d,a,g),W(u,16,u,32,d-32,u),x=0;x<16;x++)u[x]=0;return 0}function Ve(u,p,d,a,g){var x,S=new Uint8Array(32);if(d<32||(K(S,0,32,a,g),ve(p,16,p,32,d-32,S)!==0))return-1;for(we(u,0,p,0,d,a,g),x=0;x<32;x++)u[x]=0;return 0}function _(u,p){var d;for(d=0;d<16;d++)u[d]=p[d]|0}function B(u){var p,d,a=1;for(p=0;p<16;p++)d=u[p]+a+65535,a=Math.floor(d/65536),u[p]=d-a*65536;u[0]+=a-1+37*(a-1)}function F(u,p,d){for(var a,g=~(d-1),x=0;x<16;x++)a=g&(u[x]^p[x]),u[x]^=a,p[x]^=a}function re(u,p){var d,a,g,x=t(),S=t();for(d=0;d<16;d++)S[d]=p[d];for(B(S),B(S),B(S),a=0;a<2;a++){for(x[0]=S[0]-65517,d=1;d<15;d++)x[d]=S[d]-65535-(x[d-1]>>16&1),x[d-1]&=65535;x[15]=S[15]-32767-(x[14]>>16&1),g=x[15]>>16&1,x[14]&=65535,F(S,x,1-g)}for(d=0;d<16;d++)u[2*d]=S[d]&255,u[2*d+1]=S[d]>>8}function ne(u,p){var d=new Uint8Array(32),a=new Uint8Array(32);return re(d,u),re(a,p),w(d,0,a,0)}function xe(u){var p=new Uint8Array(32);return re(p,u),p[0]&1}function ke(u,p){var d;for(d=0;d<16;d++)u[d]=p[2*d]+(p[2*d+1]<<8);u[15]&=32767}function Te(u,p,d){for(var a=0;a<16;a++)u[a]=p[a]+d[a]}function De(u,p,d){for(var a=0;a<16;a++)u[a]=p[a]-d[a]}function se(u,p,d){var a,g,x=0,S=0,O=0,q=0,ee=0,j=0,Re=0,Y=0,ce=0,ue=0,ge=0,pe=0,fe=0,le=0,de=0,Z=0,oe=0,Q=0,X=0,J=0,V=0,C=0,U=0,D=0,R=0,N=0,G=0,ie=0,me=0,he=0,ye=0,A=d[0],_e=d[1],Oe=d[2],Ne=d[3],be=d[4],Ue=d[5],Ie=d[6],nt=d[7],Me=d[8],We=d[9],Ye=d[10],Ze=d[11],at=d[12],gt=d[13],mt=d[14],yt=d[15];a=p[0],x+=a*A,S+=a*_e,O+=a*Oe,q+=a*Ne,ee+=a*be,j+=a*Ue,Re+=a*Ie,Y+=a*nt,ce+=a*Me,ue+=a*We,ge+=a*Ye,pe+=a*Ze,fe+=a*at,le+=a*gt,de+=a*mt,Z+=a*yt,a=p[1],S+=a*A,O+=a*_e,q+=a*Oe,ee+=a*Ne,j+=a*be,Re+=a*Ue,Y+=a*Ie,ce+=a*nt,ue+=a*Me,ge+=a*We,pe+=a*Ye,fe+=a*Ze,le+=a*at,de+=a*gt,Z+=a*mt,oe+=a*yt,a=p[2],O+=a*A,q+=a*_e,ee+=a*Oe,j+=a*Ne,Re+=a*be,Y+=a*Ue,ce+=a*Ie,ue+=a*nt,ge+=a*Me,pe+=a*We,fe+=a*Ye,le+=a*Ze,de+=a*at,Z+=a*gt,oe+=a*mt,Q+=a*yt,a=p[3],q+=a*A,ee+=a*_e,j+=a*Oe,Re+=a*Ne,Y+=a*be,ce+=a*Ue,ue+=a*Ie,ge+=a*nt,pe+=a*Me,fe+=a*We,le+=a*Ye,de+=a*Ze,Z+=a*at,oe+=a*gt,Q+=a*mt,X+=a*yt,a=p[4],ee+=a*A,j+=a*_e,Re+=a*Oe,Y+=a*Ne,ce+=a*be,ue+=a*Ue,ge+=a*Ie,pe+=a*nt,fe+=a*Me,le+=a*We,de+=a*Ye,Z+=a*Ze,oe+=a*at,Q+=a*gt,X+=a*mt,J+=a*yt,a=p[5],j+=a*A,Re+=a*_e,Y+=a*Oe,ce+=a*Ne,ue+=a*be,ge+=a*Ue,pe+=a*Ie,fe+=a*nt,le+=a*Me,de+=a*We,Z+=a*Ye,oe+=a*Ze,Q+=a*at,X+=a*gt,J+=a*mt,V+=a*yt,a=p[6],Re+=a*A,Y+=a*_e,ce+=a*Oe,ue+=a*Ne,ge+=a*be,pe+=a*Ue,fe+=a*Ie,le+=a*nt,de+=a*Me,Z+=a*We,oe+=a*Ye,Q+=a*Ze,X+=a*at,J+=a*gt,V+=a*mt,C+=a*yt,a=p[7],Y+=a*A,ce+=a*_e,ue+=a*Oe,ge+=a*Ne,pe+=a*be,fe+=a*Ue,le+=a*Ie,de+=a*nt,Z+=a*Me,oe+=a*We,Q+=a*Ye,X+=a*Ze,J+=a*at,V+=a*gt,C+=a*mt,U+=a*yt,a=p[8],ce+=a*A,ue+=a*_e,ge+=a*Oe,pe+=a*Ne,fe+=a*be,le+=a*Ue,de+=a*Ie,Z+=a*nt,oe+=a*Me,Q+=a*We,X+=a*Ye,J+=a*Ze,V+=a*at,C+=a*gt,U+=a*mt,D+=a*yt,a=p[9],ue+=a*A,ge+=a*_e,pe+=a*Oe,fe+=a*Ne,le+=a*be,de+=a*Ue,Z+=a*Ie,oe+=a*nt,Q+=a*Me,X+=a*We,J+=a*Ye,V+=a*Ze,C+=a*at,U+=a*gt,D+=a*mt,R+=a*yt,a=p[10],ge+=a*A,pe+=a*_e,fe+=a*Oe,le+=a*Ne,de+=a*be,Z+=a*Ue,oe+=a*Ie,Q+=a*nt,X+=a*Me,J+=a*We,V+=a*Ye,C+=a*Ze,U+=a*at,D+=a*gt,R+=a*mt,N+=a*yt,a=p[11],pe+=a*A,fe+=a*_e,le+=a*Oe,de+=a*Ne,Z+=a*be,oe+=a*Ue,Q+=a*Ie,X+=a*nt,J+=a*Me,V+=a*We,C+=a*Ye,U+=a*Ze,D+=a*at,R+=a*gt,N+=a*mt,G+=a*yt,a=p[12],fe+=a*A,le+=a*_e,de+=a*Oe,Z+=a*Ne,oe+=a*be,Q+=a*Ue,X+=a*Ie,J+=a*nt,V+=a*Me,C+=a*We,U+=a*Ye,D+=a*Ze,R+=a*at,N+=a*gt,G+=a*mt,ie+=a*yt,a=p[13],le+=a*A,de+=a*_e,Z+=a*Oe,oe+=a*Ne,Q+=a*be,X+=a*Ue,J+=a*Ie,V+=a*nt,C+=a*Me,U+=a*We,D+=a*Ye,R+=a*Ze,N+=a*at,G+=a*gt,ie+=a*mt,me+=a*yt,a=p[14],de+=a*A,Z+=a*_e,oe+=a*Oe,Q+=a*Ne,X+=a*be,J+=a*Ue,V+=a*Ie,C+=a*nt,U+=a*Me,D+=a*We,R+=a*Ye,N+=a*Ze,G+=a*at,ie+=a*gt,me+=a*mt,he+=a*yt,a=p[15],Z+=a*A,oe+=a*_e,Q+=a*Oe,X+=a*Ne,J+=a*be,V+=a*Ue,C+=a*Ie,U+=a*nt,D+=a*Me,R+=a*We,N+=a*Ye,G+=a*Ze,ie+=a*at,me+=a*gt,he+=a*mt,ye+=a*yt,x+=38*oe,S+=38*Q,O+=38*X,q+=38*J,ee+=38*V,j+=38*C,Re+=38*U,Y+=38*D,ce+=38*R,ue+=38*N,ge+=38*G,pe+=38*ie,fe+=38*me,le+=38*he,de+=38*ye,g=1,a=x+g+65535,g=Math.floor(a/65536),x=a-g*65536,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=O+g+65535,g=Math.floor(a/65536),O=a-g*65536,a=q+g+65535,g=Math.floor(a/65536),q=a-g*65536,a=ee+g+65535,g=Math.floor(a/65536),ee=a-g*65536,a=j+g+65535,g=Math.floor(a/65536),j=a-g*65536,a=Re+g+65535,g=Math.floor(a/65536),Re=a-g*65536,a=Y+g+65535,g=Math.floor(a/65536),Y=a-g*65536,a=ce+g+65535,g=Math.floor(a/65536),ce=a-g*65536,a=ue+g+65535,g=Math.floor(a/65536),ue=a-g*65536,a=ge+g+65535,g=Math.floor(a/65536),ge=a-g*65536,a=pe+g+65535,g=Math.floor(a/65536),pe=a-g*65536,a=fe+g+65535,g=Math.floor(a/65536),fe=a-g*65536,a=le+g+65535,g=Math.floor(a/65536),le=a-g*65536,a=de+g+65535,g=Math.floor(a/65536),de=a-g*65536,a=Z+g+65535,g=Math.floor(a/65536),Z=a-g*65536,x+=g-1+37*(g-1),g=1,a=x+g+65535,g=Math.floor(a/65536),x=a-g*65536,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=O+g+65535,g=Math.floor(a/65536),O=a-g*65536,a=q+g+65535,g=Math.floor(a/65536),q=a-g*65536,a=ee+g+65535,g=Math.floor(a/65536),ee=a-g*65536,a=j+g+65535,g=Math.floor(a/65536),j=a-g*65536,a=Re+g+65535,g=Math.floor(a/65536),Re=a-g*65536,a=Y+g+65535,g=Math.floor(a/65536),Y=a-g*65536,a=ce+g+65535,g=Math.floor(a/65536),ce=a-g*65536,a=ue+g+65535,g=Math.floor(a/65536),ue=a-g*65536,a=ge+g+65535,g=Math.floor(a/65536),ge=a-g*65536,a=pe+g+65535,g=Math.floor(a/65536),pe=a-g*65536,a=fe+g+65535,g=Math.floor(a/65536),fe=a-g*65536,a=le+g+65535,g=Math.floor(a/65536),le=a-g*65536,a=de+g+65535,g=Math.floor(a/65536),de=a-g*65536,a=Z+g+65535,g=Math.floor(a/65536),Z=a-g*65536,x+=g-1+37*(g-1),u[0]=x,u[1]=S,u[2]=O,u[3]=q,u[4]=ee,u[5]=j,u[6]=Re,u[7]=Y,u[8]=ce,u[9]=ue,u[10]=ge,u[11]=pe,u[12]=fe,u[13]=le,u[14]=de,u[15]=Z}function Ke(u,p){se(u,p,p)}function St(u,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=253;a>=0;a--)Ke(d,d),a!==2&&a!==4&&se(d,d,p);for(a=0;a<16;a++)u[a]=d[a]}function ot(u,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=250;a>=0;a--)Ke(d,d),a!==1&&se(d,d,p);for(a=0;a<16;a++)u[a]=d[a]}function kt(u,p,d){var a=new Uint8Array(32),g=new Float64Array(80),x,S,O=t(),q=t(),ee=t(),j=t(),Re=t(),Y=t();for(S=0;S<31;S++)a[S]=p[S];for(a[31]=p[31]&127|64,a[0]&=248,ke(g,d),S=0;S<16;S++)q[S]=g[S],j[S]=O[S]=ee[S]=0;for(O[0]=j[0]=1,S=254;S>=0;--S)x=a[S>>>3]>>>(S&7)&1,F(O,q,x),F(ee,j,x),Te(Re,O,ee),De(O,O,ee),Te(ee,q,j),De(q,q,j),Ke(j,Re),Ke(Y,O),se(O,ee,O),se(ee,q,Re),Te(Re,O,ee),De(O,O,ee),Ke(q,O),De(ee,j,Y),se(O,ee,c),Te(O,O,j),se(ee,ee,O),se(O,j,Y),se(j,q,g),Ke(q,Re),F(O,q,x),F(ee,j,x);for(S=0;S<16;S++)g[S+16]=O[S],g[S+32]=ee[S],g[S+48]=q[S],g[S+64]=j[S];var ce=g.subarray(32),ue=g.subarray(16);return St(ce,ce),se(ue,ue,ce),re(u,ue),0}function st(u,p){return kt(u,p,o)}function pt(u,p){return e(p,32),st(u,p)}function ar(u,p,d){var a=new Uint8Array(32);return kt(a,d,p),$(u,n,a,M)}var Fe=Ce,xt=Ve;function Qt(u,p,d,a,g,x){var S=new Uint8Array(32);return ar(S,g,x),Fe(u,p,d,a,S)}function hn(u,p,d,a,g,x){var S=new Uint8Array(32);return ar(S,g,x),xt(u,p,d,a,S)}var qr=[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];function Ru(u,p,d,a){for(var g=new Int32Array(16),x=new Int32Array(16),S,O,q,ee,j,Re,Y,ce,ue,ge,pe,fe,le,de,Z,oe,Q,X,J,V,C,U,D,R,N,G,ie=u[0],me=u[1],he=u[2],ye=u[3],A=u[4],_e=u[5],Oe=u[6],Ne=u[7],be=p[0],Ue=p[1],Ie=p[2],nt=p[3],Me=p[4],We=p[5],Ye=p[6],Ze=p[7],at=0;a>=128;){for(J=0;J<16;J++)V=8*J+at,g[J]=d[V+0]<<24|d[V+1]<<16|d[V+2]<<8|d[V+3],x[J]=d[V+4]<<24|d[V+5]<<16|d[V+6]<<8|d[V+7];for(J=0;J<80;J++)if(S=ie,O=me,q=he,ee=ye,j=A,Re=_e,Y=Oe,ce=Ne,ue=be,ge=Ue,pe=Ie,fe=nt,le=Me,de=We,Z=Ye,oe=Ze,C=Ne,U=Ze,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=(A>>>14|Me<<18)^(A>>>18|Me<<14)^(Me>>>9|A<<23),U=(Me>>>14|A<<18)^(Me>>>18|A<<14)^(A>>>9|Me<<23),D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,C=A&_e^~A&Oe,U=Me&We^~Me&Ye,D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,C=qr[J*2],U=qr[J*2+1],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,C=g[J%16],U=x[J%16],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,Q=N&65535|G<<16,X=D&65535|R<<16,C=Q,U=X,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=(ie>>>28|be<<4)^(be>>>2|ie<<30)^(be>>>7|ie<<25),U=(be>>>28|ie<<4)^(ie>>>2|be<<30)^(ie>>>7|be<<25),D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,C=ie&me^ie&he^me&he,U=be&Ue^be&Ie^Ue&Ie,D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,ce=N&65535|G<<16,oe=D&65535|R<<16,C=ee,U=fe,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=Q,U=X,D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,ee=N&65535|G<<16,fe=D&65535|R<<16,me=S,he=O,ye=q,A=ee,_e=j,Oe=Re,Ne=Y,ie=ce,Ue=ue,Ie=ge,nt=pe,Me=fe,We=le,Ye=de,Ze=Z,be=oe,J%16===15)for(V=0;V<16;V++)C=g[V],U=x[V],D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=g[(V+9)%16],U=x[(V+9)%16],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,Q=g[(V+1)%16],X=x[(V+1)%16],C=(Q>>>1|X<<31)^(Q>>>8|X<<24)^Q>>>7,U=(X>>>1|Q<<31)^(X>>>8|Q<<24)^(X>>>7|Q<<25),D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,Q=g[(V+14)%16],X=x[(V+14)%16],C=(Q>>>19|X<<13)^(X>>>29|Q<<3)^Q>>>6,U=(X>>>19|Q<<13)^(Q>>>29|X<<3)^(X>>>6|Q<<26),D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,g[V]=N&65535|G<<16,x[V]=D&65535|R<<16;C=ie,U=be,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[0],U=p[0],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[0]=ie=N&65535|G<<16,p[0]=be=D&65535|R<<16,C=me,U=Ue,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[1],U=p[1],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[1]=me=N&65535|G<<16,p[1]=Ue=D&65535|R<<16,C=he,U=Ie,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[2],U=p[2],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[2]=he=N&65535|G<<16,p[2]=Ie=D&65535|R<<16,C=ye,U=nt,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[3],U=p[3],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[3]=ye=N&65535|G<<16,p[3]=nt=D&65535|R<<16,C=A,U=Me,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[4],U=p[4],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[4]=A=N&65535|G<<16,p[4]=Me=D&65535|R<<16,C=_e,U=We,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[5],U=p[5],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[5]=_e=N&65535|G<<16,p[5]=We=D&65535|R<<16,C=Oe,U=Ye,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[6],U=p[6],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[6]=Oe=N&65535|G<<16,p[6]=Ye=D&65535|R<<16,C=Ne,U=Ze,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[7],U=p[7],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[7]=Ne=N&65535|G<<16,p[7]=Ze=D&65535|R<<16,at+=128,a-=128}return a}function An(u,p,d){var a=new Int32Array(8),g=new Int32Array(8),x=new Uint8Array(256),S,O=d;for(a[0]=1779033703,a[1]=3144134277,a[2]=1013904242,a[3]=2773480762,a[4]=1359893119,a[5]=2600822924,a[6]=528734635,a[7]=1541459225,g[0]=4089235720,g[1]=2227873595,g[2]=4271175723,g[3]=1595750129,g[4]=2917565137,g[5]=725511199,g[6]=4215389547,g[7]=327033209,Ru(a,g,p,d),d%=128,S=0;S<d;S++)x[S]=p[O-d+S];for(x[d]=128,d=256-128*(d<112?1:0),x[d-9]=0,v(x,d-8,O/536870912|0,O<<3),Ru(a,g,x,d),S=0;S<8;S++)v(u,8*S,a[S],g[S]);return 0}function Ns(u,p){var d=t(),a=t(),g=t(),x=t(),S=t(),O=t(),q=t(),ee=t(),j=t();De(d,u[1],u[0]),De(j,p[1],p[0]),se(d,d,j),Te(a,u[0],u[1]),Te(j,p[0],p[1]),se(a,a,j),se(g,u[3],p[3]),se(g,g,l),se(x,u[2],p[2]),Te(x,x,x),De(S,a,d),De(O,x,g),Te(q,x,g),Te(ee,a,d),se(u[0],S,O),se(u[1],ee,q),se(u[2],q,O),se(u[3],S,ee)}function Ou(u,p,d){var a;for(a=0;a<4;a++)F(u[a],p[a],d)}function pa(u,p){var d=t(),a=t(),g=t();St(g,p[2]),se(d,p[0],g),se(a,p[1],g),re(u,a),u[31]^=xe(d)<<7}function ga(u,p,d){var a,g;for(_(u[0],s),_(u[1],i),_(u[2],i),_(u[3],s),g=255;g>=0;--g)a=d[g/8|0]>>(g&7)&1,Ou(u,p,a),Ns(p,u),Ns(u,u),Ou(u,p,a)}function ks(u,p){var d=[t(),t(),t(),t()];_(d[0],h),_(d[1],m),_(d[2],i),se(d[3],h,m),ga(u,d,p)}function ma(u,p,d){var a=new Uint8Array(64),g=[t(),t(),t(),t()],x;for(d||e(p,32),An(a,p,32),a[0]&=248,a[31]&=127,a[31]|=64,ks(g,a),pa(u,g),x=0;x<32;x++)p[x+32]=u[x];return 0}var zs=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ya(u,p){var d,a,g,x;for(a=63;a>=32;--a){for(d=0,g=a-32,x=a-12;g<x;++g)p[g]+=d-16*p[a]*zs[g-(a-32)],d=Math.floor((p[g]+128)/256),p[g]-=d*256;p[g]+=d,p[a]=0}for(d=0,g=0;g<32;g++)p[g]+=d-(p[31]>>4)*zs[g],d=p[g]>>8,p[g]&=255;for(g=0;g<32;g++)p[g]-=d*zs[g];for(a=0;a<32;a++)p[a+1]+=p[a]>>8,u[a]=p[a]&255}function ha(u){var p=new Float64Array(64),d;for(d=0;d<64;d++)p[d]=u[d];for(d=0;d<64;d++)u[d]=0;ya(u,p)}function Nu(u,p,d,a){var g=new Uint8Array(64),x=new Uint8Array(64),S=new Uint8Array(64),O,q,ee=new Float64Array(64),j=[t(),t(),t(),t()];An(g,a,32),g[0]&=248,g[31]&=127,g[31]|=64;var Re=d+64;for(O=0;O<d;O++)u[64+O]=p[O];for(O=0;O<32;O++)u[32+O]=g[32+O];for(An(S,u.subarray(32),d+32),ha(S),ks(j,S),pa(u,j),O=32;O<64;O++)u[O]=a[O];for(An(x,u,d+64),ha(x),O=0;O<64;O++)ee[O]=0;for(O=0;O<32;O++)ee[O]=S[O];for(O=0;O<32;O++)for(q=0;q<32;q++)ee[O+q]+=x[O]*g[q];return ya(u.subarray(32),ee),Re}function kp(u,p){var d=t(),a=t(),g=t(),x=t(),S=t(),O=t(),q=t();return _(u[2],i),ke(u[1],p),Ke(g,u[1]),se(x,g,f),De(g,g,u[2]),Te(x,u[2],x),Ke(S,x),Ke(O,S),se(q,O,S),se(d,q,g),se(d,d,x),ot(d,d),se(d,d,g),se(d,d,x),se(d,d,x),se(u[0],d,x),Ke(a,u[0]),se(a,a,x),ne(a,g)&&se(u[0],u[0],T),Ke(a,u[0]),se(a,a,x),ne(a,g)?-1:(xe(u[0])===p[31]>>7&&De(u[0],s,u[0]),se(u[3],u[0],u[1]),0)}function Aa(u,p,d,a){var g,x=new Uint8Array(32),S=new Uint8Array(64),O=[t(),t(),t(),t()],q=[t(),t(),t(),t()];if(d<64||kp(q,a))return-1;for(g=0;g<d;g++)u[g]=p[g];for(g=0;g<32;g++)u[g+32]=a[g];if(An(S,u,d),ha(S),ga(O,q,S),ks(q,p.subarray(32)),Ns(O,q),pa(x,O),d-=64,w(p,0,x,0)){for(g=0;g<d;g++)u[g]=0;return-1}for(g=0;g<d;g++)u[g]=p[g+64];return d}var xa=32,Ds=24,zo=32,so=16,Do=32,Ms=32,Mo=32,Go=32,ba=32,ku=Ds,zp=zo,Dp=so,wr=64,xn=32,io=64,wa=32,Ta=64;r.lowlevel={crypto_core_hsalsa20:$,crypto_stream_xor:we,crypto_stream:K,crypto_stream_salsa20_xor:z,crypto_stream_salsa20:L,crypto_onetimeauth:W,crypto_onetimeauth_verify:ve,crypto_verify_16:y,crypto_verify_32:w,crypto_secretbox:Ce,crypto_secretbox_open:Ve,crypto_scalarmult:kt,crypto_scalarmult_base:st,crypto_box_beforenm:ar,crypto_box_afternm:Fe,crypto_box:Qt,crypto_box_open:hn,crypto_box_keypair:pt,crypto_hash:An,crypto_sign:Nu,crypto_sign_keypair:ma,crypto_sign_open:Aa,crypto_secretbox_KEYBYTES:xa,crypto_secretbox_NONCEBYTES:Ds,crypto_secretbox_ZEROBYTES:zo,crypto_secretbox_BOXZEROBYTES:so,crypto_scalarmult_BYTES:Do,crypto_scalarmult_SCALARBYTES:Ms,crypto_box_PUBLICKEYBYTES:Mo,crypto_box_SECRETKEYBYTES:Go,crypto_box_BEFORENMBYTES:ba,crypto_box_NONCEBYTES:ku,crypto_box_ZEROBYTES:zp,crypto_box_BOXZEROBYTES:Dp,crypto_sign_BYTES:wr,crypto_sign_PUBLICKEYBYTES:xn,crypto_sign_SECRETKEYBYTES:io,crypto_sign_SEEDBYTES:wa,crypto_hash_BYTES:Ta,gf:t,D:f,L:zs,pack25519:re,unpack25519:ke,M:se,A:Te,S:Ke,Z:De,pow2523:ot,add:Ns,set25519:_,modL:ya,scalarmult:ga,scalarbase:ks};function zu(u,p){if(u.length!==xa)throw new Error("bad key size");if(p.length!==Ds)throw new Error("bad nonce size")}function Mp(u,p){if(u.length!==Mo)throw new Error("bad public key size");if(p.length!==Go)throw new Error("bad secret key size")}function Ct(){for(var u=0;u<arguments.length;u++)if(!(arguments[u]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Du(u){for(var p=0;p<u.length;p++)u[p]=0}r.randomBytes=function(u){var p=new Uint8Array(u);return e(p,u),p},r.secretbox=function(u,p,d){Ct(u,p,d),zu(d,p);for(var a=new Uint8Array(zo+u.length),g=new Uint8Array(a.length),x=0;x<u.length;x++)a[x+zo]=u[x];return Ce(g,a,a.length,p,d),g.subarray(so)},r.secretbox.open=function(u,p,d){Ct(u,p,d),zu(d,p);for(var a=new Uint8Array(so+u.length),g=new Uint8Array(a.length),x=0;x<u.length;x++)a[x+so]=u[x];return a.length<32||Ve(g,a,a.length,p,d)!==0?null:g.subarray(zo)},r.secretbox.keyLength=xa,r.secretbox.nonceLength=Ds,r.secretbox.overheadLength=so,r.scalarMult=function(u,p){if(Ct(u,p),u.length!==Ms)throw new Error("bad n size");if(p.length!==Do)throw new Error("bad p size");var d=new Uint8Array(Do);return kt(d,u,p),d},r.scalarMult.base=function(u){if(Ct(u),u.length!==Ms)throw new Error("bad n size");var p=new Uint8Array(Do);return st(p,u),p},r.scalarMult.scalarLength=Ms,r.scalarMult.groupElementLength=Do,r.box=function(u,p,d,a){var g=r.box.before(d,a);return r.secretbox(u,p,g)},r.box.before=function(u,p){Ct(u,p),Mp(u,p);var d=new Uint8Array(ba);return ar(d,u,p),d},r.box.after=r.secretbox,r.box.open=function(u,p,d,a){var g=r.box.before(d,a);return r.secretbox.open(u,p,g)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var u=new Uint8Array(Mo),p=new Uint8Array(Go);return pt(u,p),{publicKey:u,secretKey:p}},r.box.keyPair.fromSecretKey=function(u){if(Ct(u),u.length!==Go)throw new Error("bad secret key size");var p=new Uint8Array(Mo);return st(p,u),{publicKey:p,secretKey:new Uint8Array(u)}},r.box.publicKeyLength=Mo,r.box.secretKeyLength=Go,r.box.sharedKeyLength=ba,r.box.nonceLength=ku,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(u,p){if(Ct(u,p),p.length!==io)throw new Error("bad secret key size");var d=new Uint8Array(wr+u.length);return Nu(d,u,u.length,p),d},r.sign.open=function(u,p){if(Ct(u,p),p.length!==xn)throw new Error("bad public key size");var d=new Uint8Array(u.length),a=Aa(d,u,u.length,p);if(a<0)return null;for(var g=new Uint8Array(a),x=0;x<g.length;x++)g[x]=d[x];return g},r.sign.detached=function(u,p){for(var d=r.sign(u,p),a=new Uint8Array(wr),g=0;g<a.length;g++)a[g]=d[g];return a},r.sign.detached.verify=function(u,p,d){if(Ct(u,p,d),p.length!==wr)throw new Error("bad signature size");if(d.length!==xn)throw new Error("bad public key size");var a=new Uint8Array(wr+u.length),g=new Uint8Array(wr+u.length),x;for(x=0;x<wr;x++)a[x]=p[x];for(x=0;x<u.length;x++)a[x+wr]=u[x];return Aa(g,a,a.length,d)>=0},r.sign.keyPair=function(){var u=new Uint8Array(xn),p=new Uint8Array(io);return ma(u,p),{publicKey:u,secretKey:p}},r.sign.keyPair.fromSecretKey=function(u){if(Ct(u),u.length!==io)throw new Error("bad secret key size");for(var p=new Uint8Array(xn),d=0;d<p.length;d++)p[d]=u[32+d];return{publicKey:p,secretKey:new Uint8Array(u)}},r.sign.keyPair.fromSeed=function(u){if(Ct(u),u.length!==wa)throw new Error("bad seed size");for(var p=new Uint8Array(xn),d=new Uint8Array(io),a=0;a<32;a++)d[a]=u[a];return ma(p,d,!0),{publicKey:p,secretKey:d}},r.sign.publicKeyLength=xn,r.sign.secretKeyLength=io,r.sign.seedLength=wa,r.sign.signatureLength=wr,r.hash=function(u){Ct(u);var p=new Uint8Array(Ta);return An(p,u,u.length),p},r.hash.hashLength=Ta,r.verify=function(u,p){return Ct(u,p),u.length===0||p.length===0||u.length!==p.length?!1:b(u,0,p,0,u.length)===0},r.setPRNG=function(u){e=u},function(){var u=typeof self<"u"?self.crypto||self.msCrypto:null;if(u&&u.getRandomValues){var p=65536;r.setPRNG(function(d,a){var g,x=new Uint8Array(a);for(g=0;g<a;g+=p)u.getRandomValues(x.subarray(g,g+Math.min(a-g,p)));for(g=0;g<a;g++)d[g]=x[g];Du(x)})}else typeof Gu<"u"&&(u=df(),u&&u.randomBytes&&r.setPRNG(function(d,a){var g,x=u.randomBytes(a);for(g=0;g<a;g++)d[g]=x[g];Du(x)}))}()})(typeof ti<"u"&&ti.exports?ti.exports:self.nacl=self.nacl||{})});var Ph={};Gs(Ph,{APTOS_BIP44_REGEX:()=>hf,APTOS_COIN:()=>$o,APTOS_HARDENED_REGEX:()=>yf,Account:()=>Dr,AccountAddress:()=>H,AccountAuthenticator:()=>vt,AccountAuthenticatorEd25519:()=>mr,AccountAuthenticatorMultiEd25519:()=>ps,AccountAuthenticatorMultiKey:()=>Ln,AccountAuthenticatorSingleKey:()=>sr,AccountAuthenticatorVariant:()=>Ca,AccountSequenceNumber:()=>Ps,AddressInvalidReason:()=>rf,AnyPublicKey:()=>je,AnyPublicKeyVariant:()=>Ua,AnySignature:()=>lr,AnySignatureVariant:()=>Ia,Aptos:()=>Nt,AptosApiError:()=>cr,AptosApiType:()=>Ho,AptosConfig:()=>ds,AuthenticationKey:()=>or,Bool:()=>Xe,CKDPriv:()=>ec,ChainId:()=>$n,DEFAULT_MAX_GAS_AMOUNT:()=>Na,DEFAULT_NETWORK:()=>Oa,DEFAULT_TXN_EXP_SEC_FROM_NOW:()=>ka,DEFAULT_TXN_TIMEOUT_SEC:()=>Fo,DeriveScheme:()=>Vu,Deserializer:()=>Qa,Ed25519PrivateKey:()=>Ur,Ed25519PublicKey:()=>qe,Ed25519Signature:()=>Je,EntryFunction:()=>ro,EntryFunctionBytes:()=>Qo,FeePayerRawTransaction:()=>xr,FixedBytes:()=>$r,HARDENED_OFFSET:()=>Za,Hex:()=>Be,HexInvalidReason:()=>ef,Identifier:()=>Qe,KeyType:()=>Af,MimeType:()=>Ls,ModuleId:()=>So,MoveAbility:()=>Fu,MoveFunctionVisibility:()=>Hu,MoveOption:()=>Cr,MoveString:()=>ht,MoveVector:()=>Le,MultiAgentRawTransaction:()=>Ar,MultiEd25519PublicKey:()=>er,MultiEd25519Signature:()=>Bn,MultiKey:()=>Gn,MultiSig:()=>Io,MultiSigTransactionPayload:()=>Bo,Network:()=>Ko,NetworkToChainId:()=>Hs,NetworkToFaucetAPI:()=>Ra,NetworkToIndexerAPI:()=>Ks,NetworkToNetworkName:()=>tg,NetworkToNodeAPI:()=>Pa,ParsingError:()=>bt,PrivateKey:()=>Un,ProcessorType:()=>bn,PublicKey:()=>It,RAW_TRANSACTION_SALT:()=>za,RAW_TRANSACTION_WITH_DATA_SALT:()=>Fs,RawTransaction:()=>Vt,RawTransactionWithData:()=>ms,RoleType:()=>$u,RotationProofChallenge:()=>ls,Script:()=>Uo,ScriptTransactionArgumentVariants:()=>ao,Secp256k1PrivateKey:()=>Nr,Secp256k1PublicKey:()=>Ft,Secp256k1Signature:()=>kr,Serializable:()=>ae,Serializer:()=>Zt,Signature:()=>Jt,SignedTransaction:()=>ir,SigningScheme:()=>co,SigningSchemeInput:()=>Ba,StructTag:()=>hr,TransactionAuthenticator:()=>yr,TransactionAuthenticatorEd25519:()=>qn,TransactionAuthenticatorFeePayer:()=>Hn,TransactionAuthenticatorMultiAgent:()=>Kn,TransactionAuthenticatorMultiEd25519:()=>ji,TransactionAuthenticatorSingleSender:()=>Fn,TransactionAuthenticatorVariant:()=>va,TransactionPayload:()=>gn,TransactionPayloadEntryFunction:()=>vo,TransactionPayloadMultiSig:()=>Co,TransactionPayloadScript:()=>Eo,TransactionPayloadVariants:()=>Sa,TransactionResponseType:()=>qs,TransactionVariants:()=>Ea,TransactionWorker:()=>Rs,TypeTag:()=>rt,TypeTagAddress:()=>Jn,TypeTagBool:()=>Vn,TypeTagGeneric:()=>eo,TypeTagParserError:()=>He,TypeTagParserErrorType:()=>Nl,TypeTagReference:()=>gs,TypeTagSigner:()=>pn,TypeTagStruct:()=>Gr,TypeTagU128:()=>Zn,TypeTagU16:()=>Qn,TypeTagU256:()=>Xn,TypeTagU32:()=>Wn,TypeTagU64:()=>Yn,TypeTagU8:()=>jn,TypeTagVariants:()=>_a,TypeTagVector:()=>to,U128:()=>Mt,U16:()=>zt,U256:()=>Gt,U32:()=>Dt,U64:()=>ft,U8:()=>lt,aptosCoinStructTag:()=>mh,aptosRequest:()=>qo,buildTransaction:()=>sa,checkOrConvertArgument:()=>oo,convertArgument:()=>Au,deriveKey:()=>ni,deriveTransactionType:()=>Tu,deserializeFromScriptArgument:()=>Pl,ensureBoolean:()=>Ys,fetchEntryFunctionAbi:()=>hu,findFirstNonSignerArg:()=>gu,generateMultiSignersSignedTransaction:()=>Gl,generateRawTransaction:()=>Ml,generateSignedTransaction:()=>wu,generateSignedTransactionForSimulation:()=>xu,generateSigningMessage:()=>ia,generateTransactionPayload:()=>bs,generateTransactionPayloadWithABI:()=>zl,get:()=>Da,getAptosFullNode:()=>Ut,getAuthenticatorForSimulation:()=>xs,getFunctionParts:()=>oa,isBcsAddress:()=>As,isBcsBool:()=>Wi,isBcsFixedBytes:()=>kl,isBcsString:()=>Yi,isBcsU128:()=>ta,isBcsU16:()=>Xi,isBcsU256:()=>ra,isBcsU32:()=>Ji,isBcsU64:()=>ea,isBcsU8:()=>Zi,isBlockMetadataTransactionResponse:()=>Qp,isBool:()=>du,isEd25519Signature:()=>Yp,isEncodedEntryFunctionArgument:()=>pu,isFeePayerSignature:()=>Jp,isGenesisTransactionResponse:()=>jp,isLargeNumber:()=>hs,isMultiAgentSignature:()=>Xp,isMultiEd25519Signature:()=>eg,isNull:()=>lu,isNumber:()=>ys,isPendingTransactionResponse:()=>$p,isScriptDataInput:()=>na,isSecp256k1Signature:()=>Zp,isStateCheckpointTransactionResponse:()=>Wp,isString:()=>no,isUserTransactionResponse:()=>Vp,isValidBIP44Path:()=>Xa,isValidHardenedPath:()=>Ja,mnemonicToSeed:()=>Yo,objectStructTag:()=>Ah,optionStructTag:()=>hh,outOfRangeErrorMessage:()=>tf,paginateWithCursor:()=>wn,parseTypeTag:()=>Po,post:()=>$s,postAptosFaucet:()=>Ga,postAptosFullNode:()=>Tn,postAptosIndexer:()=>Ma,request:()=>Qu,sign:()=>bu,splitPath:()=>tc,standardizeTypeTags:()=>yu,stringStructTag:()=>yh,throwTypeMismatch:()=>$e,validateNumberInRange:()=>Sr});var cr=class extends Error{constructor(e,n,o){super(o);this.name="AptosApiError",this.url=n.url,this.status=n.status,this.statusText=n.statusText,this.data=n.data,this.request=e}};var Ku="1.3.0";var Ls=(n=>(n.JSON="application/json",n.BCS="application/x-bcs",n.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",n))(Ls||{}),_a=(v=>(v[v.Bool=0]="Bool",v[v.U8=1]="U8",v[v.U64=2]="U64",v[v.U128=3]="U128",v[v.Address=4]="Address",v[v.Signer=5]="Signer",v[v.Vector=6]="Vector",v[v.Struct=7]="Struct",v[v.U16=8]="U16",v[v.U32=9]="U32",v[v.U256=10]="U256",v[v.Reference=254]="Reference",v[v.Generic=255]="Generic",v))(_a||{}),ao=(l=>(l[l.U8=0]="U8",l[l.U64=1]="U64",l[l.U128=2]="U128",l[l.Address=3]="Address",l[l.U8Vector=4]="U8Vector",l[l.Bool=5]="Bool",l[l.U16=6]="U16",l[l.U32=7]="U32",l[l.U256=8]="U256",l))(ao||{}),Sa=(n=>(n[n.Script=0]="Script",n[n.EntryFunction=2]="EntryFunction",n[n.Multisig=3]="Multisig",n))(Sa||{}),Ea=(e=>(e[e.MultiAgentTransaction=0]="MultiAgentTransaction",e[e.FeePayerTransaction=1]="FeePayerTransaction",e))(Ea||{}),va=(s=>(s[s.Ed25519=0]="Ed25519",s[s.MultiEd25519=1]="MultiEd25519",s[s.MultiAgent=2]="MultiAgent",s[s.FeePayer=3]="FeePayer",s[s.SingleSender=4]="SingleSender",s))(va||{}),Ca=(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Ca||{}),Ua=(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Ua||{}),Ia=(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Ia||{}),qs=(s=>(s.Pending="pending_transaction",s.User="user_transaction",s.Genesis="genesis_transaction",s.BlockMetadata="block_metadata_transaction",s.StateCheckpoint="state_checkpoint_transaction",s))(qs||{});function $p(r){return r.type==="pending_transaction"}function Vp(r){return r.type==="user_transaction"}function jp(r){return r.type==="genesis_transaction"}function Qp(r){return r.type==="block_metadata_transaction"}function Wp(r){return r.type==="state_checkpoint_transaction"}function Yp(r){return"signature"in r&&r.signature==="ed25519_signature"}function Zp(r){return"signature"in r&&r.signature==="secp256k1_ecdsa_signature"}function Xp(r){return r.type==="multi_agent_signature"}function Jp(r){return r.type==="fee_payer_signature"}function eg(r){return r.type==="multi_ed25519_signature"}var Hu=(n=>(n.PRIVATE="private",n.PUBLIC="public",n.FRIEND="friend",n))(Hu||{}),Fu=(o=>(o.STORE="store",o.DROP="drop",o.KEY="key",o.COPY="copy",o))(Fu||{}),$u=(e=>(e.VALIDATOR="validator",e.FULL_NODE="full_node",e))($u||{}),co=(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(co||{}),Ba=(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",e))(Ba||{}),Vu=(s=>(s[s.DeriveAuid=251]="DeriveAuid",s[s.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",s[s.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",s[s.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",s[s.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",s))(Vu||{});var ju={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable"};async function Qu(r,t){let{url:e,method:n,body:o,contentType:s,params:i,overrides:c}=r,f={...c?.HEADERS,"x-aptos-client":`aptos-typescript-sdk/${Ku}`,"content-type":s??"application/json"};return c?.AUTH_TOKEN&&e.includes("faucet")&&(f.Authorization=`Bearer ${c?.AUTH_TOKEN}`),c?.API_KEY&&!e.includes("faucet")&&(f.Authorization=`Bearer ${c?.API_KEY}`),t.provider({url:e,method:n,body:o,params:i,headers:f,overrides:c})}async function qo(r,t){let{url:e,path:n}=r,o=`${e}/${n??""}`,s=await Qu({...r,url:o},t.client),i={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(t.isIndexerRequest(e)){let f=i.data;if(f.errors)throw new cr(r,i,f.errors[0].message??`Unhandled Error ${s.status} : ${s.statusText}`);i.data=f.data}if(i.status>=200&&i.status<300)return i;let c;throw i&&i.data&&"message"in i.data&&"error_code"in i.data?c=JSON.stringify(i.data):i.status in ju?c=ju[i.status]:c=`Unhandled Error ${i.status} : ${i.statusText}`,new cr(r,i,c)}var Ks={mainnet:"https://indexer.mainnet.aptoslabs.com/v1/graphql",testnet:"https://indexer-testnet.staging.gcp.aptosdev.com/v1/graphql",devnet:"https://indexer-devnet.staging.gcp.aptosdev.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Pa={mainnet:"https://fullnode.mainnet.aptoslabs.com/v1",testnet:"https://fullnode.testnet.aptoslabs.com/v1",devnet:"https://fullnode.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},Ra={mainnet:"https://faucet.mainnet.aptoslabs.com",testnet:"https://faucet.testnet.aptoslabs.com",devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},Ko=(s=>(s.MAINNET="mainnet",s.TESTNET="testnet",s.DEVNET="devnet",s.LOCAL="local",s.CUSTOM="custom",s))(Ko||{}),Hs={mainnet:1,testnet:2},tg={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var Ho=(n=>(n[n.FULLNODE=0]="FULLNODE",n[n.INDEXER=1]="INDEXER",n[n.FAUCET=2]="FAUCET",n))(Ho||{}),Oa="devnet",Na=2e5,ka=20,Fo=20,$o="0x1::aptos_coin::AptosCoin",za="APTOS::RawTransaction",Fs="APTOS::RawTransactionWithData",bn=(c=>(c.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",c.DEFAULT="default_processor",c.EVENTS_PROCESSOR="events_processor",c.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",c.STAKE_PROCESSOR="stake_processor",c.TOKEN_V2_PROCESSOR="token_v2_processor",c.USER_TRANSACTION_PROCESSOR="user_transaction_processor",c))(bn||{});async function Da(r){let{aptosConfig:t,overrides:e,params:n,contentType:o,acceptType:s,path:i,originMethod:c,type:f}=r,l=t.getRequestUrl(f);return qo({url:l,method:"GET",originMethod:c,path:i,contentType:o?.valueOf(),acceptType:s?.valueOf(),params:n,overrides:{...t.clientConfig,...e}},t)}async function Ut(r){return Da({...r,type:0})}async function wn(r){let t=[],e,n=r.params;for(;;){n.start=e;let o=await Da({type:0,aptosConfig:r.aptosConfig,originMethod:r.originMethod,path:r.path,params:n,overrides:r.overrides});if(e=o.headers["x-aptos-cursor"],delete o.headers,t.push(...o.data),e==null)break}return t}async function $s(r){let{type:t,originMethod:e,path:n,body:o,acceptType:s,contentType:i,params:c,aptosConfig:f,overrides:l}=r,h=f.getRequestUrl(t);return qo({url:h,method:"POST",originMethod:e,path:n,body:o,contentType:i?.valueOf(),acceptType:s?.valueOf(),params:c,overrides:{...f.clientConfig,...l}},f)}async function Tn(r){return $s({...r,type:0})}async function Ma(r){return $s({...r,type:1})}async function Ga(r){return $s({...r,type:2})}var Vs=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Yu=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4));function La(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var ur=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Wt=(r,t)=>r<<32-t|r>>>t,rg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!rg)throw new Error("Non little-endian hardware is not supported");var ng=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function _n(r){if(!La(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=ng[r[e]];return t}var Tr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Wu(r){if(r>=Tr._0&&r<=Tr._9)return r-Tr._0;if(r>=Tr._A&&r<=Tr._F)return r-(Tr._A-10);if(r>=Tr._a&&r<=Tr._f)return r-(Tr._a-10)}function uo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=Wu(r.charCodeAt(s)),c=Wu(r.charCodeAt(s+1));if(i===void 0||c===void 0){let f=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+c}return n}function qa(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Yt(r){if(typeof r=="string"&&(r=qa(r)),!La(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function Sn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];if(!La(o))throw new Error("Uint8Array expected");t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var Kr=class{clone(){return this._cloneInto()}},og={}.toString;function Zu(r,t){if(t!==void 0&&og.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,t)}function Hr(r){let t=n=>r().update(Yt(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Xu(r){let t=(n,o)=>r(o).update(Yt(n)).digest(),e=r({});return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=n=>r(n),t}function Ju(r=32){if(Vs&&typeof Vs.getRandomValues=="function")return Vs.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}var js=255,Qs=65535,_r=4294967295,En=18446744073709551615n,Vo=340282366920938463463374607431768211455n,Ws=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var bt=class extends Error{constructor(e,n){super(e);this.invalidReason=n}};var ef=(n=>(n.TOO_SHORT="too_short",n.INVALID_LENGTH="invalid_length",n.INVALID_HEX_CHARS="invalid_hex_chars",n))(ef||{}),Be=class r{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return _n(this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromString(t){let e=t;if(e.startsWith("0x")&&(e=e.slice(2)),e.length===0)throw new bt("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(e.length%2!==0)throw new bt("Hex string must be an even number of hex characters.","invalid_length");try{return new r(uo(e))}catch(n){throw new bt(`Hex string contains invalid hex characters: ${n?.message}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new r(t):r.fromString(t)}static isValid(t){try{return r.fromString(t),{valid:!0}}catch(e){return{valid:!1,invalidReason:e?.invalidReason,invalidReasonMessage:e?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((e,n)=>e===t.data[n])}};var ae=class{bcsToBytes(){let t=new Zt;return this.serialize(t),t.toUint8Array()}bcsToHex(){let t=this.bcsToBytes();return Be.fromHexInput(t)}},Zt=class{constructor(t=64){if(t<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(t),this.offset=0}ensureBufferWillHandleSize(t){for(;this.buffer.byteLength<this.offset+t;){let e=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e}}appendToBuffer(t){this.ensureBufferWillHandleSize(t.length),new Uint8Array(this.buffer,this.offset).set(t),this.offset+=t.length}serializeWithFunction(t,e,n){this.ensureBufferWillHandleSize(e);let o=new DataView(this.buffer,this.offset);t.apply(o,[0,n,!0]),this.offset+=e}serializeStr(t){let e=new TextEncoder;this.serializeBytes(e.encode(t))}serializeBytes(t){this.serializeU32AsUleb128(t.length),this.appendToBuffer(t)}serializeFixedBytes(t){this.appendToBuffer(t)}serializeBool(t){Ys(t);let e=t?1:0;this.appendToBuffer(new Uint8Array([e]))}serializeU8(t){this.appendToBuffer(new Uint8Array([t]))}serializeU16(t){this.serializeWithFunction(DataView.prototype.setUint16,2,t)}serializeU32(t){this.serializeWithFunction(DataView.prototype.setUint32,4,t)}serializeU64(t){let e=BigInt(t)&BigInt(_r),n=BigInt(t)>>BigInt(32);this.serializeU32(Number(e)),this.serializeU32(Number(n))}serializeU128(t){let e=BigInt(t)&En,n=BigInt(t)>>BigInt(64);this.serializeU64(e),this.serializeU64(n)}serializeU256(t){let e=BigInt(t)&Vo,n=BigInt(t)>>BigInt(128);this.serializeU128(e),this.serializeU128(n)}serializeU32AsUleb128(t){let e=t,n=[];for(;e>>>7;)n.push(e&127|128),e>>>=7;n.push(e),this.appendToBuffer(new Uint8Array(n))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(t){t.serialize(this)}serializeVector(t){this.serializeU32AsUleb128(t.length),t.forEach(e=>{e.serialize(this)})}};Et([vn(0,js)],Zt.prototype,"serializeU8",1),Et([vn(0,Qs)],Zt.prototype,"serializeU16",1),Et([vn(0,_r)],Zt.prototype,"serializeU32",1),Et([vn(BigInt(0),En)],Zt.prototype,"serializeU64",1),Et([vn(BigInt(0),Vo)],Zt.prototype,"serializeU128",1),Et([vn(BigInt(0),Ws)],Zt.prototype,"serializeU256",1),Et([vn(0,_r)],Zt.prototype,"serializeU32AsUleb128",1);function Ys(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}var tf=(r,t,e)=>`${r} is out of range: [${t}, ${e}]`;function Sr(r,t,e){let n=BigInt(r);if(n>BigInt(e)||n<BigInt(t))throw new Error(tf(r,t,e))}function vn(r,t){return(e,n,o)=>{let s=o.value;return o.value=function(c){return Sr(c,r,t),s.apply(this,[c])},o}}var rf=(c=>(c.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",c.INVALID_HEX_CHARS="invalid_hex_chars",c.TOO_SHORT="too_short",c.TOO_LONG="too_long",c.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",c.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",c.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",c))(rf||{}),Ge=class Ge extends ae{constructor(e){super();if(e.length!==Ge.LENGTH)throw new bt("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=_n(this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _n(this.data)}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let n=e.deserializeFixedBytes(Ge.LENGTH);return new Ge(n)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new bt("Hex string must start with a leading 0x.","leading_zero_x_required");let n=Ge.fromString(e);if(e.length!==Ge.LONG_STRING_LENGTH+2)if(n.isSpecial()){if(e.length!==3)throw new bt(`The given hex string ${e} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new bt(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return n}static fromString(e){let n=e;if(e.startsWith("0x")&&(n=e.slice(2)),n.length===0)throw new bt("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new bt("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let o;try{o=uo(n.padStart(64,"0"))}catch(s){throw new bt(`Hex characters are invalid: ${s?.message}`,"invalid_hex_chars")}return new Ge(o)}static from(e){return e instanceof Ge?e:e instanceof Uint8Array?new Ge(e):Ge.fromString(e)}static fromStrict(e){return e instanceof Ge?e:e instanceof Uint8Array?new Ge(e):Ge.fromStringStrict(e)}static isValid(e){try{return e.strict?Ge.fromStrict(e.input):Ge.from(e.input),{valid:!0}}catch(n){return{valid:!1,invalidReason:n?.invalidReason,invalidReasonMessage:n?.message}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((n,o)=>n===e.data[o])}};Ge.LENGTH=32,Ge.LONG_STRING_LENGTH=64,Ge.ZERO=Ge.from("0x0"),Ge.ONE=Ge.from("0x1"),Ge.TWO=Ge.from("0x2"),Ge.THREE=Ge.from("0x3"),Ge.FOUR=Ge.from("0x4");var H=Ge;function Er(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function sg(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Xt(r,...t){if(!sg(r))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function Zs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Er(r.outputLen),Er(r.blockLen)}function vr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Xs(r,t){Xt(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Js=BigInt(4294967295),Ka=BigInt(32);function nf(r,t=!1){return t?{h:Number(r&Js),l:Number(r>>Ka&Js)}:{h:Number(r>>Ka&Js)|0,l:Number(r&Js)|0}}function Ha(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=nf(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var ig=(r,t)=>BigInt(r>>>0)<<Ka|BigInt(t>>>0),ag=(r,t,e)=>r>>>e,cg=(r,t,e)=>r<<32-e|t>>>e,ug=(r,t,e)=>r>>>e|t<<32-e,fg=(r,t,e)=>r<<32-e|t>>>e,dg=(r,t,e)=>r<<64-e|t>>>e-32,lg=(r,t,e)=>r>>>e-32|t<<64-e,pg=(r,t)=>t,gg=(r,t)=>r,Fa=(r,t,e)=>r<<e|t>>>32-e,$a=(r,t,e)=>t<<e|r>>>32-e,Va=(r,t,e)=>t<<e-32|r>>>64-e,ja=(r,t,e)=>r<<e-32|t>>>64-e;function mg(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var yg=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),hg=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ag=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),xg=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,bg=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),wg=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Tg={fromBig:nf,split:Ha,toBig:ig,shrSH:ag,shrSL:cg,rotrSH:ug,rotrSL:fg,rotrBH:dg,rotrBL:lg,rotr32H:pg,rotr32L:gg,rotlSH:Fa,rotlSL:$a,rotlBH:Va,rotlBL:ja,add:mg,add3L:yg,add3H:hg,add4L:Ag,add4H:xg,add5H:wg,add5L:bg},Ae=Tg;var[af,cf,uf]=[[],[],[]],_g=BigInt(0),jo=BigInt(1),Sg=BigInt(2),Eg=BigInt(7),vg=BigInt(256),Cg=BigInt(113);for(let r=0,t=jo,e=1,n=0;r<24;r++){[e,n]=[n,(2*e+3*n)%5],af.push(2*(5*n+e)),cf.push((r+1)*(r+2)/2%64);let o=_g;for(let s=0;s<7;s++)t=(t<<jo^(t>>Eg)*Cg)%vg,t&Sg&&(o^=jo<<(jo<<BigInt(s))-jo);uf.push(o)}var[Ug,Ig]=Ha(uf,!0),of=(r,t,e)=>e>32?Va(r,t,e):Fa(r,t,e),sf=(r,t,e)=>e>32?ja(r,t,e):$a(r,t,e);function Bg(r,t=24){let e=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let i=0;i<10;i++)e[i]=r[i]^r[i+10]^r[i+20]^r[i+30]^r[i+40];for(let i=0;i<10;i+=2){let c=(i+8)%10,f=(i+2)%10,l=e[f],h=e[f+1],m=of(l,h,1)^e[c],T=sf(l,h,1)^e[c+1];for(let v=0;v<50;v+=10)r[i+v]^=m,r[i+v+1]^=T}let o=r[2],s=r[3];for(let i=0;i<24;i++){let c=cf[i],f=of(o,s,c),l=sf(o,s,c),h=af[i];o=r[h],s=r[h+1],r[h]=f,r[h+1]=l}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)e[c]=r[i+c];for(let c=0;c<10;c++)r[i+c]^=~e[(c+2)%10]&e[(c+4)%10]}r[0]^=Ug[n],r[1]^=Ig[n]}e.fill(0)}var ei=class r extends Kr{constructor(t,e,n,o=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=o,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Er(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Yu(this.state)}keccak(){Bg(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){vr(this);let{blockLen:e,state:n}=this;t=Yt(t);let o=t.length;for(let s=0;s<o;){let i=Math.min(e-this.pos,o-s);for(let c=0;c<i;c++)n[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:e,pos:n,blockLen:o}=this;t[n]^=e,e&128&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){vr(this,!1),Xt(t),this.finish();let e=this.state,{blockLen:n}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);t.set(e.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Er(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Xs(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){let{blockLen:e,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new r(e,n,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}},Fr=(r,t,e)=>Hr(()=>new ei(t,r,e)),O0=Fr(6,144,224/8),Cn=Fr(6,136,256/8),N0=Fr(6,104,384/8),k0=Fr(6,72,512/8),z0=Fr(1,144,224/8),D0=Fr(1,136,256/8),M0=Fr(1,104,384/8),G0=Fr(1,72,512/8),ff=(r,t,e)=>Xu((n={})=>new ei(t,r,n.dkLen===void 0?e:n.dkLen,!0)),L0=ff(31,168,128/8),q0=ff(31,136,256/8);var Zo=Hp(lf());var Qa=class{constructor(t){this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t,0),this.offset=0}read(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}deserializeStr(){let t=this.deserializeBytes();return new TextDecoder().decode(t)}deserializeBytes(){let t=this.deserializeUleb128AsU32();return new Uint8Array(this.read(t))}deserializeFixedBytes(t){return new Uint8Array(this.read(t))}deserializeBool(){let t=new Uint8Array(this.read(1))[0];if(t!==1&&t!==0)throw new Error("Invalid boolean value");return t===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let t=this.deserializeU32(),e=this.deserializeU32();return BigInt(BigInt(e)<<BigInt(32)|BigInt(t))}deserializeU128(){let t=this.deserializeU64(),e=this.deserializeU64();return BigInt(e<<BigInt(64)|t)}deserializeU256(){let t=this.deserializeU128(),e=this.deserializeU128();return BigInt(e<<BigInt(128)|t)}deserializeUleb128AsU32(){let t=BigInt(0),e=0;for(;t<_r;){let n=this.deserializeU8();if(t|=BigInt(n&127)<<BigInt(e),!(n&128))break;e+=7}if(t>_r)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(t)}deserialize(t){return t.deserialize(this)}deserializeVector(t){let e=this.deserializeUleb128AsU32(),n=new Array;for(let o=0;o<e;o+=1)n.push(this.deserialize(t));return n}};var $r=class r extends ae{constructor(e){super();this.value=Be.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,n){let o=e.deserializeFixedBytes(n);return new r(o)}};var Qo=class r extends ae{constructor(e){super();this.value=new $r(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,n){let o=$r.deserialize(e,n);return new r(o.value)}};var Xe=class r extends ae{constructor(e){super();Ys(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}static deserialize(e){return new r(e.deserializeBool())}},lt=class r extends ae{constructor(e){super();Sr(e,0,js),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new r(e.deserializeU8())}},zt=class r extends ae{constructor(e){super();Sr(e,0,Qs),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new r(e.deserializeU16())}},Dt=class r extends ae{constructor(e){super();Sr(e,0,_r),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new r(e.deserializeU32())}},ft=class r extends ae{constructor(e){super();Sr(e,BigInt(0),En),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new r(e.deserializeU64())}},Mt=class r extends ae{constructor(e){super();Sr(e,BigInt(0),Vo),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new r(e.deserializeU128())}},Gt=class r extends ae{constructor(e){super();Sr(e,BigInt(0),Ws),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new r(e.deserializeU256())}};var Le=class r extends ae{constructor(e){super();this.values=e}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){if(!(this.values[0]instanceof lt)&&this.values[0]!==void 0)throw new Error("Script function arguments only accept u8 vectors");e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let n;if(Array.isArray(e)&&typeof e[0]=="number")n=e;else if(typeof e=="string"){let o=Be.fromHexInput(e);n=Array.from(o.toUint8Array())}else if(e instanceof Uint8Array)n=Array.from(e);else throw new Error("Invalid input type");return new r(n.map(o=>new lt(o)))}static U16(e){return new r(e.map(n=>new zt(n)))}static U32(e){return new r(e.map(n=>new Dt(n)))}static U64(e){return new r(e.map(n=>new ft(n)))}static U128(e){return new r(e.map(n=>new Mt(n)))}static U256(e){return new r(e.map(n=>new Gt(n)))}static Bool(e){return new r(e.map(n=>new Xe(n)))}static MoveString(e){return new r(e.map(n=>new ht(n)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,n){let o=e.deserializeUleb128AsU32(),s=new Array;for(let i=0;i<o;i+=1)s.push(n.deserialize(e));return new r(s)}},ht=class r extends ae{constructor(e){super();this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){let n=this.bcsToBytes().slice(1);Le.U8(n).serializeForScriptFunction(e)}static deserialize(e){return new r(e.deserializeStr())}},Cr=class r extends ae{constructor(e){super();typeof e<"u"&&e!==null?this.vec=new Le([e]):this.vec=new Le([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new r(e!=null?new lt(e):void 0)}static U16(e){return new r(e!=null?new zt(e):void 0)}static U32(e){return new r(e!=null?new Dt(e):void 0)}static U64(e){return new r(e!=null?new ft(e):void 0)}static U128(e){return new r(e!=null?new Mt(e):void 0)}static U256(e){return new r(e!=null?new Gt(e):void 0)}static Bool(e){return new r(e!=null?new Xe(e):void 0)}static MoveString(e){return new r(e!=null?new ht(e):void 0)}static deserialize(e,n){let o=Le.deserialize(e,n);return new r(o.values[0])}};var It=class extends ae{},Un=class extends ae{},Jt=class extends ae{};var ri=class extends Kr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Zs(t);let n=Yt(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return vr(this),this.iHash.update(t),this}digestInto(t){vr(this),Xt(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),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:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},fr=(r,t,e)=>new ri(r,t).update(e).digest();fr.create=(r,t)=>new ri(r,t);function Pg(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),f=n?4:0,l=n?0:4;r.setUint32(t+f,i,n),r.setUint32(t+l,c,n)}var Vr=class extends Kr{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ur(this.buffer)}update(t){vr(this);let{view:e,buffer:n,blockLen:o}=this;t=Yt(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let f=ur(t);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){vr(this),Xs(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let m=i;m<o;m++)e[m]=0;Pg(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=ur(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=f/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<l;m++)c.setUint32(4*m,h[m],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var[Rg,Og]=Ae.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),jr=new Uint32Array(80),Qr=new Uint32Array(80),Wa=class extends Vr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:f,Eh:l,El:h,Fh:m,Fl:T,Gh:v,Gl:b,Hh:y,Hl:w}=this;return[t,e,n,o,s,i,c,f,l,h,m,T,v,b,y,w]}set(t,e,n,o,s,i,c,f,l,h,m,T,v,b,y,w){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=f|0,this.Eh=l|0,this.El=h|0,this.Fh=m|0,this.Fl=T|0,this.Gh=v|0,this.Gl=b|0,this.Hh=y|0,this.Hl=w|0}process(t,e){for(let P=0;P<16;P++,e+=4)jr[P]=t.getUint32(e),Qr[P]=t.getUint32(e+=4);for(let P=16;P<80;P++){let $=jr[P-15]|0,M=Qr[P-15]|0,z=Ae.rotrSH($,M,1)^Ae.rotrSH($,M,8)^Ae.shrSH($,M,7),L=Ae.rotrSL($,M,1)^Ae.rotrSL($,M,8)^Ae.shrSL($,M,7),K=jr[P-2]|0,we=Qr[P-2]|0,te=Ae.rotrSH(K,we,19)^Ae.rotrBH(K,we,61)^Ae.shrSH(K,we,6),W=Ae.rotrSL(K,we,19)^Ae.rotrBL(K,we,61)^Ae.shrSL(K,we,6),ve=Ae.add4L(L,W,Qr[P-7],Qr[P-16]),Ce=Ae.add4H(ve,z,te,jr[P-7],jr[P-16]);jr[P]=Ce|0,Qr[P]=ve|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:f,Dh:l,Dl:h,Eh:m,El:T,Fh:v,Fl:b,Gh:y,Gl:w,Hh:E,Hl:k}=this;for(let P=0;P<80;P++){let $=Ae.rotrSH(m,T,14)^Ae.rotrSH(m,T,18)^Ae.rotrBH(m,T,41),M=Ae.rotrSL(m,T,14)^Ae.rotrSL(m,T,18)^Ae.rotrBL(m,T,41),z=m&v^~m&y,L=T&b^~T&w,K=Ae.add5L(k,M,L,Og[P],Qr[P]),we=Ae.add5H(K,E,$,z,Rg[P],jr[P]),te=K|0,W=Ae.rotrSH(n,o,28)^Ae.rotrBH(n,o,34)^Ae.rotrBH(n,o,39),ve=Ae.rotrSL(n,o,28)^Ae.rotrBL(n,o,34)^Ae.rotrBL(n,o,39),Ce=n&s^n&c^s&c,Ve=o&i^o&f^i&f;E=y|0,k=w|0,y=v|0,w=b|0,v=m|0,b=T|0,{h:m,l:T}=Ae.add(l|0,h|0,we|0,te|0),l=c|0,h=f|0,c=s|0,f=i|0,s=n|0,i=o|0;let _=Ae.add3L(te,ve,Ve);n=Ae.add3H(_,we,W,Ce),o=_|0}({h:n,l:o}=Ae.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Ae.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:f}=Ae.add(this.Ch|0,this.Cl|0,c|0,f|0),{h:l,l:h}=Ae.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:m,l:T}=Ae.add(this.Eh|0,this.El|0,m|0,T|0),{h:v,l:b}=Ae.add(this.Fh|0,this.Fl|0,v|0,b|0),{h:y,l:w}=Ae.add(this.Gh|0,this.Gl|0,y|0,w|0),{h:E,l:k}=Ae.add(this.Hh|0,this.Hl|0,E|0,k|0),this.set(n,o,s,i,c,f,l,h,m,T,v,b,y,w,E,k)}roundClean(){jr.fill(0),Qr.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var In=Hr(()=>new Wa);function Ng(r,t,e,n){Zs(r);let o=Zu({dkLen:32,asyncTick:10},n),{c:s,dkLen:i,asyncTick:c}=o;if(Er(s),Er(i),Er(c),s<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let f=Yt(t),l=Yt(e),h=new Uint8Array(i),m=fr.create(r,f),T=m._cloneInto().update(l);return{c:s,dkLen:i,asyncTick:c,DK:h,PRF:m,PRFSalt:T}}function kg(r,t,e,n,o){return r.destroy(),t.destroy(),n&&n.destroy(),o.fill(0),e}function pf(r,t,e,n){let{c:o,dkLen:s,DK:i,PRF:c,PRFSalt:f}=Ng(r,t,e,n),l,h=new Uint8Array(4),m=ur(h),T=new Uint8Array(c.outputLen);for(let v=1,b=0;b<s;v++,b+=c.outputLen){let y=i.subarray(b,b+c.outputLen);m.setInt32(0,v,!1),(l=f._cloneInto(l)).update(h).digestInto(T),y.set(T.subarray(0,y.length));for(let w=1;w<o;w++){c._cloneInto(l).update(T).digestInto(T);for(let E=0;E<y.length;E++)y[E]^=T[E]}}return kg(c,f,i,l,T)}var zg=(r,t,e)=>r&t^~r&e,Dg=(r,t,e)=>r&t^r&e^t&e,Mg=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Wr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yr=new Uint32Array(64),Ya=class extends Vr{constructor(){super(64,32,8,!1),this.A=Wr[0]|0,this.B=Wr[1]|0,this.C=Wr[2]|0,this.D=Wr[3]|0,this.E=Wr[4]|0,this.F=Wr[5]|0,this.G=Wr[6]|0,this.H=Wr[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:f}=this;return[t,e,n,o,s,i,c,f]}set(t,e,n,o,s,i,c,f){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=f|0}process(t,e){for(let m=0;m<16;m++,e+=4)Yr[m]=t.getUint32(e,!1);for(let m=16;m<64;m++){let T=Yr[m-15],v=Yr[m-2],b=Wt(T,7)^Wt(T,18)^T>>>3,y=Wt(v,17)^Wt(v,19)^v>>>10;Yr[m]=y+Yr[m-7]+b+Yr[m-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:f,G:l,H:h}=this;for(let m=0;m<64;m++){let T=Wt(c,6)^Wt(c,11)^Wt(c,25),v=h+T+zg(c,f,l)+Mg[m]+Yr[m]|0,y=(Wt(n,2)^Wt(n,13)^Wt(n,22))+Dg(n,o,s)|0;h=l,l=f,f=c,c=i+v|0,i=s,s=o,o=n,n=v+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,f=f+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,o,s,i,c,f,l,h)}roundClean(){Yr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Wo=Hr(()=>new Ya);function gf(r){if(typeof r!="string")throw new TypeError(`Invalid mnemonic type: ${typeof r}`);return r.normalize("NFKD")}function Gg(r){let t=gf(r),e=t.split(" ");if(![12,15,18,21,24].includes(e.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:e}}var Lg=r=>gf(`mnemonic${r}`);function mf(r,t=""){return pf(In,Gg(r).nfkd,Lg(t),{c:2048,dkLen:64})}var yf=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,hf=/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,Af=(t=>(t.ED25519="ed25519 seed",t))(Af||{}),Za=2147483648;function Xa(r){return hf.test(r)}function Ja(r){return yf.test(r)}var ni=(r,t)=>{let e=fr.create(In,r).update(t).digest();return{key:e.slice(0,32),chainCode:e.slice(32)}},ec=({key:r,chainCode:t},e)=>{let n=new ArrayBuffer(4);new DataView(n).setUint32(0,e);let o=new Uint8Array(n),s=new Uint8Array([0]),i=new Uint8Array([...s,...r,...o]);return ni(t,i)},Kg=r=>r.replace("'",""),tc=r=>r.split("/").slice(1).map(Kg),Yo=r=>{let t=r.trim().split(/\s+/).map(e=>e.toLowerCase()).join(" ");return mf(t)};var Zr=class Zr extends It{constructor(e){super();let n=Be.fromHexInput(e);if(n.toUint8Array().length!==Zr.LENGTH)throw new Error(`PublicKey length should be ${Zr.LENGTH}`);this.key=n}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}verifySignature(e){let{message:n,signature:o}=e,s=Be.fromHexInput(n).toUint8Array(),i=o.toUint8Array();return Zo.default.sign.detached.verify(s,i,this.key.toUint8Array())}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let n=e.deserializeBytes();return new Zr(n)}static load(e){let n=e.deserializeBytes();return new Zr(n)}static isPublicKey(e){return e instanceof Zr}};Zr.LENGTH=32;var qe=Zr,wt=class wt extends Un{constructor(e){super();let n=Be.fromHexInput(e);if(n.toUint8Array().length!==wt.LENGTH)throw new Error(`PrivateKey length should be ${wt.LENGTH}`);this.signingKeyPair=Zo.default.sign.keyPair.fromSeed(n.toUint8Array().slice(0,wt.LENGTH))}toUint8Array(){return this.signingKeyPair.secretKey.slice(0,wt.LENGTH)}toString(){return Be.fromHexInput(this.toUint8Array()).toString()}sign(e){let n=Be.fromHexInput(e),o=Zo.default.sign.detached(n.toUint8Array(),this.signingKeyPair.secretKey);return new Je(o)}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let n=e.deserializeBytes();return new wt(n)}static generate(){let e=Zo.default.sign.keyPair();return new wt(e.secretKey.slice(0,wt.LENGTH))}publicKey(){let e=this.signingKeyPair.publicKey;return new qe(e)}static fromDerivationPath(e,n){if(!Ja(e))throw new Error(`Invalid derivation path ${e}`);return wt.fromDerivationPathInner(e,Yo(n))}static fromDerivationPathInner(e,n,o=Za){let{key:s,chainCode:i}=ni(wt.SLIP_0010_SEED,n),c=tc(e).map(l=>parseInt(l,10)),{key:f}=c.reduce((l,h)=>ec(l,h+o),{key:s,chainCode:i});return new wt(f)}static isPrivateKey(e){return e instanceof wt}};wt.LENGTH=32,wt.SLIP_0010_SEED="ed25519 seed";var Ur=wt,Xr=class Xr extends Jt{constructor(e){super();let n=Be.fromHexInput(e);if(n.toUint8Array().length!==Xr.LENGTH)throw new Error(`Signature length should be ${Xr.LENGTH}`);this.data=n}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let n=e.deserializeBytes();return new Xr(n)}static load(e){let n=e.deserializeBytes();return new Xr(n)}static isSignature(e){return e instanceof Xr}};Xr.LENGTH=64;var Je=Xr;var Lt=class Lt extends It{constructor(e){super();let{publicKeys:n,threshold:o}=e;if(n.length>Lt.MAX_KEYS||n.length<Lt.MIN_KEYS)throw new Error(`Must have between ${Lt.MIN_KEYS} and ${Lt.MAX_KEYS} public keys, inclusive`);if(o<Lt.MIN_THRESHOLD||o>n.length)throw new Error(`Threshold must be between ${Lt.MIN_THRESHOLD} and ${n.length}, inclusive`);this.publicKeys=n,this.threshold=o}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*qe.LENGTH+1);return this.publicKeys.forEach((n,o)=>{e.set(n.toUint8Array(),o*qe.LENGTH)}),e[this.publicKeys.length*qe.LENGTH]=this.threshold,e}toString(){return Be.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){throw new Error("TODO - Method not implemented.")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let n=e.deserializeBytes(),o=n[n.length-1],s=[];for(let i=0;i<n.length-1;i+=qe.LENGTH){let c=i;s.push(new qe(n.subarray(c,c+qe.LENGTH)))}return new Lt({publicKeys:s,threshold:o})}};Lt.MAX_KEYS=32,Lt.MIN_KEYS=2,Lt.MIN_THRESHOLD=1;var er=Lt,qt=class qt extends Jt{constructor(e){super();let{signatures:n,bitmap:o}=e;if(o.length!==qt.BITMAP_LEN)throw new Error(`"bitmap" length should be ${qt.BITMAP_LEN}`);if(n.length>qt.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${qt.MAX_SIGNATURES_SUPPORTED}`);this.signatures=n,this.bitmap=o}toUint8Array(){let e=new Uint8Array(this.signatures.length*Je.LENGTH+qt.BITMAP_LEN);return this.signatures.forEach((n,o)=>{e.set(n.toUint8Array(),o*Je.LENGTH)}),e.set(this.bitmap,this.signatures.length*Je.LENGTH),e}toString(){return Be.fromHexInput(this.toUint8Array()).toString()}static createBitmap(e){let{bits:n}=e,o=128,s=new Uint8Array([0,0,0,0]),i=new Set;return n.forEach(c=>{if(c>=qt.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${qt.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(c))throw new Error("Duplicate bits detected.");i.add(c);let f=Math.floor(c/8),l=s[f];l|=o>>c%8,s[f]=l}),s}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let n=e.deserializeBytes(),o=n.subarray(n.length-4),s=[];for(let i=0;i<n.length-o.length;i+=Je.LENGTH){let c=i;s.push(new Je(n.subarray(c,c+Je.LENGTH)))}return new qt({signatures:s,bitmap:o})}};qt.MAX_SIGNATURES_SUPPORTED=32,qt.BITMAP_LEN=4;var Bn=qt;function xf(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function rc(r,...t){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function bf(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");xf(r.outputLen),xf(r.blockLen)}function fo(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function wf(r,t){rc(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var oi=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Tf=r=>r instanceof Uint8Array;var si=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),tr=(r,t)=>r<<32-t|r>>>t,Hg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Hg)throw new Error("Non little-endian hardware is not supported");function Fg(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Xo(r){if(typeof r=="string"&&(r=Fg(r)),!Tf(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function _f(...r){let t=new Uint8Array(r.reduce((n,o)=>n+o.length,0)),e=0;return r.forEach(n=>{if(!Tf(n))throw new Error("Uint8Array expected");t.set(n,e),e+=n.length}),t}var lo=class{clone(){return this._cloneInto()}},dx={}.toString;function Sf(r){let t=n=>r().update(Xo(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Ef(r=32){if(oi&&typeof oi.getRandomValues=="function")return oi.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function $g(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),f=n?4:0,l=n?0:4;r.setUint32(t+f,i,n),r.setUint32(t+l,c,n)}var ii=class extends lo{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=si(this.buffer)}update(t){fo(this);let{view:e,buffer:n,blockLen:o}=this;t=Xo(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let f=si(t);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){fo(this),wf(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let m=i;m<o;m++)e[m]=0;$g(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=si(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=f/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<l;m++)c.setUint32(4*m,h[m],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var Vg=(r,t,e)=>r&t^~r&e,jg=(r,t,e)=>r&t^r&e^t&e,Qg=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Jr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),en=new Uint32Array(64),nc=class extends ii{constructor(){super(64,32,8,!1),this.A=Jr[0]|0,this.B=Jr[1]|0,this.C=Jr[2]|0,this.D=Jr[3]|0,this.E=Jr[4]|0,this.F=Jr[5]|0,this.G=Jr[6]|0,this.H=Jr[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:f}=this;return[t,e,n,o,s,i,c,f]}set(t,e,n,o,s,i,c,f){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=f|0}process(t,e){for(let m=0;m<16;m++,e+=4)en[m]=t.getUint32(e,!1);for(let m=16;m<64;m++){let T=en[m-15],v=en[m-2],b=tr(T,7)^tr(T,18)^T>>>3,y=tr(v,17)^tr(v,19)^v>>>10;en[m]=y+en[m-7]+b+en[m-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:f,G:l,H:h}=this;for(let m=0;m<64;m++){let T=tr(c,6)^tr(c,11)^tr(c,25),v=h+T+Vg(c,f,l)+Qg[m]+en[m]|0,y=(tr(n,2)^tr(n,13)^tr(n,22))+jg(n,o,s)|0;h=l,l=f,f=c,c=i+v|0,i=s,s=o,o=n,n=v+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,f=f+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,o,s,i,c,f,l,h)}roundClean(){en.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var vf=Sf(()=>new nc);var ac={};Gs(ac,{bitGet:()=>tm,bitLen:()=>em,bitMask:()=>Jo,bitSet:()=>rm,bytesToHex:()=>Pn,bytesToNumberBE:()=>Ir,bytesToNumberLE:()=>ui,concatBytes:()=>po,createHmacDrbg:()=>ic,ensureBytes:()=>Bt,equalBytes:()=>Xg,hexToBytes:()=>Rn,hexToNumber:()=>sc,numberToBytesBE:()=>tn,numberToBytesLE:()=>fi,numberToHexUnpadded:()=>If,numberToVarBytesBE:()=>Zg,utf8ToBytes:()=>Jg,validateObject:()=>rn});var Uf=BigInt(0),ai=BigInt(1),Wg=BigInt(2),ci=r=>r instanceof Uint8Array,Yg=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Pn(r){if(!ci(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=Yg[r[e]];return t}function If(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function sc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Rn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let e=new Uint8Array(t/2);for(let n=0;n<e.length;n++){let o=n*2,s=r.slice(o,o+2),i=Number.parseInt(s,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");e[n]=i}return e}function Ir(r){return sc(Pn(r))}function ui(r){if(!ci(r))throw new Error("Uint8Array expected");return sc(Pn(Uint8Array.from(r).reverse()))}function tn(r,t){return Rn(r.toString(16).padStart(t*2,"0"))}function fi(r,t){return tn(r,t).reverse()}function Zg(r){return Rn(If(r))}function Bt(r,t,e){let n;if(typeof t=="string")try{n=Rn(t)}catch(s){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${s}`)}else if(ci(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(`${r} expected ${e} bytes, got ${o}`);return n}function po(...r){let t=new Uint8Array(r.reduce((n,o)=>n+o.length,0)),e=0;return r.forEach(n=>{if(!ci(n))throw new Error("Uint8Array expected");t.set(n,e),e+=n.length}),t}function Xg(r,t){if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}function Jg(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function em(r){let t;for(t=0;r>Uf;r>>=ai,t+=1);return t}function tm(r,t){return r>>BigInt(t)&ai}var rm=(r,t,e)=>r|(e?ai:Uf)<<BigInt(t),Jo=r=>(Wg<<BigInt(r-1))-ai,oc=r=>new Uint8Array(r),Cf=r=>Uint8Array.from(r);function ic(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=oc(r),o=oc(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...m)=>e(o,n,...m),f=(m=oc())=>{o=c(Cf([0]),m),n=c(),m.length!==0&&(o=c(Cf([1]),m),n=c())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let m=0,T=[];for(;m<t;){n=c();let v=n.slice();T.push(v),m+=n.length}return po(...T)};return(m,T)=>{i(),f(m);let v;for(;!(v=T(l()));)f();return i(),v}}var nm={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||r instanceof Uint8Array,isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function rn(r,t,e={}){let n=(o,s,i)=>{let c=nm[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let f=r[o];if(!(i&&f===void 0)&&!c(f,r))throw new Error(`Invalid param ${String(o)}=${f} (${typeof f}), expected ${s}`)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var ct=BigInt(0),et=BigInt(1),On=BigInt(2),om=BigInt(3),cc=BigInt(4),Bf=BigInt(5),Pf=BigInt(8),sm=BigInt(9),im=BigInt(16);function At(r,t){let e=r%t;return e>=ct?e:t+e}function am(r,t,e){if(e<=ct||t<ct)throw new Error("Expected power/modulo > 0");if(e===et)return ct;let n=et;for(;t>ct;)t&et&&(n=n*r%e),r=r*r%e,t>>=et;return n}function Pt(r,t,e){let n=r;for(;t-- >ct;)n*=n,n%=e;return n}function di(r,t){if(r===ct||t<=ct)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=At(r,t),n=t,o=ct,s=et,i=et,c=ct;for(;e!==ct;){let l=n/e,h=n%e,m=o-i*l,T=s-c*l;n=e,e=h,o=i,s=c,i=m,c=T}if(n!==et)throw new Error("invert: does not exist");return At(o,t)}function cm(r){let t=(r-et)/On,e,n,o;for(e=r-et,n=0;e%On===ct;e/=On,n++);for(o=On;o<r&&am(o,t,r)!==r-et;o++);if(n===1){let i=(r+et)/cc;return function(f,l){let h=f.pow(l,i);if(!f.eql(f.sqr(h),l))throw new Error("Cannot find square root");return h}}let s=(e+et)/On;return function(c,f){if(c.pow(f,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=n,h=c.pow(c.mul(c.ONE,o),e),m=c.pow(f,s),T=c.pow(f,e);for(;!c.eql(T,c.ONE);){if(c.eql(T,c.ZERO))return c.ZERO;let v=1;for(let y=c.sqr(T);v<l&&!c.eql(y,c.ONE);v++)y=c.sqr(y);let b=c.pow(h,et<<BigInt(l-v-1));h=c.sqr(b),m=c.mul(m,b),T=c.mul(T,h),l=v}return m}}function um(r){if(r%cc===om){let t=(r+et)/cc;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Pf===Bf){let t=(r-Bf)/Pf;return function(n,o){let s=n.mul(o,On),i=n.pow(s,t),c=n.mul(o,i),f=n.mul(n.mul(c,On),i),l=n.mul(c,n.sub(f,n.ONE));if(!n.eql(n.sqr(l),o))throw new Error("Cannot find square root");return l}}return r%im,cm(r)}var fm=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function uc(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=fm.reduce((n,o)=>(n[o]="function",n),t);return rn(r,e)}function dm(r,t,e){if(e<ct)throw new Error("Expected power > 0");if(e===ct)return r.ONE;if(e===et)return t;let n=r.ONE,o=t;for(;e>ct;)e&et&&(n=r.mul(n,o)),o=r.sqr(o),e>>=et;return n}function lm(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function fc(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Rf(r,t,e=!1,n={}){if(r<=ct)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:s}=fc(r,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=um(r),c=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:Jo(o),ZERO:ct,ONE:et,create:f=>At(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof f}`);return ct<=f&&f<r},is0:f=>f===ct,isOdd:f=>(f&et)===et,neg:f=>At(-f,r),eql:(f,l)=>f===l,sqr:f=>At(f*f,r),add:(f,l)=>At(f+l,r),sub:(f,l)=>At(f-l,r),mul:(f,l)=>At(f*l,r),pow:(f,l)=>dm(c,f,l),div:(f,l)=>At(f*di(l,r),r),sqrN:f=>f*f,addN:(f,l)=>f+l,subN:(f,l)=>f-l,mulN:(f,l)=>f*l,inv:f=>di(f,r),sqrt:n.sqrt||(f=>i(c,f)),invertBatch:f=>lm(c,f),cmov:(f,l,h)=>h?l:f,toBytes:f=>e?fi(f,s):tn(f,s),fromBytes:f=>{if(f.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${f.length}`);return e?ui(f):Ir(f)}});return Object.freeze(c)}function Of(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function dc(r){let t=Of(r);return t+Math.ceil(t/2)}function Nf(r,t,e=!1){let n=r.length,o=Of(t),s=dc(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=e?Ir(r):ui(r),c=At(i,t-et)+et;return e?fi(c,o):tn(c,o)}var gm=BigInt(0),lc=BigInt(1);function kf(r,t){let e=(o,s)=>{let i=s.negate();return o?i:s},n=o=>{let s=Math.ceil(t/o)+1,i=2**(o-1);return{windows:s,windowSize:i}};return{constTimeNegate:e,unsafeLadder(o,s){let i=r.ZERO,c=o;for(;s>gm;)s&lc&&(i=i.add(c)),c=c.double(),s>>=lc;return i},precomputeWindow(o,s){let{windows:i,windowSize:c}=n(s),f=[],l=o,h=l;for(let m=0;m<i;m++){h=l,f.push(h);for(let T=1;T<c;T++)h=h.add(l),f.push(h);l=h.double()}return f},wNAF(o,s,i){let{windows:c,windowSize:f}=n(o),l=r.ZERO,h=r.BASE,m=BigInt(2**o-1),T=2**o,v=BigInt(o);for(let b=0;b<c;b++){let y=b*f,w=Number(i&m);i>>=v,w>f&&(w-=T,i+=lc);let E=y,k=y+Math.abs(w)-1,P=b%2!==0,$=w<0;w===0?h=h.add(e(P,s[E])):l=l.add(e($,s[k]))}return{p:l,f:h}},wNAFCached(o,s,i,c){let f=o._WINDOW_SIZE||1,l=s.get(o);return l||(l=this.precomputeWindow(o,f),f!==1&&s.set(o,c(l))),this.wNAF(f,l,i)}}}function pc(r){return uc(r.Fp),rn(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...fc(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function mm(r){let t=pc(r);rn(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:ym,hexToBytes:hm}=ac,Nn={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(r){let{Err:t}=Nn;if(r.length<2||r[0]!==2)throw new t("Invalid signature integer tag");let e=r[1],n=r.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:ym(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=Nn,e=typeof r=="string"?hm(r):r;if(!(e instanceof Uint8Array))throw new Error("ui8a expected");let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");let{d:o,l:s}=Nn._parseInt(e.subarray(2)),{d:i,l:c}=Nn._parseInt(s);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s:i}},hexFromSig(r){let t=l=>Number.parseInt(l[0],16)&8?"00"+l:l,e=l=>{let h=l.toString(16);return h.length&1?`0${h}`:h},n=t(e(r.s)),o=t(e(r.r)),s=n.length/2,i=o.length/2,c=e(s),f=e(i);return`30${e(i+s+4)}02${f}${o}02${c}${n}`}},Br=BigInt(0),Kt=BigInt(1),vx=BigInt(2),zf=BigInt(3),Cx=BigInt(4);function Am(r){let t=mm(r),{Fp:e}=t,n=t.toBytes||((b,y,w)=>{let E=y.toAffine();return po(Uint8Array.from([4]),e.toBytes(E.x),e.toBytes(E.y))}),o=t.fromBytes||(b=>{let y=b.subarray(1),w=e.fromBytes(y.subarray(0,e.BYTES)),E=e.fromBytes(y.subarray(e.BYTES,2*e.BYTES));return{x:w,y:E}});function s(b){let{a:y,b:w}=t,E=e.sqr(b),k=e.mul(E,b);return e.add(e.add(k,e.mul(b,y)),w)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function i(b){return typeof b=="bigint"&&Br<b&&b<t.n}function c(b){if(!i(b))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function f(b){let{allowedPrivateKeyLengths:y,nByteLength:w,wrapPrivateKey:E,n:k}=t;if(y&&typeof b!="bigint"){if(b instanceof Uint8Array&&(b=Pn(b)),typeof b!="string"||!y.includes(b.length))throw new Error("Invalid key");b=b.padStart(w*2,"0")}let P;try{P=typeof b=="bigint"?b:Ir(Bt("private key",b,w))}catch{throw new Error(`private key must be ${w} bytes, hex or bigint, not ${typeof b}`)}return E&&(P=At(P,k)),c(P),P}let l=new Map;function h(b){if(!(b instanceof m))throw new Error("ProjectivePoint expected")}class m{constructor(y,w,E){if(this.px=y,this.py=w,this.pz=E,y==null||!e.isValid(y))throw new Error("x required");if(w==null||!e.isValid(w))throw new Error("y required");if(E==null||!e.isValid(E))throw new Error("z required")}static fromAffine(y){let{x:w,y:E}=y||{};if(!y||!e.isValid(w)||!e.isValid(E))throw new Error("invalid affine point");if(y instanceof m)throw new Error("projective point not allowed");let k=P=>e.eql(P,e.ZERO);return k(w)&&k(E)?m.ZERO:new m(w,E,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(y){let w=e.invertBatch(y.map(E=>E.pz));return y.map((E,k)=>E.toAffine(w[k])).map(m.fromAffine)}static fromHex(y){let w=m.fromAffine(o(Bt("pointHex",y)));return w.assertValidity(),w}static fromPrivateKey(y){return m.BASE.multiply(f(y))}_setWindowSize(y){this._WINDOW_SIZE=y,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:y,y:w}=this.toAffine();if(!e.isValid(y)||!e.isValid(w))throw new Error("bad point: x or y not FE");let E=e.sqr(w),k=s(y);if(!e.eql(E,k))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y}=this.toAffine();if(e.isOdd)return!e.isOdd(y);throw new Error("Field doesn't support isOdd")}equals(y){h(y);let{px:w,py:E,pz:k}=this,{px:P,py:$,pz:M}=y,z=e.eql(e.mul(w,M),e.mul(P,k)),L=e.eql(e.mul(E,M),e.mul($,k));return z&&L}negate(){return new m(this.px,e.neg(this.py),this.pz)}double(){let{a:y,b:w}=t,E=e.mul(w,zf),{px:k,py:P,pz:$}=this,M=e.ZERO,z=e.ZERO,L=e.ZERO,K=e.mul(k,k),we=e.mul(P,P),te=e.mul($,$),W=e.mul(k,P);return W=e.add(W,W),L=e.mul(k,$),L=e.add(L,L),M=e.mul(y,L),z=e.mul(E,te),z=e.add(M,z),M=e.sub(we,z),z=e.add(we,z),z=e.mul(M,z),M=e.mul(W,M),L=e.mul(E,L),te=e.mul(y,te),W=e.sub(K,te),W=e.mul(y,W),W=e.add(W,L),L=e.add(K,K),K=e.add(L,K),K=e.add(K,te),K=e.mul(K,W),z=e.add(z,K),te=e.mul(P,$),te=e.add(te,te),K=e.mul(te,W),M=e.sub(M,K),L=e.mul(te,we),L=e.add(L,L),L=e.add(L,L),new m(M,z,L)}add(y){h(y);let{px:w,py:E,pz:k}=this,{px:P,py:$,pz:M}=y,z=e.ZERO,L=e.ZERO,K=e.ZERO,we=t.a,te=e.mul(t.b,zf),W=e.mul(w,P),ve=e.mul(E,$),Ce=e.mul(k,M),Ve=e.add(w,E),_=e.add(P,$);Ve=e.mul(Ve,_),_=e.add(W,ve),Ve=e.sub(Ve,_),_=e.add(w,k);let B=e.add(P,M);return _=e.mul(_,B),B=e.add(W,Ce),_=e.sub(_,B),B=e.add(E,k),z=e.add($,M),B=e.mul(B,z),z=e.add(ve,Ce),B=e.sub(B,z),K=e.mul(we,_),z=e.mul(te,Ce),K=e.add(z,K),z=e.sub(ve,K),K=e.add(ve,K),L=e.mul(z,K),ve=e.add(W,W),ve=e.add(ve,W),Ce=e.mul(we,Ce),_=e.mul(te,_),ve=e.add(ve,Ce),Ce=e.sub(W,Ce),Ce=e.mul(we,Ce),_=e.add(_,Ce),W=e.mul(ve,_),L=e.add(L,W),W=e.mul(B,_),z=e.mul(Ve,z),z=e.sub(z,W),W=e.mul(Ve,ve),K=e.mul(B,K),K=e.add(K,W),new m(z,L,K)}subtract(y){return this.add(y.negate())}is0(){return this.equals(m.ZERO)}wNAF(y){return v.wNAFCached(this,l,y,w=>{let E=e.invertBatch(w.map(k=>k.pz));return w.map((k,P)=>k.toAffine(E[P])).map(m.fromAffine)})}multiplyUnsafe(y){let w=m.ZERO;if(y===Br)return w;if(c(y),y===Kt)return this;let{endo:E}=t;if(!E)return v.unsafeLadder(this,y);let{k1neg:k,k1:P,k2neg:$,k2:M}=E.splitScalar(y),z=w,L=w,K=this;for(;P>Br||M>Br;)P&Kt&&(z=z.add(K)),M&Kt&&(L=L.add(K)),K=K.double(),P>>=Kt,M>>=Kt;return k&&(z=z.negate()),$&&(L=L.negate()),L=new m(e.mul(L.px,E.beta),L.py,L.pz),z.add(L)}multiply(y){c(y);let w=y,E,k,{endo:P}=t;if(P){let{k1neg:$,k1:M,k2neg:z,k2:L}=P.splitScalar(w),{p:K,f:we}=this.wNAF(M),{p:te,f:W}=this.wNAF(L);K=v.constTimeNegate($,K),te=v.constTimeNegate(z,te),te=new m(e.mul(te.px,P.beta),te.py,te.pz),E=K.add(te),k=we.add(W)}else{let{p:$,f:M}=this.wNAF(w);E=$,k=M}return m.normalizeZ([E,k])[0]}multiplyAndAddUnsafe(y,w,E){let k=m.BASE,P=(M,z)=>z===Br||z===Kt||!M.equals(k)?M.multiplyUnsafe(z):M.multiply(z),$=P(this,w).add(P(y,E));return $.is0()?void 0:$}toAffine(y){let{px:w,py:E,pz:k}=this,P=this.is0();y==null&&(y=P?e.ONE:e.inv(k));let $=e.mul(w,y),M=e.mul(E,y),z=e.mul(k,y);if(P)return{x:e.ZERO,y:e.ZERO};if(!e.eql(z,e.ONE))throw new Error("invZ was invalid");return{x:$,y:M}}isTorsionFree(){let{h:y,isTorsionFree:w}=t;if(y===Kt)return!0;if(w)return w(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:y,clearCofactor:w}=t;return y===Kt?this:w?w(m,this):this.multiplyUnsafe(t.h)}toRawBytes(y=!0){return this.assertValidity(),n(m,this,y)}toHex(y=!0){return Pn(this.toRawBytes(y))}}m.BASE=new m(t.Gx,t.Gy,e.ONE),m.ZERO=new m(e.ZERO,e.ONE,e.ZERO);let T=t.nBitLength,v=kf(m,t.endo?Math.ceil(T/2):T);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:f,weierstrassEquation:s,isWithinCurveOrder:i}}function xm(r){let t=pc(r);return rn(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Df(r){let t=xm(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(_){return Br<_&&_<e.ORDER}function c(_){return At(_,n)}function f(_){return di(_,n)}let{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:m,isWithinCurveOrder:T}=Am({...t,toBytes(_,B,F){let re=B.toAffine(),ne=e.toBytes(re.x),xe=po;return F?xe(Uint8Array.from([B.hasEvenY()?2:3]),ne):xe(Uint8Array.from([4]),ne,e.toBytes(re.y))},fromBytes(_){let B=_.length,F=_[0],re=_.subarray(1);if(B===o&&(F===2||F===3)){let ne=Ir(re);if(!i(ne))throw new Error("Point is not on curve");let xe=m(ne),ke=e.sqrt(xe),Te=(ke&Kt)===Kt;return(F&1)===1!==Te&&(ke=e.neg(ke)),{x:ne,y:ke}}else if(B===s&&F===4){let ne=e.fromBytes(re.subarray(0,e.BYTES)),xe=e.fromBytes(re.subarray(e.BYTES,2*e.BYTES));return{x:ne,y:xe}}else throw new Error(`Point of length ${B} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),v=_=>Pn(tn(_,t.nByteLength));function b(_){let B=n>>Kt;return _>B}function y(_){return b(_)?c(-_):_}let w=(_,B,F)=>Ir(_.slice(B,F));class E{constructor(B,F,re){this.r=B,this.s=F,this.recovery=re,this.assertValidity()}static fromCompact(B){let F=t.nByteLength;return B=Bt("compactSignature",B,F*2),new E(w(B,0,F),w(B,F,2*F))}static fromDER(B){let{r:F,s:re}=Nn.toSig(Bt("DER",B));return new E(F,re)}assertValidity(){if(!T(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!T(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(B){return new E(this.r,this.s,B)}recoverPublicKey(B){let{r:F,s:re,recovery:ne}=this,xe=L(Bt("msgHash",B));if(ne==null||![0,1,2,3].includes(ne))throw new Error("recovery id invalid");let ke=ne===2||ne===3?F+t.n:F;if(ke>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let Te=ne&1?"03":"02",De=l.fromHex(Te+v(ke)),se=f(ke),Ke=c(-xe*se),St=c(re*se),ot=l.BASE.multiplyAndAddUnsafe(De,Ke,St);if(!ot)throw new Error("point at infinify");return ot.assertValidity(),ot}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new E(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Rn(this.toDERHex())}toDERHex(){return Nn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Rn(this.toCompactHex())}toCompactHex(){return v(this.r)+v(this.s)}}let k={isValidPrivateKey(_){try{return h(_),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{let _=dc(t.n);return Nf(t.randomBytes(_),t.n)},precompute(_=8,B=l.BASE){return B._setWindowSize(_),B.multiply(BigInt(3)),B}};function P(_,B=!0){return l.fromPrivateKey(_).toRawBytes(B)}function $(_){let B=_ instanceof Uint8Array,F=typeof _=="string",re=(B||F)&&_.length;return B?re===o||re===s:F?re===2*o||re===2*s:_ instanceof l}function M(_,B,F=!0){if($(_))throw new Error("first arg must be private key");if(!$(B))throw new Error("second arg must be public key");return l.fromHex(B).multiply(h(_)).toRawBytes(F)}let z=t.bits2int||function(_){let B=Ir(_),F=_.length*8-t.nBitLength;return F>0?B>>BigInt(F):B},L=t.bits2int_modN||function(_){return c(z(_))},K=Jo(t.nBitLength);function we(_){if(typeof _!="bigint")throw new Error("bigint expected");if(!(Br<=_&&_<K))throw new Error(`bigint expected < 2^${t.nBitLength}`);return tn(_,t.nByteLength)}function te(_,B,F=W){if(["recovered","canonical"].some(st=>st in F))throw new Error("sign() legacy options not supported");let{hash:re,randomBytes:ne}=t,{lowS:xe,prehash:ke,extraEntropy:Te}=F;xe==null&&(xe=!0),_=Bt("msgHash",_),ke&&(_=Bt("prehashed msgHash",re(_)));let De=L(_),se=h(B),Ke=[we(se),we(De)];if(Te!=null){let st=Te===!0?ne(e.BYTES):Te;Ke.push(Bt("extraEntropy",st))}let St=po(...Ke),ot=De;function kt(st){let pt=z(st);if(!T(pt))return;let ar=f(pt),Fe=l.BASE.multiply(pt).toAffine(),xt=c(Fe.x);if(xt===Br)return;let Qt=c(ar*c(ot+xt*se));if(Qt===Br)return;let hn=(Fe.x===xt?0:2)|Number(Fe.y&Kt),qr=Qt;return xe&&b(Qt)&&(qr=y(Qt),hn^=1),new E(xt,qr,hn)}return{seed:St,k2sig:kt}}let W={lowS:t.lowS,prehash:!1},ve={lowS:t.lowS,prehash:!1};function Ce(_,B,F=W){let{seed:re,k2sig:ne}=te(_,B,F),xe=t;return ic(xe.hash.outputLen,xe.nByteLength,xe.hmac)(re,ne)}l.BASE._setWindowSize(8);function Ve(_,B,F,re=ve){let ne=_;if(B=Bt("msgHash",B),F=Bt("publicKey",F),"strict"in re)throw new Error("options.strict was renamed to lowS");let{lowS:xe,prehash:ke}=re,Te,De;try{if(typeof ne=="string"||ne instanceof Uint8Array)try{Te=E.fromDER(ne)}catch(Fe){if(!(Fe instanceof Nn.Err))throw Fe;Te=E.fromCompact(ne)}else if(typeof ne=="object"&&typeof ne.r=="bigint"&&typeof ne.s=="bigint"){let{r:Fe,s:xt}=ne;Te=new E(Fe,xt)}else throw new Error("PARSE");De=l.fromHex(F)}catch(Fe){if(Fe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(xe&&Te.hasHighS())return!1;ke&&(B=t.hash(B));let{r:se,s:Ke}=Te,St=L(B),ot=f(Ke),kt=c(St*ot),st=c(se*ot),pt=l.BASE.multiplyAndAddUnsafe(De,kt,st)?.toAffine();return pt?c(pt.x)===se:!1}return{CURVE:t,getPublicKey:P,getSharedSecret:M,sign:Ce,verify:Ve,ProjectivePoint:l,Signature:E,utils:k}}var li=class extends lo{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,bf(t);let n=Xo(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return fo(this),this.iHash.update(t),this}digestInto(t){fo(this),rc(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),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:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},gc=(r,t,e)=>new li(r,t).update(e).digest();gc.create=(r,t)=>new li(r,t);function bm(r){return{hash:r,hmac:(t,...e)=>gc(r,t,_f(...e)),randomBytes:Ef}}function Mf(r,t){let e=n=>Df({...r,...bm(n)});return Object.freeze({...e(t),create:e})}var qf=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Gf=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),wm=BigInt(1),mc=BigInt(2),Lf=(r,t)=>(r+t/mc)/t;function Tm(r){let t=qf,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),f=BigInt(88),l=r*r*r%t,h=l*l*r%t,m=Pt(h,e,t)*h%t,T=Pt(m,e,t)*h%t,v=Pt(T,mc,t)*l%t,b=Pt(v,o,t)*v%t,y=Pt(b,s,t)*b%t,w=Pt(y,c,t)*y%t,E=Pt(w,f,t)*w%t,k=Pt(E,c,t)*y%t,P=Pt(k,e,t)*h%t,$=Pt(P,i,t)*b%t,M=Pt($,n,t)*l%t,z=Pt(M,mc,t);if(!yc.eql(yc.sqr(z),r))throw new Error("Cannot find square root");return z}var yc=Rf(qf,void 0,void 0,{sqrt:Tm}),go=Mf({a:BigInt(0),b:BigInt(7),Fp:yc,n:Gf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Gf,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-wm*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=Lf(s*r,t),f=Lf(-n*r,t),l=At(r-c*e-f*o,t),h=At(-c*n-f*s,t),m=l>i,T=h>i;if(m&&(l=t-l),T&&(h=t-h),l>i||h>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:m,k1:l,k2neg:T,k2:h}}}},vf),Gx=BigInt(0);var Lx=go.ProjectivePoint;var _m=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Hf=Uint8Array.from({length:16},(r,t)=>t),Sm=Hf.map(r=>(9*r+5)%16),Ac=[Hf],xc=[Sm];for(let r=0;r<4;r++)for(let t of[Ac,xc])t.push(t[r].map(e=>_m[e]));var Ff=[[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(r=>new Uint8Array(r)),Em=Ac.map((r,t)=>r.map(e=>Ff[t][e])),vm=xc.map((r,t)=>r.map(e=>Ff[t][e])),Cm=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Um=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),pi=(r,t)=>r<<t|r>>>32-t;function Kf(r,t,e,n){return r===0?t^e^n:r===1?t&e|~t&n:r===2?(t|~e)^n:r===3?t&n|e&~n:t^(e|~n)}var gi=new Uint32Array(16),hc=class extends Vr{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){let{h0:t,h1:e,h2:n,h3:o,h4:s}=this;return[t,e,n,o,s]}set(t,e,n,o,s){this.h0=t|0,this.h1=e|0,this.h2=n|0,this.h3=o|0,this.h4=s|0}process(t,e){for(let v=0;v<16;v++,e+=4)gi[v]=t.getUint32(e,!0);let n=this.h0|0,o=n,s=this.h1|0,i=s,c=this.h2|0,f=c,l=this.h3|0,h=l,m=this.h4|0,T=m;for(let v=0;v<5;v++){let b=4-v,y=Cm[v],w=Um[v],E=Ac[v],k=xc[v],P=Em[v],$=vm[v];for(let M=0;M<16;M++){let z=pi(n+Kf(v,s,c,l)+gi[E[M]]+y,P[M])+m|0;n=m,m=l,l=pi(c,10)|0,c=s,s=z}for(let M=0;M<16;M++){let z=pi(o+Kf(b,i,f,h)+gi[k[M]]+w,$[M])+T|0;o=T,T=h,h=pi(f,10)|0,f=i,i=z}}this.set(this.h1+c+h|0,this.h2+l+T|0,this.h3+m+o|0,this.h4+n+i|0,this.h0+s+f|0)}roundClean(){gi.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}},$f=Hr(()=>new hc);var _c={};Gs(_c,{bitGet:()=>km,bitLen:()=>Nm,bitMask:()=>es,bitSet:()=>zm,bytesToHex:()=>kn,bytesToNumberBE:()=>Rr,bytesToNumberLE:()=>yi,concatBytes:()=>mo,createHmacDrbg:()=>Tc,ensureBytes:()=>Rt,equalBytes:()=>Rm,hexToBytes:()=>zn,hexToNumber:()=>wc,isBytes:()=>rr,numberToBytesBE:()=>nn,numberToBytesLE:()=>hi,numberToHexUnpadded:()=>Wf,numberToVarBytesBE:()=>Pm,utf8ToBytes:()=>Om,validateObject:()=>on});var Qf=BigInt(0),mi=BigInt(1),Im=BigInt(2);function rr(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Bm=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function kn(r){if(!rr(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=Bm[r[e]];return t}function Wf(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function wc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Pr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Vf(r){if(r>=Pr._0&&r<=Pr._9)return r-Pr._0;if(r>=Pr._A&&r<=Pr._F)return r-(Pr._A-10);if(r>=Pr._a&&r<=Pr._f)return r-(Pr._a-10)}function zn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=Vf(r.charCodeAt(s)),c=Vf(r.charCodeAt(s+1));if(i===void 0||c===void 0){let f=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+c}return n}function Rr(r){return wc(kn(r))}function yi(r){if(!rr(r))throw new Error("Uint8Array expected");return wc(kn(Uint8Array.from(r).reverse()))}function nn(r,t){return zn(r.toString(16).padStart(t*2,"0"))}function hi(r,t){return nn(r,t).reverse()}function Pm(r){return zn(Wf(r))}function Rt(r,t,e){let n;if(typeof t=="string")try{n=zn(t)}catch(s){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${s}`)}else if(rr(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(`${r} expected ${e} bytes, got ${o}`);return n}function mo(...r){let t=0;for(let o=0;o<r.length;o++){let s=r[o];if(!rr(s))throw new Error("Uint8Array expected");t+=s.length}let e=new Uint8Array(t),n=0;for(let o=0;o<r.length;o++){let s=r[o];e.set(s,n),n+=s.length}return e}function Rm(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Om(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Nm(r){let t;for(t=0;r>Qf;r>>=mi,t+=1);return t}function km(r,t){return r>>BigInt(t)&mi}var zm=(r,t,e)=>r|(e?mi:Qf)<<BigInt(t),es=r=>(Im<<BigInt(r-1))-mi,bc=r=>new Uint8Array(r),jf=r=>Uint8Array.from(r);function Tc(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=bc(r),o=bc(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...m)=>e(o,n,...m),f=(m=bc())=>{o=c(jf([0]),m),n=c(),m.length!==0&&(o=c(jf([1]),m),n=c())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let m=0,T=[];for(;m<t;){n=c();let v=n.slice();T.push(v),m+=n.length}return mo(...T)};return(m,T)=>{i(),f(m);let v;for(;!(v=T(l()));)f();return i(),v}}var Dm={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||rr(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function on(r,t,e={}){let n=(o,s,i)=>{let c=Dm[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let f=r[o];if(!(i&&f===void 0)&&!c(f,r))throw new Error(`Invalid param ${String(o)}=${f} (${typeof f}), expected ${s}`)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var ut=BigInt(0),tt=BigInt(1),Dn=BigInt(2),Mm=BigInt(3),Sc=BigInt(4),Yf=BigInt(5),Zf=BigInt(8),Gm=BigInt(9),Lm=BigInt(16);function dt(r,t){let e=r%t;return e>=ut?e:t+e}function qm(r,t,e){if(e<=ut||t<ut)throw new Error("Expected power/modulo > 0");if(e===tt)return ut;let n=tt;for(;t>ut;)t&tt&&(n=n*r%e),r=r*r%e,t>>=tt;return n}function Ot(r,t,e){let n=r;for(;t-- >ut;)n*=n,n%=e;return n}function Ai(r,t){if(r===ut||t<=ut)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=dt(r,t),n=t,o=ut,s=tt,i=tt,c=ut;for(;e!==ut;){let l=n/e,h=n%e,m=o-i*l,T=s-c*l;n=e,e=h,o=i,s=c,i=m,c=T}if(n!==tt)throw new Error("invert: does not exist");return dt(o,t)}function Km(r){let t=(r-tt)/Dn,e,n,o;for(e=r-tt,n=0;e%Dn===ut;e/=Dn,n++);for(o=Dn;o<r&&qm(o,t,r)!==r-tt;o++);if(n===1){let i=(r+tt)/Sc;return function(f,l){let h=f.pow(l,i);if(!f.eql(f.sqr(h),l))throw new Error("Cannot find square root");return h}}let s=(e+tt)/Dn;return function(c,f){if(c.pow(f,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=n,h=c.pow(c.mul(c.ONE,o),e),m=c.pow(f,s),T=c.pow(f,e);for(;!c.eql(T,c.ONE);){if(c.eql(T,c.ZERO))return c.ZERO;let v=1;for(let y=c.sqr(T);v<l&&!c.eql(y,c.ONE);v++)y=c.sqr(y);let b=c.pow(h,tt<<BigInt(l-v-1));h=c.sqr(b),m=c.mul(m,b),T=c.mul(T,h),l=v}return m}}function Hm(r){if(r%Sc===Mm){let t=(r+tt)/Sc;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Zf===Yf){let t=(r-Yf)/Zf;return function(n,o){let s=n.mul(o,Dn),i=n.pow(s,t),c=n.mul(o,i),f=n.mul(n.mul(c,Dn),i),l=n.mul(c,n.sub(f,n.ONE));if(!n.eql(n.sqr(l),o))throw new Error("Cannot find square root");return l}}return r%Lm,Km(r)}var Fm=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ec(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Fm.reduce((n,o)=>(n[o]="function",n),t);return on(r,e)}function $m(r,t,e){if(e<ut)throw new Error("Expected power > 0");if(e===ut)return r.ONE;if(e===tt)return t;let n=r.ONE,o=t;for(;e>ut;)e&tt&&(n=r.mul(n,o)),o=r.sqr(o),e>>=tt;return n}function Vm(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function vc(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Xf(r,t,e=!1,n={}){if(r<=ut)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:s}=vc(r,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Hm(r),c=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:es(o),ZERO:ut,ONE:tt,create:f=>dt(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof f}`);return ut<=f&&f<r},is0:f=>f===ut,isOdd:f=>(f&tt)===tt,neg:f=>dt(-f,r),eql:(f,l)=>f===l,sqr:f=>dt(f*f,r),add:(f,l)=>dt(f+l,r),sub:(f,l)=>dt(f-l,r),mul:(f,l)=>dt(f*l,r),pow:(f,l)=>$m(c,f,l),div:(f,l)=>dt(f*Ai(l,r),r),sqrN:f=>f*f,addN:(f,l)=>f+l,subN:(f,l)=>f-l,mulN:(f,l)=>f*l,inv:f=>Ai(f,r),sqrt:n.sqrt||(f=>i(c,f)),invertBatch:f=>Vm(c,f),cmov:(f,l,h)=>h?l:f,toBytes:f=>e?hi(f,s):nn(f,s),fromBytes:f=>{if(f.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${f.length}`);return e?yi(f):Rr(f)}});return Object.freeze(c)}function Jf(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Cc(r){let t=Jf(r);return t+Math.ceil(t/2)}function ed(r,t,e=!1){let n=r.length,o=Jf(t),s=Cc(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=e?Rr(r):yi(r),c=dt(i,t-tt)+tt;return e?hi(c,o):nn(c,o)}var Qm=BigInt(0),Uc=BigInt(1);function td(r,t){let e=(o,s)=>{let i=s.negate();return o?i:s},n=o=>{let s=Math.ceil(t/o)+1,i=2**(o-1);return{windows:s,windowSize:i}};return{constTimeNegate:e,unsafeLadder(o,s){let i=r.ZERO,c=o;for(;s>Qm;)s&Uc&&(i=i.add(c)),c=c.double(),s>>=Uc;return i},precomputeWindow(o,s){let{windows:i,windowSize:c}=n(s),f=[],l=o,h=l;for(let m=0;m<i;m++){h=l,f.push(h);for(let T=1;T<c;T++)h=h.add(l),f.push(h);l=h.double()}return f},wNAF(o,s,i){let{windows:c,windowSize:f}=n(o),l=r.ZERO,h=r.BASE,m=BigInt(2**o-1),T=2**o,v=BigInt(o);for(let b=0;b<c;b++){let y=b*f,w=Number(i&m);i>>=v,w>f&&(w-=T,i+=Uc);let E=y,k=y+Math.abs(w)-1,P=b%2!==0,$=w<0;w===0?h=h.add(e(P,s[E])):l=l.add(e($,s[k]))}return{p:l,f:h}},wNAFCached(o,s,i,c){let f=o._WINDOW_SIZE||1,l=s.get(o);return l||(l=this.precomputeWindow(o,f),f!==1&&s.set(o,c(l))),this.wNAF(f,l,i)}}}function Ic(r){return Ec(r.Fp),on(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...vc(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function Wm(r){let t=Ic(r);on(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Ym,hexToBytes:Zm}=_c,Mn={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(r){let{Err:t}=Mn;if(r.length<2||r[0]!==2)throw new t("Invalid signature integer tag");let e=r[1],n=r.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Ym(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=Mn,e=typeof r=="string"?Zm(r):r;if(!rr(e))throw new Error("ui8a expected");let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");let{d:o,l:s}=Mn._parseInt(e.subarray(2)),{d:i,l:c}=Mn._parseInt(s);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s:i}},hexFromSig(r){let t=l=>Number.parseInt(l[0],16)&8?"00"+l:l,e=l=>{let h=l.toString(16);return h.length&1?`0${h}`:h},n=t(e(r.s)),o=t(e(r.r)),s=n.length/2,i=o.length/2,c=e(s),f=e(i);return`30${e(i+s+4)}02${f}${o}02${c}${n}`}},Or=BigInt(0),Ht=BigInt(1),Xx=BigInt(2),rd=BigInt(3),Jx=BigInt(4);function Xm(r){let t=Wm(r),{Fp:e}=t,n=t.toBytes||((b,y,w)=>{let E=y.toAffine();return mo(Uint8Array.from([4]),e.toBytes(E.x),e.toBytes(E.y))}),o=t.fromBytes||(b=>{let y=b.subarray(1),w=e.fromBytes(y.subarray(0,e.BYTES)),E=e.fromBytes(y.subarray(e.BYTES,2*e.BYTES));return{x:w,y:E}});function s(b){let{a:y,b:w}=t,E=e.sqr(b),k=e.mul(E,b);return e.add(e.add(k,e.mul(b,y)),w)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function i(b){return typeof b=="bigint"&&Or<b&&b<t.n}function c(b){if(!i(b))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function f(b){let{allowedPrivateKeyLengths:y,nByteLength:w,wrapPrivateKey:E,n:k}=t;if(y&&typeof b!="bigint"){if(rr(b)&&(b=kn(b)),typeof b!="string"||!y.includes(b.length))throw new Error("Invalid key");b=b.padStart(w*2,"0")}let P;try{P=typeof b=="bigint"?b:Rr(Rt("private key",b,w))}catch{throw new Error(`private key must be ${w} bytes, hex or bigint, not ${typeof b}`)}return E&&(P=dt(P,k)),c(P),P}let l=new Map;function h(b){if(!(b instanceof m))throw new Error("ProjectivePoint expected")}class m{constructor(y,w,E){if(this.px=y,this.py=w,this.pz=E,y==null||!e.isValid(y))throw new Error("x required");if(w==null||!e.isValid(w))throw new Error("y required");if(E==null||!e.isValid(E))throw new Error("z required")}static fromAffine(y){let{x:w,y:E}=y||{};if(!y||!e.isValid(w)||!e.isValid(E))throw new Error("invalid affine point");if(y instanceof m)throw new Error("projective point not allowed");let k=P=>e.eql(P,e.ZERO);return k(w)&&k(E)?m.ZERO:new m(w,E,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(y){let w=e.invertBatch(y.map(E=>E.pz));return y.map((E,k)=>E.toAffine(w[k])).map(m.fromAffine)}static fromHex(y){let w=m.fromAffine(o(Rt("pointHex",y)));return w.assertValidity(),w}static fromPrivateKey(y){return m.BASE.multiply(f(y))}_setWindowSize(y){this._WINDOW_SIZE=y,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:y,y:w}=this.toAffine();if(!e.isValid(y)||!e.isValid(w))throw new Error("bad point: x or y not FE");let E=e.sqr(w),k=s(y);if(!e.eql(E,k))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y}=this.toAffine();if(e.isOdd)return!e.isOdd(y);throw new Error("Field doesn't support isOdd")}equals(y){h(y);let{px:w,py:E,pz:k}=this,{px:P,py:$,pz:M}=y,z=e.eql(e.mul(w,M),e.mul(P,k)),L=e.eql(e.mul(E,M),e.mul($,k));return z&&L}negate(){return new m(this.px,e.neg(this.py),this.pz)}double(){let{a:y,b:w}=t,E=e.mul(w,rd),{px:k,py:P,pz:$}=this,M=e.ZERO,z=e.ZERO,L=e.ZERO,K=e.mul(k,k),we=e.mul(P,P),te=e.mul($,$),W=e.mul(k,P);return W=e.add(W,W),L=e.mul(k,$),L=e.add(L,L),M=e.mul(y,L),z=e.mul(E,te),z=e.add(M,z),M=e.sub(we,z),z=e.add(we,z),z=e.mul(M,z),M=e.mul(W,M),L=e.mul(E,L),te=e.mul(y,te),W=e.sub(K,te),W=e.mul(y,W),W=e.add(W,L),L=e.add(K,K),K=e.add(L,K),K=e.add(K,te),K=e.mul(K,W),z=e.add(z,K),te=e.mul(P,$),te=e.add(te,te),K=e.mul(te,W),M=e.sub(M,K),L=e.mul(te,we),L=e.add(L,L),L=e.add(L,L),new m(M,z,L)}add(y){h(y);let{px:w,py:E,pz:k}=this,{px:P,py:$,pz:M}=y,z=e.ZERO,L=e.ZERO,K=e.ZERO,we=t.a,te=e.mul(t.b,rd),W=e.mul(w,P),ve=e.mul(E,$),Ce=e.mul(k,M),Ve=e.add(w,E),_=e.add(P,$);Ve=e.mul(Ve,_),_=e.add(W,ve),Ve=e.sub(Ve,_),_=e.add(w,k);let B=e.add(P,M);return _=e.mul(_,B),B=e.add(W,Ce),_=e.sub(_,B),B=e.add(E,k),z=e.add($,M),B=e.mul(B,z),z=e.add(ve,Ce),B=e.sub(B,z),K=e.mul(we,_),z=e.mul(te,Ce),K=e.add(z,K),z=e.sub(ve,K),K=e.add(ve,K),L=e.mul(z,K),ve=e.add(W,W),ve=e.add(ve,W),Ce=e.mul(we,Ce),_=e.mul(te,_),ve=e.add(ve,Ce),Ce=e.sub(W,Ce),Ce=e.mul(we,Ce),_=e.add(_,Ce),W=e.mul(ve,_),L=e.add(L,W),W=e.mul(B,_),z=e.mul(Ve,z),z=e.sub(z,W),W=e.mul(Ve,ve),K=e.mul(B,K),K=e.add(K,W),new m(z,L,K)}subtract(y){return this.add(y.negate())}is0(){return this.equals(m.ZERO)}wNAF(y){return v.wNAFCached(this,l,y,w=>{let E=e.invertBatch(w.map(k=>k.pz));return w.map((k,P)=>k.toAffine(E[P])).map(m.fromAffine)})}multiplyUnsafe(y){let w=m.ZERO;if(y===Or)return w;if(c(y),y===Ht)return this;let{endo:E}=t;if(!E)return v.unsafeLadder(this,y);let{k1neg:k,k1:P,k2neg:$,k2:M}=E.splitScalar(y),z=w,L=w,K=this;for(;P>Or||M>Or;)P&Ht&&(z=z.add(K)),M&Ht&&(L=L.add(K)),K=K.double(),P>>=Ht,M>>=Ht;return k&&(z=z.negate()),$&&(L=L.negate()),L=new m(e.mul(L.px,E.beta),L.py,L.pz),z.add(L)}multiply(y){c(y);let w=y,E,k,{endo:P}=t;if(P){let{k1neg:$,k1:M,k2neg:z,k2:L}=P.splitScalar(w),{p:K,f:we}=this.wNAF(M),{p:te,f:W}=this.wNAF(L);K=v.constTimeNegate($,K),te=v.constTimeNegate(z,te),te=new m(e.mul(te.px,P.beta),te.py,te.pz),E=K.add(te),k=we.add(W)}else{let{p:$,f:M}=this.wNAF(w);E=$,k=M}return m.normalizeZ([E,k])[0]}multiplyAndAddUnsafe(y,w,E){let k=m.BASE,P=(M,z)=>z===Or||z===Ht||!M.equals(k)?M.multiplyUnsafe(z):M.multiply(z),$=P(this,w).add(P(y,E));return $.is0()?void 0:$}toAffine(y){let{px:w,py:E,pz:k}=this,P=this.is0();y==null&&(y=P?e.ONE:e.inv(k));let $=e.mul(w,y),M=e.mul(E,y),z=e.mul(k,y);if(P)return{x:e.ZERO,y:e.ZERO};if(!e.eql(z,e.ONE))throw new Error("invZ was invalid");return{x:$,y:M}}isTorsionFree(){let{h:y,isTorsionFree:w}=t;if(y===Ht)return!0;if(w)return w(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:y,clearCofactor:w}=t;return y===Ht?this:w?w(m,this):this.multiplyUnsafe(t.h)}toRawBytes(y=!0){return this.assertValidity(),n(m,this,y)}toHex(y=!0){return kn(this.toRawBytes(y))}}m.BASE=new m(t.Gx,t.Gy,e.ONE),m.ZERO=new m(e.ZERO,e.ONE,e.ZERO);let T=t.nBitLength,v=td(m,t.endo?Math.ceil(T/2):T);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:f,weierstrassEquation:s,isWithinCurveOrder:i}}function Jm(r){let t=Ic(r);return on(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function nd(r){let t=Jm(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(_){return Or<_&&_<e.ORDER}function c(_){return dt(_,n)}function f(_){return Ai(_,n)}let{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:m,isWithinCurveOrder:T}=Xm({...t,toBytes(_,B,F){let re=B.toAffine(),ne=e.toBytes(re.x),xe=mo;return F?xe(Uint8Array.from([B.hasEvenY()?2:3]),ne):xe(Uint8Array.from([4]),ne,e.toBytes(re.y))},fromBytes(_){let B=_.length,F=_[0],re=_.subarray(1);if(B===o&&(F===2||F===3)){let ne=Rr(re);if(!i(ne))throw new Error("Point is not on curve");let xe=m(ne),ke=e.sqrt(xe),Te=(ke&Ht)===Ht;return(F&1)===1!==Te&&(ke=e.neg(ke)),{x:ne,y:ke}}else if(B===s&&F===4){let ne=e.fromBytes(re.subarray(0,e.BYTES)),xe=e.fromBytes(re.subarray(e.BYTES,2*e.BYTES));return{x:ne,y:xe}}else throw new Error(`Point of length ${B} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),v=_=>kn(nn(_,t.nByteLength));function b(_){let B=n>>Ht;return _>B}function y(_){return b(_)?c(-_):_}let w=(_,B,F)=>Rr(_.slice(B,F));class E{constructor(B,F,re){this.r=B,this.s=F,this.recovery=re,this.assertValidity()}static fromCompact(B){let F=t.nByteLength;return B=Rt("compactSignature",B,F*2),new E(w(B,0,F),w(B,F,2*F))}static fromDER(B){let{r:F,s:re}=Mn.toSig(Rt("DER",B));return new E(F,re)}assertValidity(){if(!T(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!T(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(B){return new E(this.r,this.s,B)}recoverPublicKey(B){let{r:F,s:re,recovery:ne}=this,xe=L(Rt("msgHash",B));if(ne==null||![0,1,2,3].includes(ne))throw new Error("recovery id invalid");let ke=ne===2||ne===3?F+t.n:F;if(ke>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let Te=ne&1?"03":"02",De=l.fromHex(Te+v(ke)),se=f(ke),Ke=c(-xe*se),St=c(re*se),ot=l.BASE.multiplyAndAddUnsafe(De,Ke,St);if(!ot)throw new Error("point at infinify");return ot.assertValidity(),ot}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new E(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return zn(this.toDERHex())}toDERHex(){return Mn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return zn(this.toCompactHex())}toCompactHex(){return v(this.r)+v(this.s)}}let k={isValidPrivateKey(_){try{return h(_),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{let _=Cc(t.n);return ed(t.randomBytes(_),t.n)},precompute(_=8,B=l.BASE){return B._setWindowSize(_),B.multiply(BigInt(3)),B}};function P(_,B=!0){return l.fromPrivateKey(_).toRawBytes(B)}function $(_){let B=rr(_),F=typeof _=="string",re=(B||F)&&_.length;return B?re===o||re===s:F?re===2*o||re===2*s:_ instanceof l}function M(_,B,F=!0){if($(_))throw new Error("first arg must be private key");if(!$(B))throw new Error("second arg must be public key");return l.fromHex(B).multiply(h(_)).toRawBytes(F)}let z=t.bits2int||function(_){let B=Rr(_),F=_.length*8-t.nBitLength;return F>0?B>>BigInt(F):B},L=t.bits2int_modN||function(_){return c(z(_))},K=es(t.nBitLength);function we(_){if(typeof _!="bigint")throw new Error("bigint expected");if(!(Or<=_&&_<K))throw new Error(`bigint expected < 2^${t.nBitLength}`);return nn(_,t.nByteLength)}function te(_,B,F=W){if(["recovered","canonical"].some(st=>st in F))throw new Error("sign() legacy options not supported");let{hash:re,randomBytes:ne}=t,{lowS:xe,prehash:ke,extraEntropy:Te}=F;xe==null&&(xe=!0),_=Rt("msgHash",_),ke&&(_=Rt("prehashed msgHash",re(_)));let De=L(_),se=h(B),Ke=[we(se),we(De)];if(Te!=null){let st=Te===!0?ne(e.BYTES):Te;Ke.push(Rt("extraEntropy",st))}let St=mo(...Ke),ot=De;function kt(st){let pt=z(st);if(!T(pt))return;let ar=f(pt),Fe=l.BASE.multiply(pt).toAffine(),xt=c(Fe.x);if(xt===Or)return;let Qt=c(ar*c(ot+xt*se));if(Qt===Or)return;let hn=(Fe.x===xt?0:2)|Number(Fe.y&Ht),qr=Qt;return xe&&b(Qt)&&(qr=y(Qt),hn^=1),new E(xt,qr,hn)}return{seed:St,k2sig:kt}}let W={lowS:t.lowS,prehash:!1},ve={lowS:t.lowS,prehash:!1};function Ce(_,B,F=W){let{seed:re,k2sig:ne}=te(_,B,F),xe=t;return Tc(xe.hash.outputLen,xe.nByteLength,xe.hmac)(re,ne)}l.BASE._setWindowSize(8);function Ve(_,B,F,re=ve){let ne=_;if(B=Rt("msgHash",B),F=Rt("publicKey",F),"strict"in re)throw new Error("options.strict was renamed to lowS");let{lowS:xe,prehash:ke}=re,Te,De;try{if(typeof ne=="string"||rr(ne))try{Te=E.fromDER(ne)}catch(Fe){if(!(Fe instanceof Mn.Err))throw Fe;Te=E.fromCompact(ne)}else if(typeof ne=="object"&&typeof ne.r=="bigint"&&typeof ne.s=="bigint"){let{r:Fe,s:xt}=ne;Te=new E(Fe,xt)}else throw new Error("PARSE");De=l.fromHex(F)}catch(Fe){if(Fe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(xe&&Te.hasHighS())return!1;ke&&(B=t.hash(B));let{r:se,s:Ke}=Te,St=L(B),ot=f(Ke),kt=c(St*ot),st=c(se*ot),pt=l.BASE.multiplyAndAddUnsafe(De,kt,st)?.toAffine();return pt?c(pt.x)===se:!1}return{CURVE:t,getPublicKey:P,getSharedSecret:M,sign:Ce,verify:Ve,ProjectivePoint:l,Signature:E,utils:k}}function ey(r){return{hash:r,hmac:(t,...e)=>fr(r,t,Sn(...e)),randomBytes:Ju}}function od(r,t){let e=n=>nd({...r,...ey(n)});return Object.freeze({...e(t),create:e})}var ad=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),sd=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ty=BigInt(1),Bc=BigInt(2),id=(r,t)=>(r+t/Bc)/t;function ry(r){let t=ad,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),f=BigInt(88),l=r*r*r%t,h=l*l*r%t,m=Ot(h,e,t)*h%t,T=Ot(m,e,t)*h%t,v=Ot(T,Bc,t)*l%t,b=Ot(v,o,t)*v%t,y=Ot(b,s,t)*b%t,w=Ot(y,c,t)*y%t,E=Ot(w,f,t)*w%t,k=Ot(E,c,t)*y%t,P=Ot(k,e,t)*h%t,$=Ot(P,i,t)*b%t,M=Ot($,n,t)*l%t,z=Ot(M,Bc,t);if(!Pc.eql(Pc.sqr(z),r))throw new Error("Cannot find square root");return z}var Pc=Xf(ad,void 0,void 0,{sqrt:ry}),nr=od({a:BigInt(0),b:BigInt(7),Fp:Pc,n:sd,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=sd,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ty*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=id(s*r,t),f=id(-n*r,t),l=dt(r-c*e-f*o,t),h=dt(-c*n-f*s,t),m=l>i,T=h>i;if(m&&(l=t-l),T&&(h=t-h),l>i||h>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:m,k1:l,k2neg:T,k2:h}}}},Wo),cb=BigInt(0);var ub=nr.ProjectivePoint;function xi(r){if(!Number.isSafeInteger(r))throw new Error(`Wrong integer: ${r}`)}function Rc(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function ud(...r){let t=s=>s,e=(s,i)=>c=>s(i(c)),n=r.map(s=>s.encode).reduceRight(e,t),o=r.map(s=>s.decode).reduce(e,t);return{encode:n,decode:o}}function ny(r){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(e=>{if(e<0||e>=r.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${r.length})`);return r[e]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(e=>{if(typeof e!="string")throw new Error(`alphabet.decode: not string element=${e}`);let n=r.indexOf(e);if(n===-1)throw new Error(`Unknown letter: "${e}". Allowed: ${r}`);return n})}}}function oy(r=""){if(typeof r!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let e of t)if(typeof e!="string")throw new Error(`join.encode: non-string input=${e}`);return t.join(r)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(r)}}}function cd(r,t,e){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(e<2)throw new Error(`convertRadix: wrong to=${e}, base cannot be less than 2`);if(!Array.isArray(r))throw new Error("convertRadix: data should be array");if(!r.length)return[];let n=0,o=[],s=Array.from(r);for(s.forEach(i=>{if(i<0||i>=t)throw new Error(`Wrong integer: ${i}`)});;){let i=0,c=!0;for(let f=n;f<s.length;f++){let l=s[f],h=t*i+l;if(!Number.isSafeInteger(h)||t*i/t!==i||h-l!==t*i)throw new Error("convertRadix: carry overflow");i=h%e;let m=Math.floor(h/e);if(s[f]=m,!Number.isSafeInteger(m)||m*e+i!==h)throw new Error("convertRadix: carry overflow");if(c)m?c=!1:n=f;else continue}if(o.push(i),c)break}for(let i=0;i<r.length-1&&r[i]===0;i++)o.push(0);return o.reverse()}function sy(r){return{encode:t=>{if(!Rc(t))throw new Error("radix.encode input should be Uint8Array");return cd(Array.from(t),2**8,r)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(cd(t,r,2**8))}}}function iy(r,t){if(typeof t!="function")throw new Error("checksum fn should be function");return{encode(e){if(!Rc(e))throw new Error("checksum.encode: input should be Uint8Array");let n=t(e).slice(0,r),o=new Uint8Array(e.length+r);return o.set(e),o.set(n,e.length),o},decode(e){if(!Rc(e))throw new Error("checksum.decode: input should be Uint8Array");let n=e.slice(0,-r),o=t(n).slice(0,r),s=e.slice(-r);for(let i=0;i<r;i++)if(o[i]!==s[i])throw new Error("Invalid checksum");return n}}}var ay=r=>ud(sy(58),ny(r),oy("")),cy=ay("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var fd=r=>ud(iy(4,t=>r(r(t))),cy);var bi=nr.ProjectivePoint,Oc=fd(Wo);function dd(r){return BigInt(`0x${_n(r)}`)}function uy(r){return uo(r.toString(16).padStart(64,"0"))}var fy=qa("Bitcoin seed"),Nc={private:76066276,public:76067358},kc=2147483648,dy=r=>$f(Wo(r)),ly=r=>ur(r).getUint32(0,!1),wi=r=>{if(!Number.isSafeInteger(r)||r<0||r>2**32-1)throw new Error(`Invalid number=${r}. Should be from 0 to 2 ** 32 - 1`);let t=new Uint8Array(4);return ur(t).setUint32(0,r,!1),t},Ti=class r{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return ly(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){let t=this.privateKey;if(!t)throw new Error("No private key");return Oc.encode(this.serialize(this.versions.private,Sn(new Uint8Array([0]),t)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return Oc.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(t,e=Nc){if(Xt(t),8*t.length<128||8*t.length>512)throw new Error(`HDKey: wrong seed length=${t.length}. Should be between 128 and 512 bits; 256 bits is advised)`);let n=fr(In,fy,t);return new r({versions:e,chainCode:n.slice(32),privateKey:n.slice(0,32)})}static fromExtendedKey(t,e=Nc){let n=Oc.decode(t),o=ur(n),s=o.getUint32(0,!1),i={versions:e,depth:n[4],parentFingerprint:o.getUint32(5,!1),index:o.getUint32(9,!1),chainCode:n.slice(13,45)},c=n.slice(45),f=c[0]===0;if(s!==e[f?"private":"public"])throw new Error("Version mismatch");return f?new r({...i,privateKey:c.slice(1)}):new r({...i,publicKey:c})}static fromJSON(t){return r.fromExtendedKey(t.xpriv)}constructor(t){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!t||typeof t!="object")throw new Error("HDKey.constructor must not be called directly");if(this.versions=t.versions||Nc,this.depth=t.depth||0,this.chainCode=t.chainCode,this.index=t.index||0,this.parentFingerprint=t.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(t.publicKey&&t.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(t.privateKey){if(!nr.utils.isValidPrivateKey(t.privateKey))throw new Error("Invalid private key");this.privKey=typeof t.privateKey=="bigint"?t.privateKey:dd(t.privateKey),this.privKeyBytes=uy(this.privKey),this.pubKey=nr.getPublicKey(t.privateKey,!0)}else if(t.publicKey)this.pubKey=bi.fromHex(t.publicKey).toRawBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=dy(this.pubKey)}derive(t){if(!/^[mM]'?/.test(t))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(t))return this;let e=t.replace(/^[mM]'?\//,"").split("/"),n=this;for(let o of e){let s=/^(\d+)('?)$/.exec(o),i=s&&s[1];if(!s||s.length!==3||typeof i!="string")throw new Error(`Invalid child index: ${o}`);let c=+i;if(!Number.isSafeInteger(c)||c>=kc)throw new Error("Invalid index");s[2]==="'"&&(c+=kc),n=n.deriveChild(c)}return n}deriveChild(t){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let e=wi(t);if(t>=kc){let c=this.privateKey;if(!c)throw new Error("Could not derive hardened child key");e=Sn(new Uint8Array([0]),c,e)}else e=Sn(this.pubKey,e);let n=fr(In,this.chainCode,e),o=dd(n.slice(0,32)),s=n.slice(32);if(!nr.utils.isValidPrivateKey(o))throw new Error("Tweak bigger than curve order");let i={versions:this.versions,chainCode:s,depth:this.depth+1,parentFingerprint:this.fingerprint,index:t};try{if(this.privateKey){let c=dt(this.privKey+o,nr.CURVE.n);if(!nr.utils.isValidPrivateKey(c))throw new Error("The tweak was out of range or the resulted private key is invalid");i.privateKey=c}else{let c=bi.fromHex(this.pubKey).add(bi.fromPrivateKey(o));if(c.equals(bi.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");i.publicKey=c.toRawBytes(!0)}return new r(i)}catch{return this.deriveChild(t+1)}}sign(t){if(!this.privateKey)throw new Error("No privateKey set!");return Xt(t,32),nr.sign(t,this.privKey).toCompactRawBytes()}verify(t,e){if(Xt(t,32),Xt(e,64),!this.publicKey)throw new Error("No publicKey set!");let n;try{n=nr.Signature.fromCompact(e)}catch{return!1}return nr.verify(n,t,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(t,e){if(!this.chainCode)throw new Error("No chainCode set");return Xt(e,33),Sn(wi(t),new Uint8Array([this.depth]),wi(this.parentFingerprint),wi(this.index),this.chainCode,e)}};var sn=class sn extends It{constructor(e){super();let n=Be.fromHexInput(e);if(n.toUint8Array().length!==sn.LENGTH)throw new Error(`PublicKey length should be ${sn.LENGTH}`);this.key=n}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}verifySignature(e){let{message:n,signature:o}=e,s=Be.fromHexInput(n).toUint8Array(),i=Cn(s),c=o.toUint8Array();return go.verify(c,i,this.toUint8Array())}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let n=e.deserializeBytes();return new sn(n)}static load(e){let n=e.deserializeBytes();return new sn(n)}static isPublicKey(e){return e instanceof sn}};sn.LENGTH=65;var Ft=sn,dr=class dr extends Un{constructor(e){super();let n=Be.fromHexInput(e);if(n.toUint8Array().length!==dr.LENGTH)throw new Error(`PrivateKey length should be ${dr.LENGTH}`);this.key=n}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}sign(e){let n=Be.fromHexInput(e),o=Cn(n.toUint8Array()),s=go.sign(o,this.key.toUint8Array());return new kr(s.toCompactRawBytes())}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let n=e.deserializeBytes();return new dr(n)}static generate(){let e=go.utils.randomPrivateKey();return new dr(e)}publicKey(){let e=go.getPublicKey(this.key.toUint8Array(),!1);return new Ft(e)}static fromDerivationPath(e,n){if(!Xa(e))throw new Error(`Invalid derivation path ${e}`);return dr.fromDerivationPathInner(e,Yo(n))}static fromDerivationPathInner(e,n){let{privateKey:o}=Ti.fromMasterSeed(n).derive(e);if(o===null)throw new Error("Invalid key");return new dr(o)}static isPrivateKey(e){return e instanceof dr}};dr.LENGTH=32;var Nr=dr,an=class an extends Jt{constructor(e){super();let n=Be.fromHexInput(e);if(n.toUint8Array().length!==an.LENGTH)throw new Error(`Signature length should be ${an.LENGTH}, recieved ${n.toUint8Array().length}`);this.data=n}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let n=e.deserializeBytes();return new an(n)}static load(e){let n=e.deserializeBytes();return new an(n)}static isSignature(e){return e instanceof an}};an.LENGTH=64;var kr=an;var je=class r extends It{constructor(e){super();this.publicKey=e}toUint8Array(){return this.publicKey.toUint8Array()}toString(){return this.publicKey.toString()}verifySignature(e){let{message:n,signature:o}=e;return this.publicKey.verifySignature({message:n,signature:o})}serialize(e){if(this.publicKey instanceof qe)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else if(this.publicKey instanceof Ft)e.serializeU32AsUleb128(1),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let n=e.deserializeUleb128AsU32();switch(n){case 0:return new r(qe.load(e));case 1:return new r(Ft.load(e));default:throw new Error(`Unknown variant index for AnyPublicKey: ${n}`)}}static isPublicKey(e){return e instanceof r}isEd25519(){return this.publicKey instanceof qe}isSecp256k1PublicKey(){return this.publicKey instanceof Ft}};var Gn=class r extends It{constructor(e){super();let{publicKeys:n,signaturesRequired:o}=e;if(o<1)throw new Error("The number of required signatures needs to be greater then 0");if(n.length<o)throw new Error(`Provided ${n.length} public keys is smaller than the ${o} required signatures`);let s=[];n.forEach(i=>{i instanceof je?s.push(i):s.push(new je(i))}),this.publicKeys=s,this.signaturesRequired=o}toUint8Array(){return this.bcsToBytes()}createBitmap(e){let{bits:n}=e,o=128,s=new Uint8Array([0,0,0,0]),i=new Set;return n.forEach((c,f)=>{if(f+1>this.publicKeys.length)throw new Error(`Signature index ${f+1} is out of public keys range, ${this.publicKeys.length}.`);if(i.has(c))throw new Error(`Duplicate bit ${c} detected.`);i.add(c);let l=Math.floor(c/8),h=s[l];h|=o>>c%8,s[l]=h}),s}toString(){return Be.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){throw new Error("not implemented")}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let n=e.deserializeVector(je),o=e.deserializeU8();return new r({publicKeys:n,signaturesRequired:o})}};var zr=class zr extends ae{constructor(e){super();let{data:n}=e,o=Be.fromHexInput(n);if(o.toUint8Array().length!==zr.LENGTH)throw new Error(`Authentication Key length should be ${zr.LENGTH}`);this.data=o}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let n=e.deserializeFixedBytes(zr.LENGTH);return new zr({data:n})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromPublicKeyAndScheme(e){let{publicKey:n,scheme:o}=e,s;switch(o){case 3:case 2:{let f=n.bcsToBytes();s=new Uint8Array([...f,o]);break}case 0:case 1:{let f=n.toUint8Array(),l=Be.fromHexInput(f).toUint8Array();s=new Uint8Array([...l,o]);break}default:throw new Error(`Scheme ${o} is not supported`)}let i=Cn.create();i.update(s);let c=i.digest();return new zr({data:c})}static fromPublicKey(e){let{publicKey:n}=e,o;if(n instanceof qe)o=0 .valueOf();else if(n instanceof er)o=1 .valueOf();else if(n instanceof je)o=2 .valueOf();else if(n instanceof Gn)o=3 .valueOf();else throw new Error("No supported authentication scheme for public key");return zr.fromPublicKeyAndScheme({publicKey:n,scheme:o})}derivedAddress(){return new H(this.data.toUint8Array())}};zr.LENGTH=32;var or=zr;var Dr=class r{constructor(t){let{privateKey:e,address:n,legacy:o}=t,s=o??!0;if(this.publicKey=e.publicKey(),this.publicKey instanceof qe)s?this.signingScheme=0:(this.publicKey=new je(this.publicKey),this.signingScheme=2);else if(this.publicKey instanceof er)this.signingScheme=1;else if(this.publicKey instanceof Ft)this.publicKey=new je(this.publicKey),this.signingScheme=2;else throw new Error("Can not create new Account, unsupported public key type");this.privateKey=e,this.accountAddress=n}static generate(t){let e=t?.legacy??!0,n,o;switch(t?.scheme){case 2:n=Nr.generate(),o=new je(n.publicKey());break;default:n=Ur.generate(),e===!1?o=new je(n.publicKey()):o=n.publicKey()}let i=or.fromPublicKey({publicKey:o}).derivedAddress();return new r({privateKey:n,address:i,legacy:t?.legacy})}static fromPrivateKey(t){let{privateKey:e,legacy:n}=t,o=n??!0,s;if(e instanceof Nr)s=new je(e.publicKey());else if(e instanceof Ur)o?s=e.publicKey():s=new je(e.publicKey());else throw new Error(`Unsupported private key ${e}`);let c=or.fromPublicKey({publicKey:s}).derivedAddress();return new r({privateKey:e,address:c,legacy:o})}static fromPrivateKeyAndAddress(t){let{privateKey:e,address:n,legacy:o}=t;return new r({privateKey:e,address:n,legacy:o})}static fromDerivationPath(t){let{path:e,mnemonic:n,scheme:o,legacy:s}=t,i;switch(o){case 2:i=Nr.fromDerivationPath(e,n);break;case 0:i=Ur.fromDerivationPath(e,n);break;default:throw new Error(`Unsupported scheme ${o}`)}return r.fromPrivateKey({privateKey:i,legacy:s})}static authKey(t){let{publicKey:e}=t;return or.fromPublicKey({publicKey:e})}sign(t){return this.privateKey.sign(t)}verifySignature(t){let{message:e,signature:n}=t,o=Be.fromHexInput(e).toUint8Array();return this.publicKey.verifySignature({message:o,signature:n})}};var py=`
1
+ "use strict";var aptosSDK=(()=>{var Gp=Object.create;var Lo=Object.defineProperty;var Mu=Object.getOwnPropertyDescriptor;var Lp=Object.getOwnPropertyNames;var qp=Object.getPrototypeOf,Kp=Object.prototype.hasOwnProperty;var Gu=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Lu=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Gs=(r,t)=>{for(var e in t)Lo(r,e,{get:t[e],enumerable:!0})},qu=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Lp(t))!Kp.call(r,o)&&o!==e&&Lo(r,o,{get:()=>t[o],enumerable:!(n=Mu(t,o))||n.enumerable});return r};var Hp=(r,t,e)=>(e=r!=null?Gp(qp(r)):{},qu(t||!r||!r.__esModule?Lo(e,"default",{value:r,enumerable:!0}):e,r)),Fp=r=>qu(Lo({},"__esModule",{value:!0}),r),Et=(r,t,e,n)=>{for(var o=n>1?void 0:n?Mu(t,e):t,s=r.length-1,i;s>=0;s--)(i=r[s])&&(o=(n?i(t,e,o):i(o))||o);return n&&o&&Lo(t,e,o),o};var df=Lu(()=>{"use strict"});var lf=Lu(($0,ti)=>{"use strict";(function(r){"use strict";var t=function(u){var p,d=new Float64Array(16);if(u)for(p=0;p<u.length;p++)d[p]=u[p];return d},e=function(){throw new Error("no PRNG")},n=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var s=t(),i=t([1]),c=t([56129,1]),f=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),h=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),m=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),T=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function v(u,p,d,a){u[p]=d>>24&255,u[p+1]=d>>16&255,u[p+2]=d>>8&255,u[p+3]=d&255,u[p+4]=a>>24&255,u[p+5]=a>>16&255,u[p+6]=a>>8&255,u[p+7]=a&255}function b(u,p,d,a,g){var x,S=0;for(x=0;x<g;x++)S|=u[p+x]^d[a+x];return(1&S-1>>>8)-1}function y(u,p,d,a){return b(u,p,d,a,16)}function w(u,p,d,a){return b(u,p,d,a,32)}function E(u,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,x=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,S=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,O=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,q=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,ee=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,j=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,Re=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,Y=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,ce=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,ue=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,ge=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,pe=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,fe=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,le=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,de=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,Z=g,oe=x,Q=S,X=O,J=q,V=ee,C=j,U=Re,D=Y,R=ce,N=ue,G=ge,ie=pe,me=fe,he=le,ye=de,A,_e=0;_e<20;_e+=2)A=Z+ie|0,J^=A<<7|A>>>25,A=J+Z|0,D^=A<<9|A>>>23,A=D+J|0,ie^=A<<13|A>>>19,A=ie+D|0,Z^=A<<18|A>>>14,A=V+oe|0,R^=A<<7|A>>>25,A=R+V|0,me^=A<<9|A>>>23,A=me+R|0,oe^=A<<13|A>>>19,A=oe+me|0,V^=A<<18|A>>>14,A=N+C|0,he^=A<<7|A>>>25,A=he+N|0,Q^=A<<9|A>>>23,A=Q+he|0,C^=A<<13|A>>>19,A=C+Q|0,N^=A<<18|A>>>14,A=ye+G|0,X^=A<<7|A>>>25,A=X+ye|0,U^=A<<9|A>>>23,A=U+X|0,G^=A<<13|A>>>19,A=G+U|0,ye^=A<<18|A>>>14,A=Z+X|0,oe^=A<<7|A>>>25,A=oe+Z|0,Q^=A<<9|A>>>23,A=Q+oe|0,X^=A<<13|A>>>19,A=X+Q|0,Z^=A<<18|A>>>14,A=V+J|0,C^=A<<7|A>>>25,A=C+V|0,U^=A<<9|A>>>23,A=U+C|0,J^=A<<13|A>>>19,A=J+U|0,V^=A<<18|A>>>14,A=N+R|0,G^=A<<7|A>>>25,A=G+N|0,D^=A<<9|A>>>23,A=D+G|0,R^=A<<13|A>>>19,A=R+D|0,N^=A<<18|A>>>14,A=ye+he|0,ie^=A<<7|A>>>25,A=ie+ye|0,me^=A<<9|A>>>23,A=me+ie|0,he^=A<<13|A>>>19,A=he+me|0,ye^=A<<18|A>>>14;Z=Z+g|0,oe=oe+x|0,Q=Q+S|0,X=X+O|0,J=J+q|0,V=V+ee|0,C=C+j|0,U=U+Re|0,D=D+Y|0,R=R+ce|0,N=N+ue|0,G=G+ge|0,ie=ie+pe|0,me=me+fe|0,he=he+le|0,ye=ye+de|0,u[0]=Z>>>0&255,u[1]=Z>>>8&255,u[2]=Z>>>16&255,u[3]=Z>>>24&255,u[4]=oe>>>0&255,u[5]=oe>>>8&255,u[6]=oe>>>16&255,u[7]=oe>>>24&255,u[8]=Q>>>0&255,u[9]=Q>>>8&255,u[10]=Q>>>16&255,u[11]=Q>>>24&255,u[12]=X>>>0&255,u[13]=X>>>8&255,u[14]=X>>>16&255,u[15]=X>>>24&255,u[16]=J>>>0&255,u[17]=J>>>8&255,u[18]=J>>>16&255,u[19]=J>>>24&255,u[20]=V>>>0&255,u[21]=V>>>8&255,u[22]=V>>>16&255,u[23]=V>>>24&255,u[24]=C>>>0&255,u[25]=C>>>8&255,u[26]=C>>>16&255,u[27]=C>>>24&255,u[28]=U>>>0&255,u[29]=U>>>8&255,u[30]=U>>>16&255,u[31]=U>>>24&255,u[32]=D>>>0&255,u[33]=D>>>8&255,u[34]=D>>>16&255,u[35]=D>>>24&255,u[36]=R>>>0&255,u[37]=R>>>8&255,u[38]=R>>>16&255,u[39]=R>>>24&255,u[40]=N>>>0&255,u[41]=N>>>8&255,u[42]=N>>>16&255,u[43]=N>>>24&255,u[44]=G>>>0&255,u[45]=G>>>8&255,u[46]=G>>>16&255,u[47]=G>>>24&255,u[48]=ie>>>0&255,u[49]=ie>>>8&255,u[50]=ie>>>16&255,u[51]=ie>>>24&255,u[52]=me>>>0&255,u[53]=me>>>8&255,u[54]=me>>>16&255,u[55]=me>>>24&255,u[56]=he>>>0&255,u[57]=he>>>8&255,u[58]=he>>>16&255,u[59]=he>>>24&255,u[60]=ye>>>0&255,u[61]=ye>>>8&255,u[62]=ye>>>16&255,u[63]=ye>>>24&255}function k(u,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,x=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,S=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,O=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,q=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,ee=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,j=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,Re=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,Y=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,ce=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,ue=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,ge=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,pe=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,fe=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,le=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,de=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,Z=g,oe=x,Q=S,X=O,J=q,V=ee,C=j,U=Re,D=Y,R=ce,N=ue,G=ge,ie=pe,me=fe,he=le,ye=de,A,_e=0;_e<20;_e+=2)A=Z+ie|0,J^=A<<7|A>>>25,A=J+Z|0,D^=A<<9|A>>>23,A=D+J|0,ie^=A<<13|A>>>19,A=ie+D|0,Z^=A<<18|A>>>14,A=V+oe|0,R^=A<<7|A>>>25,A=R+V|0,me^=A<<9|A>>>23,A=me+R|0,oe^=A<<13|A>>>19,A=oe+me|0,V^=A<<18|A>>>14,A=N+C|0,he^=A<<7|A>>>25,A=he+N|0,Q^=A<<9|A>>>23,A=Q+he|0,C^=A<<13|A>>>19,A=C+Q|0,N^=A<<18|A>>>14,A=ye+G|0,X^=A<<7|A>>>25,A=X+ye|0,U^=A<<9|A>>>23,A=U+X|0,G^=A<<13|A>>>19,A=G+U|0,ye^=A<<18|A>>>14,A=Z+X|0,oe^=A<<7|A>>>25,A=oe+Z|0,Q^=A<<9|A>>>23,A=Q+oe|0,X^=A<<13|A>>>19,A=X+Q|0,Z^=A<<18|A>>>14,A=V+J|0,C^=A<<7|A>>>25,A=C+V|0,U^=A<<9|A>>>23,A=U+C|0,J^=A<<13|A>>>19,A=J+U|0,V^=A<<18|A>>>14,A=N+R|0,G^=A<<7|A>>>25,A=G+N|0,D^=A<<9|A>>>23,A=D+G|0,R^=A<<13|A>>>19,A=R+D|0,N^=A<<18|A>>>14,A=ye+he|0,ie^=A<<7|A>>>25,A=ie+ye|0,me^=A<<9|A>>>23,A=me+ie|0,he^=A<<13|A>>>19,A=he+me|0,ye^=A<<18|A>>>14;u[0]=Z>>>0&255,u[1]=Z>>>8&255,u[2]=Z>>>16&255,u[3]=Z>>>24&255,u[4]=V>>>0&255,u[5]=V>>>8&255,u[6]=V>>>16&255,u[7]=V>>>24&255,u[8]=N>>>0&255,u[9]=N>>>8&255,u[10]=N>>>16&255,u[11]=N>>>24&255,u[12]=ye>>>0&255,u[13]=ye>>>8&255,u[14]=ye>>>16&255,u[15]=ye>>>24&255,u[16]=C>>>0&255,u[17]=C>>>8&255,u[18]=C>>>16&255,u[19]=C>>>24&255,u[20]=U>>>0&255,u[21]=U>>>8&255,u[22]=U>>>16&255,u[23]=U>>>24&255,u[24]=D>>>0&255,u[25]=D>>>8&255,u[26]=D>>>16&255,u[27]=D>>>24&255,u[28]=R>>>0&255,u[29]=R>>>8&255,u[30]=R>>>16&255,u[31]=R>>>24&255}function P(u,p,d,a){E(u,p,d,a)}function $(u,p,d,a){k(u,p,d,a)}var M=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function z(u,p,d,a,g,x,S){var O=new Uint8Array(16),q=new Uint8Array(64),ee,j;for(j=0;j<16;j++)O[j]=0;for(j=0;j<8;j++)O[j]=x[j];for(;g>=64;){for(P(q,O,S,M),j=0;j<64;j++)u[p+j]=d[a+j]^q[j];for(ee=1,j=8;j<16;j++)ee=ee+(O[j]&255)|0,O[j]=ee&255,ee>>>=8;g-=64,p+=64,a+=64}if(g>0)for(P(q,O,S,M),j=0;j<g;j++)u[p+j]=d[a+j]^q[j];return 0}function L(u,p,d,a,g){var x=new Uint8Array(16),S=new Uint8Array(64),O,q;for(q=0;q<16;q++)x[q]=0;for(q=0;q<8;q++)x[q]=a[q];for(;d>=64;){for(P(S,x,g,M),q=0;q<64;q++)u[p+q]=S[q];for(O=1,q=8;q<16;q++)O=O+(x[q]&255)|0,x[q]=O&255,O>>>=8;d-=64,p+=64}if(d>0)for(P(S,x,g,M),q=0;q<d;q++)u[p+q]=S[q];return 0}function K(u,p,d,a,g){var x=new Uint8Array(32);$(x,a,g,M);for(var S=new Uint8Array(8),O=0;O<8;O++)S[O]=a[O+16];return L(u,p,d,S,x)}function we(u,p,d,a,g,x,S){var O=new Uint8Array(32);$(O,x,S,M);for(var q=new Uint8Array(8),ee=0;ee<8;ee++)q[ee]=x[ee+16];return z(u,p,d,a,g,q,O)}var te=function(u){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var p,d,a,g,x,S,O,q;p=u[0]&255|(u[1]&255)<<8,this.r[0]=p&8191,d=u[2]&255|(u[3]&255)<<8,this.r[1]=(p>>>13|d<<3)&8191,a=u[4]&255|(u[5]&255)<<8,this.r[2]=(d>>>10|a<<6)&7939,g=u[6]&255|(u[7]&255)<<8,this.r[3]=(a>>>7|g<<9)&8191,x=u[8]&255|(u[9]&255)<<8,this.r[4]=(g>>>4|x<<12)&255,this.r[5]=x>>>1&8190,S=u[10]&255|(u[11]&255)<<8,this.r[6]=(x>>>14|S<<2)&8191,O=u[12]&255|(u[13]&255)<<8,this.r[7]=(S>>>11|O<<5)&8065,q=u[14]&255|(u[15]&255)<<8,this.r[8]=(O>>>8|q<<8)&8191,this.r[9]=q>>>5&127,this.pad[0]=u[16]&255|(u[17]&255)<<8,this.pad[1]=u[18]&255|(u[19]&255)<<8,this.pad[2]=u[20]&255|(u[21]&255)<<8,this.pad[3]=u[22]&255|(u[23]&255)<<8,this.pad[4]=u[24]&255|(u[25]&255)<<8,this.pad[5]=u[26]&255|(u[27]&255)<<8,this.pad[6]=u[28]&255|(u[29]&255)<<8,this.pad[7]=u[30]&255|(u[31]&255)<<8};te.prototype.blocks=function(u,p,d){for(var a=this.fin?0:2048,g,x,S,O,q,ee,j,Re,Y,ce,ue,ge,pe,fe,le,de,Z,oe,Q,X=this.h[0],J=this.h[1],V=this.h[2],C=this.h[3],U=this.h[4],D=this.h[5],R=this.h[6],N=this.h[7],G=this.h[8],ie=this.h[9],me=this.r[0],he=this.r[1],ye=this.r[2],A=this.r[3],_e=this.r[4],Oe=this.r[5],Ne=this.r[6],be=this.r[7],Ue=this.r[8],Ie=this.r[9];d>=16;)g=u[p+0]&255|(u[p+1]&255)<<8,X+=g&8191,x=u[p+2]&255|(u[p+3]&255)<<8,J+=(g>>>13|x<<3)&8191,S=u[p+4]&255|(u[p+5]&255)<<8,V+=(x>>>10|S<<6)&8191,O=u[p+6]&255|(u[p+7]&255)<<8,C+=(S>>>7|O<<9)&8191,q=u[p+8]&255|(u[p+9]&255)<<8,U+=(O>>>4|q<<12)&8191,D+=q>>>1&8191,ee=u[p+10]&255|(u[p+11]&255)<<8,R+=(q>>>14|ee<<2)&8191,j=u[p+12]&255|(u[p+13]&255)<<8,N+=(ee>>>11|j<<5)&8191,Re=u[p+14]&255|(u[p+15]&255)<<8,G+=(j>>>8|Re<<8)&8191,ie+=Re>>>5|a,Y=0,ce=Y,ce+=X*me,ce+=J*(5*Ie),ce+=V*(5*Ue),ce+=C*(5*be),ce+=U*(5*Ne),Y=ce>>>13,ce&=8191,ce+=D*(5*Oe),ce+=R*(5*_e),ce+=N*(5*A),ce+=G*(5*ye),ce+=ie*(5*he),Y+=ce>>>13,ce&=8191,ue=Y,ue+=X*he,ue+=J*me,ue+=V*(5*Ie),ue+=C*(5*Ue),ue+=U*(5*be),Y=ue>>>13,ue&=8191,ue+=D*(5*Ne),ue+=R*(5*Oe),ue+=N*(5*_e),ue+=G*(5*A),ue+=ie*(5*ye),Y+=ue>>>13,ue&=8191,ge=Y,ge+=X*ye,ge+=J*he,ge+=V*me,ge+=C*(5*Ie),ge+=U*(5*Ue),Y=ge>>>13,ge&=8191,ge+=D*(5*be),ge+=R*(5*Ne),ge+=N*(5*Oe),ge+=G*(5*_e),ge+=ie*(5*A),Y+=ge>>>13,ge&=8191,pe=Y,pe+=X*A,pe+=J*ye,pe+=V*he,pe+=C*me,pe+=U*(5*Ie),Y=pe>>>13,pe&=8191,pe+=D*(5*Ue),pe+=R*(5*be),pe+=N*(5*Ne),pe+=G*(5*Oe),pe+=ie*(5*_e),Y+=pe>>>13,pe&=8191,fe=Y,fe+=X*_e,fe+=J*A,fe+=V*ye,fe+=C*he,fe+=U*me,Y=fe>>>13,fe&=8191,fe+=D*(5*Ie),fe+=R*(5*Ue),fe+=N*(5*be),fe+=G*(5*Ne),fe+=ie*(5*Oe),Y+=fe>>>13,fe&=8191,le=Y,le+=X*Oe,le+=J*_e,le+=V*A,le+=C*ye,le+=U*he,Y=le>>>13,le&=8191,le+=D*me,le+=R*(5*Ie),le+=N*(5*Ue),le+=G*(5*be),le+=ie*(5*Ne),Y+=le>>>13,le&=8191,de=Y,de+=X*Ne,de+=J*Oe,de+=V*_e,de+=C*A,de+=U*ye,Y=de>>>13,de&=8191,de+=D*he,de+=R*me,de+=N*(5*Ie),de+=G*(5*Ue),de+=ie*(5*be),Y+=de>>>13,de&=8191,Z=Y,Z+=X*be,Z+=J*Ne,Z+=V*Oe,Z+=C*_e,Z+=U*A,Y=Z>>>13,Z&=8191,Z+=D*ye,Z+=R*he,Z+=N*me,Z+=G*(5*Ie),Z+=ie*(5*Ue),Y+=Z>>>13,Z&=8191,oe=Y,oe+=X*Ue,oe+=J*be,oe+=V*Ne,oe+=C*Oe,oe+=U*_e,Y=oe>>>13,oe&=8191,oe+=D*A,oe+=R*ye,oe+=N*he,oe+=G*me,oe+=ie*(5*Ie),Y+=oe>>>13,oe&=8191,Q=Y,Q+=X*Ie,Q+=J*Ue,Q+=V*be,Q+=C*Ne,Q+=U*Oe,Y=Q>>>13,Q&=8191,Q+=D*_e,Q+=R*A,Q+=N*ye,Q+=G*he,Q+=ie*me,Y+=Q>>>13,Q&=8191,Y=(Y<<2)+Y|0,Y=Y+ce|0,ce=Y&8191,Y=Y>>>13,ue+=Y,X=ce,J=ue,V=ge,C=pe,U=fe,D=le,R=de,N=Z,G=oe,ie=Q,p+=16,d-=16;this.h[0]=X,this.h[1]=J,this.h[2]=V,this.h[3]=C,this.h[4]=U,this.h[5]=D,this.h[6]=R,this.h[7]=N,this.h[8]=G,this.h[9]=ie},te.prototype.finish=function(u,p){var d=new Uint16Array(10),a,g,x,S;if(this.leftover){for(S=this.leftover,this.buffer[S++]=1;S<16;S++)this.buffer[S]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(a=this.h[1]>>>13,this.h[1]&=8191,S=2;S<10;S++)this.h[S]+=a,a=this.h[S]>>>13,this.h[S]&=8191;for(this.h[0]+=a*5,a=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=a,a=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=a,d[0]=this.h[0]+5,a=d[0]>>>13,d[0]&=8191,S=1;S<10;S++)d[S]=this.h[S]+a,a=d[S]>>>13,d[S]&=8191;for(d[9]-=8192,g=(a^1)-1,S=0;S<10;S++)d[S]&=g;for(g=~g,S=0;S<10;S++)this.h[S]=this.h[S]&g|d[S];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,x=this.h[0]+this.pad[0],this.h[0]=x&65535,S=1;S<8;S++)x=(this.h[S]+this.pad[S]|0)+(x>>>16)|0,this.h[S]=x&65535;u[p+0]=this.h[0]>>>0&255,u[p+1]=this.h[0]>>>8&255,u[p+2]=this.h[1]>>>0&255,u[p+3]=this.h[1]>>>8&255,u[p+4]=this.h[2]>>>0&255,u[p+5]=this.h[2]>>>8&255,u[p+6]=this.h[3]>>>0&255,u[p+7]=this.h[3]>>>8&255,u[p+8]=this.h[4]>>>0&255,u[p+9]=this.h[4]>>>8&255,u[p+10]=this.h[5]>>>0&255,u[p+11]=this.h[5]>>>8&255,u[p+12]=this.h[6]>>>0&255,u[p+13]=this.h[6]>>>8&255,u[p+14]=this.h[7]>>>0&255,u[p+15]=this.h[7]>>>8&255},te.prototype.update=function(u,p,d){var a,g;if(this.leftover){for(g=16-this.leftover,g>d&&(g=d),a=0;a<g;a++)this.buffer[this.leftover+a]=u[p+a];if(d-=g,p+=g,this.leftover+=g,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(d>=16&&(g=d-d%16,this.blocks(u,p,g),p+=g,d-=g),d){for(a=0;a<d;a++)this.buffer[this.leftover+a]=u[p+a];this.leftover+=d}};function W(u,p,d,a,g,x){var S=new te(x);return S.update(d,a,g),S.finish(u,p),0}function ve(u,p,d,a,g,x){var S=new Uint8Array(16);return W(S,0,d,a,g,x),y(u,p,S,0)}function Ce(u,p,d,a,g){var x;if(d<32)return-1;for(we(u,0,p,0,d,a,g),W(u,16,u,32,d-32,u),x=0;x<16;x++)u[x]=0;return 0}function Ve(u,p,d,a,g){var x,S=new Uint8Array(32);if(d<32||(K(S,0,32,a,g),ve(p,16,p,32,d-32,S)!==0))return-1;for(we(u,0,p,0,d,a,g),x=0;x<32;x++)u[x]=0;return 0}function _(u,p){var d;for(d=0;d<16;d++)u[d]=p[d]|0}function B(u){var p,d,a=1;for(p=0;p<16;p++)d=u[p]+a+65535,a=Math.floor(d/65536),u[p]=d-a*65536;u[0]+=a-1+37*(a-1)}function F(u,p,d){for(var a,g=~(d-1),x=0;x<16;x++)a=g&(u[x]^p[x]),u[x]^=a,p[x]^=a}function re(u,p){var d,a,g,x=t(),S=t();for(d=0;d<16;d++)S[d]=p[d];for(B(S),B(S),B(S),a=0;a<2;a++){for(x[0]=S[0]-65517,d=1;d<15;d++)x[d]=S[d]-65535-(x[d-1]>>16&1),x[d-1]&=65535;x[15]=S[15]-32767-(x[14]>>16&1),g=x[15]>>16&1,x[14]&=65535,F(S,x,1-g)}for(d=0;d<16;d++)u[2*d]=S[d]&255,u[2*d+1]=S[d]>>8}function ne(u,p){var d=new Uint8Array(32),a=new Uint8Array(32);return re(d,u),re(a,p),w(d,0,a,0)}function xe(u){var p=new Uint8Array(32);return re(p,u),p[0]&1}function ke(u,p){var d;for(d=0;d<16;d++)u[d]=p[2*d]+(p[2*d+1]<<8);u[15]&=32767}function Te(u,p,d){for(var a=0;a<16;a++)u[a]=p[a]+d[a]}function De(u,p,d){for(var a=0;a<16;a++)u[a]=p[a]-d[a]}function se(u,p,d){var a,g,x=0,S=0,O=0,q=0,ee=0,j=0,Re=0,Y=0,ce=0,ue=0,ge=0,pe=0,fe=0,le=0,de=0,Z=0,oe=0,Q=0,X=0,J=0,V=0,C=0,U=0,D=0,R=0,N=0,G=0,ie=0,me=0,he=0,ye=0,A=d[0],_e=d[1],Oe=d[2],Ne=d[3],be=d[4],Ue=d[5],Ie=d[6],nt=d[7],Me=d[8],We=d[9],Ye=d[10],Ze=d[11],at=d[12],gt=d[13],mt=d[14],yt=d[15];a=p[0],x+=a*A,S+=a*_e,O+=a*Oe,q+=a*Ne,ee+=a*be,j+=a*Ue,Re+=a*Ie,Y+=a*nt,ce+=a*Me,ue+=a*We,ge+=a*Ye,pe+=a*Ze,fe+=a*at,le+=a*gt,de+=a*mt,Z+=a*yt,a=p[1],S+=a*A,O+=a*_e,q+=a*Oe,ee+=a*Ne,j+=a*be,Re+=a*Ue,Y+=a*Ie,ce+=a*nt,ue+=a*Me,ge+=a*We,pe+=a*Ye,fe+=a*Ze,le+=a*at,de+=a*gt,Z+=a*mt,oe+=a*yt,a=p[2],O+=a*A,q+=a*_e,ee+=a*Oe,j+=a*Ne,Re+=a*be,Y+=a*Ue,ce+=a*Ie,ue+=a*nt,ge+=a*Me,pe+=a*We,fe+=a*Ye,le+=a*Ze,de+=a*at,Z+=a*gt,oe+=a*mt,Q+=a*yt,a=p[3],q+=a*A,ee+=a*_e,j+=a*Oe,Re+=a*Ne,Y+=a*be,ce+=a*Ue,ue+=a*Ie,ge+=a*nt,pe+=a*Me,fe+=a*We,le+=a*Ye,de+=a*Ze,Z+=a*at,oe+=a*gt,Q+=a*mt,X+=a*yt,a=p[4],ee+=a*A,j+=a*_e,Re+=a*Oe,Y+=a*Ne,ce+=a*be,ue+=a*Ue,ge+=a*Ie,pe+=a*nt,fe+=a*Me,le+=a*We,de+=a*Ye,Z+=a*Ze,oe+=a*at,Q+=a*gt,X+=a*mt,J+=a*yt,a=p[5],j+=a*A,Re+=a*_e,Y+=a*Oe,ce+=a*Ne,ue+=a*be,ge+=a*Ue,pe+=a*Ie,fe+=a*nt,le+=a*Me,de+=a*We,Z+=a*Ye,oe+=a*Ze,Q+=a*at,X+=a*gt,J+=a*mt,V+=a*yt,a=p[6],Re+=a*A,Y+=a*_e,ce+=a*Oe,ue+=a*Ne,ge+=a*be,pe+=a*Ue,fe+=a*Ie,le+=a*nt,de+=a*Me,Z+=a*We,oe+=a*Ye,Q+=a*Ze,X+=a*at,J+=a*gt,V+=a*mt,C+=a*yt,a=p[7],Y+=a*A,ce+=a*_e,ue+=a*Oe,ge+=a*Ne,pe+=a*be,fe+=a*Ue,le+=a*Ie,de+=a*nt,Z+=a*Me,oe+=a*We,Q+=a*Ye,X+=a*Ze,J+=a*at,V+=a*gt,C+=a*mt,U+=a*yt,a=p[8],ce+=a*A,ue+=a*_e,ge+=a*Oe,pe+=a*Ne,fe+=a*be,le+=a*Ue,de+=a*Ie,Z+=a*nt,oe+=a*Me,Q+=a*We,X+=a*Ye,J+=a*Ze,V+=a*at,C+=a*gt,U+=a*mt,D+=a*yt,a=p[9],ue+=a*A,ge+=a*_e,pe+=a*Oe,fe+=a*Ne,le+=a*be,de+=a*Ue,Z+=a*Ie,oe+=a*nt,Q+=a*Me,X+=a*We,J+=a*Ye,V+=a*Ze,C+=a*at,U+=a*gt,D+=a*mt,R+=a*yt,a=p[10],ge+=a*A,pe+=a*_e,fe+=a*Oe,le+=a*Ne,de+=a*be,Z+=a*Ue,oe+=a*Ie,Q+=a*nt,X+=a*Me,J+=a*We,V+=a*Ye,C+=a*Ze,U+=a*at,D+=a*gt,R+=a*mt,N+=a*yt,a=p[11],pe+=a*A,fe+=a*_e,le+=a*Oe,de+=a*Ne,Z+=a*be,oe+=a*Ue,Q+=a*Ie,X+=a*nt,J+=a*Me,V+=a*We,C+=a*Ye,U+=a*Ze,D+=a*at,R+=a*gt,N+=a*mt,G+=a*yt,a=p[12],fe+=a*A,le+=a*_e,de+=a*Oe,Z+=a*Ne,oe+=a*be,Q+=a*Ue,X+=a*Ie,J+=a*nt,V+=a*Me,C+=a*We,U+=a*Ye,D+=a*Ze,R+=a*at,N+=a*gt,G+=a*mt,ie+=a*yt,a=p[13],le+=a*A,de+=a*_e,Z+=a*Oe,oe+=a*Ne,Q+=a*be,X+=a*Ue,J+=a*Ie,V+=a*nt,C+=a*Me,U+=a*We,D+=a*Ye,R+=a*Ze,N+=a*at,G+=a*gt,ie+=a*mt,me+=a*yt,a=p[14],de+=a*A,Z+=a*_e,oe+=a*Oe,Q+=a*Ne,X+=a*be,J+=a*Ue,V+=a*Ie,C+=a*nt,U+=a*Me,D+=a*We,R+=a*Ye,N+=a*Ze,G+=a*at,ie+=a*gt,me+=a*mt,he+=a*yt,a=p[15],Z+=a*A,oe+=a*_e,Q+=a*Oe,X+=a*Ne,J+=a*be,V+=a*Ue,C+=a*Ie,U+=a*nt,D+=a*Me,R+=a*We,N+=a*Ye,G+=a*Ze,ie+=a*at,me+=a*gt,he+=a*mt,ye+=a*yt,x+=38*oe,S+=38*Q,O+=38*X,q+=38*J,ee+=38*V,j+=38*C,Re+=38*U,Y+=38*D,ce+=38*R,ue+=38*N,ge+=38*G,pe+=38*ie,fe+=38*me,le+=38*he,de+=38*ye,g=1,a=x+g+65535,g=Math.floor(a/65536),x=a-g*65536,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=O+g+65535,g=Math.floor(a/65536),O=a-g*65536,a=q+g+65535,g=Math.floor(a/65536),q=a-g*65536,a=ee+g+65535,g=Math.floor(a/65536),ee=a-g*65536,a=j+g+65535,g=Math.floor(a/65536),j=a-g*65536,a=Re+g+65535,g=Math.floor(a/65536),Re=a-g*65536,a=Y+g+65535,g=Math.floor(a/65536),Y=a-g*65536,a=ce+g+65535,g=Math.floor(a/65536),ce=a-g*65536,a=ue+g+65535,g=Math.floor(a/65536),ue=a-g*65536,a=ge+g+65535,g=Math.floor(a/65536),ge=a-g*65536,a=pe+g+65535,g=Math.floor(a/65536),pe=a-g*65536,a=fe+g+65535,g=Math.floor(a/65536),fe=a-g*65536,a=le+g+65535,g=Math.floor(a/65536),le=a-g*65536,a=de+g+65535,g=Math.floor(a/65536),de=a-g*65536,a=Z+g+65535,g=Math.floor(a/65536),Z=a-g*65536,x+=g-1+37*(g-1),g=1,a=x+g+65535,g=Math.floor(a/65536),x=a-g*65536,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=O+g+65535,g=Math.floor(a/65536),O=a-g*65536,a=q+g+65535,g=Math.floor(a/65536),q=a-g*65536,a=ee+g+65535,g=Math.floor(a/65536),ee=a-g*65536,a=j+g+65535,g=Math.floor(a/65536),j=a-g*65536,a=Re+g+65535,g=Math.floor(a/65536),Re=a-g*65536,a=Y+g+65535,g=Math.floor(a/65536),Y=a-g*65536,a=ce+g+65535,g=Math.floor(a/65536),ce=a-g*65536,a=ue+g+65535,g=Math.floor(a/65536),ue=a-g*65536,a=ge+g+65535,g=Math.floor(a/65536),ge=a-g*65536,a=pe+g+65535,g=Math.floor(a/65536),pe=a-g*65536,a=fe+g+65535,g=Math.floor(a/65536),fe=a-g*65536,a=le+g+65535,g=Math.floor(a/65536),le=a-g*65536,a=de+g+65535,g=Math.floor(a/65536),de=a-g*65536,a=Z+g+65535,g=Math.floor(a/65536),Z=a-g*65536,x+=g-1+37*(g-1),u[0]=x,u[1]=S,u[2]=O,u[3]=q,u[4]=ee,u[5]=j,u[6]=Re,u[7]=Y,u[8]=ce,u[9]=ue,u[10]=ge,u[11]=pe,u[12]=fe,u[13]=le,u[14]=de,u[15]=Z}function Ke(u,p){se(u,p,p)}function St(u,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=253;a>=0;a--)Ke(d,d),a!==2&&a!==4&&se(d,d,p);for(a=0;a<16;a++)u[a]=d[a]}function ot(u,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=250;a>=0;a--)Ke(d,d),a!==1&&se(d,d,p);for(a=0;a<16;a++)u[a]=d[a]}function kt(u,p,d){var a=new Uint8Array(32),g=new Float64Array(80),x,S,O=t(),q=t(),ee=t(),j=t(),Re=t(),Y=t();for(S=0;S<31;S++)a[S]=p[S];for(a[31]=p[31]&127|64,a[0]&=248,ke(g,d),S=0;S<16;S++)q[S]=g[S],j[S]=O[S]=ee[S]=0;for(O[0]=j[0]=1,S=254;S>=0;--S)x=a[S>>>3]>>>(S&7)&1,F(O,q,x),F(ee,j,x),Te(Re,O,ee),De(O,O,ee),Te(ee,q,j),De(q,q,j),Ke(j,Re),Ke(Y,O),se(O,ee,O),se(ee,q,Re),Te(Re,O,ee),De(O,O,ee),Ke(q,O),De(ee,j,Y),se(O,ee,c),Te(O,O,j),se(ee,ee,O),se(O,j,Y),se(j,q,g),Ke(q,Re),F(O,q,x),F(ee,j,x);for(S=0;S<16;S++)g[S+16]=O[S],g[S+32]=ee[S],g[S+48]=q[S],g[S+64]=j[S];var ce=g.subarray(32),ue=g.subarray(16);return St(ce,ce),se(ue,ue,ce),re(u,ue),0}function st(u,p){return kt(u,p,o)}function pt(u,p){return e(p,32),st(u,p)}function ar(u,p,d){var a=new Uint8Array(32);return kt(a,d,p),$(u,n,a,M)}var Fe=Ce,xt=Ve;function Qt(u,p,d,a,g,x){var S=new Uint8Array(32);return ar(S,g,x),Fe(u,p,d,a,S)}function hn(u,p,d,a,g,x){var S=new Uint8Array(32);return ar(S,g,x),xt(u,p,d,a,S)}var qr=[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];function Ru(u,p,d,a){for(var g=new Int32Array(16),x=new Int32Array(16),S,O,q,ee,j,Re,Y,ce,ue,ge,pe,fe,le,de,Z,oe,Q,X,J,V,C,U,D,R,N,G,ie=u[0],me=u[1],he=u[2],ye=u[3],A=u[4],_e=u[5],Oe=u[6],Ne=u[7],be=p[0],Ue=p[1],Ie=p[2],nt=p[3],Me=p[4],We=p[5],Ye=p[6],Ze=p[7],at=0;a>=128;){for(J=0;J<16;J++)V=8*J+at,g[J]=d[V+0]<<24|d[V+1]<<16|d[V+2]<<8|d[V+3],x[J]=d[V+4]<<24|d[V+5]<<16|d[V+6]<<8|d[V+7];for(J=0;J<80;J++)if(S=ie,O=me,q=he,ee=ye,j=A,Re=_e,Y=Oe,ce=Ne,ue=be,ge=Ue,pe=Ie,fe=nt,le=Me,de=We,Z=Ye,oe=Ze,C=Ne,U=Ze,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=(A>>>14|Me<<18)^(A>>>18|Me<<14)^(Me>>>9|A<<23),U=(Me>>>14|A<<18)^(Me>>>18|A<<14)^(A>>>9|Me<<23),D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,C=A&_e^~A&Oe,U=Me&We^~Me&Ye,D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,C=qr[J*2],U=qr[J*2+1],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,C=g[J%16],U=x[J%16],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,Q=N&65535|G<<16,X=D&65535|R<<16,C=Q,U=X,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=(ie>>>28|be<<4)^(be>>>2|ie<<30)^(be>>>7|ie<<25),U=(be>>>28|ie<<4)^(ie>>>2|be<<30)^(ie>>>7|be<<25),D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,C=ie&me^ie&he^me&he,U=be&Ue^be&Ie^Ue&Ie,D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,ce=N&65535|G<<16,oe=D&65535|R<<16,C=ee,U=fe,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=Q,U=X,D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,ee=N&65535|G<<16,fe=D&65535|R<<16,me=S,he=O,ye=q,A=ee,_e=j,Oe=Re,Ne=Y,ie=ce,Ue=ue,Ie=ge,nt=pe,Me=fe,We=le,Ye=de,Ze=Z,be=oe,J%16===15)for(V=0;V<16;V++)C=g[V],U=x[V],D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=g[(V+9)%16],U=x[(V+9)%16],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,Q=g[(V+1)%16],X=x[(V+1)%16],C=(Q>>>1|X<<31)^(Q>>>8|X<<24)^Q>>>7,U=(X>>>1|Q<<31)^(X>>>8|Q<<24)^(X>>>7|Q<<25),D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,Q=g[(V+14)%16],X=x[(V+14)%16],C=(Q>>>19|X<<13)^(X>>>29|Q<<3)^Q>>>6,U=(X>>>19|Q<<13)^(Q>>>29|X<<3)^(X>>>6|Q<<26),D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,g[V]=N&65535|G<<16,x[V]=D&65535|R<<16;C=ie,U=be,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[0],U=p[0],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[0]=ie=N&65535|G<<16,p[0]=be=D&65535|R<<16,C=me,U=Ue,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[1],U=p[1],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[1]=me=N&65535|G<<16,p[1]=Ue=D&65535|R<<16,C=he,U=Ie,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[2],U=p[2],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[2]=he=N&65535|G<<16,p[2]=Ie=D&65535|R<<16,C=ye,U=nt,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[3],U=p[3],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[3]=ye=N&65535|G<<16,p[3]=nt=D&65535|R<<16,C=A,U=Me,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[4],U=p[4],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[4]=A=N&65535|G<<16,p[4]=Me=D&65535|R<<16,C=_e,U=We,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[5],U=p[5],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[5]=_e=N&65535|G<<16,p[5]=We=D&65535|R<<16,C=Oe,U=Ye,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[6],U=p[6],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[6]=Oe=N&65535|G<<16,p[6]=Ye=D&65535|R<<16,C=Ne,U=Ze,D=U&65535,R=U>>>16,N=C&65535,G=C>>>16,C=u[7],U=p[7],D+=U&65535,R+=U>>>16,N+=C&65535,G+=C>>>16,R+=D>>>16,N+=R>>>16,G+=N>>>16,u[7]=Ne=N&65535|G<<16,p[7]=Ze=D&65535|R<<16,at+=128,a-=128}return a}function An(u,p,d){var a=new Int32Array(8),g=new Int32Array(8),x=new Uint8Array(256),S,O=d;for(a[0]=1779033703,a[1]=3144134277,a[2]=1013904242,a[3]=2773480762,a[4]=1359893119,a[5]=2600822924,a[6]=528734635,a[7]=1541459225,g[0]=4089235720,g[1]=2227873595,g[2]=4271175723,g[3]=1595750129,g[4]=2917565137,g[5]=725511199,g[6]=4215389547,g[7]=327033209,Ru(a,g,p,d),d%=128,S=0;S<d;S++)x[S]=p[O-d+S];for(x[d]=128,d=256-128*(d<112?1:0),x[d-9]=0,v(x,d-8,O/536870912|0,O<<3),Ru(a,g,x,d),S=0;S<8;S++)v(u,8*S,a[S],g[S]);return 0}function Ns(u,p){var d=t(),a=t(),g=t(),x=t(),S=t(),O=t(),q=t(),ee=t(),j=t();De(d,u[1],u[0]),De(j,p[1],p[0]),se(d,d,j),Te(a,u[0],u[1]),Te(j,p[0],p[1]),se(a,a,j),se(g,u[3],p[3]),se(g,g,l),se(x,u[2],p[2]),Te(x,x,x),De(S,a,d),De(O,x,g),Te(q,x,g),Te(ee,a,d),se(u[0],S,O),se(u[1],ee,q),se(u[2],q,O),se(u[3],S,ee)}function Ou(u,p,d){var a;for(a=0;a<4;a++)F(u[a],p[a],d)}function pa(u,p){var d=t(),a=t(),g=t();St(g,p[2]),se(d,p[0],g),se(a,p[1],g),re(u,a),u[31]^=xe(d)<<7}function ga(u,p,d){var a,g;for(_(u[0],s),_(u[1],i),_(u[2],i),_(u[3],s),g=255;g>=0;--g)a=d[g/8|0]>>(g&7)&1,Ou(u,p,a),Ns(p,u),Ns(u,u),Ou(u,p,a)}function ks(u,p){var d=[t(),t(),t(),t()];_(d[0],h),_(d[1],m),_(d[2],i),se(d[3],h,m),ga(u,d,p)}function ma(u,p,d){var a=new Uint8Array(64),g=[t(),t(),t(),t()],x;for(d||e(p,32),An(a,p,32),a[0]&=248,a[31]&=127,a[31]|=64,ks(g,a),pa(u,g),x=0;x<32;x++)p[x+32]=u[x];return 0}var zs=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ya(u,p){var d,a,g,x;for(a=63;a>=32;--a){for(d=0,g=a-32,x=a-12;g<x;++g)p[g]+=d-16*p[a]*zs[g-(a-32)],d=Math.floor((p[g]+128)/256),p[g]-=d*256;p[g]+=d,p[a]=0}for(d=0,g=0;g<32;g++)p[g]+=d-(p[31]>>4)*zs[g],d=p[g]>>8,p[g]&=255;for(g=0;g<32;g++)p[g]-=d*zs[g];for(a=0;a<32;a++)p[a+1]+=p[a]>>8,u[a]=p[a]&255}function ha(u){var p=new Float64Array(64),d;for(d=0;d<64;d++)p[d]=u[d];for(d=0;d<64;d++)u[d]=0;ya(u,p)}function Nu(u,p,d,a){var g=new Uint8Array(64),x=new Uint8Array(64),S=new Uint8Array(64),O,q,ee=new Float64Array(64),j=[t(),t(),t(),t()];An(g,a,32),g[0]&=248,g[31]&=127,g[31]|=64;var Re=d+64;for(O=0;O<d;O++)u[64+O]=p[O];for(O=0;O<32;O++)u[32+O]=g[32+O];for(An(S,u.subarray(32),d+32),ha(S),ks(j,S),pa(u,j),O=32;O<64;O++)u[O]=a[O];for(An(x,u,d+64),ha(x),O=0;O<64;O++)ee[O]=0;for(O=0;O<32;O++)ee[O]=S[O];for(O=0;O<32;O++)for(q=0;q<32;q++)ee[O+q]+=x[O]*g[q];return ya(u.subarray(32),ee),Re}function kp(u,p){var d=t(),a=t(),g=t(),x=t(),S=t(),O=t(),q=t();return _(u[2],i),ke(u[1],p),Ke(g,u[1]),se(x,g,f),De(g,g,u[2]),Te(x,u[2],x),Ke(S,x),Ke(O,S),se(q,O,S),se(d,q,g),se(d,d,x),ot(d,d),se(d,d,g),se(d,d,x),se(d,d,x),se(u[0],d,x),Ke(a,u[0]),se(a,a,x),ne(a,g)&&se(u[0],u[0],T),Ke(a,u[0]),se(a,a,x),ne(a,g)?-1:(xe(u[0])===p[31]>>7&&De(u[0],s,u[0]),se(u[3],u[0],u[1]),0)}function Aa(u,p,d,a){var g,x=new Uint8Array(32),S=new Uint8Array(64),O=[t(),t(),t(),t()],q=[t(),t(),t(),t()];if(d<64||kp(q,a))return-1;for(g=0;g<d;g++)u[g]=p[g];for(g=0;g<32;g++)u[g+32]=a[g];if(An(S,u,d),ha(S),ga(O,q,S),ks(q,p.subarray(32)),Ns(O,q),pa(x,O),d-=64,w(p,0,x,0)){for(g=0;g<d;g++)u[g]=0;return-1}for(g=0;g<d;g++)u[g]=p[g+64];return d}var xa=32,Ds=24,zo=32,so=16,Do=32,Ms=32,Mo=32,Go=32,ba=32,ku=Ds,zp=zo,Dp=so,wr=64,xn=32,io=64,wa=32,Ta=64;r.lowlevel={crypto_core_hsalsa20:$,crypto_stream_xor:we,crypto_stream:K,crypto_stream_salsa20_xor:z,crypto_stream_salsa20:L,crypto_onetimeauth:W,crypto_onetimeauth_verify:ve,crypto_verify_16:y,crypto_verify_32:w,crypto_secretbox:Ce,crypto_secretbox_open:Ve,crypto_scalarmult:kt,crypto_scalarmult_base:st,crypto_box_beforenm:ar,crypto_box_afternm:Fe,crypto_box:Qt,crypto_box_open:hn,crypto_box_keypair:pt,crypto_hash:An,crypto_sign:Nu,crypto_sign_keypair:ma,crypto_sign_open:Aa,crypto_secretbox_KEYBYTES:xa,crypto_secretbox_NONCEBYTES:Ds,crypto_secretbox_ZEROBYTES:zo,crypto_secretbox_BOXZEROBYTES:so,crypto_scalarmult_BYTES:Do,crypto_scalarmult_SCALARBYTES:Ms,crypto_box_PUBLICKEYBYTES:Mo,crypto_box_SECRETKEYBYTES:Go,crypto_box_BEFORENMBYTES:ba,crypto_box_NONCEBYTES:ku,crypto_box_ZEROBYTES:zp,crypto_box_BOXZEROBYTES:Dp,crypto_sign_BYTES:wr,crypto_sign_PUBLICKEYBYTES:xn,crypto_sign_SECRETKEYBYTES:io,crypto_sign_SEEDBYTES:wa,crypto_hash_BYTES:Ta,gf:t,D:f,L:zs,pack25519:re,unpack25519:ke,M:se,A:Te,S:Ke,Z:De,pow2523:ot,add:Ns,set25519:_,modL:ya,scalarmult:ga,scalarbase:ks};function zu(u,p){if(u.length!==xa)throw new Error("bad key size");if(p.length!==Ds)throw new Error("bad nonce size")}function Mp(u,p){if(u.length!==Mo)throw new Error("bad public key size");if(p.length!==Go)throw new Error("bad secret key size")}function Ct(){for(var u=0;u<arguments.length;u++)if(!(arguments[u]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Du(u){for(var p=0;p<u.length;p++)u[p]=0}r.randomBytes=function(u){var p=new Uint8Array(u);return e(p,u),p},r.secretbox=function(u,p,d){Ct(u,p,d),zu(d,p);for(var a=new Uint8Array(zo+u.length),g=new Uint8Array(a.length),x=0;x<u.length;x++)a[x+zo]=u[x];return Ce(g,a,a.length,p,d),g.subarray(so)},r.secretbox.open=function(u,p,d){Ct(u,p,d),zu(d,p);for(var a=new Uint8Array(so+u.length),g=new Uint8Array(a.length),x=0;x<u.length;x++)a[x+so]=u[x];return a.length<32||Ve(g,a,a.length,p,d)!==0?null:g.subarray(zo)},r.secretbox.keyLength=xa,r.secretbox.nonceLength=Ds,r.secretbox.overheadLength=so,r.scalarMult=function(u,p){if(Ct(u,p),u.length!==Ms)throw new Error("bad n size");if(p.length!==Do)throw new Error("bad p size");var d=new Uint8Array(Do);return kt(d,u,p),d},r.scalarMult.base=function(u){if(Ct(u),u.length!==Ms)throw new Error("bad n size");var p=new Uint8Array(Do);return st(p,u),p},r.scalarMult.scalarLength=Ms,r.scalarMult.groupElementLength=Do,r.box=function(u,p,d,a){var g=r.box.before(d,a);return r.secretbox(u,p,g)},r.box.before=function(u,p){Ct(u,p),Mp(u,p);var d=new Uint8Array(ba);return ar(d,u,p),d},r.box.after=r.secretbox,r.box.open=function(u,p,d,a){var g=r.box.before(d,a);return r.secretbox.open(u,p,g)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var u=new Uint8Array(Mo),p=new Uint8Array(Go);return pt(u,p),{publicKey:u,secretKey:p}},r.box.keyPair.fromSecretKey=function(u){if(Ct(u),u.length!==Go)throw new Error("bad secret key size");var p=new Uint8Array(Mo);return st(p,u),{publicKey:p,secretKey:new Uint8Array(u)}},r.box.publicKeyLength=Mo,r.box.secretKeyLength=Go,r.box.sharedKeyLength=ba,r.box.nonceLength=ku,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(u,p){if(Ct(u,p),p.length!==io)throw new Error("bad secret key size");var d=new Uint8Array(wr+u.length);return Nu(d,u,u.length,p),d},r.sign.open=function(u,p){if(Ct(u,p),p.length!==xn)throw new Error("bad public key size");var d=new Uint8Array(u.length),a=Aa(d,u,u.length,p);if(a<0)return null;for(var g=new Uint8Array(a),x=0;x<g.length;x++)g[x]=d[x];return g},r.sign.detached=function(u,p){for(var d=r.sign(u,p),a=new Uint8Array(wr),g=0;g<a.length;g++)a[g]=d[g];return a},r.sign.detached.verify=function(u,p,d){if(Ct(u,p,d),p.length!==wr)throw new Error("bad signature size");if(d.length!==xn)throw new Error("bad public key size");var a=new Uint8Array(wr+u.length),g=new Uint8Array(wr+u.length),x;for(x=0;x<wr;x++)a[x]=p[x];for(x=0;x<u.length;x++)a[x+wr]=u[x];return Aa(g,a,a.length,d)>=0},r.sign.keyPair=function(){var u=new Uint8Array(xn),p=new Uint8Array(io);return ma(u,p),{publicKey:u,secretKey:p}},r.sign.keyPair.fromSecretKey=function(u){if(Ct(u),u.length!==io)throw new Error("bad secret key size");for(var p=new Uint8Array(xn),d=0;d<p.length;d++)p[d]=u[32+d];return{publicKey:p,secretKey:new Uint8Array(u)}},r.sign.keyPair.fromSeed=function(u){if(Ct(u),u.length!==wa)throw new Error("bad seed size");for(var p=new Uint8Array(xn),d=new Uint8Array(io),a=0;a<32;a++)d[a]=u[a];return ma(p,d,!0),{publicKey:p,secretKey:d}},r.sign.publicKeyLength=xn,r.sign.secretKeyLength=io,r.sign.seedLength=wa,r.sign.signatureLength=wr,r.hash=function(u){Ct(u);var p=new Uint8Array(Ta);return An(p,u,u.length),p},r.hash.hashLength=Ta,r.verify=function(u,p){return Ct(u,p),u.length===0||p.length===0||u.length!==p.length?!1:b(u,0,p,0,u.length)===0},r.setPRNG=function(u){e=u},function(){var u=typeof self<"u"?self.crypto||self.msCrypto:null;if(u&&u.getRandomValues){var p=65536;r.setPRNG(function(d,a){var g,x=new Uint8Array(a);for(g=0;g<a;g+=p)u.getRandomValues(x.subarray(g,g+Math.min(a-g,p)));for(g=0;g<a;g++)d[g]=x[g];Du(x)})}else typeof Gu<"u"&&(u=df(),u&&u.randomBytes&&r.setPRNG(function(d,a){var g,x=u.randomBytes(a);for(g=0;g<a;g++)d[g]=x[g];Du(x)}))}()})(typeof ti<"u"&&ti.exports?ti.exports:self.nacl=self.nacl||{})});var Ph={};Gs(Ph,{APTOS_BIP44_REGEX:()=>hf,APTOS_COIN:()=>$o,APTOS_HARDENED_REGEX:()=>yf,Account:()=>Dr,AccountAddress:()=>H,AccountAuthenticator:()=>vt,AccountAuthenticatorEd25519:()=>mr,AccountAuthenticatorMultiEd25519:()=>ps,AccountAuthenticatorMultiKey:()=>Ln,AccountAuthenticatorSingleKey:()=>sr,AccountAuthenticatorVariant:()=>Ca,AccountSequenceNumber:()=>Ps,AddressInvalidReason:()=>rf,AnyPublicKey:()=>je,AnyPublicKeyVariant:()=>Ua,AnySignature:()=>lr,AnySignatureVariant:()=>Ia,Aptos:()=>Nt,AptosApiError:()=>cr,AptosApiType:()=>Ho,AptosConfig:()=>ds,AuthenticationKey:()=>or,Bool:()=>Xe,CKDPriv:()=>ec,ChainId:()=>$n,DEFAULT_MAX_GAS_AMOUNT:()=>Na,DEFAULT_NETWORK:()=>Oa,DEFAULT_TXN_EXP_SEC_FROM_NOW:()=>ka,DEFAULT_TXN_TIMEOUT_SEC:()=>Fo,DeriveScheme:()=>Vu,Deserializer:()=>Qa,Ed25519PrivateKey:()=>Ur,Ed25519PublicKey:()=>qe,Ed25519Signature:()=>Je,EntryFunction:()=>ro,EntryFunctionBytes:()=>Qo,FeePayerRawTransaction:()=>xr,FixedBytes:()=>$r,HARDENED_OFFSET:()=>Za,Hex:()=>Be,HexInvalidReason:()=>ef,Identifier:()=>Qe,KeyType:()=>Af,MimeType:()=>Ls,ModuleId:()=>So,MoveAbility:()=>Fu,MoveFunctionVisibility:()=>Hu,MoveOption:()=>Cr,MoveString:()=>ht,MoveVector:()=>Le,MultiAgentRawTransaction:()=>Ar,MultiEd25519PublicKey:()=>er,MultiEd25519Signature:()=>Bn,MultiKey:()=>Gn,MultiSig:()=>Io,MultiSigTransactionPayload:()=>Bo,Network:()=>Ko,NetworkToChainId:()=>Hs,NetworkToFaucetAPI:()=>Ra,NetworkToIndexerAPI:()=>Ks,NetworkToNetworkName:()=>tg,NetworkToNodeAPI:()=>Pa,ParsingError:()=>bt,PrivateKey:()=>Un,ProcessorType:()=>bn,PublicKey:()=>It,RAW_TRANSACTION_SALT:()=>za,RAW_TRANSACTION_WITH_DATA_SALT:()=>Fs,RawTransaction:()=>Vt,RawTransactionWithData:()=>ms,RoleType:()=>$u,RotationProofChallenge:()=>ls,Script:()=>Uo,ScriptTransactionArgumentVariants:()=>ao,Secp256k1PrivateKey:()=>Nr,Secp256k1PublicKey:()=>Ft,Secp256k1Signature:()=>kr,Serializable:()=>ae,Serializer:()=>Zt,Signature:()=>Jt,SignedTransaction:()=>ir,SigningScheme:()=>co,SigningSchemeInput:()=>Ba,StructTag:()=>hr,TransactionAuthenticator:()=>yr,TransactionAuthenticatorEd25519:()=>qn,TransactionAuthenticatorFeePayer:()=>Hn,TransactionAuthenticatorMultiAgent:()=>Kn,TransactionAuthenticatorMultiEd25519:()=>ji,TransactionAuthenticatorSingleSender:()=>Fn,TransactionAuthenticatorVariant:()=>va,TransactionPayload:()=>gn,TransactionPayloadEntryFunction:()=>vo,TransactionPayloadMultiSig:()=>Co,TransactionPayloadScript:()=>Eo,TransactionPayloadVariants:()=>Sa,TransactionResponseType:()=>qs,TransactionVariants:()=>Ea,TransactionWorker:()=>Rs,TypeTag:()=>rt,TypeTagAddress:()=>Jn,TypeTagBool:()=>Vn,TypeTagGeneric:()=>eo,TypeTagParserError:()=>He,TypeTagParserErrorType:()=>Nl,TypeTagReference:()=>gs,TypeTagSigner:()=>pn,TypeTagStruct:()=>Gr,TypeTagU128:()=>Zn,TypeTagU16:()=>Qn,TypeTagU256:()=>Xn,TypeTagU32:()=>Wn,TypeTagU64:()=>Yn,TypeTagU8:()=>jn,TypeTagVariants:()=>_a,TypeTagVector:()=>to,U128:()=>Mt,U16:()=>zt,U256:()=>Gt,U32:()=>Dt,U64:()=>ft,U8:()=>lt,aptosCoinStructTag:()=>mh,aptosRequest:()=>qo,buildTransaction:()=>sa,checkOrConvertArgument:()=>oo,convertArgument:()=>Au,deriveKey:()=>ni,deriveTransactionType:()=>Tu,deserializeFromScriptArgument:()=>Pl,ensureBoolean:()=>Ys,fetchEntryFunctionAbi:()=>hu,findFirstNonSignerArg:()=>gu,generateMultiSignersSignedTransaction:()=>Gl,generateRawTransaction:()=>Ml,generateSignedTransaction:()=>wu,generateSignedTransactionForSimulation:()=>xu,generateSigningMessage:()=>ia,generateTransactionPayload:()=>bs,generateTransactionPayloadWithABI:()=>zl,get:()=>Da,getAptosFullNode:()=>Ut,getAuthenticatorForSimulation:()=>xs,getFunctionParts:()=>oa,isBcsAddress:()=>As,isBcsBool:()=>Wi,isBcsFixedBytes:()=>kl,isBcsString:()=>Yi,isBcsU128:()=>ta,isBcsU16:()=>Xi,isBcsU256:()=>ra,isBcsU32:()=>Ji,isBcsU64:()=>ea,isBcsU8:()=>Zi,isBlockMetadataTransactionResponse:()=>Qp,isBool:()=>du,isEd25519Signature:()=>Yp,isEncodedEntryFunctionArgument:()=>pu,isFeePayerSignature:()=>Jp,isGenesisTransactionResponse:()=>jp,isLargeNumber:()=>hs,isMultiAgentSignature:()=>Xp,isMultiEd25519Signature:()=>eg,isNull:()=>lu,isNumber:()=>ys,isPendingTransactionResponse:()=>$p,isScriptDataInput:()=>na,isSecp256k1Signature:()=>Zp,isStateCheckpointTransactionResponse:()=>Wp,isString:()=>no,isUserTransactionResponse:()=>Vp,isValidBIP44Path:()=>Xa,isValidHardenedPath:()=>Ja,mnemonicToSeed:()=>Yo,objectStructTag:()=>Ah,optionStructTag:()=>hh,outOfRangeErrorMessage:()=>tf,paginateWithCursor:()=>wn,parseTypeTag:()=>Po,post:()=>$s,postAptosFaucet:()=>Ga,postAptosFullNode:()=>Tn,postAptosIndexer:()=>Ma,request:()=>Qu,sign:()=>bu,splitPath:()=>tc,standardizeTypeTags:()=>yu,stringStructTag:()=>yh,throwTypeMismatch:()=>$e,validateNumberInRange:()=>Sr});var cr=class extends Error{constructor(e,n,o){super(o);this.name="AptosApiError",this.url=n.url,this.status=n.status,this.statusText=n.statusText,this.data=n.data,this.request=e}};var Ku="1.4.0";var Ls=(n=>(n.JSON="application/json",n.BCS="application/x-bcs",n.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",n))(Ls||{}),_a=(v=>(v[v.Bool=0]="Bool",v[v.U8=1]="U8",v[v.U64=2]="U64",v[v.U128=3]="U128",v[v.Address=4]="Address",v[v.Signer=5]="Signer",v[v.Vector=6]="Vector",v[v.Struct=7]="Struct",v[v.U16=8]="U16",v[v.U32=9]="U32",v[v.U256=10]="U256",v[v.Reference=254]="Reference",v[v.Generic=255]="Generic",v))(_a||{}),ao=(l=>(l[l.U8=0]="U8",l[l.U64=1]="U64",l[l.U128=2]="U128",l[l.Address=3]="Address",l[l.U8Vector=4]="U8Vector",l[l.Bool=5]="Bool",l[l.U16=6]="U16",l[l.U32=7]="U32",l[l.U256=8]="U256",l))(ao||{}),Sa=(n=>(n[n.Script=0]="Script",n[n.EntryFunction=2]="EntryFunction",n[n.Multisig=3]="Multisig",n))(Sa||{}),Ea=(e=>(e[e.MultiAgentTransaction=0]="MultiAgentTransaction",e[e.FeePayerTransaction=1]="FeePayerTransaction",e))(Ea||{}),va=(s=>(s[s.Ed25519=0]="Ed25519",s[s.MultiEd25519=1]="MultiEd25519",s[s.MultiAgent=2]="MultiAgent",s[s.FeePayer=3]="FeePayer",s[s.SingleSender=4]="SingleSender",s))(va||{}),Ca=(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Ca||{}),Ua=(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Ua||{}),Ia=(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Ia||{}),qs=(s=>(s.Pending="pending_transaction",s.User="user_transaction",s.Genesis="genesis_transaction",s.BlockMetadata="block_metadata_transaction",s.StateCheckpoint="state_checkpoint_transaction",s))(qs||{});function $p(r){return r.type==="pending_transaction"}function Vp(r){return r.type==="user_transaction"}function jp(r){return r.type==="genesis_transaction"}function Qp(r){return r.type==="block_metadata_transaction"}function Wp(r){return r.type==="state_checkpoint_transaction"}function Yp(r){return"signature"in r&&r.signature==="ed25519_signature"}function Zp(r){return"signature"in r&&r.signature==="secp256k1_ecdsa_signature"}function Xp(r){return r.type==="multi_agent_signature"}function Jp(r){return r.type==="fee_payer_signature"}function eg(r){return r.type==="multi_ed25519_signature"}var Hu=(n=>(n.PRIVATE="private",n.PUBLIC="public",n.FRIEND="friend",n))(Hu||{}),Fu=(o=>(o.STORE="store",o.DROP="drop",o.KEY="key",o.COPY="copy",o))(Fu||{}),$u=(e=>(e.VALIDATOR="validator",e.FULL_NODE="full_node",e))($u||{}),co=(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(co||{}),Ba=(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",e))(Ba||{}),Vu=(s=>(s[s.DeriveAuid=251]="DeriveAuid",s[s.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",s[s.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",s[s.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",s[s.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",s))(Vu||{});var ju={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable"};async function Qu(r,t){let{url:e,method:n,body:o,contentType:s,params:i,overrides:c}=r,f={...c?.HEADERS,"x-aptos-client":`aptos-typescript-sdk/${Ku}`,"content-type":s??"application/json"};return c?.AUTH_TOKEN&&e.includes("faucet")&&(f.Authorization=`Bearer ${c?.AUTH_TOKEN}`),c?.API_KEY&&!e.includes("faucet")&&(f.Authorization=`Bearer ${c?.API_KEY}`),t.provider({url:e,method:n,body:o,params:i,headers:f,overrides:c})}async function qo(r,t){let{url:e,path:n}=r,o=`${e}/${n??""}`,s=await Qu({...r,url:o},t.client),i={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(t.isIndexerRequest(e)){let f=i.data;if(f.errors)throw new cr(r,i,f.errors[0].message??`Unhandled Error ${s.status} : ${s.statusText}`);i.data=f.data}if(i.status>=200&&i.status<300)return i;let c;throw i&&i.data&&"message"in i.data&&"error_code"in i.data?c=JSON.stringify(i.data):i.status in ju?c=ju[i.status]:c=`Unhandled Error ${i.status} : ${i.statusText}`,new cr(r,i,c)}var Ks={mainnet:"https://indexer.mainnet.aptoslabs.com/v1/graphql",testnet:"https://indexer-testnet.staging.gcp.aptosdev.com/v1/graphql",devnet:"https://indexer-devnet.staging.gcp.aptosdev.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Pa={mainnet:"https://fullnode.mainnet.aptoslabs.com/v1",testnet:"https://fullnode.testnet.aptoslabs.com/v1",devnet:"https://fullnode.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},Ra={mainnet:"https://faucet.mainnet.aptoslabs.com",testnet:"https://faucet.testnet.aptoslabs.com",devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},Ko=(s=>(s.MAINNET="mainnet",s.TESTNET="testnet",s.DEVNET="devnet",s.LOCAL="local",s.CUSTOM="custom",s))(Ko||{}),Hs={mainnet:1,testnet:2},tg={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var Ho=(n=>(n[n.FULLNODE=0]="FULLNODE",n[n.INDEXER=1]="INDEXER",n[n.FAUCET=2]="FAUCET",n))(Ho||{}),Oa="devnet",Na=2e5,ka=20,Fo=20,$o="0x1::aptos_coin::AptosCoin",za="APTOS::RawTransaction",Fs="APTOS::RawTransactionWithData",bn=(c=>(c.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",c.DEFAULT="default_processor",c.EVENTS_PROCESSOR="events_processor",c.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",c.STAKE_PROCESSOR="stake_processor",c.TOKEN_V2_PROCESSOR="token_v2_processor",c.USER_TRANSACTION_PROCESSOR="user_transaction_processor",c))(bn||{});async function Da(r){let{aptosConfig:t,overrides:e,params:n,contentType:o,acceptType:s,path:i,originMethod:c,type:f}=r,l=t.getRequestUrl(f);return qo({url:l,method:"GET",originMethod:c,path:i,contentType:o?.valueOf(),acceptType:s?.valueOf(),params:n,overrides:{...t.clientConfig,...e}},t)}async function Ut(r){return Da({...r,type:0})}async function wn(r){let t=[],e,n=r.params;for(;;){n.start=e;let o=await Da({type:0,aptosConfig:r.aptosConfig,originMethod:r.originMethod,path:r.path,params:n,overrides:r.overrides});if(e=o.headers["x-aptos-cursor"],delete o.headers,t.push(...o.data),e==null)break}return t}async function $s(r){let{type:t,originMethod:e,path:n,body:o,acceptType:s,contentType:i,params:c,aptosConfig:f,overrides:l}=r,h=f.getRequestUrl(t);return qo({url:h,method:"POST",originMethod:e,path:n,body:o,contentType:i?.valueOf(),acceptType:s?.valueOf(),params:c,overrides:{...f.clientConfig,...l}},f)}async function Tn(r){return $s({...r,type:0})}async function Ma(r){return $s({...r,type:1})}async function Ga(r){return $s({...r,type:2})}var Vs=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Yu=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4));function La(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var ur=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Wt=(r,t)=>r<<32-t|r>>>t,rg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!rg)throw new Error("Non little-endian hardware is not supported");var ng=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function _n(r){if(!La(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=ng[r[e]];return t}var Tr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Wu(r){if(r>=Tr._0&&r<=Tr._9)return r-Tr._0;if(r>=Tr._A&&r<=Tr._F)return r-(Tr._A-10);if(r>=Tr._a&&r<=Tr._f)return r-(Tr._a-10)}function uo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=Wu(r.charCodeAt(s)),c=Wu(r.charCodeAt(s+1));if(i===void 0||c===void 0){let f=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+c}return n}function qa(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Yt(r){if(typeof r=="string"&&(r=qa(r)),!La(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function Sn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];if(!La(o))throw new Error("Uint8Array expected");t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var Kr=class{clone(){return this._cloneInto()}},og={}.toString;function Zu(r,t){if(t!==void 0&&og.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,t)}function Hr(r){let t=n=>r().update(Yt(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Xu(r){let t=(n,o)=>r(o).update(Yt(n)).digest(),e=r({});return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=n=>r(n),t}function Ju(r=32){if(Vs&&typeof Vs.getRandomValues=="function")return Vs.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}var js=255,Qs=65535,_r=4294967295,En=18446744073709551615n,Vo=340282366920938463463374607431768211455n,Ws=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var bt=class extends Error{constructor(e,n){super(e);this.invalidReason=n}};var ef=(n=>(n.TOO_SHORT="too_short",n.INVALID_LENGTH="invalid_length",n.INVALID_HEX_CHARS="invalid_hex_chars",n))(ef||{}),Be=class r{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return _n(this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromString(t){let e=t;if(e.startsWith("0x")&&(e=e.slice(2)),e.length===0)throw new bt("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(e.length%2!==0)throw new bt("Hex string must be an even number of hex characters.","invalid_length");try{return new r(uo(e))}catch(n){throw new bt(`Hex string contains invalid hex characters: ${n?.message}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new r(t):r.fromString(t)}static isValid(t){try{return r.fromString(t),{valid:!0}}catch(e){return{valid:!1,invalidReason:e?.invalidReason,invalidReasonMessage:e?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((e,n)=>e===t.data[n])}};var ae=class{bcsToBytes(){let t=new Zt;return this.serialize(t),t.toUint8Array()}bcsToHex(){let t=this.bcsToBytes();return Be.fromHexInput(t)}},Zt=class{constructor(t=64){if(t<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(t),this.offset=0}ensureBufferWillHandleSize(t){for(;this.buffer.byteLength<this.offset+t;){let e=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e}}appendToBuffer(t){this.ensureBufferWillHandleSize(t.length),new Uint8Array(this.buffer,this.offset).set(t),this.offset+=t.length}serializeWithFunction(t,e,n){this.ensureBufferWillHandleSize(e);let o=new DataView(this.buffer,this.offset);t.apply(o,[0,n,!0]),this.offset+=e}serializeStr(t){let e=new TextEncoder;this.serializeBytes(e.encode(t))}serializeBytes(t){this.serializeU32AsUleb128(t.length),this.appendToBuffer(t)}serializeFixedBytes(t){this.appendToBuffer(t)}serializeBool(t){Ys(t);let e=t?1:0;this.appendToBuffer(new Uint8Array([e]))}serializeU8(t){this.appendToBuffer(new Uint8Array([t]))}serializeU16(t){this.serializeWithFunction(DataView.prototype.setUint16,2,t)}serializeU32(t){this.serializeWithFunction(DataView.prototype.setUint32,4,t)}serializeU64(t){let e=BigInt(t)&BigInt(_r),n=BigInt(t)>>BigInt(32);this.serializeU32(Number(e)),this.serializeU32(Number(n))}serializeU128(t){let e=BigInt(t)&En,n=BigInt(t)>>BigInt(64);this.serializeU64(e),this.serializeU64(n)}serializeU256(t){let e=BigInt(t)&Vo,n=BigInt(t)>>BigInt(128);this.serializeU128(e),this.serializeU128(n)}serializeU32AsUleb128(t){let e=t,n=[];for(;e>>>7;)n.push(e&127|128),e>>>=7;n.push(e),this.appendToBuffer(new Uint8Array(n))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(t){t.serialize(this)}serializeVector(t){this.serializeU32AsUleb128(t.length),t.forEach(e=>{e.serialize(this)})}};Et([vn(0,js)],Zt.prototype,"serializeU8",1),Et([vn(0,Qs)],Zt.prototype,"serializeU16",1),Et([vn(0,_r)],Zt.prototype,"serializeU32",1),Et([vn(BigInt(0),En)],Zt.prototype,"serializeU64",1),Et([vn(BigInt(0),Vo)],Zt.prototype,"serializeU128",1),Et([vn(BigInt(0),Ws)],Zt.prototype,"serializeU256",1),Et([vn(0,_r)],Zt.prototype,"serializeU32AsUleb128",1);function Ys(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}var tf=(r,t,e)=>`${r} is out of range: [${t}, ${e}]`;function Sr(r,t,e){let n=BigInt(r);if(n>BigInt(e)||n<BigInt(t))throw new Error(tf(r,t,e))}function vn(r,t){return(e,n,o)=>{let s=o.value;return o.value=function(c){return Sr(c,r,t),s.apply(this,[c])},o}}var rf=(c=>(c.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",c.INVALID_HEX_CHARS="invalid_hex_chars",c.TOO_SHORT="too_short",c.TOO_LONG="too_long",c.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",c.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",c.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",c))(rf||{}),Ge=class Ge extends ae{constructor(e){super();if(e.length!==Ge.LENGTH)throw new bt("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=_n(this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _n(this.data)}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let n=e.deserializeFixedBytes(Ge.LENGTH);return new Ge(n)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new bt("Hex string must start with a leading 0x.","leading_zero_x_required");let n=Ge.fromString(e);if(e.length!==Ge.LONG_STRING_LENGTH+2)if(n.isSpecial()){if(e.length!==3)throw new bt(`The given hex string ${e} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new bt(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return n}static fromString(e){let n=e;if(e.startsWith("0x")&&(n=e.slice(2)),n.length===0)throw new bt("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new bt("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let o;try{o=uo(n.padStart(64,"0"))}catch(s){throw new bt(`Hex characters are invalid: ${s?.message}`,"invalid_hex_chars")}return new Ge(o)}static from(e){return e instanceof Ge?e:e instanceof Uint8Array?new Ge(e):Ge.fromString(e)}static fromStrict(e){return e instanceof Ge?e:e instanceof Uint8Array?new Ge(e):Ge.fromStringStrict(e)}static isValid(e){try{return e.strict?Ge.fromStrict(e.input):Ge.from(e.input),{valid:!0}}catch(n){return{valid:!1,invalidReason:n?.invalidReason,invalidReasonMessage:n?.message}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((n,o)=>n===e.data[o])}};Ge.LENGTH=32,Ge.LONG_STRING_LENGTH=64,Ge.ZERO=Ge.from("0x0"),Ge.ONE=Ge.from("0x1"),Ge.TWO=Ge.from("0x2"),Ge.THREE=Ge.from("0x3"),Ge.FOUR=Ge.from("0x4");var H=Ge;function Er(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function sg(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Xt(r,...t){if(!sg(r))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function Zs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Er(r.outputLen),Er(r.blockLen)}function vr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Xs(r,t){Xt(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Js=BigInt(4294967295),Ka=BigInt(32);function nf(r,t=!1){return t?{h:Number(r&Js),l:Number(r>>Ka&Js)}:{h:Number(r>>Ka&Js)|0,l:Number(r&Js)|0}}function Ha(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=nf(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var ig=(r,t)=>BigInt(r>>>0)<<Ka|BigInt(t>>>0),ag=(r,t,e)=>r>>>e,cg=(r,t,e)=>r<<32-e|t>>>e,ug=(r,t,e)=>r>>>e|t<<32-e,fg=(r,t,e)=>r<<32-e|t>>>e,dg=(r,t,e)=>r<<64-e|t>>>e-32,lg=(r,t,e)=>r>>>e-32|t<<64-e,pg=(r,t)=>t,gg=(r,t)=>r,Fa=(r,t,e)=>r<<e|t>>>32-e,$a=(r,t,e)=>t<<e|r>>>32-e,Va=(r,t,e)=>t<<e-32|r>>>64-e,ja=(r,t,e)=>r<<e-32|t>>>64-e;function mg(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var yg=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),hg=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ag=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),xg=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,bg=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),wg=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Tg={fromBig:nf,split:Ha,toBig:ig,shrSH:ag,shrSL:cg,rotrSH:ug,rotrSL:fg,rotrBH:dg,rotrBL:lg,rotr32H:pg,rotr32L:gg,rotlSH:Fa,rotlSL:$a,rotlBH:Va,rotlBL:ja,add:mg,add3L:yg,add3H:hg,add4L:Ag,add4H:xg,add5H:wg,add5L:bg},Ae=Tg;var[af,cf,uf]=[[],[],[]],_g=BigInt(0),jo=BigInt(1),Sg=BigInt(2),Eg=BigInt(7),vg=BigInt(256),Cg=BigInt(113);for(let r=0,t=jo,e=1,n=0;r<24;r++){[e,n]=[n,(2*e+3*n)%5],af.push(2*(5*n+e)),cf.push((r+1)*(r+2)/2%64);let o=_g;for(let s=0;s<7;s++)t=(t<<jo^(t>>Eg)*Cg)%vg,t&Sg&&(o^=jo<<(jo<<BigInt(s))-jo);uf.push(o)}var[Ug,Ig]=Ha(uf,!0),of=(r,t,e)=>e>32?Va(r,t,e):Fa(r,t,e),sf=(r,t,e)=>e>32?ja(r,t,e):$a(r,t,e);function Bg(r,t=24){let e=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let i=0;i<10;i++)e[i]=r[i]^r[i+10]^r[i+20]^r[i+30]^r[i+40];for(let i=0;i<10;i+=2){let c=(i+8)%10,f=(i+2)%10,l=e[f],h=e[f+1],m=of(l,h,1)^e[c],T=sf(l,h,1)^e[c+1];for(let v=0;v<50;v+=10)r[i+v]^=m,r[i+v+1]^=T}let o=r[2],s=r[3];for(let i=0;i<24;i++){let c=cf[i],f=of(o,s,c),l=sf(o,s,c),h=af[i];o=r[h],s=r[h+1],r[h]=f,r[h+1]=l}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)e[c]=r[i+c];for(let c=0;c<10;c++)r[i+c]^=~e[(c+2)%10]&e[(c+4)%10]}r[0]^=Ug[n],r[1]^=Ig[n]}e.fill(0)}var ei=class r extends Kr{constructor(t,e,n,o=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=o,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Er(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Yu(this.state)}keccak(){Bg(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){vr(this);let{blockLen:e,state:n}=this;t=Yt(t);let o=t.length;for(let s=0;s<o;){let i=Math.min(e-this.pos,o-s);for(let c=0;c<i;c++)n[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:e,pos:n,blockLen:o}=this;t[n]^=e,e&128&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){vr(this,!1),Xt(t),this.finish();let e=this.state,{blockLen:n}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);t.set(e.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Er(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Xs(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){let{blockLen:e,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new r(e,n,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}},Fr=(r,t,e)=>Hr(()=>new ei(t,r,e)),O0=Fr(6,144,224/8),Cn=Fr(6,136,256/8),N0=Fr(6,104,384/8),k0=Fr(6,72,512/8),z0=Fr(1,144,224/8),D0=Fr(1,136,256/8),M0=Fr(1,104,384/8),G0=Fr(1,72,512/8),ff=(r,t,e)=>Xu((n={})=>new ei(t,r,n.dkLen===void 0?e:n.dkLen,!0)),L0=ff(31,168,128/8),q0=ff(31,136,256/8);var Zo=Hp(lf());var Qa=class{constructor(t){this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t,0),this.offset=0}read(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}deserializeStr(){let t=this.deserializeBytes();return new TextDecoder().decode(t)}deserializeBytes(){let t=this.deserializeUleb128AsU32();return new Uint8Array(this.read(t))}deserializeFixedBytes(t){return new Uint8Array(this.read(t))}deserializeBool(){let t=new Uint8Array(this.read(1))[0];if(t!==1&&t!==0)throw new Error("Invalid boolean value");return t===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let t=this.deserializeU32(),e=this.deserializeU32();return BigInt(BigInt(e)<<BigInt(32)|BigInt(t))}deserializeU128(){let t=this.deserializeU64(),e=this.deserializeU64();return BigInt(e<<BigInt(64)|t)}deserializeU256(){let t=this.deserializeU128(),e=this.deserializeU128();return BigInt(e<<BigInt(128)|t)}deserializeUleb128AsU32(){let t=BigInt(0),e=0;for(;t<_r;){let n=this.deserializeU8();if(t|=BigInt(n&127)<<BigInt(e),!(n&128))break;e+=7}if(t>_r)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(t)}deserialize(t){return t.deserialize(this)}deserializeVector(t){let e=this.deserializeUleb128AsU32(),n=new Array;for(let o=0;o<e;o+=1)n.push(this.deserialize(t));return n}};var $r=class r extends ae{constructor(e){super();this.value=Be.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,n){let o=e.deserializeFixedBytes(n);return new r(o)}};var Qo=class r extends ae{constructor(e){super();this.value=new $r(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,n){let o=$r.deserialize(e,n);return new r(o.value)}};var Xe=class r extends ae{constructor(e){super();Ys(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}static deserialize(e){return new r(e.deserializeBool())}},lt=class r extends ae{constructor(e){super();Sr(e,0,js),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new r(e.deserializeU8())}},zt=class r extends ae{constructor(e){super();Sr(e,0,Qs),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new r(e.deserializeU16())}},Dt=class r extends ae{constructor(e){super();Sr(e,0,_r),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new r(e.deserializeU32())}},ft=class r extends ae{constructor(e){super();Sr(e,BigInt(0),En),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new r(e.deserializeU64())}},Mt=class r extends ae{constructor(e){super();Sr(e,BigInt(0),Vo),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new r(e.deserializeU128())}},Gt=class r extends ae{constructor(e){super();Sr(e,BigInt(0),Ws),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new r(e.deserializeU256())}};var Le=class r extends ae{constructor(e){super();this.values=e}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){if(!(this.values[0]instanceof lt)&&this.values[0]!==void 0)throw new Error("Script function arguments only accept u8 vectors");e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let n;if(Array.isArray(e)&&typeof e[0]=="number")n=e;else if(typeof e=="string"){let o=Be.fromHexInput(e);n=Array.from(o.toUint8Array())}else if(e instanceof Uint8Array)n=Array.from(e);else throw new Error("Invalid input type");return new r(n.map(o=>new lt(o)))}static U16(e){return new r(e.map(n=>new zt(n)))}static U32(e){return new r(e.map(n=>new Dt(n)))}static U64(e){return new r(e.map(n=>new ft(n)))}static U128(e){return new r(e.map(n=>new Mt(n)))}static U256(e){return new r(e.map(n=>new Gt(n)))}static Bool(e){return new r(e.map(n=>new Xe(n)))}static MoveString(e){return new r(e.map(n=>new ht(n)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,n){let o=e.deserializeUleb128AsU32(),s=new Array;for(let i=0;i<o;i+=1)s.push(n.deserialize(e));return new r(s)}},ht=class r extends ae{constructor(e){super();this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}serializeForScriptFunction(e){let n=this.bcsToBytes().slice(1);Le.U8(n).serializeForScriptFunction(e)}static deserialize(e){return new r(e.deserializeStr())}},Cr=class r extends ae{constructor(e){super();typeof e<"u"&&e!==null?this.vec=new Le([e]):this.vec=new Le([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let n=this.bcsToBytes();e.serializeBytes(n)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new r(e!=null?new lt(e):void 0)}static U16(e){return new r(e!=null?new zt(e):void 0)}static U32(e){return new r(e!=null?new Dt(e):void 0)}static U64(e){return new r(e!=null?new ft(e):void 0)}static U128(e){return new r(e!=null?new Mt(e):void 0)}static U256(e){return new r(e!=null?new Gt(e):void 0)}static Bool(e){return new r(e!=null?new Xe(e):void 0)}static MoveString(e){return new r(e!=null?new ht(e):void 0)}static deserialize(e,n){let o=Le.deserialize(e,n);return new r(o.values[0])}};var It=class extends ae{},Un=class extends ae{},Jt=class extends ae{};var ri=class extends Kr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Zs(t);let n=Yt(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return vr(this),this.iHash.update(t),this}digestInto(t){vr(this),Xt(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),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:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},fr=(r,t,e)=>new ri(r,t).update(e).digest();fr.create=(r,t)=>new ri(r,t);function Pg(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),f=n?4:0,l=n?0:4;r.setUint32(t+f,i,n),r.setUint32(t+l,c,n)}var Vr=class extends Kr{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ur(this.buffer)}update(t){vr(this);let{view:e,buffer:n,blockLen:o}=this;t=Yt(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let f=ur(t);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){vr(this),Xs(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let m=i;m<o;m++)e[m]=0;Pg(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=ur(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=f/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<l;m++)c.setUint32(4*m,h[m],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var[Rg,Og]=Ae.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),jr=new Uint32Array(80),Qr=new Uint32Array(80),Wa=class extends Vr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:f,Eh:l,El:h,Fh:m,Fl:T,Gh:v,Gl:b,Hh:y,Hl:w}=this;return[t,e,n,o,s,i,c,f,l,h,m,T,v,b,y,w]}set(t,e,n,o,s,i,c,f,l,h,m,T,v,b,y,w){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=f|0,this.Eh=l|0,this.El=h|0,this.Fh=m|0,this.Fl=T|0,this.Gh=v|0,this.Gl=b|0,this.Hh=y|0,this.Hl=w|0}process(t,e){for(let P=0;P<16;P++,e+=4)jr[P]=t.getUint32(e),Qr[P]=t.getUint32(e+=4);for(let P=16;P<80;P++){let $=jr[P-15]|0,M=Qr[P-15]|0,z=Ae.rotrSH($,M,1)^Ae.rotrSH($,M,8)^Ae.shrSH($,M,7),L=Ae.rotrSL($,M,1)^Ae.rotrSL($,M,8)^Ae.shrSL($,M,7),K=jr[P-2]|0,we=Qr[P-2]|0,te=Ae.rotrSH(K,we,19)^Ae.rotrBH(K,we,61)^Ae.shrSH(K,we,6),W=Ae.rotrSL(K,we,19)^Ae.rotrBL(K,we,61)^Ae.shrSL(K,we,6),ve=Ae.add4L(L,W,Qr[P-7],Qr[P-16]),Ce=Ae.add4H(ve,z,te,jr[P-7],jr[P-16]);jr[P]=Ce|0,Qr[P]=ve|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:f,Dh:l,Dl:h,Eh:m,El:T,Fh:v,Fl:b,Gh:y,Gl:w,Hh:E,Hl:k}=this;for(let P=0;P<80;P++){let $=Ae.rotrSH(m,T,14)^Ae.rotrSH(m,T,18)^Ae.rotrBH(m,T,41),M=Ae.rotrSL(m,T,14)^Ae.rotrSL(m,T,18)^Ae.rotrBL(m,T,41),z=m&v^~m&y,L=T&b^~T&w,K=Ae.add5L(k,M,L,Og[P],Qr[P]),we=Ae.add5H(K,E,$,z,Rg[P],jr[P]),te=K|0,W=Ae.rotrSH(n,o,28)^Ae.rotrBH(n,o,34)^Ae.rotrBH(n,o,39),ve=Ae.rotrSL(n,o,28)^Ae.rotrBL(n,o,34)^Ae.rotrBL(n,o,39),Ce=n&s^n&c^s&c,Ve=o&i^o&f^i&f;E=y|0,k=w|0,y=v|0,w=b|0,v=m|0,b=T|0,{h:m,l:T}=Ae.add(l|0,h|0,we|0,te|0),l=c|0,h=f|0,c=s|0,f=i|0,s=n|0,i=o|0;let _=Ae.add3L(te,ve,Ve);n=Ae.add3H(_,we,W,Ce),o=_|0}({h:n,l:o}=Ae.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Ae.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:f}=Ae.add(this.Ch|0,this.Cl|0,c|0,f|0),{h:l,l:h}=Ae.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:m,l:T}=Ae.add(this.Eh|0,this.El|0,m|0,T|0),{h:v,l:b}=Ae.add(this.Fh|0,this.Fl|0,v|0,b|0),{h:y,l:w}=Ae.add(this.Gh|0,this.Gl|0,y|0,w|0),{h:E,l:k}=Ae.add(this.Hh|0,this.Hl|0,E|0,k|0),this.set(n,o,s,i,c,f,l,h,m,T,v,b,y,w,E,k)}roundClean(){jr.fill(0),Qr.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var In=Hr(()=>new Wa);function Ng(r,t,e,n){Zs(r);let o=Zu({dkLen:32,asyncTick:10},n),{c:s,dkLen:i,asyncTick:c}=o;if(Er(s),Er(i),Er(c),s<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let f=Yt(t),l=Yt(e),h=new Uint8Array(i),m=fr.create(r,f),T=m._cloneInto().update(l);return{c:s,dkLen:i,asyncTick:c,DK:h,PRF:m,PRFSalt:T}}function kg(r,t,e,n,o){return r.destroy(),t.destroy(),n&&n.destroy(),o.fill(0),e}function pf(r,t,e,n){let{c:o,dkLen:s,DK:i,PRF:c,PRFSalt:f}=Ng(r,t,e,n),l,h=new Uint8Array(4),m=ur(h),T=new Uint8Array(c.outputLen);for(let v=1,b=0;b<s;v++,b+=c.outputLen){let y=i.subarray(b,b+c.outputLen);m.setInt32(0,v,!1),(l=f._cloneInto(l)).update(h).digestInto(T),y.set(T.subarray(0,y.length));for(let w=1;w<o;w++){c._cloneInto(l).update(T).digestInto(T);for(let E=0;E<y.length;E++)y[E]^=T[E]}}return kg(c,f,i,l,T)}var zg=(r,t,e)=>r&t^~r&e,Dg=(r,t,e)=>r&t^r&e^t&e,Mg=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Wr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yr=new Uint32Array(64),Ya=class extends Vr{constructor(){super(64,32,8,!1),this.A=Wr[0]|0,this.B=Wr[1]|0,this.C=Wr[2]|0,this.D=Wr[3]|0,this.E=Wr[4]|0,this.F=Wr[5]|0,this.G=Wr[6]|0,this.H=Wr[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:f}=this;return[t,e,n,o,s,i,c,f]}set(t,e,n,o,s,i,c,f){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=f|0}process(t,e){for(let m=0;m<16;m++,e+=4)Yr[m]=t.getUint32(e,!1);for(let m=16;m<64;m++){let T=Yr[m-15],v=Yr[m-2],b=Wt(T,7)^Wt(T,18)^T>>>3,y=Wt(v,17)^Wt(v,19)^v>>>10;Yr[m]=y+Yr[m-7]+b+Yr[m-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:f,G:l,H:h}=this;for(let m=0;m<64;m++){let T=Wt(c,6)^Wt(c,11)^Wt(c,25),v=h+T+zg(c,f,l)+Mg[m]+Yr[m]|0,y=(Wt(n,2)^Wt(n,13)^Wt(n,22))+Dg(n,o,s)|0;h=l,l=f,f=c,c=i+v|0,i=s,s=o,o=n,n=v+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,f=f+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,o,s,i,c,f,l,h)}roundClean(){Yr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Wo=Hr(()=>new Ya);function gf(r){if(typeof r!="string")throw new TypeError(`Invalid mnemonic type: ${typeof r}`);return r.normalize("NFKD")}function Gg(r){let t=gf(r),e=t.split(" ");if(![12,15,18,21,24].includes(e.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:e}}var Lg=r=>gf(`mnemonic${r}`);function mf(r,t=""){return pf(In,Gg(r).nfkd,Lg(t),{c:2048,dkLen:64})}var yf=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,hf=/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,Af=(t=>(t.ED25519="ed25519 seed",t))(Af||{}),Za=2147483648;function Xa(r){return hf.test(r)}function Ja(r){return yf.test(r)}var ni=(r,t)=>{let e=fr.create(In,r).update(t).digest();return{key:e.slice(0,32),chainCode:e.slice(32)}},ec=({key:r,chainCode:t},e)=>{let n=new ArrayBuffer(4);new DataView(n).setUint32(0,e);let o=new Uint8Array(n),s=new Uint8Array([0]),i=new Uint8Array([...s,...r,...o]);return ni(t,i)},Kg=r=>r.replace("'",""),tc=r=>r.split("/").slice(1).map(Kg),Yo=r=>{let t=r.trim().split(/\s+/).map(e=>e.toLowerCase()).join(" ");return mf(t)};var Zr=class Zr extends It{constructor(e){super();let n=Be.fromHexInput(e);if(n.toUint8Array().length!==Zr.LENGTH)throw new Error(`PublicKey length should be ${Zr.LENGTH}`);this.key=n}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}verifySignature(e){let{message:n,signature:o}=e,s=Be.fromHexInput(n).toUint8Array(),i=o.toUint8Array();return Zo.default.sign.detached.verify(s,i,this.key.toUint8Array())}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let n=e.deserializeBytes();return new Zr(n)}static load(e){let n=e.deserializeBytes();return new Zr(n)}static isPublicKey(e){return e instanceof Zr}};Zr.LENGTH=32;var qe=Zr,wt=class wt extends Un{constructor(e){super();let n=Be.fromHexInput(e);if(n.toUint8Array().length!==wt.LENGTH)throw new Error(`PrivateKey length should be ${wt.LENGTH}`);this.signingKeyPair=Zo.default.sign.keyPair.fromSeed(n.toUint8Array().slice(0,wt.LENGTH))}toUint8Array(){return this.signingKeyPair.secretKey.slice(0,wt.LENGTH)}toString(){return Be.fromHexInput(this.toUint8Array()).toString()}sign(e){let n=Be.fromHexInput(e),o=Zo.default.sign.detached(n.toUint8Array(),this.signingKeyPair.secretKey);return new Je(o)}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let n=e.deserializeBytes();return new wt(n)}static generate(){let e=Zo.default.sign.keyPair();return new wt(e.secretKey.slice(0,wt.LENGTH))}publicKey(){let e=this.signingKeyPair.publicKey;return new qe(e)}static fromDerivationPath(e,n){if(!Ja(e))throw new Error(`Invalid derivation path ${e}`);return wt.fromDerivationPathInner(e,Yo(n))}static fromDerivationPathInner(e,n,o=Za){let{key:s,chainCode:i}=ni(wt.SLIP_0010_SEED,n),c=tc(e).map(l=>parseInt(l,10)),{key:f}=c.reduce((l,h)=>ec(l,h+o),{key:s,chainCode:i});return new wt(f)}static isPrivateKey(e){return e instanceof wt}};wt.LENGTH=32,wt.SLIP_0010_SEED="ed25519 seed";var Ur=wt,Xr=class Xr extends Jt{constructor(e){super();let n=Be.fromHexInput(e);if(n.toUint8Array().length!==Xr.LENGTH)throw new Error(`Signature length should be ${Xr.LENGTH}`);this.data=n}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let n=e.deserializeBytes();return new Xr(n)}static load(e){let n=e.deserializeBytes();return new Xr(n)}static isSignature(e){return e instanceof Xr}};Xr.LENGTH=64;var Je=Xr;var Lt=class Lt extends It{constructor(e){super();let{publicKeys:n,threshold:o}=e;if(n.length>Lt.MAX_KEYS||n.length<Lt.MIN_KEYS)throw new Error(`Must have between ${Lt.MIN_KEYS} and ${Lt.MAX_KEYS} public keys, inclusive`);if(o<Lt.MIN_THRESHOLD||o>n.length)throw new Error(`Threshold must be between ${Lt.MIN_THRESHOLD} and ${n.length}, inclusive`);this.publicKeys=n,this.threshold=o}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*qe.LENGTH+1);return this.publicKeys.forEach((n,o)=>{e.set(n.toUint8Array(),o*qe.LENGTH)}),e[this.publicKeys.length*qe.LENGTH]=this.threshold,e}toString(){return Be.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){throw new Error("TODO - Method not implemented.")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let n=e.deserializeBytes(),o=n[n.length-1],s=[];for(let i=0;i<n.length-1;i+=qe.LENGTH){let c=i;s.push(new qe(n.subarray(c,c+qe.LENGTH)))}return new Lt({publicKeys:s,threshold:o})}};Lt.MAX_KEYS=32,Lt.MIN_KEYS=2,Lt.MIN_THRESHOLD=1;var er=Lt,qt=class qt extends Jt{constructor(e){super();let{signatures:n,bitmap:o}=e;if(o.length!==qt.BITMAP_LEN)throw new Error(`"bitmap" length should be ${qt.BITMAP_LEN}`);if(n.length>qt.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${qt.MAX_SIGNATURES_SUPPORTED}`);this.signatures=n,this.bitmap=o}toUint8Array(){let e=new Uint8Array(this.signatures.length*Je.LENGTH+qt.BITMAP_LEN);return this.signatures.forEach((n,o)=>{e.set(n.toUint8Array(),o*Je.LENGTH)}),e.set(this.bitmap,this.signatures.length*Je.LENGTH),e}toString(){return Be.fromHexInput(this.toUint8Array()).toString()}static createBitmap(e){let{bits:n}=e,o=128,s=new Uint8Array([0,0,0,0]),i=new Set;return n.forEach(c=>{if(c>=qt.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${qt.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(c))throw new Error("Duplicate bits detected.");i.add(c);let f=Math.floor(c/8),l=s[f];l|=o>>c%8,s[f]=l}),s}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let n=e.deserializeBytes(),o=n.subarray(n.length-4),s=[];for(let i=0;i<n.length-o.length;i+=Je.LENGTH){let c=i;s.push(new Je(n.subarray(c,c+Je.LENGTH)))}return new qt({signatures:s,bitmap:o})}};qt.MAX_SIGNATURES_SUPPORTED=32,qt.BITMAP_LEN=4;var Bn=qt;function xf(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function rc(r,...t){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function bf(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");xf(r.outputLen),xf(r.blockLen)}function fo(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function wf(r,t){rc(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var oi=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Tf=r=>r instanceof Uint8Array;var si=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),tr=(r,t)=>r<<32-t|r>>>t,Hg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Hg)throw new Error("Non little-endian hardware is not supported");function Fg(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Xo(r){if(typeof r=="string"&&(r=Fg(r)),!Tf(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function _f(...r){let t=new Uint8Array(r.reduce((n,o)=>n+o.length,0)),e=0;return r.forEach(n=>{if(!Tf(n))throw new Error("Uint8Array expected");t.set(n,e),e+=n.length}),t}var lo=class{clone(){return this._cloneInto()}},dx={}.toString;function Sf(r){let t=n=>r().update(Xo(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Ef(r=32){if(oi&&typeof oi.getRandomValues=="function")return oi.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function $g(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),f=n?4:0,l=n?0:4;r.setUint32(t+f,i,n),r.setUint32(t+l,c,n)}var ii=class extends lo{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=si(this.buffer)}update(t){fo(this);let{view:e,buffer:n,blockLen:o}=this;t=Xo(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let f=si(t);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){fo(this),wf(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let m=i;m<o;m++)e[m]=0;$g(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=si(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=f/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<l;m++)c.setUint32(4*m,h[m],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var Vg=(r,t,e)=>r&t^~r&e,jg=(r,t,e)=>r&t^r&e^t&e,Qg=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Jr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),en=new Uint32Array(64),nc=class extends ii{constructor(){super(64,32,8,!1),this.A=Jr[0]|0,this.B=Jr[1]|0,this.C=Jr[2]|0,this.D=Jr[3]|0,this.E=Jr[4]|0,this.F=Jr[5]|0,this.G=Jr[6]|0,this.H=Jr[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:f}=this;return[t,e,n,o,s,i,c,f]}set(t,e,n,o,s,i,c,f){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=f|0}process(t,e){for(let m=0;m<16;m++,e+=4)en[m]=t.getUint32(e,!1);for(let m=16;m<64;m++){let T=en[m-15],v=en[m-2],b=tr(T,7)^tr(T,18)^T>>>3,y=tr(v,17)^tr(v,19)^v>>>10;en[m]=y+en[m-7]+b+en[m-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:f,G:l,H:h}=this;for(let m=0;m<64;m++){let T=tr(c,6)^tr(c,11)^tr(c,25),v=h+T+Vg(c,f,l)+Qg[m]+en[m]|0,y=(tr(n,2)^tr(n,13)^tr(n,22))+jg(n,o,s)|0;h=l,l=f,f=c,c=i+v|0,i=s,s=o,o=n,n=v+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,f=f+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,o,s,i,c,f,l,h)}roundClean(){en.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var vf=Sf(()=>new nc);var ac={};Gs(ac,{bitGet:()=>tm,bitLen:()=>em,bitMask:()=>Jo,bitSet:()=>rm,bytesToHex:()=>Pn,bytesToNumberBE:()=>Ir,bytesToNumberLE:()=>ui,concatBytes:()=>po,createHmacDrbg:()=>ic,ensureBytes:()=>Bt,equalBytes:()=>Xg,hexToBytes:()=>Rn,hexToNumber:()=>sc,numberToBytesBE:()=>tn,numberToBytesLE:()=>fi,numberToHexUnpadded:()=>If,numberToVarBytesBE:()=>Zg,utf8ToBytes:()=>Jg,validateObject:()=>rn});var Uf=BigInt(0),ai=BigInt(1),Wg=BigInt(2),ci=r=>r instanceof Uint8Array,Yg=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Pn(r){if(!ci(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=Yg[r[e]];return t}function If(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function sc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Rn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let e=new Uint8Array(t/2);for(let n=0;n<e.length;n++){let o=n*2,s=r.slice(o,o+2),i=Number.parseInt(s,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");e[n]=i}return e}function Ir(r){return sc(Pn(r))}function ui(r){if(!ci(r))throw new Error("Uint8Array expected");return sc(Pn(Uint8Array.from(r).reverse()))}function tn(r,t){return Rn(r.toString(16).padStart(t*2,"0"))}function fi(r,t){return tn(r,t).reverse()}function Zg(r){return Rn(If(r))}function Bt(r,t,e){let n;if(typeof t=="string")try{n=Rn(t)}catch(s){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${s}`)}else if(ci(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(`${r} expected ${e} bytes, got ${o}`);return n}function po(...r){let t=new Uint8Array(r.reduce((n,o)=>n+o.length,0)),e=0;return r.forEach(n=>{if(!ci(n))throw new Error("Uint8Array expected");t.set(n,e),e+=n.length}),t}function Xg(r,t){if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}function Jg(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function em(r){let t;for(t=0;r>Uf;r>>=ai,t+=1);return t}function tm(r,t){return r>>BigInt(t)&ai}var rm=(r,t,e)=>r|(e?ai:Uf)<<BigInt(t),Jo=r=>(Wg<<BigInt(r-1))-ai,oc=r=>new Uint8Array(r),Cf=r=>Uint8Array.from(r);function ic(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=oc(r),o=oc(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...m)=>e(o,n,...m),f=(m=oc())=>{o=c(Cf([0]),m),n=c(),m.length!==0&&(o=c(Cf([1]),m),n=c())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let m=0,T=[];for(;m<t;){n=c();let v=n.slice();T.push(v),m+=n.length}return po(...T)};return(m,T)=>{i(),f(m);let v;for(;!(v=T(l()));)f();return i(),v}}var nm={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||r instanceof Uint8Array,isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function rn(r,t,e={}){let n=(o,s,i)=>{let c=nm[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let f=r[o];if(!(i&&f===void 0)&&!c(f,r))throw new Error(`Invalid param ${String(o)}=${f} (${typeof f}), expected ${s}`)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var ct=BigInt(0),et=BigInt(1),On=BigInt(2),om=BigInt(3),cc=BigInt(4),Bf=BigInt(5),Pf=BigInt(8),sm=BigInt(9),im=BigInt(16);function At(r,t){let e=r%t;return e>=ct?e:t+e}function am(r,t,e){if(e<=ct||t<ct)throw new Error("Expected power/modulo > 0");if(e===et)return ct;let n=et;for(;t>ct;)t&et&&(n=n*r%e),r=r*r%e,t>>=et;return n}function Pt(r,t,e){let n=r;for(;t-- >ct;)n*=n,n%=e;return n}function di(r,t){if(r===ct||t<=ct)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=At(r,t),n=t,o=ct,s=et,i=et,c=ct;for(;e!==ct;){let l=n/e,h=n%e,m=o-i*l,T=s-c*l;n=e,e=h,o=i,s=c,i=m,c=T}if(n!==et)throw new Error("invert: does not exist");return At(o,t)}function cm(r){let t=(r-et)/On,e,n,o;for(e=r-et,n=0;e%On===ct;e/=On,n++);for(o=On;o<r&&am(o,t,r)!==r-et;o++);if(n===1){let i=(r+et)/cc;return function(f,l){let h=f.pow(l,i);if(!f.eql(f.sqr(h),l))throw new Error("Cannot find square root");return h}}let s=(e+et)/On;return function(c,f){if(c.pow(f,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=n,h=c.pow(c.mul(c.ONE,o),e),m=c.pow(f,s),T=c.pow(f,e);for(;!c.eql(T,c.ONE);){if(c.eql(T,c.ZERO))return c.ZERO;let v=1;for(let y=c.sqr(T);v<l&&!c.eql(y,c.ONE);v++)y=c.sqr(y);let b=c.pow(h,et<<BigInt(l-v-1));h=c.sqr(b),m=c.mul(m,b),T=c.mul(T,h),l=v}return m}}function um(r){if(r%cc===om){let t=(r+et)/cc;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Pf===Bf){let t=(r-Bf)/Pf;return function(n,o){let s=n.mul(o,On),i=n.pow(s,t),c=n.mul(o,i),f=n.mul(n.mul(c,On),i),l=n.mul(c,n.sub(f,n.ONE));if(!n.eql(n.sqr(l),o))throw new Error("Cannot find square root");return l}}return r%im,cm(r)}var fm=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function uc(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=fm.reduce((n,o)=>(n[o]="function",n),t);return rn(r,e)}function dm(r,t,e){if(e<ct)throw new Error("Expected power > 0");if(e===ct)return r.ONE;if(e===et)return t;let n=r.ONE,o=t;for(;e>ct;)e&et&&(n=r.mul(n,o)),o=r.sqr(o),e>>=et;return n}function lm(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function fc(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Rf(r,t,e=!1,n={}){if(r<=ct)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:s}=fc(r,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=um(r),c=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:Jo(o),ZERO:ct,ONE:et,create:f=>At(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof f}`);return ct<=f&&f<r},is0:f=>f===ct,isOdd:f=>(f&et)===et,neg:f=>At(-f,r),eql:(f,l)=>f===l,sqr:f=>At(f*f,r),add:(f,l)=>At(f+l,r),sub:(f,l)=>At(f-l,r),mul:(f,l)=>At(f*l,r),pow:(f,l)=>dm(c,f,l),div:(f,l)=>At(f*di(l,r),r),sqrN:f=>f*f,addN:(f,l)=>f+l,subN:(f,l)=>f-l,mulN:(f,l)=>f*l,inv:f=>di(f,r),sqrt:n.sqrt||(f=>i(c,f)),invertBatch:f=>lm(c,f),cmov:(f,l,h)=>h?l:f,toBytes:f=>e?fi(f,s):tn(f,s),fromBytes:f=>{if(f.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${f.length}`);return e?ui(f):Ir(f)}});return Object.freeze(c)}function Of(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function dc(r){let t=Of(r);return t+Math.ceil(t/2)}function Nf(r,t,e=!1){let n=r.length,o=Of(t),s=dc(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=e?Ir(r):ui(r),c=At(i,t-et)+et;return e?fi(c,o):tn(c,o)}var gm=BigInt(0),lc=BigInt(1);function kf(r,t){let e=(o,s)=>{let i=s.negate();return o?i:s},n=o=>{let s=Math.ceil(t/o)+1,i=2**(o-1);return{windows:s,windowSize:i}};return{constTimeNegate:e,unsafeLadder(o,s){let i=r.ZERO,c=o;for(;s>gm;)s&lc&&(i=i.add(c)),c=c.double(),s>>=lc;return i},precomputeWindow(o,s){let{windows:i,windowSize:c}=n(s),f=[],l=o,h=l;for(let m=0;m<i;m++){h=l,f.push(h);for(let T=1;T<c;T++)h=h.add(l),f.push(h);l=h.double()}return f},wNAF(o,s,i){let{windows:c,windowSize:f}=n(o),l=r.ZERO,h=r.BASE,m=BigInt(2**o-1),T=2**o,v=BigInt(o);for(let b=0;b<c;b++){let y=b*f,w=Number(i&m);i>>=v,w>f&&(w-=T,i+=lc);let E=y,k=y+Math.abs(w)-1,P=b%2!==0,$=w<0;w===0?h=h.add(e(P,s[E])):l=l.add(e($,s[k]))}return{p:l,f:h}},wNAFCached(o,s,i,c){let f=o._WINDOW_SIZE||1,l=s.get(o);return l||(l=this.precomputeWindow(o,f),f!==1&&s.set(o,c(l))),this.wNAF(f,l,i)}}}function pc(r){return uc(r.Fp),rn(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...fc(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function mm(r){let t=pc(r);rn(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:ym,hexToBytes:hm}=ac,Nn={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(r){let{Err:t}=Nn;if(r.length<2||r[0]!==2)throw new t("Invalid signature integer tag");let e=r[1],n=r.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:ym(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=Nn,e=typeof r=="string"?hm(r):r;if(!(e instanceof Uint8Array))throw new Error("ui8a expected");let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");let{d:o,l:s}=Nn._parseInt(e.subarray(2)),{d:i,l:c}=Nn._parseInt(s);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s:i}},hexFromSig(r){let t=l=>Number.parseInt(l[0],16)&8?"00"+l:l,e=l=>{let h=l.toString(16);return h.length&1?`0${h}`:h},n=t(e(r.s)),o=t(e(r.r)),s=n.length/2,i=o.length/2,c=e(s),f=e(i);return`30${e(i+s+4)}02${f}${o}02${c}${n}`}},Br=BigInt(0),Kt=BigInt(1),vx=BigInt(2),zf=BigInt(3),Cx=BigInt(4);function Am(r){let t=mm(r),{Fp:e}=t,n=t.toBytes||((b,y,w)=>{let E=y.toAffine();return po(Uint8Array.from([4]),e.toBytes(E.x),e.toBytes(E.y))}),o=t.fromBytes||(b=>{let y=b.subarray(1),w=e.fromBytes(y.subarray(0,e.BYTES)),E=e.fromBytes(y.subarray(e.BYTES,2*e.BYTES));return{x:w,y:E}});function s(b){let{a:y,b:w}=t,E=e.sqr(b),k=e.mul(E,b);return e.add(e.add(k,e.mul(b,y)),w)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function i(b){return typeof b=="bigint"&&Br<b&&b<t.n}function c(b){if(!i(b))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function f(b){let{allowedPrivateKeyLengths:y,nByteLength:w,wrapPrivateKey:E,n:k}=t;if(y&&typeof b!="bigint"){if(b instanceof Uint8Array&&(b=Pn(b)),typeof b!="string"||!y.includes(b.length))throw new Error("Invalid key");b=b.padStart(w*2,"0")}let P;try{P=typeof b=="bigint"?b:Ir(Bt("private key",b,w))}catch{throw new Error(`private key must be ${w} bytes, hex or bigint, not ${typeof b}`)}return E&&(P=At(P,k)),c(P),P}let l=new Map;function h(b){if(!(b instanceof m))throw new Error("ProjectivePoint expected")}class m{constructor(y,w,E){if(this.px=y,this.py=w,this.pz=E,y==null||!e.isValid(y))throw new Error("x required");if(w==null||!e.isValid(w))throw new Error("y required");if(E==null||!e.isValid(E))throw new Error("z required")}static fromAffine(y){let{x:w,y:E}=y||{};if(!y||!e.isValid(w)||!e.isValid(E))throw new Error("invalid affine point");if(y instanceof m)throw new Error("projective point not allowed");let k=P=>e.eql(P,e.ZERO);return k(w)&&k(E)?m.ZERO:new m(w,E,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(y){let w=e.invertBatch(y.map(E=>E.pz));return y.map((E,k)=>E.toAffine(w[k])).map(m.fromAffine)}static fromHex(y){let w=m.fromAffine(o(Bt("pointHex",y)));return w.assertValidity(),w}static fromPrivateKey(y){return m.BASE.multiply(f(y))}_setWindowSize(y){this._WINDOW_SIZE=y,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:y,y:w}=this.toAffine();if(!e.isValid(y)||!e.isValid(w))throw new Error("bad point: x or y not FE");let E=e.sqr(w),k=s(y);if(!e.eql(E,k))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y}=this.toAffine();if(e.isOdd)return!e.isOdd(y);throw new Error("Field doesn't support isOdd")}equals(y){h(y);let{px:w,py:E,pz:k}=this,{px:P,py:$,pz:M}=y,z=e.eql(e.mul(w,M),e.mul(P,k)),L=e.eql(e.mul(E,M),e.mul($,k));return z&&L}negate(){return new m(this.px,e.neg(this.py),this.pz)}double(){let{a:y,b:w}=t,E=e.mul(w,zf),{px:k,py:P,pz:$}=this,M=e.ZERO,z=e.ZERO,L=e.ZERO,K=e.mul(k,k),we=e.mul(P,P),te=e.mul($,$),W=e.mul(k,P);return W=e.add(W,W),L=e.mul(k,$),L=e.add(L,L),M=e.mul(y,L),z=e.mul(E,te),z=e.add(M,z),M=e.sub(we,z),z=e.add(we,z),z=e.mul(M,z),M=e.mul(W,M),L=e.mul(E,L),te=e.mul(y,te),W=e.sub(K,te),W=e.mul(y,W),W=e.add(W,L),L=e.add(K,K),K=e.add(L,K),K=e.add(K,te),K=e.mul(K,W),z=e.add(z,K),te=e.mul(P,$),te=e.add(te,te),K=e.mul(te,W),M=e.sub(M,K),L=e.mul(te,we),L=e.add(L,L),L=e.add(L,L),new m(M,z,L)}add(y){h(y);let{px:w,py:E,pz:k}=this,{px:P,py:$,pz:M}=y,z=e.ZERO,L=e.ZERO,K=e.ZERO,we=t.a,te=e.mul(t.b,zf),W=e.mul(w,P),ve=e.mul(E,$),Ce=e.mul(k,M),Ve=e.add(w,E),_=e.add(P,$);Ve=e.mul(Ve,_),_=e.add(W,ve),Ve=e.sub(Ve,_),_=e.add(w,k);let B=e.add(P,M);return _=e.mul(_,B),B=e.add(W,Ce),_=e.sub(_,B),B=e.add(E,k),z=e.add($,M),B=e.mul(B,z),z=e.add(ve,Ce),B=e.sub(B,z),K=e.mul(we,_),z=e.mul(te,Ce),K=e.add(z,K),z=e.sub(ve,K),K=e.add(ve,K),L=e.mul(z,K),ve=e.add(W,W),ve=e.add(ve,W),Ce=e.mul(we,Ce),_=e.mul(te,_),ve=e.add(ve,Ce),Ce=e.sub(W,Ce),Ce=e.mul(we,Ce),_=e.add(_,Ce),W=e.mul(ve,_),L=e.add(L,W),W=e.mul(B,_),z=e.mul(Ve,z),z=e.sub(z,W),W=e.mul(Ve,ve),K=e.mul(B,K),K=e.add(K,W),new m(z,L,K)}subtract(y){return this.add(y.negate())}is0(){return this.equals(m.ZERO)}wNAF(y){return v.wNAFCached(this,l,y,w=>{let E=e.invertBatch(w.map(k=>k.pz));return w.map((k,P)=>k.toAffine(E[P])).map(m.fromAffine)})}multiplyUnsafe(y){let w=m.ZERO;if(y===Br)return w;if(c(y),y===Kt)return this;let{endo:E}=t;if(!E)return v.unsafeLadder(this,y);let{k1neg:k,k1:P,k2neg:$,k2:M}=E.splitScalar(y),z=w,L=w,K=this;for(;P>Br||M>Br;)P&Kt&&(z=z.add(K)),M&Kt&&(L=L.add(K)),K=K.double(),P>>=Kt,M>>=Kt;return k&&(z=z.negate()),$&&(L=L.negate()),L=new m(e.mul(L.px,E.beta),L.py,L.pz),z.add(L)}multiply(y){c(y);let w=y,E,k,{endo:P}=t;if(P){let{k1neg:$,k1:M,k2neg:z,k2:L}=P.splitScalar(w),{p:K,f:we}=this.wNAF(M),{p:te,f:W}=this.wNAF(L);K=v.constTimeNegate($,K),te=v.constTimeNegate(z,te),te=new m(e.mul(te.px,P.beta),te.py,te.pz),E=K.add(te),k=we.add(W)}else{let{p:$,f:M}=this.wNAF(w);E=$,k=M}return m.normalizeZ([E,k])[0]}multiplyAndAddUnsafe(y,w,E){let k=m.BASE,P=(M,z)=>z===Br||z===Kt||!M.equals(k)?M.multiplyUnsafe(z):M.multiply(z),$=P(this,w).add(P(y,E));return $.is0()?void 0:$}toAffine(y){let{px:w,py:E,pz:k}=this,P=this.is0();y==null&&(y=P?e.ONE:e.inv(k));let $=e.mul(w,y),M=e.mul(E,y),z=e.mul(k,y);if(P)return{x:e.ZERO,y:e.ZERO};if(!e.eql(z,e.ONE))throw new Error("invZ was invalid");return{x:$,y:M}}isTorsionFree(){let{h:y,isTorsionFree:w}=t;if(y===Kt)return!0;if(w)return w(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:y,clearCofactor:w}=t;return y===Kt?this:w?w(m,this):this.multiplyUnsafe(t.h)}toRawBytes(y=!0){return this.assertValidity(),n(m,this,y)}toHex(y=!0){return Pn(this.toRawBytes(y))}}m.BASE=new m(t.Gx,t.Gy,e.ONE),m.ZERO=new m(e.ZERO,e.ONE,e.ZERO);let T=t.nBitLength,v=kf(m,t.endo?Math.ceil(T/2):T);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:f,weierstrassEquation:s,isWithinCurveOrder:i}}function xm(r){let t=pc(r);return rn(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Df(r){let t=xm(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(_){return Br<_&&_<e.ORDER}function c(_){return At(_,n)}function f(_){return di(_,n)}let{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:m,isWithinCurveOrder:T}=Am({...t,toBytes(_,B,F){let re=B.toAffine(),ne=e.toBytes(re.x),xe=po;return F?xe(Uint8Array.from([B.hasEvenY()?2:3]),ne):xe(Uint8Array.from([4]),ne,e.toBytes(re.y))},fromBytes(_){let B=_.length,F=_[0],re=_.subarray(1);if(B===o&&(F===2||F===3)){let ne=Ir(re);if(!i(ne))throw new Error("Point is not on curve");let xe=m(ne),ke=e.sqrt(xe),Te=(ke&Kt)===Kt;return(F&1)===1!==Te&&(ke=e.neg(ke)),{x:ne,y:ke}}else if(B===s&&F===4){let ne=e.fromBytes(re.subarray(0,e.BYTES)),xe=e.fromBytes(re.subarray(e.BYTES,2*e.BYTES));return{x:ne,y:xe}}else throw new Error(`Point of length ${B} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),v=_=>Pn(tn(_,t.nByteLength));function b(_){let B=n>>Kt;return _>B}function y(_){return b(_)?c(-_):_}let w=(_,B,F)=>Ir(_.slice(B,F));class E{constructor(B,F,re){this.r=B,this.s=F,this.recovery=re,this.assertValidity()}static fromCompact(B){let F=t.nByteLength;return B=Bt("compactSignature",B,F*2),new E(w(B,0,F),w(B,F,2*F))}static fromDER(B){let{r:F,s:re}=Nn.toSig(Bt("DER",B));return new E(F,re)}assertValidity(){if(!T(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!T(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(B){return new E(this.r,this.s,B)}recoverPublicKey(B){let{r:F,s:re,recovery:ne}=this,xe=L(Bt("msgHash",B));if(ne==null||![0,1,2,3].includes(ne))throw new Error("recovery id invalid");let ke=ne===2||ne===3?F+t.n:F;if(ke>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let Te=ne&1?"03":"02",De=l.fromHex(Te+v(ke)),se=f(ke),Ke=c(-xe*se),St=c(re*se),ot=l.BASE.multiplyAndAddUnsafe(De,Ke,St);if(!ot)throw new Error("point at infinify");return ot.assertValidity(),ot}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new E(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Rn(this.toDERHex())}toDERHex(){return Nn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Rn(this.toCompactHex())}toCompactHex(){return v(this.r)+v(this.s)}}let k={isValidPrivateKey(_){try{return h(_),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{let _=dc(t.n);return Nf(t.randomBytes(_),t.n)},precompute(_=8,B=l.BASE){return B._setWindowSize(_),B.multiply(BigInt(3)),B}};function P(_,B=!0){return l.fromPrivateKey(_).toRawBytes(B)}function $(_){let B=_ instanceof Uint8Array,F=typeof _=="string",re=(B||F)&&_.length;return B?re===o||re===s:F?re===2*o||re===2*s:_ instanceof l}function M(_,B,F=!0){if($(_))throw new Error("first arg must be private key");if(!$(B))throw new Error("second arg must be public key");return l.fromHex(B).multiply(h(_)).toRawBytes(F)}let z=t.bits2int||function(_){let B=Ir(_),F=_.length*8-t.nBitLength;return F>0?B>>BigInt(F):B},L=t.bits2int_modN||function(_){return c(z(_))},K=Jo(t.nBitLength);function we(_){if(typeof _!="bigint")throw new Error("bigint expected");if(!(Br<=_&&_<K))throw new Error(`bigint expected < 2^${t.nBitLength}`);return tn(_,t.nByteLength)}function te(_,B,F=W){if(["recovered","canonical"].some(st=>st in F))throw new Error("sign() legacy options not supported");let{hash:re,randomBytes:ne}=t,{lowS:xe,prehash:ke,extraEntropy:Te}=F;xe==null&&(xe=!0),_=Bt("msgHash",_),ke&&(_=Bt("prehashed msgHash",re(_)));let De=L(_),se=h(B),Ke=[we(se),we(De)];if(Te!=null){let st=Te===!0?ne(e.BYTES):Te;Ke.push(Bt("extraEntropy",st))}let St=po(...Ke),ot=De;function kt(st){let pt=z(st);if(!T(pt))return;let ar=f(pt),Fe=l.BASE.multiply(pt).toAffine(),xt=c(Fe.x);if(xt===Br)return;let Qt=c(ar*c(ot+xt*se));if(Qt===Br)return;let hn=(Fe.x===xt?0:2)|Number(Fe.y&Kt),qr=Qt;return xe&&b(Qt)&&(qr=y(Qt),hn^=1),new E(xt,qr,hn)}return{seed:St,k2sig:kt}}let W={lowS:t.lowS,prehash:!1},ve={lowS:t.lowS,prehash:!1};function Ce(_,B,F=W){let{seed:re,k2sig:ne}=te(_,B,F),xe=t;return ic(xe.hash.outputLen,xe.nByteLength,xe.hmac)(re,ne)}l.BASE._setWindowSize(8);function Ve(_,B,F,re=ve){let ne=_;if(B=Bt("msgHash",B),F=Bt("publicKey",F),"strict"in re)throw new Error("options.strict was renamed to lowS");let{lowS:xe,prehash:ke}=re,Te,De;try{if(typeof ne=="string"||ne instanceof Uint8Array)try{Te=E.fromDER(ne)}catch(Fe){if(!(Fe instanceof Nn.Err))throw Fe;Te=E.fromCompact(ne)}else if(typeof ne=="object"&&typeof ne.r=="bigint"&&typeof ne.s=="bigint"){let{r:Fe,s:xt}=ne;Te=new E(Fe,xt)}else throw new Error("PARSE");De=l.fromHex(F)}catch(Fe){if(Fe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(xe&&Te.hasHighS())return!1;ke&&(B=t.hash(B));let{r:se,s:Ke}=Te,St=L(B),ot=f(Ke),kt=c(St*ot),st=c(se*ot),pt=l.BASE.multiplyAndAddUnsafe(De,kt,st)?.toAffine();return pt?c(pt.x)===se:!1}return{CURVE:t,getPublicKey:P,getSharedSecret:M,sign:Ce,verify:Ve,ProjectivePoint:l,Signature:E,utils:k}}var li=class extends lo{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,bf(t);let n=Xo(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return fo(this),this.iHash.update(t),this}digestInto(t){fo(this),rc(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),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:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},gc=(r,t,e)=>new li(r,t).update(e).digest();gc.create=(r,t)=>new li(r,t);function bm(r){return{hash:r,hmac:(t,...e)=>gc(r,t,_f(...e)),randomBytes:Ef}}function Mf(r,t){let e=n=>Df({...r,...bm(n)});return Object.freeze({...e(t),create:e})}var qf=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Gf=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),wm=BigInt(1),mc=BigInt(2),Lf=(r,t)=>(r+t/mc)/t;function Tm(r){let t=qf,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),f=BigInt(88),l=r*r*r%t,h=l*l*r%t,m=Pt(h,e,t)*h%t,T=Pt(m,e,t)*h%t,v=Pt(T,mc,t)*l%t,b=Pt(v,o,t)*v%t,y=Pt(b,s,t)*b%t,w=Pt(y,c,t)*y%t,E=Pt(w,f,t)*w%t,k=Pt(E,c,t)*y%t,P=Pt(k,e,t)*h%t,$=Pt(P,i,t)*b%t,M=Pt($,n,t)*l%t,z=Pt(M,mc,t);if(!yc.eql(yc.sqr(z),r))throw new Error("Cannot find square root");return z}var yc=Rf(qf,void 0,void 0,{sqrt:Tm}),go=Mf({a:BigInt(0),b:BigInt(7),Fp:yc,n:Gf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Gf,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-wm*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=Lf(s*r,t),f=Lf(-n*r,t),l=At(r-c*e-f*o,t),h=At(-c*n-f*s,t),m=l>i,T=h>i;if(m&&(l=t-l),T&&(h=t-h),l>i||h>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:m,k1:l,k2neg:T,k2:h}}}},vf),Gx=BigInt(0);var Lx=go.ProjectivePoint;var _m=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Hf=Uint8Array.from({length:16},(r,t)=>t),Sm=Hf.map(r=>(9*r+5)%16),Ac=[Hf],xc=[Sm];for(let r=0;r<4;r++)for(let t of[Ac,xc])t.push(t[r].map(e=>_m[e]));var Ff=[[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(r=>new Uint8Array(r)),Em=Ac.map((r,t)=>r.map(e=>Ff[t][e])),vm=xc.map((r,t)=>r.map(e=>Ff[t][e])),Cm=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Um=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),pi=(r,t)=>r<<t|r>>>32-t;function Kf(r,t,e,n){return r===0?t^e^n:r===1?t&e|~t&n:r===2?(t|~e)^n:r===3?t&n|e&~n:t^(e|~n)}var gi=new Uint32Array(16),hc=class extends Vr{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){let{h0:t,h1:e,h2:n,h3:o,h4:s}=this;return[t,e,n,o,s]}set(t,e,n,o,s){this.h0=t|0,this.h1=e|0,this.h2=n|0,this.h3=o|0,this.h4=s|0}process(t,e){for(let v=0;v<16;v++,e+=4)gi[v]=t.getUint32(e,!0);let n=this.h0|0,o=n,s=this.h1|0,i=s,c=this.h2|0,f=c,l=this.h3|0,h=l,m=this.h4|0,T=m;for(let v=0;v<5;v++){let b=4-v,y=Cm[v],w=Um[v],E=Ac[v],k=xc[v],P=Em[v],$=vm[v];for(let M=0;M<16;M++){let z=pi(n+Kf(v,s,c,l)+gi[E[M]]+y,P[M])+m|0;n=m,m=l,l=pi(c,10)|0,c=s,s=z}for(let M=0;M<16;M++){let z=pi(o+Kf(b,i,f,h)+gi[k[M]]+w,$[M])+T|0;o=T,T=h,h=pi(f,10)|0,f=i,i=z}}this.set(this.h1+c+h|0,this.h2+l+T|0,this.h3+m+o|0,this.h4+n+i|0,this.h0+s+f|0)}roundClean(){gi.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}},$f=Hr(()=>new hc);var _c={};Gs(_c,{bitGet:()=>km,bitLen:()=>Nm,bitMask:()=>es,bitSet:()=>zm,bytesToHex:()=>kn,bytesToNumberBE:()=>Rr,bytesToNumberLE:()=>yi,concatBytes:()=>mo,createHmacDrbg:()=>Tc,ensureBytes:()=>Rt,equalBytes:()=>Rm,hexToBytes:()=>zn,hexToNumber:()=>wc,isBytes:()=>rr,numberToBytesBE:()=>nn,numberToBytesLE:()=>hi,numberToHexUnpadded:()=>Wf,numberToVarBytesBE:()=>Pm,utf8ToBytes:()=>Om,validateObject:()=>on});var Qf=BigInt(0),mi=BigInt(1),Im=BigInt(2);function rr(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Bm=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function kn(r){if(!rr(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=Bm[r[e]];return t}function Wf(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function wc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Pr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Vf(r){if(r>=Pr._0&&r<=Pr._9)return r-Pr._0;if(r>=Pr._A&&r<=Pr._F)return r-(Pr._A-10);if(r>=Pr._a&&r<=Pr._f)return r-(Pr._a-10)}function zn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=Vf(r.charCodeAt(s)),c=Vf(r.charCodeAt(s+1));if(i===void 0||c===void 0){let f=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+c}return n}function Rr(r){return wc(kn(r))}function yi(r){if(!rr(r))throw new Error("Uint8Array expected");return wc(kn(Uint8Array.from(r).reverse()))}function nn(r,t){return zn(r.toString(16).padStart(t*2,"0"))}function hi(r,t){return nn(r,t).reverse()}function Pm(r){return zn(Wf(r))}function Rt(r,t,e){let n;if(typeof t=="string")try{n=zn(t)}catch(s){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${s}`)}else if(rr(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(`${r} expected ${e} bytes, got ${o}`);return n}function mo(...r){let t=0;for(let o=0;o<r.length;o++){let s=r[o];if(!rr(s))throw new Error("Uint8Array expected");t+=s.length}let e=new Uint8Array(t),n=0;for(let o=0;o<r.length;o++){let s=r[o];e.set(s,n),n+=s.length}return e}function Rm(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Om(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Nm(r){let t;for(t=0;r>Qf;r>>=mi,t+=1);return t}function km(r,t){return r>>BigInt(t)&mi}var zm=(r,t,e)=>r|(e?mi:Qf)<<BigInt(t),es=r=>(Im<<BigInt(r-1))-mi,bc=r=>new Uint8Array(r),jf=r=>Uint8Array.from(r);function Tc(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=bc(r),o=bc(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...m)=>e(o,n,...m),f=(m=bc())=>{o=c(jf([0]),m),n=c(),m.length!==0&&(o=c(jf([1]),m),n=c())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let m=0,T=[];for(;m<t;){n=c();let v=n.slice();T.push(v),m+=n.length}return mo(...T)};return(m,T)=>{i(),f(m);let v;for(;!(v=T(l()));)f();return i(),v}}var Dm={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||rr(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function on(r,t,e={}){let n=(o,s,i)=>{let c=Dm[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let f=r[o];if(!(i&&f===void 0)&&!c(f,r))throw new Error(`Invalid param ${String(o)}=${f} (${typeof f}), expected ${s}`)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var ut=BigInt(0),tt=BigInt(1),Dn=BigInt(2),Mm=BigInt(3),Sc=BigInt(4),Yf=BigInt(5),Zf=BigInt(8),Gm=BigInt(9),Lm=BigInt(16);function dt(r,t){let e=r%t;return e>=ut?e:t+e}function qm(r,t,e){if(e<=ut||t<ut)throw new Error("Expected power/modulo > 0");if(e===tt)return ut;let n=tt;for(;t>ut;)t&tt&&(n=n*r%e),r=r*r%e,t>>=tt;return n}function Ot(r,t,e){let n=r;for(;t-- >ut;)n*=n,n%=e;return n}function Ai(r,t){if(r===ut||t<=ut)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=dt(r,t),n=t,o=ut,s=tt,i=tt,c=ut;for(;e!==ut;){let l=n/e,h=n%e,m=o-i*l,T=s-c*l;n=e,e=h,o=i,s=c,i=m,c=T}if(n!==tt)throw new Error("invert: does not exist");return dt(o,t)}function Km(r){let t=(r-tt)/Dn,e,n,o;for(e=r-tt,n=0;e%Dn===ut;e/=Dn,n++);for(o=Dn;o<r&&qm(o,t,r)!==r-tt;o++);if(n===1){let i=(r+tt)/Sc;return function(f,l){let h=f.pow(l,i);if(!f.eql(f.sqr(h),l))throw new Error("Cannot find square root");return h}}let s=(e+tt)/Dn;return function(c,f){if(c.pow(f,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=n,h=c.pow(c.mul(c.ONE,o),e),m=c.pow(f,s),T=c.pow(f,e);for(;!c.eql(T,c.ONE);){if(c.eql(T,c.ZERO))return c.ZERO;let v=1;for(let y=c.sqr(T);v<l&&!c.eql(y,c.ONE);v++)y=c.sqr(y);let b=c.pow(h,tt<<BigInt(l-v-1));h=c.sqr(b),m=c.mul(m,b),T=c.mul(T,h),l=v}return m}}function Hm(r){if(r%Sc===Mm){let t=(r+tt)/Sc;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Zf===Yf){let t=(r-Yf)/Zf;return function(n,o){let s=n.mul(o,Dn),i=n.pow(s,t),c=n.mul(o,i),f=n.mul(n.mul(c,Dn),i),l=n.mul(c,n.sub(f,n.ONE));if(!n.eql(n.sqr(l),o))throw new Error("Cannot find square root");return l}}return r%Lm,Km(r)}var Fm=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ec(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Fm.reduce((n,o)=>(n[o]="function",n),t);return on(r,e)}function $m(r,t,e){if(e<ut)throw new Error("Expected power > 0");if(e===ut)return r.ONE;if(e===tt)return t;let n=r.ONE,o=t;for(;e>ut;)e&tt&&(n=r.mul(n,o)),o=r.sqr(o),e>>=tt;return n}function Vm(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function vc(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Xf(r,t,e=!1,n={}){if(r<=ut)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:s}=vc(r,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Hm(r),c=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:es(o),ZERO:ut,ONE:tt,create:f=>dt(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof f}`);return ut<=f&&f<r},is0:f=>f===ut,isOdd:f=>(f&tt)===tt,neg:f=>dt(-f,r),eql:(f,l)=>f===l,sqr:f=>dt(f*f,r),add:(f,l)=>dt(f+l,r),sub:(f,l)=>dt(f-l,r),mul:(f,l)=>dt(f*l,r),pow:(f,l)=>$m(c,f,l),div:(f,l)=>dt(f*Ai(l,r),r),sqrN:f=>f*f,addN:(f,l)=>f+l,subN:(f,l)=>f-l,mulN:(f,l)=>f*l,inv:f=>Ai(f,r),sqrt:n.sqrt||(f=>i(c,f)),invertBatch:f=>Vm(c,f),cmov:(f,l,h)=>h?l:f,toBytes:f=>e?hi(f,s):nn(f,s),fromBytes:f=>{if(f.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${f.length}`);return e?yi(f):Rr(f)}});return Object.freeze(c)}function Jf(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Cc(r){let t=Jf(r);return t+Math.ceil(t/2)}function ed(r,t,e=!1){let n=r.length,o=Jf(t),s=Cc(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=e?Rr(r):yi(r),c=dt(i,t-tt)+tt;return e?hi(c,o):nn(c,o)}var Qm=BigInt(0),Uc=BigInt(1);function td(r,t){let e=(o,s)=>{let i=s.negate();return o?i:s},n=o=>{let s=Math.ceil(t/o)+1,i=2**(o-1);return{windows:s,windowSize:i}};return{constTimeNegate:e,unsafeLadder(o,s){let i=r.ZERO,c=o;for(;s>Qm;)s&Uc&&(i=i.add(c)),c=c.double(),s>>=Uc;return i},precomputeWindow(o,s){let{windows:i,windowSize:c}=n(s),f=[],l=o,h=l;for(let m=0;m<i;m++){h=l,f.push(h);for(let T=1;T<c;T++)h=h.add(l),f.push(h);l=h.double()}return f},wNAF(o,s,i){let{windows:c,windowSize:f}=n(o),l=r.ZERO,h=r.BASE,m=BigInt(2**o-1),T=2**o,v=BigInt(o);for(let b=0;b<c;b++){let y=b*f,w=Number(i&m);i>>=v,w>f&&(w-=T,i+=Uc);let E=y,k=y+Math.abs(w)-1,P=b%2!==0,$=w<0;w===0?h=h.add(e(P,s[E])):l=l.add(e($,s[k]))}return{p:l,f:h}},wNAFCached(o,s,i,c){let f=o._WINDOW_SIZE||1,l=s.get(o);return l||(l=this.precomputeWindow(o,f),f!==1&&s.set(o,c(l))),this.wNAF(f,l,i)}}}function Ic(r){return Ec(r.Fp),on(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...vc(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function Wm(r){let t=Ic(r);on(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Ym,hexToBytes:Zm}=_c,Mn={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(r){let{Err:t}=Mn;if(r.length<2||r[0]!==2)throw new t("Invalid signature integer tag");let e=r[1],n=r.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Ym(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=Mn,e=typeof r=="string"?Zm(r):r;if(!rr(e))throw new Error("ui8a expected");let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");let{d:o,l:s}=Mn._parseInt(e.subarray(2)),{d:i,l:c}=Mn._parseInt(s);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s:i}},hexFromSig(r){let t=l=>Number.parseInt(l[0],16)&8?"00"+l:l,e=l=>{let h=l.toString(16);return h.length&1?`0${h}`:h},n=t(e(r.s)),o=t(e(r.r)),s=n.length/2,i=o.length/2,c=e(s),f=e(i);return`30${e(i+s+4)}02${f}${o}02${c}${n}`}},Or=BigInt(0),Ht=BigInt(1),Xx=BigInt(2),rd=BigInt(3),Jx=BigInt(4);function Xm(r){let t=Wm(r),{Fp:e}=t,n=t.toBytes||((b,y,w)=>{let E=y.toAffine();return mo(Uint8Array.from([4]),e.toBytes(E.x),e.toBytes(E.y))}),o=t.fromBytes||(b=>{let y=b.subarray(1),w=e.fromBytes(y.subarray(0,e.BYTES)),E=e.fromBytes(y.subarray(e.BYTES,2*e.BYTES));return{x:w,y:E}});function s(b){let{a:y,b:w}=t,E=e.sqr(b),k=e.mul(E,b);return e.add(e.add(k,e.mul(b,y)),w)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function i(b){return typeof b=="bigint"&&Or<b&&b<t.n}function c(b){if(!i(b))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function f(b){let{allowedPrivateKeyLengths:y,nByteLength:w,wrapPrivateKey:E,n:k}=t;if(y&&typeof b!="bigint"){if(rr(b)&&(b=kn(b)),typeof b!="string"||!y.includes(b.length))throw new Error("Invalid key");b=b.padStart(w*2,"0")}let P;try{P=typeof b=="bigint"?b:Rr(Rt("private key",b,w))}catch{throw new Error(`private key must be ${w} bytes, hex or bigint, not ${typeof b}`)}return E&&(P=dt(P,k)),c(P),P}let l=new Map;function h(b){if(!(b instanceof m))throw new Error("ProjectivePoint expected")}class m{constructor(y,w,E){if(this.px=y,this.py=w,this.pz=E,y==null||!e.isValid(y))throw new Error("x required");if(w==null||!e.isValid(w))throw new Error("y required");if(E==null||!e.isValid(E))throw new Error("z required")}static fromAffine(y){let{x:w,y:E}=y||{};if(!y||!e.isValid(w)||!e.isValid(E))throw new Error("invalid affine point");if(y instanceof m)throw new Error("projective point not allowed");let k=P=>e.eql(P,e.ZERO);return k(w)&&k(E)?m.ZERO:new m(w,E,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(y){let w=e.invertBatch(y.map(E=>E.pz));return y.map((E,k)=>E.toAffine(w[k])).map(m.fromAffine)}static fromHex(y){let w=m.fromAffine(o(Rt("pointHex",y)));return w.assertValidity(),w}static fromPrivateKey(y){return m.BASE.multiply(f(y))}_setWindowSize(y){this._WINDOW_SIZE=y,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:y,y:w}=this.toAffine();if(!e.isValid(y)||!e.isValid(w))throw new Error("bad point: x or y not FE");let E=e.sqr(w),k=s(y);if(!e.eql(E,k))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y}=this.toAffine();if(e.isOdd)return!e.isOdd(y);throw new Error("Field doesn't support isOdd")}equals(y){h(y);let{px:w,py:E,pz:k}=this,{px:P,py:$,pz:M}=y,z=e.eql(e.mul(w,M),e.mul(P,k)),L=e.eql(e.mul(E,M),e.mul($,k));return z&&L}negate(){return new m(this.px,e.neg(this.py),this.pz)}double(){let{a:y,b:w}=t,E=e.mul(w,rd),{px:k,py:P,pz:$}=this,M=e.ZERO,z=e.ZERO,L=e.ZERO,K=e.mul(k,k),we=e.mul(P,P),te=e.mul($,$),W=e.mul(k,P);return W=e.add(W,W),L=e.mul(k,$),L=e.add(L,L),M=e.mul(y,L),z=e.mul(E,te),z=e.add(M,z),M=e.sub(we,z),z=e.add(we,z),z=e.mul(M,z),M=e.mul(W,M),L=e.mul(E,L),te=e.mul(y,te),W=e.sub(K,te),W=e.mul(y,W),W=e.add(W,L),L=e.add(K,K),K=e.add(L,K),K=e.add(K,te),K=e.mul(K,W),z=e.add(z,K),te=e.mul(P,$),te=e.add(te,te),K=e.mul(te,W),M=e.sub(M,K),L=e.mul(te,we),L=e.add(L,L),L=e.add(L,L),new m(M,z,L)}add(y){h(y);let{px:w,py:E,pz:k}=this,{px:P,py:$,pz:M}=y,z=e.ZERO,L=e.ZERO,K=e.ZERO,we=t.a,te=e.mul(t.b,rd),W=e.mul(w,P),ve=e.mul(E,$),Ce=e.mul(k,M),Ve=e.add(w,E),_=e.add(P,$);Ve=e.mul(Ve,_),_=e.add(W,ve),Ve=e.sub(Ve,_),_=e.add(w,k);let B=e.add(P,M);return _=e.mul(_,B),B=e.add(W,Ce),_=e.sub(_,B),B=e.add(E,k),z=e.add($,M),B=e.mul(B,z),z=e.add(ve,Ce),B=e.sub(B,z),K=e.mul(we,_),z=e.mul(te,Ce),K=e.add(z,K),z=e.sub(ve,K),K=e.add(ve,K),L=e.mul(z,K),ve=e.add(W,W),ve=e.add(ve,W),Ce=e.mul(we,Ce),_=e.mul(te,_),ve=e.add(ve,Ce),Ce=e.sub(W,Ce),Ce=e.mul(we,Ce),_=e.add(_,Ce),W=e.mul(ve,_),L=e.add(L,W),W=e.mul(B,_),z=e.mul(Ve,z),z=e.sub(z,W),W=e.mul(Ve,ve),K=e.mul(B,K),K=e.add(K,W),new m(z,L,K)}subtract(y){return this.add(y.negate())}is0(){return this.equals(m.ZERO)}wNAF(y){return v.wNAFCached(this,l,y,w=>{let E=e.invertBatch(w.map(k=>k.pz));return w.map((k,P)=>k.toAffine(E[P])).map(m.fromAffine)})}multiplyUnsafe(y){let w=m.ZERO;if(y===Or)return w;if(c(y),y===Ht)return this;let{endo:E}=t;if(!E)return v.unsafeLadder(this,y);let{k1neg:k,k1:P,k2neg:$,k2:M}=E.splitScalar(y),z=w,L=w,K=this;for(;P>Or||M>Or;)P&Ht&&(z=z.add(K)),M&Ht&&(L=L.add(K)),K=K.double(),P>>=Ht,M>>=Ht;return k&&(z=z.negate()),$&&(L=L.negate()),L=new m(e.mul(L.px,E.beta),L.py,L.pz),z.add(L)}multiply(y){c(y);let w=y,E,k,{endo:P}=t;if(P){let{k1neg:$,k1:M,k2neg:z,k2:L}=P.splitScalar(w),{p:K,f:we}=this.wNAF(M),{p:te,f:W}=this.wNAF(L);K=v.constTimeNegate($,K),te=v.constTimeNegate(z,te),te=new m(e.mul(te.px,P.beta),te.py,te.pz),E=K.add(te),k=we.add(W)}else{let{p:$,f:M}=this.wNAF(w);E=$,k=M}return m.normalizeZ([E,k])[0]}multiplyAndAddUnsafe(y,w,E){let k=m.BASE,P=(M,z)=>z===Or||z===Ht||!M.equals(k)?M.multiplyUnsafe(z):M.multiply(z),$=P(this,w).add(P(y,E));return $.is0()?void 0:$}toAffine(y){let{px:w,py:E,pz:k}=this,P=this.is0();y==null&&(y=P?e.ONE:e.inv(k));let $=e.mul(w,y),M=e.mul(E,y),z=e.mul(k,y);if(P)return{x:e.ZERO,y:e.ZERO};if(!e.eql(z,e.ONE))throw new Error("invZ was invalid");return{x:$,y:M}}isTorsionFree(){let{h:y,isTorsionFree:w}=t;if(y===Ht)return!0;if(w)return w(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:y,clearCofactor:w}=t;return y===Ht?this:w?w(m,this):this.multiplyUnsafe(t.h)}toRawBytes(y=!0){return this.assertValidity(),n(m,this,y)}toHex(y=!0){return kn(this.toRawBytes(y))}}m.BASE=new m(t.Gx,t.Gy,e.ONE),m.ZERO=new m(e.ZERO,e.ONE,e.ZERO);let T=t.nBitLength,v=td(m,t.endo?Math.ceil(T/2):T);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:f,weierstrassEquation:s,isWithinCurveOrder:i}}function Jm(r){let t=Ic(r);return on(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function nd(r){let t=Jm(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(_){return Or<_&&_<e.ORDER}function c(_){return dt(_,n)}function f(_){return Ai(_,n)}let{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:m,isWithinCurveOrder:T}=Xm({...t,toBytes(_,B,F){let re=B.toAffine(),ne=e.toBytes(re.x),xe=mo;return F?xe(Uint8Array.from([B.hasEvenY()?2:3]),ne):xe(Uint8Array.from([4]),ne,e.toBytes(re.y))},fromBytes(_){let B=_.length,F=_[0],re=_.subarray(1);if(B===o&&(F===2||F===3)){let ne=Rr(re);if(!i(ne))throw new Error("Point is not on curve");let xe=m(ne),ke=e.sqrt(xe),Te=(ke&Ht)===Ht;return(F&1)===1!==Te&&(ke=e.neg(ke)),{x:ne,y:ke}}else if(B===s&&F===4){let ne=e.fromBytes(re.subarray(0,e.BYTES)),xe=e.fromBytes(re.subarray(e.BYTES,2*e.BYTES));return{x:ne,y:xe}}else throw new Error(`Point of length ${B} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),v=_=>kn(nn(_,t.nByteLength));function b(_){let B=n>>Ht;return _>B}function y(_){return b(_)?c(-_):_}let w=(_,B,F)=>Rr(_.slice(B,F));class E{constructor(B,F,re){this.r=B,this.s=F,this.recovery=re,this.assertValidity()}static fromCompact(B){let F=t.nByteLength;return B=Rt("compactSignature",B,F*2),new E(w(B,0,F),w(B,F,2*F))}static fromDER(B){let{r:F,s:re}=Mn.toSig(Rt("DER",B));return new E(F,re)}assertValidity(){if(!T(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!T(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(B){return new E(this.r,this.s,B)}recoverPublicKey(B){let{r:F,s:re,recovery:ne}=this,xe=L(Rt("msgHash",B));if(ne==null||![0,1,2,3].includes(ne))throw new Error("recovery id invalid");let ke=ne===2||ne===3?F+t.n:F;if(ke>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let Te=ne&1?"03":"02",De=l.fromHex(Te+v(ke)),se=f(ke),Ke=c(-xe*se),St=c(re*se),ot=l.BASE.multiplyAndAddUnsafe(De,Ke,St);if(!ot)throw new Error("point at infinify");return ot.assertValidity(),ot}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new E(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return zn(this.toDERHex())}toDERHex(){return Mn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return zn(this.toCompactHex())}toCompactHex(){return v(this.r)+v(this.s)}}let k={isValidPrivateKey(_){try{return h(_),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{let _=Cc(t.n);return ed(t.randomBytes(_),t.n)},precompute(_=8,B=l.BASE){return B._setWindowSize(_),B.multiply(BigInt(3)),B}};function P(_,B=!0){return l.fromPrivateKey(_).toRawBytes(B)}function $(_){let B=rr(_),F=typeof _=="string",re=(B||F)&&_.length;return B?re===o||re===s:F?re===2*o||re===2*s:_ instanceof l}function M(_,B,F=!0){if($(_))throw new Error("first arg must be private key");if(!$(B))throw new Error("second arg must be public key");return l.fromHex(B).multiply(h(_)).toRawBytes(F)}let z=t.bits2int||function(_){let B=Rr(_),F=_.length*8-t.nBitLength;return F>0?B>>BigInt(F):B},L=t.bits2int_modN||function(_){return c(z(_))},K=es(t.nBitLength);function we(_){if(typeof _!="bigint")throw new Error("bigint expected");if(!(Or<=_&&_<K))throw new Error(`bigint expected < 2^${t.nBitLength}`);return nn(_,t.nByteLength)}function te(_,B,F=W){if(["recovered","canonical"].some(st=>st in F))throw new Error("sign() legacy options not supported");let{hash:re,randomBytes:ne}=t,{lowS:xe,prehash:ke,extraEntropy:Te}=F;xe==null&&(xe=!0),_=Rt("msgHash",_),ke&&(_=Rt("prehashed msgHash",re(_)));let De=L(_),se=h(B),Ke=[we(se),we(De)];if(Te!=null){let st=Te===!0?ne(e.BYTES):Te;Ke.push(Rt("extraEntropy",st))}let St=mo(...Ke),ot=De;function kt(st){let pt=z(st);if(!T(pt))return;let ar=f(pt),Fe=l.BASE.multiply(pt).toAffine(),xt=c(Fe.x);if(xt===Or)return;let Qt=c(ar*c(ot+xt*se));if(Qt===Or)return;let hn=(Fe.x===xt?0:2)|Number(Fe.y&Ht),qr=Qt;return xe&&b(Qt)&&(qr=y(Qt),hn^=1),new E(xt,qr,hn)}return{seed:St,k2sig:kt}}let W={lowS:t.lowS,prehash:!1},ve={lowS:t.lowS,prehash:!1};function Ce(_,B,F=W){let{seed:re,k2sig:ne}=te(_,B,F),xe=t;return Tc(xe.hash.outputLen,xe.nByteLength,xe.hmac)(re,ne)}l.BASE._setWindowSize(8);function Ve(_,B,F,re=ve){let ne=_;if(B=Rt("msgHash",B),F=Rt("publicKey",F),"strict"in re)throw new Error("options.strict was renamed to lowS");let{lowS:xe,prehash:ke}=re,Te,De;try{if(typeof ne=="string"||rr(ne))try{Te=E.fromDER(ne)}catch(Fe){if(!(Fe instanceof Mn.Err))throw Fe;Te=E.fromCompact(ne)}else if(typeof ne=="object"&&typeof ne.r=="bigint"&&typeof ne.s=="bigint"){let{r:Fe,s:xt}=ne;Te=new E(Fe,xt)}else throw new Error("PARSE");De=l.fromHex(F)}catch(Fe){if(Fe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(xe&&Te.hasHighS())return!1;ke&&(B=t.hash(B));let{r:se,s:Ke}=Te,St=L(B),ot=f(Ke),kt=c(St*ot),st=c(se*ot),pt=l.BASE.multiplyAndAddUnsafe(De,kt,st)?.toAffine();return pt?c(pt.x)===se:!1}return{CURVE:t,getPublicKey:P,getSharedSecret:M,sign:Ce,verify:Ve,ProjectivePoint:l,Signature:E,utils:k}}function ey(r){return{hash:r,hmac:(t,...e)=>fr(r,t,Sn(...e)),randomBytes:Ju}}function od(r,t){let e=n=>nd({...r,...ey(n)});return Object.freeze({...e(t),create:e})}var ad=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),sd=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ty=BigInt(1),Bc=BigInt(2),id=(r,t)=>(r+t/Bc)/t;function ry(r){let t=ad,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),f=BigInt(88),l=r*r*r%t,h=l*l*r%t,m=Ot(h,e,t)*h%t,T=Ot(m,e,t)*h%t,v=Ot(T,Bc,t)*l%t,b=Ot(v,o,t)*v%t,y=Ot(b,s,t)*b%t,w=Ot(y,c,t)*y%t,E=Ot(w,f,t)*w%t,k=Ot(E,c,t)*y%t,P=Ot(k,e,t)*h%t,$=Ot(P,i,t)*b%t,M=Ot($,n,t)*l%t,z=Ot(M,Bc,t);if(!Pc.eql(Pc.sqr(z),r))throw new Error("Cannot find square root");return z}var Pc=Xf(ad,void 0,void 0,{sqrt:ry}),nr=od({a:BigInt(0),b:BigInt(7),Fp:Pc,n:sd,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=sd,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ty*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=id(s*r,t),f=id(-n*r,t),l=dt(r-c*e-f*o,t),h=dt(-c*n-f*s,t),m=l>i,T=h>i;if(m&&(l=t-l),T&&(h=t-h),l>i||h>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:m,k1:l,k2neg:T,k2:h}}}},Wo),cb=BigInt(0);var ub=nr.ProjectivePoint;function xi(r){if(!Number.isSafeInteger(r))throw new Error(`Wrong integer: ${r}`)}function Rc(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function ud(...r){let t=s=>s,e=(s,i)=>c=>s(i(c)),n=r.map(s=>s.encode).reduceRight(e,t),o=r.map(s=>s.decode).reduce(e,t);return{encode:n,decode:o}}function ny(r){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(e=>{if(e<0||e>=r.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${r.length})`);return r[e]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(e=>{if(typeof e!="string")throw new Error(`alphabet.decode: not string element=${e}`);let n=r.indexOf(e);if(n===-1)throw new Error(`Unknown letter: "${e}". Allowed: ${r}`);return n})}}}function oy(r=""){if(typeof r!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let e of t)if(typeof e!="string")throw new Error(`join.encode: non-string input=${e}`);return t.join(r)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(r)}}}function cd(r,t,e){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(e<2)throw new Error(`convertRadix: wrong to=${e}, base cannot be less than 2`);if(!Array.isArray(r))throw new Error("convertRadix: data should be array");if(!r.length)return[];let n=0,o=[],s=Array.from(r);for(s.forEach(i=>{if(i<0||i>=t)throw new Error(`Wrong integer: ${i}`)});;){let i=0,c=!0;for(let f=n;f<s.length;f++){let l=s[f],h=t*i+l;if(!Number.isSafeInteger(h)||t*i/t!==i||h-l!==t*i)throw new Error("convertRadix: carry overflow");i=h%e;let m=Math.floor(h/e);if(s[f]=m,!Number.isSafeInteger(m)||m*e+i!==h)throw new Error("convertRadix: carry overflow");if(c)m?c=!1:n=f;else continue}if(o.push(i),c)break}for(let i=0;i<r.length-1&&r[i]===0;i++)o.push(0);return o.reverse()}function sy(r){return{encode:t=>{if(!Rc(t))throw new Error("radix.encode input should be Uint8Array");return cd(Array.from(t),2**8,r)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(cd(t,r,2**8))}}}function iy(r,t){if(typeof t!="function")throw new Error("checksum fn should be function");return{encode(e){if(!Rc(e))throw new Error("checksum.encode: input should be Uint8Array");let n=t(e).slice(0,r),o=new Uint8Array(e.length+r);return o.set(e),o.set(n,e.length),o},decode(e){if(!Rc(e))throw new Error("checksum.decode: input should be Uint8Array");let n=e.slice(0,-r),o=t(n).slice(0,r),s=e.slice(-r);for(let i=0;i<r;i++)if(o[i]!==s[i])throw new Error("Invalid checksum");return n}}}var ay=r=>ud(sy(58),ny(r),oy("")),cy=ay("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var fd=r=>ud(iy(4,t=>r(r(t))),cy);var bi=nr.ProjectivePoint,Oc=fd(Wo);function dd(r){return BigInt(`0x${_n(r)}`)}function uy(r){return uo(r.toString(16).padStart(64,"0"))}var fy=qa("Bitcoin seed"),Nc={private:76066276,public:76067358},kc=2147483648,dy=r=>$f(Wo(r)),ly=r=>ur(r).getUint32(0,!1),wi=r=>{if(!Number.isSafeInteger(r)||r<0||r>2**32-1)throw new Error(`Invalid number=${r}. Should be from 0 to 2 ** 32 - 1`);let t=new Uint8Array(4);return ur(t).setUint32(0,r,!1),t},Ti=class r{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return ly(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){let t=this.privateKey;if(!t)throw new Error("No private key");return Oc.encode(this.serialize(this.versions.private,Sn(new Uint8Array([0]),t)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return Oc.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(t,e=Nc){if(Xt(t),8*t.length<128||8*t.length>512)throw new Error(`HDKey: wrong seed length=${t.length}. Should be between 128 and 512 bits; 256 bits is advised)`);let n=fr(In,fy,t);return new r({versions:e,chainCode:n.slice(32),privateKey:n.slice(0,32)})}static fromExtendedKey(t,e=Nc){let n=Oc.decode(t),o=ur(n),s=o.getUint32(0,!1),i={versions:e,depth:n[4],parentFingerprint:o.getUint32(5,!1),index:o.getUint32(9,!1),chainCode:n.slice(13,45)},c=n.slice(45),f=c[0]===0;if(s!==e[f?"private":"public"])throw new Error("Version mismatch");return f?new r({...i,privateKey:c.slice(1)}):new r({...i,publicKey:c})}static fromJSON(t){return r.fromExtendedKey(t.xpriv)}constructor(t){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!t||typeof t!="object")throw new Error("HDKey.constructor must not be called directly");if(this.versions=t.versions||Nc,this.depth=t.depth||0,this.chainCode=t.chainCode,this.index=t.index||0,this.parentFingerprint=t.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(t.publicKey&&t.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(t.privateKey){if(!nr.utils.isValidPrivateKey(t.privateKey))throw new Error("Invalid private key");this.privKey=typeof t.privateKey=="bigint"?t.privateKey:dd(t.privateKey),this.privKeyBytes=uy(this.privKey),this.pubKey=nr.getPublicKey(t.privateKey,!0)}else if(t.publicKey)this.pubKey=bi.fromHex(t.publicKey).toRawBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=dy(this.pubKey)}derive(t){if(!/^[mM]'?/.test(t))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(t))return this;let e=t.replace(/^[mM]'?\//,"").split("/"),n=this;for(let o of e){let s=/^(\d+)('?)$/.exec(o),i=s&&s[1];if(!s||s.length!==3||typeof i!="string")throw new Error(`Invalid child index: ${o}`);let c=+i;if(!Number.isSafeInteger(c)||c>=kc)throw new Error("Invalid index");s[2]==="'"&&(c+=kc),n=n.deriveChild(c)}return n}deriveChild(t){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let e=wi(t);if(t>=kc){let c=this.privateKey;if(!c)throw new Error("Could not derive hardened child key");e=Sn(new Uint8Array([0]),c,e)}else e=Sn(this.pubKey,e);let n=fr(In,this.chainCode,e),o=dd(n.slice(0,32)),s=n.slice(32);if(!nr.utils.isValidPrivateKey(o))throw new Error("Tweak bigger than curve order");let i={versions:this.versions,chainCode:s,depth:this.depth+1,parentFingerprint:this.fingerprint,index:t};try{if(this.privateKey){let c=dt(this.privKey+o,nr.CURVE.n);if(!nr.utils.isValidPrivateKey(c))throw new Error("The tweak was out of range or the resulted private key is invalid");i.privateKey=c}else{let c=bi.fromHex(this.pubKey).add(bi.fromPrivateKey(o));if(c.equals(bi.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");i.publicKey=c.toRawBytes(!0)}return new r(i)}catch{return this.deriveChild(t+1)}}sign(t){if(!this.privateKey)throw new Error("No privateKey set!");return Xt(t,32),nr.sign(t,this.privKey).toCompactRawBytes()}verify(t,e){if(Xt(t,32),Xt(e,64),!this.publicKey)throw new Error("No publicKey set!");let n;try{n=nr.Signature.fromCompact(e)}catch{return!1}return nr.verify(n,t,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(t,e){if(!this.chainCode)throw new Error("No chainCode set");return Xt(e,33),Sn(wi(t),new Uint8Array([this.depth]),wi(this.parentFingerprint),wi(this.index),this.chainCode,e)}};var sn=class sn extends It{constructor(e){super();let n=Be.fromHexInput(e);if(n.toUint8Array().length!==sn.LENGTH)throw new Error(`PublicKey length should be ${sn.LENGTH}`);this.key=n}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}verifySignature(e){let{message:n,signature:o}=e,s=Be.fromHexInput(n).toUint8Array(),i=Cn(s),c=o.toUint8Array();return go.verify(c,i,this.toUint8Array())}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let n=e.deserializeBytes();return new sn(n)}static load(e){let n=e.deserializeBytes();return new sn(n)}static isPublicKey(e){return e instanceof sn}};sn.LENGTH=65;var Ft=sn,dr=class dr extends Un{constructor(e){super();let n=Be.fromHexInput(e);if(n.toUint8Array().length!==dr.LENGTH)throw new Error(`PrivateKey length should be ${dr.LENGTH}`);this.key=n}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}sign(e){let n=Be.fromHexInput(e),o=Cn(n.toUint8Array()),s=go.sign(o,this.key.toUint8Array());return new kr(s.toCompactRawBytes())}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let n=e.deserializeBytes();return new dr(n)}static generate(){let e=go.utils.randomPrivateKey();return new dr(e)}publicKey(){let e=go.getPublicKey(this.key.toUint8Array(),!1);return new Ft(e)}static fromDerivationPath(e,n){if(!Xa(e))throw new Error(`Invalid derivation path ${e}`);return dr.fromDerivationPathInner(e,Yo(n))}static fromDerivationPathInner(e,n){let{privateKey:o}=Ti.fromMasterSeed(n).derive(e);if(o===null)throw new Error("Invalid key");return new dr(o)}static isPrivateKey(e){return e instanceof dr}};dr.LENGTH=32;var Nr=dr,an=class an extends Jt{constructor(e){super();let n=Be.fromHexInput(e);if(n.toUint8Array().length!==an.LENGTH)throw new Error(`Signature length should be ${an.LENGTH}, recieved ${n.toUint8Array().length}`);this.data=n}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let n=e.deserializeBytes();return new an(n)}static load(e){let n=e.deserializeBytes();return new an(n)}static isSignature(e){return e instanceof an}};an.LENGTH=64;var kr=an;var je=class r extends It{constructor(e){super();this.publicKey=e}toUint8Array(){return this.publicKey.toUint8Array()}toString(){return this.publicKey.toString()}verifySignature(e){let{message:n,signature:o}=e;return this.publicKey.verifySignature({message:n,signature:o})}serialize(e){if(this.publicKey instanceof qe)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else if(this.publicKey instanceof Ft)e.serializeU32AsUleb128(1),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let n=e.deserializeUleb128AsU32();switch(n){case 0:return new r(qe.load(e));case 1:return new r(Ft.load(e));default:throw new Error(`Unknown variant index for AnyPublicKey: ${n}`)}}static isPublicKey(e){return e instanceof r}isEd25519(){return this.publicKey instanceof qe}isSecp256k1PublicKey(){return this.publicKey instanceof Ft}};var Gn=class r extends It{constructor(e){super();let{publicKeys:n,signaturesRequired:o}=e;if(o<1)throw new Error("The number of required signatures needs to be greater then 0");if(n.length<o)throw new Error(`Provided ${n.length} public keys is smaller than the ${o} required signatures`);let s=[];n.forEach(i=>{i instanceof je?s.push(i):s.push(new je(i))}),this.publicKeys=s,this.signaturesRequired=o}toUint8Array(){return this.bcsToBytes()}createBitmap(e){let{bits:n}=e,o=128,s=new Uint8Array([0,0,0,0]),i=new Set;return n.forEach((c,f)=>{if(f+1>this.publicKeys.length)throw new Error(`Signature index ${f+1} is out of public keys range, ${this.publicKeys.length}.`);if(i.has(c))throw new Error(`Duplicate bit ${c} detected.`);i.add(c);let l=Math.floor(c/8),h=s[l];h|=o>>c%8,s[l]=h}),s}toString(){return Be.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){throw new Error("not implemented")}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let n=e.deserializeVector(je),o=e.deserializeU8();return new r({publicKeys:n,signaturesRequired:o})}};var zr=class zr extends ae{constructor(e){super();let{data:n}=e,o=Be.fromHexInput(n);if(o.toUint8Array().length!==zr.LENGTH)throw new Error(`Authentication Key length should be ${zr.LENGTH}`);this.data=o}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let n=e.deserializeFixedBytes(zr.LENGTH);return new zr({data:n})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromPublicKeyAndScheme(e){let{publicKey:n,scheme:o}=e,s;switch(o){case 3:case 2:{let f=n.bcsToBytes();s=new Uint8Array([...f,o]);break}case 0:case 1:{let f=n.toUint8Array(),l=Be.fromHexInput(f).toUint8Array();s=new Uint8Array([...l,o]);break}default:throw new Error(`Scheme ${o} is not supported`)}let i=Cn.create();i.update(s);let c=i.digest();return new zr({data:c})}static fromPublicKey(e){let{publicKey:n}=e,o;if(n instanceof qe)o=0 .valueOf();else if(n instanceof er)o=1 .valueOf();else if(n instanceof je)o=2 .valueOf();else if(n instanceof Gn)o=3 .valueOf();else throw new Error("No supported authentication scheme for public key");return zr.fromPublicKeyAndScheme({publicKey:n,scheme:o})}derivedAddress(){return new H(this.data.toUint8Array())}};zr.LENGTH=32;var or=zr;var Dr=class r{constructor(t){let{privateKey:e,address:n,legacy:o}=t,s=o??!0;if(this.publicKey=e.publicKey(),this.publicKey instanceof qe)s?this.signingScheme=0:(this.publicKey=new je(this.publicKey),this.signingScheme=2);else if(this.publicKey instanceof er)this.signingScheme=1;else if(this.publicKey instanceof Ft)this.publicKey=new je(this.publicKey),this.signingScheme=2;else throw new Error("Can not create new Account, unsupported public key type");this.privateKey=e,this.accountAddress=n}static generate(t){let e=t?.legacy??!0,n,o;switch(t?.scheme){case 2:n=Nr.generate(),o=new je(n.publicKey());break;default:n=Ur.generate(),e===!1?o=new je(n.publicKey()):o=n.publicKey()}let i=or.fromPublicKey({publicKey:o}).derivedAddress();return new r({privateKey:n,address:i,legacy:t?.legacy})}static fromPrivateKey(t){let{privateKey:e,legacy:n}=t,o=n??!0,s;if(e instanceof Nr)s=new je(e.publicKey());else if(e instanceof Ur)o?s=e.publicKey():s=new je(e.publicKey());else throw new Error(`Unsupported private key ${e}`);let c=or.fromPublicKey({publicKey:s}).derivedAddress();return new r({privateKey:e,address:c,legacy:o})}static fromPrivateKeyAndAddress(t){let{privateKey:e,address:n,legacy:o}=t;return new r({privateKey:e,address:n,legacy:o})}static fromDerivationPath(t){let{path:e,mnemonic:n,scheme:o,legacy:s}=t,i;switch(o){case 2:i=Nr.fromDerivationPath(e,n);break;case 0:i=Ur.fromDerivationPath(e,n);break;default:throw new Error(`Unsupported scheme ${o}`)}return r.fromPrivateKey({privateKey:i,legacy:s})}static authKey(t){let{publicKey:e}=t;return or.fromPublicKey({publicKey:e})}sign(t){return this.privateKey.sign(t)}verifySignature(t){let{message:e,signature:n}=t,o=Be.fromHexInput(e).toUint8Array();return this.publicKey.verifySignature({message:o,signature:n})}};var py=`
2
2
  fragment TokenActivitiesFields on token_activities_v2 {
3
3
  after_value
4
4
  before_value
@@ -427,7 +427,7 @@
427
427
  `).forEach(function(i){o=i.indexOf(":"),e=i.substring(0,o).trim().toLowerCase(),n=i.substring(o+1).trim(),!(!e||t[e]&&ih[e])&&(e==="set-cookie"?t[e]?t[e].push(n):t[e]=[n]:t[e]=t[e]?t[e]+", "+n:n)}),t};var hl=Symbol("internals");function is(r){return r&&String(r).trim().toLowerCase()}function qi(r){return r===!1||r==null?r:I.isArray(r)?r.map(qi):String(r)}function ah(r){let t=Object.create(null),e=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=e.exec(r);)t[n[1]]=n[2];return t}var ch=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function Jc(r,t,e,n,o){if(I.isFunction(n))return n.call(this,t,e);if(o&&(t=e),!!I.isString(t)){if(I.isString(n))return t.indexOf(n)!==-1;if(I.isRegExp(n))return n.test(t)}}function uh(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,n)=>e.toUpperCase()+n)}function fh(r,t){let e=I.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(r,n+e,{value:function(o,s,i){return this[n].call(this,t,o,s,i)},configurable:!0})})}var To=class{constructor(t){t&&this.set(t)}set(t,e,n){let o=this;function s(c,f,l){let h=is(f);if(!h)throw new Error("header name must be a non-empty string");let m=I.findKey(o,h);(!m||o[m]===void 0||l===!0||l===void 0&&o[m]!==!1)&&(o[m||f]=qi(c))}let i=(c,f)=>I.forEach(c,(l,h)=>s(l,h,f));return I.isPlainObject(t)||t instanceof this.constructor?i(t,e):I.isString(t)&&(t=t.trim())&&!ch(t)?i(yl(t),e):t!=null&&s(e,t,n),this}get(t,e){if(t=is(t),t){let n=I.findKey(this,t);if(n){let o=this[n];if(!e)return o;if(e===!0)return ah(o);if(I.isFunction(e))return e.call(this,o,n);if(I.isRegExp(e))return e.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=is(t),t){let n=I.findKey(this,t);return!!(n&&this[n]!==void 0&&(!e||Jc(this,this[n],n,e)))}return!1}delete(t,e){let n=this,o=!1;function s(i){if(i=is(i),i){let c=I.findKey(n,i);c&&(!e||Jc(n,n[c],c,e))&&(delete n[c],o=!0)}}return I.isArray(t)?t.forEach(s):s(t),o}clear(t){let e=Object.keys(this),n=e.length,o=!1;for(;n--;){let s=e[n];(!t||Jc(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){let e=this,n={};return I.forEach(this,(o,s)=>{let i=I.findKey(n,s);if(i){e[i]=qi(o),delete e[s];return}let c=t?uh(s):String(s).trim();c!==s&&delete e[s],e[c]=qi(o),n[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let e=Object.create(null);return I.forEach(this,(n,o)=>{n!=null&&n!==!1&&(e[o]=t&&I.isArray(n)?n.join(", "):n)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,e])=>t+": "+e).join(`
428
428
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){let n=new this(t);return e.forEach(o=>n.set(o)),n}static accessor(t){let n=(this[hl]=this[hl]={accessors:{}}).accessors,o=this.prototype;function s(i){let c=is(i);n[c]||(fh(o,i),n[c]=!0)}return I.isArray(t)?t.forEach(s):s(t),this}};To.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);I.reduceDescriptors(To.prototype,({value:r},t)=>{let e=t[0].toUpperCase()+t.slice(1);return{get:()=>r,set(n){this[e]=n}}});I.freezeMethods(To);var _t=To;function as(r,t){let e=this||wo,n=t||e,o=_t.from(n.headers),s=n.data;return I.forEach(r,function(c){s=c.call(e,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function cs(r){return!!(r&&r.__CANCEL__)}function Al(r,t,e){Se.call(this,r??"canceled",Se.ERR_CANCELED,t,e),this.name="CanceledError"}I.inherits(Al,Se,{__CANCEL__:!0});var dn=Al;function eu(r,t,e){let n=e.config.validateStatus;!e.status||!n||n(e.status)?r(e):t(new Se("Request failed with status code "+e.status,[Se.ERR_BAD_REQUEST,Se.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}var xl=Tt.hasStandardBrowserEnv?{write(r,t,e,n,o,s){let i=[r+"="+encodeURIComponent(t)];I.isNumber(e)&&i.push("expires="+new Date(e).toGMTString()),I.isString(n)&&i.push("path="+n),I.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(r){let t=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function tu(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function ru(r,t){return t?r.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):r}function us(r,t){return r&&!tu(t)?ru(r,t):t}var bl=Tt.hasStandardBrowserEnv?function(){let t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a"),n;function o(s){let i=s;return t&&(e.setAttribute("href",i),i=e.href),e.setAttribute("href",i),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:e.pathname.charAt(0)==="/"?e.pathname:"/"+e.pathname}}return n=o(window.location.href),function(i){let c=I.isString(i)?o(i):i;return c.protocol===n.protocol&&c.host===n.host}}():function(){return function(){return!0}}();function nu(r){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return t&&t[1]||""}function dh(r,t){r=r||10;let e=new Array(r),n=new Array(r),o=0,s=0,i;return t=t!==void 0?t:1e3,function(f){let l=Date.now(),h=n[s];i||(i=l),e[o]=f,n[o]=l;let m=s,T=0;for(;m!==o;)T+=e[m++],m=m%r;if(o=(o+1)%r,o===s&&(s=(s+1)%r),l-i<t)return;let v=h&&l-h;return v?Math.round(T*1e3/v):void 0}}var wl=dh;function Tl(r,t){let e=0,n=wl(50,250);return o=>{let s=o.loaded,i=o.lengthComputable?o.total:void 0,c=s-e,f=n(c),l=s<=i;e=s;let h={loaded:s,total:i,progress:i?s/i:void 0,bytes:c,rate:f||void 0,estimated:f&&i&&l?(i-s)/f:void 0,event:o};h[t?"download":"upload"]=!0,r(h)}}var lh=typeof XMLHttpRequest<"u",_l=lh&&function(r){return new Promise(function(e,n){let o=r.data,s=_t.from(r.headers).normalize(),{responseType:i,withXSRFToken:c}=r,f;function l(){r.cancelToken&&r.cancelToken.unsubscribe(f),r.signal&&r.signal.removeEventListener("abort",f)}let h;if(I.isFormData(o)){if(Tt.hasStandardBrowserEnv||Tt.hasStandardBrowserWebWorkerEnv)s.setContentType(!1);else if((h=s.getContentType())!==!1){let[y,...w]=h?h.split(";").map(E=>E.trim()).filter(Boolean):[];s.setContentType([y||"multipart/form-data",...w].join("; "))}}let m=new XMLHttpRequest;if(r.auth){let y=r.auth.username||"",w=r.auth.password?unescape(encodeURIComponent(r.auth.password)):"";s.set("Authorization","Basic "+btoa(y+":"+w))}let T=us(r.baseURL,r.url);m.open(r.method.toUpperCase(),ss(T,r.params,r.paramsSerializer),!0),m.timeout=r.timeout;function v(){if(!m)return;let y=_t.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),E={data:!i||i==="text"||i==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:y,config:r,request:m};eu(function(P){e(P),l()},function(P){n(P),l()},E),m=null}if("onloadend"in m?m.onloadend=v:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(v)},m.onabort=function(){m&&(n(new Se("Request aborted",Se.ECONNABORTED,r,m)),m=null)},m.onerror=function(){n(new Se("Network Error",Se.ERR_NETWORK,r,m)),m=null},m.ontimeout=function(){let w=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded",E=r.transitional||Gi;r.timeoutErrorMessage&&(w=r.timeoutErrorMessage),n(new Se(w,E.clarifyTimeoutError?Se.ETIMEDOUT:Se.ECONNABORTED,r,m)),m=null},Tt.hasStandardBrowserEnv&&(c&&I.isFunction(c)&&(c=c(r)),c||c!==!1&&bl(T))){let y=r.xsrfHeaderName&&r.xsrfCookieName&&xl.read(r.xsrfCookieName);y&&s.set(r.xsrfHeaderName,y)}o===void 0&&s.setContentType(null),"setRequestHeader"in m&&I.forEach(s.toJSON(),function(w,E){m.setRequestHeader(E,w)}),I.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),i&&i!=="json"&&(m.responseType=r.responseType),typeof r.onDownloadProgress=="function"&&m.addEventListener("progress",Tl(r.onDownloadProgress,!0)),typeof r.onUploadProgress=="function"&&m.upload&&m.upload.addEventListener("progress",Tl(r.onUploadProgress)),(r.cancelToken||r.signal)&&(f=y=>{m&&(n(!y||y.type?new dn(null,r,m):y),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(f),r.signal&&(r.signal.aborted?f():r.signal.addEventListener("abort",f)));let b=nu(T);if(b&&Tt.protocols.indexOf(b)===-1){n(new Se("Unsupported protocol "+b+":",Se.ERR_BAD_REQUEST,r));return}m.send(o||null)})};var ou={http:Di,xhr:_l};I.forEach(ou,(r,t)=>{if(r){try{Object.defineProperty(r,"name",{value:t})}catch{}Object.defineProperty(r,"adapterName",{value:t})}});var Sl=r=>`- ${r}`,ph=r=>I.isFunction(r)||r===null||r===!1,Ki={getAdapter:r=>{r=I.isArray(r)?r:[r];let{length:t}=r,e,n,o={};for(let s=0;s<t;s++){e=r[s];let i;if(n=e,!ph(e)&&(n=ou[(i=String(e)).toLowerCase()],n===void 0))throw new Se(`Unknown adapter '${i}'`);if(n)break;o[i||"#"+s]=n}if(!n){let s=Object.entries(o).map(([c,f])=>`adapter ${c} `+(f===!1?"is not supported by the environment":"is not available in the build")),i=t?s.length>1?`since :
429
429
  `+s.map(Sl).join(`
430
- `):" "+Sl(s[0]):"as no adapter specified";throw new Se("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return n},adapters:ou};function su(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new dn(null,r)}function Hi(r){return su(r),r.headers=_t.from(r.headers),r.data=as.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),Ki.getAdapter(r.adapter||wo.adapter)(r).then(function(n){return su(r),n.data=as.call(r,r.transformResponse,n),n.headers=_t.from(n.headers),n},function(n){return cs(n)||(su(r),n&&n.response&&(n.response.data=as.call(r,r.transformResponse,n.response),n.response.headers=_t.from(n.response.headers))),Promise.reject(n)})}var El=r=>r instanceof _t?r.toJSON():r;function Mr(r,t){t=t||{};let e={};function n(l,h,m){return I.isPlainObject(l)&&I.isPlainObject(h)?I.merge.call({caseless:m},l,h):I.isPlainObject(h)?I.merge({},h):I.isArray(h)?h.slice():h}function o(l,h,m){if(I.isUndefined(h)){if(!I.isUndefined(l))return n(void 0,l,m)}else return n(l,h,m)}function s(l,h){if(!I.isUndefined(h))return n(void 0,h)}function i(l,h){if(I.isUndefined(h)){if(!I.isUndefined(l))return n(void 0,l)}else return n(void 0,h)}function c(l,h,m){if(m in t)return n(l,h);if(m in r)return n(void 0,l)}let f={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(l,h)=>o(El(l),El(h),!0)};return I.forEach(Object.keys(Object.assign({},r,t)),function(h){let m=f[h]||o,T=m(r[h],t[h],h);I.isUndefined(T)&&m!==c||(e[h]=T)}),e}var Fi="1.6.2";var iu={};["object","boolean","number","function","string","symbol"].forEach((r,t)=>{iu[r]=function(n){return typeof n===r||"a"+(t<1?"n ":" ")+r}});var vl={};iu.transitional=function(t,e,n){function o(s,i){return"[Axios v"+Fi+"] Transitional option '"+s+"'"+i+(n?". "+n:"")}return(s,i,c)=>{if(t===!1)throw new Se(o(i," has been removed"+(e?" in "+e:"")),Se.ERR_DEPRECATED);return e&&!vl[i]&&(vl[i]=!0,console.warn(o(i," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(s,i,c):!0}};function gh(r,t,e){if(typeof r!="object")throw new Se("options must be an object",Se.ERR_BAD_OPTION_VALUE);let n=Object.keys(r),o=n.length;for(;o-- >0;){let s=n[o],i=t[s];if(i){let c=r[s],f=c===void 0||i(c,s,r);if(f!==!0)throw new Se("option "+s+" must be "+f,Se.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new Se("Unknown option "+s,Se.ERR_BAD_OPTION)}}var $i={assertOptions:gh,validators:iu};var ln=$i.validators,_o=class{constructor(t){this.defaults=t,this.interceptors={request:new Wc,response:new Wc}}request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=Mr(this.defaults,e);let{transitional:n,paramsSerializer:o,headers:s}=e;n!==void 0&&$i.assertOptions(n,{silentJSONParsing:ln.transitional(ln.boolean),forcedJSONParsing:ln.transitional(ln.boolean),clarifyTimeoutError:ln.transitional(ln.boolean)},!1),o!=null&&(I.isFunction(o)?e.paramsSerializer={serialize:o}:$i.assertOptions(o,{encode:ln.function,serialize:ln.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let i=s&&I.merge(s.common,s[e.method]);s&&I.forEach(["delete","get","head","post","put","patch","common"],b=>{delete s[b]}),e.headers=_t.concat(i,s);let c=[],f=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(e)===!1||(f=f&&y.synchronous,c.unshift(y.fulfilled,y.rejected))});let l=[];this.interceptors.response.forEach(function(y){l.push(y.fulfilled,y.rejected)});let h,m=0,T;if(!f){let b=[Hi.bind(this),void 0];for(b.unshift.apply(b,c),b.push.apply(b,l),T=b.length,h=Promise.resolve(e);m<T;)h=h.then(b[m++],b[m++]);return h}T=c.length;let v=e;for(m=0;m<T;){let b=c[m++],y=c[m++];try{v=b(v)}catch(w){y.call(this,w);break}}try{h=Hi.call(this,v)}catch(b){return Promise.reject(b)}for(m=0,T=l.length;m<T;)h=h.then(l[m++],l[m++]);return h}getUri(t){t=Mr(this.defaults,t);let e=us(t.baseURL,t.url);return ss(e,t.params,t.paramsSerializer)}};I.forEach(["delete","get","head","options"],function(t){_o.prototype[t]=function(e,n){return this.request(Mr(n||{},{method:t,url:e,data:(n||{}).data}))}});I.forEach(["post","put","patch"],function(t){function e(n){return function(s,i,c){return this.request(Mr(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}_o.prototype[t]=e(),_o.prototype[t+"Form"]=e(!0)});var fs=_o;var au=class r{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(s){e=s});let n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s,i=new Promise(c=>{n.subscribe(c),s=c}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,c){n.reason||(n.reason=new dn(s,i,c),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}static source(){let t;return{token:new r(function(o){t=o}),cancel:t}}},Cl=au;function cu(r){return function(e){return r.apply(null,e)}}function uu(r){return I.isObject(r)&&r.isAxiosError===!0}var fu={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(fu).forEach(([r,t])=>{fu[t]=r});var Ul=fu;function Il(r){let t=new fs(r),e=rs(fs.prototype.request,t);return I.extend(e,fs.prototype,t,{allOwnKeys:!0}),I.extend(e,t,null,{allOwnKeys:!0}),e.create=function(o){return Il(Mr(r,o))},e}var it=Il(wo);it.Axios=fs;it.CanceledError=dn;it.CancelToken=Cl;it.isCancel=cs;it.VERSION=Fi;it.toFormData=fn;it.AxiosError=Se;it.Cancel=it.CanceledError;it.all=function(t){return Promise.all(t)};it.spread=cu;it.isAxiosError=uu;it.mergeConfig=Mr;it.AxiosHeaders=_t;it.formToJSON=r=>Li(I.isHTMLForm(r)?new FormData(r):r);it.getAdapter=Ki.getAdapter;it.HttpStatusCode=Ul;it.default=it;var Vi=it;var{Axios:JT,AxiosError:e_,CanceledError:t_,isCancel:r_,CancelToken:n_,VERSION:o_,all:s_,Cancel:i_,isAxiosError:a_,spread:c_,toFormData:u_,AxiosHeaders:f_,HttpStatusCode:d_,formToJSON:l_,getAdapter:p_,mergeConfig:g_}=Vi;async function Bl(r){var t;let{params:e,method:n,url:o,headers:s,body:i,overrides:c}=r,f={headers:s,method:n,url:o,params:e,data:i,withCredentials:(t=c?.WITH_CREDENTIALS)!=null?t:!0};try{let l=await Vi(f);return{status:l.status,statusText:l.statusText,data:l.data,headers:l.headers,config:l.config}}catch(l){let h=l;if(h.response)return h.response;throw l}}var ds=class{constructor(t){this.network=t?.network??Oa,this.fullnode=t?.fullnode,this.faucet=t?.faucet,this.indexer=t?.indexer,this.client=t?.client??{provider:Bl},this.clientConfig=t?.clientConfig??{}}getRequestUrl(t){switch(t){case 0:if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return Pa[this.network];case 2:if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return Ra[this.network];case 1:if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return Ks[this.network];default:throw Error(`apiType ${t} is not supported`)}}isIndexerRequest(t){return Ks[this.network]===t}};var ls=class extends ae{constructor(e){super();this.accountAddress=H.ONE;this.moduleName=new ht("account");this.structName=new ht("RotationProofChallenge");this.sequenceNumber=new ft(e.sequenceNumber),this.originator=e.originator,this.currentAuthKey=e.currentAuthKey,this.newPublicKey=Le.U8(e.newPublicKey.toUint8Array())}serialize(e){e.serialize(this.accountAddress),e.serialize(this.moduleName),e.serialize(this.structName),e.serialize(this.sequenceNumber),e.serialize(this.originator),e.serialize(this.currentAuthKey),e.serialize(this.newPublicKey)}};var vt=class extends ae{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return mr.load(t);case 1:return ps.load(t);case 2:return sr.load(t);case 3:return Ln.load(t);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${e}`)}}isEd25519(){return this instanceof mr}isMultiEd25519(){return this instanceof ps}isSingleKey(){return this instanceof sr}isMultiKey(){return this instanceof Ln}},mr=class r extends vt{constructor(e,n){super();this.public_key=e,this.signature=n}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let n=qe.deserialize(e),o=Je.deserialize(e);return new r(n,o)}},ps=class r extends vt{constructor(e,n){super();this.public_key=e,this.signature=n}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let n=er.deserialize(e),o=Bn.deserialize(e);return new r(n,o)}},sr=class r extends vt{constructor(e,n){super();this.public_key=e,this.signature=n}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let n=je.deserialize(e),o=lr.deserialize(e);return new r(n,o)}},Ln=class r extends vt{constructor(e,n,o){super();this.public_keys=e,this.signatures=n,this.signatures_bitmap=o}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),e.serializeVector(this.signatures),e.serializeBytes(this.signatures_bitmap)}static load(e){let n=Gn.deserialize(e),o=e.deserializeVector(lr),s=e.deserializeBytes();return new r(n,o,s)}};var yr=class extends ae{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return qn.load(t);case 1:return ji.load(t);case 2:return Kn.load(t);case 3:return Hn.load(t);case 4:return Fn.load(t);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${e}`)}}},qn=class r extends yr{constructor(e,n){super();this.public_key=e,this.signature=n}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let n=qe.deserialize(e),o=Je.deserialize(e);return new r(n,o)}},ji=class r extends yr{constructor(e,n){super();this.public_key=e,this.signature=n}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let n=er.deserialize(e),o=Bn.deserialize(e);return new r(n,o)}},Kn=class r extends yr{constructor(e,n,o){super();this.sender=e,this.secondary_signer_addresses=n,this.secondary_signers=o}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let n=vt.deserialize(e),o=e.deserializeVector(H),s=e.deserializeVector(vt);return new r(n,o,s)}},Hn=class r extends yr{constructor(e,n,o,s){super();this.sender=e,this.secondary_signer_addresses=n,this.secondary_signers=o,this.fee_payer=s}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let n=vt.deserialize(e),o=e.deserializeVector(H),s=e.deserializeVector(vt),i=H.deserialize(e),c=vt.deserialize(e),f={address:i,authenticator:c};return new r(n,o,s,f)}},Fn=class r extends yr{constructor(e){super();this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let n=vt.deserialize(e);return new r(n)}};var $n=class r extends ae{constructor(e){super();this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let n=e.deserializeU8();return new r(n)}};var Qe=class r extends ae{constructor(e){super();this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let n=e.deserializeStr();return new r(n)}};var So=class r extends ae{constructor(e,n){super();this.address=e,this.name=n}static fromStr(e){let n=e.split("::");if(n.length!==2)throw new Error("Invalid module id.");return new r(H.fromString(n[0]),new Qe(n[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let n=H.deserialize(e),o=Qe.deserialize(e);return new r(n,o)}};var rt=class extends ae{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Vn.load(t);case 1:return jn.load(t);case 2:return Yn.load(t);case 3:return Zn.load(t);case 4:return Jn.load(t);case 5:return pn.load(t);case 6:return to.load(t);case 7:return Gr.load(t);case 8:return Qn.load(t);case 9:return Wn.load(t);case 10:return Xn.load(t);case 255:return eo.load(t);default:throw new Error(`Unknown variant index for TypeTag: ${e}`)}}isBool(){return this instanceof Vn}isAddress(){return this instanceof Jn}isGeneric(){return this instanceof eo}isSigner(){return this instanceof pn}isVector(){return this instanceof to}isStruct(){return this instanceof Gr}isU8(){return this instanceof jn}isU16(){return this instanceof Qn}isU32(){return this instanceof Wn}isU64(){return this instanceof Yn}isU128(){return this instanceof Zn}isU256(){return this instanceof Xn}},Vn=class r extends rt{toString(){return"bool"}serialize(t){t.serializeU32AsUleb128(0)}static load(t){return new r}},jn=class r extends rt{toString(){return"u8"}serialize(t){t.serializeU32AsUleb128(1)}static load(t){return new r}},Qn=class r extends rt{toString(){return"u16"}serialize(t){t.serializeU32AsUleb128(8)}static load(t){return new r}},Wn=class r extends rt{toString(){return"u32"}serialize(t){t.serializeU32AsUleb128(9)}static load(t){return new r}},Yn=class r extends rt{toString(){return"u64"}serialize(t){t.serializeU32AsUleb128(2)}static load(t){return new r}},Zn=class r extends rt{toString(){return"u128"}serialize(t){t.serializeU32AsUleb128(3)}static load(t){return new r}},Xn=class r extends rt{toString(){return"u256"}serialize(t){t.serializeU32AsUleb128(10)}static load(t){return new r}},Jn=class r extends rt{toString(){return"address"}serialize(t){t.serializeU32AsUleb128(4)}static load(t){return new r}},pn=class r extends rt{toString(){return"signer"}serialize(t){t.serializeU32AsUleb128(5)}static load(t){return new r}},gs=class r extends rt{constructor(e){super();this.value=e}toString(){return`&${this.value.toString()}`}serialize(e){e.serializeU32AsUleb128(254)}static load(e){let n=rt.deserialize(e);return new r(n)}},eo=class r extends rt{constructor(e){super();this.value=e;if(e<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(e){e.serializeU32AsUleb128(255),e.serializeU32(this.value)}static load(e){let n=e.deserializeU32();return new r(n)}},to=class r extends rt{constructor(e){super();this.value=e}toString(){return`vector<${this.value.toString()}>`}serialize(e){e.serializeU32AsUleb128(6),this.value.serialize(e)}static load(e){let n=rt.deserialize(e);return new r(n)}},Gr=class r extends rt{constructor(e){super();this.value=e}toString(){let e="";return this.value.typeArgs.length>0&&(e=`<${this.value.typeArgs.map(n=>n.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${e}`}serialize(e){e.serializeU32AsUleb128(7),this.value.serialize(e)}static load(e){let n=hr.deserialize(e);return new r(n)}isTypeTag(e,n,o){return this.value.moduleName.identifier===n&&this.value.name.identifier===o&&this.value.address.equals(e)}isString(){return this.isTypeTag(H.ONE,"string","String")}isOption(){return this.isTypeTag(H.ONE,"option","Option")}isObject(){return this.isTypeTag(H.ONE,"object","Object")}},hr=class r extends ae{constructor(e,n,o,s){super();this.address=e,this.moduleName=n,this.name=o,this.typeArgs=s}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let n=H.deserialize(e),o=Qe.deserialize(e),s=Qe.deserialize(e),i=e.deserializeVector(rt);return new r(n,o,s,i)}};function mh(){return new hr(H.ONE,new Qe("aptos_coin"),new Qe("AptosCoin"),[])}function yh(){return new hr(H.ONE,new Qe("string"),new Qe("String"),[])}function hh(r){return new hr(H.ONE,new Qe("option"),new Qe("Option"),[r])}function Ah(r){return new hr(H.ONE,new Qe("object"),new Qe("Object"),[r])}function Pl(r){let t=r.deserializeUleb128AsU32();switch(t){case 0:return lt.deserialize(r);case 1:return ft.deserialize(r);case 2:return Mt.deserialize(r);case 3:return H.deserialize(r);case 4:return Le.deserialize(r,lt);case 5:return Xe.deserialize(r);case 6:return zt.deserialize(r);case 7:return Dt.deserialize(r);case 8:return Gt.deserialize(r);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${t}`)}}var gn=class extends ae{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Eo.load(t);case 2:return vo.load(t);case 3:return Co.load(t);default:throw new Error(`Unknown variant index for TransactionPayload: ${e}`)}}},Eo=class r extends gn{constructor(e){super();this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let n=Uo.deserialize(e);return new r(n)}},vo=class r extends gn{constructor(e){super();this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let n=ro.deserialize(e);return new r(n)}},Co=class r extends gn{constructor(e){super();this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let n=Io.deserialize(e);return new r(n)}},ro=class r{constructor(t,e,n,o){this.module_name=t,this.function_name=e,this.type_args=n,this.args=o}static build(t,e,n,o){return new r(So.fromStr(t),new Qe(e),n,o)}serialize(t){this.module_name.serialize(t),this.function_name.serialize(t),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForEntryFunction(t)})}static deserialize(t){let e=So.deserialize(t),n=Qe.deserialize(t),o=t.deserializeVector(rt),s=t.deserializeUleb128AsU32(),i=new Array;for(let c=0;c<s;c+=1){let f=t.deserializeUleb128AsU32(),l=Qo.deserialize(t,f);i.push(l)}return new r(e,n,o,i)}},Uo=class r{constructor(t,e,n){this.bytecode=t,this.type_args=e,this.args=n}serialize(t){t.serializeBytes(this.bytecode),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForScriptFunction(t)})}static deserialize(t){let e=t.deserializeBytes(),n=t.deserializeVector(rt),o=t.deserializeUleb128AsU32(),s=new Array;for(let i=0;i<o;i+=1){let c=Pl(t);s.push(c)}return new r(e,n,s)}},Io=class r{constructor(t,e){this.multisig_address=t,this.transaction_payload=e}serialize(t){this.multisig_address.serialize(t),this.transaction_payload===void 0?t.serializeBool(!1):(t.serializeBool(!0),this.transaction_payload.serialize(t))}static deserialize(t){let e=H.deserialize(t),n=t.deserializeBool(),o;return n&&(o=Bo.deserialize(t)),new r(e,o)}},Bo=class r extends ae{constructor(e){super();this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new r(ro.deserialize(e))}};var Vt=class r extends ae{constructor(e,n,o,s,i,c,f){super();this.sender=e,this.sequence_number=n,this.payload=o,this.max_gas_amount=s,this.gas_unit_price=i,this.expiration_timestamp_secs=c,this.chain_id=f}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let n=H.deserialize(e),o=e.deserializeU64(),s=gn.deserialize(e),i=e.deserializeU64(),c=e.deserializeU64(),f=e.deserializeU64(),l=$n.deserialize(e);return new r(n,o,s,i,c,f,l)}},ms=class extends ae{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Ar.load(t);case 1:return xr.load(t);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${e}`)}}},Ar=class r extends ms{constructor(e,n){super();this.raw_txn=e,this.secondary_signer_addresses=n}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let n=Vt.deserialize(e),o=e.deserializeVector(H);return new r(n,o)}},xr=class r extends ms{constructor(e,n,o){super();this.raw_txn=e,this.secondary_signer_addresses=n,this.fee_payer_address=o}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let n=Vt.deserialize(e),o=e.deserializeVector(H),s=H.deserialize(e);return new r(n,o,s)}};var ir=class r extends ae{constructor(e,n){super();this.raw_txn=e,this.authenticator=n}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let n=Vt.deserialize(e),o=yr.deserialize(e);return new r(n,o)}};function Rl(r){return!!r.match(/^[_a-zA-Z0-9]+$/)}function Ol(r){return!!r.match(/\s/)}function xh(r){return!!r.match(/^T[0-9]+$/)}function bh(r,t){let e=t;for(;e<r.length;e+=1){let n=r[e];if(!Ol(n))break}return e}var Nl=(T=>(T.InvalidTypeTag="unknown type",T.UnexpectedGenericType="unexpected generic type",T.UnexpectedTypeArgumentClose="unexpected '>'",T.UnexpectedWhitespaceCharacter="unexpected whitespace character",T.UnexpectedComma="unexpected ','",T.TypeArgumentCountMismatch="type argument count doesn't match expected amount",T.MissingTypeArgumentClose="no matching '>' for '<'",T.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",T.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",T.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",T.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",T.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",T))(Nl||{}),He=class extends Error{constructor(t,e){super(`Failed to parse typeTag '${t}', ${e}`)}};function Po(r,t){let e=t?.allowGenerics??!1,n=[],o=[],s=[],i=0,c="",f=1;for(;i<r.length;){let l=r[i];if(l==="<")n.push({savedExpectedTypes:f,savedStr:c,savedTypes:s}),c="",s=[],f=1;else if(l===">"){if(c!==""){let b=Qi(c,o,e);s.push(b)}let h=n.pop();if(h===void 0)throw new He(r,"unexpected '>'");if(f!==s.length)throw new He(r,"type argument count doesn't match expected amount");let{savedStr:m,savedTypes:T,savedExpectedTypes:v}=h;o=s,s=T,c=m,f=v}else if(l===","){if(c.length!==0){let h=Qi(c,o,e);o=[],s.push(h),c="",f+=1}}else if(Ol(l)){let h=!1;if(c.length!==0){let T=Qi(c,o,e);o=[],s.push(T),c="",h=!0}i=bh(r,i);let m=r[i];if(i<r.length&&h&&m!==","&&m!==">")throw new He(r,"unexpected whitespace character");continue}else c+=l;i+=1}if(n.length>0)throw new He(r,"no matching '>' for '<'");switch(s.length){case 0:return Qi(c,o,e);case 1:if(c==="")return s[0];throw new He(r,"unexpected ','");default:throw new He(r,"unexpected whitespace character")}}function Qi(r,t,e){switch(r){case"&signer":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new gs(new pn);case"signer":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new pn;case"bool":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Vn;case"address":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Jn;case"u8":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new jn;case"u16":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Qn;case"u32":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Wn;case"u64":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Yn;case"u128":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Zn;case"u256":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Xn;case"vector":if(t.length!==1)throw new He(r,"vector type expected to have exactly one type argument");return new to(t[0]);default:if(xh(r)){if(e)return new eo(Number(r.split("T")[1]));throw new He(r,"unexpected generic type")}if(!r.match(/.*:.*/))throw new He(r,"unknown type");let n=r.split("::");if(n.length!==3)throw new He(r,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");if(!Rl(n[1]))throw new He(r,"module name must only contain alphanumeric or '_' characters");if(!Rl(n[2]))throw new He(r,"struct name must only contain alphanumeric or '_' characters");return new Gr(new hr(H.fromString(n[0]),new Qe(n[1]),new Qe(n[2]),t))}}function du(r){return typeof r=="boolean"}function no(r){return typeof r=="string"}function ys(r){return typeof r=="number"}function hs(r){return typeof r=="number"||typeof r=="bigint"||typeof r=="string"}function lu(r){return r==null}function pu(r){return Wi(r)||Zi(r)||Xi(r)||Ji(r)||ea(r)||ta(r)||ra(r)||As(r)||Yi(r)||kl(r)||r instanceof Le||r instanceof Cr}function Wi(r){return r instanceof Xe}function As(r){return r instanceof H}function Yi(r){return r instanceof ht}function kl(r){return r instanceof $r}function Zi(r){return r instanceof lt}function Xi(r){return r instanceof zt}function Ji(r){return r instanceof Dt}function ea(r){return r instanceof ft}function ta(r){return r instanceof Mt}function ra(r){return r instanceof Gt}function na(r){return"bytecode"in r}function $e(r,t){throw new Error(`Type mismatch for argument ${t}, expected '${r}'`)}function gu(r){let t=r.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?r.params.length:t}function oa(r){let t=r.split("::");if(t.length!==3)throw new Error(`Invalid function ${r}`);let e=t[0],n=t[1],o=t[2];return{moduleAddress:e,moduleName:n,functionName:o}}var wh=new TextEncoder;function yu(r){return r?.map(t=>no(t)?Po(t):t)??[]}async function hu(r,t,e,n){let s=(await Ui({aptosConfig:n,accountAddress:r,moduleName:t})).abi?.exposed_functions.find(f=>f.name===e);if(!s)throw new Error(`Could not find entry function ABI for '${r}::${t}::${e}'`);if(!s.is_entry)throw new Error(`'${r}::${t}::${e}' is not an entry function`);let i=gu(s),c=[];for(let f=i;f<s.params.length;f+=1)c.push(Po(s.params[f],{allowGenerics:!0}));return{typeParameters:s.generic_type_params,parameters:c}}function Au(r,t,e,n,o){if(n>=t.parameters.length)throw new Error(`Too many arguments for '${r}', expected ${t.parameters.length}`);let s=t.parameters[n];return oo(e,s,n,o)}function oo(r,t,e,n){return pu(r)?(mu(t,r,e),r):Th(r,t,e,n)}function Th(r,t,e,n){if(t.isBool()){if(du(r))return new Xe(r);$e("boolean",e)}if(t.isAddress()){if(no(r))return H.fromString(r);$e("string | AccountAddress",e)}if(t.isU8()){if(ys(r))return new lt(r);$e("number",e)}if(t.isU16()){if(ys(r))return new zt(r);$e("number",e)}if(t.isU32()){if(ys(r))return new Dt(r);$e("number",e)}if(t.isU64()){if(hs(r))return new ft(BigInt(r));$e("bigint | number | string",e)}if(t.isU128()){if(hs(r))return new Mt(BigInt(r));$e("bigint | number | string",e)}if(t.isU256()){if(hs(r))return new Gt(BigInt(r));$e("bigint | number | string",e)}if(t.isGeneric()){let o=t.value;if(o<0||o>=n.length)throw new Error(`Generic argument ${t.toString()} is invalid for argument ${e}`);return oo(r,n[o],e,n)}if(t.isVector()){if(t.value.isU8()){if(no(r))return Le.U8(wh.encode(r));if(r instanceof Uint8Array)return Le.U8(r);if(r instanceof ArrayBuffer)return Le.U8(new Uint8Array(r))}if(Array.isArray(r))return new Le(r.map(o=>oo(o,t.value,e,n)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(no(r))return new ht(r);$e("string",e)}if(t.isObject()){if(no(r))return H.fromString(r);$e("string | AccountAddress",e)}if(t.isOption())return lu(r)?new Cr(null):new Cr(oo(r,t.value.typeArgs[0],e,n));throw new Error(`Unsupported struct input type for argument ${e}, type '${t.toString()}'`)}throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}function mu(r,t,e){if(r.isBool()){if(Wi(t))return;$e("Bool",e)}if(r.isAddress()){if(As(t))return;$e("AccountAddress",e)}if(r.isU8()){if(Zi(t))return;$e("U8",e)}if(r.isU16()){if(Xi(t))return;$e("U16",e)}if(r.isU32()){if(Ji(t))return;$e("U32",e)}if(r.isU64()){if(ea(t))return;$e("U64",e)}if(r.isU128()){if(ta(t))return;$e("U128",e)}if(r.isU256()){if(ra(t))return;$e("U256",e)}if(r.isVector()){if(t instanceof Le){t.values.length>0&&mu(r.value,t.values[0],e);return}$e("MoveVector",e)}if(r instanceof Gr){if(r.isString()){if(Yi(t))return;$e("MoveString",e)}if(r.isObject()){if(As(t))return;$e("AccountAddress",e)}if(r.isOption()){if(t instanceof Cr){t.value!==void 0&&mu(r.value.typeArgs[0],t.value,e);return}$e("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${r.toString()}'`)}async function bs(r){if(na(r))return Dl(r);let{moduleAddress:t,moduleName:e,functionName:n}=oa(r.function),o=await ho(async()=>hu(t,e,n,r.aptosConfig),`entry-function-${r.aptosConfig.network}-${t}-${e}-${n}`,1e3*60*5)();return zl(r,o)}function zl(r,t){if(na(r))return Dl(r);let{moduleAddress:e,moduleName:n,functionName:o}=oa(r.function),s=yu(r.typeArguments);if(s.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${s.length}`);let i=r.functionArguments.map((f,l)=>Au(r.function,t,f,l,s));if(i.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${n}::${o}', expected ${t.parameters.length} but got ${i.length}`);let c=ro.build(`${e}::${n}`,o,s,i);if("multisigAddress"in r){let f=H.from(r.multisigAddress);return new Co(new Io(f,new Bo(c)))}return new vo(c)}function Dl(r){return new Eo(new Uo(Be.fromHexInput(r.bytecode).toUint8Array(),r.typeArguments??[],r.functionArguments))}async function Ml(r){let{aptosConfig:t,sender:e,payload:n,options:o}=r,s=o?.accountSequenceNumber!==void 0?Promise.resolve({sequence_number:o.accountSequenceNumber}):pr({aptosConfig:t,accountAddress:e}),i=Hs[t.network]?Promise.resolve({chain_id:Hs[t.network]}):Si({aptosConfig:t}),c=o?.gasUnitPrice?Promise.resolve({gas_estimate:o.gasUnitPrice}):Bi({aptosConfig:t}),[{sequence_number:f},{chain_id:l},{gas_estimate:h}]=await Promise.all([s,i,c]),{maxGasAmount:m,gasUnitPrice:T,expireTimestamp:v}={maxGasAmount:o?.maxGasAmount?BigInt(o.maxGasAmount):BigInt(Na),gasUnitPrice:BigInt(h),expireTimestamp:BigInt(Math.floor(Date.now()/1e3)+ka),...o};return new Vt(H.from(e),BigInt(f),n,BigInt(m),BigInt(T),BigInt(v),new $n(l))}async function sa(r){let{aptosConfig:t,sender:e,payload:n,options:o}=r,s=await Ml({aptosConfig:t,sender:e,payload:n,options:o});if("secondarySignerAddresses"in r){let i=r.secondarySignerAddresses?.map(c=>H.from(c))??[];return{rawTransaction:s,secondarySignerAddresses:i,feePayerAddress:r.feePayerAddress?H.from(r.feePayerAddress):void 0}}return{rawTransaction:s,feePayerAddress:r.feePayerAddress?H.from(r.feePayerAddress):void 0}}function xu(r){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:n,feePayerPublicKey:o}=r,s=xs(t);if(e.feePayerAddress){let c=new xr(e.rawTransaction,e.secondarySignerAddresses??[],e.feePayerAddress),f=[];n&&(f=n.map(m=>xs(m)));let l=xs(o),h=new Hn(s,e.secondarySignerAddresses??[],f,{address:e.feePayerAddress,authenticator:l});return new ir(c.raw_txn,h).bcsToBytes()}if(e.secondarySignerAddresses){let c=new Ar(e.rawTransaction,e.secondarySignerAddresses),f=[];f=n.map(h=>xs(h));let l=new Kn(s,e.secondarySignerAddresses,f);return new ir(c.raw_txn,l).bcsToBytes()}let i;if(s instanceof mr)i=new qn(s.public_key,s.signature);else if(s instanceof sr)i=new Fn(s);else throw new Error("Invalid public key");return new ir(e.rawTransaction,i).bcsToBytes()}function xs(r){if(r instanceof je){if(r.publicKey instanceof qe)return new sr(r,new lr(new Je(new Uint8Array(64))));if(r.publicKey instanceof Ft)return new sr(r,new lr(new kr(new Uint8Array(64))))}return new mr(new qe(r.toUint8Array()),new Je(new Uint8Array(64)))}function bu(r){let{signer:t,transaction:e}=r,n=ia(e),o=t.sign(n);switch(t.signingScheme){case 0:return new mr(new qe(t.publicKey.toUint8Array()),new Je(o.toUint8Array()));case 2:if(!je.isPublicKey(t.publicKey))throw new Error(`Cannot sign transaction, public key does not match ${t.signingScheme}`);return new sr(t.publicKey,new lr(o));default:throw new Error(`Cannot sign transaction, signing scheme ${t.signingScheme} not supported`)}}function wu(r){let{transaction:t,senderAuthenticator:e,feePayerAuthenticator:n,additionalSignersAuthenticators:o}=r,s=Tu(t);if((n||o)&&(s instanceof Ar||s instanceof xr))return Gl(s,e,n,o);if(e instanceof mr&&s instanceof Vt){let i=new qn(e.public_key,e.signature);return new ir(s,i).bcsToBytes()}if((e instanceof sr||e instanceof Ln)&&s instanceof Vt){let i=new Fn(e);return new ir(s,i).bcsToBytes()}throw new Error(`Cannot generate a signed transaction, ${e} is not a supported account authentication scheme`)}function Tu(r){return r.feePayerAddress?new xr(r.rawTransaction,r.secondarySignerAddresses??[],r.feePayerAddress):r.secondarySignerAddresses?new Ar(r.rawTransaction,r.secondarySignerAddresses):r.rawTransaction}function Gl(r,t,e,n){if(r instanceof xr){if(!e)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");let o=new Hn(t,r.secondary_signer_addresses,n??[],{address:r.fee_payer_address,authenticator:e});return new ir(r.raw_txn,o).bcsToBytes()}if(r instanceof Ar){if(!n)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");let o=new Kn(t,r.secondary_signer_addresses,n??[]);return new ir(r.raw_txn,o).bcsToBytes()}throw new Error(`Cannot prepare multi signers transaction to submission, ${typeof r} transaction is not supported`)}function ia(r){let t=Tu(r),e=Cn.create();if(t instanceof Vt)e.update(za);else if(t instanceof Ar)e.update(Fs);else if(t instanceof xr)e.update(Fs);else throw new Error(`Unknown transaction type to sign on: ${t}`);let n=e.digest(),o=t.bcsToBytes(),s=new Uint8Array(n.length+o.length);return s.set(n),s.set(o,n.length),s}async function Pe(r){let t=await _h(r);return Sh(r,t)}async function _h(r){let{aptosConfig:t,data:e}=r,n,o;return"bytecode"in e?(n=e,o=await bs(n)):"multisigAddress"in e?(n={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments},o=await bs(n)):(n={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments},o=await bs(n)),o}async function Sh(r,t){let{aptosConfig:e,sender:n,options:o}=r,s;if(Eh(r)&&(s=H.ZERO.toString()),vh(r)){let{secondarySignerAddresses:i}=r;return sa({aptosConfig:e,sender:n,payload:t,options:o,secondarySignerAddresses:i,feePayerAddress:s})}return sa({aptosConfig:e,sender:n,payload:t,options:o,feePayerAddress:s})}function Eh(r){return r.withFeePayer===!0}function vh(r){return"secondarySignerAddresses"in r}function Ll(r){let{transaction:t}=r;return ia(t)}function aa(r){return bu({...r})}async function _u(r){let{aptosConfig:t,transaction:e,signerPublicKey:n,secondarySignersPublicKeys:o,feePayerPublicKey:s,options:i}=r,c=xu({transaction:e,signerPublicKey:n,secondarySignersPublicKeys:o,feePayerPublicKey:s,options:i}),{data:f}=await Tn({aptosConfig:t,body:c,path:"transactions/simulate",params:{estimate_gas_unit_price:r.options?.estimateGasUnitPrice??!1,estimate_max_gas_amount:r.options?.estimateMaxGasAmount??!1,estimate_prioritized_gas_unit_price:r.options?.estimatePrioritizedGasUnitPrice??!1},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return f}async function ca(r){let{aptosConfig:t}=r,e=wu({...r}),{data:n}=await Tn({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return n}async function ws(r){let{aptosConfig:t,signer:e,transaction:n}=r,o=aa({signer:e,transaction:n});return ca({aptosConfig:t,transaction:n,senderAuthenticator:o})}async function ql(r){let{aptosConfig:t,account:e,metadataBytes:n,moduleBytecode:o,options:s}=r,i=o.map(f=>Le.U8(f));return await Pe({aptosConfig:t,sender:H.from(e),data:{function:"0x1::code::publish_package_txn",functionArguments:[Le.U8(n),new Le(i)]},options:s})}async function Kl(r){let{aptosConfig:t,fromAccount:e,toNewPrivateKey:n}=r,o=await pr({aptosConfig:t,accountAddress:e.accountAddress}),s=Dr.fromPrivateKey({privateKey:n,legacy:!0}),c=new ls({sequenceNumber:BigInt(o.sequence_number),originator:e.accountAddress,currentAuthKey:H.from(o.authentication_key),newPublicKey:s.publicKey}).bcsToBytes(),f=e.sign(c),l=s.sign(c),h=await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new lt(e.signingScheme.valueOf()),Le.U8(e.publicKey.toUint8Array()),new lt(s.signingScheme.valueOf()),Le.U8(s.publicKey.toUint8Array()),Le.U8(f.toUint8Array()),Le.U8(l.toUint8Array())]}});return await ws({aptosConfig:t,signer:e,transaction:h})}async function Hl(r){let{aptosConfig:t,sender:e,recipient:n,amount:o,coinType:s,options:i}=r,c=s??$o;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[c],functionArguments:[n,o]},options:i})}var Ts=class{constructor(t){this.config=t}async transferCoinTransaction(t){return Hl({aptosConfig:this.config,...t})}};var mn={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},jt="0x4::token::Token";async function Fl(r){let{aptosConfig:t,digitalAssetAddress:e}=r,n={token_data_id:{_eq:H.from(e).toStringLong()}};return(await Ee({aptosConfig:t,query:{query:Ud,variables:{where_condition:n}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function $l(r){let{aptosConfig:t,digitalAssetAddress:e}=r,n={token_data_id:{_eq:H.from(e).toStringLong()}};return(await Ee({aptosConfig:t,query:{query:Mc,variables:{where_condition:n}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Vl(r){let{aptosConfig:t,ownerAddress:e,options:n}=r,o={owner_address:{_eq:H.from(e).toStringLong()},amount:{_gt:0}},s={query:Mc,variables:{where_condition:o,offset:n?.offset,limit:n?.limit,order_by:n?.orderBy}};return(await Ee({aptosConfig:t,query:s,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function jl(r){let{aptosConfig:t,digitalAssetAddress:e,options:n}=r,o={token_data_id:{_eq:H.from(e).toStringLong()}},s={query:Cd,variables:{where_condition:o,offset:n?.offset,limit:n?.limit,order_by:n?.orderBy}};return(await Ee({aptosConfig:t,query:s,originMethod:"getDigitalAssetActivity"})).token_activities_v2}async function Ql(r){let{aptosConfig:t,options:e,creator:n}=r;return await Pe({aptosConfig:t,sender:n.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new ht(r.description),new ft(r.maxSupply??En),new ht(r.name),new ht(r.uri),new Xe(r.mutableDescription??!0),new Xe(r.mutableRoyalty??!0),new Xe(r.mutableURI??!0),new Xe(r.mutableTokenDescription??!0),new Xe(r.mutableTokenName??!0),new Xe(r.mutableTokenProperties??!0),new Xe(r.mutableTokenURI??!0),new Xe(r.tokensBurnableByCreator??!0),new Xe(r.tokensFreezableByCreator??!0),new ft(r.royaltyNumerator??0),new ft(r.royaltyDenominator??1)]},options:e})}async function Su(r){let{aptosConfig:t,creatorAddress:e,collectionName:n,options:o}=r,s=H.from(e),i={collection_name:{_eq:n},creator_address:{_eq:s.toStringLong()}};return o?.tokenStandard&&(i.token_standard={_eq:o?.tokenStandard??"v2"}),(await Ee({aptosConfig:t,query:{query:wd,variables:{where_condition:i}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function Wl(r){return(await Su(r)).collection_id}async function Yl(r){let{aptosConfig:t,options:e,creator:n,collection:o,description:s,name:i,uri:c,propertyKeys:f,propertyTypes:l,propertyValues:h}=r,m=l?.map(v=>mn[v]);return await Pe({aptosConfig:t,sender:n.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[o,s,i,c,f??[],m??[],fp(h??[],m??[])]},options:e})}async function Zl(r){let{aptosConfig:t,sender:e,digitalAssetAddress:n,recipient:o,digitalAssetType:s,options:i}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[s??jt],functionArguments:[n,o]},options:i})}async function Xl(r){let{aptosConfig:t,account:e,collection:n,description:o,name:s,uri:i,recipient:c,propertyKeys:f,propertyTypes:l,propertyValues:h,options:m}=r;if(f?.length!==h?.length)throw new Error("Property keys and property values counts do not match");if(l?.length!==h?.length)throw new Error("Property types and property values counts do not match");let T=l?.map(b=>mn[b]);return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[n,o,s,i,f??[],T??[],fp(h??[],T??[]),c]},options:m})}async function Jl(r){let{aptosConfig:t,creator:e,digitalAssetAddress:n,digitalAssetType:o,options:s}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[o??jt],functionArguments:[n]},options:s})}async function ep(r){let{aptosConfig:t,creator:e,digitalAssetAddress:n,digitalAssetType:o,options:s}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[o??jt],functionArguments:[n]},options:s})}async function tp(r){let{aptosConfig:t,creator:e,digitalAssetAddress:n,digitalAssetType:o,options:s}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[o??jt],functionArguments:[n]},options:s})}async function rp(r){let{aptosConfig:t,creator:e,description:n,digitalAssetAddress:o,digitalAssetType:s,options:i}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[s??jt],functionArguments:[o,n]},options:i})}async function np(r){let{aptosConfig:t,creator:e,name:n,digitalAssetAddress:o,digitalAssetType:s,options:i}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[s??jt],functionArguments:[o,n]},options:i})}async function op(r){let{aptosConfig:t,creator:e,uri:n,digitalAssetAddress:o,digitalAssetType:s,options:i}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[s??jt],functionArguments:[o,n]},options:i})}async function sp(r){let{aptosConfig:t,creator:e,propertyKey:n,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:c,options:f}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[c??jt],functionArguments:[i,n,mn[o],Eu(s,mn[o])]},options:f})}async function ip(r){let{aptosConfig:t,creator:e,propertyKey:n,digitalAssetAddress:o,digitalAssetType:s,options:i}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[s??jt],functionArguments:[o,n]},options:i})}async function ap(r){let{aptosConfig:t,creator:e,propertyKey:n,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:c,options:f}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[c??jt],functionArguments:[i,n,mn[o],Eu(s,mn[o])]},options:f})}async function cp(r){let{aptosConfig:t,creator:e,propertyKey:n,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:c,options:f}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[c??jt,mn[o]],functionArguments:[i,n,s]},options:f})}async function up(r){let{aptosConfig:t,creator:e,propertyKey:n,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:c,options:f}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[c??jt,mn[o]],functionArguments:[i,n,s]},options:f})}function fp(r,t){let e=new Array;return t.forEach((n,o)=>{e.push(Eu(r[o],n))}),e}function Eu(r,t){let e=Po(t);return oo(r,e,0,[]).bcsToBytes()}var _s=class{constructor(t){this.config=t}async getCollectionData(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Su({aptosConfig:this.config,...t})}async getCollectionId(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Wl({aptosConfig:this.config,...t})}async getDigitalAssetData(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Fl({aptosConfig:this.config,...t})}async getCurrentDigitalAssetOwnership(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),$l({aptosConfig:this.config,...t})}async getOwnedDigitalAssets(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Vl({aptosConfig:this.config,...t})}async getDigitalAssetActivity(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),jl({aptosConfig:this.config,...t})}async createCollectionTransaction(t){return Ql({aptosConfig:this.config,...t})}async mintDigitalAssetTransaction(t){return Yl({aptosConfig:this.config,...t})}async transferDigitalAssetTransaction(t){return Zl({aptosConfig:this.config,...t})}async mintSoulBoundTransaction(t){return Xl({aptosConfig:this.config,...t})}async burnDigitalAssetTransaction(t){return Jl({aptosConfig:this.config,...t})}async freezeDigitalAssetTransaferTransaction(t){return ep({aptosConfig:this.config,...t})}async unfreezeDigitalAssetTransaferTransaction(t){return tp({aptosConfig:this.config,...t})}async setDigitalAssetDescriptionTransaction(t){return rp({aptosConfig:this.config,...t})}async setDigitalAssetNameTransaction(t){return np({aptosConfig:this.config,...t})}async setDigitalAssetURITransaction(t){return op({aptosConfig:this.config,...t})}async addDigitalAssetPropertyTransaction(t){return sp({aptosConfig:this.config,...t})}async removeDigitalAssetPropertyTransaction(t){return ip({aptosConfig:this.config,...t})}async updateDigitalAssetPropertyTransaction(t){return ap({aptosConfig:this.config,...t})}async addDigitalAssetTypedPropertyTransaction(t){return cp({aptosConfig:this.config,...t})}async updateDigitalAssetTypedPropertyTransaction(t){return up({aptosConfig:this.config,...t})}};async function dp(r){let{accountAddress:t,aptosConfig:e,creationNumber:n}=r,s={account_address:{_eq:H.from(t).toStringLong()},creation_number:{_eq:n}};return ua({aptosConfig:e,options:{where:s}})}async function lp(r){let{accountAddress:t,aptosConfig:e,eventType:n,options:o}=r,c={where:{account_address:{_eq:H.from(t).toStringLong()},indexed_type:{_eq:n}},pagination:o,orderBy:o?.orderBy};return ua({aptosConfig:e,options:c})}async function ua(r){let{aptosConfig:t,options:e}=r,n={query:Sd,variables:{where_condition:e?.where,offset:e?.offset,limit:e?.limit,order_by:e?.orderBy}};return(await Ee({aptosConfig:t,query:n,originMethod:"getEvents"})).events}var Ss=class{constructor(t){this.config=t}async getAccountEventsByCreationNumber(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),dp({aptosConfig:this.config,...t})}async getAccountEventsByEventType(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),lp({aptosConfig:this.config,...t})}async getEvents(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"events_processor"}),ua({aptosConfig:this.config,...t})}};async function pp(r){let{aptosConfig:t,accountAddress:e,amount:n,options:o}=r,s=o?.timeoutSecs||Fo,{data:i}=await Ga({aptosConfig:t,path:"fund",body:{address:H.from(e).toString(),amount:n},originMethod:"fundAccount"}),c=i.txn_hashes[0],f=await Ao({aptosConfig:t,transactionHash:c,options:{timeoutSecs:s,checkSuccess:o?.checkSuccess}});if(f.type==="user_transaction")return f;throw new Error(`Unexpected transaction received for fund account: ${f.type}`)}var Es=class{constructor(t){this.config=t}async fundAccount(t){let e=await pp({aptosConfig:this.config,...t});return t.options?.waitForIndexer!==!1&&await Ri({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version)}),e}};async function vu(r){let{aptosConfig:t,options:e}=r,n={query:vd,variables:{where_condition:e?.where,limit:e?.limit,offset:e?.offset}};return(await Ee({aptosConfig:t,query:n,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function gp(r){let{aptosConfig:t,options:e}=r,n={query:Ed,variables:{where_condition:e?.where,limit:e?.limit,offset:e?.offset}};return(await Ee({aptosConfig:t,query:n,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function mp(r){let{aptosConfig:t,options:e}=r,n={query:Td,variables:{where_condition:e?.where,limit:e?.limit,offset:e?.offset}};return(await Ee({aptosConfig:t,query:n,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}async function yp(r){let{aptosConfig:t,sender:e,fungibleAssetMetadataAddress:n,recipient:o,amount:s,options:i}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[n,o,s]},options:i})}var vs=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),vu({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),(await vu({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetActivities(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),gp({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),mp({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return yp({aptosConfig:this.config,...t})}};var Cs=class{constructor(t){this.config=t}async getLedgerInfo(){return Si({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(t){return Id({aptosConfig:this.config,...t})}async getBlockByHeight(t){return Bd({aptosConfig:this.config,...t})}async getTableItem(t){return Ei({aptosConfig:this.config,...t})}async view(t){return cn({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return Pd({aptosConfig:this.config,...t})}async queryIndexer(t){return Ee({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return vi({aptosConfig:this.config})}async getProcessorStatus(t){return Ci({aptosConfig:this.config,processorType:t})}};var hp=["A name must be between 3 and 63 characters long,","and can only contain lowercase a-z, 0-9, and hyphens.","A name may not start or end with a hyphen."].join(" ");function Ap(r){return!(!r||r.length<3||r.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(r))}function yn(r){let[t,e,...n]=r.replace(/\.apt$/,"").split(".");if(n.length>0)throw new Error(`${r} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!Ap(t))throw new Error(`${t} is not valid. ${hp}`);if(e&&!Ap(e))throw new Error(`${e} is not valid. ${hp}`);return{domainName:e||t,subdomainName:e?t:void 0}}var Ch="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Uh={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Ch,custom:null,devnet:null};function Lr(r){let t=Uh[r.network];if(!t)throw new Error(`The ANS contract is not deployed to ${r.network}`);return t}var Ih=r=>({vec:[r]}),Bh=()=>({vec:[]}),Cu=r=>r!=null?Ih(r):Bh(),fa=r=>{if(r&&typeof r=="object"&&"vec"in r&&Array.isArray(r.vec))return r.vec[0]};async function xp(r){let{aptosConfig:t,name:e}=r,n=Lr(t),{domainName:o,subdomainName:s}=yn(e),i=await cn({aptosConfig:t,payload:{function:`${n}::router::get_owner_addr`,functionArguments:[o,Cu(s)]}}),c=fa(i[0]);return c?H.from(c).toString():void 0}async function bp(r){let{aptosConfig:t,expiration:e,name:n,sender:o,targetAddress:s,toAddress:i,options:c,transferable:f}=r,l=Lr(t),{domainName:h,subdomainName:m}=yn(n),T=e.policy==="subdomain:independent"||e.policy==="subdomain:follow-domain";if(m&&!T)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(T&&!m)throw new Error(`Policy is set to ${e.policy} but no subdomain was provided`);if(e.policy==="domain"){let w=e.years??1;if(w!==1)throw new Error("For now, names can only be registered for 1 year at a time");let k=w*31536e3;return await Pe({aptosConfig:t,sender:o.accountAddress.toString(),data:{function:`${l}::router::register_domain`,functionArguments:[h,k,s,i]},options:c})}if(!m)throw new Error(`${e.policy} requires a subdomain to be provided.`);let v=await Uu({aptosConfig:t,name:h});if(!v)throw new Error("The domain does not exist");let b=e.policy==="subdomain:independent"?e.expirationDate:v;if(b>v)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await Pe({aptosConfig:t,sender:o.accountAddress.toString(),data:{function:`${l}::router::register_subdomain`,functionArguments:[h,m,Math.round(b/1e3),e.policy==="subdomain:follow-domain"?1:0,!!f,s,i]},options:c})}async function Uu(r){let{aptosConfig:t,name:e}=r,n=Lr(t),{domainName:o,subdomainName:s}=yn(e);try{let i=await cn({aptosConfig:t,payload:{function:`${n}::router::get_expiration`,functionArguments:[o,Cu(s)]}});return Number(i[0])*1e3}catch{return}}async function wp(r){let{aptosConfig:t,address:e}=r,n=Lr(t),o=await cn({aptosConfig:t,payload:{function:`${n}::router::get_primary_name`,functionArguments:[H.from(e).toString()]}}),s=fa(o[1]),i=fa(o[0]);if(s)return[i,s].filter(Boolean).join(".")}async function Tp(r){let{aptosConfig:t,sender:e,name:n,options:o}=r,s=Lr(t);if(!n)return await Pe({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::clear_primary_name`,functionArguments:[]},options:o});let{domainName:i,subdomainName:c}=yn(n);return await Pe({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::set_primary_name`,functionArguments:[i,c]},options:o})}async function _p(r){let{aptosConfig:t,name:e}=r,n=Lr(t),{domainName:o,subdomainName:s}=yn(e),i=await cn({aptosConfig:t,payload:{function:`${n}::router::get_target_addr`,functionArguments:[o,Cu(s)]}}),c=fa(i[0]);return c?H.from(c).toString():void 0}async function Sp(r){let{aptosConfig:t,sender:e,name:n,address:o,options:s}=r,i=Lr(t),{domainName:c,subdomainName:f}=yn(n);return await Pe({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${i}::router::set_target_addr`,functionArguments:[c,f,o]},options:s})}async function Ep(r){let{aptosConfig:t,name:e}=r,{domainName:n,subdomainName:o=""}=yn(e),c=(await Ee({aptosConfig:t,query:{query:yo,variables:{where_condition:{domain:{_eq:n},subdomain:{_eq:o}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return c&&(c=Us(c)),c}async function vp(r){let{aptosConfig:t,options:e,accountAddress:n}=r,o=await Iu({aptosConfig:t});return(await Ee({aptosConfig:t,originMethod:"getAccountNames",query:{query:yo,variables:{limit:e?.limit,offset:e?.offset,order_by:e?.orderBy,where_condition:{...r.options?.where??{},owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:o}}}}})).current_aptos_names.map(Us)}async function Cp(r){let{aptosConfig:t,options:e,accountAddress:n}=r,o=await Iu({aptosConfig:t});return(await Ee({aptosConfig:t,originMethod:"getAccountDomains",query:{query:yo,variables:{limit:e?.limit,offset:e?.offset,order_by:e?.orderBy,where_condition:{...r.options?.where??{},owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""}}}}})).current_aptos_names.map(Us)}async function Up(r){let{aptosConfig:t,options:e,accountAddress:n}=r,o=await Iu({aptosConfig:t});return(await Ee({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:yo,variables:{limit:e?.limit,offset:e?.offset,order_by:e?.orderBy,where_condition:{...r.options?.where??{},owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:o},subdomain:{_neq:""}}}}})).current_aptos_names.map(Us)}async function Ip(r){let{aptosConfig:t,options:e,domain:n}=r;return(await Ee({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:yo,variables:{limit:e?.limit,offset:e?.offset,order_by:e?.orderBy,where_condition:{...r.options?.where??{},domain:{_eq:n},subdomain:{_neq:""}}}}})).current_aptos_names.map(Us)}async function Iu(r){let{aptosConfig:t}=r,e=Lr(t),[n]=await cn({aptosConfig:t,payload:{function:`${e}::config::reregistration_grace_sec`,functionArguments:[]}}),o=n/60/60/24,s=()=>new Date;return new Date(s().setDate(s().getDate()-o)).toISOString()}async function Bp(r){let{aptosConfig:t,sender:e,name:n,years:o=1,options:s}=r,i=Lr(t),c=o*31536e3,{domainName:f,subdomainName:l}=yn(n);if(l)throw new Error("Subdomains cannot be renewed");if(o!==1)throw new Error("Currently, only 1 year renewals are supported");return await Pe({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${i}::router::renew_domain`,functionArguments:[f,c]},options:s})}function Us(r){return{...r,expiration_timestamp:new Date(r.expiration_timestamp).valueOf()}}var Is=class{constructor(t){this.config=t}async getOwnerAddress(t){return xp({aptosConfig:this.config,...t})}async getExpiration(t){return Uu({aptosConfig:this.config,...t})}async getTargetAddress(t){return _p({aptosConfig:this.config,...t})}async setTargetAddress(t){return Sp({aptosConfig:this.config,...t})}async getPrimaryName(t){return wp({aptosConfig:this.config,...t})}async setPrimaryName(t){return Tp({aptosConfig:this.config,...t})}async registerName(t){return bp({aptosConfig:this.config,...t})}async renewDomain(t){return Bp({aptosConfig:this.config,...t})}async getName(t){return Ep({aptosConfig:this.config,...t})}async getAccountNames(t){return vp({aptosConfig:this.config,...t})}async getAccountDomains(t){return Cp({aptosConfig:this.config,...t})}async getAccountSubdomains(t){return Up({aptosConfig:this.config,...t})}async getDomainSubdomains(t){return Ip({aptosConfig:this.config,...t})}};async function Pp(r){let{aptosConfig:t,poolAddress:e}=r,n=H.from(e).toStringLong(),s=await Ee({aptosConfig:t,query:{query:zc,variables:{where_condition:{pool_address:{_eq:n}}}}});return s.num_active_delegator_per_pool[0]?s.num_active_delegator_per_pool[0].num_active_delegator:0}async function Rp(r){let{aptosConfig:t,options:e}=r,n={query:zc,variables:{order_by:e?.orderBy}};return(await Ee({aptosConfig:t,query:n})).num_active_delegator_per_pool}async function Op(r){let{aptosConfig:t,delegatorAddress:e,poolAddress:n}=r,o={query:_d,variables:{delegatorAddress:H.from(e).toStringLong(),poolAddress:H.from(n).toStringLong()}};return(await Ee({aptosConfig:t,query:o})).delegated_staking_activities}var Bs=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"stake_processor"}),Pp({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"stake_processor"}),Rp({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"stake_processor"}),Op({aptosConfig:this.config,...t})}};var da=()=>Math.floor(Date.now()/1e3),Ps=class{constructor(t,e,n,o,s){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=e,this.maxWaitTime=n,this.maximumInFlight=o,this.sleepTime=s}async nextSequenceNumber(){for(;this.lock;)await un(this.sleepTime);this.lock=!0;let t=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let e=da();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await un(this.sleepTime),da()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}t=this.currentNumber,this.currentNumber+=BigInt(1)}catch(e){console.error("error in getting next sequence number for this account",e)}finally{this.lock=!1}return t}async initialize(){let{sequence_number:t}=await pr({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await pr({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(t),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await un(this.sleepTime);this.lock=!0;try{await this.update();let t=da();for(;this.lastUncommintedNumber!==this.currentNumber;)da()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await un(this.sleepTime),await this.update())}catch(t){console.error("error in synchronizing this account sequence number with the one on chain",t)}finally{this.lock=!1}}}};var Ro=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){this.pendingDequeue.shift()?.resolve(t);return}this.queue.push(t)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((t,e)=>{this.pendingDequeue.push({resolve:t,reject:e})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:t})=>{t(new Oo("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Oo=class extends Error{};var Np="fulfilled",Rs=class{constructor(t,e,n=30,o=100,s=10){this.taskQueue=new Ro;this.transactionsQueue=new Ro;this.outstandingTransactions=new Ro;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=e,this.started=!1,this.accountSequnceNumber=new Ps(t,e,n,o,s)}async submitNextTransaction(){try{for(;;){if(this.transactionsQueue.isEmpty())return;let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let e=await this.generateNextTransaction(this.account,t);if(!e)return;let n=ws({aptosConfig:this.aptosConfig,transaction:e,signer:this.account});await this.outstandingTransactions.enqueue([n,t])}}catch(t){if(t instanceof Oo)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],e=[],[n,o]=await this.outstandingTransactions.dequeue();for(t.push(n),e.push(o);!this.outstandingTransactions.isEmpty();)[n,o]=await this.outstandingTransactions.dequeue(),t.push(n),e.push(o);let s=await Promise.allSettled(t);for(let i=0;i<s.length&&i<e.length;i+=1){let c=s[i];o=e[i],c.status===Np?(this.sentTransactions.push([c.value.hash,o,null]),await this.checkTransaction(c,o)):this.sentTransactions.push([c.status,o,c.reason])}}}catch(t){if(t instanceof Oo)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,e){try{let n=[];n.push(Ao({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(n);for(let s=0;s<o.length;s+=1){let i=o[s];i.status===Np?this.executedTransactions.push([i.value.hash,e,null]):this.executedTransactions.push([i.status,e,i.reason])}}catch(n){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${n}`)}}async push(t,e){await this.transactionsQueue.enqueue([t,e])}async generateNextTransaction(t,e){if(this.transactionsQueue.isEmpty())return;let[n,o]=await this.transactionsQueue.dequeue();return await Pe({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:n,options:{...o,accountSequenceNumber:e}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var la=class{constructor(t){this.config=t}async simple(t){return Pe({aptosConfig:this.config,...t})}async multiAgent(t){return Pe({aptosConfig:this.config,...t})}};function Bu(r,t,e){let n=e.value;return e.value=async function(...o){let[s]=o;if(s.transaction.feePayerAddress&&!s.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return n.apply(this,o)},e}function Pu(r,t,e){let n=e.value;return e.value=async function(...o){let[s]=o;if(s.transaction.feePayerAddress&&!s.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return n.apply(this,o)},e}var No=class{constructor(t){this.config=t}async simple(t){return _u({aptosConfig:this.config,...t})}async multiAgent(t){return _u({aptosConfig:this.config,...t})}};Et([Pu],No.prototype,"simple",1),Et([Pu],No.prototype,"multiAgent",1);var ko=class{constructor(t){this.config=t}async simple(t){return ca({aptosConfig:this.config,...t})}async multiAgent(t){return ca({aptosConfig:this.config,...t})}};Et([Bu],ko.prototype,"simple",1),Et([Bu],ko.prototype,"multiAgent",1);var Os=class{constructor(t){this.config=t,this.build=new la(this.config),this.simulate=new No(this.config),this.submit=new ko(this.config)}async getTransactions(t){return Vd({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return jd({aptosConfig:this.config,...t})}async getTransactionByHash(t){return Pi({aptosConfig:this.config,...t})}async isPendingTransaction(t){return Qd({aptosConfig:this.config,...t})}async waitForTransaction(t){return Ao({aptosConfig:this.config,...t})}async getGasPriceEstimation(){return Bi({aptosConfig:this.config})}getSigningMessage(t){return Ll(t)}async publishPackageTransaction(t){return ql({aptosConfig:this.config,...t})}async rotateAuthKey(t){return Kl({aptosConfig:this.config,...t})}sign(t){return aa({...t})}signAsFeePayer(t){let{signer:e,transaction:n}=t;if(!n.feePayerAddress)throw new Error(`Transaction ${n} is not a Fee Payer transaction`);return n.feePayerAddress=e.accountAddress,aa({signer:e,transaction:n})}async batchTransactionsForSingleAccount(t){try{let{sender:e,data:n,options:o}=t,s=new Rs(this.config,e);s.start();for(let i of n)await s.push(i,o)}catch(e){throw new Error(`failed to submit transactions with error: ${e}`)}}async signAndSubmitTransaction(t){let{signer:e,transaction:n}=t;return ws({aptosConfig:this.config,signer:e,transaction:n})}};var Nt=class{constructor(t){this.config=new ds(t),this.account=new ts(this.config),this.ans=new Is(this.config),this.coin=new Ts(this.config),this.digitalAsset=new _s(this.config),this.event=new Ss(this.config),this.faucet=new Es(this.config),this.fungibleAsset=new vs(this.config),this.general=new Cs(this.config),this.staking=new Bs(this.config),this.transaction=new Os(this.config)}};function br(r,t,e){Object.getOwnPropertyNames(t.prototype).forEach(n=>{let o=Object.getOwnPropertyDescriptor(t.prototype,n);o&&(o.value=function(...s){return this[e][n](...s)},Object.defineProperty(r.prototype,n,o))})}br(Nt,ts,"account");br(Nt,Is,"ans");br(Nt,Ts,"coin");br(Nt,_s,"digitalAsset");br(Nt,Ss,"event");br(Nt,Es,"faucet");br(Nt,vs,"fungibleAsset");br(Nt,Cs,"general");br(Nt,Bs,"staking");br(Nt,Os,"transaction");return Fp(Ph);})();
430
+ `):" "+Sl(s[0]):"as no adapter specified";throw new Se("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return n},adapters:ou};function su(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new dn(null,r)}function Hi(r){return su(r),r.headers=_t.from(r.headers),r.data=as.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),Ki.getAdapter(r.adapter||wo.adapter)(r).then(function(n){return su(r),n.data=as.call(r,r.transformResponse,n),n.headers=_t.from(n.headers),n},function(n){return cs(n)||(su(r),n&&n.response&&(n.response.data=as.call(r,r.transformResponse,n.response),n.response.headers=_t.from(n.response.headers))),Promise.reject(n)})}var El=r=>r instanceof _t?r.toJSON():r;function Mr(r,t){t=t||{};let e={};function n(l,h,m){return I.isPlainObject(l)&&I.isPlainObject(h)?I.merge.call({caseless:m},l,h):I.isPlainObject(h)?I.merge({},h):I.isArray(h)?h.slice():h}function o(l,h,m){if(I.isUndefined(h)){if(!I.isUndefined(l))return n(void 0,l,m)}else return n(l,h,m)}function s(l,h){if(!I.isUndefined(h))return n(void 0,h)}function i(l,h){if(I.isUndefined(h)){if(!I.isUndefined(l))return n(void 0,l)}else return n(void 0,h)}function c(l,h,m){if(m in t)return n(l,h);if(m in r)return n(void 0,l)}let f={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(l,h)=>o(El(l),El(h),!0)};return I.forEach(Object.keys(Object.assign({},r,t)),function(h){let m=f[h]||o,T=m(r[h],t[h],h);I.isUndefined(T)&&m!==c||(e[h]=T)}),e}var Fi="1.6.2";var iu={};["object","boolean","number","function","string","symbol"].forEach((r,t)=>{iu[r]=function(n){return typeof n===r||"a"+(t<1?"n ":" ")+r}});var vl={};iu.transitional=function(t,e,n){function o(s,i){return"[Axios v"+Fi+"] Transitional option '"+s+"'"+i+(n?". "+n:"")}return(s,i,c)=>{if(t===!1)throw new Se(o(i," has been removed"+(e?" in "+e:"")),Se.ERR_DEPRECATED);return e&&!vl[i]&&(vl[i]=!0,console.warn(o(i," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(s,i,c):!0}};function gh(r,t,e){if(typeof r!="object")throw new Se("options must be an object",Se.ERR_BAD_OPTION_VALUE);let n=Object.keys(r),o=n.length;for(;o-- >0;){let s=n[o],i=t[s];if(i){let c=r[s],f=c===void 0||i(c,s,r);if(f!==!0)throw new Se("option "+s+" must be "+f,Se.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new Se("Unknown option "+s,Se.ERR_BAD_OPTION)}}var $i={assertOptions:gh,validators:iu};var ln=$i.validators,_o=class{constructor(t){this.defaults=t,this.interceptors={request:new Wc,response:new Wc}}request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=Mr(this.defaults,e);let{transitional:n,paramsSerializer:o,headers:s}=e;n!==void 0&&$i.assertOptions(n,{silentJSONParsing:ln.transitional(ln.boolean),forcedJSONParsing:ln.transitional(ln.boolean),clarifyTimeoutError:ln.transitional(ln.boolean)},!1),o!=null&&(I.isFunction(o)?e.paramsSerializer={serialize:o}:$i.assertOptions(o,{encode:ln.function,serialize:ln.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let i=s&&I.merge(s.common,s[e.method]);s&&I.forEach(["delete","get","head","post","put","patch","common"],b=>{delete s[b]}),e.headers=_t.concat(i,s);let c=[],f=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(e)===!1||(f=f&&y.synchronous,c.unshift(y.fulfilled,y.rejected))});let l=[];this.interceptors.response.forEach(function(y){l.push(y.fulfilled,y.rejected)});let h,m=0,T;if(!f){let b=[Hi.bind(this),void 0];for(b.unshift.apply(b,c),b.push.apply(b,l),T=b.length,h=Promise.resolve(e);m<T;)h=h.then(b[m++],b[m++]);return h}T=c.length;let v=e;for(m=0;m<T;){let b=c[m++],y=c[m++];try{v=b(v)}catch(w){y.call(this,w);break}}try{h=Hi.call(this,v)}catch(b){return Promise.reject(b)}for(m=0,T=l.length;m<T;)h=h.then(l[m++],l[m++]);return h}getUri(t){t=Mr(this.defaults,t);let e=us(t.baseURL,t.url);return ss(e,t.params,t.paramsSerializer)}};I.forEach(["delete","get","head","options"],function(t){_o.prototype[t]=function(e,n){return this.request(Mr(n||{},{method:t,url:e,data:(n||{}).data}))}});I.forEach(["post","put","patch"],function(t){function e(n){return function(s,i,c){return this.request(Mr(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}_o.prototype[t]=e(),_o.prototype[t+"Form"]=e(!0)});var fs=_o;var au=class r{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(s){e=s});let n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s,i=new Promise(c=>{n.subscribe(c),s=c}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,c){n.reason||(n.reason=new dn(s,i,c),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}static source(){let t;return{token:new r(function(o){t=o}),cancel:t}}},Cl=au;function cu(r){return function(e){return r.apply(null,e)}}function uu(r){return I.isObject(r)&&r.isAxiosError===!0}var fu={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(fu).forEach(([r,t])=>{fu[t]=r});var Ul=fu;function Il(r){let t=new fs(r),e=rs(fs.prototype.request,t);return I.extend(e,fs.prototype,t,{allOwnKeys:!0}),I.extend(e,t,null,{allOwnKeys:!0}),e.create=function(o){return Il(Mr(r,o))},e}var it=Il(wo);it.Axios=fs;it.CanceledError=dn;it.CancelToken=Cl;it.isCancel=cs;it.VERSION=Fi;it.toFormData=fn;it.AxiosError=Se;it.Cancel=it.CanceledError;it.all=function(t){return Promise.all(t)};it.spread=cu;it.isAxiosError=uu;it.mergeConfig=Mr;it.AxiosHeaders=_t;it.formToJSON=r=>Li(I.isHTMLForm(r)?new FormData(r):r);it.getAdapter=Ki.getAdapter;it.HttpStatusCode=Ul;it.default=it;var Vi=it;var{Axios:JT,AxiosError:e_,CanceledError:t_,isCancel:r_,CancelToken:n_,VERSION:o_,all:s_,Cancel:i_,isAxiosError:a_,spread:c_,toFormData:u_,AxiosHeaders:f_,HttpStatusCode:d_,formToJSON:l_,getAdapter:p_,mergeConfig:g_}=Vi;async function Bl(r){var t;let{params:e,method:n,url:o,headers:s,body:i,overrides:c}=r,f={headers:s,method:n,url:o,params:e,data:i,withCredentials:(t=c?.WITH_CREDENTIALS)!=null?t:!0};try{let l=await Vi(f);return{status:l.status,statusText:l.statusText,data:l.data,headers:l.headers,config:l.config}}catch(l){let h=l;if(h.response)return h.response;throw l}}var ds=class{constructor(t){this.network=t?.network??Oa,this.fullnode=t?.fullnode,this.faucet=t?.faucet,this.indexer=t?.indexer,this.client=t?.client??{provider:Bl},this.clientConfig=t?.clientConfig??{}}getRequestUrl(t){switch(t){case 0:if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return Pa[this.network];case 2:if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return Ra[this.network];case 1:if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return Ks[this.network];default:throw Error(`apiType ${t} is not supported`)}}isIndexerRequest(t){return Ks[this.network]===t}};var ls=class extends ae{constructor(e){super();this.accountAddress=H.ONE;this.moduleName=new ht("account");this.structName=new ht("RotationProofChallenge");this.sequenceNumber=new ft(e.sequenceNumber),this.originator=e.originator,this.currentAuthKey=e.currentAuthKey,this.newPublicKey=Le.U8(e.newPublicKey.toUint8Array())}serialize(e){e.serialize(this.accountAddress),e.serialize(this.moduleName),e.serialize(this.structName),e.serialize(this.sequenceNumber),e.serialize(this.originator),e.serialize(this.currentAuthKey),e.serialize(this.newPublicKey)}};var vt=class extends ae{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return mr.load(t);case 1:return ps.load(t);case 2:return sr.load(t);case 3:return Ln.load(t);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${e}`)}}isEd25519(){return this instanceof mr}isMultiEd25519(){return this instanceof ps}isSingleKey(){return this instanceof sr}isMultiKey(){return this instanceof Ln}},mr=class r extends vt{constructor(e,n){super();this.public_key=e,this.signature=n}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let n=qe.deserialize(e),o=Je.deserialize(e);return new r(n,o)}},ps=class r extends vt{constructor(e,n){super();this.public_key=e,this.signature=n}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let n=er.deserialize(e),o=Bn.deserialize(e);return new r(n,o)}},sr=class r extends vt{constructor(e,n){super();this.public_key=e,this.signature=n}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let n=je.deserialize(e),o=lr.deserialize(e);return new r(n,o)}},Ln=class r extends vt{constructor(e,n,o){super();this.public_keys=e,this.signatures=n,this.signatures_bitmap=o}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),e.serializeVector(this.signatures),e.serializeBytes(this.signatures_bitmap)}static load(e){let n=Gn.deserialize(e),o=e.deserializeVector(lr),s=e.deserializeBytes();return new r(n,o,s)}};var yr=class extends ae{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return qn.load(t);case 1:return ji.load(t);case 2:return Kn.load(t);case 3:return Hn.load(t);case 4:return Fn.load(t);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${e}`)}}},qn=class r extends yr{constructor(e,n){super();this.public_key=e,this.signature=n}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let n=qe.deserialize(e),o=Je.deserialize(e);return new r(n,o)}},ji=class r extends yr{constructor(e,n){super();this.public_key=e,this.signature=n}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let n=er.deserialize(e),o=Bn.deserialize(e);return new r(n,o)}},Kn=class r extends yr{constructor(e,n,o){super();this.sender=e,this.secondary_signer_addresses=n,this.secondary_signers=o}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let n=vt.deserialize(e),o=e.deserializeVector(H),s=e.deserializeVector(vt);return new r(n,o,s)}},Hn=class r extends yr{constructor(e,n,o,s){super();this.sender=e,this.secondary_signer_addresses=n,this.secondary_signers=o,this.fee_payer=s}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let n=vt.deserialize(e),o=e.deserializeVector(H),s=e.deserializeVector(vt),i=H.deserialize(e),c=vt.deserialize(e),f={address:i,authenticator:c};return new r(n,o,s,f)}},Fn=class r extends yr{constructor(e){super();this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let n=vt.deserialize(e);return new r(n)}};var $n=class r extends ae{constructor(e){super();this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let n=e.deserializeU8();return new r(n)}};var Qe=class r extends ae{constructor(e){super();this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let n=e.deserializeStr();return new r(n)}};var So=class r extends ae{constructor(e,n){super();this.address=e,this.name=n}static fromStr(e){let n=e.split("::");if(n.length!==2)throw new Error("Invalid module id.");return new r(H.fromString(n[0]),new Qe(n[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let n=H.deserialize(e),o=Qe.deserialize(e);return new r(n,o)}};var rt=class extends ae{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Vn.load(t);case 1:return jn.load(t);case 2:return Yn.load(t);case 3:return Zn.load(t);case 4:return Jn.load(t);case 5:return pn.load(t);case 6:return to.load(t);case 7:return Gr.load(t);case 8:return Qn.load(t);case 9:return Wn.load(t);case 10:return Xn.load(t);case 255:return eo.load(t);default:throw new Error(`Unknown variant index for TypeTag: ${e}`)}}isBool(){return this instanceof Vn}isAddress(){return this instanceof Jn}isGeneric(){return this instanceof eo}isSigner(){return this instanceof pn}isVector(){return this instanceof to}isStruct(){return this instanceof Gr}isU8(){return this instanceof jn}isU16(){return this instanceof Qn}isU32(){return this instanceof Wn}isU64(){return this instanceof Yn}isU128(){return this instanceof Zn}isU256(){return this instanceof Xn}},Vn=class r extends rt{toString(){return"bool"}serialize(t){t.serializeU32AsUleb128(0)}static load(t){return new r}},jn=class r extends rt{toString(){return"u8"}serialize(t){t.serializeU32AsUleb128(1)}static load(t){return new r}},Qn=class r extends rt{toString(){return"u16"}serialize(t){t.serializeU32AsUleb128(8)}static load(t){return new r}},Wn=class r extends rt{toString(){return"u32"}serialize(t){t.serializeU32AsUleb128(9)}static load(t){return new r}},Yn=class r extends rt{toString(){return"u64"}serialize(t){t.serializeU32AsUleb128(2)}static load(t){return new r}},Zn=class r extends rt{toString(){return"u128"}serialize(t){t.serializeU32AsUleb128(3)}static load(t){return new r}},Xn=class r extends rt{toString(){return"u256"}serialize(t){t.serializeU32AsUleb128(10)}static load(t){return new r}},Jn=class r extends rt{toString(){return"address"}serialize(t){t.serializeU32AsUleb128(4)}static load(t){return new r}},pn=class r extends rt{toString(){return"signer"}serialize(t){t.serializeU32AsUleb128(5)}static load(t){return new r}},gs=class r extends rt{constructor(e){super();this.value=e}toString(){return`&${this.value.toString()}`}serialize(e){e.serializeU32AsUleb128(254)}static load(e){let n=rt.deserialize(e);return new r(n)}},eo=class r extends rt{constructor(e){super();this.value=e;if(e<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(e){e.serializeU32AsUleb128(255),e.serializeU32(this.value)}static load(e){let n=e.deserializeU32();return new r(n)}},to=class r extends rt{constructor(e){super();this.value=e}toString(){return`vector<${this.value.toString()}>`}serialize(e){e.serializeU32AsUleb128(6),this.value.serialize(e)}static load(e){let n=rt.deserialize(e);return new r(n)}},Gr=class r extends rt{constructor(e){super();this.value=e}toString(){let e="";return this.value.typeArgs.length>0&&(e=`<${this.value.typeArgs.map(n=>n.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${e}`}serialize(e){e.serializeU32AsUleb128(7),this.value.serialize(e)}static load(e){let n=hr.deserialize(e);return new r(n)}isTypeTag(e,n,o){return this.value.moduleName.identifier===n&&this.value.name.identifier===o&&this.value.address.equals(e)}isString(){return this.isTypeTag(H.ONE,"string","String")}isOption(){return this.isTypeTag(H.ONE,"option","Option")}isObject(){return this.isTypeTag(H.ONE,"object","Object")}},hr=class r extends ae{constructor(e,n,o,s){super();this.address=e,this.moduleName=n,this.name=o,this.typeArgs=s}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let n=H.deserialize(e),o=Qe.deserialize(e),s=Qe.deserialize(e),i=e.deserializeVector(rt);return new r(n,o,s,i)}};function mh(){return new hr(H.ONE,new Qe("aptos_coin"),new Qe("AptosCoin"),[])}function yh(){return new hr(H.ONE,new Qe("string"),new Qe("String"),[])}function hh(r){return new hr(H.ONE,new Qe("option"),new Qe("Option"),[r])}function Ah(r){return new hr(H.ONE,new Qe("object"),new Qe("Object"),[r])}function Pl(r){let t=r.deserializeUleb128AsU32();switch(t){case 0:return lt.deserialize(r);case 1:return ft.deserialize(r);case 2:return Mt.deserialize(r);case 3:return H.deserialize(r);case 4:return Le.deserialize(r,lt);case 5:return Xe.deserialize(r);case 6:return zt.deserialize(r);case 7:return Dt.deserialize(r);case 8:return Gt.deserialize(r);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${t}`)}}var gn=class extends ae{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Eo.load(t);case 2:return vo.load(t);case 3:return Co.load(t);default:throw new Error(`Unknown variant index for TransactionPayload: ${e}`)}}},Eo=class r extends gn{constructor(e){super();this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let n=Uo.deserialize(e);return new r(n)}},vo=class r extends gn{constructor(e){super();this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let n=ro.deserialize(e);return new r(n)}},Co=class r extends gn{constructor(e){super();this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let n=Io.deserialize(e);return new r(n)}},ro=class r{constructor(t,e,n,o){this.module_name=t,this.function_name=e,this.type_args=n,this.args=o}static build(t,e,n,o){return new r(So.fromStr(t),new Qe(e),n,o)}serialize(t){this.module_name.serialize(t),this.function_name.serialize(t),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForEntryFunction(t)})}static deserialize(t){let e=So.deserialize(t),n=Qe.deserialize(t),o=t.deserializeVector(rt),s=t.deserializeUleb128AsU32(),i=new Array;for(let c=0;c<s;c+=1){let f=t.deserializeUleb128AsU32(),l=Qo.deserialize(t,f);i.push(l)}return new r(e,n,o,i)}},Uo=class r{constructor(t,e,n){this.bytecode=t,this.type_args=e,this.args=n}serialize(t){t.serializeBytes(this.bytecode),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForScriptFunction(t)})}static deserialize(t){let e=t.deserializeBytes(),n=t.deserializeVector(rt),o=t.deserializeUleb128AsU32(),s=new Array;for(let i=0;i<o;i+=1){let c=Pl(t);s.push(c)}return new r(e,n,s)}},Io=class r{constructor(t,e){this.multisig_address=t,this.transaction_payload=e}serialize(t){this.multisig_address.serialize(t),this.transaction_payload===void 0?t.serializeBool(!1):(t.serializeBool(!0),this.transaction_payload.serialize(t))}static deserialize(t){let e=H.deserialize(t),n=t.deserializeBool(),o;return n&&(o=Bo.deserialize(t)),new r(e,o)}},Bo=class r extends ae{constructor(e){super();this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new r(ro.deserialize(e))}};var Vt=class r extends ae{constructor(e,n,o,s,i,c,f){super();this.sender=e,this.sequence_number=n,this.payload=o,this.max_gas_amount=s,this.gas_unit_price=i,this.expiration_timestamp_secs=c,this.chain_id=f}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let n=H.deserialize(e),o=e.deserializeU64(),s=gn.deserialize(e),i=e.deserializeU64(),c=e.deserializeU64(),f=e.deserializeU64(),l=$n.deserialize(e);return new r(n,o,s,i,c,f,l)}},ms=class extends ae{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Ar.load(t);case 1:return xr.load(t);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${e}`)}}},Ar=class r extends ms{constructor(e,n){super();this.raw_txn=e,this.secondary_signer_addresses=n}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let n=Vt.deserialize(e),o=e.deserializeVector(H);return new r(n,o)}},xr=class r extends ms{constructor(e,n,o){super();this.raw_txn=e,this.secondary_signer_addresses=n,this.fee_payer_address=o}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let n=Vt.deserialize(e),o=e.deserializeVector(H),s=H.deserialize(e);return new r(n,o,s)}};var ir=class r extends ae{constructor(e,n){super();this.raw_txn=e,this.authenticator=n}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let n=Vt.deserialize(e),o=yr.deserialize(e);return new r(n,o)}};function Rl(r){return!!r.match(/^[_a-zA-Z0-9]+$/)}function Ol(r){return!!r.match(/\s/)}function xh(r){return!!r.match(/^T[0-9]+$/)}function bh(r,t){let e=t;for(;e<r.length;e+=1){let n=r[e];if(!Ol(n))break}return e}var Nl=(T=>(T.InvalidTypeTag="unknown type",T.UnexpectedGenericType="unexpected generic type",T.UnexpectedTypeArgumentClose="unexpected '>'",T.UnexpectedWhitespaceCharacter="unexpected whitespace character",T.UnexpectedComma="unexpected ','",T.TypeArgumentCountMismatch="type argument count doesn't match expected amount",T.MissingTypeArgumentClose="no matching '>' for '<'",T.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",T.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",T.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",T.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",T.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",T))(Nl||{}),He=class extends Error{constructor(t,e){super(`Failed to parse typeTag '${t}', ${e}`)}};function Po(r,t){let e=t?.allowGenerics??!1,n=[],o=[],s=[],i=0,c="",f=1;for(;i<r.length;){let l=r[i];if(l==="<")n.push({savedExpectedTypes:f,savedStr:c,savedTypes:s}),c="",s=[],f=1;else if(l===">"){if(c!==""){let b=Qi(c,o,e);s.push(b)}let h=n.pop();if(h===void 0)throw new He(r,"unexpected '>'");if(f!==s.length)throw new He(r,"type argument count doesn't match expected amount");let{savedStr:m,savedTypes:T,savedExpectedTypes:v}=h;o=s,s=T,c=m,f=v}else if(l===","){if(c.length!==0){let h=Qi(c,o,e);o=[],s.push(h),c="",f+=1}}else if(Ol(l)){let h=!1;if(c.length!==0){let T=Qi(c,o,e);o=[],s.push(T),c="",h=!0}i=bh(r,i);let m=r[i];if(i<r.length&&h&&m!==","&&m!==">")throw new He(r,"unexpected whitespace character");continue}else c+=l;i+=1}if(n.length>0)throw new He(r,"no matching '>' for '<'");switch(s.length){case 0:return Qi(c,o,e);case 1:if(c==="")return s[0];throw new He(r,"unexpected ','");default:throw new He(r,"unexpected whitespace character")}}function Qi(r,t,e){switch(r){case"&signer":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new gs(new pn);case"signer":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new pn;case"bool":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Vn;case"address":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Jn;case"u8":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new jn;case"u16":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Qn;case"u32":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Wn;case"u64":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Yn;case"u128":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Zn;case"u256":if(t.length>0)throw new He(r,"primitive types not expected to have type arguments");return new Xn;case"vector":if(t.length!==1)throw new He(r,"vector type expected to have exactly one type argument");return new to(t[0]);default:if(xh(r)){if(e)return new eo(Number(r.split("T")[1]));throw new He(r,"unexpected generic type")}if(!r.match(/.*:.*/))throw new He(r,"unknown type");let n=r.split("::");if(n.length!==3)throw new He(r,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");if(!Rl(n[1]))throw new He(r,"module name must only contain alphanumeric or '_' characters");if(!Rl(n[2]))throw new He(r,"struct name must only contain alphanumeric or '_' characters");return new Gr(new hr(H.fromString(n[0]),new Qe(n[1]),new Qe(n[2]),t))}}function du(r){return typeof r=="boolean"}function no(r){return typeof r=="string"}function ys(r){return typeof r=="number"}function hs(r){return typeof r=="number"||typeof r=="bigint"||typeof r=="string"}function lu(r){return r==null}function pu(r){return Wi(r)||Zi(r)||Xi(r)||Ji(r)||ea(r)||ta(r)||ra(r)||As(r)||Yi(r)||kl(r)||r instanceof Le||r instanceof Cr}function Wi(r){return r instanceof Xe}function As(r){return r instanceof H}function Yi(r){return r instanceof ht}function kl(r){return r instanceof $r}function Zi(r){return r instanceof lt}function Xi(r){return r instanceof zt}function Ji(r){return r instanceof Dt}function ea(r){return r instanceof ft}function ta(r){return r instanceof Mt}function ra(r){return r instanceof Gt}function na(r){return"bytecode"in r}function $e(r,t){throw new Error(`Type mismatch for argument ${t}, expected '${r}'`)}function gu(r){let t=r.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?r.params.length:t}function oa(r){let t=r.split("::");if(t.length!==3)throw new Error(`Invalid function ${r}`);let e=t[0],n=t[1],o=t[2];return{moduleAddress:e,moduleName:n,functionName:o}}var wh=new TextEncoder;function yu(r){return r?.map(t=>no(t)?Po(t):t)??[]}async function hu(r,t,e,n){let s=(await Ui({aptosConfig:n,accountAddress:r,moduleName:t})).abi?.exposed_functions.find(f=>f.name===e);if(!s)throw new Error(`Could not find entry function ABI for '${r}::${t}::${e}'`);if(!s.is_entry)throw new Error(`'${r}::${t}::${e}' is not an entry function`);let i=gu(s),c=[];for(let f=i;f<s.params.length;f+=1)c.push(Po(s.params[f],{allowGenerics:!0}));return{typeParameters:s.generic_type_params,parameters:c}}function Au(r,t,e,n,o){if(n>=t.parameters.length)throw new Error(`Too many arguments for '${r}', expected ${t.parameters.length}`);let s=t.parameters[n];return oo(e,s,n,o)}function oo(r,t,e,n){return pu(r)?(mu(t,r,e),r):Th(r,t,e,n)}function Th(r,t,e,n){if(t.isBool()){if(du(r))return new Xe(r);$e("boolean",e)}if(t.isAddress()){if(no(r))return H.fromString(r);$e("string | AccountAddress",e)}if(t.isU8()){if(ys(r))return new lt(r);$e("number",e)}if(t.isU16()){if(ys(r))return new zt(r);$e("number",e)}if(t.isU32()){if(ys(r))return new Dt(r);$e("number",e)}if(t.isU64()){if(hs(r))return new ft(BigInt(r));$e("bigint | number | string",e)}if(t.isU128()){if(hs(r))return new Mt(BigInt(r));$e("bigint | number | string",e)}if(t.isU256()){if(hs(r))return new Gt(BigInt(r));$e("bigint | number | string",e)}if(t.isGeneric()){let o=t.value;if(o<0||o>=n.length)throw new Error(`Generic argument ${t.toString()} is invalid for argument ${e}`);return oo(r,n[o],e,n)}if(t.isVector()){if(t.value.isU8()){if(no(r))return Le.U8(wh.encode(r));if(r instanceof Uint8Array)return Le.U8(r);if(r instanceof ArrayBuffer)return Le.U8(new Uint8Array(r))}if(Array.isArray(r))return new Le(r.map(o=>oo(o,t.value,e,n)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(no(r))return new ht(r);$e("string",e)}if(t.isObject()){if(no(r))return H.fromString(r);$e("string | AccountAddress",e)}if(t.isOption())return lu(r)?new Cr(null):new Cr(oo(r,t.value.typeArgs[0],e,n));throw new Error(`Unsupported struct input type for argument ${e}, type '${t.toString()}'`)}throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}function mu(r,t,e){if(r.isBool()){if(Wi(t))return;$e("Bool",e)}if(r.isAddress()){if(As(t))return;$e("AccountAddress",e)}if(r.isU8()){if(Zi(t))return;$e("U8",e)}if(r.isU16()){if(Xi(t))return;$e("U16",e)}if(r.isU32()){if(Ji(t))return;$e("U32",e)}if(r.isU64()){if(ea(t))return;$e("U64",e)}if(r.isU128()){if(ta(t))return;$e("U128",e)}if(r.isU256()){if(ra(t))return;$e("U256",e)}if(r.isVector()){if(t instanceof Le){t.values.length>0&&mu(r.value,t.values[0],e);return}$e("MoveVector",e)}if(r instanceof Gr){if(r.isString()){if(Yi(t))return;$e("MoveString",e)}if(r.isObject()){if(As(t))return;$e("AccountAddress",e)}if(r.isOption()){if(t instanceof Cr){t.value!==void 0&&mu(r.value.typeArgs[0],t.value,e);return}$e("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${r.toString()}'`)}async function bs(r){if(na(r))return Dl(r);let{moduleAddress:t,moduleName:e,functionName:n}=oa(r.function),o=await ho(async()=>hu(t,e,n,r.aptosConfig),`entry-function-${r.aptosConfig.network}-${t}-${e}-${n}`,1e3*60*5)();return zl(r,o)}function zl(r,t){if(na(r))return Dl(r);let{moduleAddress:e,moduleName:n,functionName:o}=oa(r.function),s=yu(r.typeArguments);if(s.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${s.length}`);let i=r.functionArguments.map((f,l)=>Au(r.function,t,f,l,s));if(i.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${n}::${o}', expected ${t.parameters.length} but got ${i.length}`);let c=ro.build(`${e}::${n}`,o,s,i);if("multisigAddress"in r){let f=H.from(r.multisigAddress);return new Co(new Io(f,new Bo(c)))}return new vo(c)}function Dl(r){return new Eo(new Uo(Be.fromHexInput(r.bytecode).toUint8Array(),r.typeArguments??[],r.functionArguments))}async function Ml(r){let{aptosConfig:t,sender:e,payload:n,options:o}=r,s=o?.accountSequenceNumber!==void 0?Promise.resolve({sequence_number:o.accountSequenceNumber}):pr({aptosConfig:t,accountAddress:e}),i=Hs[t.network]?Promise.resolve({chain_id:Hs[t.network]}):Si({aptosConfig:t}),c=o?.gasUnitPrice?Promise.resolve({gas_estimate:o.gasUnitPrice}):Bi({aptosConfig:t}),[{sequence_number:f},{chain_id:l},{gas_estimate:h}]=await Promise.all([s,i,c]),{maxGasAmount:m,gasUnitPrice:T,expireTimestamp:v}={maxGasAmount:o?.maxGasAmount?BigInt(o.maxGasAmount):BigInt(Na),gasUnitPrice:BigInt(h),expireTimestamp:BigInt(Math.floor(Date.now()/1e3)+ka),...o};return new Vt(H.from(e),BigInt(f),n,BigInt(m),BigInt(T),BigInt(v),new $n(l))}async function sa(r){let{aptosConfig:t,sender:e,payload:n,options:o}=r,s=await Ml({aptosConfig:t,sender:e,payload:n,options:o});if("secondarySignerAddresses"in r){let i=r.secondarySignerAddresses?.map(c=>H.from(c))??[];return{rawTransaction:s,secondarySignerAddresses:i,feePayerAddress:r.feePayerAddress?H.from(r.feePayerAddress):void 0}}return{rawTransaction:s,feePayerAddress:r.feePayerAddress?H.from(r.feePayerAddress):void 0}}function xu(r){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:n,feePayerPublicKey:o}=r,s=xs(t);if(e.feePayerAddress){let c=new xr(e.rawTransaction,e.secondarySignerAddresses??[],e.feePayerAddress),f=[];n&&(f=n.map(m=>xs(m)));let l=xs(o),h=new Hn(s,e.secondarySignerAddresses??[],f,{address:e.feePayerAddress,authenticator:l});return new ir(c.raw_txn,h).bcsToBytes()}if(e.secondarySignerAddresses){let c=new Ar(e.rawTransaction,e.secondarySignerAddresses),f=[];f=n.map(h=>xs(h));let l=new Kn(s,e.secondarySignerAddresses,f);return new ir(c.raw_txn,l).bcsToBytes()}let i;if(s instanceof mr)i=new qn(s.public_key,s.signature);else if(s instanceof sr)i=new Fn(s);else throw new Error("Invalid public key");return new ir(e.rawTransaction,i).bcsToBytes()}function xs(r){if(r instanceof je){if(r.publicKey instanceof qe)return new sr(r,new lr(new Je(new Uint8Array(64))));if(r.publicKey instanceof Ft)return new sr(r,new lr(new kr(new Uint8Array(64))))}return new mr(new qe(r.toUint8Array()),new Je(new Uint8Array(64)))}function bu(r){let{signer:t,transaction:e}=r,n=ia(e),o=t.sign(n);switch(t.signingScheme){case 0:return new mr(new qe(t.publicKey.toUint8Array()),new Je(o.toUint8Array()));case 2:if(!je.isPublicKey(t.publicKey))throw new Error(`Cannot sign transaction, public key does not match ${t.signingScheme}`);return new sr(t.publicKey,new lr(o));default:throw new Error(`Cannot sign transaction, signing scheme ${t.signingScheme} not supported`)}}function wu(r){let{transaction:t,senderAuthenticator:e,feePayerAuthenticator:n,additionalSignersAuthenticators:o}=r,s=Tu(t);if((n||o)&&(s instanceof Ar||s instanceof xr))return Gl(s,e,n,o);if(e instanceof mr&&s instanceof Vt){let i=new qn(e.public_key,e.signature);return new ir(s,i).bcsToBytes()}if((e instanceof sr||e instanceof Ln)&&s instanceof Vt){let i=new Fn(e);return new ir(s,i).bcsToBytes()}throw new Error(`Cannot generate a signed transaction, ${e} is not a supported account authentication scheme`)}function Tu(r){return r.feePayerAddress?new xr(r.rawTransaction,r.secondarySignerAddresses??[],r.feePayerAddress):r.secondarySignerAddresses?new Ar(r.rawTransaction,r.secondarySignerAddresses):r.rawTransaction}function Gl(r,t,e,n){if(r instanceof xr){if(!e)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");let o=new Hn(t,r.secondary_signer_addresses,n??[],{address:r.fee_payer_address,authenticator:e});return new ir(r.raw_txn,o).bcsToBytes()}if(r instanceof Ar){if(!n)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");let o=new Kn(t,r.secondary_signer_addresses,n??[]);return new ir(r.raw_txn,o).bcsToBytes()}throw new Error(`Cannot prepare multi signers transaction to submission, ${typeof r} transaction is not supported`)}function ia(r){let t=Tu(r),e=Cn.create();if(t instanceof Vt)e.update(za);else if(t instanceof Ar)e.update(Fs);else if(t instanceof xr)e.update(Fs);else throw new Error(`Unknown transaction type to sign on: ${t}`);let n=e.digest(),o=t.bcsToBytes(),s=new Uint8Array(n.length+o.length);return s.set(n),s.set(o,n.length),s}async function Pe(r){let t=await _h(r);return Sh(r,t)}async function _h(r){let{aptosConfig:t,data:e}=r,n,o;return"bytecode"in e?(n=e,o=await bs(n)):"multisigAddress"in e?(n={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments},o=await bs(n)):(n={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments},o=await bs(n)),o}async function Sh(r,t){let{aptosConfig:e,sender:n,options:o}=r,s;if(Eh(r)&&(s=H.ZERO.toString()),vh(r)){let{secondarySignerAddresses:i}=r;return sa({aptosConfig:e,sender:n,payload:t,options:o,secondarySignerAddresses:i,feePayerAddress:s})}return sa({aptosConfig:e,sender:n,payload:t,options:o,feePayerAddress:s})}function Eh(r){return r.withFeePayer===!0}function vh(r){return"secondarySignerAddresses"in r}function Ll(r){let{transaction:t}=r;return ia(t)}function aa(r){return bu({...r})}async function _u(r){let{aptosConfig:t,transaction:e,signerPublicKey:n,secondarySignersPublicKeys:o,feePayerPublicKey:s,options:i}=r,c=xu({transaction:e,signerPublicKey:n,secondarySignersPublicKeys:o,feePayerPublicKey:s,options:i}),{data:f}=await Tn({aptosConfig:t,body:c,path:"transactions/simulate",params:{estimate_gas_unit_price:r.options?.estimateGasUnitPrice??!1,estimate_max_gas_amount:r.options?.estimateMaxGasAmount??!1,estimate_prioritized_gas_unit_price:r.options?.estimatePrioritizedGasUnitPrice??!1},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return f}async function ca(r){let{aptosConfig:t}=r,e=wu({...r}),{data:n}=await Tn({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return n}async function ws(r){let{aptosConfig:t,signer:e,transaction:n}=r,o=aa({signer:e,transaction:n});return ca({aptosConfig:t,transaction:n,senderAuthenticator:o})}async function ql(r){let{aptosConfig:t,account:e,metadataBytes:n,moduleBytecode:o,options:s}=r,i=o.map(f=>Le.U8(f));return await Pe({aptosConfig:t,sender:H.from(e),data:{function:"0x1::code::publish_package_txn",functionArguments:[Le.U8(n),new Le(i)]},options:s})}async function Kl(r){let{aptosConfig:t,fromAccount:e,toNewPrivateKey:n}=r,o=await pr({aptosConfig:t,accountAddress:e.accountAddress}),s=Dr.fromPrivateKey({privateKey:n,legacy:!0}),c=new ls({sequenceNumber:BigInt(o.sequence_number),originator:e.accountAddress,currentAuthKey:H.from(o.authentication_key),newPublicKey:s.publicKey}).bcsToBytes(),f=e.sign(c),l=s.sign(c),h=await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new lt(e.signingScheme.valueOf()),Le.U8(e.publicKey.toUint8Array()),new lt(s.signingScheme.valueOf()),Le.U8(s.publicKey.toUint8Array()),Le.U8(f.toUint8Array()),Le.U8(l.toUint8Array())]}});return await ws({aptosConfig:t,signer:e,transaction:h})}async function Hl(r){let{aptosConfig:t,sender:e,recipient:n,amount:o,coinType:s,options:i}=r;return await Pe({aptosConfig:t,sender:e,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[s??$o],functionArguments:[n,o]},options:i})}var Ts=class{constructor(t){this.config=t}async transferCoinTransaction(t){return Hl({aptosConfig:this.config,...t})}};var mn={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},jt="0x4::token::Token";async function Fl(r){let{aptosConfig:t,digitalAssetAddress:e}=r,n={token_data_id:{_eq:H.from(e).toStringLong()}};return(await Ee({aptosConfig:t,query:{query:Ud,variables:{where_condition:n}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function $l(r){let{aptosConfig:t,digitalAssetAddress:e}=r,n={token_data_id:{_eq:H.from(e).toStringLong()}};return(await Ee({aptosConfig:t,query:{query:Mc,variables:{where_condition:n}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Vl(r){let{aptosConfig:t,ownerAddress:e,options:n}=r,o={owner_address:{_eq:H.from(e).toStringLong()},amount:{_gt:0}},s={query:Mc,variables:{where_condition:o,offset:n?.offset,limit:n?.limit,order_by:n?.orderBy}};return(await Ee({aptosConfig:t,query:s,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function jl(r){let{aptosConfig:t,digitalAssetAddress:e,options:n}=r,o={token_data_id:{_eq:H.from(e).toStringLong()}},s={query:Cd,variables:{where_condition:o,offset:n?.offset,limit:n?.limit,order_by:n?.orderBy}};return(await Ee({aptosConfig:t,query:s,originMethod:"getDigitalAssetActivity"})).token_activities_v2}async function Ql(r){let{aptosConfig:t,options:e,creator:n}=r;return await Pe({aptosConfig:t,sender:n.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new ht(r.description),new ft(r.maxSupply??En),new ht(r.name),new ht(r.uri),new Xe(r.mutableDescription??!0),new Xe(r.mutableRoyalty??!0),new Xe(r.mutableURI??!0),new Xe(r.mutableTokenDescription??!0),new Xe(r.mutableTokenName??!0),new Xe(r.mutableTokenProperties??!0),new Xe(r.mutableTokenURI??!0),new Xe(r.tokensBurnableByCreator??!0),new Xe(r.tokensFreezableByCreator??!0),new ft(r.royaltyNumerator??0),new ft(r.royaltyDenominator??1)]},options:e})}async function Su(r){let{aptosConfig:t,creatorAddress:e,collectionName:n,options:o}=r,s=H.from(e),i={collection_name:{_eq:n},creator_address:{_eq:s.toStringLong()}};return o?.tokenStandard&&(i.token_standard={_eq:o?.tokenStandard??"v2"}),(await Ee({aptosConfig:t,query:{query:wd,variables:{where_condition:i}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function Wl(r){return(await Su(r)).collection_id}async function Yl(r){let{aptosConfig:t,options:e,creator:n,collection:o,description:s,name:i,uri:c,propertyKeys:f,propertyTypes:l,propertyValues:h}=r,m=l?.map(v=>mn[v]);return await Pe({aptosConfig:t,sender:n.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[o,s,i,c,f??[],m??[],fp(h??[],m??[])]},options:e})}async function Zl(r){let{aptosConfig:t,sender:e,digitalAssetAddress:n,recipient:o,digitalAssetType:s,options:i}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[s??jt],functionArguments:[n,o]},options:i})}async function Xl(r){let{aptosConfig:t,account:e,collection:n,description:o,name:s,uri:i,recipient:c,propertyKeys:f,propertyTypes:l,propertyValues:h,options:m}=r;if(f?.length!==h?.length)throw new Error("Property keys and property values counts do not match");if(l?.length!==h?.length)throw new Error("Property types and property values counts do not match");let T=l?.map(b=>mn[b]);return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[n,o,s,i,f??[],T??[],fp(h??[],T??[]),c]},options:m})}async function Jl(r){let{aptosConfig:t,creator:e,digitalAssetAddress:n,digitalAssetType:o,options:s}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[o??jt],functionArguments:[n]},options:s})}async function ep(r){let{aptosConfig:t,creator:e,digitalAssetAddress:n,digitalAssetType:o,options:s}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[o??jt],functionArguments:[n]},options:s})}async function tp(r){let{aptosConfig:t,creator:e,digitalAssetAddress:n,digitalAssetType:o,options:s}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[o??jt],functionArguments:[n]},options:s})}async function rp(r){let{aptosConfig:t,creator:e,description:n,digitalAssetAddress:o,digitalAssetType:s,options:i}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[s??jt],functionArguments:[o,n]},options:i})}async function np(r){let{aptosConfig:t,creator:e,name:n,digitalAssetAddress:o,digitalAssetType:s,options:i}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[s??jt],functionArguments:[o,n]},options:i})}async function op(r){let{aptosConfig:t,creator:e,uri:n,digitalAssetAddress:o,digitalAssetType:s,options:i}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[s??jt],functionArguments:[o,n]},options:i})}async function sp(r){let{aptosConfig:t,creator:e,propertyKey:n,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:c,options:f}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[c??jt],functionArguments:[i,n,mn[o],Eu(s,mn[o])]},options:f})}async function ip(r){let{aptosConfig:t,creator:e,propertyKey:n,digitalAssetAddress:o,digitalAssetType:s,options:i}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[s??jt],functionArguments:[o,n]},options:i})}async function ap(r){let{aptosConfig:t,creator:e,propertyKey:n,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:c,options:f}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[c??jt],functionArguments:[i,n,mn[o],Eu(s,mn[o])]},options:f})}async function cp(r){let{aptosConfig:t,creator:e,propertyKey:n,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:c,options:f}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[c??jt,mn[o]],functionArguments:[i,n,s]},options:f})}async function up(r){let{aptosConfig:t,creator:e,propertyKey:n,propertyType:o,propertyValue:s,digitalAssetAddress:i,digitalAssetType:c,options:f}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[c??jt,mn[o]],functionArguments:[i,n,s]},options:f})}function fp(r,t){let e=new Array;return t.forEach((n,o)=>{e.push(Eu(r[o],n))}),e}function Eu(r,t){let e=Po(t);return oo(r,e,0,[]).bcsToBytes()}var _s=class{constructor(t){this.config=t}async getCollectionData(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Su({aptosConfig:this.config,...t})}async getCollectionId(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Wl({aptosConfig:this.config,...t})}async getDigitalAssetData(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Fl({aptosConfig:this.config,...t})}async getCurrentDigitalAssetOwnership(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),$l({aptosConfig:this.config,...t})}async getOwnedDigitalAssets(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Vl({aptosConfig:this.config,...t})}async getDigitalAssetActivity(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),jl({aptosConfig:this.config,...t})}async createCollectionTransaction(t){return Ql({aptosConfig:this.config,...t})}async mintDigitalAssetTransaction(t){return Yl({aptosConfig:this.config,...t})}async transferDigitalAssetTransaction(t){return Zl({aptosConfig:this.config,...t})}async mintSoulBoundTransaction(t){return Xl({aptosConfig:this.config,...t})}async burnDigitalAssetTransaction(t){return Jl({aptosConfig:this.config,...t})}async freezeDigitalAssetTransaferTransaction(t){return ep({aptosConfig:this.config,...t})}async unfreezeDigitalAssetTransaferTransaction(t){return tp({aptosConfig:this.config,...t})}async setDigitalAssetDescriptionTransaction(t){return rp({aptosConfig:this.config,...t})}async setDigitalAssetNameTransaction(t){return np({aptosConfig:this.config,...t})}async setDigitalAssetURITransaction(t){return op({aptosConfig:this.config,...t})}async addDigitalAssetPropertyTransaction(t){return sp({aptosConfig:this.config,...t})}async removeDigitalAssetPropertyTransaction(t){return ip({aptosConfig:this.config,...t})}async updateDigitalAssetPropertyTransaction(t){return ap({aptosConfig:this.config,...t})}async addDigitalAssetTypedPropertyTransaction(t){return cp({aptosConfig:this.config,...t})}async updateDigitalAssetTypedPropertyTransaction(t){return up({aptosConfig:this.config,...t})}};async function dp(r){let{accountAddress:t,aptosConfig:e,creationNumber:n}=r,s={account_address:{_eq:H.from(t).toStringLong()},creation_number:{_eq:n}};return ua({aptosConfig:e,options:{where:s}})}async function lp(r){let{accountAddress:t,aptosConfig:e,eventType:n,options:o}=r,c={where:{account_address:{_eq:H.from(t).toStringLong()},indexed_type:{_eq:n}},pagination:o,orderBy:o?.orderBy};return ua({aptosConfig:e,options:c})}async function ua(r){let{aptosConfig:t,options:e}=r,n={query:Sd,variables:{where_condition:e?.where,offset:e?.offset,limit:e?.limit,order_by:e?.orderBy}};return(await Ee({aptosConfig:t,query:n,originMethod:"getEvents"})).events}var Ss=class{constructor(t){this.config=t}async getAccountEventsByCreationNumber(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),dp({aptosConfig:this.config,...t})}async getAccountEventsByEventType(t){return await ze({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),lp({aptosConfig:this.config,...t})}async getEvents(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"events_processor"}),ua({aptosConfig:this.config,...t})}};async function pp(r){let{aptosConfig:t,accountAddress:e,amount:n,options:o}=r,s=o?.timeoutSecs||Fo,{data:i}=await Ga({aptosConfig:t,path:"fund",body:{address:H.from(e).toString(),amount:n},originMethod:"fundAccount"}),c=i.txn_hashes[0],f=await Ao({aptosConfig:t,transactionHash:c,options:{timeoutSecs:s,checkSuccess:o?.checkSuccess}});if(f.type==="user_transaction")return f;throw new Error(`Unexpected transaction received for fund account: ${f.type}`)}var Es=class{constructor(t){this.config=t}async fundAccount(t){let e=await pp({aptosConfig:this.config,...t});return t.options?.waitForIndexer!==!1&&await Ri({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version)}),e}};async function vu(r){let{aptosConfig:t,options:e}=r,n={query:vd,variables:{where_condition:e?.where,limit:e?.limit,offset:e?.offset}};return(await Ee({aptosConfig:t,query:n,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function gp(r){let{aptosConfig:t,options:e}=r,n={query:Ed,variables:{where_condition:e?.where,limit:e?.limit,offset:e?.offset}};return(await Ee({aptosConfig:t,query:n,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function mp(r){let{aptosConfig:t,options:e}=r,n={query:Td,variables:{where_condition:e?.where,limit:e?.limit,offset:e?.offset}};return(await Ee({aptosConfig:t,query:n,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}async function yp(r){let{aptosConfig:t,sender:e,fungibleAssetMetadataAddress:n,recipient:o,amount:s,options:i}=r;return await Pe({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[n,o,s]},options:i})}var vs=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),vu({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),(await vu({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetActivities(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),gp({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),mp({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return yp({aptosConfig:this.config,...t})}};var Cs=class{constructor(t){this.config=t}async getLedgerInfo(){return Si({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(t){return Id({aptosConfig:this.config,...t})}async getBlockByHeight(t){return Bd({aptosConfig:this.config,...t})}async getTableItem(t){return Ei({aptosConfig:this.config,...t})}async view(t){return cn({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return Pd({aptosConfig:this.config,...t})}async queryIndexer(t){return Ee({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return vi({aptosConfig:this.config})}async getProcessorStatus(t){return Ci({aptosConfig:this.config,processorType:t})}};var hp=["A name must be between 3 and 63 characters long,","and can only contain lowercase a-z, 0-9, and hyphens.","A name may not start or end with a hyphen."].join(" ");function Ap(r){return!(!r||r.length<3||r.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(r))}function yn(r){let[t,e,...n]=r.replace(/\.apt$/,"").split(".");if(n.length>0)throw new Error(`${r} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!Ap(t))throw new Error(`${t} is not valid. ${hp}`);if(e&&!Ap(e))throw new Error(`${e} is not valid. ${hp}`);return{domainName:e||t,subdomainName:e?t:void 0}}var Ch="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Uh={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Ch,custom:null,devnet:null};function Lr(r){let t=Uh[r.network];if(!t)throw new Error(`The ANS contract is not deployed to ${r.network}`);return t}var Ih=r=>({vec:[r]}),Bh=()=>({vec:[]}),Cu=r=>r!=null?Ih(r):Bh(),fa=r=>{if(r&&typeof r=="object"&&"vec"in r&&Array.isArray(r.vec))return r.vec[0]};async function xp(r){let{aptosConfig:t,name:e}=r,n=Lr(t),{domainName:o,subdomainName:s}=yn(e),i=await cn({aptosConfig:t,payload:{function:`${n}::router::get_owner_addr`,functionArguments:[o,Cu(s)]}}),c=fa(i[0]);return c?H.from(c).toString():void 0}async function bp(r){let{aptosConfig:t,expiration:e,name:n,sender:o,targetAddress:s,toAddress:i,options:c,transferable:f}=r,l=Lr(t),{domainName:h,subdomainName:m}=yn(n),T=e.policy==="subdomain:independent"||e.policy==="subdomain:follow-domain";if(m&&!T)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(T&&!m)throw new Error(`Policy is set to ${e.policy} but no subdomain was provided`);if(e.policy==="domain"){let w=e.years??1;if(w!==1)throw new Error("For now, names can only be registered for 1 year at a time");let k=w*31536e3;return await Pe({aptosConfig:t,sender:o.accountAddress.toString(),data:{function:`${l}::router::register_domain`,functionArguments:[h,k,s,i]},options:c})}if(!m)throw new Error(`${e.policy} requires a subdomain to be provided.`);let v=await Uu({aptosConfig:t,name:h});if(!v)throw new Error("The domain does not exist");let b=e.policy==="subdomain:independent"?e.expirationDate:v;if(b>v)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await Pe({aptosConfig:t,sender:o.accountAddress.toString(),data:{function:`${l}::router::register_subdomain`,functionArguments:[h,m,Math.round(b/1e3),e.policy==="subdomain:follow-domain"?1:0,!!f,s,i]},options:c})}async function Uu(r){let{aptosConfig:t,name:e}=r,n=Lr(t),{domainName:o,subdomainName:s}=yn(e);try{let i=await cn({aptosConfig:t,payload:{function:`${n}::router::get_expiration`,functionArguments:[o,Cu(s)]}});return Number(i[0])*1e3}catch{return}}async function wp(r){let{aptosConfig:t,address:e}=r,n=Lr(t),o=await cn({aptosConfig:t,payload:{function:`${n}::router::get_primary_name`,functionArguments:[H.from(e).toString()]}}),s=fa(o[1]),i=fa(o[0]);if(s)return[i,s].filter(Boolean).join(".")}async function Tp(r){let{aptosConfig:t,sender:e,name:n,options:o}=r,s=Lr(t);if(!n)return await Pe({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::clear_primary_name`,functionArguments:[]},options:o});let{domainName:i,subdomainName:c}=yn(n);return await Pe({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::set_primary_name`,functionArguments:[i,c]},options:o})}async function _p(r){let{aptosConfig:t,name:e}=r,n=Lr(t),{domainName:o,subdomainName:s}=yn(e),i=await cn({aptosConfig:t,payload:{function:`${n}::router::get_target_addr`,functionArguments:[o,Cu(s)]}}),c=fa(i[0]);return c?H.from(c).toString():void 0}async function Sp(r){let{aptosConfig:t,sender:e,name:n,address:o,options:s}=r,i=Lr(t),{domainName:c,subdomainName:f}=yn(n);return await Pe({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${i}::router::set_target_addr`,functionArguments:[c,f,o]},options:s})}async function Ep(r){let{aptosConfig:t,name:e}=r,{domainName:n,subdomainName:o=""}=yn(e),c=(await Ee({aptosConfig:t,query:{query:yo,variables:{where_condition:{domain:{_eq:n},subdomain:{_eq:o}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return c&&(c=Us(c)),c}async function vp(r){let{aptosConfig:t,options:e,accountAddress:n}=r,o=await Iu({aptosConfig:t});return(await Ee({aptosConfig:t,originMethod:"getAccountNames",query:{query:yo,variables:{limit:e?.limit,offset:e?.offset,order_by:e?.orderBy,where_condition:{...r.options?.where??{},owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:o}}}}})).current_aptos_names.map(Us)}async function Cp(r){let{aptosConfig:t,options:e,accountAddress:n}=r,o=await Iu({aptosConfig:t});return(await Ee({aptosConfig:t,originMethod:"getAccountDomains",query:{query:yo,variables:{limit:e?.limit,offset:e?.offset,order_by:e?.orderBy,where_condition:{...r.options?.where??{},owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""}}}}})).current_aptos_names.map(Us)}async function Up(r){let{aptosConfig:t,options:e,accountAddress:n}=r,o=await Iu({aptosConfig:t});return(await Ee({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:yo,variables:{limit:e?.limit,offset:e?.offset,order_by:e?.orderBy,where_condition:{...r.options?.where??{},owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:o},subdomain:{_neq:""}}}}})).current_aptos_names.map(Us)}async function Ip(r){let{aptosConfig:t,options:e,domain:n}=r;return(await Ee({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:yo,variables:{limit:e?.limit,offset:e?.offset,order_by:e?.orderBy,where_condition:{...r.options?.where??{},domain:{_eq:n},subdomain:{_neq:""}}}}})).current_aptos_names.map(Us)}async function Iu(r){let{aptosConfig:t}=r,e=Lr(t),[n]=await cn({aptosConfig:t,payload:{function:`${e}::config::reregistration_grace_sec`,functionArguments:[]}}),o=n/60/60/24,s=()=>new Date;return new Date(s().setDate(s().getDate()-o)).toISOString()}async function Bp(r){let{aptosConfig:t,sender:e,name:n,years:o=1,options:s}=r,i=Lr(t),c=o*31536e3,{domainName:f,subdomainName:l}=yn(n);if(l)throw new Error("Subdomains cannot be renewed");if(o!==1)throw new Error("Currently, only 1 year renewals are supported");return await Pe({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${i}::router::renew_domain`,functionArguments:[f,c]},options:s})}function Us(r){return{...r,expiration_timestamp:new Date(r.expiration_timestamp).valueOf()}}var Is=class{constructor(t){this.config=t}async getOwnerAddress(t){return xp({aptosConfig:this.config,...t})}async getExpiration(t){return Uu({aptosConfig:this.config,...t})}async getTargetAddress(t){return _p({aptosConfig:this.config,...t})}async setTargetAddress(t){return Sp({aptosConfig:this.config,...t})}async getPrimaryName(t){return wp({aptosConfig:this.config,...t})}async setPrimaryName(t){return Tp({aptosConfig:this.config,...t})}async registerName(t){return bp({aptosConfig:this.config,...t})}async renewDomain(t){return Bp({aptosConfig:this.config,...t})}async getName(t){return Ep({aptosConfig:this.config,...t})}async getAccountNames(t){return vp({aptosConfig:this.config,...t})}async getAccountDomains(t){return Cp({aptosConfig:this.config,...t})}async getAccountSubdomains(t){return Up({aptosConfig:this.config,...t})}async getDomainSubdomains(t){return Ip({aptosConfig:this.config,...t})}};async function Pp(r){let{aptosConfig:t,poolAddress:e}=r,n=H.from(e).toStringLong(),s=await Ee({aptosConfig:t,query:{query:zc,variables:{where_condition:{pool_address:{_eq:n}}}}});return s.num_active_delegator_per_pool[0]?s.num_active_delegator_per_pool[0].num_active_delegator:0}async function Rp(r){let{aptosConfig:t,options:e}=r,n={query:zc,variables:{order_by:e?.orderBy}};return(await Ee({aptosConfig:t,query:n})).num_active_delegator_per_pool}async function Op(r){let{aptosConfig:t,delegatorAddress:e,poolAddress:n}=r,o={query:_d,variables:{delegatorAddress:H.from(e).toStringLong(),poolAddress:H.from(n).toStringLong()}};return(await Ee({aptosConfig:t,query:o})).delegated_staking_activities}var Bs=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"stake_processor"}),Pp({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"stake_processor"}),Rp({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await ze({config:this.config,minimumLedgerVersion:t?.minimumLedgerVersion,processorType:"stake_processor"}),Op({aptosConfig:this.config,...t})}};var da=()=>Math.floor(Date.now()/1e3),Ps=class{constructor(t,e,n,o,s){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=e,this.maxWaitTime=n,this.maximumInFlight=o,this.sleepTime=s}async nextSequenceNumber(){for(;this.lock;)await un(this.sleepTime);this.lock=!0;let t=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let e=da();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await un(this.sleepTime),da()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}t=this.currentNumber,this.currentNumber+=BigInt(1)}catch(e){console.error("error in getting next sequence number for this account",e)}finally{this.lock=!1}return t}async initialize(){let{sequence_number:t}=await pr({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await pr({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(t),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await un(this.sleepTime);this.lock=!0;try{await this.update();let t=da();for(;this.lastUncommintedNumber!==this.currentNumber;)da()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await un(this.sleepTime),await this.update())}catch(t){console.error("error in synchronizing this account sequence number with the one on chain",t)}finally{this.lock=!1}}}};var Ro=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){this.pendingDequeue.shift()?.resolve(t);return}this.queue.push(t)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((t,e)=>{this.pendingDequeue.push({resolve:t,reject:e})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:t})=>{t(new Oo("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Oo=class extends Error{};var Np="fulfilled",Rs=class{constructor(t,e,n=30,o=100,s=10){this.taskQueue=new Ro;this.transactionsQueue=new Ro;this.outstandingTransactions=new Ro;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=e,this.started=!1,this.accountSequnceNumber=new Ps(t,e,n,o,s)}async submitNextTransaction(){try{for(;;){if(this.transactionsQueue.isEmpty())return;let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let e=await this.generateNextTransaction(this.account,t);if(!e)return;let n=ws({aptosConfig:this.aptosConfig,transaction:e,signer:this.account});await this.outstandingTransactions.enqueue([n,t])}}catch(t){if(t instanceof Oo)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],e=[],[n,o]=await this.outstandingTransactions.dequeue();for(t.push(n),e.push(o);!this.outstandingTransactions.isEmpty();)[n,o]=await this.outstandingTransactions.dequeue(),t.push(n),e.push(o);let s=await Promise.allSettled(t);for(let i=0;i<s.length&&i<e.length;i+=1){let c=s[i];o=e[i],c.status===Np?(this.sentTransactions.push([c.value.hash,o,null]),await this.checkTransaction(c,o)):this.sentTransactions.push([c.status,o,c.reason])}}}catch(t){if(t instanceof Oo)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,e){try{let n=[];n.push(Ao({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(n);for(let s=0;s<o.length;s+=1){let i=o[s];i.status===Np?this.executedTransactions.push([i.value.hash,e,null]):this.executedTransactions.push([i.status,e,i.reason])}}catch(n){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${n}`)}}async push(t,e){await this.transactionsQueue.enqueue([t,e])}async generateNextTransaction(t,e){if(this.transactionsQueue.isEmpty())return;let[n,o]=await this.transactionsQueue.dequeue();return await Pe({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:n,options:{...o,accountSequenceNumber:e}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var la=class{constructor(t){this.config=t}async simple(t){return Pe({aptosConfig:this.config,...t})}async multiAgent(t){return Pe({aptosConfig:this.config,...t})}};function Bu(r,t,e){let n=e.value;return e.value=async function(...o){let[s]=o;if(s.transaction.feePayerAddress&&!s.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return n.apply(this,o)},e}function Pu(r,t,e){let n=e.value;return e.value=async function(...o){let[s]=o;if(s.transaction.feePayerAddress&&!s.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return n.apply(this,o)},e}var No=class{constructor(t){this.config=t}async simple(t){return _u({aptosConfig:this.config,...t})}async multiAgent(t){return _u({aptosConfig:this.config,...t})}};Et([Pu],No.prototype,"simple",1),Et([Pu],No.prototype,"multiAgent",1);var ko=class{constructor(t){this.config=t}async simple(t){return ca({aptosConfig:this.config,...t})}async multiAgent(t){return ca({aptosConfig:this.config,...t})}};Et([Bu],ko.prototype,"simple",1),Et([Bu],ko.prototype,"multiAgent",1);var Os=class{constructor(t){this.config=t,this.build=new la(this.config),this.simulate=new No(this.config),this.submit=new ko(this.config)}async getTransactions(t){return Vd({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return jd({aptosConfig:this.config,...t})}async getTransactionByHash(t){return Pi({aptosConfig:this.config,...t})}async isPendingTransaction(t){return Qd({aptosConfig:this.config,...t})}async waitForTransaction(t){return Ao({aptosConfig:this.config,...t})}async getGasPriceEstimation(){return Bi({aptosConfig:this.config})}getSigningMessage(t){return Ll(t)}async publishPackageTransaction(t){return ql({aptosConfig:this.config,...t})}async rotateAuthKey(t){return Kl({aptosConfig:this.config,...t})}sign(t){return aa({...t})}signAsFeePayer(t){let{signer:e,transaction:n}=t;if(!n.feePayerAddress)throw new Error(`Transaction ${n} is not a Fee Payer transaction`);return n.feePayerAddress=e.accountAddress,aa({signer:e,transaction:n})}async batchTransactionsForSingleAccount(t){try{let{sender:e,data:n,options:o}=t,s=new Rs(this.config,e);s.start();for(let i of n)await s.push(i,o)}catch(e){throw new Error(`failed to submit transactions with error: ${e}`)}}async signAndSubmitTransaction(t){let{signer:e,transaction:n}=t;return ws({aptosConfig:this.config,signer:e,transaction:n})}};var Nt=class{constructor(t){this.config=new ds(t),this.account=new ts(this.config),this.ans=new Is(this.config),this.coin=new Ts(this.config),this.digitalAsset=new _s(this.config),this.event=new Ss(this.config),this.faucet=new Es(this.config),this.fungibleAsset=new vs(this.config),this.general=new Cs(this.config),this.staking=new Bs(this.config),this.transaction=new Os(this.config)}};function br(r,t,e){Object.getOwnPropertyNames(t.prototype).forEach(n=>{let o=Object.getOwnPropertyDescriptor(t.prototype,n);o&&(o.value=function(...s){return this[e][n](...s)},Object.defineProperty(r.prototype,n,o))})}br(Nt,ts,"account");br(Nt,Is,"ans");br(Nt,Ts,"coin");br(Nt,_s,"digitalAsset");br(Nt,Ss,"event");br(Nt,Es,"faucet");br(Nt,vs,"fungibleAsset");br(Nt,Cs,"general");br(Nt,Bs,"staking");br(Nt,Os,"transaction");return Fp(Ph);})();
431
431
  /*! Bundled license information:
432
432
 
433
433
  @noble/hashes/esm/utils.js: