@aptos-labs/ts-sdk 1.22.1 → 1.22.2

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 (231) hide show
  1. package/dist/common/cli/index.d.ts +21 -7
  2. package/dist/common/cli/index.js +1 -1
  3. package/dist/common/cli/index.js.map +1 -1
  4. package/dist/common/index.d.ts +30 -1
  5. package/dist/common/index.js +24 -24
  6. package/dist/common/index.js.map +1 -1
  7. package/dist/esm/account/Account.mjs +1 -1
  8. package/dist/esm/account/Ed25519Account.mjs +1 -1
  9. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  10. package/dist/esm/account/KeylessAccount.mjs +1 -1
  11. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  12. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  13. package/dist/esm/account/index.mjs +1 -1
  14. package/dist/esm/api/account.mjs +1 -1
  15. package/dist/esm/api/ans.mjs +1 -1
  16. package/dist/esm/api/aptos.mjs +1 -1
  17. package/dist/esm/api/coin.mjs +1 -1
  18. package/dist/esm/api/digitalAsset.mjs +1 -1
  19. package/dist/esm/api/event.mjs +1 -1
  20. package/dist/esm/api/faucet.mjs +1 -1
  21. package/dist/esm/api/fungibleAsset.mjs +1 -1
  22. package/dist/esm/api/general.mjs +1 -1
  23. package/dist/esm/api/index.mjs +1 -1
  24. package/dist/esm/api/keyless.mjs +1 -1
  25. package/dist/esm/api/object.mjs +1 -1
  26. package/dist/esm/api/staking.mjs +1 -1
  27. package/dist/esm/api/table.mjs +1 -1
  28. package/dist/esm/api/transaction.mjs +1 -1
  29. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  30. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  31. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  32. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  33. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  34. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  35. package/dist/esm/api/utils.mjs +1 -1
  36. package/dist/esm/bcs/index.mjs +1 -1
  37. package/dist/esm/{chunk-Z4CGG42L.mjs → chunk-2ZAYK464.mjs} +2 -2
  38. package/dist/esm/{chunk-KDIPFPMS.mjs → chunk-37Y7VAN7.mjs} +2 -2
  39. package/dist/esm/{chunk-V5COHBA4.mjs → chunk-42XNGDUC.mjs} +2 -2
  40. package/dist/esm/{chunk-7WFKAS7T.mjs → chunk-4EPLOSKY.mjs} +2 -2
  41. package/dist/esm/{chunk-NAGFCYG6.mjs → chunk-4ZXCQXVC.mjs} +2 -2
  42. package/dist/esm/{chunk-LTMOMXPN.mjs → chunk-5E672SHG.mjs} +2 -2
  43. package/dist/esm/{chunk-IPGKZUSA.mjs → chunk-5IRM54PL.mjs} +2 -2
  44. package/dist/esm/{chunk-SK2HTEP7.mjs → chunk-6AJLTBXC.mjs} +2 -2
  45. package/dist/esm/{chunk-OVG4SGPI.mjs → chunk-6TWRNWC3.mjs} +2 -2
  46. package/dist/esm/{chunk-Y2H7FG2P.mjs → chunk-6XCZ56O7.mjs} +2 -2
  47. package/dist/esm/{chunk-XWVMFCW3.mjs → chunk-6ZQWPHLV.mjs} +2 -2
  48. package/dist/esm/{chunk-XVWNPR4T.mjs → chunk-7LY73OAN.mjs} +2 -2
  49. package/dist/esm/{chunk-F6REP536.mjs → chunk-A2Z7I2EY.mjs} +2 -2
  50. package/dist/esm/chunk-B6PLCJJ2.mjs +2 -0
  51. package/dist/esm/chunk-B6PLCJJ2.mjs.map +1 -0
  52. package/dist/esm/{chunk-3NPBKAPF.mjs → chunk-BF3D6ADE.mjs} +2 -2
  53. package/dist/esm/{chunk-J5YHMYHB.mjs → chunk-BN2PXCFR.mjs} +2 -2
  54. package/dist/esm/{chunk-H6CS3BD7.mjs → chunk-D6WTINSF.mjs} +2 -2
  55. package/dist/esm/{chunk-JB5R6RGF.mjs → chunk-DM6HVA4K.mjs} +2 -2
  56. package/dist/esm/chunk-E7FWVXGX.mjs +1 -0
  57. package/dist/esm/{chunk-43IKKJ2Y.mjs → chunk-EIKBYKIJ.mjs} +2 -2
  58. package/dist/esm/{chunk-H6QWMF3Q.mjs → chunk-EKZHYOQH.mjs} +2 -2
  59. package/dist/esm/{chunk-TCEOTADF.mjs → chunk-EOJWPF3P.mjs} +2 -2
  60. package/dist/esm/{chunk-GWH34VNI.mjs → chunk-EPVAT625.mjs} +2 -2
  61. package/dist/esm/{chunk-J5KAD2RM.mjs → chunk-FC7IRFFN.mjs} +2 -2
  62. package/dist/esm/{chunk-L6RINMT6.mjs → chunk-FEGCUPGO.mjs} +2 -2
  63. package/dist/esm/{chunk-PY23BQ2H.mjs → chunk-FPDE5EYE.mjs} +2 -2
  64. package/dist/esm/{chunk-3DCHEXE3.mjs → chunk-GEP4HPQ6.mjs} +2 -2
  65. package/dist/esm/{chunk-TWRYY6DD.mjs → chunk-GGU4XOUO.mjs} +2 -2
  66. package/dist/esm/{chunk-SQQ2424E.mjs → chunk-H4XMI4WZ.mjs} +2 -2
  67. package/dist/esm/{chunk-4ARX2MGY.mjs → chunk-HFOLSSAQ.mjs} +2 -2
  68. package/dist/esm/{chunk-6TRGVQLA.mjs → chunk-IMF5XUVW.mjs} +2 -2
  69. package/dist/esm/{chunk-7CMCN6LB.mjs → chunk-JY5LTRTM.mjs} +2 -2
  70. package/dist/esm/{chunk-T7YRD4PM.mjs → chunk-K7Y2SC65.mjs} +2 -2
  71. package/dist/esm/{chunk-TZOKV22Z.mjs → chunk-MI732NUU.mjs} +2 -2
  72. package/dist/esm/{chunk-UJYWEIQ2.mjs → chunk-NBJFTE2P.mjs} +2 -2
  73. package/dist/esm/chunk-NECL5FCQ.mjs +1 -0
  74. package/dist/esm/chunk-NECL5FCQ.mjs.map +1 -0
  75. package/dist/esm/{chunk-LBU3LV7I.mjs → chunk-NRAQZUD5.mjs} +2 -2
  76. package/dist/esm/{chunk-7X6HZUXX.mjs → chunk-O4O7HSUQ.mjs} +2 -2
  77. package/dist/esm/{chunk-4GNJJZ4R.mjs → chunk-OAKHR7AG.mjs} +2 -2
  78. package/dist/esm/{chunk-VN2CRWOI.mjs → chunk-OTK3HBAU.mjs} +2 -2
  79. package/dist/esm/{chunk-ZL4JYTID.mjs → chunk-OYLT6IVC.mjs} +2 -2
  80. package/dist/esm/chunk-QA7VTFUT.mjs +2 -0
  81. package/dist/esm/{chunk-4KYQ7N3N.mjs.map → chunk-QA7VTFUT.mjs.map} +1 -1
  82. package/dist/esm/{chunk-463B3NF7.mjs → chunk-RFMLKHUD.mjs} +2 -2
  83. package/dist/esm/{chunk-T4NXIMZL.mjs → chunk-RS2FIBMQ.mjs} +2 -2
  84. package/dist/esm/{chunk-VQPLSJEI.mjs → chunk-U2QQD2ER.mjs} +2 -2
  85. package/dist/esm/{chunk-67BD7B6N.mjs → chunk-U6X2FYNI.mjs} +2 -2
  86. package/dist/esm/{chunk-NLJVP5RP.mjs → chunk-U7I7YKWD.mjs} +2 -2
  87. package/dist/esm/{chunk-IPTCWBFV.mjs → chunk-UIJK42CX.mjs} +2 -2
  88. package/dist/esm/{chunk-LBKYNX5K.mjs → chunk-VBPDZZXC.mjs} +2 -2
  89. package/dist/esm/{chunk-S6H5Q2IK.mjs → chunk-W5ZII3JO.mjs} +2 -2
  90. package/dist/esm/{chunk-7HS4UJGE.mjs → chunk-WL4FXFAM.mjs} +2 -2
  91. package/dist/esm/{chunk-O7XEE7QT.mjs → chunk-WTJCMD4D.mjs} +2 -2
  92. package/dist/esm/{chunk-S7G6VBUB.mjs → chunk-XBTCOCZJ.mjs} +2 -2
  93. package/dist/esm/{chunk-W26LO3CR.mjs → chunk-XCNNMSVO.mjs} +2 -2
  94. package/dist/esm/{chunk-I2T6BJOA.mjs → chunk-XFBB7YYI.mjs} +2 -2
  95. package/dist/esm/{chunk-IN2L5ZAT.mjs → chunk-XT2VVDT3.mjs} +2 -2
  96. package/dist/esm/{chunk-7RVYF5OP.mjs → chunk-XWAOZPIP.mjs} +2 -2
  97. package/dist/esm/{chunk-P43CXEO4.mjs → chunk-XYWMFCL6.mjs} +2 -2
  98. package/dist/esm/{chunk-CUSKA6RZ.mjs → chunk-Y2DHN4CV.mjs} +2 -2
  99. package/dist/esm/chunk-Y5VJSCVY.mjs +2 -0
  100. package/dist/esm/chunk-Y5VJSCVY.mjs.map +1 -0
  101. package/dist/esm/{chunk-VEGT6ZPK.mjs → chunk-Z4OZBMSL.mjs} +2 -2
  102. package/dist/esm/cli/index.mjs +1 -1
  103. package/dist/esm/cli/move.d.mts +21 -7
  104. package/dist/esm/cli/move.mjs +1 -1
  105. package/dist/esm/client/core.mjs +1 -1
  106. package/dist/esm/client/get.mjs +1 -1
  107. package/dist/esm/client/index.mjs +1 -1
  108. package/dist/esm/client/post.mjs +1 -1
  109. package/dist/esm/core/account/index.mjs +1 -1
  110. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  111. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  112. package/dist/esm/core/crypto/index.d.mts +3 -3
  113. package/dist/esm/core/crypto/index.mjs +1 -1
  114. package/dist/esm/core/crypto/keyless.mjs +1 -1
  115. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  116. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  117. package/dist/esm/core/crypto/proof.mjs +1 -1
  118. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  119. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  120. package/dist/esm/core/crypto/signature.mjs +1 -1
  121. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  122. package/dist/esm/core/index.d.mts +1 -0
  123. package/dist/esm/core/index.mjs +1 -1
  124. package/dist/esm/index.d.mts +1 -0
  125. package/dist/esm/index.mjs +1 -1
  126. package/dist/esm/internal/account.mjs +1 -1
  127. package/dist/esm/internal/ans.mjs +1 -1
  128. package/dist/esm/internal/coin.mjs +1 -1
  129. package/dist/esm/internal/digitalAsset.mjs +1 -1
  130. package/dist/esm/internal/event.mjs +1 -1
  131. package/dist/esm/internal/faucet.mjs +1 -1
  132. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  133. package/dist/esm/internal/general.mjs +1 -1
  134. package/dist/esm/internal/keyless.mjs +1 -1
  135. package/dist/esm/internal/object.mjs +1 -1
  136. package/dist/esm/internal/staking.mjs +1 -1
  137. package/dist/esm/internal/table.mjs +1 -1
  138. package/dist/esm/internal/transaction.mjs +1 -1
  139. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  140. package/dist/esm/internal/view.mjs +1 -1
  141. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  142. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  143. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  144. package/dist/esm/transactions/index.mjs +1 -1
  145. package/dist/esm/transactions/instances/index.mjs +1 -1
  146. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  147. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  148. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  149. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  150. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  151. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  152. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  153. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  154. package/dist/esm/transactions/management/index.mjs +1 -1
  155. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  156. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  157. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  158. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  159. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  160. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  161. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  162. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  163. package/dist/esm/utils/index.mjs +1 -1
  164. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  165. package/dist/esm/version.d.mts +1 -1
  166. package/dist/esm/version.mjs +1 -1
  167. package/package.json +1 -1
  168. package/src/version.ts +1 -1
  169. package/dist/esm/chunk-4KYQ7N3N.mjs +0 -2
  170. package/dist/esm/chunk-5M235PLS.mjs +0 -2
  171. package/dist/esm/chunk-5M235PLS.mjs.map +0 -1
  172. package/dist/esm/chunk-Q7ZP25NJ.mjs +0 -2
  173. package/dist/esm/chunk-Q7ZP25NJ.mjs.map +0 -1
  174. package/dist/esm/chunk-RFSO3JRG.mjs +0 -1
  175. /package/dist/esm/{chunk-Z4CGG42L.mjs.map → chunk-2ZAYK464.mjs.map} +0 -0
  176. /package/dist/esm/{chunk-KDIPFPMS.mjs.map → chunk-37Y7VAN7.mjs.map} +0 -0
  177. /package/dist/esm/{chunk-V5COHBA4.mjs.map → chunk-42XNGDUC.mjs.map} +0 -0
  178. /package/dist/esm/{chunk-7WFKAS7T.mjs.map → chunk-4EPLOSKY.mjs.map} +0 -0
  179. /package/dist/esm/{chunk-NAGFCYG6.mjs.map → chunk-4ZXCQXVC.mjs.map} +0 -0
  180. /package/dist/esm/{chunk-LTMOMXPN.mjs.map → chunk-5E672SHG.mjs.map} +0 -0
  181. /package/dist/esm/{chunk-IPGKZUSA.mjs.map → chunk-5IRM54PL.mjs.map} +0 -0
  182. /package/dist/esm/{chunk-SK2HTEP7.mjs.map → chunk-6AJLTBXC.mjs.map} +0 -0
  183. /package/dist/esm/{chunk-OVG4SGPI.mjs.map → chunk-6TWRNWC3.mjs.map} +0 -0
  184. /package/dist/esm/{chunk-Y2H7FG2P.mjs.map → chunk-6XCZ56O7.mjs.map} +0 -0
  185. /package/dist/esm/{chunk-XWVMFCW3.mjs.map → chunk-6ZQWPHLV.mjs.map} +0 -0
  186. /package/dist/esm/{chunk-XVWNPR4T.mjs.map → chunk-7LY73OAN.mjs.map} +0 -0
  187. /package/dist/esm/{chunk-F6REP536.mjs.map → chunk-A2Z7I2EY.mjs.map} +0 -0
  188. /package/dist/esm/{chunk-3NPBKAPF.mjs.map → chunk-BF3D6ADE.mjs.map} +0 -0
  189. /package/dist/esm/{chunk-J5YHMYHB.mjs.map → chunk-BN2PXCFR.mjs.map} +0 -0
  190. /package/dist/esm/{chunk-H6CS3BD7.mjs.map → chunk-D6WTINSF.mjs.map} +0 -0
  191. /package/dist/esm/{chunk-JB5R6RGF.mjs.map → chunk-DM6HVA4K.mjs.map} +0 -0
  192. /package/dist/esm/{chunk-RFSO3JRG.mjs.map → chunk-E7FWVXGX.mjs.map} +0 -0
  193. /package/dist/esm/{chunk-43IKKJ2Y.mjs.map → chunk-EIKBYKIJ.mjs.map} +0 -0
  194. /package/dist/esm/{chunk-H6QWMF3Q.mjs.map → chunk-EKZHYOQH.mjs.map} +0 -0
  195. /package/dist/esm/{chunk-TCEOTADF.mjs.map → chunk-EOJWPF3P.mjs.map} +0 -0
  196. /package/dist/esm/{chunk-GWH34VNI.mjs.map → chunk-EPVAT625.mjs.map} +0 -0
  197. /package/dist/esm/{chunk-J5KAD2RM.mjs.map → chunk-FC7IRFFN.mjs.map} +0 -0
  198. /package/dist/esm/{chunk-L6RINMT6.mjs.map → chunk-FEGCUPGO.mjs.map} +0 -0
  199. /package/dist/esm/{chunk-PY23BQ2H.mjs.map → chunk-FPDE5EYE.mjs.map} +0 -0
  200. /package/dist/esm/{chunk-3DCHEXE3.mjs.map → chunk-GEP4HPQ6.mjs.map} +0 -0
  201. /package/dist/esm/{chunk-TWRYY6DD.mjs.map → chunk-GGU4XOUO.mjs.map} +0 -0
  202. /package/dist/esm/{chunk-SQQ2424E.mjs.map → chunk-H4XMI4WZ.mjs.map} +0 -0
  203. /package/dist/esm/{chunk-4ARX2MGY.mjs.map → chunk-HFOLSSAQ.mjs.map} +0 -0
  204. /package/dist/esm/{chunk-6TRGVQLA.mjs.map → chunk-IMF5XUVW.mjs.map} +0 -0
  205. /package/dist/esm/{chunk-7CMCN6LB.mjs.map → chunk-JY5LTRTM.mjs.map} +0 -0
  206. /package/dist/esm/{chunk-T7YRD4PM.mjs.map → chunk-K7Y2SC65.mjs.map} +0 -0
  207. /package/dist/esm/{chunk-TZOKV22Z.mjs.map → chunk-MI732NUU.mjs.map} +0 -0
  208. /package/dist/esm/{chunk-UJYWEIQ2.mjs.map → chunk-NBJFTE2P.mjs.map} +0 -0
  209. /package/dist/esm/{chunk-LBU3LV7I.mjs.map → chunk-NRAQZUD5.mjs.map} +0 -0
  210. /package/dist/esm/{chunk-7X6HZUXX.mjs.map → chunk-O4O7HSUQ.mjs.map} +0 -0
  211. /package/dist/esm/{chunk-4GNJJZ4R.mjs.map → chunk-OAKHR7AG.mjs.map} +0 -0
  212. /package/dist/esm/{chunk-VN2CRWOI.mjs.map → chunk-OTK3HBAU.mjs.map} +0 -0
  213. /package/dist/esm/{chunk-ZL4JYTID.mjs.map → chunk-OYLT6IVC.mjs.map} +0 -0
  214. /package/dist/esm/{chunk-463B3NF7.mjs.map → chunk-RFMLKHUD.mjs.map} +0 -0
  215. /package/dist/esm/{chunk-T4NXIMZL.mjs.map → chunk-RS2FIBMQ.mjs.map} +0 -0
  216. /package/dist/esm/{chunk-VQPLSJEI.mjs.map → chunk-U2QQD2ER.mjs.map} +0 -0
  217. /package/dist/esm/{chunk-67BD7B6N.mjs.map → chunk-U6X2FYNI.mjs.map} +0 -0
  218. /package/dist/esm/{chunk-NLJVP5RP.mjs.map → chunk-U7I7YKWD.mjs.map} +0 -0
  219. /package/dist/esm/{chunk-IPTCWBFV.mjs.map → chunk-UIJK42CX.mjs.map} +0 -0
  220. /package/dist/esm/{chunk-LBKYNX5K.mjs.map → chunk-VBPDZZXC.mjs.map} +0 -0
  221. /package/dist/esm/{chunk-S6H5Q2IK.mjs.map → chunk-W5ZII3JO.mjs.map} +0 -0
  222. /package/dist/esm/{chunk-7HS4UJGE.mjs.map → chunk-WL4FXFAM.mjs.map} +0 -0
  223. /package/dist/esm/{chunk-O7XEE7QT.mjs.map → chunk-WTJCMD4D.mjs.map} +0 -0
  224. /package/dist/esm/{chunk-S7G6VBUB.mjs.map → chunk-XBTCOCZJ.mjs.map} +0 -0
  225. /package/dist/esm/{chunk-W26LO3CR.mjs.map → chunk-XCNNMSVO.mjs.map} +0 -0
  226. /package/dist/esm/{chunk-I2T6BJOA.mjs.map → chunk-XFBB7YYI.mjs.map} +0 -0
  227. /package/dist/esm/{chunk-IN2L5ZAT.mjs.map → chunk-XT2VVDT3.mjs.map} +0 -0
  228. /package/dist/esm/{chunk-7RVYF5OP.mjs.map → chunk-XWAOZPIP.mjs.map} +0 -0
  229. /package/dist/esm/{chunk-P43CXEO4.mjs.map → chunk-XYWMFCL6.mjs.map} +0 -0
  230. /package/dist/esm/{chunk-CUSKA6RZ.mjs.map → chunk-Y2DHN4CV.mjs.map} +0 -0
  231. /package/dist/esm/{chunk-VEGT6ZPK.mjs.map → chunk-Z4OZBMSL.mjs.map} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunkBHKSQXUZjs = require('./chunk-BHKSQXUZ.js');var xn=255,_n=65535,ve=4294967295,Xe=18446744073709551615n,qt=340282366920938463463374607431768211455n,vn=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var oe=class{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeBool()?this.deserializeStr():void 0}deserializeOption(e){return this.deserializeBool()?this.deserialize(e):void 0}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===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 e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<ve;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),!(r&128))break;t+=7}if(e>ve)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),r=new Array;for(let o=0;o<t;o+=1)r.push(this.deserialize(e));return r}};var _utils = require('@noble/hashes/utils');var Y=class extends Error{constructor(e,t){super(e),this.invalidReason=t}};var ta=(r=>(r.TOO_SHORT="too_short",r.INVALID_LENGTH="invalid_length",r.INVALID_HEX_CHARS="invalid_hex_chars",r))(ta||{}),l= exports.Hex =class n{constructor(e){this.data=e}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(e){let t=e;if(t.startsWith("0x")&&(t=t.slice(2)),t.length===0)throw new Y("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(t.length%2!==0)throw new Y("Hex string must be an even number of hex characters.","invalid_length");try{return new n(_utils.hexToBytes.call(void 0, t))}catch(r){throw new Y(`Hex string contains invalid hex characters: ${_optionalChain([r, 'optionalAccess', _2 => _2.message])}`,"invalid_hex_chars")}}static fromHexInput(e){return e instanceof Uint8Array?new n(e):n.fromHexString(e)}static isValid(e){try{return n.fromHexString(e),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _3 => _3.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _4 => _4.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,r)=>t===e.data[r])}};var d=class{bcsToBytes(){let e=new Z;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return l.fromHexInput(e)}},Z= exports.Serializer =class{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.offset=0}ensureBufferWillHandleSize(e){for(;this.buffer.byteLength<this.offset+e;){let t=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t}}appendToBuffer(e){this.ensureBufferWillHandleSize(e.length),new Uint8Array(this.buffer,this.offset).set(e),this.offset+=e.length}serializeWithFunction(e,t,r){this.ensureBufferWillHandleSize(t);let o=new DataView(this.buffer,this.offset);e.apply(o,[0,r,!0]),this.offset+=t}serializeStr(e){let t=new TextEncoder;this.serializeBytes(t.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){fr(e);let t=e?1:0;this.appendToBuffer(new Uint8Array([t]))}serializeU8(e){this.appendToBuffer(new Uint8Array([e]))}serializeU16(e){this.serializeWithFunction(DataView.prototype.setUint16,2,e)}serializeU32(e){this.serializeWithFunction(DataView.prototype.setUint32,4,e)}serializeU64(e){let t=BigInt(e)&BigInt(ve),r=BigInt(e)>>BigInt(32);this.serializeU32(Number(t)),this.serializeU32(Number(r))}serializeU128(e){let t=BigInt(e)&Xe,r=BigInt(e)>>BigInt(64);this.serializeU64(t),this.serializeU64(r)}serializeU256(e){let t=BigInt(e)&qt,r=BigInt(e)>>BigInt(128);this.serializeU128(t),this.serializeU128(r)}serializeU32AsUleb128(e){let t=e,r=[];for(;t>>>7;)r.push(t&127|128),t>>>=7;r.push(t),this.appendToBuffer(new Uint8Array(r))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(e){e.serialize(this)}serializeVector(e){this.serializeU32AsUleb128(e.length),e.forEach(t=>{t.serialize(this)})}serializeOption(e){let t=e!==void 0;this.serializeBool(t),t&&e.serialize(this)}serializeOptionStr(e){e===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(e))}};_chunkBHKSQXUZjs.a.call(void 0, [Ye(0,xn)],Z.prototype,"serializeU8",1),_chunkBHKSQXUZjs.a.call(void 0, [Ye(0,_n)],Z.prototype,"serializeU16",1),_chunkBHKSQXUZjs.a.call(void 0, [Ye(0,ve)],Z.prototype,"serializeU32",1),_chunkBHKSQXUZjs.a.call(void 0, [Ye(BigInt(0),Xe)],Z.prototype,"serializeU64",1),_chunkBHKSQXUZjs.a.call(void 0, [Ye(BigInt(0),qt)],Z.prototype,"serializeU128",1),_chunkBHKSQXUZjs.a.call(void 0, [Ye(BigInt(0),vn)],Z.prototype,"serializeU256",1),_chunkBHKSQXUZjs.a.call(void 0, [Ye(0,ve)],Z.prototype,"serializeU32AsUleb128",1);function fr(n){if(typeof n!="boolean")throw new Error(`${n} is not a boolean value`)}var na=(n,e,t)=>`${n} is out of range: [${e}, ${t}]`;function Ge(n,e,t){let r=BigInt(n);if(r>BigInt(t)||r<BigInt(e))throw new Error(na(n,e,t))}function Ye(n,e){return(t,r,o)=>{let i=o.value;return o.value=function(a){return Ge(a,n,e),i.apply(this,[a])},o}}var Ze=class n extends d{constructor(e){super(),this.value=l.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let r=e.deserializeFixedBytes(t);return new n(r)}};var Pn=class n extends d{constructor(e){super(),this.value=new Ze(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=Ze.deserialize(e,t);return new n(r.value)}};var Cn=(o=>(o.JSON="application/json",o.BCS="application/x-bcs",o.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",o.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",o))(Cn||{}),go= exports.TypeTagVariants =(g=>(g[g.Bool=0]="Bool",g[g.U8=1]="U8",g[g.U64=2]="U64",g[g.U128=3]="U128",g[g.Address=4]="Address",g[g.Signer=5]="Signer",g[g.Vector=6]="Vector",g[g.Struct=7]="Struct",g[g.U16=8]="U16",g[g.U32=9]="U32",g[g.U256=10]="U256",g[g.Reference=254]="Reference",g[g.Generic=255]="Generic",g))(go||{}),Vt= exports.ScriptTransactionArgumentVariants =(p=>(p[p.U8=0]="U8",p[p.U64=1]="U64",p[p.U128=2]="U128",p[p.Address=3]="Address",p[p.U8Vector=4]="U8Vector",p[p.Bool=5]="Bool",p[p.U16=6]="U16",p[p.U32=7]="U32",p[p.U256=8]="U256",p))(Vt||{}),mo= exports.TransactionPayloadVariants =(r=>(r[r.Script=0]="Script",r[r.EntryFunction=2]="EntryFunction",r[r.Multisig=3]="Multisig",r))(mo||{}),yo= exports.TransactionVariants =(t=>(t[t.MultiAgentTransaction=0]="MultiAgentTransaction",t[t.FeePayerTransaction=1]="FeePayerTransaction",t))(yo||{}),fo= exports.TransactionAuthenticatorVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.MultiAgent=2]="MultiAgent",i[i.FeePayer=3]="FeePayer",i[i.SingleSender=4]="SingleSender",i))(fo||{}),Ao= exports.AccountAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Ao||{}),Ar= exports.AnyPublicKeyVariant =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1=1]="Secp256k1",r[r.Keyless=3]="Keyless",r))(Ar||{}),ho= exports.AnySignatureVariant =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1=1]="Secp256k1",r[r.Keyless=3]="Keyless",r))(ho||{}),hr= exports.EphemeralPublicKeyVariant =(e=>(e[e.Ed25519=0]="Ed25519",e))(hr||{}),To= exports.EphemeralSignatureVariant =(e=>(e[e.Ed25519=0]="Ed25519",e))(To||{}),Tr= exports.EphemeralCertificateVariant =(e=>(e[e.ZkProof=0]="ZkProof",e))(Tr||{}),br= exports.ZkpVariant =(e=>(e[e.Groth16=0]="Groth16",e))(br||{}),wr= exports.TransactionResponseType =(s=>(s.Pending="pending_transaction",s.User="user_transaction",s.Genesis="genesis_transaction",s.BlockMetadata="block_metadata_transaction",s.StateCheckpoint="state_checkpoint_transaction",s.Validator="validator_transaction",s))(wr||{});function fu(n){return n.type==="pending_transaction"}function Au(n){return n.type==="user_transaction"}function hu(n){return n.type==="genesis_transaction"}function Tu(n){return n.type==="block_metadata_transaction"}function bu(n){return n.type==="state_checkpoint_transaction"}function wu(n){return n.type==="validator_transaction"}function Su(n){return"signature"in n&&n.signature==="ed25519_signature"}function xu(n){return"signature"in n&&n.signature==="secp256k1_ecdsa_signature"}function _u(n){return n.type==="multi_agent_signature"}function vu(n){return n.type==="fee_payer_signature"}function Pu(n){return n.type==="multi_ed25519_signature"}var ra=(r=>(r.PRIVATE="private",r.PUBLIC="public",r.FRIEND="friend",r))(ra||{}),bo= exports.MoveAbility =(o=>(o.STORE="store",o.DROP="drop",o.KEY="key",o.COPY="copy",o))(bo||{}),oa= exports.RoleType =(t=>(t.VALIDATOR="validator",t.FULL_NODE="full_node",t))(oa||{}),Ae= exports.SigningScheme =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Ae||{}),Sr= exports.SigningSchemeInput =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",t))(Sr||{}),ia= exports.DeriveScheme =(i=>(i[i.DeriveAuid=251]="DeriveAuid",i[i.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",i[i.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",i[i.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",i[i.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",i))(ia||{});var I=class n extends d{constructor(e){super(),fr(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}static deserialize(e){return new n(e.deserializeBool())}},F= exports.U8 =class n extends d{constructor(e){super(),Ge(e,0,xn),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},de= exports.U16 =class n extends d{constructor(e){super(),Ge(e,0,_n),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},le= exports.U32 =class n extends d{constructor(e){super(),Ge(e,0,ve),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},O= exports.U64 =class n extends d{constructor(e){super(),Ge(e,BigInt(0),Xe),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},ge= exports.U128 =class n extends d{constructor(e){super(),Ge(e,BigInt(0),qt),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},me= exports.U256 =class n extends d{constructor(e){super(),Ge(e,BigInt(0),vn),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var T=class n extends d{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(!(this.values[0]instanceof F)&&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 t;if(Array.isArray(e)&&e.length===0)t=[];else if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let r=l.fromHexInput(e);t=Array.from(r.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new n(t.map(r=>new F(r)))}static U16(e){return new n(e.map(t=>new de(t)))}static U32(e){return new n(e.map(t=>new le(t)))}static U64(e){return new n(e.map(t=>new O(t)))}static U128(e){return new n(e.map(t=>new ge(t)))}static U256(e){return new n(e.map(t=>new me(t)))}static Bool(e){return new n(e.map(t=>new I(t)))}static MoveString(e){return new n(e.map(t=>new b(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let r=e.deserializeUleb128AsU32(),o=new Array;for(let i=0;i<r;i+=1)o.push(t.deserialize(e));return new n(o)}},b= exports.MoveString =class n extends d{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let t=this.bcsToBytes().slice(1);T.U8(t).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},M= exports.MoveOption =class n extends d{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new T([e]):this.vec=new T([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}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 n(e!=null?new F(e):void 0)}static U16(e){return new n(e!=null?new de(e):void 0)}static U32(e){return new n(e!=null?new le(e):void 0)}static U64(e){return new n(e!=null?new O(e):void 0)}static U128(e){return new n(e!=null?new ge(e):void 0)}static U256(e){return new n(e!=null?new me(e):void 0)}static Bool(e){return new n(e!=null?new I(e):void 0)}static MoveString(e){return new n(e!=null?new b(e):void 0)}static deserialize(e,t){let r=T.deserialize(e,t);return new n(r.values[0])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var aa=(a=>(a.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",a.INVALID_HEX_CHARS="invalid_hex_chars",a.TOO_SHORT="too_short",a.TOO_LONG="too_long",a.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",a.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",a.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",a))(aa||{}),x=class x extends d{constructor(e){if(super(),e.length!==x.LENGTH)throw new Y("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=_utils.bytesToHex.call(void 0, this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let t=e.deserializeFixedBytes(x.LENGTH);return new x(t)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new Y("Hex string must start with a leading 0x.","leading_zero_x_required");let t=x.fromString(e);if(e.length!==x.LONG_STRING_LENGTH+2)if(t.isSpecial()){if(e.length!==3)throw new Y(`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 Y(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return t}static fromString(e){let t=e;if(e.startsWith("0x")&&(t=e.slice(2)),t.length===0)throw new Y("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(t.length>64)throw new Y("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let r;try{r=_utils.hexToBytes.call(void 0, t.padStart(64,"0"))}catch(o){throw new Y(`Hex characters are invalid: ${_optionalChain([o, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}return new x(r)}static from(e){return e instanceof x?e:e instanceof Uint8Array?new x(e):x.fromString(e)}static fromStrict(e){return e instanceof x?e:e instanceof Uint8Array?new x(e):x.fromStringStrict(e)}static isValid(e){try{return e.strict?x.fromStrict(e.input):x.from(e.input),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _6 => _6.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _7 => _7.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,r)=>t===e.data[r])}};x.LENGTH=32,x.LONG_STRING_LENGTH=64,x.ZERO=x.from("0x0"),x.ONE=x.from("0x1"),x.TWO=x.from("0x2"),x.THREE=x.from("0x3"),x.FOUR=x.from("0x4");var u=x;var Be=class Be extends d{constructor(e){super();let{data:t}=e,r=l.fromHexInput(t);if(r.toUint8Array().length!==Be.LENGTH)throw new Error(`Authentication Key length should be ${Be.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(Be.LENGTH);return new Be({data:t})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:r}=e,o=l.fromHexInput(r).toUint8Array(),i=new Uint8Array([...o,t]),s=_sha3.sha3_256.create();s.update(i);let a=s.digest();return new Be({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new u(this.data.toUint8Array())}};Be.LENGTH=32;var q=Be;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var So = _interopRequireWildcard(_bip39);var da=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,la= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,ga= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(ga||{}),xo= exports.HARDENED_OFFSET =2147483648;function _o(n){return la.test(n)}function vo(n){return da.test(n)}var xr=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},Po= exports.CKDPriv =({key:n,chainCode:e},t)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,t);let o=new Uint8Array(r),i=new Uint8Array([0]),s=new Uint8Array([...i,...n,...o]);return xr(e,s)},ma=n=>n.replace("'",""),Co= exports.splitPath =n=>n.split("/").slice(1).map(ma),En= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return So.mnemonicToSeedSync(e)};var Je=class extends d{toString(){let e=this.toUint8Array();return l.fromHexInput(e).toString()}},ie= exports.AccountPublicKey =class extends Je{};var G=class extends d{toString(){let e=this.toUint8Array();return l.fromHexInput(e).toString()}};var mt=n=>typeof n=="string"?l.isValid(n).valid?n:Buffer.from(n,"utf8"):n;var Eo=[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],et=class et extends ie{constructor(e){super();let t=l.fromHexInput(e);if(t.toUint8Array().length!==et.LENGTH)throw new Error(`PublicKey length should be ${et.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof v))return!1;let o=mt(t),i=l.fromHexInput(o).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return r.isCanonicalSignature()?_ed25519.ed25519.verify(s,i,a):!1}authKey(){return q.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new et(t)}static isPublicKey(e){return e instanceof et}};et.LENGTH=32;var _=et,se=class se extends d{constructor(e){super();let t=l.fromHexInput(e);if(t.toUint8Array().length!==se.LENGTH)throw new Error(`PrivateKey length should be ${se.LENGTH}`);this.signingKey=t}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new se(e)}static fromDerivationPath(e,t){if(!vo(e))throw new Error(`Invalid derivation path ${e}`);return se.fromDerivationPathInner(e,En(t))}static fromDerivationPathInner(e,t,r=xo){let{key:o,chainCode:i}=xr(se.SLIP_0010_SEED,t),s=Co(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>Po(c,p+r),{key:o,chainCode:i});return new se(a)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new _(e)}sign(e){let t=mt(e),r=l.fromHexInput(t).toUint8Array(),o=_ed25519.ed25519.sign(r,this.signingKey.toUint8Array());return new v(o)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.signingKey.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new se(t)}static isPrivateKey(e){return e instanceof se}};se.LENGTH=32,se.SLIP_0010_SEED="ed25519 seed";var L=se,yt=class yt extends G{constructor(e){super();let t=l.fromHexInput(e);if(t.toUint8Array().length!==yt.LENGTH)throw new Error(`Signature length should be ${yt.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new yt(t)}isCanonicalSignature(){let e=this.toUint8Array().slice(32);for(let t=e.length-1;t>=0;t-=1){if(e[t]<Eo[t])return!0;if(e[t]>Eo[t])return!1}return!1}};yt.LENGTH=64;var v=yt;var ae=class ae extends ie{constructor(e){super();let{publicKeys:t,threshold:r}=e;if(t.length>ae.MAX_KEYS||t.length<ae.MIN_KEYS)throw new Error(`Must have between ${ae.MIN_KEYS} and ${ae.MAX_KEYS} public keys, inclusive`);if(r<ae.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${ae.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof tt))return!1;let o=[];for(let i=0;i<4;i+=1)for(let s=0;s<8;s+=1)if((r.bitmap[i]&1<<7-s)!==0){let c=i*8+s;o.push(c)}if(o.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(o.length<this.threshold)throw new Error("Not enough signatures");for(let i=0;i<o.length;i+=1)if(!this.publicKeys[o[i]].verifySignature({message:t,signature:r.signatures[i]}))return!1;return!0}authKey(){return q.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*_.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*_.LENGTH)}),e[this.publicKeys.length*_.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t[t.length-1],o=[];for(let i=0;i<t.length-1;i+=_.LENGTH){let s=i;o.push(new _(t.subarray(s,s+_.LENGTH)))}return new ae({publicKeys:o,threshold:r})}};ae.MAX_KEYS=32,ae.MIN_KEYS=2,ae.MIN_THRESHOLD=1;var ft=ae,J=class J extends G{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>J.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${J.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=J.createBitmap({bits:r});else{if(r.length!==J.BITMAP_LEN)throw new Error(`"bitmap" length should be ${J.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*v.LENGTH+J.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*v.LENGTH)}),e.set(this.bitmap,this.signatures.length*v.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t.subarray(t.length-4),o=[];for(let i=0;i<t.length-r.length;i+=v.LENGTH){let s=i;o.push(new v(t.subarray(s,s+v.LENGTH)))}return new J({signatures:o,bitmap:r})}static createBitmap(e){let{bits:t}=e,r=128,o=new Uint8Array([0,0,0,0]),i=new Set;return t.forEach((s,a)=>{if(s>=J.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${J.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");i.add(s);let c=Math.floor(s/8),p=o[c];p|=r>>s%8,o[c]=p}),o}};J.MAX_SIGNATURES_SUPPORTED=32,J.BITMAP_LEN=4;var tt=J;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var nt=class nt extends Je{constructor(e){super();let t=l.fromHexInput(e);if(t.toUint8Array().length!==nt.LENGTH)throw new Error(`PublicKey length should be ${nt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Pe))return!1;let o=mt(t),i=l.fromHexInput(o).toUint8Array(),s=_sha3.sha3_256.call(void 0, i),a=r.toUint8Array();return _secp256k1.secp256k1.verify(a,s,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new nt(t)}static isPublicKey(e){return e instanceof nt}};nt.LENGTH=65;var Te=nt,he=class he extends d{constructor(e){super();let t=l.fromHexInput(e);if(t.toUint8Array().length!==he.LENGTH)throw new Error(`PrivateKey length should be ${he.LENGTH}`);this.key=t}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new he(e)}static fromDerivationPath(e,t){if(!_o(e))throw new Error(`Invalid derivation path ${e}`);return he.fromDerivationPathInner(e,En(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new he(r)}sign(e){let t=mt(e),r=l.fromHexInput(t),o=_sha3.sha3_256.call(void 0, r.toUint8Array()),i=_secp256k1.secp256k1.sign(o,this.key.toUint8Array(),{lowS:!0});return new Pe(i.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Te(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new he(t)}static isPrivateKey(e){return e instanceof he}};he.LENGTH=32;var rt=he,At=class At extends G{constructor(e){super();let t=l.fromHexInput(e);if(t.toUint8Array().length!==At.LENGTH)throw new Error(`Signature length should be ${At.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new At(t)}};At.LENGTH=64;var Pe=At;var _jwtdecode = require('jwt-decode');var ot=class n extends Je{constructor(e){super();let t=e.constructor.name;switch(t){case _.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}toUint8Array(){return this.bcsToBytes()}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r})}serialize(e){if(this.publicKey instanceof _)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(_.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},be= exports.EphemeralSignature =class n extends G{constructor(e){super();let t=e.constructor.name;switch(t){case v.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}toUint8Array(){return this.bcsToBytes()}static fromHex(e){let t=l.fromHexInput(e),r=new oe(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof v)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(v.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _poseidonlite = require('poseidon-lite');var _r=[_poseidonlite.poseidon1,_poseidonlite.poseidon2,_poseidonlite.poseidon3,_poseidonlite.poseidon4,_poseidonlite.poseidon5,_poseidonlite.poseidon6,_poseidonlite.poseidon7,_poseidonlite.poseidon8,_poseidonlite.poseidon9,_poseidonlite.poseidon10,_poseidonlite.poseidon11,_poseidonlite.poseidon12,_poseidonlite.poseidon13,_poseidonlite.poseidon14,_poseidonlite.poseidon15,_poseidonlite.poseidon16],Ro=31,za=16,Uo=(za-1)*Ro;function Rn(n,e){let r=new TextEncoder().encode(n);return Da(r,e)}function Da(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=vr(n,e);return Lt(t)}function ka(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);let t=Ka(n,e);return Ga(t)}function vr(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);return ka(n,e).concat([BigInt(n.length)])}function Ga(n){if(n.length>Uo)throw new Error(`Can't pack more than ${Uo}. Was given ${n.length} bytes`);return Ba(n,Ro).map(e=>$t(e))}function Ba(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.subarray(r,r+e));return t}function $t(n){let e=BigInt(0);for(let t=n.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(n[t]);return e}function zo(n,e){let t=new Uint8Array(e);for(let r=0;r<e;r+=1)t[r]=Number(n&BigInt(255)),n>>=BigInt(8);return t}function Ka(n,e){if(e<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(n);for(let r=n.length;r<e;r+=1)t[r]=0;return t}function Lt(n){if(n.length>_r.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${_r.length}`);return _r[n.length-1](n)}var zn=class extends d{toString(){let e=this.bcsToBytes();return l.fromHexInput(e).toString()}};var ye=class extends Error{constructor(e,t,r){super(r),this.name="AptosApiError",this.url=t.url,this.status=t.status,this.statusText=t.statusText,this.data=t.data,this.request=e}};var Do="1.20.0";var ko={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Go= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},Bo= exports.NetworkToFaucetAPI ={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"},Pr= exports.NetworkToPepperAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},Cr= exports.NetworkToProverAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},Er= exports.Network =(i=>(i.MAINNET="mainnet",i.TESTNET="testnet",i.DEVNET="devnet",i.LOCAL="local",i.CUSTOM="custom",i))(Er||{}),Ir= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},Td= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var Ht=(i=>(i.FULLNODE="Fullnode",i.INDEXER="Indexer",i.FAUCET="Faucet",i.PEPPER="Pepper",i.PROVER="Prover",i))(Ht||{}),Ko= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,No= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Dn= exports.DEFAULT_TXN_TIMEOUT_SEC =20,kn= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Oo= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Ur= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",Ke= exports.ProcessorType =(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.OBJECT_PROCESSOR="objects_processor",c))(Ke||{});function Fo(n,e){let t=e.bcsToBytes(),r=new oe(t);return n.deserialize(r)}var Mo={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 Na(n,e){let{url:t,method:r,body:o,contentType:i,params:s,overrides:a,originMethod:c}=n,p={..._optionalChain([a, 'optionalAccess', _8 => _8.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${Do}`,"content-type":_nullishCoalesce(i, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _9 => _9.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _10 => _10.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _11 => _11.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _12 => _12.API_KEY])}`),e.provider({url:t,method:r,body:o,params:s,headers:p,overrides:a})}async function Gn(n,e,t){let{url:r,path:o}=n,i=o?`${r}/${o}`:r,s=await Na({...n,url:i},e.client),a={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:i};if(a.status===401)throw new ye(n,a,`Error: ${a.data}`);if(t==="Indexer"){let p=a.data;if(p.errors)throw new ye(n,a,_nullishCoalesce(`Indexer error: ${p.errors[0].message}`, () => (`Indexer unhandled Error ${s.status} : ${s.statusText}`)));a.data=p.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new ye(n,a,`${s.data}`);if(a.status>=200&&a.status<300)return a;let c;throw a&&a.data&&"message"in a.data&&"error_code"in a.data?c=JSON.stringify(a.data):a.status in Mo?c=Mo[a.status]:c=`Unhandled Error ${a.status} : ${a.statusText}`,new ye(n,a,`${t} error: ${c}`)}async function Rr(n){let{aptosConfig:e,overrides:t,params:r,contentType:o,acceptType:i,path:s,originMethod:a,type:c}=n,p=e.getRequestUrl(c);return Gn({url:p,method:"GET",originMethod:a,path:s,contentType:o,acceptType:i,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function V(n){let{aptosConfig:e}=n;return Rr({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _13 => _13.clientConfig, 'optionalAccess', _14 => _14.HEADERS]),..._optionalChain([e, 'access', _15 => _15.fullnodeConfig, 'optionalAccess', _16 => _16.HEADERS])}}})}async function qd(n){return Rr({...n,type:"Pepper"})}async function ht(n){let e=[],t,r=n.params;do{let o=await Rr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});t=o.headers["x-aptos-cursor"],delete o.headers,e.push(...o.data),r.start=t}while(t!=null);return e}async function Qt(n){let{type:e,originMethod:t,path:r,body:o,acceptType:i,contentType:s,params:a,aptosConfig:c,overrides:p}=n,y=c.getRequestUrl(e);return Gn({url:y,method:"POST",originMethod:t,path:r,body:o,contentType:s,acceptType:i,params:a,overrides:p},c,n.type)}async function Ne(n){let{aptosConfig:e}=n;return Qt({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _17 => _17.clientConfig, 'optionalAccess', _18 => _18.HEADERS]),..._optionalChain([e, 'access', _19 => _19.fullnodeConfig, 'optionalAccess', _20 => _20.HEADERS])}}})}async function qo(n){let{aptosConfig:e}=n;return Qt({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _21 => _21.clientConfig, 'optionalAccess', _22 => _22.HEADERS]),..._optionalChain([e, 'access', _23 => _23.indexerConfig, 'optionalAccess', _24 => _24.HEADERS])}}})}async function Vo(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _25 => _25.clientConfig, 'optionalAccess', _26 => delete _26.API_KEY]),Qt({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _27 => _27.clientConfig, 'optionalAccess', _28 => _28.HEADERS]),..._optionalChain([t, 'access', _29 => _29.faucetConfig, 'optionalAccess', _30 => _30.HEADERS])}}})}async function $o(n){return Qt({...n,type:"Pepper"})}async function Lo(n){return Qt({...n,type:"Prover"})}var zr=new Map;function Oe(n,e,t){return async(...r)=>{if(zr.has(e)){let{value:i,timestamp:s}=zr.get(e);if(t===void 0||Date.now()-s<=t)return i}let o=await n(...r);return zr.set(e,{value:o,timestamp:Date.now()}),o}}var hl=1e7,Fa= exports.MAX_AUD_VAL_BYTES =120,Ma= exports.MAX_UID_KEY_BYTES =30,qa= exports.MAX_UID_VAL_BYTES =330,Tl= exports.MAX_ISS_VAL_BYTES =120,bl= exports.MAX_EXTRA_FIELD_BYTES =350,wl= exports.MAX_JWT_HEADER_B64_BYTES =300,Sl= exports.MAX_COMMITED_EPK_BYTES =93,we=class we extends ie{constructor(e,t){super();let r=l.fromHexInput(t).toUint8Array();if(r.length!==we.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${we.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new Z;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),q.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}toString(){return l.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new we(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new we(t,r)}static isPublicKey(e){return e instanceof we}static create(e){return Ho(e),new we(e.iss,Ho(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:o="sub"}=e,i=_jwtdecode.jwtDecode.call(void 0, t),s=i.iss;if(typeof i.aud!="string")throw new Error("aud was not found or an array of values");let a=i.aud,c=i[o];return we.create({iss:s,uidKey:o,uidVal:c,aud:a,pepper:r})}};we.ID_COMMITMENT_LENGTH=32;var ee=we;function Ho(n){let{uidKey:e,uidVal:t,aud:r,pepper:o}=n,i=[$t(l.fromHexInput(o).toUint8Array()),Rn(r,Fa),Rn(t,qa),Rn(e,Ma)];return zo(Lt(i),ee.ID_COMMITMENT_LENGTH)}var Ee=class n extends G{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:r,expiryDateSecs:o,ephemeralPublicKey:i,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=r,this.expiryDateSecs=o,this.ephemeralPublicKey=i,this.ephemeralSignature=s}toUint8Array(){return this.bcsToBytes()}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=Tt.deserialize(e),r=e.deserializeStr(),o=e.deserializeU64(),i=ot.deserialize(e),s=be.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(o),ephemeralCertificate:t,ephemeralPublicKey:i,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new Tt(new Ie({proof:new wt(new bt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new ot(new _(new Uint8Array(32))),ephemeralSignature:new be(new v(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},Tt= exports.EphemeralCertificate =class n extends G{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(Ie.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},Ce=class n extends d{constructor(e){if(super(),this.data=l.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new n(t)}},it=class n extends d{constructor(e){if(super(),this.data=l.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new n(t)}},bt= exports.Groth16Zkp =class n extends zn{constructor(e){super();let{a:t,b:r,c:o}=e;this.a=new Ce(t),this.b=new it(r),this.c=new Ce(o)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=Ce.deserialize(e).bcsToBytes(),r=it.deserialize(e).bcsToBytes(),o=Ce.deserialize(e).bcsToBytes();return new n({a:t,b:r,c:o})}},wt= exports.ZkProof =class n extends d{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(bt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},Ie= exports.ZeroKnowledgeSig =class n extends G{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:o,extraField:i,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=o,this.extraField=i,this.overrideAudVal=s}toUint8Array(){return this.bcsToBytes()}static fromBytes(e){return n.deserialize(new oe(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOptionStr(this.extraField),e.serializeOptionStr(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=wt.deserialize(e),r=Number(e.deserializeU64()),o=e.deserializeOptionStr(),i=e.deserializeOptionStr(),s=e.deserializeOption(be);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:o,overrideAudVal:i})}},Dr= exports.KeylessConfiguration =class n{constructor(e,t){this.verficationKey=e,this.maxExpHorizonSecs=t}static create(e,t){return new n(new kr({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),t)}},kr=class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:o,gammaAbcG1:i,gammaG2:s}=e;this.alphaG1=new Ce(t),this.betaG2=new it(r),this.deltaG2=new it(o),this.gammaAbcG1=[new Ce(i[0]),new Ce(i[1])],this.gammaG2=new it(s)}static fromGroth16VerificationKeyResponse(e){return new n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}};async function Qo(n){let{aptosConfig:e}=n;return Oe(async()=>{let t=await Va(n),r=await $a(n);return Dr.create(r,Number(t.max_exp_horizon_secs))},`keyless-configuration-${e.network}`,1e3*60*5)()}async function Va(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration",{data:o}=await V({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${u.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _31 => _31.ledgerVersion])}});return o.data}async function $a(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey",{data:o}=await V({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${u.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _32 => _32.ledgerVersion])}});return o.data}var k=class n extends ie{constructor(e){if(super(),this.publicKey=e,e instanceof _)this.variant=0;else if(e instanceof Te)this.variant=1;else if(e instanceof ee)this.variant=3;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;return r instanceof B?this.publicKey.verifySignature({message:t,signature:r.signature}):!1}authKey(){return q.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=_.deserialize(e);break;case 1:r=Te.deserialize(e);break;case 3:r=ee.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new n(r)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof _}isSecp256k1PublicKey(){return this.publicKey instanceof Te}},B= exports.AnySignature =class n extends G{constructor(e){if(super(),this.signature=e,e instanceof v)this.variant=0;else if(e instanceof Pe)this.variant=1;else if(e instanceof Ee)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=v.deserialize(e);break;case 1:r=Pe.deserialize(e);break;case 3:r=Ee.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new n(r)}};function La(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var St=class n extends ie{constructor(e){super();let{publicKeys:t,signaturesRequired:r}=e;if(r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);this.publicKeys=t.map(o=>o instanceof k?o:new k(o)),this.signaturesRequired=r}verifySignature(e){throw new Error("not implemented")}authKey(){return q.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(k),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}createBitmap(e){let{bits:t}=e,r=128,o=new Uint8Array([0,0,0,0]),i=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(i.has(s))throw new Error(`Duplicate bit ${s} detected.`);i.add(s);let c=Math.floor(s/8),p=o[c];p|=r>>s%8,o[c]=p}),o}getIndex(e){let t=e instanceof k?e:new k(e),r=this.publicKeys.findIndex(o=>o.toString()===t.toString());if(r!==-1)return r;throw new Error("Public key not found in MultiKey")}},te=class te extends G{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>te.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${te.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(i=>i instanceof B?i:new B(i)),!(r instanceof Uint8Array))this.bitmap=te.createBitmap({bits:r});else{if(r.length!==te.BITMAP_LEN)throw new Error(`"bitmap" length should be ${te.BITMAP_LEN}`);this.bitmap=r}let o=this.bitmap.reduce((i,s)=>i+La(s),0);if(o!==this.signatures.length)throw new Error(`Expecting ${o} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:t}=e,r=128,o=new Uint8Array([0,0,0,0]),i=new Set;return t.forEach(s=>{if(s>=te.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${te.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(s))throw new Error("Duplicate bits detected.");i.add(s);let a=Math.floor(s/8),c=o[a];c|=r>>s%8,o[a]=c}),o}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(B),r=e.deserializeBytes();return new te({signatures:t,bitmap:r})}};te.BITMAP_LEN=4,te.MAX_SIGNATURES_SUPPORTED=te.BITMAP_LEN*8;var st=te;var H=class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return fe.load(e);case 1:return Bn.load(e);case 2:return Q.load(e);case 3:return at.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof fe}isMultiEd25519(){return this instanceof Bn}isSingleKey(){return this instanceof Q}isMultiKey(){return this instanceof at}},fe= exports.AccountAuthenticatorEd25519 =class n extends H{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=_.deserialize(e),r=v.deserialize(e);return new n(t,r)}},Bn= exports.AccountAuthenticatorMultiEd25519 =class n extends H{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=ft.deserialize(e),r=tt.deserialize(e);return new n(t,r)}},Q= exports.AccountAuthenticatorSingleKey =class n extends H{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=k.deserialize(e),r=B.deserialize(e);return new n(t,r)}},at= exports.AccountAuthenticatorMultiKey =class n extends H{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=St.deserialize(e),r=st.deserialize(e);return new n(t,r)}};var xt=class n extends d{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new n(t)}};var R=class n extends d{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var Wt=class n extends d{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new n(u.fromString(t[0]),new R(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=R.deserialize(e);return new n(t,r)}};var z=class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return K.load(e);case 1:return ce.load(e);case 2:return $.load(e);case 3:return qe.load(e);case 4:return W.load(e);case 5:return _t.load(e);case 6:return C.load(e);case 7:return m.load(e);case 8:return Fe.load(e);case 9:return Me.load(e);case 10:return Ve.load(e);case 255:return D.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof K}isAddress(){return this instanceof W}isGeneric(){return this instanceof D}isSigner(){return this instanceof _t}isVector(){return this instanceof C}isStruct(){return this instanceof m}isU8(){return this instanceof ce}isU16(){return this instanceof Fe}isU32(){return this instanceof Me}isU64(){return this instanceof $}isU128(){return this instanceof qe}isU256(){return this instanceof Ve}},K= exports.TypeTagBool =class n extends z{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},ce= exports.TypeTagU8 =class n extends z{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},Fe= exports.TypeTagU16 =class n extends z{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},Me= exports.TypeTagU32 =class n extends z{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},$= exports.TypeTagU64 =class n extends z{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},qe= exports.TypeTagU128 =class n extends z{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},Ve= exports.TypeTagU256 =class n extends z{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},W= exports.TypeTagAddress =class n extends z{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},_t= exports.TypeTagSigner =class n extends z{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},Kn= exports.TypeTagReference =class n extends z{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=z.deserialize(t);return new n(r)}},D= exports.TypeTagGeneric =class n extends z{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let r=t.deserializeU32();return new n(r)}},C= exports.TypeTagVector =class n extends z{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new ce)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=z.deserialize(t);return new n(r)}},m= exports.TypeTagStruct =class n extends z{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${t}`}serialize(t){t.serializeU32AsUleb128(7),this.value.serialize(t)}static load(t){let r=Ue.deserialize(t);return new n(r)}isTypeTag(t,r,o){return this.value.moduleName.identifier===r&&this.value.name.identifier===o&&this.value.address.equals(t)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}},Ue= exports.StructTag =class n extends d{constructor(e,t,r,o){super(),this.address=e,this.moduleName=t,this.name=r,this.typeArgs=o}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=u.deserialize(e),r=R.deserialize(e),o=R.deserialize(e),i=e.deserializeVector(z);return new n(t,r,o,i)}};function Rg(){return new Ue(u.ONE,new R("aptos_coin"),new R("AptosCoin"),[])}function P(){return new Ue(u.ONE,new R("string"),new R("String"),[])}function zg(n){return new Ue(u.ONE,new R("option"),new R("Option"),[n])}function ne(n){return new Ue(u.ONE,new R("object"),new R("Object"),[n])}function Ha(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return F.deserialize(n);case 1:return O.deserialize(n);case 2:return ge.deserialize(n);case 3:return u.deserialize(n);case 4:return T.deserialize(n,F);case 5:return I.deserialize(n);case 6:return de.deserialize(n);case 7:return le.deserialize(n);case 8:return me.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var ct=class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return jt.load(e);case 2:return Xt.load(e);case 3:return Yt.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},jt= exports.TransactionPayloadScript =class n extends ct{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=Zt.deserialize(e);return new n(t)}},Xt= exports.TransactionPayloadEntryFunction =class n extends ct{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=ut.deserialize(e);return new n(t)}},Yt= exports.TransactionPayloadMultiSig =class n extends ct{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Jt.deserialize(e);return new n(t)}},ut= exports.EntryFunction =class n{constructor(e,t,r,o){this.module_name=e,this.function_name=t,this.type_args=r,this.args=o}static build(e,t,r,o){return new n(Wt.fromStr(e),new R(t),r,o)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=Wt.deserialize(e),r=R.deserialize(e),o=e.deserializeVector(z),i=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<i;a+=1){let c=e.deserializeUleb128AsU32(),p=Pn.deserialize(e,c);s.push(p)}return new n(t,r,o,s)}},Zt= exports.Script =class n{constructor(e,t,r){this.bytecode=e,this.type_args=t,this.args=r}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),r=e.deserializeVector(z),o=e.deserializeUleb128AsU32(),i=new Array;for(let s=0;s<o;s+=1){let a=Ha(e);i.push(a)}return new n(t,r,i)}},Jt= exports.MultiSig =class n{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=u.deserialize(e),r=e.deserializeBool(),o;return r&&(o=en.deserialize(e)),new n(t,o)}},en= exports.MultiSigTransactionPayload =class n extends d{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new n(ut.deserialize(e))}};var ue=class n extends d{constructor(e,t,r,o,i,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,this.max_gas_amount=o,this.gas_unit_price=i,this.expiration_timestamp_secs=s,this.chain_id=a}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 t=u.deserialize(e),r=e.deserializeU64(),o=ct.deserialize(e),i=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=xt.deserialize(e);return new n(t,r,o,i,s,a,c)}},Nn= exports.RawTransactionWithData =class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return pt.load(e);case 1:return dt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},pt= exports.MultiAgentRawTransaction =class n extends Nn{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=ue.deserialize(e),r=e.deserializeVector(u);return new n(t,r)}},dt= exports.FeePayerRawTransaction =class n extends Nn{constructor(e,t,r){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=r}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 t=ue.deserialize(e),r=e.deserializeVector(u),o=u.deserialize(e);return new n(t,r,o)}};var On=class extends d{constructor(t){super();this.accountAddress=u.ONE;this.moduleName=new b("account");this.structName=new b("RotationProofChallenge");this.sequenceNumber=new O(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=T.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var Re=class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return vt.load(e);case 1:return Gr.load(e);case 2:return Pt.load(e);case 3:return Ct.load(e);case 4:return Et.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}},vt= exports.TransactionAuthenticatorEd25519 =class n extends Re{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=_.deserialize(e),r=v.deserialize(e);return new n(t,r)}},Gr= exports.TransactionAuthenticatorMultiEd25519 =class n extends Re{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=ft.deserialize(e),r=tt.deserialize(e);return new n(t,r)}},Pt= exports.TransactionAuthenticatorMultiAgent =class n extends Re{constructor(e,t,r){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let t=H.deserialize(e),r=e.deserializeVector(u),o=e.deserializeVector(H);return new n(t,r,o)}},Ct= exports.TransactionAuthenticatorFeePayer =class n extends Re{constructor(e,t,r,o){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r,this.fee_payer=o}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 t=H.deserialize(e),r=e.deserializeVector(u),o=e.deserializeVector(H),i=u.deserialize(e),s=H.deserialize(e),a={address:i,authenticator:s};return new n(t,r,o,a)}},Et= exports.TransactionAuthenticatorSingleSender =class n extends Re{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=H.deserialize(e);return new n(t)}};var lt=class n extends d{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=ue.deserialize(e),r=Re.deserialize(e);return new n(t,r)}};var Fn=class n extends d{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=ue.deserialize(e),r=e.deserializeBool(),o;return r&&(o=u.deserialize(e)),new n(t,o)}};var Mn=class n extends d{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=ue.deserialize(e),r=e.deserializeVector(u),o=e.deserializeBool(),i;return o&&(i=u.deserialize(e)),new n(t,r,i)}};function Br(n){return n.feePayerAddress?new dt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new pt(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function It(n,e){let t=_sha3.sha3_256.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let r=t.digest(),o=n,i=new Uint8Array(r.length+o.length);return i.set(r),i.set(o,r.length),i}function Vm(n){return It(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Ut(n){let e=Br(n);return n.feePayerAddress?It(e.bcsToBytes(),Ur):n.secondarySignerAddresses?It(e.bcsToBytes(),Ur):It(e.bcsToBytes(),Oo)}var Rt=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=L.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,o=L.fromDerivationPath(t,r);return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new fe(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new fe(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Ut(e))}};var zt=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new k(t.publicKey()),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=L.generate();break;case 2:r=rt.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:o}=e,i;switch(t){case 0:i=L.fromDerivationPath(r,o);break;case 2:i=rt.fromDerivationPath(r,o);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new Q(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Q(this.publicKey,this.signTransaction(e))}sign(e){return new B(this.privateKey.sign(e))}signTransaction(e){return this.sign(Ut(e))}};var $e=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?Rt.generate():zt.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:o=!0}=e;return t instanceof L&&o?new Rt({privateKey:t,address:r}):new zt({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:r,path:o,legacy:i=!0}=e;return t===0&&i?Rt.fromDerivationPath({mnemonic:r,path:o}):zt.fromDerivationPath({scheme:t,mnemonic:r,path:o})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}};var ja=1209600,Dt=class Dt extends d{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:o}=e;this.privateKey=t,this.publicKey=new ot(t.publicKey()),this.expiryDateSecs=r||_chunkBHKSQXUZjs.d.call(void 0, _chunkBHKSQXUZjs.c.call(void 0, )+ja),this.blinder=o!==void 0?l.fromHexInput(o).toUint8Array():Xa();let i=vr(this.publicKey.bcsToBytes(),93);i.push(BigInt(this.expiryDateSecs)),i.push($t(this.blinder));let s=Lt(i);this.nonce=s.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=L.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let o=e.deserializeU64(),i=e.deserializeFixedBytes(31);return new Dt({privateKey:r,expiryDateSecs:Number(o),blinder:i})}static fromBytes(e){return Dt.deserialize(new oe(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _33 => _33.scheme])){case 0:default:t=L.generate()}return new Dt({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _34 => _34.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new be(this.privateKey.sign(e))}};Dt.BLINDER_LENGTH=31;var tn=Dt;function Xa(){return _utils.randomBytes.call(void 0, tn.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);var Le=class Le extends d{constructor(e){super();let{address:t,ephemeralKeyPair:r,uidKey:o,uidVal:i,aud:s,pepper:a,proof:c,proofFetchCallback:p,jwt:y}=e;if(this.ephemeralKeyPair=r,this.publicKey=ee.create(e),this.accountAddress=t?u.from(t):this.publicKey.authKey().derivedAddress(),this.uidKey=o,this.uidVal=i,this.aud=s,this.jwt=y,this.emitter=new _eventemitter32.default,this.proofOrPromise=c,c instanceof Ie)this.proof=c;else{if(p===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async S=>{await p(S),this.emitter.removeAllListeners()}),this.init(c)}this.signingScheme=2;let w=l.fromHexInput(a).toUint8Array();if(w.length!==Le.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${Le.PEPPER_LENGTH}`);this.pepper=w}async init(e){try{this.proof=await e,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(t){t instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:t.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(e){if(e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),this.proof===void 0)throw new Error("Connot serialize - proof undefined");this.proof.serialize(e)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeStr(),o=e.deserializeFixedBytes(31),i=tn.deserialize(e),s=Ie.deserialize(e);return Le.create({proof:s,pepper:o,uidKey:r,jwt:t,ephemeralKeyPair:i})}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(e){let t=new B(this.sign(e)),r=new k(this.publicKey);return new Q(r,t)}signTransactionWithAuthenticator(e){let t=new B(this.signTransaction(e)),r=new k(this.publicKey);return new Q(r,t)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}sign(e){let{expiryDateSecs:t}=this.ephemeralKeyPair;if(this.isExpired())throw new Error("EphemeralKeyPair is expired");if(this.proof===void 0)throw new Error("Proof not defined");let r=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(e);return new Ee({jwtHeader:_chunkBHKSQXUZjs.e.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new Tt(this.proof,0),expiryDateSecs:t,ephemeralPublicKey:r,ephemeralSignature:o})}signTransaction(e){if(this.proof===void 0)throw new Error("Proof not found");let t=Br(e),o=new Kr(t,this.proof.proof).hash();return this.sign(o)}verifySignature(e){throw new Error("Not implemented")}static fromBytes(e){return Le.deserialize(new oe(e))}static create(e){let{address:t,proof:r,jwt:o,ephemeralKeyPair:i,pepper:s,uidKey:a="sub",proofFetchCallback:c}=e,p=_jwtdecode.jwtDecode.call(void 0, o),y=p.iss;if(typeof p.aud!="string")throw new Error("aud was not found or an array of values");let w=p.aud,S=p[a];return new Le({address:t,proof:r,ephemeralKeyPair:i,iss:y,uidKey:a,uidVal:S,aud:w,pepper:s,jwt:o,proofFetchCallback:c})}};Le.PEPPER_LENGTH=31;var Se=Le,Kr=class extends d{constructor(t,r){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=r}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return It(this.bcsToBytes(),this.domainSeparator)}};var qn=class n{constructor(e){let{multiKey:t,signers:r}=e;this.publicKey=t,this.signingScheme=3,this.accountAddress=this.publicKey.authKey().derivedAddress();let o=[];for(let s of r)o.push(this.publicKey.getIndex(s.publicKey));let i=r.map((s,a)=>[s,o[a]]);i.sort((s,a)=>s[1]-a[1]),this.signers=i.map(s=>s[0]),this.signerIndicies=i.map(s=>s[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{publicKeys:t,signaturesRequired:r,signers:o}=e,i=new St({publicKeys:t,signaturesRequired:r});return new n({multiKey:i,signers:o})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new at(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new at(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof Se).map(async r=>r.waitForProofFetch());await Promise.all(t)}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new st({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new st({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){let{message:t,signature:r}=e;if(!this.signerIndicies.every((i,s)=>s===0||i>=this.signerIndicies[s-1]))return!1;for(let i=0;i<r.signatures.length;i+=1){let s=r.signatures[i];if(!this.publicKey.publicKeys[this.signerIndicies[i]].verifySignature({message:t,signature:s}))return!1}return!0}};var Ja=`
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunkBHKSQXUZjs = require('./chunk-BHKSQXUZ.js');var xn=255,_n=65535,ve=4294967295,Xe=18446744073709551615n,qt=340282366920938463463374607431768211455n,vn=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var oe=class{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeBool()?this.deserializeStr():void 0}deserializeOption(e){return this.deserializeBool()?this.deserialize(e):void 0}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===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 e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<ve;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),!(r&128))break;t+=7}if(e>ve)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),r=new Array;for(let o=0;o<t;o+=1)r.push(this.deserialize(e));return r}};var _utils = require('@noble/hashes/utils');var Y=class extends Error{constructor(e,t){super(e),this.invalidReason=t}};var ra=(r=>(r.TOO_SHORT="too_short",r.INVALID_LENGTH="invalid_length",r.INVALID_HEX_CHARS="invalid_hex_chars",r))(ra||{}),l= exports.Hex =class n{constructor(e){this.data=e}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(e){let t=e;if(t.startsWith("0x")&&(t=t.slice(2)),t.length===0)throw new Y("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(t.length%2!==0)throw new Y("Hex string must be an even number of hex characters.","invalid_length");try{return new n(_utils.hexToBytes.call(void 0, t))}catch(r){throw new Y(`Hex string contains invalid hex characters: ${_optionalChain([r, 'optionalAccess', _2 => _2.message])}`,"invalid_hex_chars")}}static fromHexInput(e){return e instanceof Uint8Array?new n(e):n.fromHexString(e)}static isValid(e){try{return n.fromHexString(e),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _3 => _3.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _4 => _4.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,r)=>t===e.data[r])}};var d=class{bcsToBytes(){let e=new Z;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return l.fromHexInput(e)}},Z= exports.Serializer =class{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.offset=0}ensureBufferWillHandleSize(e){for(;this.buffer.byteLength<this.offset+e;){let t=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t}}appendToBuffer(e){this.ensureBufferWillHandleSize(e.length),new Uint8Array(this.buffer,this.offset).set(e),this.offset+=e.length}serializeWithFunction(e,t,r){this.ensureBufferWillHandleSize(t);let o=new DataView(this.buffer,this.offset);e.apply(o,[0,r,!0]),this.offset+=t}serializeStr(e){let t=new TextEncoder;this.serializeBytes(t.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){fr(e);let t=e?1:0;this.appendToBuffer(new Uint8Array([t]))}serializeU8(e){this.appendToBuffer(new Uint8Array([e]))}serializeU16(e){this.serializeWithFunction(DataView.prototype.setUint16,2,e)}serializeU32(e){this.serializeWithFunction(DataView.prototype.setUint32,4,e)}serializeU64(e){let t=BigInt(e)&BigInt(ve),r=BigInt(e)>>BigInt(32);this.serializeU32(Number(t)),this.serializeU32(Number(r))}serializeU128(e){let t=BigInt(e)&Xe,r=BigInt(e)>>BigInt(64);this.serializeU64(t),this.serializeU64(r)}serializeU256(e){let t=BigInt(e)&qt,r=BigInt(e)>>BigInt(128);this.serializeU128(t),this.serializeU128(r)}serializeU32AsUleb128(e){let t=e,r=[];for(;t>>>7;)r.push(t&127|128),t>>>=7;r.push(t),this.appendToBuffer(new Uint8Array(r))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(e){e.serialize(this)}serializeVector(e){this.serializeU32AsUleb128(e.length),e.forEach(t=>{t.serialize(this)})}serializeOption(e){let t=e!==void 0;this.serializeBool(t),t&&e.serialize(this)}serializeOptionStr(e){e===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(e))}};_chunkBHKSQXUZjs.a.call(void 0, [Ye(0,xn)],Z.prototype,"serializeU8",1),_chunkBHKSQXUZjs.a.call(void 0, [Ye(0,_n)],Z.prototype,"serializeU16",1),_chunkBHKSQXUZjs.a.call(void 0, [Ye(0,ve)],Z.prototype,"serializeU32",1),_chunkBHKSQXUZjs.a.call(void 0, [Ye(BigInt(0),Xe)],Z.prototype,"serializeU64",1),_chunkBHKSQXUZjs.a.call(void 0, [Ye(BigInt(0),qt)],Z.prototype,"serializeU128",1),_chunkBHKSQXUZjs.a.call(void 0, [Ye(BigInt(0),vn)],Z.prototype,"serializeU256",1),_chunkBHKSQXUZjs.a.call(void 0, [Ye(0,ve)],Z.prototype,"serializeU32AsUleb128",1);function fr(n){if(typeof n!="boolean")throw new Error(`${n} is not a boolean value`)}var oa=(n,e,t)=>`${n} is out of range: [${e}, ${t}]`;function Be(n,e,t){let r=BigInt(n);if(r>BigInt(t)||r<BigInt(e))throw new Error(oa(n,e,t))}function Ye(n,e){return(t,r,o)=>{let i=o.value;return o.value=function(a){return Be(a,n,e),i.apply(this,[a])},o}}var Ze=class n extends d{constructor(e){super(),this.value=l.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let r=e.deserializeFixedBytes(t);return new n(r)}};var Pn=class n extends d{constructor(e){super(),this.value=new Ze(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=Ze.deserialize(e,t);return new n(r.value)}};var Cn=(o=>(o.JSON="application/json",o.BCS="application/x-bcs",o.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",o.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",o))(Cn||{}),go= exports.TypeTagVariants =(g=>(g[g.Bool=0]="Bool",g[g.U8=1]="U8",g[g.U64=2]="U64",g[g.U128=3]="U128",g[g.Address=4]="Address",g[g.Signer=5]="Signer",g[g.Vector=6]="Vector",g[g.Struct=7]="Struct",g[g.U16=8]="U16",g[g.U32=9]="U32",g[g.U256=10]="U256",g[g.Reference=254]="Reference",g[g.Generic=255]="Generic",g))(go||{}),Vt= exports.ScriptTransactionArgumentVariants =(p=>(p[p.U8=0]="U8",p[p.U64=1]="U64",p[p.U128=2]="U128",p[p.Address=3]="Address",p[p.U8Vector=4]="U8Vector",p[p.Bool=5]="Bool",p[p.U16=6]="U16",p[p.U32=7]="U32",p[p.U256=8]="U256",p))(Vt||{}),mo= exports.TransactionPayloadVariants =(r=>(r[r.Script=0]="Script",r[r.EntryFunction=2]="EntryFunction",r[r.Multisig=3]="Multisig",r))(mo||{}),yo= exports.TransactionVariants =(t=>(t[t.MultiAgentTransaction=0]="MultiAgentTransaction",t[t.FeePayerTransaction=1]="FeePayerTransaction",t))(yo||{}),fo= exports.TransactionAuthenticatorVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.MultiAgent=2]="MultiAgent",i[i.FeePayer=3]="FeePayer",i[i.SingleSender=4]="SingleSender",i))(fo||{}),Ao= exports.AccountAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Ao||{}),Ar= exports.AnyPublicKeyVariant =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1=1]="Secp256k1",r[r.Keyless=3]="Keyless",r))(Ar||{}),ho= exports.AnySignatureVariant =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1=1]="Secp256k1",r[r.Keyless=3]="Keyless",r))(ho||{}),hr= exports.EphemeralPublicKeyVariant =(e=>(e[e.Ed25519=0]="Ed25519",e))(hr||{}),To= exports.EphemeralSignatureVariant =(e=>(e[e.Ed25519=0]="Ed25519",e))(To||{}),Tr= exports.EphemeralCertificateVariant =(e=>(e[e.ZkProof=0]="ZkProof",e))(Tr||{}),br= exports.ZkpVariant =(e=>(e[e.Groth16=0]="Groth16",e))(br||{}),wr= exports.TransactionResponseType =(s=>(s.Pending="pending_transaction",s.User="user_transaction",s.Genesis="genesis_transaction",s.BlockMetadata="block_metadata_transaction",s.StateCheckpoint="state_checkpoint_transaction",s.Validator="validator_transaction",s))(wr||{});function hu(n){return n.type==="pending_transaction"}function Tu(n){return n.type==="user_transaction"}function bu(n){return n.type==="genesis_transaction"}function wu(n){return n.type==="block_metadata_transaction"}function Su(n){return n.type==="state_checkpoint_transaction"}function xu(n){return n.type==="validator_transaction"}function _u(n){return"signature"in n&&n.signature==="ed25519_signature"}function vu(n){return"signature"in n&&n.signature==="secp256k1_ecdsa_signature"}function Pu(n){return n.type==="multi_agent_signature"}function Cu(n){return n.type==="fee_payer_signature"}function Eu(n){return n.type==="multi_ed25519_signature"}var ia=(r=>(r.PRIVATE="private",r.PUBLIC="public",r.FRIEND="friend",r))(ia||{}),bo= exports.MoveAbility =(o=>(o.STORE="store",o.DROP="drop",o.KEY="key",o.COPY="copy",o))(bo||{}),sa= exports.RoleType =(t=>(t.VALIDATOR="validator",t.FULL_NODE="full_node",t))(sa||{}),Ae= exports.SigningScheme =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Ae||{}),Sr= exports.SigningSchemeInput =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",t))(Sr||{}),wo= exports.DeriveScheme =(i=>(i[i.DeriveAuid=251]="DeriveAuid",i[i.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",i[i.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",i[i.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",i[i.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",i))(wo||{});var I=class n extends d{constructor(e){super(),fr(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}static deserialize(e){return new n(e.deserializeBool())}},F= exports.U8 =class n extends d{constructor(e){super(),Be(e,0,xn),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},de= exports.U16 =class n extends d{constructor(e){super(),Be(e,0,_n),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},le= exports.U32 =class n extends d{constructor(e){super(),Be(e,0,ve),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},O= exports.U64 =class n extends d{constructor(e){super(),Be(e,BigInt(0),Xe),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},ge= exports.U128 =class n extends d{constructor(e){super(),Be(e,BigInt(0),qt),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},me= exports.U256 =class n extends d{constructor(e){super(),Be(e,BigInt(0),vn),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var T=class n extends d{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(!(this.values[0]instanceof F)&&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 t;if(Array.isArray(e)&&e.length===0)t=[];else if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let r=l.fromHexInput(e);t=Array.from(r.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new n(t.map(r=>new F(r)))}static U16(e){return new n(e.map(t=>new de(t)))}static U32(e){return new n(e.map(t=>new le(t)))}static U64(e){return new n(e.map(t=>new O(t)))}static U128(e){return new n(e.map(t=>new ge(t)))}static U256(e){return new n(e.map(t=>new me(t)))}static Bool(e){return new n(e.map(t=>new I(t)))}static MoveString(e){return new n(e.map(t=>new b(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let r=e.deserializeUleb128AsU32(),o=new Array;for(let i=0;i<r;i+=1)o.push(t.deserialize(e));return new n(o)}},b= exports.MoveString =class n extends d{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let t=this.bcsToBytes().slice(1);T.U8(t).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},M= exports.MoveOption =class n extends d{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new T([e]):this.vec=new T([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}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 n(e!=null?new F(e):void 0)}static U16(e){return new n(e!=null?new de(e):void 0)}static U32(e){return new n(e!=null?new le(e):void 0)}static U64(e){return new n(e!=null?new O(e):void 0)}static U128(e){return new n(e!=null?new ge(e):void 0)}static U256(e){return new n(e!=null?new me(e):void 0)}static Bool(e){return new n(e!=null?new I(e):void 0)}static MoveString(e){return new n(e!=null?new b(e):void 0)}static deserialize(e,t){let r=T.deserialize(e,t);return new n(r.values[0])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var ca=(a=>(a.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",a.INVALID_HEX_CHARS="invalid_hex_chars",a.TOO_SHORT="too_short",a.TOO_LONG="too_long",a.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",a.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",a.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",a))(ca||{}),x=class x extends d{constructor(e){if(super(),e.length!==x.LENGTH)throw new Y("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=_utils.bytesToHex.call(void 0, this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let t=e.deserializeFixedBytes(x.LENGTH);return new x(t)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new Y("Hex string must start with a leading 0x.","leading_zero_x_required");let t=x.fromString(e);if(e.length!==x.LONG_STRING_LENGTH+2)if(t.isSpecial()){if(e.length!==3)throw new Y(`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 Y(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return t}static fromString(e){let t=e;if(e.startsWith("0x")&&(t=e.slice(2)),t.length===0)throw new Y("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(t.length>64)throw new Y("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let r;try{r=_utils.hexToBytes.call(void 0, t.padStart(64,"0"))}catch(o){throw new Y(`Hex characters are invalid: ${_optionalChain([o, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}return new x(r)}static from(e){return e instanceof x?e:e instanceof Uint8Array?new x(e):x.fromString(e)}static fromStrict(e){return e instanceof x?e:e instanceof Uint8Array?new x(e):x.fromStringStrict(e)}static isValid(e){try{return e.strict?x.fromStrict(e.input):x.from(e.input),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _6 => _6.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _7 => _7.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,r)=>t===e.data[r])}};x.LENGTH=32,x.LONG_STRING_LENGTH=64,x.ZERO=x.from("0x0"),x.ONE=x.from("0x1"),x.TWO=x.from("0x2"),x.THREE=x.from("0x3"),x.FOUR=x.from("0x4");var u=x;var Ge=class Ge extends d{constructor(e){super();let{data:t}=e,r=l.fromHexInput(t);if(r.toUint8Array().length!==Ge.LENGTH)throw new Error(`Authentication Key length should be ${Ge.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(Ge.LENGTH);return new Ge({data:t})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:r}=e,o=l.fromHexInput(r).toUint8Array(),i=new Uint8Array([...o,t]),s=_sha3.sha3_256.create();s.update(i);let a=s.digest();return new Ge({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new u(this.data.toUint8Array())}};Ge.LENGTH=32;var q=Ge;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var xo = _interopRequireWildcard(_bip39);var la=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,ga= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,ma= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(ma||{}),_o= exports.HARDENED_OFFSET =2147483648;function vo(n){return ga.test(n)}function Po(n){return la.test(n)}var xr=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},Co= exports.CKDPriv =({key:n,chainCode:e},t)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,t);let o=new Uint8Array(r),i=new Uint8Array([0]),s=new Uint8Array([...i,...n,...o]);return xr(e,s)},ya=n=>n.replace("'",""),Eo= exports.splitPath =n=>n.split("/").slice(1).map(ya),En= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return xo.mnemonicToSeedSync(e)};var Je=class extends d{toString(){let e=this.toUint8Array();return l.fromHexInput(e).toString()}},ie= exports.AccountPublicKey =class extends Je{};var B=class extends d{toString(){let e=this.toUint8Array();return l.fromHexInput(e).toString()}};var mt=n=>typeof n=="string"?l.isValid(n).valid?n:Buffer.from(n,"utf8"):n;var Io=[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],et=class et extends ie{constructor(e){super();let t=l.fromHexInput(e);if(t.toUint8Array().length!==et.LENGTH)throw new Error(`PublicKey length should be ${et.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof v))return!1;let o=mt(t),i=l.fromHexInput(o).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return r.isCanonicalSignature()?_ed25519.ed25519.verify(s,i,a):!1}authKey(){return q.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new et(t)}static isPublicKey(e){return e instanceof et}};et.LENGTH=32;var _=et,se=class se extends d{constructor(e){super();let t=l.fromHexInput(e);if(t.toUint8Array().length!==se.LENGTH)throw new Error(`PrivateKey length should be ${se.LENGTH}`);this.signingKey=t}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new se(e)}static fromDerivationPath(e,t){if(!Po(e))throw new Error(`Invalid derivation path ${e}`);return se.fromDerivationPathInner(e,En(t))}static fromDerivationPathInner(e,t,r=_o){let{key:o,chainCode:i}=xr(se.SLIP_0010_SEED,t),s=Eo(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>Co(c,p+r),{key:o,chainCode:i});return new se(a)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new _(e)}sign(e){let t=mt(e),r=l.fromHexInput(t).toUint8Array(),o=_ed25519.ed25519.sign(r,this.signingKey.toUint8Array());return new v(o)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.signingKey.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new se(t)}static isPrivateKey(e){return e instanceof se}};se.LENGTH=32,se.SLIP_0010_SEED="ed25519 seed";var L=se,yt=class yt extends B{constructor(e){super();let t=l.fromHexInput(e);if(t.toUint8Array().length!==yt.LENGTH)throw new Error(`Signature length should be ${yt.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new yt(t)}isCanonicalSignature(){let e=this.toUint8Array().slice(32);for(let t=e.length-1;t>=0;t-=1){if(e[t]<Io[t])return!0;if(e[t]>Io[t])return!1}return!1}};yt.LENGTH=64;var v=yt;var ae=class ae extends ie{constructor(e){super();let{publicKeys:t,threshold:r}=e;if(t.length>ae.MAX_KEYS||t.length<ae.MIN_KEYS)throw new Error(`Must have between ${ae.MIN_KEYS} and ${ae.MAX_KEYS} public keys, inclusive`);if(r<ae.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${ae.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof tt))return!1;let o=[];for(let i=0;i<4;i+=1)for(let s=0;s<8;s+=1)if((r.bitmap[i]&1<<7-s)!==0){let c=i*8+s;o.push(c)}if(o.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(o.length<this.threshold)throw new Error("Not enough signatures");for(let i=0;i<o.length;i+=1)if(!this.publicKeys[o[i]].verifySignature({message:t,signature:r.signatures[i]}))return!1;return!0}authKey(){return q.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*_.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*_.LENGTH)}),e[this.publicKeys.length*_.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t[t.length-1],o=[];for(let i=0;i<t.length-1;i+=_.LENGTH){let s=i;o.push(new _(t.subarray(s,s+_.LENGTH)))}return new ae({publicKeys:o,threshold:r})}};ae.MAX_KEYS=32,ae.MIN_KEYS=2,ae.MIN_THRESHOLD=1;var ft=ae,J=class J extends B{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>J.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${J.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=J.createBitmap({bits:r});else{if(r.length!==J.BITMAP_LEN)throw new Error(`"bitmap" length should be ${J.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*v.LENGTH+J.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*v.LENGTH)}),e.set(this.bitmap,this.signatures.length*v.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t.subarray(t.length-4),o=[];for(let i=0;i<t.length-r.length;i+=v.LENGTH){let s=i;o.push(new v(t.subarray(s,s+v.LENGTH)))}return new J({signatures:o,bitmap:r})}static createBitmap(e){let{bits:t}=e,r=128,o=new Uint8Array([0,0,0,0]),i=new Set;return t.forEach((s,a)=>{if(s>=J.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${J.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");i.add(s);let c=Math.floor(s/8),p=o[c];p|=r>>s%8,o[c]=p}),o}};J.MAX_SIGNATURES_SUPPORTED=32,J.BITMAP_LEN=4;var tt=J;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var nt=class nt extends Je{constructor(e){super();let t=l.fromHexInput(e);if(t.toUint8Array().length!==nt.LENGTH)throw new Error(`PublicKey length should be ${nt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Pe))return!1;let o=mt(t),i=l.fromHexInput(o).toUint8Array(),s=_sha3.sha3_256.call(void 0, i),a=r.toUint8Array();return _secp256k1.secp256k1.verify(a,s,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new nt(t)}static isPublicKey(e){return e instanceof nt}};nt.LENGTH=65;var Te=nt,he=class he extends d{constructor(e){super();let t=l.fromHexInput(e);if(t.toUint8Array().length!==he.LENGTH)throw new Error(`PrivateKey length should be ${he.LENGTH}`);this.key=t}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new he(e)}static fromDerivationPath(e,t){if(!vo(e))throw new Error(`Invalid derivation path ${e}`);return he.fromDerivationPathInner(e,En(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new he(r)}sign(e){let t=mt(e),r=l.fromHexInput(t),o=_sha3.sha3_256.call(void 0, r.toUint8Array()),i=_secp256k1.secp256k1.sign(o,this.key.toUint8Array(),{lowS:!0});return new Pe(i.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Te(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new he(t)}static isPrivateKey(e){return e instanceof he}};he.LENGTH=32;var rt=he,At=class At extends B{constructor(e){super();let t=l.fromHexInput(e);if(t.toUint8Array().length!==At.LENGTH)throw new Error(`Signature length should be ${At.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new At(t)}};At.LENGTH=64;var Pe=At;var _jwtdecode = require('jwt-decode');var ot=class n extends Je{constructor(e){super();let t=e.constructor.name;switch(t){case _.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}toUint8Array(){return this.bcsToBytes()}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r})}serialize(e){if(this.publicKey instanceof _)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(_.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},be= exports.EphemeralSignature =class n extends B{constructor(e){super();let t=e.constructor.name;switch(t){case v.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}toUint8Array(){return this.bcsToBytes()}static fromHex(e){let t=l.fromHexInput(e),r=new oe(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof v)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(v.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _poseidonlite = require('poseidon-lite');var _r=[_poseidonlite.poseidon1,_poseidonlite.poseidon2,_poseidonlite.poseidon3,_poseidonlite.poseidon4,_poseidonlite.poseidon5,_poseidonlite.poseidon6,_poseidonlite.poseidon7,_poseidonlite.poseidon8,_poseidonlite.poseidon9,_poseidonlite.poseidon10,_poseidonlite.poseidon11,_poseidonlite.poseidon12,_poseidonlite.poseidon13,_poseidonlite.poseidon14,_poseidonlite.poseidon15,_poseidonlite.poseidon16],zo=31,Da=16,Ro=(Da-1)*zo;function Rn(n,e){let r=new TextEncoder().encode(n);return ka(r,e)}function ka(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=vr(n,e);return Lt(t)}function Ba(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);let t=Na(n,e);return Ga(t)}function vr(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);return Ba(n,e).concat([BigInt(n.length)])}function Ga(n){if(n.length>Ro)throw new Error(`Can't pack more than ${Ro}. Was given ${n.length} bytes`);return Ka(n,zo).map(e=>$t(e))}function Ka(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.subarray(r,r+e));return t}function $t(n){let e=BigInt(0);for(let t=n.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(n[t]);return e}function Do(n,e){let t=new Uint8Array(e);for(let r=0;r<e;r+=1)t[r]=Number(n&BigInt(255)),n>>=BigInt(8);return t}function Na(n,e){if(e<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(n);for(let r=n.length;r<e;r+=1)t[r]=0;return t}function Lt(n){if(n.length>_r.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${_r.length}`);return _r[n.length-1](n)}var zn=class extends d{toString(){let e=this.bcsToBytes();return l.fromHexInput(e).toString()}};var ye=class extends Error{constructor(e,t,r){super(r),this.name="AptosApiError",this.url=t.url,this.status=t.status,this.statusText=t.statusText,this.data=t.data,this.request=e}};var ko="1.22.2";var Bo={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Go= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},Ko= exports.NetworkToFaucetAPI ={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"},Pr= exports.NetworkToPepperAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},Cr= exports.NetworkToProverAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},Er= exports.Network =(i=>(i.MAINNET="mainnet",i.TESTNET="testnet",i.DEVNET="devnet",i.LOCAL="local",i.CUSTOM="custom",i))(Er||{}),Ir= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},wd= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var Ht=(i=>(i.FULLNODE="Fullnode",i.INDEXER="Indexer",i.FAUCET="Faucet",i.PEPPER="Pepper",i.PROVER="Prover",i))(Ht||{}),No= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,Oo= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Dn= exports.DEFAULT_TXN_TIMEOUT_SEC =20,kn= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Fo= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Ur= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",Ke= exports.ProcessorType =(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.OBJECT_PROCESSOR="objects_processor",c))(Ke||{});function Mo(n,e){let t=e.bcsToBytes(),r=new oe(t);return n.deserialize(r)}var qo={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 Oa(n,e){let{url:t,method:r,body:o,contentType:i,params:s,overrides:a,originMethod:c}=n,p={..._optionalChain([a, 'optionalAccess', _8 => _8.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${ko}`,"content-type":_nullishCoalesce(i, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _9 => _9.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _10 => _10.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _11 => _11.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _12 => _12.API_KEY])}`),e.provider({url:t,method:r,body:o,params:s,headers:p,overrides:a})}async function Bn(n,e,t){let{url:r,path:o}=n,i=o?`${r}/${o}`:r,s=await Oa({...n,url:i},e.client),a={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:i};if(a.status===401)throw new ye(n,a,`Error: ${a.data}`);if(t==="Indexer"){let p=a.data;if(p.errors)throw new ye(n,a,_nullishCoalesce(`Indexer error: ${p.errors[0].message}`, () => (`Indexer unhandled Error ${s.status} : ${s.statusText}`)));a.data=p.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new ye(n,a,`${s.data}`);if(a.status>=200&&a.status<300)return a;let c;throw a&&a.data&&"message"in a.data&&"error_code"in a.data?c=JSON.stringify(a.data):a.status in qo?c=qo[a.status]:c=`Unhandled Error ${a.status} : ${a.statusText}`,new ye(n,a,`${t} error: ${c}`)}async function Rr(n){let{aptosConfig:e,overrides:t,params:r,contentType:o,acceptType:i,path:s,originMethod:a,type:c}=n,p=e.getRequestUrl(c);return Bn({url:p,method:"GET",originMethod:a,path:s,contentType:o,acceptType:i,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function V(n){let{aptosConfig:e}=n;return Rr({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _13 => _13.clientConfig, 'optionalAccess', _14 => _14.HEADERS]),..._optionalChain([e, 'access', _15 => _15.fullnodeConfig, 'optionalAccess', _16 => _16.HEADERS])}}})}async function $d(n){return Rr({...n,type:"Pepper"})}async function ht(n){let e=[],t,r=n.params;do{let o=await Rr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});t=o.headers["x-aptos-cursor"],delete o.headers,e.push(...o.data),r.start=t}while(t!=null);return e}async function Qt(n){let{type:e,originMethod:t,path:r,body:o,acceptType:i,contentType:s,params:a,aptosConfig:c,overrides:p}=n,y=c.getRequestUrl(e);return Bn({url:y,method:"POST",originMethod:t,path:r,body:o,contentType:s,acceptType:i,params:a,overrides:p},c,n.type)}async function Ne(n){let{aptosConfig:e}=n;return Qt({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _17 => _17.clientConfig, 'optionalAccess', _18 => _18.HEADERS]),..._optionalChain([e, 'access', _19 => _19.fullnodeConfig, 'optionalAccess', _20 => _20.HEADERS])}}})}async function Vo(n){let{aptosConfig:e}=n;return Qt({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _21 => _21.clientConfig, 'optionalAccess', _22 => _22.HEADERS]),..._optionalChain([e, 'access', _23 => _23.indexerConfig, 'optionalAccess', _24 => _24.HEADERS])}}})}async function $o(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _25 => _25.clientConfig, 'optionalAccess', _26 => delete _26.API_KEY]),Qt({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _27 => _27.clientConfig, 'optionalAccess', _28 => _28.HEADERS]),..._optionalChain([t, 'access', _29 => _29.faucetConfig, 'optionalAccess', _30 => _30.HEADERS])}}})}async function Lo(n){return Qt({...n,type:"Pepper"})}async function Ho(n){return Qt({...n,type:"Prover"})}var zr=new Map;function Oe(n,e,t){return async(...r)=>{if(zr.has(e)){let{value:i,timestamp:s}=zr.get(e);if(t===void 0||Date.now()-s<=t)return i}let o=await n(...r);return zr.set(e,{value:o,timestamp:Date.now()}),o}}var bl=1e7,Ma= exports.MAX_AUD_VAL_BYTES =120,qa= exports.MAX_UID_KEY_BYTES =30,Va= exports.MAX_UID_VAL_BYTES =330,wl= exports.MAX_ISS_VAL_BYTES =120,Sl= exports.MAX_EXTRA_FIELD_BYTES =350,xl= exports.MAX_JWT_HEADER_B64_BYTES =300,_l= exports.MAX_COMMITED_EPK_BYTES =93,we=class we extends ie{constructor(e,t){super();let r=l.fromHexInput(t).toUint8Array();if(r.length!==we.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${we.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new Z;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),q.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}toString(){return l.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new we(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new we(t,r)}static isPublicKey(e){return e instanceof we}static create(e){return Qo(e),new we(e.iss,Qo(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:o="sub"}=e,i=_jwtdecode.jwtDecode.call(void 0, t),s=i.iss;if(typeof i.aud!="string")throw new Error("aud was not found or an array of values");let a=i.aud,c=i[o];return we.create({iss:s,uidKey:o,uidVal:c,aud:a,pepper:r})}};we.ID_COMMITMENT_LENGTH=32;var ee=we;function Qo(n){let{uidKey:e,uidVal:t,aud:r,pepper:o}=n,i=[$t(l.fromHexInput(o).toUint8Array()),Rn(r,Ma),Rn(t,Va),Rn(e,qa)];return Do(Lt(i),ee.ID_COMMITMENT_LENGTH)}var Ee=class n extends B{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:r,expiryDateSecs:o,ephemeralPublicKey:i,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=r,this.expiryDateSecs=o,this.ephemeralPublicKey=i,this.ephemeralSignature=s}toUint8Array(){return this.bcsToBytes()}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=Tt.deserialize(e),r=e.deserializeStr(),o=e.deserializeU64(),i=ot.deserialize(e),s=be.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(o),ephemeralCertificate:t,ephemeralPublicKey:i,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new Tt(new Ie({proof:new wt(new bt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new ot(new _(new Uint8Array(32))),ephemeralSignature:new be(new v(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},Tt= exports.EphemeralCertificate =class n extends B{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(Ie.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},Ce=class n extends d{constructor(e){if(super(),this.data=l.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new n(t)}},it=class n extends d{constructor(e){if(super(),this.data=l.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new n(t)}},bt= exports.Groth16Zkp =class n extends zn{constructor(e){super();let{a:t,b:r,c:o}=e;this.a=new Ce(t),this.b=new it(r),this.c=new Ce(o)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=Ce.deserialize(e).bcsToBytes(),r=it.deserialize(e).bcsToBytes(),o=Ce.deserialize(e).bcsToBytes();return new n({a:t,b:r,c:o})}},wt= exports.ZkProof =class n extends d{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(bt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},Ie= exports.ZeroKnowledgeSig =class n extends B{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:o,extraField:i,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=o,this.extraField=i,this.overrideAudVal=s}toUint8Array(){return this.bcsToBytes()}static fromBytes(e){return n.deserialize(new oe(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOptionStr(this.extraField),e.serializeOptionStr(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=wt.deserialize(e),r=Number(e.deserializeU64()),o=e.deserializeOptionStr(),i=e.deserializeOptionStr(),s=e.deserializeOption(be);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:o,overrideAudVal:i})}},Dr= exports.KeylessConfiguration =class n{constructor(e,t){this.verficationKey=e,this.maxExpHorizonSecs=t}static create(e,t){return new n(new kr({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),t)}},kr=class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:o,gammaAbcG1:i,gammaG2:s}=e;this.alphaG1=new Ce(t),this.betaG2=new it(r),this.deltaG2=new it(o),this.gammaAbcG1=[new Ce(i[0]),new Ce(i[1])],this.gammaG2=new it(s)}static fromGroth16VerificationKeyResponse(e){return new n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}};async function Wo(n){let{aptosConfig:e}=n;return Oe(async()=>{let t=await $a(n),r=await La(n);return Dr.create(r,Number(t.max_exp_horizon_secs))},`keyless-configuration-${e.network}`,1e3*60*5)()}async function $a(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration",{data:o}=await V({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${u.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _31 => _31.ledgerVersion])}});return o.data}async function La(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey",{data:o}=await V({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${u.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _32 => _32.ledgerVersion])}});return o.data}var k=class n extends ie{constructor(e){if(super(),this.publicKey=e,e instanceof _)this.variant=0;else if(e instanceof Te)this.variant=1;else if(e instanceof ee)this.variant=3;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;return r instanceof G?this.publicKey.verifySignature({message:t,signature:r.signature}):!1}authKey(){return q.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=_.deserialize(e);break;case 1:r=Te.deserialize(e);break;case 3:r=ee.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new n(r)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof _}isSecp256k1PublicKey(){return this.publicKey instanceof Te}},G= exports.AnySignature =class n extends B{constructor(e){if(super(),this.signature=e,e instanceof v)this.variant=0;else if(e instanceof Pe)this.variant=1;else if(e instanceof Ee)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=v.deserialize(e);break;case 1:r=Pe.deserialize(e);break;case 3:r=Ee.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new n(r)}};function Ha(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var St=class n extends ie{constructor(e){super();let{publicKeys:t,signaturesRequired:r}=e;if(r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);this.publicKeys=t.map(o=>o instanceof k?o:new k(o)),this.signaturesRequired=r}verifySignature(e){throw new Error("not implemented")}authKey(){return q.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(k),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}createBitmap(e){let{bits:t}=e,r=128,o=new Uint8Array([0,0,0,0]),i=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(i.has(s))throw new Error(`Duplicate bit ${s} detected.`);i.add(s);let c=Math.floor(s/8),p=o[c];p|=r>>s%8,o[c]=p}),o}getIndex(e){let t=e instanceof k?e:new k(e),r=this.publicKeys.findIndex(o=>o.toString()===t.toString());if(r!==-1)return r;throw new Error("Public key not found in MultiKey")}},te=class te extends B{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>te.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${te.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(i=>i instanceof G?i:new G(i)),!(r instanceof Uint8Array))this.bitmap=te.createBitmap({bits:r});else{if(r.length!==te.BITMAP_LEN)throw new Error(`"bitmap" length should be ${te.BITMAP_LEN}`);this.bitmap=r}let o=this.bitmap.reduce((i,s)=>i+Ha(s),0);if(o!==this.signatures.length)throw new Error(`Expecting ${o} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:t}=e,r=128,o=new Uint8Array([0,0,0,0]),i=new Set;return t.forEach(s=>{if(s>=te.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${te.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(s))throw new Error("Duplicate bits detected.");i.add(s);let a=Math.floor(s/8),c=o[a];c|=r>>s%8,o[a]=c}),o}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(G),r=e.deserializeBytes();return new te({signatures:t,bitmap:r})}};te.BITMAP_LEN=4,te.MAX_SIGNATURES_SUPPORTED=te.BITMAP_LEN*8;var st=te;var H=class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return fe.load(e);case 1:return Gn.load(e);case 2:return Q.load(e);case 3:return at.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof fe}isMultiEd25519(){return this instanceof Gn}isSingleKey(){return this instanceof Q}isMultiKey(){return this instanceof at}},fe= exports.AccountAuthenticatorEd25519 =class n extends H{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=_.deserialize(e),r=v.deserialize(e);return new n(t,r)}},Gn= exports.AccountAuthenticatorMultiEd25519 =class n extends H{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=ft.deserialize(e),r=tt.deserialize(e);return new n(t,r)}},Q= exports.AccountAuthenticatorSingleKey =class n extends H{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=k.deserialize(e),r=G.deserialize(e);return new n(t,r)}},at= exports.AccountAuthenticatorMultiKey =class n extends H{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=St.deserialize(e),r=st.deserialize(e);return new n(t,r)}};var xt=class n extends d{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new n(t)}};var R=class n extends d{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var Qa=(n,e)=>{let t=n.bcsToBytes(),r=typeof e=="string"?Buffer.from(e,"utf8"):e,o=new Uint8Array([...t,...r,254]);return new u(_sha3.sha3_256.call(void 0, o))},bg= exports.createResourceAddress =(n,e)=>{let t=n.bcsToBytes(),r=typeof e=="string"?Buffer.from(e,"utf8"):e,o=new Uint8Array([...t,...r,255]);return new u(_sha3.sha3_256.call(void 0, o))},wg= exports.createTokenAddress =(n,e,t)=>{let r=`${e}::${t}`;return Qa(n,r)};var Wt=class n extends d{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new n(u.fromString(t[0]),new R(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=R.deserialize(e);return new n(t,r)}};var z=class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return K.load(e);case 1:return ce.load(e);case 2:return $.load(e);case 3:return qe.load(e);case 4:return W.load(e);case 5:return _t.load(e);case 6:return C.load(e);case 7:return m.load(e);case 8:return Fe.load(e);case 9:return Me.load(e);case 10:return Ve.load(e);case 255:return D.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof K}isAddress(){return this instanceof W}isGeneric(){return this instanceof D}isSigner(){return this instanceof _t}isVector(){return this instanceof C}isStruct(){return this instanceof m}isU8(){return this instanceof ce}isU16(){return this instanceof Fe}isU32(){return this instanceof Me}isU64(){return this instanceof $}isU128(){return this instanceof qe}isU256(){return this instanceof Ve}},K= exports.TypeTagBool =class n extends z{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},ce= exports.TypeTagU8 =class n extends z{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},Fe= exports.TypeTagU16 =class n extends z{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},Me= exports.TypeTagU32 =class n extends z{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},$= exports.TypeTagU64 =class n extends z{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},qe= exports.TypeTagU128 =class n extends z{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},Ve= exports.TypeTagU256 =class n extends z{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},W= exports.TypeTagAddress =class n extends z{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},_t= exports.TypeTagSigner =class n extends z{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},Kn= exports.TypeTagReference =class n extends z{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=z.deserialize(t);return new n(r)}},D= exports.TypeTagGeneric =class n extends z{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let r=t.deserializeU32();return new n(r)}},C= exports.TypeTagVector =class n extends z{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new ce)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=z.deserialize(t);return new n(r)}},m= exports.TypeTagStruct =class n extends z{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${t}`}serialize(t){t.serializeU32AsUleb128(7),this.value.serialize(t)}static load(t){let r=Ue.deserialize(t);return new n(r)}isTypeTag(t,r,o){return this.value.moduleName.identifier===r&&this.value.name.identifier===o&&this.value.address.equals(t)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}},Ue= exports.StructTag =class n extends d{constructor(e,t,r,o){super(),this.address=e,this.moduleName=t,this.name=r,this.typeArgs=o}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=u.deserialize(e),r=R.deserialize(e),o=R.deserialize(e),i=e.deserializeVector(z);return new n(t,r,o,i)}};function $g(){return new Ue(u.ONE,new R("aptos_coin"),new R("AptosCoin"),[])}function P(){return new Ue(u.ONE,new R("string"),new R("String"),[])}function Lg(n){return new Ue(u.ONE,new R("option"),new R("Option"),[n])}function ne(n){return new Ue(u.ONE,new R("object"),new R("Object"),[n])}function Wa(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return F.deserialize(n);case 1:return O.deserialize(n);case 2:return ge.deserialize(n);case 3:return u.deserialize(n);case 4:return T.deserialize(n,F);case 5:return I.deserialize(n);case 6:return de.deserialize(n);case 7:return le.deserialize(n);case 8:return me.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var ct=class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return jt.load(e);case 2:return Xt.load(e);case 3:return Yt.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},jt= exports.TransactionPayloadScript =class n extends ct{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=Zt.deserialize(e);return new n(t)}},Xt= exports.TransactionPayloadEntryFunction =class n extends ct{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=ut.deserialize(e);return new n(t)}},Yt= exports.TransactionPayloadMultiSig =class n extends ct{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Jt.deserialize(e);return new n(t)}},ut= exports.EntryFunction =class n{constructor(e,t,r,o){this.module_name=e,this.function_name=t,this.type_args=r,this.args=o}static build(e,t,r,o){return new n(Wt.fromStr(e),new R(t),r,o)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=Wt.deserialize(e),r=R.deserialize(e),o=e.deserializeVector(z),i=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<i;a+=1){let c=e.deserializeUleb128AsU32(),p=Pn.deserialize(e,c);s.push(p)}return new n(t,r,o,s)}},Zt= exports.Script =class n{constructor(e,t,r){this.bytecode=e,this.type_args=t,this.args=r}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),r=e.deserializeVector(z),o=e.deserializeUleb128AsU32(),i=new Array;for(let s=0;s<o;s+=1){let a=Wa(e);i.push(a)}return new n(t,r,i)}},Jt= exports.MultiSig =class n{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=u.deserialize(e),r=e.deserializeBool(),o;return r&&(o=en.deserialize(e)),new n(t,o)}},en= exports.MultiSigTransactionPayload =class n extends d{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new n(ut.deserialize(e))}};var ue=class n extends d{constructor(e,t,r,o,i,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,this.max_gas_amount=o,this.gas_unit_price=i,this.expiration_timestamp_secs=s,this.chain_id=a}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 t=u.deserialize(e),r=e.deserializeU64(),o=ct.deserialize(e),i=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=xt.deserialize(e);return new n(t,r,o,i,s,a,c)}},Nn= exports.RawTransactionWithData =class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return pt.load(e);case 1:return dt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},pt= exports.MultiAgentRawTransaction =class n extends Nn{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=ue.deserialize(e),r=e.deserializeVector(u);return new n(t,r)}},dt= exports.FeePayerRawTransaction =class n extends Nn{constructor(e,t,r){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=r}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 t=ue.deserialize(e),r=e.deserializeVector(u),o=u.deserialize(e);return new n(t,r,o)}};var On=class extends d{constructor(t){super();this.accountAddress=u.ONE;this.moduleName=new b("account");this.structName=new b("RotationProofChallenge");this.sequenceNumber=new O(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=T.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var Re=class extends d{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return vt.load(e);case 1:return Br.load(e);case 2:return Pt.load(e);case 3:return Ct.load(e);case 4:return Et.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}},vt= exports.TransactionAuthenticatorEd25519 =class n extends Re{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=_.deserialize(e),r=v.deserialize(e);return new n(t,r)}},Br= exports.TransactionAuthenticatorMultiEd25519 =class n extends Re{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=ft.deserialize(e),r=tt.deserialize(e);return new n(t,r)}},Pt= exports.TransactionAuthenticatorMultiAgent =class n extends Re{constructor(e,t,r){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let t=H.deserialize(e),r=e.deserializeVector(u),o=e.deserializeVector(H);return new n(t,r,o)}},Ct= exports.TransactionAuthenticatorFeePayer =class n extends Re{constructor(e,t,r,o){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r,this.fee_payer=o}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 t=H.deserialize(e),r=e.deserializeVector(u),o=e.deserializeVector(H),i=u.deserialize(e),s=H.deserialize(e),a={address:i,authenticator:s};return new n(t,r,o,a)}},Et= exports.TransactionAuthenticatorSingleSender =class n extends Re{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=H.deserialize(e);return new n(t)}};var lt=class n extends d{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=ue.deserialize(e),r=Re.deserialize(e);return new n(t,r)}};var Fn=class n extends d{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=ue.deserialize(e),r=e.deserializeBool(),o;return r&&(o=u.deserialize(e)),new n(t,o)}};var Mn=class n extends d{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=ue.deserialize(e),r=e.deserializeVector(u),o=e.deserializeBool(),i;return o&&(i=u.deserialize(e)),new n(t,r,i)}};function Gr(n){return n.feePayerAddress?new dt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new pt(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function It(n,e){let t=_sha3.sha3_256.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let r=t.digest(),o=n,i=new Uint8Array(r.length+o.length);return i.set(r),i.set(o,r.length),i}function ny(n){return It(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Ut(n){let e=Gr(n);return n.feePayerAddress?It(e.bcsToBytes(),Ur):n.secondarySignerAddresses?It(e.bcsToBytes(),Ur):It(e.bcsToBytes(),Fo)}var Rt=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=L.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,o=L.fromDerivationPath(t,r);return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new fe(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new fe(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Ut(e))}};var zt=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new k(t.publicKey()),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=L.generate();break;case 2:r=rt.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:o}=e,i;switch(t){case 0:i=L.fromDerivationPath(r,o);break;case 2:i=rt.fromDerivationPath(r,o);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new Q(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Q(this.publicKey,this.signTransaction(e))}sign(e){return new G(this.privateKey.sign(e))}signTransaction(e){return this.sign(Ut(e))}};var $e=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?Rt.generate():zt.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:o=!0}=e;return t instanceof L&&o?new Rt({privateKey:t,address:r}):new zt({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:r,path:o,legacy:i=!0}=e;return t===0&&i?Rt.fromDerivationPath({mnemonic:r,path:o}):zt.fromDerivationPath({scheme:t,mnemonic:r,path:o})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}};var Ya=1209600,Dt=class Dt extends d{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:o}=e;this.privateKey=t,this.publicKey=new ot(t.publicKey()),this.expiryDateSecs=r||_chunkBHKSQXUZjs.d.call(void 0, _chunkBHKSQXUZjs.c.call(void 0, )+Ya),this.blinder=o!==void 0?l.fromHexInput(o).toUint8Array():Za();let i=vr(this.publicKey.bcsToBytes(),93);i.push(BigInt(this.expiryDateSecs)),i.push($t(this.blinder));let s=Lt(i);this.nonce=s.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=L.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let o=e.deserializeU64(),i=e.deserializeFixedBytes(31);return new Dt({privateKey:r,expiryDateSecs:Number(o),blinder:i})}static fromBytes(e){return Dt.deserialize(new oe(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _33 => _33.scheme])){case 0:default:t=L.generate()}return new Dt({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _34 => _34.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new be(this.privateKey.sign(e))}};Dt.BLINDER_LENGTH=31;var tn=Dt;function Za(){return _utils.randomBytes.call(void 0, tn.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);var Le=class Le extends d{constructor(e){super();let{address:t,ephemeralKeyPair:r,uidKey:o,uidVal:i,aud:s,pepper:a,proof:c,proofFetchCallback:p,jwt:y}=e;if(this.ephemeralKeyPair=r,this.publicKey=ee.create(e),this.accountAddress=t?u.from(t):this.publicKey.authKey().derivedAddress(),this.uidKey=o,this.uidVal=i,this.aud=s,this.jwt=y,this.emitter=new _eventemitter32.default,this.proofOrPromise=c,c instanceof Ie)this.proof=c;else{if(p===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async S=>{await p(S),this.emitter.removeAllListeners()}),this.init(c)}this.signingScheme=2;let w=l.fromHexInput(a).toUint8Array();if(w.length!==Le.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${Le.PEPPER_LENGTH}`);this.pepper=w}async init(e){try{this.proof=await e,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(t){t instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:t.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(e){if(e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),this.proof===void 0)throw new Error("Connot serialize - proof undefined");this.proof.serialize(e)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeStr(),o=e.deserializeFixedBytes(31),i=tn.deserialize(e),s=Ie.deserialize(e);return Le.create({proof:s,pepper:o,uidKey:r,jwt:t,ephemeralKeyPair:i})}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(e){let t=new G(this.sign(e)),r=new k(this.publicKey);return new Q(r,t)}signTransactionWithAuthenticator(e){let t=new G(this.signTransaction(e)),r=new k(this.publicKey);return new Q(r,t)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}sign(e){let{expiryDateSecs:t}=this.ephemeralKeyPair;if(this.isExpired())throw new Error("EphemeralKeyPair is expired");if(this.proof===void 0)throw new Error("Proof not defined");let r=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(e);return new Ee({jwtHeader:_chunkBHKSQXUZjs.e.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new Tt(this.proof,0),expiryDateSecs:t,ephemeralPublicKey:r,ephemeralSignature:o})}signTransaction(e){if(this.proof===void 0)throw new Error("Proof not found");let t=Gr(e),o=new Kr(t,this.proof.proof).hash();return this.sign(o)}verifySignature(e){throw new Error("Not implemented")}static fromBytes(e){return Le.deserialize(new oe(e))}static create(e){let{address:t,proof:r,jwt:o,ephemeralKeyPair:i,pepper:s,uidKey:a="sub",proofFetchCallback:c}=e,p=_jwtdecode.jwtDecode.call(void 0, o),y=p.iss;if(typeof p.aud!="string")throw new Error("aud was not found or an array of values");let w=p.aud,S=p[a];return new Le({address:t,proof:r,ephemeralKeyPair:i,iss:y,uidKey:a,uidVal:S,aud:w,pepper:s,jwt:o,proofFetchCallback:c})}};Le.PEPPER_LENGTH=31;var Se=Le,Kr=class extends d{constructor(t,r){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=r}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return It(this.bcsToBytes(),this.domainSeparator)}};var qn=class n{constructor(e){let{multiKey:t,signers:r}=e;this.publicKey=t,this.signingScheme=3,this.accountAddress=this.publicKey.authKey().derivedAddress();let o=[];for(let s of r)o.push(this.publicKey.getIndex(s.publicKey));let i=r.map((s,a)=>[s,o[a]]);i.sort((s,a)=>s[1]-a[1]),this.signers=i.map(s=>s[0]),this.signerIndicies=i.map(s=>s[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{publicKeys:t,signaturesRequired:r,signers:o}=e,i=new St({publicKeys:t,signaturesRequired:r});return new n({multiKey:i,signers:o})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new at(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new at(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof Se).map(async r=>r.waitForProofFetch());await Promise.all(t)}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new st({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new st({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){let{message:t,signature:r}=e;if(!this.signerIndicies.every((i,s)=>s===0||i>=this.signerIndicies[s-1]))return!1;for(let i=0;i<r.signatures.length;i+=1){let s=r.signatures[i];if(!this.publicKey.publicKeys[this.signerIndicies[i]].verifySignature({message:t,signature:s}))return!1}return!0}};var tc=`
2
2
  fragment TokenActivitiesFields on token_activities_v2 {
3
3
  after_value
4
4
  before_value
@@ -16,7 +16,7 @@
16
16
  transaction_version
17
17
  type
18
18
  }
19
- `,ec=`
19
+ `,nc=`
20
20
  fragment AnsTokenFragment on current_aptos_names {
21
21
  domain
22
22
  expiration_timestamp
@@ -73,7 +73,7 @@
73
73
  }
74
74
  }
75
75
  }
76
- `,Wo=`
76
+ `,Xo=`
77
77
  query getAccountCoinsCount($address: String) {
78
78
  current_fungible_asset_balances_aggregate(
79
79
  where: {owner_address: {_eq: $address}}
@@ -83,7 +83,7 @@
83
83
  }
84
84
  }
85
85
  }
86
- `,jo=`
86
+ `,Yo=`
87
87
  query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {
88
88
  current_fungible_asset_balances(
89
89
  where: $where_condition
@@ -116,7 +116,7 @@
116
116
  }
117
117
  }
118
118
  }
119
- `,Xo=`
119
+ `,Zo=`
120
120
  query getAccountCollectionsWithOwnedTokens($where_condition: current_collection_ownership_v2_view_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_collection_ownership_v2_view_order_by!]) {
121
121
  current_collection_ownership_v2_view(
122
122
  where: $where_condition
@@ -150,7 +150,7 @@
150
150
  single_token_uri
151
151
  }
152
152
  }
153
- `,Yo=`
153
+ `,Jo=`
154
154
  query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
155
155
  current_token_ownerships_v2(
156
156
  where: $where_condition
@@ -161,7 +161,7 @@
161
161
  ...CurrentTokenOwnershipFields
162
162
  }
163
163
  }
164
- ${Vn}`,uf=`
164
+ ${Vn}`,Sf=`
165
165
  query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
166
166
  current_token_ownerships_v2(
167
167
  where: $where_condition
@@ -172,7 +172,7 @@
172
172
  ...CurrentTokenOwnershipFields
173
173
  }
174
174
  }
175
- ${Vn}`,Zo=`
175
+ ${Vn}`,ei=`
176
176
  query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
177
177
  current_token_ownerships_v2(
178
178
  where: $where_condition
@@ -183,7 +183,7 @@
183
183
  ...CurrentTokenOwnershipFields
184
184
  }
185
185
  }
186
- ${Vn}`,Jo=`
186
+ ${Vn}`,ti=`
187
187
  query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {
188
188
  current_token_ownerships_v2_aggregate(
189
189
  where: $where_condition
@@ -195,7 +195,7 @@
195
195
  }
196
196
  }
197
197
  }
198
- `,ei=`
198
+ `,ni=`
199
199
  query getAccountTransactionsCount($address: String) {
200
200
  account_transactions_aggregate(where: {account_address: {_eq: $address}}) {
201
201
  aggregate {
@@ -203,13 +203,13 @@
203
203
  }
204
204
  }
205
205
  }
206
- `,ti=`
206
+ `,ri=`
207
207
  query getChainTopUserTransactions($limit: Int) {
208
208
  user_transactions(limit: $limit, order_by: {version: desc}) {
209
209
  version
210
210
  }
211
211
  }
212
- `,ni=`
212
+ `,oi=`
213
213
  query getCollectionData($where_condition: current_collections_v2_bool_exp!) {
214
214
  current_collections_v2(where: $where_condition) {
215
215
  uri
@@ -239,7 +239,7 @@
239
239
  }
240
240
  }
241
241
  }
242
- `,ri=`
242
+ `,ii=`
243
243
  query getCurrentFungibleAssetBalances($where_condition: current_fungible_asset_balances_bool_exp, $offset: Int, $limit: Int) {
244
244
  current_fungible_asset_balances(
245
245
  where: $where_condition
@@ -257,7 +257,7 @@
257
257
  token_standard
258
258
  }
259
259
  }
260
- `,oi=`
260
+ `,si=`
261
261
  query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {
262
262
  delegated_staking_activities(
263
263
  where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}
@@ -270,7 +270,7 @@
270
270
  transaction_version
271
271
  }
272
272
  }
273
- `,ii=`
273
+ `,ai=`
274
274
  query getEvents($where_condition: events_bool_exp, $offset: Int, $limit: Int, $order_by: [events_order_by!]) {
275
275
  events(
276
276
  where: $where_condition
@@ -289,7 +289,7 @@
289
289
  indexed_type
290
290
  }
291
291
  }
292
- `,si=`
292
+ `,ci=`
293
293
  query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {
294
294
  fungible_asset_activities(
295
295
  where: $where_condition
@@ -314,7 +314,7 @@
314
314
  type
315
315
  }
316
316
  }
317
- `,ai=`
317
+ `,ui=`
318
318
  query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {
319
319
  fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {
320
320
  icon_uri
@@ -344,7 +344,7 @@
344
344
  ...AnsTokenFragment
345
345
  }
346
346
  }
347
- ${ec}`,Nr=`
347
+ ${nc}`,Nr=`
348
348
  query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {
349
349
  num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
350
350
  num_active_delegator
@@ -376,7 +376,7 @@
376
376
  last_updated
377
377
  }
378
378
  }
379
- `,ci=`
379
+ `,pi=`
380
380
  query getTableItemsData($where_condition: table_items_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_items_order_by!]) {
381
381
  table_items(
382
382
  where: $where_condition
@@ -392,7 +392,7 @@
392
392
  write_set_change_index
393
393
  }
394
394
  }
395
- `,ui=`
395
+ `,di=`
396
396
  query getTableItemsMetadata($where_condition: table_metadatas_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_metadatas_order_by!]) {
397
397
  table_metadatas(
398
398
  where: $where_condition
@@ -405,7 +405,7 @@
405
405
  value_type
406
406
  }
407
407
  }
408
- `,pi=`
408
+ `,li=`
409
409
  query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {
410
410
  token_activities_v2(
411
411
  where: $where_condition
@@ -416,7 +416,7 @@
416
416
  ...TokenActivitiesFields
417
417
  }
418
418
  }
419
- ${Ja}`,Fr=`
419
+ ${tc}`,Fr=`
420
420
  query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
421
421
  current_token_ownerships_v2(
422
422
  where: $where_condition
@@ -427,7 +427,7 @@
427
427
  ...CurrentTokenOwnershipFields
428
428
  }
429
429
  }
430
- ${Vn}`,di=`
430
+ ${Vn}`,gi=`
431
431
  query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {
432
432
  current_token_datas_v2(
433
433
  where: $where_condition
@@ -467,5 +467,5 @@
467
467
  }
468
468
  }
469
469
  }
470
- `;async function Ln(n){let{aptosConfig:e}=n,{data:t}=await V({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function li(n){let{aptosConfig:e,limit:t}=n;return(await f({aptosConfig:e,query:{query:ti,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function f(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:o}=await qo({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return o}async function tc(n){let{aptosConfig:e}=n;return(await f({aptosConfig:e,query:{query:Or},originMethod:"getProcessorStatuses"})).processor_status}async function Hn(n){let e=await tc({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function Qn(n){let{aptosConfig:e,processorType:t}=n;return(await f({aptosConfig:e,query:{query:Or,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function Wn(n){let{aptosConfig:e,handle:t,data:r,options:o}=n;return(await Ne({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _35 => _35.ledgerVersion])},body:r})).data}async function gi(n){let{aptosConfig:e,options:t}=n,r={query:ci,variables:{where_condition:_optionalChain([t, 'optionalAccess', _36 => _36.where]),offset:_optionalChain([t, 'optionalAccess', _37 => _37.offset]),limit:_optionalChain([t, 'optionalAccess', _38 => _38.limit]),order_by:_optionalChain([t, 'optionalAccess', _39 => _39.orderBy])}};return(await f({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function mi(n){let{aptosConfig:e,options:t}=n,r={query:ui,variables:{where_condition:_optionalChain([t, 'optionalAccess', _40 => _40.where]),offset:_optionalChain([t, 'optionalAccess', _41 => _41.offset]),limit:_optionalChain([t, 'optionalAccess', _42 => _42.limit]),order_by:_optionalChain([t, 'optionalAccess', _43 => _43.orderBy])}};return(await f({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function xe(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getInfo",path:`accounts/${u.from(t).toString()}`});return r}async function Ai(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ht({aptosConfig:e,originMethod:"getModules",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _44 => _44.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _45 => _45.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _46 => _46.limit]), () => (1e3))}})}async function jn(n){return _optionalChain([n, 'access', _47 => _47.options, 'optionalAccess', _48 => _48.ledgerVersion])!==void 0?yi(n):Oe(async()=>yi(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function yi(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:o}=n,{data:i}=await V({aptosConfig:e,originMethod:"getModule",path:`accounts/${u.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _49 => _49.ledgerVersion])}});return i}async function hi(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ht({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${u.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _50 => _50.offset]),limit:_optionalChain([r, 'optionalAccess', _51 => _51.limit])}})}async function Ti(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ht({aptosConfig:e,originMethod:"getResources",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _52 => _52.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _53 => _53.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _54 => _54.limit]), () => (999))}})}async function Mr(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:o}=n,{data:i}=await V({aptosConfig:e,originMethod:"getResource",path:`accounts/${u.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _55 => _55.ledgerVersion])}});return i.data}async function nn(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,o=await Mr({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:i}}=o,s=u.from(t);try{let a=await Wn({aptosConfig:e,handle:i,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof ye&&a.data.error_code==="table_item_not_found")return s;throw a}}async function bi(n){let{aptosConfig:e,accountAddress:t}=n,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},s=await f({aptosConfig:e,query:{query:Jo,variables:{where_condition:o}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function wi(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _56 => _56.tokenStandard])&&(i.token_standard={_eq:_optionalChain([r, 'optionalAccess', _57 => _57.tokenStandard])});let s={query:Yo,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _58 => _58.offset]),limit:_optionalChain([r, 'optionalAccess', _59 => _59.limit]),order_by:_optionalChain([r, 'optionalAccess', _60 => _60.orderBy])}};return(await f({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Si(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:o}=n,i=u.from(t).toStringLong(),s=u.from(r).toStringLong(),a={owner_address:{_eq:i},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([o, 'optionalAccess', _61 => _61.tokenStandard])&&(a.token_standard={_eq:_optionalChain([o, 'optionalAccess', _62 => _62.tokenStandard])});let c={query:Zo,variables:{where_condition:a,offset:_optionalChain([o, 'optionalAccess', _63 => _63.offset]),limit:_optionalChain([o, 'optionalAccess', _64 => _64.limit]),order_by:_optionalChain([o, 'optionalAccess', _65 => _65.orderBy])}};return(await f({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function xi(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _66 => _66.tokenStandard])&&(i.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _67 => _67.tokenStandard])}});let s={query:Xo,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _68 => _68.offset]),limit:_optionalChain([r, 'optionalAccess', _69 => _69.limit]),order_by:_optionalChain([r, 'optionalAccess', _70 => _70.orderBy])}};return(await f({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function _i(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),i=await f({aptosConfig:e,query:{query:ei,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return i.account_transactions_aggregate.aggregate?i.account_transactions_aggregate.aggregate.count:0}async function vi(n){let{aptosConfig:e,accountAddress:t,coinType:r}=n,o=u.from(t).toStringLong(),i=await qr({aptosConfig:e,accountAddress:o,options:{where:{asset_type:{_eq:r}}}});return i[0]?i[0].amount:0}async function qr(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o=u.from(t).toStringLong(),i={..._optionalChain([r, 'optionalAccess', _71 => _71.where]),owner_address:{_eq:o}},s={query:jo,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _72 => _72.offset]),limit:_optionalChain([r, 'optionalAccess', _73 => _73.limit]),order_by:_optionalChain([r, 'optionalAccess', _74 => _74.orderBy])}};return(await f({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Pi(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),i=await f({aptosConfig:e,query:{query:Wo,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!i.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return i.current_fungible_asset_balances_aggregate.aggregate.count}async function Ci(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()}},s={query:$n,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _75 => _75.offset]),limit:_optionalChain([r, 'optionalAccess', _76 => _76.limit]),order_by:_optionalChain([r, 'optionalAccess', _77 => _77.orderBy])}};return(await f({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function Ei(n){let{aptosConfig:e,privateKey:t}=n,r=new k(t.publicKey());if(t instanceof rt){let i=q.fromPublicKey({publicKey:r}).derivedAddress();return $e.fromPrivateKey({privateKey:t,address:i})}if(t instanceof L){let o=q.fromPublicKey({publicKey:r});if(await fi({authKey:o,aptosConfig:e})){let c=o.derivedAddress();return $e.fromPrivateKey({privateKey:t,address:c,legacy:!1})}let s=q.fromPublicKey({publicKey:r.publicKey});if(await fi({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return $e.fromPrivateKey({privateKey:t,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${t}`)}async function fi(n){let{aptosConfig:e,authKey:t}=n,r=await nn({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await xe({aptosConfig:e,accountAddress:r}),!0}catch(o){if(o.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function $r(n){let{aptosConfig:e,options:t}=n;return ht({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _78 => _78.offset]),limit:_optionalChain([t, 'optionalAccess', _79 => _79.limit])}})}async function Yn(n){let{aptosConfig:e}=n;return Oe(async()=>{let{data:t}=await V({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function Ii(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function rn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await V({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function Ui(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await rn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _80 => _80.status])===404)return!0;throw r}}async function nc(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await V({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return r}async function Gt(n){let{aptosConfig:e,transactionHash:t,options:r}=n,o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _81 => _81.timeoutSecs]), () => (20)),i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _82 => _82.checkSuccess]), () => (!0)),s=!0,a=0,c,p,y=200,w=1.5;function S(g){if(!(g instanceof ye)||(p=g,g.status!==404&&g.status>=400&&g.status<500))throw g}try{c=await rn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(g){S(g)}if(s){let g=Date.now();try{c=await nc({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(E){S(E)}a=(Date.now()-g)/1e3}for(;s&&!(a>=o);){try{if(c=await rn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(g){S(g)}await _chunkBHKSQXUZjs.b.call(void 0, y),a+=y/1e3,y*=w}if(c===void 0)throw p||new Xn(`Fetching transaction ${t} failed and timed out after ${o} seconds`,c);if(c.type==="pending_transaction")throw new Xn(`Transaction ${t} timed out in pending state after ${o} seconds`,c);if(!i)return c;if(!c.success)throw new Vr(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function Zn(n){let{aptosConfig:e,processorType:t}=n,r=BigInt(n.minimumLedgerVersion),o=3e3,i=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-i>o)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await Hn({aptosConfig:e}):s=(await Qn({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunkBHKSQXUZjs.b.call(void 0, 200)}}var Xn=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},Vr=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function Ri(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:o}=await V({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _83 => _83.withTransactions])}});return Di({block:o,...n})}async function zi(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:o}=await V({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _84 => _84.withTransactions])}});return Di({block:o,...n})}async function Di(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _85 => _85.withTransactions])){t.transactions=_nullishCoalesce(t.transactions, () => ([]));let o=t.transactions[t.transactions.length-1],i=BigInt(t.first_version),s=BigInt(t.last_version),a=_optionalChain([o, 'optionalAccess', _86 => _86.version]),c;if(a===void 0?c=i-1n:c=BigInt(a),c===s)return t;let p=[],y=100n;for(let S=c+1n;S<s;S+=BigInt(100))p.push($r({aptosConfig:e,options:{offset:S,limit:Math.min(Number(y),Number(s-S+1n))}}));let w=await Promise.all(p);for(let S of w)t.transactions.push(...S)}return t}async function A(n){n.minimumLedgerVersion!==void 0&&await Zn({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}var on=class{constructor(e){this.config=e}async getAccountInfo(e){return xe({aptosConfig:this.config,...e})}async getAccountModules(e){return Ai({aptosConfig:this.config,...e})}async getAccountModule(e){return jn({aptosConfig:this.config,...e})}async getAccountTransactions(e){return hi({aptosConfig:this.config,...e})}async getAccountResources(e){return Ti({aptosConfig:this.config,...e})}async getAccountResource(e){return Mr({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return nn({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),bi({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),wi({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Si({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),xi({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),_i({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),qr({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Pi({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:kn,...e})}async getAccountCoinAmount(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),vi({aptosConfig:this.config,...e})}async getAccountOwnedObjects(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Ci({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return Ei({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Jn=class{constructor(e){this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _87 => _87.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _88 => _88.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _89 => _89.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _90 => _90.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _91 => _91.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _92 => _92.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _93 => _93.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _94 => _94.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _95 => _95.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _96 => _96.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _97 => _97.faucetConfig]), () => ({}))}getRequestUrl(e){switch(e){case"Fullnode":if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return Go[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return Bo[this.network];case"Indexer":if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return ko[this.network];case"Pepper":if(this.pepper!==void 0)return this.pepper;if(this.network==="custom")throw new Error("Please provide a custom pepper service url");return Pr[this.network];case"Prover":if(this.prover!==void 0)return this.prover;if(this.network==="custom")throw new Error("Please provide a custom prover service url");return Cr[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return Pr[this.network]===e}isProverServiceRequest(e){return Cr[this.network]===e}};function ki(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Gi(n){return!!n.match(/\s/)}function oc(n){return!!n.match(/^T[0-9]+$/)}function ic(n){return!!n.match(/^&.+$/)}function sc(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function ac(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!Gi(r))break}return t}var cc=(E=>(E.InvalidTypeTag="unknown type",E.UnexpectedGenericType="unexpected generic type",E.UnexpectedTypeArgumentClose="unexpected '>'",E.UnexpectedWhitespaceCharacter="unexpected whitespace character",E.UnexpectedComma="unexpected ','",E.TypeArgumentCountMismatch="type argument count doesn't match expected amount",E.MissingTypeArgumentClose="no matching '>' for '<'",E.MissingTypeArgument="no type argument before ','",E.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",E.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",E.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",E.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",E.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",E.InvalidAddress="struct address must be valid",E))(cc||{}),N= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function ze(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _98 => _98.allowGenerics]), () => (!1)),r=[],o=[],i=[],s=0,a="",c=1;for(;s<n.length;){let p=n[s];if(p==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:i}),a="",i=[],c=1;else if(p===">"){if(a!==""){let E=sn(a,o,t);i.push(E)}let y=r.pop();if(y===void 0)throw new N(n,"unexpected '>'");if(c!==i.length)throw new N(n,"type argument count doesn't match expected amount");let{savedStr:w,savedTypes:S,savedExpectedTypes:g}=y;o=i,i=S,a=w,c=g}else if(p===","){if(r.length===0)throw new N(n,"unexpected ','");if(a.length===0)throw new N(n,"no type argument before ','");let y=sn(a,o,t);o=[],i.push(y),a="",c+=1}else if(Gi(p)){let y=!1;if(a.length!==0){let S=sn(a,o,t);o=[],i.push(S),a="",y=!0}s=ac(n,s);let w=n[s];if(s<n.length&&y&&w!==","&&w!==">")throw new N(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new N(n,"no matching '>' for '<'");switch(i.length){case 0:return sn(a,o,t);case 1:if(a==="")return i[0];throw new N(n,"unexpected ','");default:throw new N(n,"unexpected whitespace character")}}function sn(n,e,t){let r=n.trim(),o=r.toLowerCase();if(sc(o)&&e.length>0)throw new N(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new _t;case"bool":return new K;case"address":return new W;case"u8":return new ce;case"u16":return new Fe;case"u32":return new Me;case"u64":return new $;case"u128":return new qe;case"u256":return new Ve;case"vector":if(e.length!==1)throw new N(n,"vector type expected to have exactly one type argument");return new C(e[0]);default:if(ic(r)){let a=r.substring(1);return new Kn(sn(a,e,t))}if(oc(r)){if(t)return new D(Number(r.split("T")[1]));throw new N(n,"unexpected generic type")}if(!r.match(/:/))throw new N(n,"unknown type");let i=r.split("::");if(i.length!==3)throw new N(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=u.fromString(i[0])}catch (e2){throw new N(n,"struct address must be valid")}if(!ki(i[1]))throw new N(n,"module name must only contain alphanumeric or '_' characters");if(!ki(i[2]))throw new N(n,"struct name must only contain alphanumeric or '_' characters");return new m(new Ue(s,new R(i[1]),new R(i[2]),e))}}function Bi(n){return typeof n=="boolean"}function He(n){return typeof n=="string"}function uc(n){return typeof n=="number"}function er(n){if(uc(n))return n;if(He(n)&&n!=="")return Number.parseInt(n,10)}function tr(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Ki(n){return n==null}function Ni(n){return Lr(n)||Qr(n)||Wr(n)||jr(n)||Xr(n)||Yr(n)||Zr(n)||nr(n)||Hr(n)||pc(n)||n instanceof T||n instanceof M}function Lr(n){return n instanceof I}function nr(n){return n instanceof u}function Hr(n){return n instanceof b}function pc(n){return n instanceof Ze}function Qr(n){return n instanceof F}function Wr(n){return n instanceof de}function jr(n){return n instanceof le}function Xr(n){return n instanceof O}function Yr(n){return n instanceof ge}function Zr(n){return n instanceof me}function Oi(n){return"bytecode"in n}function U(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function Fi(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}function an(n){let e=n.split("::");if(e.length!==3)throw new Error(`Invalid function ${n}`);let t=e[0],r=e[1],o=e[2];return{moduleAddress:t,moduleName:r,functionName:o}}var dc=new TextEncoder;function rr(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _99 => _99.map, 'call', _100 => _100(e=>He(e)?ze(e):e)]), () => ([]))}async function Mi(n,e,t,r){let o=await jn({aptosConfig:r,accountAddress:n,moduleName:e});if(o.abi)return o.abi.exposed_functions.find(i=>i.name===t)}async function qi(n,e,t,r){let o=await Mi(n,e,t,r);if(!o)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!o.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let i=Fi(o),s=[];for(let a=i;a<o.params.length;a+=1)s.push(ze(o.params[a],{allowGenerics:!0}));return{signers:i,typeParameters:o.generic_type_params,parameters:s}}async function Vi(n,e,t,r){let o=await Mi(n,e,t,r);if(!o)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!o.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let i=[];for(let a=0;a<o.params.length;a+=1)i.push(ze(o.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<o.return.length;a+=1)s.push(ze(o.return[a],{allowGenerics:!0}));return{typeParameters:o.generic_type_params,parameters:i,returnTypes:s}}function eo(n,e,t,r,o){if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);let i=e.parameters[r];return Bt(t,i,r,o)}function Bt(n,e,t,r){return Ni(n)?(Jr(e,n,t),n):lc(n,e,t,r)}function lc(n,e,t,r){if(e.isBool()){if(Bi(n))return new I(n);if(He(n)){if(n==="true")return new I(!0);if(n==="false")return new I(!1)}U("boolean",t)}if(e.isAddress()){if(He(n))return u.fromString(n);U("string | AccountAddress",t)}if(e.isU8()){let o=er(n);if(o!==void 0)return new F(o);U("number | string",t)}if(e.isU16()){let o=er(n);if(o!==void 0)return new de(o);U("number | string",t)}if(e.isU32()){let o=er(n);if(o!==void 0)return new le(o);U("number | string",t)}if(e.isU64()){if(tr(n))return new O(BigInt(n));U("bigint | number | string",t)}if(e.isU128()){if(tr(n))return new ge(BigInt(n));U("bigint | number | string",t)}if(e.isU256()){if(tr(n))return new me(BigInt(n));U("bigint | number | string",t)}if(e.isGeneric()){let o=e.value;if(o<0||o>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return Bt(n,r[o],t,r)}if(e.isVector()){if(e.value.isU8()){if(He(n))return T.U8(dc.encode(n));if(n instanceof Uint8Array)return T.U8(n);if(n instanceof ArrayBuffer)return T.U8(new Uint8Array(n))}if(Array.isArray(n))return new T(n.map(o=>Bt(o,e.value,t,r)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(He(n))return new b(n);U("string",t)}if(e.isObject()){if(He(n))return u.fromString(n);U("string | AccountAddress",t)}if(e.isOption()){if(Ki(n)){let o=e.value.typeArgs[0];return o instanceof K?new M(null):o instanceof W?new M(null):o instanceof ce?new M(null):o instanceof Fe?new M(null):o instanceof Me?new M(null):o instanceof $?new M(null):o instanceof qe?new M(null):o instanceof Ve?new M(null):new M(null)}return new M(Bt(n,e.value.typeArgs[0],t,r))}throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function Jr(n,e,t){if(n.isBool()){if(Lr(e))return;U("Bool",t)}if(n.isAddress()){if(nr(e))return;U("AccountAddress",t)}if(n.isU8()){if(Qr(e))return;U("U8",t)}if(n.isU16()){if(Wr(e))return;U("U16",t)}if(n.isU32()){if(jr(e))return;U("U32",t)}if(n.isU64()){if(Xr(e))return;U("U64",t)}if(n.isU128()){if(Yr(e))return;U("U128",t)}if(n.isU256()){if(Zr(e))return;U("U256",t)}if(n.isVector()){if(e instanceof T){e.values.length>0&&Jr(n.value,e.values[0],t);return}U("MoveVector",t)}if(n instanceof m){if(n.isString()){if(Hr(e))return;U("MoveString",t)}if(n.isObject()){if(nr(e))return;U("AccountAddress",t)}if(n.isOption()){if(e instanceof M){e.value!==void 0&&Jr(n.value.typeArgs[0],e.value,t);return}U("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function ir(n){if(Oi(n))return fc(n);let{moduleAddress:e,moduleName:t,functionName:r}=an(n.function),o=await Qi({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:qi});return mc({...n,abi:o})}function mc(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:o}=an(n.function),i=rr(n.typeArguments);if(i.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${i.length}`);let s=n.functionArguments.map((c,p)=>eo(n.function,e,c,p,i));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${o}', expected ${e.parameters.length} but got ${s.length}`);let a=ut.build(`${t}::${r}`,o,i,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new Yt(new Jt(c,new en(a)))}return new Xt(a)}async function $i(n){let{moduleAddress:e,moduleName:t,functionName:r}=an(n.function),o=await Qi({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Vi});return yc({abi:o,...n})}function yc(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:o}=an(n.function),i=rr(n.typeArguments);if(i.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${i.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _101 => _101.functionArguments, 'optionalAccess', _102 => _102.map, 'call', _103 => _103((a,c)=>eo(n.function,e,a,c,i))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${o}', expected ${e.parameters.length} but got ${s.length}`);return ut.build(`${t}::${r}`,o,i,s)}function fc(n){return new jt(new Zt(l.fromHexInput(n.bytecode).toUint8Array(),rr(n.typeArguments),n.functionArguments))}async function Ac(n){let{aptosConfig:e,sender:t,payload:r,options:o,feePayerAddress:i}=n,s=async()=>Ir[e.network]?{chainId:Ir[e.network]}:{chainId:(await Ln({aptosConfig:e})).chain_id},a=async()=>_optionalChain([o, 'optionalAccess', _104 => _104.gasUnitPrice])?{gasEstimate:o.gasUnitPrice}:{gasEstimate:(await Yn({aptosConfig:e})).gas_estimate},c=async()=>{let gt=async()=>_optionalChain([o, 'optionalAccess', _105 => _105.accountSequenceNumber])!==void 0?o.accountSequenceNumber:(await xe({aptosConfig:e,accountAddress:t})).sequence_number;if(i&&u.from(i).equals(u.ZERO))try{return await gt()}catch (e3){return 0}else return gt()},[{chainId:p},{gasEstimate:y},w]=await Promise.all([s(),a(),c()]),{maxGasAmount:S,gasUnitPrice:g,expireTimestamp:E}={maxGasAmount:_optionalChain([o, 'optionalAccess', _106 => _106.maxGasAmount])?BigInt(o.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _107 => _107.gasUnitPrice]), () => (BigInt(y))),expireTimestamp:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _108 => _108.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new ue(u.from(t),BigInt(w),r,BigInt(S),BigInt(g),BigInt(E),new xt(p))}async function to(n){let{aptosConfig:e,sender:t,payload:r,options:o,feePayerAddress:i}=n,s=await Ac({aptosConfig:e,sender:t,payload:r,options:o,feePayerAddress:i});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _109 => _109.secondarySignerAddresses, 'optionalAccess', _110 => _110.map, 'call', _111 => _111(c=>u.from(c))]), () => ([]));return new Mn(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new Fn(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function Li(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:o}=n,i=or(e);if(t.feePayerAddress){let a=new dt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];r&&(c=r.map(w=>or(w)));let p=or(o),y=new Ct(i,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:p});return new lt(a.raw_txn,y).bcsToBytes()}if(t.secondarySignerAddresses){let a=new pt(t.rawTransaction,t.secondarySignerAddresses),c=[];c=r.map(y=>or(y));let p=new Pt(i,t.secondarySignerAddresses,c);return new lt(a.raw_txn,p).bcsToBytes()}let s;if(i instanceof fe)s=new vt(i.public_key,i.signature);else if(i instanceof Q)s=new Et(i);else throw new Error("Invalid public key");return new lt(t.rawTransaction,s).bcsToBytes()}function or(n){if((n instanceof ee||n instanceof Te)&&(n=new k(n)),n instanceof k){if(n.publicKey instanceof _)return new Q(n,new B(new v(new Uint8Array(64))));if(n.publicKey instanceof Te)return new Q(n,new B(new Pe(new Uint8Array(64))));if(n.publicKey instanceof ee)return new Q(n,new B(Ee.getSimulationSignature()))}return new fe(new _(n.toUint8Array()),new v(new Uint8Array(64)))}function no(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,o=Fo(H,n.senderAuthenticator),i;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");i=new Ct(o,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");i=new Pt(o,e.secondarySignerAddresses,r)}else o instanceof fe?i=new vt(o.public_key,o.signature):i=new Et(o);return new lt(e.rawTransaction,i).bcsToBytes()}function Hi(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var hc=Hi(["APTOS::Transaction"]);function BA(n){let e=no(n);return new l(Hi([hc,new Uint8Array([0]),e])).toString()}async function Qi({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:o,abi:i,fetch:s}){return i!==void 0?i:Oe(async()=>s(e,t,r,o),`${n}-${o.network}-${e}-${t}-${r}`,1e3*60*5)()}async function h(n){let e=await Tc(n);return bc(n,e)}async function Tc(n){let{aptosConfig:e,data:t}=n,r,o;return"bytecode"in t?o=await ir(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},o=await ir(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},o=await ir(r)),o}async function bc(n,e){let{aptosConfig:t,sender:r,options:o}=n,i;if(wc(n)&&(i=u.ZERO.toString()),Sc(n)){let{secondarySignerAddresses:s}=n;return to({aptosConfig:t,sender:r,payload:e,options:o,secondarySignerAddresses:s,feePayerAddress:i})}return to({aptosConfig:t,sender:r,payload:e,options:o,feePayerAddress:i})}function wc(n){return n.withFeePayer===!0}function Sc(n){return"secondarySignerAddresses"in n}function Wi(n){let{transaction:e}=n;return Ut(e)}function sr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}async function ro(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:s}=n,a=Li({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:s}),{data:c}=await Ne({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _112 => _112.options, 'optionalAccess', _113 => _113.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _114 => _114.options, 'optionalAccess', _115 => _115.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _116 => _116.options, 'optionalAccess', _117 => _117.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function ar(n){let{aptosConfig:e}=n,t=no({...n}),{data:r}=await Ne({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function cn(n){let{aptosConfig:e,signer:t,transaction:r}=n;(t instanceof Se||t instanceof qn)&&await t.waitForProofFetch();let o=sr({signer:t,transaction:r});return ar({aptosConfig:e,transaction:r,senderAuthenticator:o})}var xc={typeParameters:[],parameters:[C.u8(),new C(C.u8())]};async function ji(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:o,options:i}=n,s=o.map(a=>T.U8(a));return h({aptosConfig:e,sender:u.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[T.U8(r),new T(s)],abi:xc},options:i})}var _c={typeParameters:[],parameters:[new ce,C.u8(),new ce,C.u8(),C.u8(),C.u8()]};async function Xi(n){let{aptosConfig:e,fromAccount:t,toNewPrivateKey:r}=n,o=await xe({aptosConfig:e,accountAddress:t.accountAddress}),i=$e.fromPrivateKey({privateKey:r,legacy:!0}),a=new On({sequenceNumber:BigInt(o.sequence_number),originator:t.accountAddress,currentAuthKey:u.from(o.authentication_key),newPublicKey:i.publicKey}).bcsToBytes(),c=t.sign(a),p=i.sign(a),y=await h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new F(t.signingScheme),T.U8(t.publicKey.toUint8Array()),new F(i.signingScheme),T.U8(i.publicKey.toUint8Array()),T.U8(c.toUint8Array()),T.U8(p.toUint8Array())],abi:_c}});return cn({aptosConfig:e,signer:t,transaction:y})}var vc={typeParameters:[{constraints:[]}],parameters:[new W,new $]};async function Yi(n){let{aptosConfig:e,sender:t,recipient:r,amount:o,coinType:i,options:s}=n;return h({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(i, () => (kn))],functionArguments:[r,o],abi:vc},options:s})}var un=class{constructor(e){this.config=e}async transferCoinTransaction(e){return Yi({aptosConfig:this.config,...e})}};var Qe={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},pe="0x4::token::Token";async function Zi(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()}};return(await f({aptosConfig:e,query:{query:di,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Ji(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};return(await f({aptosConfig:e,query:{query:Fr,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function es(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},i={query:Fr,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _118 => _118.offset]),limit:_optionalChain([r, 'optionalAccess', _119 => _119.limit]),order_by:_optionalChain([r, 'optionalAccess', _120 => _120.orderBy])}};return(await f({aptosConfig:e,query:i,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function ts(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,o={token_data_id:{_eq:u.from(t).toStringLong()}},i={query:pi,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _121 => _121.offset]),limit:_optionalChain([r, 'optionalAccess', _122 => _122.limit]),order_by:_optionalChain([r, 'optionalAccess', _123 => _123.orderBy])}};return(await f({aptosConfig:e,query:i,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Pc={typeParameters:[],parameters:[new m(P()),new $,new m(P()),new m(P()),new K,new K,new K,new K,new K,new K,new K,new K,new K,new $,new $]};async function ns(n){let{aptosConfig:e,options:t,creator:r}=n;return h({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new b(n.description),new O(_nullishCoalesce(n.maxSupply, () => (Xe))),new b(n.name),new b(n.uri),new I(_nullishCoalesce(n.mutableDescription, () => (!0))),new I(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new I(_nullishCoalesce(n.mutableURI, () => (!0))),new I(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new I(_nullishCoalesce(n.mutableTokenName, () => (!0))),new I(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new I(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new I(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new I(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new O(_nullishCoalesce(n.royaltyNumerator, () => (0))),new O(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Pc},options:t})}async function Kt(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _124 => _124.where]);_optionalChain([t, 'optionalAccess', _125 => _125.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _126 => _126.tokenStandard]), () => ("v2"))});let o={query:ni,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _127 => _127.offset]),limit:_optionalChain([t, 'optionalAccess', _128 => _128.limit])}};return(await f({aptosConfig:e,query:o,originMethod:"getCollectionData"})).current_collections_v2[0]}async function rs(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:o}=n,i=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:i.toStringLong()}};return _optionalChain([o, 'optionalAccess', _129 => _129.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _130 => _130.tokenStandard]), () => ("v2"))}),Kt({aptosConfig:e,options:{...o,where:s}})}async function os(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,i={creator_address:{_eq:u.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _131 => _131.tokenStandard])&&(i.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _132 => _132.tokenStandard]), () => ("v2"))}),Kt({aptosConfig:e,options:{...r,where:i}})}async function is(n){let{aptosConfig:e,collectionId:t,options:r}=n,i={collection_id:{_eq:u.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _133 => _133.tokenStandard])&&(i.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _134 => _134.tokenStandard]), () => ("v2"))}),Kt({aptosConfig:e,options:{...r,where:i}})}async function ss(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:o}=n,i=u.from(e),s={collection_name:{_eq:t},creator_address:{_eq:i.toStringLong()}};return _optionalChain([r, 'optionalAccess', _135 => _135.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _136 => _136.tokenStandard]), () => ("v2"))}),(await Kt({aptosConfig:o,options:{where:s}})).collection_id}var Cc={typeParameters:[],parameters:[new m(P()),new m(P()),new m(P()),new m(P()),new C(new m(P())),new C(new m(P())),new C(C.u8())]};async function as(n){let{aptosConfig:e,options:t,creator:r,collection:o,description:i,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:y}=n,w=_optionalChain([p, 'optionalAccess', _137 => _137.map, 'call', _138 => _138(S=>Qe[S])]);return h({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new b(o),new b(i),new b(s),new b(a),T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(w, () => ([]))),ws(_nullishCoalesce(y, () => ([])),_nullishCoalesce(w, () => ([])))],abi:Cc},options:t})}var Ec={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new W]};async function cs(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:o,digitalAssetType:i,options:s}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(i, () => (pe))],functionArguments:[u.from(r),u.from(o)],abi:Ec},options:s})}var Ic={typeParameters:[],parameters:[new m(P()),new m(P()),new m(P()),new m(P()),new C(new m(P())),new C(new m(P())),new C(C.u8()),new W]};async function us(n){let{aptosConfig:e,account:t,collection:r,description:o,name:i,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:y,options:w}=n;if(_optionalChain([c, 'optionalAccess', _139 => _139.length])!==_optionalChain([y, 'optionalAccess', _140 => _140.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _141 => _141.length])!==_optionalChain([y, 'optionalAccess', _142 => _142.length]))throw new Error("Property types and property values counts do not match");let S=_optionalChain([p, 'optionalAccess', _143 => _143.map, 'call', _144 => _144(g=>Qe[g])]);return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,o,i,s,T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(S, () => ([]))),ws(_nullishCoalesce(y, () => ([])),_nullishCoalesce(S, () => ([]))),a],abi:Ic},options:w})}var Uc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0)))]};async function ps(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:o,options:i}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(o, () => (pe))],functionArguments:[u.from(r)],abi:Uc},options:i})}var Rc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0)))]};async function ds(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:o,options:i}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(o, () => (pe))],functionArguments:[r],abi:Rc},options:i})}var zc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0)))]};async function ls(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:o,options:i}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(o, () => (pe))],functionArguments:[r],abi:zc},options:i})}var Dc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new m(P())]};async function gs(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(i, () => (pe))],functionArguments:[u.from(o),new b(r)],abi:Dc},options:s})}var kc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new m(P())]};async function ms(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(i, () => (pe))],functionArguments:[u.from(o),new b(r)],abi:kc},options:s})}var Gc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new m(P())]};async function ys(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(i, () => (pe))],functionArguments:[u.from(o),new b(r)],abi:Gc},options:s})}var Bc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new m(P()),new m(P()),C.u8()]};async function fs(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (pe))],functionArguments:[u.from(s),new b(r),new b(Qe[o]),T.U8(oo(i,Qe[o]))],abi:Bc},options:c})}var Kc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new m(P())]};async function As(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(i, () => (pe))],functionArguments:[u.from(o),new b(r)],abi:Kc},options:s})}var Nc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new m(P()),new m(P()),C.u8()]};async function hs(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (pe))],functionArguments:[u.from(s),new b(r),new b(Qe[o]),oo(i,Qe[o])],abi:Nc},options:c})}var Oc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new m(ne(new D(0))),new m(P()),new D(1)]};async function Ts(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (pe)),Qe[o]],functionArguments:[u.from(s),new b(r),i],abi:Oc},options:c})}var Fc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new m(ne(new D(0))),new m(P()),new D(1)]};async function bs(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (pe)),Qe[o]],functionArguments:[u.from(s),new b(r),i],abi:Fc},options:c})}function ws(n,e){let t=new Array;return e.forEach((r,o)=>{t.push(oo(n[o],r))}),t}function oo(n,e){let t=ze(e);return Bt(n,t,0,[]).bcsToBytes()}var pn=class{constructor(e){this.config=e}async getCollectionData(e){await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:o}=e,i=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:i.toStringLong()}};return _optionalChain([o, 'optionalAccess', _145 => _145.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _146 => _146.tokenStandard]), () => ("v2"))}),Kt({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),rs({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),os({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),is({aptosConfig:this.config,...e})}async getCollectionId(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ss({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Zi({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ji({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),es({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ts({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return ns({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return as({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return cs({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return us({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return ps({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return ds({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return ls({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return gs({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return ms({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return ys({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return fs({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return As({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return hs({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return Ts({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return bs({aptosConfig:this.config,...e})}};var Ss=300,Mc=n=>{if(n&&n.length>Ss)throw new Error(`Event type length exceeds the maximum length of ${Ss}`)};async function xs(n){let{aptosConfig:e,eventType:t,options:r}=n,i={where:{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},creation_number:{_eq:"0"},sequence_number:{_eq:"0"},indexed_type:{_eq:t}},pagination:r,orderBy:_optionalChain([r, 'optionalAccess', _147 => _147.orderBy])};return dn({aptosConfig:e,options:i})}async function _s(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:o}=n,a={where:{account_address:{_eq:u.from(e).toStringLong()},creation_number:{_eq:r}},pagination:o,orderBy:_optionalChain([o, 'optionalAccess', _148 => _148.orderBy])};return dn({aptosConfig:t,options:a})}async function vs(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:o}=n,a={where:{account_address:{_eq:u.from(e).toStringLong()},indexed_type:{_eq:r}},pagination:o,orderBy:_optionalChain([o, 'optionalAccess', _149 => _149.orderBy])};return dn({aptosConfig:t,options:a})}async function dn(n){let{aptosConfig:e,options:t}=n;Mc(_optionalChain([t, 'optionalAccess', _150 => _150.where, 'optionalAccess', _151 => _151.indexed_type, 'optionalAccess', _152 => _152._eq]));let r={query:ii,variables:{where_condition:_optionalChain([t, 'optionalAccess', _153 => _153.where]),offset:_optionalChain([t, 'optionalAccess', _154 => _154.offset]),limit:_optionalChain([t, 'optionalAccess', _155 => _155.limit]),order_by:_optionalChain([t, 'optionalAccess', _156 => _156.orderBy])}};return(await f({aptosConfig:e,query:r,originMethod:"getEvents"})).events}var ln=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),xs({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),_s({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),vs({aptosConfig:this.config,...e})}async getEvents(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _157 => _157.minimumLedgerVersion]),processorType:"events_processor"}),dn({aptosConfig:this.config,...e})}};async function Ps(n){let{aptosConfig:e,accountAddress:t,amount:r,options:o}=n,i=_optionalChain([o, 'optionalAccess', _158 => _158.timeoutSecs])||20,{data:s}=await Vo({aptosConfig:e,path:"fund",body:{address:u.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Gt({aptosConfig:e,transactionHash:a,options:{timeoutSecs:i,checkSuccess:_optionalChain([o, 'optionalAccess', _159 => _159.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var gn=class{constructor(e){this.config=e}async fundAccount(e){let t=await Ps({aptosConfig:this.config,...e});return _optionalChain([e, 'access', _160 => _160.options, 'optionalAccess', _161 => _161.waitForIndexer])!==!1&&await Zn({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version)}),t}};async function cr(n){let{aptosConfig:e,options:t}=n,r={query:ai,variables:{where_condition:_optionalChain([t, 'optionalAccess', _162 => _162.where]),limit:_optionalChain([t, 'optionalAccess', _163 => _163.limit]),offset:_optionalChain([t, 'optionalAccess', _164 => _164.offset])}};return(await f({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function Cs(n){let{aptosConfig:e,options:t}=n,r={query:si,variables:{where_condition:_optionalChain([t, 'optionalAccess', _165 => _165.where]),limit:_optionalChain([t, 'optionalAccess', _166 => _166.limit]),offset:_optionalChain([t, 'optionalAccess', _167 => _167.offset])}};return(await f({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Es(n){let{aptosConfig:e,options:t}=n,r={query:ri,variables:{where_condition:_optionalChain([t, 'optionalAccess', _168 => _168.where]),limit:_optionalChain([t, 'optionalAccess', _169 => _169.limit]),offset:_optionalChain([t, 'optionalAccess', _170 => _170.offset])}};return(await f({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var qc={typeParameters:[{constraints:[]}],parameters:[ze("0x1::object::Object"),new W,new $]};async function Is(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:o,amount:i,options:s}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,o,i],abi:qc},options:s})}var mn=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _171 => _171.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),cr({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _172 => _172.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await cr({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _173 => _173.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await cr({aptosConfig:this.config,options:{where:{creator_address:{_eq:u.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _174 => _174.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Cs({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _175 => _175.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Es({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return Is({aptosConfig:this.config,...e})}};async function We(n){let{aptosConfig:e,payload:t,options:r}=n,o=await $i({...t,aptosConfig:e}),i=new Z;o.serialize(i);let s=i.toUint8Array(),{data:a}=await Ne({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _176 => _176.ledgerVersion])},body:s});return a}async function Us(n){let{aptosConfig:e,payload:t,options:r}=n,{data:o}=await Ne({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _177 => _177.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return o}var yn=class{constructor(e){this.config=e}async getLedgerInfo(){return Ln({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return Ri({aptosConfig:this.config,...e})}async getBlockByHeight(e){return zi({aptosConfig:this.config,...e})}async view(e){return We({aptosConfig:this.config,...e})}async viewJson(e){return Us({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return li({aptosConfig:this.config,...e})}async queryIndexer(e){return f({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return Hn({aptosConfig:this.config})}async getProcessorStatus(e){return Qn({aptosConfig:this.config,processorType:e})}};var Rs=["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 zs(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function je(n){let[e,t,...r]=n.replace(/\.apt$/,"").split(".");if(r.length>0)throw new Error(`${n} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!zs(e))throw new Error(`${e} is not valid. ${Rs}`);if(t&&!zs(t))throw new Error(`${t} is not valid. ${Rs}`);return{domainName:t||e,subdomainName:t?e:void 0}}var Vc="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",$c={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Vc,custom:null,devnet:null};function De(n){let e=$c[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var ur=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Ds(n){let{aptosConfig:e,name:t}=n,r=De(e),{domainName:o,subdomainName:i}=je(t),s=await We({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[o,i]}}),a=ur(s[0]);return a?u.from(a):void 0}async function ks(n){let{aptosConfig:e,expiration:t,name:r,sender:o,targetAddress:i,toAddress:s,options:a,transferable:c}=n,p=De(e),{domainName:y,subdomainName:w}=je(r),S=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(w&&!S)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(S&&!w)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let yr=_nullishCoalesce(t.years, () => (1));if(yr!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Zs=yr*31536e3;return await h({aptosConfig:e,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[y,Zs,i,s]},options:a})}if(!w)throw new Error(`${t.policy} requires a subdomain to be provided.`);let g=await io({aptosConfig:e,name:y});if(!g)throw new Error("The domain does not exist");let E=t.policy==="subdomain:independent"?t.expirationDate:g;if(E>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await h({aptosConfig:e,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[y,w,Math.round(E/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,i,s]},options:a})}async function io(n){let{aptosConfig:e,name:t}=n,r=De(e),{domainName:o,subdomainName:i}=je(t);try{let s=await We({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[o,i]}});return Number(s[0])*1e3}catch (e4){return}}async function Gs(n){let{aptosConfig:e,address:t}=n,r=De(e),o=await We({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(t).toString()]}}),i=ur(o[1]),s=ur(o[0]);if(i)return[s,i].filter(Boolean).join(".")}async function Bs(n){let{aptosConfig:e,sender:t,name:r,options:o}=n,i=De(e);if(!r)return await h({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${i}::router::clear_primary_name`,functionArguments:[]},options:o});let{domainName:s,subdomainName:a}=je(r);return await h({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${i}::router::set_primary_name`,functionArguments:[s,a]},options:o})}async function Ks(n){let{aptosConfig:e,name:t}=n,r=De(e),{domainName:o,subdomainName:i}=je(t),s=await We({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[o,i]}}),a=ur(s[0]);return a?u.from(a):void 0}async function Ns(n){let{aptosConfig:e,sender:t,name:r,address:o,options:i}=n,s=De(e),{domainName:a,subdomainName:c}=je(r);return await h({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,o]},options:i})}async function Os(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:o=""}=je(t),a=(await f({aptosConfig:e,query:{query:kt,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:o},is_active:{_eq:!0}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=fn(a)),a}async function Fs(n){let{aptosConfig:e,options:t,accountAddress:r}=n,o=await so({aptosConfig:e});return(await f({aptosConfig:e,originMethod:"getAccountNames",query:{query:kt,variables:{limit:_optionalChain([t, 'optionalAccess', _178 => _178.limit]),offset:_optionalChain([t, 'optionalAccess', _179 => _179.offset]),order_by:_optionalChain([t, 'optionalAccess', _180 => _180.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _181 => _181.options, 'optionalAccess', _182 => _182.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o}}}}})).current_aptos_names.map(fn)}async function Ms(n){let{aptosConfig:e,options:t,accountAddress:r}=n,o=await so({aptosConfig:e});return(await f({aptosConfig:e,originMethod:"getAccountDomains",query:{query:kt,variables:{limit:_optionalChain([t, 'optionalAccess', _183 => _183.limit]),offset:_optionalChain([t, 'optionalAccess', _184 => _184.offset]),order_by:_optionalChain([t, 'optionalAccess', _185 => _185.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _186 => _186.options, 'optionalAccess', _187 => _187.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""}}}}})).current_aptos_names.map(fn)}async function qs(n){let{aptosConfig:e,options:t,accountAddress:r}=n,o=await so({aptosConfig:e});return(await f({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:kt,variables:{limit:_optionalChain([t, 'optionalAccess', _188 => _188.limit]),offset:_optionalChain([t, 'optionalAccess', _189 => _189.offset]),order_by:_optionalChain([t, 'optionalAccess', _190 => _190.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _191 => _191.options, 'optionalAccess', _192 => _192.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_neq:""}}}}})).current_aptos_names.map(fn)}async function Vs(n){let{aptosConfig:e,options:t,domain:r}=n;return(await f({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:kt,variables:{limit:_optionalChain([t, 'optionalAccess', _193 => _193.limit]),offset:_optionalChain([t, 'optionalAccess', _194 => _194.offset]),order_by:_optionalChain([t, 'optionalAccess', _195 => _195.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _196 => _196.options, 'optionalAccess', _197 => _197.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""},is_active:{_eq:!0}}}}})).current_aptos_names.map(fn)}async function so(n){let{aptosConfig:e}=n,t=De(e),[r]=await We({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),o=r/60/60/24,i=()=>new Date;return new Date(i().setDate(i().getDate()-o)).toISOString()}async function $s(n){let{aptosConfig:e,sender:t,name:r,years:o=1,options:i}=n,s=De(e),a=o*31536e3,{domainName:c,subdomainName:p}=je(r);if(p)throw new Error("Subdomains cannot be renewed");if(o!==1)throw new Error("Currently, only 1 year renewals are supported");return await h({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:i})}function fn(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var An=class{constructor(e){this.config=e}async getOwnerAddress(e){return Ds({aptosConfig:this.config,...e})}async getExpiration(e){return io({aptosConfig:this.config,...e})}async getTargetAddress(e){return Ks({aptosConfig:this.config,...e})}async setTargetAddress(e){return Ns({aptosConfig:this.config,...e})}async getPrimaryName(e){return Gs({aptosConfig:this.config,...e})}async setPrimaryName(e){return Bs({aptosConfig:this.config,...e})}async registerName(e){return ks({aptosConfig:this.config,...e})}async renewDomain(e){return $s({aptosConfig:this.config,...e})}async getName(e){return Os({aptosConfig:this.config,...e})}async getAccountNames(e){return Fs({aptosConfig:this.config,...e})}async getAccountDomains(e){return Ms({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return qs({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Vs({aptosConfig:this.config,...e})}};async function Ls(n){let{aptosConfig:e,poolAddress:t}=n,r=u.from(t).toStringLong(),i=await f({aptosConfig:e,query:{query:Nr,variables:{where_condition:{pool_address:{_eq:r}}}}});return i.num_active_delegator_per_pool[0]?i.num_active_delegator_per_pool[0].num_active_delegator:0}async function Hs(n){let{aptosConfig:e,options:t}=n,r={query:Nr,variables:{order_by:_optionalChain([t, 'optionalAccess', _198 => _198.orderBy])}};return(await f({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function Qs(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,o={query:oi,variables:{delegatorAddress:u.from(t).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await f({aptosConfig:e,query:o})).delegated_staking_activities}var hn=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _199 => _199.minimumLedgerVersion]),processorType:"stake_processor"}),Ls({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _200 => _200.minimumLedgerVersion]),processorType:"stake_processor"}),Hs({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _201 => _201.minimumLedgerVersion]),processorType:"stake_processor"}),Qs({aptosConfig:this.config,...e})}};var pr=class{constructor(e){this.config=e}async simple(e){return h({aptosConfig:this.config,...e})}async multiAgent(e){return h({aptosConfig:this.config,...e})}};function ao(n,e,t){let r=t.value;return t.value=async function(...o){let[i]=o;if(i.transaction.feePayerAddress&&!i.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,o)},t}function co(n,e,t){let r=t.value;return t.value=async function(...o){let[i]=o;if(i.transaction.feePayerAddress&&!i.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return r.apply(this,o)},t}var Nt=class{constructor(e){this.config=e}async simple(e){return ro({aptosConfig:this.config,...e})}async multiAgent(e){return ro({aptosConfig:this.config,...e})}};_chunkBHKSQXUZjs.a.call(void 0, [co],Nt.prototype,"simple",1),_chunkBHKSQXUZjs.a.call(void 0, [co],Nt.prototype,"multiAgent",1);var Ot=class{constructor(e){this.config=e}async simple(e){return ar({aptosConfig:this.config,...e})}async multiAgent(e){return ar({aptosConfig:this.config,...e})}};_chunkBHKSQXUZjs.a.call(void 0, [ao],Ot.prototype,"simple",1),_chunkBHKSQXUZjs.a.call(void 0, [ao],Ot.prototype,"multiAgent",1);var dr=class{constructor(e,t,r,o,i){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=r,this.maximumInFlight=o,this.sleepTime=i}async nextSequenceNumber(){for(;this.lock;)await _chunkBHKSQXUZjs.b.call(void 0, this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=_chunkBHKSQXUZjs.c.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkBHKSQXUZjs.b.call(void 0, this.sleepTime),_chunkBHKSQXUZjs.c.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await xe({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await xe({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await _chunkBHKSQXUZjs.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunkBHKSQXUZjs.c.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkBHKSQXUZjs.c.call(void 0, )-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkBHKSQXUZjs.b.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var Ft=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _202 => _202.pendingDequeue, 'access', _203 => _203.shift, 'call', _204 => _204(), 'optionalAccess', _205 => _205.resolve, 'call', _206 => _206(e)]);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,t)=>{this.pendingDequeue.push({resolve:e,reject:t})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new Mt("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Mt=class extends Error{};var Ws="fulfilled",js= exports.TransactionWorkerEventsEnum =(i=>(i.TransactionSent="transactionSent",i.TransactionSendFailed="transactionSendFailed",i.TransactionExecuted="transactionExecuted",i.TransactionExecutionFailed="transactionExecutionFailed",i.ExecutionFinish="executionFinish",i))(js||{}),lr= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,o=30,i=100,s=10){super();this.taskQueue=new Ft;this.transactionsQueue=new Ft;this.outstandingTransactions=new Ft;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new dr(t,r,o,i,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let r=await this.generateNextTransaction(this.account,t);if(!r)return;let o=cn({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([o,t])}}catch(t){if(t instanceof Mt)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[o,i]=await this.outstandingTransactions.dequeue();for(t.push(o),r.push(i);!this.outstandingTransactions.isEmpty();)[o,i]=await this.outstandingTransactions.dequeue(),t.push(o),r.push(i);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];i=r[a],c.status===Ws?(this.sentTransactions.push([c.value.hash,i,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,i)):(this.sentTransactions.push([c.status,i,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof Mt)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let o=[];o.push(Gt({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let i=await Promise.allSettled(o);for(let s=0;s<i.length;s+=1){let a=i[s];a.status===Ws?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(o){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${o}`)}}async push(t,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[o,i]=await this.transactionsQueue.dequeue();return h({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:o,options:{...i,accountSequenceNumber:r}})}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 gr=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new lr(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:r}=e;for(let o of t)this.transactionWorker.push(o,r)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:r,options:o}=e;this.start({sender:t}),this.push({data:r,options:o})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var Tn=class{constructor(e){this.config=e,this.build=new pr(this.config),this.simulate=new Nt(this.config),this.submit=new Ot(this.config),this.batch=new gr(this.config)}async getTransactions(e){return $r({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return Ii({aptosConfig:this.config,...e})}async getTransactionByHash(e){return rn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return Ui({aptosConfig:this.config,...e})}async waitForTransaction(e){return Gt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Yn({aptosConfig:this.config})}getSigningMessage(e){return Wi(e)}async publishPackageTransaction(e){return ji({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Xi({aptosConfig:this.config,...e})}sign(e){return sr({...e})}signAsFeePayer(e){let{signer:t,transaction:r}=e;if(!r.feePayerAddress)throw new Error(`Transaction ${r} is not a Fee Payer transaction`);return r.feePayerAddress=t.accountAddress,sr({signer:t,transaction:r})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:r,options:o}=e;this.batch.forSingleAccount({sender:t,data:r,options:o})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){let{signer:t,transaction:r}=e;return cn({aptosConfig:this.config,signer:t,transaction:r})}};var bn=class{constructor(e){this.config=e}async getTableItem(e){return Wn({aptosConfig:this.config,...e})}async getTableItemsData(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),gi({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),mi({aptosConfig:this.config,...e})}};async function mr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,uidKey:o="sub",derivationPath:i}=n,s={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:l.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:o,derivation_path:i},{data:a}=await $o({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return l.fromHexInput(a.pepper).toUint8Array()}async function uo(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:o=await mr(n),uidKey:i="sub"}=n;if(l.fromHexInput(o).toUint8Array().length!==Se.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Se.PEPPER_LENGTH} bytes`);let{maxExpHorizonSecs:s}=await Qo({aptosConfig:e});if(s<r.expiryDateSecs-_chunkBHKSQXUZjs.c.call(void 0, ))throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let a={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:l.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:l.fromHexInput(o).toStringWithoutPrefix(),uid_key:i},{data:c}=await Lo({aptosConfig:e,path:"prove",body:a,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),p=c.proof,y=new bt({a:p.a,b:p.b,c:p.c});return new Ie({proof:new wt(y,0),trainingWheelsSignature:be.fromHex(c.training_wheels_signature),expHorizonSecs:s})}async function Xs(n){let{aptosConfig:e,jwt:t,uidKey:r,proofFetchCallback:o,pepper:i=await mr(n)}=n,s=uo({...n,pepper:i}),a=o?s:await s,c=ee.fromJwtAndPepper({jwt:t,pepper:i,uidKey:r}),p=await nn({aptosConfig:e,authenticationKey:c.authKey().derivedAddress()});return Se.create({...n,address:p,proof:a,pepper:i,proofFetchCallback:o})}var wn=class{constructor(e){this.config=e}async getPepper(e){return mr({aptosConfig:this.config,...e})}async getProof(e){return uo({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Xs({aptosConfig:this.config,...e})}};async function Qc(n){let{aptosConfig:e,options:t}=n,r={query:$n,variables:{where_condition:_optionalChain([t, 'optionalAccess', _207 => _207.where]),offset:_optionalChain([t, 'optionalAccess', _208 => _208.offset]),limit:_optionalChain([t, 'optionalAccess', _209 => _209.limit]),order_by:_optionalChain([t, 'optionalAccess', _210 => _210.orderBy])}};return(await f({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function Ys(n){let{aptosConfig:e,objectAddress:t,options:r}=n,i={object_address:{_eq:u.from(t).toStringLong()}};return(await Qc({aptosConfig:e,options:{...r,where:i}}))[0]}var Sn=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Ys({aptosConfig:this.config,...e})}};var j=class{constructor(e){this.config=new Jn(e),this.account=new on(this.config),this.ans=new An(this.config),this.coin=new un(this.config),this.digitalAsset=new pn(this.config),this.event=new ln(this.config),this.faucet=new gn(this.config),this.fungibleAsset=new mn(this.config),this.general=new yn(this.config),this.staking=new hn(this.config),this.transaction=new Tn(this.config),this.table=new bn(this.config),this.keyless=new wn(this.config),this.object=new Sn(this.config)}};function re(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let o=Object.getOwnPropertyDescriptor(e.prototype,r);o&&(o.value=function(...i){return this[t][r](...i)},Object.defineProperty(n.prototype,r,o))})}re(j,on,"account");re(j,An,"ans");re(j,un,"coin");re(j,pn,"digitalAsset");re(j,ln,"event");re(j,gn,"faucet");re(j,mn,"fungibleAsset");re(j,yn,"general");re(j,hn,"staking");re(j,Tn,"transaction");re(j,bn,"table");re(j,wn,"keyless");re(j,Sn,"object");exports.APTOS_BIP44_REGEX = la; exports.APTOS_COIN = kn; exports.APTOS_HARDENED_REGEX = da; exports.Account = $e; exports.AccountAddress = u; exports.AccountAuthenticator = H; exports.AccountAuthenticatorEd25519 = fe; exports.AccountAuthenticatorMultiEd25519 = Bn; exports.AccountAuthenticatorMultiKey = at; exports.AccountAuthenticatorSingleKey = Q; exports.AccountAuthenticatorVariant = Ao; exports.AccountPublicKey = ie; exports.AccountSequenceNumber = dr; exports.AddressInvalidReason = aa; exports.AnyPublicKey = k; exports.AnyPublicKeyVariant = Ar; exports.AnySignature = B; exports.AnySignatureVariant = ho; exports.Aptos = j; exports.AptosApiError = ye; exports.AptosApiType = Ht; exports.AptosConfig = Jn; exports.AuthenticationKey = q; exports.Bool = I; exports.CKDPriv = Po; exports.ChainId = xt; exports.DEFAULT_MAX_GAS_AMOUNT = Ko; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = No; exports.DEFAULT_TXN_TIMEOUT_SEC = Dn; exports.DeriveScheme = ia; exports.Deserializer = oe; exports.EPK_HORIZON_SECS = hl; exports.Ed25519Account = Rt; exports.Ed25519PrivateKey = L; exports.Ed25519PublicKey = _; exports.Ed25519Signature = v; exports.EntryFunction = ut; exports.EntryFunctionBytes = Pn; exports.EphemeralCertificate = Tt; exports.EphemeralCertificateVariant = Tr; exports.EphemeralKeyPair = tn; exports.EphemeralPublicKey = ot; exports.EphemeralPublicKeyVariant = hr; exports.EphemeralSignature = be; exports.EphemeralSignatureVariant = To; exports.FeePayerRawTransaction = dt; exports.FixedBytes = Ze; exports.Groth16Zkp = bt; exports.HARDENED_OFFSET = xo; exports.Hex = l; exports.HexInvalidReason = ta; exports.Identifier = R; exports.KeyType = ga; exports.KeylessAccount = Se; exports.KeylessConfiguration = Dr; exports.KeylessPublicKey = ee; exports.KeylessSignature = Ee; exports.MAX_AUD_VAL_BYTES = Fa; exports.MAX_COMMITED_EPK_BYTES = Sl; exports.MAX_EXTRA_FIELD_BYTES = bl; exports.MAX_ISS_VAL_BYTES = Tl; exports.MAX_JWT_HEADER_B64_BYTES = wl; exports.MAX_UID_KEY_BYTES = Ma; exports.MAX_UID_VAL_BYTES = qa; exports.MimeType = Cn; exports.ModuleId = Wt; exports.MoveAbility = bo; exports.MoveFunctionVisibility = ra; exports.MoveOption = M; exports.MoveString = b; exports.MoveVector = T; exports.MultiAgentRawTransaction = pt; exports.MultiAgentTransaction = Mn; exports.MultiEd25519PublicKey = ft; exports.MultiEd25519Signature = tt; exports.MultiKey = St; exports.MultiKeyAccount = qn; exports.MultiKeySignature = st; exports.MultiSig = Jt; exports.MultiSigTransactionPayload = en; exports.Network = Er; exports.NetworkToChainId = Ir; exports.NetworkToFaucetAPI = Bo; exports.NetworkToIndexerAPI = ko; exports.NetworkToNetworkName = Td; exports.NetworkToNodeAPI = Go; exports.NetworkToPepperAPI = Pr; exports.NetworkToProverAPI = Cr; exports.ParsingError = Y; exports.ProcessorType = Ke; exports.PublicKey = Je; exports.RAW_TRANSACTION_SALT = Oo; exports.RAW_TRANSACTION_WITH_DATA_SALT = Ur; exports.RawTransaction = ue; exports.RawTransactionWithData = Nn; exports.RoleType = oa; exports.RotationProofChallenge = On; exports.Script = Zt; exports.ScriptTransactionArgumentVariants = Vt; exports.Secp256k1PrivateKey = rt; exports.Secp256k1PublicKey = Te; exports.Secp256k1Signature = Pe; exports.Serializable = d; exports.Serializer = Z; exports.Signature = G; exports.SignedTransaction = lt; exports.SigningScheme = Ae; exports.SigningSchemeInput = Sr; exports.SimpleTransaction = Fn; exports.SingleKeyAccount = zt; exports.StructTag = Ue; exports.TransactionAuthenticator = Re; exports.TransactionAuthenticatorEd25519 = vt; exports.TransactionAuthenticatorFeePayer = Ct; exports.TransactionAuthenticatorMultiAgent = Pt; exports.TransactionAuthenticatorMultiEd25519 = Gr; exports.TransactionAuthenticatorSingleSender = Et; exports.TransactionAuthenticatorVariant = fo; exports.TransactionPayload = ct; exports.TransactionPayloadEntryFunction = Xt; exports.TransactionPayloadMultiSig = Yt; exports.TransactionPayloadScript = jt; exports.TransactionPayloadVariants = mo; exports.TransactionResponseType = wr; exports.TransactionVariants = yo; exports.TransactionWorker = lr; exports.TransactionWorkerEventsEnum = js; exports.TypeTag = z; exports.TypeTagAddress = W; exports.TypeTagBool = K; exports.TypeTagGeneric = D; exports.TypeTagParserError = N; exports.TypeTagParserErrorType = cc; exports.TypeTagReference = Kn; exports.TypeTagSigner = _t; exports.TypeTagStruct = m; exports.TypeTagU128 = qe; exports.TypeTagU16 = Fe; exports.TypeTagU256 = Ve; exports.TypeTagU32 = Me; exports.TypeTagU64 = $; exports.TypeTagU8 = ce; exports.TypeTagVariants = go; exports.TypeTagVector = C; exports.U128 = ge; exports.U16 = de; exports.U256 = me; exports.U32 = le; exports.U64 = O; exports.U8 = F; exports.ZeroKnowledgeSig = Ie; exports.ZkProof = wt; exports.ZkpVariant = br; exports.aptosCoinStructTag = Rg; exports.aptosRequest = Gn; exports.buildTransaction = to; exports.checkOrConvertArgument = Bt; exports.convertArgument = eo; exports.convertNumber = er; exports.deriveKey = xr; exports.deriveTransactionType = Br; exports.deserializeFromScriptArgument = Ha; exports.ensureBoolean = fr; exports.fetchEntryFunctionAbi = qi; exports.fetchFunctionAbi = Mi; exports.fetchViewFunctionAbi = Vi; exports.findFirstNonSignerArg = Fi; exports.generateRawTransaction = Ac; exports.generateSignedTransaction = no; exports.generateSignedTransactionForSimulation = Li; exports.generateSigningMessage = It; exports.generateSigningMessageForSerializable = Vm; exports.generateSigningMessageForTransaction = Ut; exports.generateTransactionPayload = ir; exports.generateTransactionPayloadWithABI = mc; exports.generateUserTransactionHash = BA; exports.generateViewFunctionPayload = $i; exports.generateViewFunctionPayloadWithABI = yc; exports.get = Rr; exports.getAptosFullNode = V; exports.getAptosPepperService = qd; exports.getAuthenticatorForSimulation = or; exports.getFunctionParts = an; exports.getKeylessConfig = Qo; exports.hashValues = Hi; exports.isBcsAddress = nr; exports.isBcsBool = Lr; exports.isBcsFixedBytes = pc; exports.isBcsString = Hr; exports.isBcsU128 = Yr; exports.isBcsU16 = Wr; exports.isBcsU256 = Zr; exports.isBcsU32 = jr; exports.isBcsU64 = Xr; exports.isBcsU8 = Qr; exports.isBlockMetadataTransactionResponse = Tu; exports.isBool = Bi; exports.isEd25519Signature = Su; exports.isEmptyOption = Ki; exports.isEncodedEntryFunctionArgument = Ni; exports.isFeePayerSignature = vu; exports.isGenesisTransactionResponse = hu; exports.isLargeNumber = tr; exports.isMultiAgentSignature = _u; exports.isMultiEd25519Signature = Pu; exports.isNumber = uc; exports.isPendingTransactionResponse = fu; exports.isScriptDataInput = Oi; exports.isSecp256k1Signature = xu; exports.isStateCheckpointTransactionResponse = bu; exports.isString = He; exports.isUserTransactionResponse = Au; exports.isValidBIP44Path = _o; exports.isValidHardenedPath = vo; exports.isValidatorTransactionResponse = wu; exports.mnemonicToSeed = En; exports.normalizeBundle = Fo; exports.objectStructTag = ne; exports.optionStructTag = zg; exports.outOfRangeErrorMessage = na; exports.paginateWithCursor = ht; exports.parseTypeTag = ze; exports.post = Qt; exports.postAptosFaucet = Vo; exports.postAptosFullNode = Ne; exports.postAptosIndexer = qo; exports.postAptosPepperService = $o; exports.postAptosProvingService = Lo; exports.promiseFulfilledStatus = Ws; exports.request = Na; exports.splitPath = Co; exports.standardizeTypeTags = rr; exports.stringStructTag = P; exports.throwTypeMismatch = U; exports.validateNumberInRange = Ge;
470
+ `;async function Ln(n){let{aptosConfig:e}=n,{data:t}=await V({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function mi(n){let{aptosConfig:e,limit:t}=n;return(await f({aptosConfig:e,query:{query:ri,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function f(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:o}=await Vo({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return o}async function rc(n){let{aptosConfig:e}=n;return(await f({aptosConfig:e,query:{query:Or},originMethod:"getProcessorStatuses"})).processor_status}async function Hn(n){let e=await rc({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function Qn(n){let{aptosConfig:e,processorType:t}=n;return(await f({aptosConfig:e,query:{query:Or,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function Wn(n){let{aptosConfig:e,handle:t,data:r,options:o}=n;return(await Ne({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _35 => _35.ledgerVersion])},body:r})).data}async function yi(n){let{aptosConfig:e,options:t}=n,r={query:pi,variables:{where_condition:_optionalChain([t, 'optionalAccess', _36 => _36.where]),offset:_optionalChain([t, 'optionalAccess', _37 => _37.offset]),limit:_optionalChain([t, 'optionalAccess', _38 => _38.limit]),order_by:_optionalChain([t, 'optionalAccess', _39 => _39.orderBy])}};return(await f({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function fi(n){let{aptosConfig:e,options:t}=n,r={query:di,variables:{where_condition:_optionalChain([t, 'optionalAccess', _40 => _40.where]),offset:_optionalChain([t, 'optionalAccess', _41 => _41.offset]),limit:_optionalChain([t, 'optionalAccess', _42 => _42.limit]),order_by:_optionalChain([t, 'optionalAccess', _43 => _43.orderBy])}};return(await f({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function xe(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getInfo",path:`accounts/${u.from(t).toString()}`});return r}async function Ti(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ht({aptosConfig:e,originMethod:"getModules",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _44 => _44.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _45 => _45.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _46 => _46.limit]), () => (1e3))}})}async function jn(n){return _optionalChain([n, 'access', _47 => _47.options, 'optionalAccess', _48 => _48.ledgerVersion])!==void 0?Ai(n):Oe(async()=>Ai(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function Ai(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:o}=n,{data:i}=await V({aptosConfig:e,originMethod:"getModule",path:`accounts/${u.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _49 => _49.ledgerVersion])}});return i}async function bi(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ht({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${u.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _50 => _50.offset]),limit:_optionalChain([r, 'optionalAccess', _51 => _51.limit])}})}async function wi(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ht({aptosConfig:e,originMethod:"getResources",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _52 => _52.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _53 => _53.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _54 => _54.limit]), () => (999))}})}async function Mr(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:o}=n,{data:i}=await V({aptosConfig:e,originMethod:"getResource",path:`accounts/${u.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _55 => _55.ledgerVersion])}});return i.data}async function nn(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,o=await Mr({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:i}}=o,s=u.from(t);try{let a=await Wn({aptosConfig:e,handle:i,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof ye&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Si(n){let{aptosConfig:e,accountAddress:t}=n,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},s=await f({aptosConfig:e,query:{query:ti,variables:{where_condition:o}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function xi(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _56 => _56.tokenStandard])&&(i.token_standard={_eq:_optionalChain([r, 'optionalAccess', _57 => _57.tokenStandard])});let s={query:Jo,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _58 => _58.offset]),limit:_optionalChain([r, 'optionalAccess', _59 => _59.limit]),order_by:_optionalChain([r, 'optionalAccess', _60 => _60.orderBy])}};return(await f({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function _i(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:o}=n,i=u.from(t).toStringLong(),s=u.from(r).toStringLong(),a={owner_address:{_eq:i},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([o, 'optionalAccess', _61 => _61.tokenStandard])&&(a.token_standard={_eq:_optionalChain([o, 'optionalAccess', _62 => _62.tokenStandard])});let c={query:ei,variables:{where_condition:a,offset:_optionalChain([o, 'optionalAccess', _63 => _63.offset]),limit:_optionalChain([o, 'optionalAccess', _64 => _64.limit]),order_by:_optionalChain([o, 'optionalAccess', _65 => _65.orderBy])}};return(await f({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function vi(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _66 => _66.tokenStandard])&&(i.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _67 => _67.tokenStandard])}});let s={query:Zo,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _68 => _68.offset]),limit:_optionalChain([r, 'optionalAccess', _69 => _69.limit]),order_by:_optionalChain([r, 'optionalAccess', _70 => _70.orderBy])}};return(await f({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function Pi(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),i=await f({aptosConfig:e,query:{query:ni,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return i.account_transactions_aggregate.aggregate?i.account_transactions_aggregate.aggregate.count:0}async function Ci(n){let{aptosConfig:e,accountAddress:t,coinType:r}=n,o=u.from(t).toStringLong(),i=await qr({aptosConfig:e,accountAddress:o,options:{where:{asset_type:{_eq:r}}}});return i[0]?i[0].amount:0}async function qr(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o=u.from(t).toStringLong(),i={..._optionalChain([r, 'optionalAccess', _71 => _71.where]),owner_address:{_eq:o}},s={query:Yo,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _72 => _72.offset]),limit:_optionalChain([r, 'optionalAccess', _73 => _73.limit]),order_by:_optionalChain([r, 'optionalAccess', _74 => _74.orderBy])}};return(await f({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Ei(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),i=await f({aptosConfig:e,query:{query:Xo,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!i.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return i.current_fungible_asset_balances_aggregate.aggregate.count}async function Ii(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()}},s={query:$n,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _75 => _75.offset]),limit:_optionalChain([r, 'optionalAccess', _76 => _76.limit]),order_by:_optionalChain([r, 'optionalAccess', _77 => _77.orderBy])}};return(await f({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function Ui(n){let{aptosConfig:e,privateKey:t}=n,r=new k(t.publicKey());if(t instanceof rt){let i=q.fromPublicKey({publicKey:r}).derivedAddress();return $e.fromPrivateKey({privateKey:t,address:i})}if(t instanceof L){let o=q.fromPublicKey({publicKey:r});if(await hi({authKey:o,aptosConfig:e})){let c=o.derivedAddress();return $e.fromPrivateKey({privateKey:t,address:c,legacy:!1})}let s=q.fromPublicKey({publicKey:r.publicKey});if(await hi({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return $e.fromPrivateKey({privateKey:t,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${t}`)}async function hi(n){let{aptosConfig:e,authKey:t}=n,r=await nn({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await xe({aptosConfig:e,accountAddress:r}),!0}catch(o){if(o.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function $r(n){let{aptosConfig:e,options:t}=n;return ht({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _78 => _78.offset]),limit:_optionalChain([t, 'optionalAccess', _79 => _79.limit])}})}async function Yn(n){let{aptosConfig:e}=n;return Oe(async()=>{let{data:t}=await V({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function Ri(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function rn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await V({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function zi(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await rn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _80 => _80.status])===404)return!0;throw r}}async function oc(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await V({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return r}async function Bt(n){let{aptosConfig:e,transactionHash:t,options:r}=n,o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _81 => _81.timeoutSecs]), () => (20)),i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _82 => _82.checkSuccess]), () => (!0)),s=!0,a=0,c,p,y=200,w=1.5;function S(g){if(!(g instanceof ye)||(p=g,g.status!==404&&g.status>=400&&g.status<500))throw g}try{c=await rn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(g){S(g)}if(s){let g=Date.now();try{c=await oc({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(E){S(E)}a=(Date.now()-g)/1e3}for(;s&&!(a>=o);){try{if(c=await rn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(g){S(g)}await _chunkBHKSQXUZjs.b.call(void 0, y),a+=y/1e3,y*=w}if(c===void 0)throw p||new Xn(`Fetching transaction ${t} failed and timed out after ${o} seconds`,c);if(c.type==="pending_transaction")throw new Xn(`Transaction ${t} timed out in pending state after ${o} seconds`,c);if(!i)return c;if(!c.success)throw new Vr(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function Zn(n){let{aptosConfig:e,processorType:t}=n,r=BigInt(n.minimumLedgerVersion),o=3e3,i=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-i>o)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await Hn({aptosConfig:e}):s=(await Qn({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunkBHKSQXUZjs.b.call(void 0, 200)}}var Xn=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},Vr=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function Di(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:o}=await V({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _83 => _83.withTransactions])}});return Bi({block:o,...n})}async function ki(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:o}=await V({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _84 => _84.withTransactions])}});return Bi({block:o,...n})}async function Bi(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _85 => _85.withTransactions])){t.transactions=_nullishCoalesce(t.transactions, () => ([]));let o=t.transactions[t.transactions.length-1],i=BigInt(t.first_version),s=BigInt(t.last_version),a=_optionalChain([o, 'optionalAccess', _86 => _86.version]),c;if(a===void 0?c=i-1n:c=BigInt(a),c===s)return t;let p=[],y=100n;for(let S=c+1n;S<s;S+=BigInt(100))p.push($r({aptosConfig:e,options:{offset:S,limit:Math.min(Number(y),Number(s-S+1n))}}));let w=await Promise.all(p);for(let S of w)t.transactions.push(...S)}return t}async function A(n){n.minimumLedgerVersion!==void 0&&await Zn({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}var on=class{constructor(e){this.config=e}async getAccountInfo(e){return xe({aptosConfig:this.config,...e})}async getAccountModules(e){return Ti({aptosConfig:this.config,...e})}async getAccountModule(e){return jn({aptosConfig:this.config,...e})}async getAccountTransactions(e){return bi({aptosConfig:this.config,...e})}async getAccountResources(e){return wi({aptosConfig:this.config,...e})}async getAccountResource(e){return Mr({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return nn({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Si({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),xi({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),_i({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),vi({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Pi({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),qr({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Ei({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:kn,...e})}async getAccountCoinAmount(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Ci({aptosConfig:this.config,...e})}async getAccountOwnedObjects(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Ii({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return Ui({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Jn=class{constructor(e){this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _87 => _87.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _88 => _88.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _89 => _89.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _90 => _90.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _91 => _91.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _92 => _92.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _93 => _93.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _94 => _94.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _95 => _95.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _96 => _96.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _97 => _97.faucetConfig]), () => ({}))}getRequestUrl(e){switch(e){case"Fullnode":if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return Go[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return Ko[this.network];case"Indexer":if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return Bo[this.network];case"Pepper":if(this.pepper!==void 0)return this.pepper;if(this.network==="custom")throw new Error("Please provide a custom pepper service url");return Pr[this.network];case"Prover":if(this.prover!==void 0)return this.prover;if(this.network==="custom")throw new Error("Please provide a custom prover service url");return Cr[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return Pr[this.network]===e}isProverServiceRequest(e){return Cr[this.network]===e}};function Gi(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Ki(n){return!!n.match(/\s/)}function sc(n){return!!n.match(/^T[0-9]+$/)}function ac(n){return!!n.match(/^&.+$/)}function cc(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function uc(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!Ki(r))break}return t}var pc=(E=>(E.InvalidTypeTag="unknown type",E.UnexpectedGenericType="unexpected generic type",E.UnexpectedTypeArgumentClose="unexpected '>'",E.UnexpectedWhitespaceCharacter="unexpected whitespace character",E.UnexpectedComma="unexpected ','",E.TypeArgumentCountMismatch="type argument count doesn't match expected amount",E.MissingTypeArgumentClose="no matching '>' for '<'",E.MissingTypeArgument="no type argument before ','",E.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",E.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",E.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",E.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",E.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",E.InvalidAddress="struct address must be valid",E))(pc||{}),N= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function ze(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _98 => _98.allowGenerics]), () => (!1)),r=[],o=[],i=[],s=0,a="",c=1;for(;s<n.length;){let p=n[s];if(p==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:i}),a="",i=[],c=1;else if(p===">"){if(a!==""){let E=sn(a,o,t);i.push(E)}let y=r.pop();if(y===void 0)throw new N(n,"unexpected '>'");if(c!==i.length)throw new N(n,"type argument count doesn't match expected amount");let{savedStr:w,savedTypes:S,savedExpectedTypes:g}=y;o=i,i=S,a=w,c=g}else if(p===","){if(r.length===0)throw new N(n,"unexpected ','");if(a.length===0)throw new N(n,"no type argument before ','");let y=sn(a,o,t);o=[],i.push(y),a="",c+=1}else if(Ki(p)){let y=!1;if(a.length!==0){let S=sn(a,o,t);o=[],i.push(S),a="",y=!0}s=uc(n,s);let w=n[s];if(s<n.length&&y&&w!==","&&w!==">")throw new N(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new N(n,"no matching '>' for '<'");switch(i.length){case 0:return sn(a,o,t);case 1:if(a==="")return i[0];throw new N(n,"unexpected ','");default:throw new N(n,"unexpected whitespace character")}}function sn(n,e,t){let r=n.trim(),o=r.toLowerCase();if(cc(o)&&e.length>0)throw new N(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new _t;case"bool":return new K;case"address":return new W;case"u8":return new ce;case"u16":return new Fe;case"u32":return new Me;case"u64":return new $;case"u128":return new qe;case"u256":return new Ve;case"vector":if(e.length!==1)throw new N(n,"vector type expected to have exactly one type argument");return new C(e[0]);default:if(ac(r)){let a=r.substring(1);return new Kn(sn(a,e,t))}if(sc(r)){if(t)return new D(Number(r.split("T")[1]));throw new N(n,"unexpected generic type")}if(!r.match(/:/))throw new N(n,"unknown type");let i=r.split("::");if(i.length!==3)throw new N(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=u.fromString(i[0])}catch (e2){throw new N(n,"struct address must be valid")}if(!Gi(i[1]))throw new N(n,"module name must only contain alphanumeric or '_' characters");if(!Gi(i[2]))throw new N(n,"struct name must only contain alphanumeric or '_' characters");return new m(new Ue(s,new R(i[1]),new R(i[2]),e))}}function Ni(n){return typeof n=="boolean"}function He(n){return typeof n=="string"}function dc(n){return typeof n=="number"}function er(n){if(dc(n))return n;if(He(n)&&n!=="")return Number.parseInt(n,10)}function tr(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Oi(n){return n==null}function Fi(n){return Lr(n)||Qr(n)||Wr(n)||jr(n)||Xr(n)||Yr(n)||Zr(n)||nr(n)||Hr(n)||lc(n)||n instanceof T||n instanceof M}function Lr(n){return n instanceof I}function nr(n){return n instanceof u}function Hr(n){return n instanceof b}function lc(n){return n instanceof Ze}function Qr(n){return n instanceof F}function Wr(n){return n instanceof de}function jr(n){return n instanceof le}function Xr(n){return n instanceof O}function Yr(n){return n instanceof ge}function Zr(n){return n instanceof me}function Mi(n){return"bytecode"in n}function U(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function qi(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}function an(n){let e=n.split("::");if(e.length!==3)throw new Error(`Invalid function ${n}`);let t=e[0],r=e[1],o=e[2];return{moduleAddress:t,moduleName:r,functionName:o}}var gc=new TextEncoder;function rr(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _99 => _99.map, 'call', _100 => _100(e=>He(e)?ze(e):e)]), () => ([]))}async function Vi(n,e,t,r){let o=await jn({aptosConfig:r,accountAddress:n,moduleName:e});if(o.abi)return o.abi.exposed_functions.find(i=>i.name===t)}async function $i(n,e,t,r){let o=await Vi(n,e,t,r);if(!o)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!o.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let i=qi(o),s=[];for(let a=i;a<o.params.length;a+=1)s.push(ze(o.params[a],{allowGenerics:!0}));return{signers:i,typeParameters:o.generic_type_params,parameters:s}}async function Li(n,e,t,r){let o=await Vi(n,e,t,r);if(!o)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!o.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let i=[];for(let a=0;a<o.params.length;a+=1)i.push(ze(o.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<o.return.length;a+=1)s.push(ze(o.return[a],{allowGenerics:!0}));return{typeParameters:o.generic_type_params,parameters:i,returnTypes:s}}function eo(n,e,t,r,o){if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);let i=e.parameters[r];return Gt(t,i,r,o)}function Gt(n,e,t,r){return Fi(n)?(Jr(e,n,t),n):mc(n,e,t,r)}function mc(n,e,t,r){if(e.isBool()){if(Ni(n))return new I(n);if(He(n)){if(n==="true")return new I(!0);if(n==="false")return new I(!1)}U("boolean",t)}if(e.isAddress()){if(He(n))return u.fromString(n);U("string | AccountAddress",t)}if(e.isU8()){let o=er(n);if(o!==void 0)return new F(o);U("number | string",t)}if(e.isU16()){let o=er(n);if(o!==void 0)return new de(o);U("number | string",t)}if(e.isU32()){let o=er(n);if(o!==void 0)return new le(o);U("number | string",t)}if(e.isU64()){if(tr(n))return new O(BigInt(n));U("bigint | number | string",t)}if(e.isU128()){if(tr(n))return new ge(BigInt(n));U("bigint | number | string",t)}if(e.isU256()){if(tr(n))return new me(BigInt(n));U("bigint | number | string",t)}if(e.isGeneric()){let o=e.value;if(o<0||o>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return Gt(n,r[o],t,r)}if(e.isVector()){if(e.value.isU8()){if(He(n))return T.U8(gc.encode(n));if(n instanceof Uint8Array)return T.U8(n);if(n instanceof ArrayBuffer)return T.U8(new Uint8Array(n))}if(Array.isArray(n))return new T(n.map(o=>Gt(o,e.value,t,r)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(He(n))return new b(n);U("string",t)}if(e.isObject()){if(He(n))return u.fromString(n);U("string | AccountAddress",t)}if(e.isOption()){if(Oi(n)){let o=e.value.typeArgs[0];return o instanceof K?new M(null):o instanceof W?new M(null):o instanceof ce?new M(null):o instanceof Fe?new M(null):o instanceof Me?new M(null):o instanceof $?new M(null):o instanceof qe?new M(null):o instanceof Ve?new M(null):new M(null)}return new M(Gt(n,e.value.typeArgs[0],t,r))}throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function Jr(n,e,t){if(n.isBool()){if(Lr(e))return;U("Bool",t)}if(n.isAddress()){if(nr(e))return;U("AccountAddress",t)}if(n.isU8()){if(Qr(e))return;U("U8",t)}if(n.isU16()){if(Wr(e))return;U("U16",t)}if(n.isU32()){if(jr(e))return;U("U32",t)}if(n.isU64()){if(Xr(e))return;U("U64",t)}if(n.isU128()){if(Yr(e))return;U("U128",t)}if(n.isU256()){if(Zr(e))return;U("U256",t)}if(n.isVector()){if(e instanceof T){e.values.length>0&&Jr(n.value,e.values[0],t);return}U("MoveVector",t)}if(n instanceof m){if(n.isString()){if(Hr(e))return;U("MoveString",t)}if(n.isObject()){if(nr(e))return;U("AccountAddress",t)}if(n.isOption()){if(e instanceof M){e.value!==void 0&&Jr(n.value.typeArgs[0],e.value,t);return}U("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function ir(n){if(Mi(n))return hc(n);let{moduleAddress:e,moduleName:t,functionName:r}=an(n.function),o=await ji({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:$i});return fc({...n,abi:o})}function fc(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:o}=an(n.function),i=rr(n.typeArguments);if(i.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${i.length}`);let s=n.functionArguments.map((c,p)=>eo(n.function,e,c,p,i));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${o}', expected ${e.parameters.length} but got ${s.length}`);let a=ut.build(`${t}::${r}`,o,i,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new Yt(new Jt(c,new en(a)))}return new Xt(a)}async function Hi(n){let{moduleAddress:e,moduleName:t,functionName:r}=an(n.function),o=await ji({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Li});return Ac({abi:o,...n})}function Ac(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:o}=an(n.function),i=rr(n.typeArguments);if(i.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${i.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _101 => _101.functionArguments, 'optionalAccess', _102 => _102.map, 'call', _103 => _103((a,c)=>eo(n.function,e,a,c,i))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${o}', expected ${e.parameters.length} but got ${s.length}`);return ut.build(`${t}::${r}`,o,i,s)}function hc(n){return new jt(new Zt(l.fromHexInput(n.bytecode).toUint8Array(),rr(n.typeArguments),n.functionArguments))}async function Tc(n){let{aptosConfig:e,sender:t,payload:r,options:o,feePayerAddress:i}=n,s=async()=>Ir[e.network]?{chainId:Ir[e.network]}:{chainId:(await Ln({aptosConfig:e})).chain_id},a=async()=>_optionalChain([o, 'optionalAccess', _104 => _104.gasUnitPrice])?{gasEstimate:o.gasUnitPrice}:{gasEstimate:(await Yn({aptosConfig:e})).gas_estimate},c=async()=>{let gt=async()=>_optionalChain([o, 'optionalAccess', _105 => _105.accountSequenceNumber])!==void 0?o.accountSequenceNumber:(await xe({aptosConfig:e,accountAddress:t})).sequence_number;if(i&&u.from(i).equals(u.ZERO))try{return await gt()}catch (e3){return 0}else return gt()},[{chainId:p},{gasEstimate:y},w]=await Promise.all([s(),a(),c()]),{maxGasAmount:S,gasUnitPrice:g,expireTimestamp:E}={maxGasAmount:_optionalChain([o, 'optionalAccess', _106 => _106.maxGasAmount])?BigInt(o.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _107 => _107.gasUnitPrice]), () => (BigInt(y))),expireTimestamp:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _108 => _108.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new ue(u.from(t),BigInt(w),r,BigInt(S),BigInt(g),BigInt(E),new xt(p))}async function to(n){let{aptosConfig:e,sender:t,payload:r,options:o,feePayerAddress:i}=n,s=await Tc({aptosConfig:e,sender:t,payload:r,options:o,feePayerAddress:i});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _109 => _109.secondarySignerAddresses, 'optionalAccess', _110 => _110.map, 'call', _111 => _111(c=>u.from(c))]), () => ([]));return new Mn(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new Fn(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function Qi(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:o}=n,i=or(e);if(t.feePayerAddress){let a=new dt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];r&&(c=r.map(w=>or(w)));let p=or(o),y=new Ct(i,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:p});return new lt(a.raw_txn,y).bcsToBytes()}if(t.secondarySignerAddresses){let a=new pt(t.rawTransaction,t.secondarySignerAddresses),c=[];c=r.map(y=>or(y));let p=new Pt(i,t.secondarySignerAddresses,c);return new lt(a.raw_txn,p).bcsToBytes()}let s;if(i instanceof fe)s=new vt(i.public_key,i.signature);else if(i instanceof Q)s=new Et(i);else throw new Error("Invalid public key");return new lt(t.rawTransaction,s).bcsToBytes()}function or(n){if((n instanceof ee||n instanceof Te)&&(n=new k(n)),n instanceof k){if(n.publicKey instanceof _)return new Q(n,new G(new v(new Uint8Array(64))));if(n.publicKey instanceof Te)return new Q(n,new G(new Pe(new Uint8Array(64))));if(n.publicKey instanceof ee)return new Q(n,new G(Ee.getSimulationSignature()))}return new fe(new _(n.toUint8Array()),new v(new Uint8Array(64)))}function no(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,o=Mo(H,n.senderAuthenticator),i;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");i=new Ct(o,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");i=new Pt(o,e.secondarySignerAddresses,r)}else o instanceof fe?i=new vt(o.public_key,o.signature):i=new Et(o);return new lt(e.rawTransaction,i).bcsToBytes()}function Wi(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var bc=Wi(["APTOS::Transaction"]);function jA(n){let e=no(n);return new l(Wi([bc,new Uint8Array([0]),e])).toString()}async function ji({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:o,abi:i,fetch:s}){return i!==void 0?i:Oe(async()=>s(e,t,r,o),`${n}-${o.network}-${e}-${t}-${r}`,1e3*60*5)()}async function h(n){let e=await wc(n);return Sc(n,e)}async function wc(n){let{aptosConfig:e,data:t}=n,r,o;return"bytecode"in t?o=await ir(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},o=await ir(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},o=await ir(r)),o}async function Sc(n,e){let{aptosConfig:t,sender:r,options:o}=n,i;if(xc(n)&&(i=u.ZERO.toString()),_c(n)){let{secondarySignerAddresses:s}=n;return to({aptosConfig:t,sender:r,payload:e,options:o,secondarySignerAddresses:s,feePayerAddress:i})}return to({aptosConfig:t,sender:r,payload:e,options:o,feePayerAddress:i})}function xc(n){return n.withFeePayer===!0}function _c(n){return"secondarySignerAddresses"in n}function Xi(n){let{transaction:e}=n;return Ut(e)}function sr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}async function ro(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:s}=n,a=Qi({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:s}),{data:c}=await Ne({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _112 => _112.options, 'optionalAccess', _113 => _113.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _114 => _114.options, 'optionalAccess', _115 => _115.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _116 => _116.options, 'optionalAccess', _117 => _117.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function ar(n){let{aptosConfig:e}=n,t=no({...n}),{data:r}=await Ne({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function cn(n){let{aptosConfig:e,signer:t,transaction:r}=n;(t instanceof Se||t instanceof qn)&&await t.waitForProofFetch();let o=sr({signer:t,transaction:r});return ar({aptosConfig:e,transaction:r,senderAuthenticator:o})}var vc={typeParameters:[],parameters:[C.u8(),new C(C.u8())]};async function Yi(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:o,options:i}=n,s=o.map(a=>T.U8(a));return h({aptosConfig:e,sender:u.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[T.U8(r),new T(s)],abi:vc},options:i})}var Pc={typeParameters:[],parameters:[new ce,C.u8(),new ce,C.u8(),C.u8(),C.u8()]};async function Zi(n){let{aptosConfig:e,fromAccount:t,toNewPrivateKey:r}=n,o=await xe({aptosConfig:e,accountAddress:t.accountAddress}),i=$e.fromPrivateKey({privateKey:r,legacy:!0}),a=new On({sequenceNumber:BigInt(o.sequence_number),originator:t.accountAddress,currentAuthKey:u.from(o.authentication_key),newPublicKey:i.publicKey}).bcsToBytes(),c=t.sign(a),p=i.sign(a),y=await h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new F(t.signingScheme),T.U8(t.publicKey.toUint8Array()),new F(i.signingScheme),T.U8(i.publicKey.toUint8Array()),T.U8(c.toUint8Array()),T.U8(p.toUint8Array())],abi:Pc}});return cn({aptosConfig:e,signer:t,transaction:y})}var Cc={typeParameters:[{constraints:[]}],parameters:[new W,new $]};async function Ji(n){let{aptosConfig:e,sender:t,recipient:r,amount:o,coinType:i,options:s}=n;return h({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(i, () => (kn))],functionArguments:[r,o],abi:Cc},options:s})}var un=class{constructor(e){this.config=e}async transferCoinTransaction(e){return Ji({aptosConfig:this.config,...e})}};var Qe={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},pe="0x4::token::Token";async function es(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()}};return(await f({aptosConfig:e,query:{query:gi,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function ts(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};return(await f({aptosConfig:e,query:{query:Fr,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function ns(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},i={query:Fr,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _118 => _118.offset]),limit:_optionalChain([r, 'optionalAccess', _119 => _119.limit]),order_by:_optionalChain([r, 'optionalAccess', _120 => _120.orderBy])}};return(await f({aptosConfig:e,query:i,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function rs(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,o={token_data_id:{_eq:u.from(t).toStringLong()}},i={query:li,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _121 => _121.offset]),limit:_optionalChain([r, 'optionalAccess', _122 => _122.limit]),order_by:_optionalChain([r, 'optionalAccess', _123 => _123.orderBy])}};return(await f({aptosConfig:e,query:i,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Ec={typeParameters:[],parameters:[new m(P()),new $,new m(P()),new m(P()),new K,new K,new K,new K,new K,new K,new K,new K,new K,new $,new $]};async function os(n){let{aptosConfig:e,options:t,creator:r}=n;return h({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new b(n.description),new O(_nullishCoalesce(n.maxSupply, () => (Xe))),new b(n.name),new b(n.uri),new I(_nullishCoalesce(n.mutableDescription, () => (!0))),new I(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new I(_nullishCoalesce(n.mutableURI, () => (!0))),new I(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new I(_nullishCoalesce(n.mutableTokenName, () => (!0))),new I(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new I(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new I(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new I(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new O(_nullishCoalesce(n.royaltyNumerator, () => (0))),new O(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Ec},options:t})}async function Kt(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _124 => _124.where]);_optionalChain([t, 'optionalAccess', _125 => _125.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _126 => _126.tokenStandard]), () => ("v2"))});let o={query:oi,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _127 => _127.offset]),limit:_optionalChain([t, 'optionalAccess', _128 => _128.limit])}};return(await f({aptosConfig:e,query:o,originMethod:"getCollectionData"})).current_collections_v2[0]}async function is(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:o}=n,i=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:i.toStringLong()}};return _optionalChain([o, 'optionalAccess', _129 => _129.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _130 => _130.tokenStandard]), () => ("v2"))}),Kt({aptosConfig:e,options:{...o,where:s}})}async function ss(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,i={creator_address:{_eq:u.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _131 => _131.tokenStandard])&&(i.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _132 => _132.tokenStandard]), () => ("v2"))}),Kt({aptosConfig:e,options:{...r,where:i}})}async function as(n){let{aptosConfig:e,collectionId:t,options:r}=n,i={collection_id:{_eq:u.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _133 => _133.tokenStandard])&&(i.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _134 => _134.tokenStandard]), () => ("v2"))}),Kt({aptosConfig:e,options:{...r,where:i}})}async function cs(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:o}=n,i=u.from(e),s={collection_name:{_eq:t},creator_address:{_eq:i.toStringLong()}};return _optionalChain([r, 'optionalAccess', _135 => _135.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _136 => _136.tokenStandard]), () => ("v2"))}),(await Kt({aptosConfig:o,options:{where:s}})).collection_id}var Ic={typeParameters:[],parameters:[new m(P()),new m(P()),new m(P()),new m(P()),new C(new m(P())),new C(new m(P())),new C(C.u8())]};async function us(n){let{aptosConfig:e,options:t,creator:r,collection:o,description:i,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:y}=n,w=_optionalChain([p, 'optionalAccess', _137 => _137.map, 'call', _138 => _138(S=>Qe[S])]);return h({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new b(o),new b(i),new b(s),new b(a),T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(w, () => ([]))),xs(_nullishCoalesce(y, () => ([])),_nullishCoalesce(w, () => ([])))],abi:Ic},options:t})}var Uc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new W]};async function ps(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:o,digitalAssetType:i,options:s}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(i, () => (pe))],functionArguments:[u.from(r),u.from(o)],abi:Uc},options:s})}var Rc={typeParameters:[],parameters:[new m(P()),new m(P()),new m(P()),new m(P()),new C(new m(P())),new C(new m(P())),new C(C.u8()),new W]};async function ds(n){let{aptosConfig:e,account:t,collection:r,description:o,name:i,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:y,options:w}=n;if(_optionalChain([c, 'optionalAccess', _139 => _139.length])!==_optionalChain([y, 'optionalAccess', _140 => _140.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _141 => _141.length])!==_optionalChain([y, 'optionalAccess', _142 => _142.length]))throw new Error("Property types and property values counts do not match");let S=_optionalChain([p, 'optionalAccess', _143 => _143.map, 'call', _144 => _144(g=>Qe[g])]);return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,o,i,s,T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(S, () => ([]))),xs(_nullishCoalesce(y, () => ([])),_nullishCoalesce(S, () => ([]))),a],abi:Rc},options:w})}var zc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0)))]};async function ls(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:o,options:i}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(o, () => (pe))],functionArguments:[u.from(r)],abi:zc},options:i})}var Dc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0)))]};async function gs(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:o,options:i}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(o, () => (pe))],functionArguments:[r],abi:Dc},options:i})}var kc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0)))]};async function ms(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:o,options:i}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(o, () => (pe))],functionArguments:[r],abi:kc},options:i})}var Bc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new m(P())]};async function ys(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(i, () => (pe))],functionArguments:[u.from(o),new b(r)],abi:Bc},options:s})}var Gc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new m(P())]};async function fs(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(i, () => (pe))],functionArguments:[u.from(o),new b(r)],abi:Gc},options:s})}var Kc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new m(P())]};async function As(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(i, () => (pe))],functionArguments:[u.from(o),new b(r)],abi:Kc},options:s})}var Nc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new m(P()),new m(P()),C.u8()]};async function hs(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (pe))],functionArguments:[u.from(s),new b(r),new b(Qe[o]),T.U8(oo(i,Qe[o]))],abi:Nc},options:c})}var Oc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new m(P())]};async function Ts(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(i, () => (pe))],functionArguments:[u.from(o),new b(r)],abi:Oc},options:s})}var Fc={typeParameters:[{constraints:["key"]}],parameters:[new m(ne(new D(0))),new m(P()),new m(P()),C.u8()]};async function bs(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (pe))],functionArguments:[u.from(s),new b(r),new b(Qe[o]),oo(i,Qe[o])],abi:Fc},options:c})}var Mc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new m(ne(new D(0))),new m(P()),new D(1)]};async function ws(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (pe)),Qe[o]],functionArguments:[u.from(s),new b(r),i],abi:Mc},options:c})}var qc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new m(ne(new D(0))),new m(P()),new D(1)]};async function Ss(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (pe)),Qe[o]],functionArguments:[u.from(s),new b(r),i],abi:qc},options:c})}function xs(n,e){let t=new Array;return e.forEach((r,o)=>{t.push(oo(n[o],r))}),t}function oo(n,e){let t=ze(e);return Gt(n,t,0,[]).bcsToBytes()}var pn=class{constructor(e){this.config=e}async getCollectionData(e){await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:o}=e,i=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:i.toStringLong()}};return _optionalChain([o, 'optionalAccess', _145 => _145.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _146 => _146.tokenStandard]), () => ("v2"))}),Kt({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),is({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ss({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),as({aptosConfig:this.config,...e})}async getCollectionId(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),cs({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),es({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ts({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ns({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),rs({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return os({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return us({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return ps({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return ds({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return ls({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return gs({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return ms({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return ys({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return fs({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return As({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return hs({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return Ts({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return bs({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return ws({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return Ss({aptosConfig:this.config,...e})}};var _s=300,Vc=n=>{if(n&&n.length>_s)throw new Error(`Event type length exceeds the maximum length of ${_s}`)};async function vs(n){let{aptosConfig:e,eventType:t,options:r}=n;return dn({aptosConfig:e,options:{...r,where:{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},creation_number:{_eq:"0"},sequence_number:{_eq:"0"},indexed_type:{_eq:t}}}})}async function Ps(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:o}=n,s={account_address:{_eq:u.from(e).toStringLong()},creation_number:{_eq:r}};return dn({aptosConfig:t,options:{...o,where:s}})}async function Cs(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:o}=n,s={account_address:{_eq:u.from(e).toStringLong()},indexed_type:{_eq:r}};return dn({aptosConfig:t,options:{...o,where:s}})}async function dn(n){let{aptosConfig:e,options:t}=n;Vc(_optionalChain([t, 'optionalAccess', _147 => _147.where, 'optionalAccess', _148 => _148.indexed_type, 'optionalAccess', _149 => _149._eq]));let r={query:ai,variables:{where_condition:_optionalChain([t, 'optionalAccess', _150 => _150.where]),offset:_optionalChain([t, 'optionalAccess', _151 => _151.offset]),limit:_optionalChain([t, 'optionalAccess', _152 => _152.limit]),order_by:_optionalChain([t, 'optionalAccess', _153 => _153.orderBy])}};return(await f({aptosConfig:e,query:r,originMethod:"getEvents"})).events}var ln=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),vs({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ps({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Cs({aptosConfig:this.config,...e})}async getEvents(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _154 => _154.minimumLedgerVersion]),processorType:"events_processor"}),dn({aptosConfig:this.config,...e})}};async function Es(n){let{aptosConfig:e,accountAddress:t,amount:r,options:o}=n,i=_optionalChain([o, 'optionalAccess', _155 => _155.timeoutSecs])||20,{data:s}=await $o({aptosConfig:e,path:"fund",body:{address:u.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Bt({aptosConfig:e,transactionHash:a,options:{timeoutSecs:i,checkSuccess:_optionalChain([o, 'optionalAccess', _156 => _156.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var gn=class{constructor(e){this.config=e}async fundAccount(e){let t=await Es({aptosConfig:this.config,...e});return _optionalChain([e, 'access', _157 => _157.options, 'optionalAccess', _158 => _158.waitForIndexer])!==!1&&await Zn({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version)}),t}};async function cr(n){let{aptosConfig:e,options:t}=n,r={query:ui,variables:{where_condition:_optionalChain([t, 'optionalAccess', _159 => _159.where]),limit:_optionalChain([t, 'optionalAccess', _160 => _160.limit]),offset:_optionalChain([t, 'optionalAccess', _161 => _161.offset])}};return(await f({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function Is(n){let{aptosConfig:e,options:t}=n,r={query:ci,variables:{where_condition:_optionalChain([t, 'optionalAccess', _162 => _162.where]),limit:_optionalChain([t, 'optionalAccess', _163 => _163.limit]),offset:_optionalChain([t, 'optionalAccess', _164 => _164.offset])}};return(await f({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Us(n){let{aptosConfig:e,options:t}=n,r={query:ii,variables:{where_condition:_optionalChain([t, 'optionalAccess', _165 => _165.where]),limit:_optionalChain([t, 'optionalAccess', _166 => _166.limit]),offset:_optionalChain([t, 'optionalAccess', _167 => _167.offset])}};return(await f({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var $c={typeParameters:[{constraints:[]}],parameters:[ze("0x1::object::Object"),new W,new $]};async function Rs(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:o,amount:i,options:s}=n;return h({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,o,i],abi:$c},options:s})}var mn=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _168 => _168.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),cr({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _169 => _169.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await cr({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _170 => _170.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await cr({aptosConfig:this.config,options:{where:{creator_address:{_eq:u.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _171 => _171.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Is({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _172 => _172.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Us({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return Rs({aptosConfig:this.config,...e})}};async function We(n){let{aptosConfig:e,payload:t,options:r}=n,o=await Hi({...t,aptosConfig:e}),i=new Z;o.serialize(i);let s=i.toUint8Array(),{data:a}=await Ne({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _173 => _173.ledgerVersion])},body:s});return a}async function zs(n){let{aptosConfig:e,payload:t,options:r}=n,{data:o}=await Ne({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _174 => _174.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return o}var yn=class{constructor(e){this.config=e}async getLedgerInfo(){return Ln({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return Di({aptosConfig:this.config,...e})}async getBlockByHeight(e){return ki({aptosConfig:this.config,...e})}async view(e){return We({aptosConfig:this.config,...e})}async viewJson(e){return zs({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return mi({aptosConfig:this.config,...e})}async queryIndexer(e){return f({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return Hn({aptosConfig:this.config})}async getProcessorStatus(e){return Qn({aptosConfig:this.config,processorType:e})}};var Ds=["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 ks(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function je(n){let[e,t,...r]=n.replace(/\.apt$/,"").split(".");if(r.length>0)throw new Error(`${n} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!ks(e))throw new Error(`${e} is not valid. ${Ds}`);if(t&&!ks(t))throw new Error(`${t} is not valid. ${Ds}`);return{domainName:t||e,subdomainName:t?e:void 0}}var Lc="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Hc={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Lc,custom:null,devnet:null};function De(n){let e=Hc[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var ur=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Bs(n){let{aptosConfig:e,name:t}=n,r=De(e),{domainName:o,subdomainName:i}=je(t),s=await We({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[o,i]}}),a=ur(s[0]);return a?u.from(a):void 0}async function Gs(n){let{aptosConfig:e,expiration:t,name:r,sender:o,targetAddress:i,toAddress:s,options:a,transferable:c}=n,p=De(e),{domainName:y,subdomainName:w}=je(r),S=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(w&&!S)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(S&&!w)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let yr=_nullishCoalesce(t.years, () => (1));if(yr!==1)throw new Error("For now, names can only be registered for 1 year at a time");let ea=yr*31536e3;return await h({aptosConfig:e,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[y,ea,i,s]},options:a})}if(!w)throw new Error(`${t.policy} requires a subdomain to be provided.`);let g=await io({aptosConfig:e,name:y});if(!g)throw new Error("The domain does not exist");let E=t.policy==="subdomain:independent"?t.expirationDate:g;if(E>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await h({aptosConfig:e,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[y,w,Math.round(E/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,i,s]},options:a})}async function io(n){let{aptosConfig:e,name:t}=n,r=De(e),{domainName:o,subdomainName:i}=je(t);try{let s=await We({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[o,i]}});return Number(s[0])*1e3}catch (e4){return}}async function Ks(n){let{aptosConfig:e,address:t}=n,r=De(e),o=await We({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(t).toString()]}}),i=ur(o[1]),s=ur(o[0]);if(i)return[s,i].filter(Boolean).join(".")}async function Ns(n){let{aptosConfig:e,sender:t,name:r,options:o}=n,i=De(e);if(!r)return await h({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${i}::router::clear_primary_name`,functionArguments:[]},options:o});let{domainName:s,subdomainName:a}=je(r);return await h({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${i}::router::set_primary_name`,functionArguments:[s,a]},options:o})}async function Os(n){let{aptosConfig:e,name:t}=n,r=De(e),{domainName:o,subdomainName:i}=je(t),s=await We({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[o,i]}}),a=ur(s[0]);return a?u.from(a):void 0}async function Fs(n){let{aptosConfig:e,sender:t,name:r,address:o,options:i}=n,s=De(e),{domainName:a,subdomainName:c}=je(r);return await h({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,o]},options:i})}async function Ms(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:o=""}=je(t),a=(await f({aptosConfig:e,query:{query:kt,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:o},is_active:{_eq:!0}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=fn(a)),a}async function qs(n){let{aptosConfig:e,options:t,accountAddress:r}=n,o=await so({aptosConfig:e});return(await f({aptosConfig:e,originMethod:"getAccountNames",query:{query:kt,variables:{limit:_optionalChain([t, 'optionalAccess', _175 => _175.limit]),offset:_optionalChain([t, 'optionalAccess', _176 => _176.offset]),order_by:_optionalChain([t, 'optionalAccess', _177 => _177.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _178 => _178.options, 'optionalAccess', _179 => _179.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o}}}}})).current_aptos_names.map(fn)}async function Vs(n){let{aptosConfig:e,options:t,accountAddress:r}=n,o=await so({aptosConfig:e});return(await f({aptosConfig:e,originMethod:"getAccountDomains",query:{query:kt,variables:{limit:_optionalChain([t, 'optionalAccess', _180 => _180.limit]),offset:_optionalChain([t, 'optionalAccess', _181 => _181.offset]),order_by:_optionalChain([t, 'optionalAccess', _182 => _182.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _183 => _183.options, 'optionalAccess', _184 => _184.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""}}}}})).current_aptos_names.map(fn)}async function $s(n){let{aptosConfig:e,options:t,accountAddress:r}=n,o=await so({aptosConfig:e});return(await f({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:kt,variables:{limit:_optionalChain([t, 'optionalAccess', _185 => _185.limit]),offset:_optionalChain([t, 'optionalAccess', _186 => _186.offset]),order_by:_optionalChain([t, 'optionalAccess', _187 => _187.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _188 => _188.options, 'optionalAccess', _189 => _189.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_neq:""}}}}})).current_aptos_names.map(fn)}async function Ls(n){let{aptosConfig:e,options:t,domain:r}=n;return(await f({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:kt,variables:{limit:_optionalChain([t, 'optionalAccess', _190 => _190.limit]),offset:_optionalChain([t, 'optionalAccess', _191 => _191.offset]),order_by:_optionalChain([t, 'optionalAccess', _192 => _192.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _193 => _193.options, 'optionalAccess', _194 => _194.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""},is_active:{_eq:!0}}}}})).current_aptos_names.map(fn)}async function so(n){let{aptosConfig:e}=n,t=De(e),[r]=await We({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),o=r/60/60/24,i=()=>new Date;return new Date(i().setDate(i().getDate()-o)).toISOString()}async function Hs(n){let{aptosConfig:e,sender:t,name:r,years:o=1,options:i}=n,s=De(e),a=o*31536e3,{domainName:c,subdomainName:p}=je(r);if(p)throw new Error("Subdomains cannot be renewed");if(o!==1)throw new Error("Currently, only 1 year renewals are supported");return await h({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:i})}function fn(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var An=class{constructor(e){this.config=e}async getOwnerAddress(e){return Bs({aptosConfig:this.config,...e})}async getExpiration(e){return io({aptosConfig:this.config,...e})}async getTargetAddress(e){return Os({aptosConfig:this.config,...e})}async setTargetAddress(e){return Fs({aptosConfig:this.config,...e})}async getPrimaryName(e){return Ks({aptosConfig:this.config,...e})}async setPrimaryName(e){return Ns({aptosConfig:this.config,...e})}async registerName(e){return Gs({aptosConfig:this.config,...e})}async renewDomain(e){return Hs({aptosConfig:this.config,...e})}async getName(e){return Ms({aptosConfig:this.config,...e})}async getAccountNames(e){return qs({aptosConfig:this.config,...e})}async getAccountDomains(e){return Vs({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return $s({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Ls({aptosConfig:this.config,...e})}};async function Qs(n){let{aptosConfig:e,poolAddress:t}=n,r=u.from(t).toStringLong(),i=await f({aptosConfig:e,query:{query:Nr,variables:{where_condition:{pool_address:{_eq:r}}}}});return i.num_active_delegator_per_pool[0]?i.num_active_delegator_per_pool[0].num_active_delegator:0}async function Ws(n){let{aptosConfig:e,options:t}=n,r={query:Nr,variables:{order_by:_optionalChain([t, 'optionalAccess', _195 => _195.orderBy])}};return(await f({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function js(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,o={query:si,variables:{delegatorAddress:u.from(t).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await f({aptosConfig:e,query:o})).delegated_staking_activities}var hn=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _196 => _196.minimumLedgerVersion]),processorType:"stake_processor"}),Qs({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _197 => _197.minimumLedgerVersion]),processorType:"stake_processor"}),Ws({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await A({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _198 => _198.minimumLedgerVersion]),processorType:"stake_processor"}),js({aptosConfig:this.config,...e})}};var pr=class{constructor(e){this.config=e}async simple(e){return h({aptosConfig:this.config,...e})}async multiAgent(e){return h({aptosConfig:this.config,...e})}};function ao(n,e,t){let r=t.value;return t.value=async function(...o){let[i]=o;if(i.transaction.feePayerAddress&&!i.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,o)},t}function co(n,e,t){let r=t.value;return t.value=async function(...o){let[i]=o;if(i.transaction.feePayerAddress&&!i.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return r.apply(this,o)},t}var Nt=class{constructor(e){this.config=e}async simple(e){return ro({aptosConfig:this.config,...e})}async multiAgent(e){return ro({aptosConfig:this.config,...e})}};_chunkBHKSQXUZjs.a.call(void 0, [co],Nt.prototype,"simple",1),_chunkBHKSQXUZjs.a.call(void 0, [co],Nt.prototype,"multiAgent",1);var Ot=class{constructor(e){this.config=e}async simple(e){return ar({aptosConfig:this.config,...e})}async multiAgent(e){return ar({aptosConfig:this.config,...e})}};_chunkBHKSQXUZjs.a.call(void 0, [ao],Ot.prototype,"simple",1),_chunkBHKSQXUZjs.a.call(void 0, [ao],Ot.prototype,"multiAgent",1);var dr=class{constructor(e,t,r,o,i){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=r,this.maximumInFlight=o,this.sleepTime=i}async nextSequenceNumber(){for(;this.lock;)await _chunkBHKSQXUZjs.b.call(void 0, this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=_chunkBHKSQXUZjs.c.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkBHKSQXUZjs.b.call(void 0, this.sleepTime),_chunkBHKSQXUZjs.c.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await xe({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await xe({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await _chunkBHKSQXUZjs.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunkBHKSQXUZjs.c.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkBHKSQXUZjs.c.call(void 0, )-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkBHKSQXUZjs.b.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var Ft=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _199 => _199.pendingDequeue, 'access', _200 => _200.shift, 'call', _201 => _201(), 'optionalAccess', _202 => _202.resolve, 'call', _203 => _203(e)]);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,t)=>{this.pendingDequeue.push({resolve:e,reject:t})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new Mt("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Mt=class extends Error{};var Xs="fulfilled",Ys= exports.TransactionWorkerEventsEnum =(i=>(i.TransactionSent="transactionSent",i.TransactionSendFailed="transactionSendFailed",i.TransactionExecuted="transactionExecuted",i.TransactionExecutionFailed="transactionExecutionFailed",i.ExecutionFinish="executionFinish",i))(Ys||{}),lr= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,o=30,i=100,s=10){super();this.taskQueue=new Ft;this.transactionsQueue=new Ft;this.outstandingTransactions=new Ft;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new dr(t,r,o,i,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let r=await this.generateNextTransaction(this.account,t);if(!r)return;let o=cn({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([o,t])}}catch(t){if(t instanceof Mt)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[o,i]=await this.outstandingTransactions.dequeue();for(t.push(o),r.push(i);!this.outstandingTransactions.isEmpty();)[o,i]=await this.outstandingTransactions.dequeue(),t.push(o),r.push(i);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];i=r[a],c.status===Xs?(this.sentTransactions.push([c.value.hash,i,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,i)):(this.sentTransactions.push([c.status,i,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof Mt)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let o=[];o.push(Bt({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let i=await Promise.allSettled(o);for(let s=0;s<i.length;s+=1){let a=i[s];a.status===Xs?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(o){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${o}`)}}async push(t,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[o,i]=await this.transactionsQueue.dequeue();return h({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:o,options:{...i,accountSequenceNumber:r}})}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 gr=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new lr(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:r}=e;for(let o of t)this.transactionWorker.push(o,r)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:r,options:o}=e;this.start({sender:t}),this.push({data:r,options:o})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var Tn=class{constructor(e){this.config=e,this.build=new pr(this.config),this.simulate=new Nt(this.config),this.submit=new Ot(this.config),this.batch=new gr(this.config)}async getTransactions(e){return $r({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return Ri({aptosConfig:this.config,...e})}async getTransactionByHash(e){return rn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return zi({aptosConfig:this.config,...e})}async waitForTransaction(e){return Bt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Yn({aptosConfig:this.config})}getSigningMessage(e){return Xi(e)}async publishPackageTransaction(e){return Yi({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Zi({aptosConfig:this.config,...e})}sign(e){return sr({...e})}signAsFeePayer(e){let{signer:t,transaction:r}=e;if(!r.feePayerAddress)throw new Error(`Transaction ${r} is not a Fee Payer transaction`);return r.feePayerAddress=t.accountAddress,sr({signer:t,transaction:r})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:r,options:o}=e;this.batch.forSingleAccount({sender:t,data:r,options:o})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){let{signer:t,transaction:r}=e;return cn({aptosConfig:this.config,signer:t,transaction:r})}};var bn=class{constructor(e){this.config=e}async getTableItem(e){return Wn({aptosConfig:this.config,...e})}async getTableItemsData(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),yi({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),fi({aptosConfig:this.config,...e})}};async function mr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,uidKey:o="sub",derivationPath:i}=n,s={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:l.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:o,derivation_path:i},{data:a}=await Lo({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return l.fromHexInput(a.pepper).toUint8Array()}async function uo(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:o=await mr(n),uidKey:i="sub"}=n;if(l.fromHexInput(o).toUint8Array().length!==Se.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Se.PEPPER_LENGTH} bytes`);let{maxExpHorizonSecs:s}=await Wo({aptosConfig:e});if(s<r.expiryDateSecs-_chunkBHKSQXUZjs.c.call(void 0, ))throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let a={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:l.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:l.fromHexInput(o).toStringWithoutPrefix(),uid_key:i},{data:c}=await Ho({aptosConfig:e,path:"prove",body:a,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),p=c.proof,y=new bt({a:p.a,b:p.b,c:p.c});return new Ie({proof:new wt(y,0),trainingWheelsSignature:be.fromHex(c.training_wheels_signature),expHorizonSecs:s})}async function Zs(n){let{aptosConfig:e,jwt:t,uidKey:r,proofFetchCallback:o,pepper:i=await mr(n)}=n,s=uo({...n,pepper:i}),a=o?s:await s,c=ee.fromJwtAndPepper({jwt:t,pepper:i,uidKey:r}),p=await nn({aptosConfig:e,authenticationKey:c.authKey().derivedAddress()});return Se.create({...n,address:p,proof:a,pepper:i,proofFetchCallback:o})}var wn=class{constructor(e){this.config=e}async getPepper(e){return mr({aptosConfig:this.config,...e})}async getProof(e){return uo({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Zs({aptosConfig:this.config,...e})}};async function jc(n){let{aptosConfig:e,options:t}=n,r={query:$n,variables:{where_condition:_optionalChain([t, 'optionalAccess', _204 => _204.where]),offset:_optionalChain([t, 'optionalAccess', _205 => _205.offset]),limit:_optionalChain([t, 'optionalAccess', _206 => _206.limit]),order_by:_optionalChain([t, 'optionalAccess', _207 => _207.orderBy])}};return(await f({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function Js(n){let{aptosConfig:e,objectAddress:t,options:r}=n,i={object_address:{_eq:u.from(t).toStringLong()}};return(await jc({aptosConfig:e,options:{...r,where:i}}))[0]}var Sn=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await A({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Js({aptosConfig:this.config,...e})}};var j=class{constructor(e){this.config=new Jn(e),this.account=new on(this.config),this.ans=new An(this.config),this.coin=new un(this.config),this.digitalAsset=new pn(this.config),this.event=new ln(this.config),this.faucet=new gn(this.config),this.fungibleAsset=new mn(this.config),this.general=new yn(this.config),this.staking=new hn(this.config),this.transaction=new Tn(this.config),this.table=new bn(this.config),this.keyless=new wn(this.config),this.object=new Sn(this.config)}};function re(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let o=Object.getOwnPropertyDescriptor(e.prototype,r);o&&(o.value=function(...i){return this[t][r](...i)},Object.defineProperty(n.prototype,r,o))})}re(j,on,"account");re(j,An,"ans");re(j,un,"coin");re(j,pn,"digitalAsset");re(j,ln,"event");re(j,gn,"faucet");re(j,mn,"fungibleAsset");re(j,yn,"general");re(j,hn,"staking");re(j,Tn,"transaction");re(j,bn,"table");re(j,wn,"keyless");re(j,Sn,"object");exports.APTOS_BIP44_REGEX = ga; exports.APTOS_COIN = kn; exports.APTOS_HARDENED_REGEX = la; exports.Account = $e; exports.AccountAddress = u; exports.AccountAuthenticator = H; exports.AccountAuthenticatorEd25519 = fe; exports.AccountAuthenticatorMultiEd25519 = Gn; exports.AccountAuthenticatorMultiKey = at; exports.AccountAuthenticatorSingleKey = Q; exports.AccountAuthenticatorVariant = Ao; exports.AccountPublicKey = ie; exports.AccountSequenceNumber = dr; exports.AddressInvalidReason = ca; exports.AnyPublicKey = k; exports.AnyPublicKeyVariant = Ar; exports.AnySignature = G; exports.AnySignatureVariant = ho; exports.Aptos = j; exports.AptosApiError = ye; exports.AptosApiType = Ht; exports.AptosConfig = Jn; exports.AuthenticationKey = q; exports.Bool = I; exports.CKDPriv = Co; exports.ChainId = xt; exports.DEFAULT_MAX_GAS_AMOUNT = No; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = Oo; exports.DEFAULT_TXN_TIMEOUT_SEC = Dn; exports.DeriveScheme = wo; exports.Deserializer = oe; exports.EPK_HORIZON_SECS = bl; exports.Ed25519Account = Rt; exports.Ed25519PrivateKey = L; exports.Ed25519PublicKey = _; exports.Ed25519Signature = v; exports.EntryFunction = ut; exports.EntryFunctionBytes = Pn; exports.EphemeralCertificate = Tt; exports.EphemeralCertificateVariant = Tr; exports.EphemeralKeyPair = tn; exports.EphemeralPublicKey = ot; exports.EphemeralPublicKeyVariant = hr; exports.EphemeralSignature = be; exports.EphemeralSignatureVariant = To; exports.FeePayerRawTransaction = dt; exports.FixedBytes = Ze; exports.Groth16Zkp = bt; exports.HARDENED_OFFSET = _o; exports.Hex = l; exports.HexInvalidReason = ra; exports.Identifier = R; exports.KeyType = ma; exports.KeylessAccount = Se; exports.KeylessConfiguration = Dr; exports.KeylessPublicKey = ee; exports.KeylessSignature = Ee; exports.MAX_AUD_VAL_BYTES = Ma; exports.MAX_COMMITED_EPK_BYTES = _l; exports.MAX_EXTRA_FIELD_BYTES = Sl; exports.MAX_ISS_VAL_BYTES = wl; exports.MAX_JWT_HEADER_B64_BYTES = xl; exports.MAX_UID_KEY_BYTES = qa; exports.MAX_UID_VAL_BYTES = Va; exports.MimeType = Cn; exports.ModuleId = Wt; exports.MoveAbility = bo; exports.MoveFunctionVisibility = ia; exports.MoveOption = M; exports.MoveString = b; exports.MoveVector = T; exports.MultiAgentRawTransaction = pt; exports.MultiAgentTransaction = Mn; exports.MultiEd25519PublicKey = ft; exports.MultiEd25519Signature = tt; exports.MultiKey = St; exports.MultiKeyAccount = qn; exports.MultiKeySignature = st; exports.MultiSig = Jt; exports.MultiSigTransactionPayload = en; exports.Network = Er; exports.NetworkToChainId = Ir; exports.NetworkToFaucetAPI = Ko; exports.NetworkToIndexerAPI = Bo; exports.NetworkToNetworkName = wd; exports.NetworkToNodeAPI = Go; exports.NetworkToPepperAPI = Pr; exports.NetworkToProverAPI = Cr; exports.ParsingError = Y; exports.ProcessorType = Ke; exports.PublicKey = Je; exports.RAW_TRANSACTION_SALT = Fo; exports.RAW_TRANSACTION_WITH_DATA_SALT = Ur; exports.RawTransaction = ue; exports.RawTransactionWithData = Nn; exports.RoleType = sa; exports.RotationProofChallenge = On; exports.Script = Zt; exports.ScriptTransactionArgumentVariants = Vt; exports.Secp256k1PrivateKey = rt; exports.Secp256k1PublicKey = Te; exports.Secp256k1Signature = Pe; exports.Serializable = d; exports.Serializer = Z; exports.Signature = B; exports.SignedTransaction = lt; exports.SigningScheme = Ae; exports.SigningSchemeInput = Sr; exports.SimpleTransaction = Fn; exports.SingleKeyAccount = zt; exports.StructTag = Ue; exports.TransactionAuthenticator = Re; exports.TransactionAuthenticatorEd25519 = vt; exports.TransactionAuthenticatorFeePayer = Ct; exports.TransactionAuthenticatorMultiAgent = Pt; exports.TransactionAuthenticatorMultiEd25519 = Br; exports.TransactionAuthenticatorSingleSender = Et; exports.TransactionAuthenticatorVariant = fo; exports.TransactionPayload = ct; exports.TransactionPayloadEntryFunction = Xt; exports.TransactionPayloadMultiSig = Yt; exports.TransactionPayloadScript = jt; exports.TransactionPayloadVariants = mo; exports.TransactionResponseType = wr; exports.TransactionVariants = yo; exports.TransactionWorker = lr; exports.TransactionWorkerEventsEnum = Ys; exports.TypeTag = z; exports.TypeTagAddress = W; exports.TypeTagBool = K; exports.TypeTagGeneric = D; exports.TypeTagParserError = N; exports.TypeTagParserErrorType = pc; exports.TypeTagReference = Kn; exports.TypeTagSigner = _t; exports.TypeTagStruct = m; exports.TypeTagU128 = qe; exports.TypeTagU16 = Fe; exports.TypeTagU256 = Ve; exports.TypeTagU32 = Me; exports.TypeTagU64 = $; exports.TypeTagU8 = ce; exports.TypeTagVariants = go; exports.TypeTagVector = C; exports.U128 = ge; exports.U16 = de; exports.U256 = me; exports.U32 = le; exports.U64 = O; exports.U8 = F; exports.ZeroKnowledgeSig = Ie; exports.ZkProof = wt; exports.ZkpVariant = br; exports.aptosCoinStructTag = $g; exports.aptosRequest = Bn; exports.buildTransaction = to; exports.checkOrConvertArgument = Gt; exports.convertArgument = eo; exports.convertNumber = er; exports.createObjectAddress = Qa; exports.createResourceAddress = bg; exports.createTokenAddress = wg; exports.deriveKey = xr; exports.deriveTransactionType = Gr; exports.deserializeFromScriptArgument = Wa; exports.ensureBoolean = fr; exports.fetchEntryFunctionAbi = $i; exports.fetchFunctionAbi = Vi; exports.fetchViewFunctionAbi = Li; exports.findFirstNonSignerArg = qi; exports.generateRawTransaction = Tc; exports.generateSignedTransaction = no; exports.generateSignedTransactionForSimulation = Qi; exports.generateSigningMessage = It; exports.generateSigningMessageForSerializable = ny; exports.generateSigningMessageForTransaction = Ut; exports.generateTransactionPayload = ir; exports.generateTransactionPayloadWithABI = fc; exports.generateUserTransactionHash = jA; exports.generateViewFunctionPayload = Hi; exports.generateViewFunctionPayloadWithABI = Ac; exports.get = Rr; exports.getAptosFullNode = V; exports.getAptosPepperService = $d; exports.getAuthenticatorForSimulation = or; exports.getFunctionParts = an; exports.getKeylessConfig = Wo; exports.hashValues = Wi; exports.isBcsAddress = nr; exports.isBcsBool = Lr; exports.isBcsFixedBytes = lc; exports.isBcsString = Hr; exports.isBcsU128 = Yr; exports.isBcsU16 = Wr; exports.isBcsU256 = Zr; exports.isBcsU32 = jr; exports.isBcsU64 = Xr; exports.isBcsU8 = Qr; exports.isBlockMetadataTransactionResponse = wu; exports.isBool = Ni; exports.isEd25519Signature = _u; exports.isEmptyOption = Oi; exports.isEncodedEntryFunctionArgument = Fi; exports.isFeePayerSignature = Cu; exports.isGenesisTransactionResponse = bu; exports.isLargeNumber = tr; exports.isMultiAgentSignature = Pu; exports.isMultiEd25519Signature = Eu; exports.isNumber = dc; exports.isPendingTransactionResponse = hu; exports.isScriptDataInput = Mi; exports.isSecp256k1Signature = vu; exports.isStateCheckpointTransactionResponse = Su; exports.isString = He; exports.isUserTransactionResponse = Tu; exports.isValidBIP44Path = vo; exports.isValidHardenedPath = Po; exports.isValidatorTransactionResponse = xu; exports.mnemonicToSeed = En; exports.normalizeBundle = Mo; exports.objectStructTag = ne; exports.optionStructTag = Lg; exports.outOfRangeErrorMessage = oa; exports.paginateWithCursor = ht; exports.parseTypeTag = ze; exports.post = Qt; exports.postAptosFaucet = $o; exports.postAptosFullNode = Ne; exports.postAptosIndexer = Vo; exports.postAptosPepperService = Lo; exports.postAptosProvingService = Ho; exports.promiseFulfilledStatus = Xs; exports.request = Oa; exports.splitPath = Eo; exports.standardizeTypeTags = rr; exports.stringStructTag = P; exports.throwTypeMismatch = U; exports.validateNumberInRange = Be;
471
471
  //# sourceMappingURL=index.js.map