@otim/utils 0.0.2-development.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/LICENSE +201 -0
  2. package/dist/api/api.d.mts +18 -0
  3. package/dist/api/api.d.ts +18 -0
  4. package/dist/api/api.d.ts.map +1 -0
  5. package/dist/api/core/error.d.mts +74 -0
  6. package/dist/api/core/error.d.ts +74 -0
  7. package/dist/api/core/error.d.ts.map +1 -0
  8. package/dist/api/core/index.d.mts +4 -0
  9. package/dist/api/core/index.d.ts +4 -0
  10. package/dist/api/core/index.d.ts.map +1 -0
  11. package/dist/api/core/instance.d.mts +13 -0
  12. package/dist/api/core/instance.d.ts +13 -0
  13. package/dist/api/core/instance.d.ts.map +1 -0
  14. package/dist/api/core/service.d.mts +51 -0
  15. package/dist/api/core/service.d.ts +51 -0
  16. package/dist/api/core/service.d.ts.map +1 -0
  17. package/dist/api/index.d.mts +7 -0
  18. package/dist/api/index.d.ts +7 -0
  19. package/dist/api/index.d.ts.map +1 -0
  20. package/dist/api/index.js +2061 -0
  21. package/dist/api/index.js.map +7 -0
  22. package/dist/api/index.mjs +2030 -0
  23. package/dist/api/index.mjs.map +7 -0
  24. package/dist/api/schemas/account.d.mts +44 -0
  25. package/dist/api/schemas/account.d.ts +44 -0
  26. package/dist/api/schemas/account.d.ts.map +1 -0
  27. package/dist/api/schemas/activity.d.mts +277 -0
  28. package/dist/api/schemas/activity.d.ts +277 -0
  29. package/dist/api/schemas/activity.d.ts.map +1 -0
  30. package/dist/api/schemas/auth.d.mts +127 -0
  31. package/dist/api/schemas/auth.d.ts +127 -0
  32. package/dist/api/schemas/auth.d.ts.map +1 -0
  33. package/dist/api/schemas/chain.d.mts +15 -0
  34. package/dist/api/schemas/chain.d.ts +15 -0
  35. package/dist/api/schemas/chain.d.ts.map +1 -0
  36. package/dist/api/schemas/config.d.mts +33 -0
  37. package/dist/api/schemas/config.d.ts +33 -0
  38. package/dist/api/schemas/config.d.ts.map +1 -0
  39. package/dist/api/schemas/contacts.d.mts +27 -0
  40. package/dist/api/schemas/contacts.d.ts +27 -0
  41. package/dist/api/schemas/contacts.d.ts.map +1 -0
  42. package/dist/api/schemas/index.d.mts +12 -0
  43. package/dist/api/schemas/index.d.ts +12 -0
  44. package/dist/api/schemas/index.d.ts.map +1 -0
  45. package/dist/api/schemas/instruction.d.mts +446 -0
  46. package/dist/api/schemas/instruction.d.ts +446 -0
  47. package/dist/api/schemas/instruction.d.ts.map +1 -0
  48. package/dist/api/schemas/integration.d.mts +166 -0
  49. package/dist/api/schemas/integration.d.ts +166 -0
  50. package/dist/api/schemas/integration.d.ts.map +1 -0
  51. package/dist/api/schemas/operating-account.d.mts +11 -0
  52. package/dist/api/schemas/operating-account.d.ts +11 -0
  53. package/dist/api/schemas/operating-account.d.ts.map +1 -0
  54. package/dist/api/schemas/payments.d.mts +196 -0
  55. package/dist/api/schemas/payments.d.ts +196 -0
  56. package/dist/api/schemas/payments.d.ts.map +1 -0
  57. package/dist/api/schemas/transaction.d.mts +37 -0
  58. package/dist/api/schemas/transaction.d.ts +37 -0
  59. package/dist/api/schemas/transaction.d.ts.map +1 -0
  60. package/dist/api/services/account.d.mts +8 -0
  61. package/dist/api/services/account.d.ts +8 -0
  62. package/dist/api/services/account.d.ts.map +1 -0
  63. package/dist/api/services/activity.d.mts +7 -0
  64. package/dist/api/services/activity.d.ts +7 -0
  65. package/dist/api/services/activity.d.ts.map +1 -0
  66. package/dist/api/services/auth.d.mts +12 -0
  67. package/dist/api/services/auth.d.ts +12 -0
  68. package/dist/api/services/auth.d.ts.map +1 -0
  69. package/dist/api/services/base.d.mts +10 -0
  70. package/dist/api/services/base.d.ts +10 -0
  71. package/dist/api/services/base.d.ts.map +1 -0
  72. package/dist/api/services/config.d.mts +10 -0
  73. package/dist/api/services/config.d.ts +10 -0
  74. package/dist/api/services/config.d.ts.map +1 -0
  75. package/dist/api/services/contacts.d.mts +8 -0
  76. package/dist/api/services/contacts.d.ts +8 -0
  77. package/dist/api/services/contacts.d.ts.map +1 -0
  78. package/dist/api/services/developer.d.mts +6 -0
  79. package/dist/api/services/developer.d.ts +6 -0
  80. package/dist/api/services/developer.d.ts.map +1 -0
  81. package/dist/api/services/index.d.mts +13 -0
  82. package/dist/api/services/index.d.ts +13 -0
  83. package/dist/api/services/index.d.ts.map +1 -0
  84. package/dist/api/services/instruction.d.mts +12 -0
  85. package/dist/api/services/instruction.d.ts +12 -0
  86. package/dist/api/services/instruction.d.ts.map +1 -0
  87. package/dist/api/services/integration.d.mts +8 -0
  88. package/dist/api/services/integration.d.ts +8 -0
  89. package/dist/api/services/integration.d.ts.map +1 -0
  90. package/dist/api/services/operating-account.d.mts +8 -0
  91. package/dist/api/services/operating-account.d.ts +8 -0
  92. package/dist/api/services/operating-account.d.ts.map +1 -0
  93. package/dist/api/services/payments.d.mts +13 -0
  94. package/dist/api/services/payments.d.ts +13 -0
  95. package/dist/api/services/payments.d.ts.map +1 -0
  96. package/dist/api/services/transaction.d.mts +8 -0
  97. package/dist/api/services/transaction.d.ts +8 -0
  98. package/dist/api/services/transaction.d.ts.map +1 -0
  99. package/dist/api/services/uniswap-token-list-service.d.mts +66 -0
  100. package/dist/api/services/uniswap-token-list-service.d.ts +66 -0
  101. package/dist/api/services/uniswap-token-list-service.d.ts.map +1 -0
  102. package/dist/api/utils/index.d.mts +2 -0
  103. package/dist/api/utils/index.d.ts +2 -0
  104. package/dist/api/utils/index.d.ts.map +1 -0
  105. package/dist/api/utils/pagination.d.mts +32 -0
  106. package/dist/api/utils/pagination.d.ts +32 -0
  107. package/dist/api/utils/pagination.d.ts.map +1 -0
  108. package/dist/chains/config/all-chains.d.mts +4243 -0
  109. package/dist/chains/config/all-chains.d.ts +4243 -0
  110. package/dist/chains/config/all-chains.d.ts.map +1 -0
  111. package/dist/chains/config/custom-chains.d.mts +49 -0
  112. package/dist/chains/config/custom-chains.d.ts +49 -0
  113. package/dist/chains/config/custom-chains.d.ts.map +1 -0
  114. package/dist/chains/config/mainnet-chains.d.mts +1063 -0
  115. package/dist/chains/config/mainnet-chains.d.ts +1063 -0
  116. package/dist/chains/config/mainnet-chains.d.ts.map +1 -0
  117. package/dist/chains/config/supported-chains.d.mts +2172 -0
  118. package/dist/chains/config/supported-chains.d.ts +2172 -0
  119. package/dist/chains/config/supported-chains.d.ts.map +1 -0
  120. package/dist/chains/config/testnet-chains.d.mts +1110 -0
  121. package/dist/chains/config/testnet-chains.d.ts +1110 -0
  122. package/dist/chains/config/testnet-chains.d.ts.map +1 -0
  123. package/dist/chains/index.d.mts +16 -0
  124. package/dist/chains/index.d.ts +16 -0
  125. package/dist/chains/index.d.ts.map +1 -0
  126. package/dist/chains/index.js +490 -0
  127. package/dist/chains/index.js.map +7 -0
  128. package/dist/chains/index.mjs +505 -0
  129. package/dist/chains/index.mjs.map +7 -0
  130. package/dist/chains/lambda/chain-mapping.d.mts +55 -0
  131. package/dist/chains/lambda/chain-mapping.d.ts +55 -0
  132. package/dist/chains/lambda/chain-mapping.d.ts.map +1 -0
  133. package/dist/chains/lambda/index.d.mts +2 -0
  134. package/dist/chains/lambda/index.d.ts +2 -0
  135. package/dist/chains/lambda/index.d.ts.map +1 -0
  136. package/dist/chains/tokens/chain-tokens.d.mts +6 -0
  137. package/dist/chains/tokens/chain-tokens.d.ts +6 -0
  138. package/dist/chains/tokens/chain-tokens.d.ts.map +1 -0
  139. package/dist/chains/tokens/token-addresses.d.mts +8 -0
  140. package/dist/chains/tokens/token-addresses.d.ts +8 -0
  141. package/dist/chains/tokens/token-addresses.d.ts.map +1 -0
  142. package/dist/chains/tokens/token-metadata.d.mts +5 -0
  143. package/dist/chains/tokens/token-metadata.d.ts +5 -0
  144. package/dist/chains/tokens/token-metadata.d.ts.map +1 -0
  145. package/dist/chains/types.d.mts +23 -0
  146. package/dist/chains/types.d.ts +23 -0
  147. package/dist/chains/types.d.ts.map +1 -0
  148. package/dist/chains/utils/filter-tokens.d.mts +3 -0
  149. package/dist/chains/utils/filter-tokens.d.ts +3 -0
  150. package/dist/chains/utils/filter-tokens.d.ts.map +1 -0
  151. package/dist/chains/utils/stablecoin.d.mts +7 -0
  152. package/dist/chains/utils/stablecoin.d.ts +7 -0
  153. package/dist/chains/utils/stablecoin.d.ts.map +1 -0
  154. package/dist/chains/utils/token-maps.d.mts +10 -0
  155. package/dist/chains/utils/token-maps.d.ts +10 -0
  156. package/dist/chains/utils/token-maps.d.ts.map +1 -0
  157. package/dist/constants.d.mts +31 -0
  158. package/dist/constants.d.ts +31 -0
  159. package/dist/constants.d.ts.map +1 -0
  160. package/dist/constants.js +47 -0
  161. package/dist/constants.js.map +7 -0
  162. package/dist/constants.mjs +26 -0
  163. package/dist/constants.mjs.map +7 -0
  164. package/dist/env.d.mts +17 -0
  165. package/dist/env.d.ts +17 -0
  166. package/dist/env.d.ts.map +1 -0
  167. package/dist/formatters/index.d.mts +2 -0
  168. package/dist/formatters/index.d.ts +2 -0
  169. package/dist/formatters/index.d.ts.map +1 -0
  170. package/dist/formatters/index.js +19 -0
  171. package/dist/formatters/index.js.map +7 -0
  172. package/dist/formatters/index.mjs +1 -0
  173. package/dist/formatters/index.mjs.map +7 -0
  174. package/dist/helpers/address.d.mts +7 -0
  175. package/dist/helpers/address.d.ts +7 -0
  176. package/dist/helpers/address.d.ts.map +1 -0
  177. package/dist/helpers/blockchain.d.mts +41 -0
  178. package/dist/helpers/blockchain.d.ts +41 -0
  179. package/dist/helpers/blockchain.d.ts.map +1 -0
  180. package/dist/helpers/date.d.mts +70 -0
  181. package/dist/helpers/date.d.ts +70 -0
  182. package/dist/helpers/date.d.ts.map +1 -0
  183. package/dist/helpers/datetime.d.mts +57 -0
  184. package/dist/helpers/datetime.d.ts +57 -0
  185. package/dist/helpers/datetime.d.ts.map +1 -0
  186. package/dist/helpers/domain.d.mts +2 -0
  187. package/dist/helpers/domain.d.ts +2 -0
  188. package/dist/helpers/domain.d.ts.map +1 -0
  189. package/dist/helpers/index.d.mts +19 -0
  190. package/dist/helpers/index.d.ts +19 -0
  191. package/dist/helpers/index.d.ts.map +1 -0
  192. package/dist/helpers/index.js +1322 -0
  193. package/dist/helpers/index.js.map +7 -0
  194. package/dist/helpers/index.mjs +1294 -0
  195. package/dist/helpers/index.mjs.map +7 -0
  196. package/dist/helpers/intl.d.mts +20 -0
  197. package/dist/helpers/intl.d.ts +20 -0
  198. package/dist/helpers/intl.d.ts.map +1 -0
  199. package/dist/helpers/logger.d.mts +26 -0
  200. package/dist/helpers/logger.d.ts +26 -0
  201. package/dist/helpers/logger.d.ts.map +1 -0
  202. package/dist/helpers/mask-options.d.mts +10 -0
  203. package/dist/helpers/mask-options.d.ts +10 -0
  204. package/dist/helpers/mask-options.d.ts.map +1 -0
  205. package/dist/helpers/num-formatter.d.mts +3 -0
  206. package/dist/helpers/num-formatter.d.ts +3 -0
  207. package/dist/helpers/num-formatter.d.ts.map +1 -0
  208. package/dist/helpers/polling.d.mts +39 -0
  209. package/dist/helpers/polling.d.ts +39 -0
  210. package/dist/helpers/polling.d.ts.map +1 -0
  211. package/dist/helpers/random.d.mts +10 -0
  212. package/dist/helpers/random.d.ts +10 -0
  213. package/dist/helpers/random.d.ts.map +1 -0
  214. package/dist/helpers/sdk-loader.d.mts +25 -0
  215. package/dist/helpers/sdk-loader.d.ts +25 -0
  216. package/dist/helpers/sdk-loader.d.ts.map +1 -0
  217. package/dist/helpers/signatures.d.mts +17 -0
  218. package/dist/helpers/signatures.d.ts +17 -0
  219. package/dist/helpers/signatures.d.ts.map +1 -0
  220. package/dist/helpers/string.d.mts +17 -0
  221. package/dist/helpers/string.d.ts +17 -0
  222. package/dist/helpers/string.d.ts.map +1 -0
  223. package/dist/helpers/types.d.mts +39 -0
  224. package/dist/helpers/types.d.ts +39 -0
  225. package/dist/helpers/types.d.ts.map +1 -0
  226. package/dist/helpers/url.d.mts +11 -0
  227. package/dist/helpers/url.d.ts +11 -0
  228. package/dist/helpers/url.d.ts.map +1 -0
  229. package/dist/helpers/window.d.mts +37 -0
  230. package/dist/helpers/window.d.ts +37 -0
  231. package/dist/helpers/window.d.ts.map +1 -0
  232. package/dist/helpers/zod.d.mts +30 -0
  233. package/dist/helpers/zod.d.ts +30 -0
  234. package/dist/helpers/zod.d.ts.map +1 -0
  235. package/dist/index.d.mts +1 -0
  236. package/dist/index.d.ts +1 -0
  237. package/dist/index.d.ts.map +1 -0
  238. package/dist/index.js +2 -0
  239. package/dist/index.js.map +7 -0
  240. package/dist/index.mjs +1 -0
  241. package/dist/index.mjs.map +7 -0
  242. package/dist/instructions/actions/index.d.mts +5 -0
  243. package/dist/instructions/actions/index.d.ts +5 -0
  244. package/dist/instructions/actions/index.d.ts.map +1 -0
  245. package/dist/instructions/actions/refuel/index.d.mts +15 -0
  246. package/dist/instructions/actions/refuel/index.d.ts +15 -0
  247. package/dist/instructions/actions/refuel/index.d.ts.map +1 -0
  248. package/dist/instructions/actions/swap/index.d.mts +19 -0
  249. package/dist/instructions/actions/swap/index.d.ts +19 -0
  250. package/dist/instructions/actions/swap/index.d.ts.map +1 -0
  251. package/dist/instructions/actions/sweep/index.d.mts +16 -0
  252. package/dist/instructions/actions/sweep/index.d.ts +16 -0
  253. package/dist/instructions/actions/sweep/index.d.ts.map +1 -0
  254. package/dist/instructions/actions/transfer/index.d.mts +13 -0
  255. package/dist/instructions/actions/transfer/index.d.ts +13 -0
  256. package/dist/instructions/actions/transfer/index.d.ts.map +1 -0
  257. package/dist/instructions/activate.d.mts +84 -0
  258. package/dist/instructions/activate.d.ts +84 -0
  259. package/dist/instructions/activate.d.ts.map +1 -0
  260. package/dist/instructions/build.d.mts +146 -0
  261. package/dist/instructions/build.d.ts +146 -0
  262. package/dist/instructions/build.d.ts.map +1 -0
  263. package/dist/instructions/constants.d.mts +9 -0
  264. package/dist/instructions/constants.d.ts +9 -0
  265. package/dist/instructions/constants.d.ts.map +1 -0
  266. package/dist/instructions/contracts/artifacts/abi/build-instruction-action-arguments-abi.d.mts +609 -0
  267. package/dist/instructions/contracts/artifacts/abi/build-instruction-action-arguments-abi.d.ts +609 -0
  268. package/dist/instructions/contracts/artifacts/abi/build-instruction-action-arguments-abi.d.ts.map +1 -0
  269. package/dist/instructions/index.d.mts +6 -0
  270. package/dist/instructions/index.d.ts +6 -0
  271. package/dist/instructions/index.d.ts.map +1 -0
  272. package/dist/instructions/index.js +1152 -0
  273. package/dist/instructions/index.js.map +7 -0
  274. package/dist/instructions/index.mjs +1119 -0
  275. package/dist/instructions/index.mjs.map +7 -0
  276. package/dist/instructions/types.d.mts +289 -0
  277. package/dist/instructions/types.d.ts +289 -0
  278. package/dist/instructions/types.d.ts.map +1 -0
  279. package/dist/payments/action-names.d.mts +16 -0
  280. package/dist/payments/action-names.d.ts +16 -0
  281. package/dist/payments/action-names.d.ts.map +1 -0
  282. package/dist/payments/actions/index.d.mts +5 -0
  283. package/dist/payments/actions/index.d.ts +5 -0
  284. package/dist/payments/actions/index.d.ts.map +1 -0
  285. package/dist/payments/actions/sweep-cctp.d.mts +15 -0
  286. package/dist/payments/actions/sweep-cctp.d.ts +15 -0
  287. package/dist/payments/actions/sweep-cctp.d.ts.map +1 -0
  288. package/dist/payments/actions/sweep-erc20.d.mts +12 -0
  289. package/dist/payments/actions/sweep-erc20.d.ts +12 -0
  290. package/dist/payments/actions/sweep-erc20.d.ts.map +1 -0
  291. package/dist/payments/actions/sweep-uniswap-v3.d.mts +17 -0
  292. package/dist/payments/actions/sweep-uniswap-v3.d.ts +17 -0
  293. package/dist/payments/actions/sweep-uniswap-v3.d.ts.map +1 -0
  294. package/dist/payments/actions/sweep.d.mts +12 -0
  295. package/dist/payments/actions/sweep.d.ts +12 -0
  296. package/dist/payments/actions/sweep.d.ts.map +1 -0
  297. package/dist/payments/build.d.mts +27 -0
  298. package/dist/payments/build.d.ts +27 -0
  299. package/dist/payments/build.d.ts.map +1 -0
  300. package/dist/payments/chain-token-config-builder.d.mts +10 -0
  301. package/dist/payments/chain-token-config-builder.d.ts +10 -0
  302. package/dist/payments/chain-token-config-builder.d.ts.map +1 -0
  303. package/dist/payments/comprehensive-payment-request.d.mts +25 -0
  304. package/dist/payments/comprehensive-payment-request.d.ts +25 -0
  305. package/dist/payments/comprehensive-payment-request.d.ts.map +1 -0
  306. package/dist/payments/config/cctp.d.mts +14 -0
  307. package/dist/payments/config/cctp.d.ts +14 -0
  308. package/dist/payments/config/cctp.d.ts.map +1 -0
  309. package/dist/payments/config/index.d.mts +3 -0
  310. package/dist/payments/config/index.d.ts +3 -0
  311. package/dist/payments/config/index.d.ts.map +1 -0
  312. package/dist/payments/config/tokens.d.mts +14 -0
  313. package/dist/payments/config/tokens.d.ts +14 -0
  314. package/dist/payments/config/tokens.d.ts.map +1 -0
  315. package/dist/payments/index.d.mts +16 -0
  316. package/dist/payments/index.d.ts +16 -0
  317. package/dist/payments/index.d.ts.map +1 -0
  318. package/dist/payments/index.js +1303 -0
  319. package/dist/payments/index.js.map +7 -0
  320. package/dist/payments/index.mjs +1281 -0
  321. package/dist/payments/index.mjs.map +7 -0
  322. package/dist/payments/instruction-registry.d.mts +19 -0
  323. package/dist/payments/instruction-registry.d.ts +19 -0
  324. package/dist/payments/instruction-registry.d.ts.map +1 -0
  325. package/dist/payments/payment-metadata-builder.d.mts +56 -0
  326. package/dist/payments/payment-metadata-builder.d.ts +56 -0
  327. package/dist/payments/payment-metadata-builder.d.ts.map +1 -0
  328. package/dist/payments/payment-metadata.d.mts +15 -0
  329. package/dist/payments/payment-metadata.d.ts +15 -0
  330. package/dist/payments/payment-metadata.d.ts.map +1 -0
  331. package/dist/payments/payment-request-token-resolver.d.mts +25 -0
  332. package/dist/payments/payment-request-token-resolver.d.ts +25 -0
  333. package/dist/payments/payment-request-token-resolver.d.ts.map +1 -0
  334. package/dist/payments/types.d.mts +40 -0
  335. package/dist/payments/types.d.ts +40 -0
  336. package/dist/payments/types.d.ts.map +1 -0
  337. package/dist/payments/validation.d.mts +19 -0
  338. package/dist/payments/validation.d.ts +19 -0
  339. package/dist/payments/validation.d.ts.map +1 -0
  340. package/dist/schemas/account.d.mts +9 -0
  341. package/dist/schemas/account.d.ts +9 -0
  342. package/dist/schemas/account.d.ts.map +1 -0
  343. package/dist/schemas/brand.d.mts +7 -0
  344. package/dist/schemas/brand.d.ts +7 -0
  345. package/dist/schemas/brand.d.ts.map +1 -0
  346. package/dist/schemas/contact.d.mts +18 -0
  347. package/dist/schemas/contact.d.ts +18 -0
  348. package/dist/schemas/contact.d.ts.map +1 -0
  349. package/dist/schemas/index.d.mts +10 -0
  350. package/dist/schemas/index.d.ts +10 -0
  351. package/dist/schemas/index.d.ts.map +1 -0
  352. package/dist/schemas/index.js +433 -0
  353. package/dist/schemas/index.js.map +7 -0
  354. package/dist/schemas/index.mjs +410 -0
  355. package/dist/schemas/index.mjs.map +7 -0
  356. package/dist/schemas/instruction.d.mts +248 -0
  357. package/dist/schemas/instruction.d.ts +248 -0
  358. package/dist/schemas/instruction.d.ts.map +1 -0
  359. package/dist/schemas/misc.d.mts +36 -0
  360. package/dist/schemas/misc.d.ts +36 -0
  361. package/dist/schemas/misc.d.ts.map +1 -0
  362. package/dist/schemas/payment.d.mts +64 -0
  363. package/dist/schemas/payment.d.ts +64 -0
  364. package/dist/schemas/payment.d.ts.map +1 -0
  365. package/dist/schemas/token.d.mts +17 -0
  366. package/dist/schemas/token.d.ts +17 -0
  367. package/dist/schemas/token.d.ts.map +1 -0
  368. package/dist/schemas/transaction.d.mts +65 -0
  369. package/dist/schemas/transaction.d.ts +65 -0
  370. package/dist/schemas/transaction.d.ts.map +1 -0
  371. package/dist/schemas/user.d.mts +24 -0
  372. package/dist/schemas/user.d.ts +24 -0
  373. package/dist/schemas/user.d.ts.map +1 -0
  374. package/dist/server/client.d.mts +3 -0
  375. package/dist/server/client.d.ts +3 -0
  376. package/dist/server/client.d.ts.map +1 -0
  377. package/dist/server/index.d.mts +3 -0
  378. package/dist/server/index.d.ts +3 -0
  379. package/dist/server/index.d.ts.map +1 -0
  380. package/dist/server/index.js +420 -0
  381. package/dist/server/index.js.map +7 -0
  382. package/dist/server/index.mjs +389 -0
  383. package/dist/server/index.mjs.map +7 -0
  384. package/dist/server/routes/account.d.mts +4 -0
  385. package/dist/server/routes/account.d.ts +4 -0
  386. package/dist/server/routes/account.d.ts.map +1 -0
  387. package/dist/server/routes/auth.d.mts +28 -0
  388. package/dist/server/routes/auth.d.ts +28 -0
  389. package/dist/server/routes/auth.d.ts.map +1 -0
  390. package/dist/server/routes/bridge.d.mts +192 -0
  391. package/dist/server/routes/bridge.d.ts +192 -0
  392. package/dist/server/routes/bridge.d.ts.map +1 -0
  393. package/dist/server/routes/config.d.mts +3 -0
  394. package/dist/server/routes/config.d.ts +3 -0
  395. package/dist/server/routes/config.d.ts.map +1 -0
  396. package/dist/server/routes/index.d.mts +8 -0
  397. package/dist/server/routes/index.d.ts +8 -0
  398. package/dist/server/routes/index.d.ts.map +1 -0
  399. package/dist/server/routes/instruction.d.mts +4 -0
  400. package/dist/server/routes/instruction.d.ts +4 -0
  401. package/dist/server/routes/instruction.d.ts.map +1 -0
  402. package/dist/server/routes/integration.d.mts +4 -0
  403. package/dist/server/routes/integration.d.ts +4 -0
  404. package/dist/server/routes/integration.d.ts.map +1 -0
  405. package/dist/server/routes/payments.d.mts +4 -0
  406. package/dist/server/routes/payments.d.ts +4 -0
  407. package/dist/server/routes/payments.d.ts.map +1 -0
  408. package/dist/server/routes/verify.d.mts +3 -0
  409. package/dist/server/routes/verify.d.ts +3 -0
  410. package/dist/server/routes/verify.d.ts.map +1 -0
  411. package/dist/wallet/wagmi/config.d.mts +18 -0
  412. package/dist/wallet/wagmi/config.d.ts +18 -0
  413. package/dist/wallet/wagmi/config.d.ts.map +1 -0
  414. package/dist/wallet/wagmi/index.d.mts +2 -0
  415. package/dist/wallet/wagmi/index.d.ts +2 -0
  416. package/dist/wallet/wagmi/index.d.ts.map +1 -0
  417. package/dist/wallet/wagmi/index.js +429 -0
  418. package/dist/wallet/wagmi/index.js.map +7 -0
  419. package/dist/wallet/wagmi/index.mjs +431 -0
  420. package/dist/wallet/wagmi/index.mjs.map +7 -0
  421. package/package.json +222 -0
@@ -0,0 +1,1322 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
31
+
32
+ // src/helpers/index.ts
33
+ var helpers_exports = {};
34
+ __export(helpers_exports, {
35
+ DEFAULT_ADDRESS: () => DEFAULT_ADDRESS,
36
+ ETHEREUM_ADDRESS_REGEX: () => ETHEREUM_ADDRESS_REGEX,
37
+ PollingManager: () => PollingManager,
38
+ TimeUnit: () => TimeUnit,
39
+ areAddressesEqual: () => areAddressesEqual,
40
+ buildQueryString: () => buildQueryString,
41
+ buildUrl: () => buildUrl,
42
+ capitalize: () => capitalize,
43
+ closeEmergentWindow: () => closeEmergentWindow,
44
+ coerceSecondsFromTimeUnitValue: () => coerceSecondsFromTimeUnitValue,
45
+ composeValidators: () => composeValidators,
46
+ createEIP2098Signature: () => createEIP2098Signature,
47
+ createTimeUnitValidator: () => createTimeUnitValidator,
48
+ dateMaskOptions: () => dateMaskOptions,
49
+ extractNumber: () => extractNumber,
50
+ extractString: () => extractString,
51
+ focusMainWindow: () => focusMainWindow,
52
+ formatCurrency: () => formatCurrency,
53
+ formatDateAsISO: () => formatDateAsISO,
54
+ formatDateAsUSStandard: () => formatDateAsUSStandard,
55
+ formatDateTime: () => formatDateTime,
56
+ formatDateToYYYYMMDD: () => formatDateToYYYYMMDD,
57
+ formatFullDate: () => formatFullDate,
58
+ formatLongDate: () => formatLongDate,
59
+ formatLongDateTime: () => formatLongDateTime,
60
+ formatNumberAsUSStandard: () => formatNumberAsUSStandard,
61
+ formatSignatureToEIP2098: () => formatSignatureToEIP2098,
62
+ formatTime: () => formatTime,
63
+ formatToJustDate: () => formatToJustDate,
64
+ formatToShortDate: () => formatToShortDate,
65
+ formatToShortDateWithYear: () => formatToShortDateWithYear,
66
+ formatUUID: () => formatUUID,
67
+ formattedNumber: () => formattedNumber,
68
+ getBaseDomain: () => getBaseDomain,
69
+ getChainRpcUrl: () => getChainRpcUrl,
70
+ getPluralizedUnit: () => getPluralizedUnit,
71
+ getRelativeDateDescription: () => getRelativeDateDescription,
72
+ getSecondsFromTimeUnitValue: () => getSecondsFromTimeUnitValue,
73
+ i18n: () => i18n,
74
+ isBoolean: () => isBoolean,
75
+ isClient: () => isClient,
76
+ isDateEpoc: () => isDateEpoc,
77
+ isDateInPast: () => isDateInPast,
78
+ isDateInRange: () => isDateInRange,
79
+ isDateInvalid: () => isDateInvalid,
80
+ isError: () => isError,
81
+ isFunction: () => isFunction,
82
+ isNullAddress: () => isNullAddress,
83
+ isNumber: () => isNumber,
84
+ isObject: () => isObject,
85
+ isSameDate: () => isSameDate,
86
+ isScriptLoaded: () => isScriptLoaded,
87
+ isString: () => isString,
88
+ isUndefined: () => isUndefined,
89
+ isValidDate: () => isValidDate,
90
+ isValidEthereumAddress: () => isValidEthereumAddress,
91
+ isValidTimeUnitValue: () => isValidTimeUnitValue,
92
+ isValidV: () => isValidV,
93
+ iso8601DateSchema: () => iso8601DateSchema,
94
+ loadExternalSdk: () => loadExternalSdk,
95
+ localeSchema: () => localeSchema,
96
+ logger: () => logger,
97
+ normalizeV: () => normalizeV,
98
+ numFormatter: () => numFormatter,
99
+ openCenteredEmergentWindow: () => openCenteredEmergentWindow,
100
+ parseDateTime: () => parseDateTime,
101
+ parseDateTimeStrict: () => parseDateTimeStrict,
102
+ parseSchema: () => parseSchema,
103
+ parseSignatureToVRS: () => parseSignatureToVRS,
104
+ parseTimeUnitValue: () => parseTimeUnitValue,
105
+ performRedirect: () => performRedirect,
106
+ postalCodeMaskOptions: () => postalCodeMaskOptions,
107
+ randomNumber: () => randomNumber,
108
+ safeFormatDate: () => safeFormatDate,
109
+ serializeTimeUnitValue: () => serializeTimeUnitValue,
110
+ timeMaskOptionsHHMM: () => timeMaskOptionsHHMM,
111
+ timeOptions: () => timeOptions,
112
+ timeOptionsWithoutMeridiem: () => timeOptionsWithoutMeridiem,
113
+ timeUnitInputValueSchema: () => timeUnitInputValueSchema,
114
+ toTitleCase: () => toTitleCase,
115
+ truncateAddress: () => truncateAddress,
116
+ usdCurrencyMaskOptions: () => usdCurrencyMaskOptions,
117
+ uuidMaskOptions: () => uuidMaskOptions,
118
+ validateIso8601Date: () => validateIso8601Date
119
+ });
120
+ module.exports = __toCommonJS(helpers_exports);
121
+
122
+ // src/helpers/address.ts
123
+ var areAddressesEqual = (address1, address2) => {
124
+ if (!address1 || !address2) return false;
125
+ return address1.toLowerCase() === address2.toLowerCase();
126
+ };
127
+
128
+ // src/helpers/blockchain.ts
129
+ var import_viem = require("viem");
130
+ var truncateAddress = (address) => {
131
+ if (!address) return "";
132
+ return `${address.slice(0, 6)}...${address.slice(-4)}`;
133
+ };
134
+ var ETHEREUM_ADDRESS_REGEX = /^0x[a-fA-F0-9]{40}$/;
135
+ var isValidEthereumAddress = (address) => {
136
+ return ETHEREUM_ADDRESS_REGEX.test(address);
137
+ };
138
+ var parseSignatureToVRS = (signature) => {
139
+ if (typeof signature !== "string") {
140
+ throw new Error("Signature must be a string");
141
+ }
142
+ if (!signature.startsWith("0x")) {
143
+ throw new Error('Signature must start with "0x"');
144
+ }
145
+ if (signature.length !== 132) {
146
+ throw new Error(
147
+ 'Signature must be 65 bytes (130 hex chars) plus "0x" = 132 total length'
148
+ );
149
+ }
150
+ const r = signature.slice(2, 66);
151
+ const s = signature.slice(66, 130);
152
+ const vHex = signature.slice(130, 132);
153
+ const v = parseInt(vHex, 16);
154
+ return { v, r: `0x${r}`, s: `0x${s}` };
155
+ };
156
+ var isValidV = (v) => {
157
+ return v === 0 || v === 1 || v === 27 || v === 28 || v >= 35;
158
+ };
159
+ var normalizeV = (v) => {
160
+ if (!isValidV(v)) return 0;
161
+ const cmp = v <= 1 ? 1 : 0;
162
+ const result = v % 2 === cmp;
163
+ return Number(result) % 2;
164
+ };
165
+ var createEIP2098Signature = (vrs) => {
166
+ const v = vrs.v;
167
+ const r = vrs.r;
168
+ const s = vrs.s;
169
+ return { yParity: normalizeV(v), r, s };
170
+ };
171
+ var getChainRpcUrl = (chainId, chains) => {
172
+ const chain = chains.find((chain2) => chain2.id === chainId);
173
+ return chain?.rpcUrls.default;
174
+ };
175
+ var DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
176
+ var isNullAddress = (address) => {
177
+ return (0, import_viem.isAddressEqual)(address, DEFAULT_ADDRESS);
178
+ };
179
+
180
+ // src/helpers/date.ts
181
+ var import_zod = __toESM(require("zod"));
182
+
183
+ // src/env.ts
184
+ var BUILD_MODE = "development";
185
+
186
+ // src/helpers/logger.ts
187
+ var Logger = class {
188
+ constructor() {
189
+ __publicField(this, "isDevelopment", BUILD_MODE === "development");
190
+ }
191
+ debug(message, options) {
192
+ if (this.isDevelopment) {
193
+ this.log("debug", message, options);
194
+ }
195
+ }
196
+ info(message, options) {
197
+ this.log("info", message, options);
198
+ }
199
+ warn(message, options) {
200
+ this.log("warn", message, options);
201
+ }
202
+ error(message, options) {
203
+ this.log("error", message, options);
204
+ }
205
+ /**
206
+ * Log errors with context - useful for non-API errors
207
+ * For API errors, use the existing getErrorMessage from @otim/utils/api
208
+ */
209
+ logError(error, options = {}) {
210
+ const { context, operation, metadata } = options;
211
+ const prefix = this.buildPrefix(context, operation);
212
+ let message = "Unknown error";
213
+ if (error instanceof Error) {
214
+ message = error.message;
215
+ } else if (typeof error === "string") {
216
+ message = error;
217
+ } else if (error && typeof error === "object" && "message" in error) {
218
+ message = String(error.message);
219
+ }
220
+ console.error(prefix ? `${prefix} ${message}` : message);
221
+ if (metadata && Object.keys(metadata).length > 0) {
222
+ console.error("Context:", metadata);
223
+ }
224
+ if (error instanceof Error && error.stack) {
225
+ console.error("Stack:", error.stack);
226
+ } else {
227
+ console.error("Error details:", error);
228
+ }
229
+ }
230
+ buildPrefix(context, operation) {
231
+ const parts = [];
232
+ if (context) parts.push(`[${context}]`);
233
+ if (operation) parts.push(`[${operation}]`);
234
+ return parts.join(" ");
235
+ }
236
+ log(level, message, options) {
237
+ const prefix = options?.context ? `[${options.context}]` : "";
238
+ const fullMessage = `${prefix} ${message}`.trim();
239
+ switch (level) {
240
+ case "debug":
241
+ case "info":
242
+ console.log(fullMessage);
243
+ break;
244
+ case "warn":
245
+ console.warn(fullMessage);
246
+ break;
247
+ case "error":
248
+ console.error(fullMessage);
249
+ break;
250
+ }
251
+ if (options?.data) {
252
+ console.dir(options.data, { depth: null });
253
+ }
254
+ }
255
+ };
256
+ var logger = new Logger();
257
+
258
+ // src/helpers/date.ts
259
+ var iso8601DateSchema = import_zod.default.string().regex(
260
+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/,
261
+ "Must be a valid ISO 8601 date format (e.g., 2024-12-31T23:59:59.000Z)"
262
+ );
263
+ var TimeUnit = {
264
+ Day: "day",
265
+ Month: "month",
266
+ Year: "year"
267
+ };
268
+ var units = {
269
+ [TimeUnit.Day]: {
270
+ one: "day",
271
+ other: "days"
272
+ },
273
+ [TimeUnit.Month]: {
274
+ one: "month",
275
+ other: "months"
276
+ },
277
+ [TimeUnit.Year]: {
278
+ one: "year",
279
+ other: "years"
280
+ }
281
+ };
282
+ var formatDateAsUSStandard = (date, opts) => date.toLocaleString("en-US", {
283
+ month: "2-digit",
284
+ day: "2-digit",
285
+ year: "numeric",
286
+ ...opts
287
+ });
288
+ var formatDateAsISO = (date) => date.toISOString();
289
+ var formatFullDate = (date) => {
290
+ const options = {
291
+ year: "numeric",
292
+ month: "long",
293
+ day: "2-digit",
294
+ timeZone: "UTC"
295
+ };
296
+ return new Intl.DateTimeFormat("en-US", options).format(date);
297
+ };
298
+ var formatTime = (date) => {
299
+ return date.toLocaleTimeString("en-US", {
300
+ hour: "2-digit",
301
+ minute: "2-digit",
302
+ second: "2-digit",
303
+ timeZone: "UTC",
304
+ timeZoneName: "short"
305
+ });
306
+ };
307
+ var formatDateTime = (date) => {
308
+ const dateOptions = {
309
+ month: "short",
310
+ day: "numeric",
311
+ year: "numeric",
312
+ timeZone: "UTC"
313
+ };
314
+ const timeOptions2 = {
315
+ hour: "2-digit",
316
+ minute: "2-digit",
317
+ timeZone: "UTC"
318
+ };
319
+ const formattedDate = new Intl.DateTimeFormat("en-US", dateOptions).format(
320
+ date
321
+ );
322
+ const formattedTime = new Intl.DateTimeFormat("en-US", timeOptions2).format(
323
+ date
324
+ );
325
+ return `${formattedDate} at ${formattedTime}`;
326
+ };
327
+ var formatLongDate = (date) => {
328
+ const options = {
329
+ year: "numeric",
330
+ month: "long",
331
+ day: "numeric",
332
+ timeZone: "UTC"
333
+ };
334
+ return new Intl.DateTimeFormat("en-US", options).format(date);
335
+ };
336
+ var formatLongDateTime = (date) => {
337
+ const dateOptions = {
338
+ year: "numeric",
339
+ month: "long",
340
+ day: "numeric",
341
+ timeZone: "UTC"
342
+ };
343
+ const timeOptions2 = {
344
+ hour: "2-digit",
345
+ minute: "2-digit",
346
+ hour12: true,
347
+ timeZone: "UTC"
348
+ };
349
+ const formattedDate = new Intl.DateTimeFormat("en-US", dateOptions).format(
350
+ date
351
+ );
352
+ const formattedTime = new Intl.DateTimeFormat("en-US", timeOptions2).format(date).toLowerCase();
353
+ return `${formattedDate} at ${formattedTime}`;
354
+ };
355
+ var formatToShortDate = (dateString) => {
356
+ const date = typeof dateString === "string" ? new Date(dateString) : dateString;
357
+ if (isNaN(date.getTime())) {
358
+ return "Jan 1";
359
+ }
360
+ return date.toLocaleDateString("en-US", {
361
+ month: "short",
362
+ day: "numeric",
363
+ timeZone: "UTC"
364
+ });
365
+ };
366
+ var formatToShortDateWithYear = (dateString) => {
367
+ const date = typeof dateString === "string" ? new Date(dateString) : dateString;
368
+ if (isNaN(date.getTime())) {
369
+ return "Unknown";
370
+ }
371
+ return date.toLocaleDateString("en-US", {
372
+ month: "short",
373
+ day: "numeric",
374
+ year: "numeric",
375
+ timeZone: "UTC"
376
+ });
377
+ };
378
+ var formatToJustDate = (dateString) => {
379
+ const date = new Date(dateString);
380
+ if (isNaN(date.getTime())) {
381
+ return "1";
382
+ }
383
+ return date.getUTCDate().toString();
384
+ };
385
+ var formatDateToYYYYMMDD = (date) => {
386
+ return new Intl.DateTimeFormat("en-CA", {
387
+ year: "numeric",
388
+ month: "2-digit",
389
+ day: "2-digit"
390
+ }).format(date);
391
+ };
392
+ var isDateInvalid = (date) => {
393
+ return date.toString() === "Invalid Date";
394
+ };
395
+ var isValidDate = (date) => {
396
+ return !isDateInvalid(date) && !isNaN(date.getTime());
397
+ };
398
+ var isDateEpoc = (date) => {
399
+ return date.getTime() <= 0;
400
+ };
401
+ var isDateInRange = (arg) => {
402
+ if (typeof arg !== "string") {
403
+ return false;
404
+ }
405
+ const date = new Date(arg);
406
+ const startDate = /* @__PURE__ */ new Date("1800-01-01T00:00:00.000Z");
407
+ const endDate = /* @__PURE__ */ new Date("2999-12-31T23:59:59.999Z");
408
+ return date >= startDate && date <= endDate;
409
+ };
410
+ var isDateInPast = (input) => {
411
+ let date;
412
+ if (input instanceof Date) {
413
+ date = input;
414
+ } else if (typeof input === "number") {
415
+ const ms = input < 1e12 ? input * 1e3 : input;
416
+ date = new Date(ms);
417
+ } else {
418
+ date = new Date(input);
419
+ }
420
+ if (isNaN(date.getTime())) {
421
+ return false;
422
+ }
423
+ return date.getTime() < Date.now();
424
+ };
425
+ var isSameDate = (dateA, dateB) => {
426
+ return dateA.getFullYear() === dateB.getFullYear() && dateA.getMonth() === dateB.getMonth() && dateA.getDate() === dateB.getDate();
427
+ };
428
+ var getPluralizedUnit = (unit, count, locale = "en") => {
429
+ const pluralRules = new Intl.PluralRules(locale, {
430
+ type: "cardinal"
431
+ });
432
+ const pluralCategory = pluralRules.select(count);
433
+ if (pluralCategory === "one" || pluralCategory === "other") {
434
+ return `${count} ${units[unit][pluralCategory]}`;
435
+ }
436
+ return `${count} ${units[unit].other}`;
437
+ };
438
+ var getRelativeDateDescription = (targetDate, locale = "en") => {
439
+ const currentDate = /* @__PURE__ */ new Date();
440
+ const oneDay = 1e3 * 60 * 60 * 24;
441
+ const oneMonth = oneDay * 30;
442
+ const oneYear = oneDay * 365;
443
+ const diffInMilliseconds = targetDate.getTime() - currentDate.getTime();
444
+ const diffInDays = Math.round(diffInMilliseconds / oneDay);
445
+ const diffInMonths = Math.round(diffInMilliseconds / oneMonth);
446
+ const diffInYears = Math.round(diffInMilliseconds / oneYear);
447
+ if (Math.abs(diffInYears) >= 1) {
448
+ return getPluralizedUnit("year", Math.abs(diffInYears), locale);
449
+ }
450
+ if (Math.abs(diffInMonths) >= 1) {
451
+ return getPluralizedUnit("month", Math.abs(diffInMonths), locale);
452
+ }
453
+ return getPluralizedUnit("day", Math.abs(diffInDays), locale);
454
+ };
455
+ var safeFormatDate = (date, formatter, fallback) => {
456
+ const dateObj = typeof date === "string" ? new Date(date) : date;
457
+ if (!isValidDate(dateObj)) {
458
+ return fallback;
459
+ }
460
+ try {
461
+ return formatter(dateObj);
462
+ } catch (error) {
463
+ logger.logError(error, {
464
+ context: safeFormatDate.name
465
+ });
466
+ return fallback;
467
+ }
468
+ };
469
+ var parseDateTime = (dateInput, timeInput) => {
470
+ const dateRegex = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
471
+ const timeRegex = /^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM|am|pm)?$/;
472
+ const dateMatch = dateRegex.exec(dateInput);
473
+ if (!dateMatch) {
474
+ return void 0;
475
+ }
476
+ const month = parseInt(dateMatch[1], 10) - 1;
477
+ const day = parseInt(dateMatch[2], 10);
478
+ const year = parseInt(dateMatch[3], 10);
479
+ let hours = 0;
480
+ let minutes = 0;
481
+ let seconds = 0;
482
+ if (timeInput) {
483
+ timeInput = timeInput.replace(/\u00A0/g, " ").trim();
484
+ const timeMatch = timeRegex.exec(timeInput);
485
+ if (!timeMatch) {
486
+ return void 0;
487
+ }
488
+ hours = parseInt(timeMatch[1], 10);
489
+ minutes = parseInt(timeMatch[2], 10);
490
+ seconds = timeMatch[3] ? parseInt(timeMatch[3], 10) : 0;
491
+ const meridiem = timeMatch[4] ? timeMatch[4].toUpperCase() : null;
492
+ if (meridiem === "PM" && hours < 12) {
493
+ hours += 12;
494
+ } else if (meridiem === "AM" && hours === 12) {
495
+ hours = 0;
496
+ }
497
+ }
498
+ const date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
499
+ if (isNaN(date.getTime())) {
500
+ return void 0;
501
+ }
502
+ return date;
503
+ };
504
+ var validateIso8601Date = (dueDate) => {
505
+ const result = iso8601DateSchema.safeParse(dueDate);
506
+ if (!result.success) {
507
+ const errorMessage = result.error.issues[0]?.message || "Invalid ISO 8601 format";
508
+ throw new Error(`Invalid due date format: ${errorMessage}`);
509
+ }
510
+ };
511
+
512
+ // src/helpers/datetime.ts
513
+ var import_zod4 = require("zod");
514
+
515
+ // src/schemas/instruction.ts
516
+ var import_zod3 = require("zod");
517
+
518
+ // src/schemas/misc.ts
519
+ var import_zod2 = require("zod");
520
+ var DATE_REGEX = /^(19|20)\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
521
+ var DATE_ISO_8601_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?$/;
522
+ var DATE_STANDARD_REGEX = /^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/(19|20)\d{2}$/;
523
+ var TIME_REGEX = /^(0[1-9]|1[0-2]):[0-5][0-9]:[0-5][0-9] (AM|PM)$/;
524
+ var regexSchema = (regex, message) => import_zod2.z.string().regex(regex, message);
525
+ var nonEmptyStringSchema = import_zod2.z.string().min(1);
526
+ var numberSchema = import_zod2.z.union([
527
+ import_zod2.z.number().finite(),
528
+ import_zod2.z.string().regex(/^-?\d*\.?\d+(?:[eE][-+]?\d+)?$/).transform(Number)
529
+ ]);
530
+ var decimalStringSchema = import_zod2.z.string().regex(/^-?\d*\.?\d+$/).refine((val) => !isNaN(parseFloat(val)), {
531
+ message: "Must be a valid decimal number"
532
+ });
533
+ var bigintSchema = import_zod2.z.union([
534
+ import_zod2.z.bigint(),
535
+ import_zod2.z.string().regex(/^-?\d+$/).transform(BigInt)
536
+ ]);
537
+ var hexStringSchema = import_zod2.z.string().startsWith("0x").transform((val) => val);
538
+ var dateSchema = regexSchema(DATE_REGEX);
539
+ var dateISO8601Schema = regexSchema(DATE_ISO_8601_REGEX);
540
+ var dateStandardSchema = regexSchema(DATE_STANDARD_REGEX);
541
+ var timeSchema = regexSchema(TIME_REGEX);
542
+ var Sort = {
543
+ Asc: "asc",
544
+ Desc: "desc"
545
+ };
546
+ var sortValues = Object.values(Sort);
547
+ var vrsSchema = import_zod2.z.object({
548
+ v: import_zod2.z.number(),
549
+ r: import_zod2.z.string(),
550
+ s: import_zod2.z.string()
551
+ });
552
+ var eip2098SignatureSchema = import_zod2.z.object({
553
+ yParity: import_zod2.z.number(),
554
+ r: import_zod2.z.string(),
555
+ s: import_zod2.z.string()
556
+ });
557
+
558
+ // src/schemas/instruction.ts
559
+ var InstructionState = {
560
+ PendingActivation: "PendingActivation",
561
+ Active: "Active",
562
+ PendingDeactivation: "PendingDeactivation",
563
+ Deactivated: "Deactivated",
564
+ Errored: "Errored",
565
+ Completed: "Completed",
566
+ UserNotDelegated: "UserNotDelegated",
567
+ InFlight: "InFlight",
568
+ NotifyUser: "NotifyUser"
569
+ };
570
+ var instructionStateValues = Object.values(InstructionState);
571
+ var instructionStateSchema = import_zod3.z.enum(instructionStateValues);
572
+ var InstructionAction = {
573
+ RefuelERC20: "refuelERC20",
574
+ Refuel: "refuel",
575
+ Transfer: "transfer",
576
+ TransferERC20: "transferERC20",
577
+ UniswapV3ExactInput: "uniswapV3ExactInput",
578
+ Sweep: "sweep",
579
+ SweepERC20: "sweepERC20",
580
+ SweepCCTP: "sweepCCTP",
581
+ SweepUniswapV3: "sweepUniswapV3",
582
+ SweepDepositAccount: "sweepDepositAccount",
583
+ SweepDepositAccountERC20: "sweepDepositAccountERC20",
584
+ DeactivateInstruction: "deactivateInstruction",
585
+ SweepSkipCCTPDepositAccount: "sweepSkipCCTPDepositAccount"
586
+ };
587
+ var instructionActionValues = Object.values(InstructionAction);
588
+ var instructionActionSchema = import_zod3.z.enum(instructionActionValues);
589
+ var InstructionScheduleStartType = {
590
+ Now: "now",
591
+ DateTime: "datetime"
592
+ };
593
+ var instructionScheduleStartValues = Object.values(
594
+ InstructionScheduleStartType
595
+ );
596
+ var baseStartSchema = import_zod3.z.object({
597
+ type: import_zod3.z.enum(instructionScheduleStartValues)
598
+ });
599
+ var nowStartSchema = baseStartSchema.extend({
600
+ type: import_zod3.z.literal(InstructionScheduleStartType.Now)
601
+ });
602
+ var dateTimeStartSchema = baseStartSchema.extend({
603
+ type: import_zod3.z.literal(InstructionScheduleStartType.DateTime),
604
+ startDate: dateStandardSchema,
605
+ startTime: import_zod3.z.string()
606
+ });
607
+ var instructionScheduleStartSchema = import_zod3.z.discriminatedUnion("type", [
608
+ nowStartSchema,
609
+ dateTimeStartSchema
610
+ ]);
611
+ var InstructionScheduleRepeatType = {
612
+ UntilDeactivated: "until-deactivated",
613
+ MaxExecutions: "max-executions"
614
+ };
615
+ var instructionScheduleRepeatValues = Object.values(
616
+ InstructionScheduleRepeatType
617
+ );
618
+ var baseRepeatSchema = import_zod3.z.object({});
619
+ var untilDeactivatedRepeatSchema = baseRepeatSchema.extend({
620
+ type: import_zod3.z.literal(InstructionScheduleRepeatType.UntilDeactivated)
621
+ });
622
+ var maxExecutionsRepeatSchema = baseRepeatSchema.extend({
623
+ type: import_zod3.z.literal(InstructionScheduleRepeatType.MaxExecutions),
624
+ maxExecutions: numberSchema
625
+ });
626
+ var instructionScheduleRepeatSchema = import_zod3.z.discriminatedUnion("type", [
627
+ untilDeactivatedRepeatSchema,
628
+ maxExecutionsRepeatSchema
629
+ ]);
630
+ var InstructionScheduleRetryType = {
631
+ UntilDeactivated: "until-deactivated",
632
+ TimeLimited: "time-limited"
633
+ };
634
+ var instructionScheduleRetryValues = Object.values(
635
+ InstructionScheduleRetryType
636
+ );
637
+ var baseRetrySchema = import_zod3.z.object({});
638
+ var untilDeactivatedRetrySchema = baseRetrySchema.extend({
639
+ type: import_zod3.z.literal(InstructionScheduleRetryType.UntilDeactivated)
640
+ });
641
+ var timeLimitedRetrySchema = baseRetrySchema.extend({
642
+ type: import_zod3.z.literal(InstructionScheduleRetryType.TimeLimited),
643
+ retryCount: numberSchema
644
+ });
645
+ var instructionScheduleRetrySchema = import_zod3.z.discriminatedUnion("type", [
646
+ untilDeactivatedRetrySchema,
647
+ timeLimitedRetrySchema
648
+ ]);
649
+ var TimeUnit2 = {
650
+ None: "none",
651
+ Second: "second",
652
+ Minute: "minute",
653
+ Hour: "hour",
654
+ Day: "day",
655
+ Week: "week",
656
+ Month: "month"
657
+ };
658
+ var timeUnitValues = Object.values(TimeUnit2);
659
+ var timeUnitSchema = import_zod3.z.enum(timeUnitValues);
660
+ var instructionExecutionStateSchema = import_zod3.z.object({
661
+ executionStatus: instructionStateSchema.optional(),
662
+ executionCounter: import_zod3.z.number().int().optional(),
663
+ lastExecuted: import_zod3.z.number().int().optional()
664
+ });
665
+ var instructionSchema = import_zod3.z.object({
666
+ instructionId: hexStringSchema,
667
+ createdAt: import_zod3.z.number().optional(),
668
+ startAt: import_zod3.z.string().nullish(),
669
+ interval: import_zod3.z.number().nullish(),
670
+ timeout: import_zod3.z.number().nullish(),
671
+ maxExecutions: import_zod3.z.number().nullish(),
672
+ executionState: instructionExecutionStateSchema.optional(),
673
+ actionName: import_zod3.z.string().optional(),
674
+ arguments: import_zod3.z.any(),
675
+ nickname: import_zod3.z.string().nullish(),
676
+ lastInstructedValue: import_zod3.z.string().optional(),
677
+ lastErrorCode: import_zod3.z.number().nullish(),
678
+ lastErrorMessage: import_zod3.z.string().nullish(),
679
+ totalInstructedValue: import_zod3.z.string().optional(),
680
+ instructedTokenAddress: hexStringSchema.nullish(),
681
+ chainId: import_zod3.z.number().nullish(),
682
+ chain: import_zod3.z.string().optional()
683
+ });
684
+ var instructionsSchema = import_zod3.z.array(instructionSchema);
685
+ var instructionSummarySchema = import_zod3.z.object({
686
+ instructionId: hexStringSchema,
687
+ chainId: import_zod3.z.number().int(),
688
+ executionCount: import_zod3.z.number().int(),
689
+ onTimeCount: import_zod3.z.number().int(),
690
+ lateCount: import_zod3.z.number().int(),
691
+ wasActivatedDuring: import_zod3.z.boolean(),
692
+ amount: import_zod3.z.number().default(0),
693
+ instructedValue: import_zod3.z.string().nullish().default("0"),
694
+ instructedTokenAddress: import_zod3.z.string().nullish().default(null)
695
+ });
696
+ var instructionSummariesSchema = import_zod3.z.array(instructionSummarySchema);
697
+ var instructionSummariesByDateSchema = import_zod3.z.record(
698
+ import_zod3.z.string(),
699
+ instructionSummariesSchema
700
+ );
701
+ var InstructionViewTimescale = {
702
+ Days: "days",
703
+ Hours: "hours",
704
+ Minutes: "minutes",
705
+ Seconds: "seconds"
706
+ };
707
+ var instructionViewTimescaleValues = Object.values(
708
+ InstructionViewTimescale
709
+ );
710
+
711
+ // src/helpers/datetime.ts
712
+ var timeUnitInputValueSchema = import_zod4.z.object({
713
+ unit: timeUnitSchema,
714
+ value: import_zod4.z.number().finite(),
715
+ seconds: import_zod4.z.number().finite()
716
+ });
717
+ var isTimeUnitInputValue = (value) => {
718
+ if (typeof value !== "object" || value === null) {
719
+ return false;
720
+ }
721
+ const obj = value;
722
+ return "unit" in obj && "value" in obj && "seconds" in obj && typeof obj.unit === "string" && typeof obj.value === "number" && typeof obj.seconds === "number";
723
+ };
724
+ var parseJsonToTimeUnitValue = (jsonString) => {
725
+ try {
726
+ const parsed = JSON.parse(jsonString);
727
+ return isTimeUnitInputValue(parsed) ? parsed : void 0;
728
+ } catch {
729
+ return void 0;
730
+ }
731
+ };
732
+ var parseTimeUnitValue = (value) => {
733
+ if (!value) return void 0;
734
+ if (isTimeUnitInputValue(value)) {
735
+ return value;
736
+ }
737
+ if (typeof value === "string") {
738
+ return parseJsonToTimeUnitValue(value);
739
+ }
740
+ return void 0;
741
+ };
742
+ var serializeTimeUnitValue = (value) => {
743
+ return JSON.stringify(value);
744
+ };
745
+ var isValidTimeUnitValue = (value) => {
746
+ return parseTimeUnitValue(value) !== void 0;
747
+ };
748
+ var getSecondsFromTimeUnitValue = (value) => {
749
+ const parsed = parseTimeUnitValue(value);
750
+ return parsed?.seconds ?? 0;
751
+ };
752
+ var coerceSecondsFromTimeUnitValue = (value) => {
753
+ if (!value) return 0;
754
+ if (typeof value === "object") {
755
+ const obj = value;
756
+ const seconds = obj?.seconds;
757
+ if (typeof seconds === "number" && Number.isFinite(seconds)) return seconds;
758
+ }
759
+ if (typeof value === "string") {
760
+ try {
761
+ const parsed = JSON.parse(value);
762
+ const seconds = parsed?.seconds;
763
+ if (typeof seconds === "number" && Number.isFinite(seconds))
764
+ return seconds;
765
+ } catch {
766
+ }
767
+ }
768
+ return 0;
769
+ };
770
+ function parseDateTimeStrict(date, time) {
771
+ try {
772
+ const parts = date?.split("/") ?? [];
773
+ const month = Number(parts[0]);
774
+ const day = Number(parts[1]);
775
+ const year = Number(parts[2]);
776
+ const timeParts = time?.split(" ") ?? [];
777
+ const timePart = timeParts[0] ?? "00:00:00";
778
+ const ampm = timeParts[1] ?? "AM";
779
+ const [hoursStr, minutesStr, secondsStr] = timePart.split(":");
780
+ let hours = Number(hoursStr ?? 0);
781
+ const minutes = Number(minutesStr ?? 0);
782
+ const seconds = Number(secondsStr ?? 0);
783
+ if (ampm === "PM" && hours < 12) hours += 12;
784
+ if (ampm === "AM" && hours === 12) hours = 0;
785
+ const dt = new Date(
786
+ year || 0,
787
+ (month || 1) - 1,
788
+ day || 1,
789
+ hours,
790
+ minutes,
791
+ seconds
792
+ );
793
+ return isNaN(dt.getTime()) ? null : dt;
794
+ } catch {
795
+ return null;
796
+ }
797
+ }
798
+
799
+ // src/helpers/domain.ts
800
+ function getBaseDomain(hostname) {
801
+ if (hostname.includes("localhost")) {
802
+ return hostname;
803
+ }
804
+ const parts = hostname.split(".");
805
+ if (parts.length < 2) {
806
+ return hostname;
807
+ }
808
+ if (parts.length === 2) {
809
+ return hostname;
810
+ }
811
+ const lastTwoParts = parts.slice(-2).join(".");
812
+ const traditionalMultiPartTlds = [
813
+ "co.uk",
814
+ "com.au",
815
+ "co.jp",
816
+ "co.kr",
817
+ "co.za",
818
+ "co.in",
819
+ "com.br",
820
+ "com.mx",
821
+ "com.ar",
822
+ "com.cn",
823
+ "com.tw",
824
+ "org.uk",
825
+ "net.uk",
826
+ "ac.uk",
827
+ "gov.uk"
828
+ ];
829
+ if (traditionalMultiPartTlds.includes(lastTwoParts)) {
830
+ return parts.slice(-3).join(".");
831
+ }
832
+ const deploymentTlds = [
833
+ "vercel.app",
834
+ "netlify.app",
835
+ "github.io",
836
+ "gitlab.io"
837
+ ];
838
+ if (deploymentTlds.includes(lastTwoParts)) {
839
+ return hostname;
840
+ }
841
+ return parts.slice(-2).join(".");
842
+ }
843
+
844
+ // src/helpers/intl.ts
845
+ var import_zod5 = require("zod");
846
+ var locales = ["en", "es"];
847
+ var i18n = {
848
+ defaultLocale: "en",
849
+ locales: [...locales]
850
+ };
851
+ var localeSchema = import_zod5.z.enum(locales);
852
+ var formattedNumber = (num) => {
853
+ if (!Number.isFinite(num)) {
854
+ return "0";
855
+ }
856
+ return num.toLocaleString("en-US");
857
+ };
858
+ var formatCurrency = (amount, options) => {
859
+ return new Intl.NumberFormat("en-US", {
860
+ style: "currency",
861
+ currency: "USD",
862
+ minimumFractionDigits: 2,
863
+ maximumFractionDigits: 2,
864
+ ...options
865
+ }).format(amount);
866
+ };
867
+
868
+ // src/helpers/mask-options.ts
869
+ var import_kit = require("@maskito/kit");
870
+ var SHORT_FORM_POSTAL_MASK = [/\d/, /\d/, /\d/, /\d/, /\d/];
871
+ var LONG_FORM_POSTAL_MASK = [
872
+ /\d/,
873
+ /\d/,
874
+ /\d/,
875
+ /\d/,
876
+ /\d/,
877
+ "-",
878
+ /\d/,
879
+ /\d/,
880
+ /\d/,
881
+ /\d/
882
+ ];
883
+ var postalCodeMaskOptions = {
884
+ mask: (state) => {
885
+ return state.value.length > 5 ? LONG_FORM_POSTAL_MASK : SHORT_FORM_POSTAL_MASK;
886
+ }
887
+ };
888
+ var dateMaskOptions = (0, import_kit.maskitoDateOptionsGenerator)({
889
+ mode: "mm/dd/yyyy",
890
+ separator: "/"
891
+ });
892
+ var timeOptions = (0, import_kit.maskitoTimeOptionsGenerator)({
893
+ mode: "HH:MM:SS AA"
894
+ });
895
+ var timeOptionsWithoutMeridiem = (0, import_kit.maskitoTimeOptionsGenerator)({
896
+ mode: "HH:MM:SS"
897
+ });
898
+ var timeMaskOptionsHHMM = (0, import_kit.maskitoTimeOptionsGenerator)({
899
+ mode: "HH:MM"
900
+ });
901
+ var formatUUID = (value) => {
902
+ if (!value) {
903
+ return "";
904
+ }
905
+ const cleanValue = value.replace(/[^0-9a-f-]/gi, "");
906
+ const hexOnly = cleanValue.replace(/-/g, "");
907
+ const limitedHex = hexOnly.slice(0, 32);
908
+ if (limitedHex.length === 32) {
909
+ return [
910
+ limitedHex.slice(0, 8),
911
+ limitedHex.slice(8, 12),
912
+ limitedHex.slice(12, 16),
913
+ limitedHex.slice(16, 20),
914
+ limitedHex.slice(20, 32)
915
+ ].join("-");
916
+ }
917
+ let formatted = "";
918
+ let index = 0;
919
+ if (index < limitedHex.length) {
920
+ const group1 = limitedHex.slice(
921
+ index,
922
+ Math.min(index + 8, limitedHex.length)
923
+ );
924
+ formatted += group1;
925
+ index += 8;
926
+ if (index <= limitedHex.length && group1.length === 8) {
927
+ formatted += "-";
928
+ }
929
+ }
930
+ if (index < limitedHex.length) {
931
+ const group2 = limitedHex.slice(
932
+ index,
933
+ Math.min(index + 4, limitedHex.length)
934
+ );
935
+ formatted += group2;
936
+ index += 4;
937
+ if (index <= limitedHex.length && group2.length === 4) {
938
+ formatted += "-";
939
+ }
940
+ }
941
+ if (index < limitedHex.length) {
942
+ const group3 = limitedHex.slice(
943
+ index,
944
+ Math.min(index + 4, limitedHex.length)
945
+ );
946
+ formatted += group3;
947
+ index += 4;
948
+ if (index <= limitedHex.length && group3.length === 4) {
949
+ formatted += "-";
950
+ }
951
+ }
952
+ if (index < limitedHex.length) {
953
+ const group4 = limitedHex.slice(
954
+ index,
955
+ Math.min(index + 4, limitedHex.length)
956
+ );
957
+ formatted += group4;
958
+ index += 4;
959
+ if (index <= limitedHex.length && group4.length === 4) {
960
+ formatted += "-";
961
+ }
962
+ }
963
+ if (index < limitedHex.length) {
964
+ formatted += limitedHex.slice(
965
+ index,
966
+ Math.min(index + 12, limitedHex.length)
967
+ );
968
+ }
969
+ return formatted;
970
+ };
971
+ var uuidMaskOptions = {
972
+ mask: /^[0-9a-f-]*$/i
973
+ };
974
+ var usdCurrencyMaskOptions = {
975
+ mask: /^[0-9., $]*$/,
976
+ postprocessors: [
977
+ (state) => {
978
+ const selectionEnd = state.selection?.[1] ?? state.value.length;
979
+ const numeric = state.value.replace(/[^0-9]/g, "");
980
+ if (numeric.length === 0) {
981
+ return { ...state, value: "", selection: [0, 0] };
982
+ }
983
+ const clamped = numeric.slice(0, 11);
984
+ const amount = Number(clamped) / 100;
985
+ const formatted = amount.toLocaleString("en-US", {
986
+ style: "currency",
987
+ currency: "USD",
988
+ minimumFractionDigits: 2,
989
+ maximumFractionDigits: 2
990
+ });
991
+ const nextCaret = Math.min(
992
+ formatted.length,
993
+ selectionEnd + (formatted.length - state.value.length)
994
+ );
995
+ return { ...state, value: formatted, selection: [nextCaret, nextCaret] };
996
+ }
997
+ ]
998
+ };
999
+
1000
+ // src/helpers/num-formatter.ts
1001
+ var numFormatter = (num, round) => {
1002
+ if (num >= 1e3 && num < 1e6) {
1003
+ return `${(num / 1e3).toFixed(typeof round === "number" ? round : num % 1e3 === 0 ? 0 : 1)}K`;
1004
+ }
1005
+ if (num >= 1e6 && num < 1e9) {
1006
+ return `${(num / 1e6).toFixed(typeof round === "number" ? round : num % 1e6 === 0 ? 0 : 2)}M`;
1007
+ }
1008
+ if (num > 1e9) {
1009
+ return `${(num / 1e9).toFixed(typeof round === "number" ? round : num % 1e9 === 0 ? 0 : 2)}B`;
1010
+ }
1011
+ return Number(
1012
+ Number(num).toFixed(
1013
+ typeof round === "number" ? round : num * 100 % 100 === 0 ? 0 : 2
1014
+ )
1015
+ );
1016
+ };
1017
+ var formatNumberAsUSStandard = (num) => {
1018
+ return num.toLocaleString("en-US", {
1019
+ maximumSignificantDigits: 3
1020
+ });
1021
+ };
1022
+
1023
+ // src/helpers/window.ts
1024
+ var isClient = () => typeof globalThis !== "undefined" && "window" in globalThis;
1025
+ var DEFAULT_EMERGENT_WINDOW_CONFIG = {
1026
+ width: 480,
1027
+ height: 720,
1028
+ name: "emergent_window"
1029
+ };
1030
+ function openCenteredEmergentWindow(url, config = {}) {
1031
+ if (!isClient()) {
1032
+ return null;
1033
+ }
1034
+ const { width, height, name } = {
1035
+ ...DEFAULT_EMERGENT_WINDOW_CONFIG,
1036
+ ...config
1037
+ };
1038
+ const screenLeft = window.screenLeft ?? window.screenX ?? 0;
1039
+ const screenTop = window.screenTop ?? window.screenY ?? 0;
1040
+ const viewportWidth = window.innerWidth || document.documentElement.clientWidth || screen.width;
1041
+ const viewportHeight = window.innerHeight || document.documentElement.clientHeight || screen.height;
1042
+ const left = Math.max(0, screenLeft + (viewportWidth - width) / 2);
1043
+ const top = Math.max(0, screenTop + (viewportHeight - height) / 2);
1044
+ const features = [
1045
+ "noopener",
1046
+ "noreferrer",
1047
+ `width=${width}`,
1048
+ `height=${height}`,
1049
+ `left=${left}`,
1050
+ `top=${top}`,
1051
+ "menubar=no",
1052
+ "toolbar=no",
1053
+ "location=no",
1054
+ "status=no",
1055
+ "scrollbars=yes"
1056
+ ].join(",");
1057
+ const emergentWindow = window.open(url, name, features);
1058
+ try {
1059
+ emergentWindow?.focus();
1060
+ } catch (error) {
1061
+ logger.logError(error, {
1062
+ context: openCenteredEmergentWindow.name
1063
+ });
1064
+ }
1065
+ return emergentWindow ?? null;
1066
+ }
1067
+ function closeEmergentWindow(emergentWindow) {
1068
+ if (!emergentWindow) return;
1069
+ try {
1070
+ emergentWindow.close();
1071
+ } catch (error) {
1072
+ logger.logError(error, {
1073
+ context: closeEmergentWindow.name
1074
+ });
1075
+ }
1076
+ }
1077
+ function focusMainWindow() {
1078
+ if (!isClient()) return;
1079
+ try {
1080
+ window.focus();
1081
+ } catch (error) {
1082
+ logger.logError(error, {
1083
+ context: focusMainWindow.name
1084
+ });
1085
+ }
1086
+ }
1087
+ function performRedirect(path, fallbackPath = "/") {
1088
+ if (!isClient()) return;
1089
+ const redirectPath = path || fallbackPath;
1090
+ window.location.href = redirectPath;
1091
+ }
1092
+
1093
+ // src/helpers/polling.ts
1094
+ var DEFAULT_POLLING_CONFIG = {
1095
+ intervalMs: 1e3,
1096
+ onComplete: () => {
1097
+ }
1098
+ };
1099
+ var PollingManager = class {
1100
+ constructor(config = {}) {
1101
+ __publicField(this, "emergentWindow", null);
1102
+ __publicField(this, "pollIntervalId", null);
1103
+ __publicField(this, "config");
1104
+ this.config = { ...DEFAULT_POLLING_CONFIG, ...config };
1105
+ }
1106
+ /**
1107
+ * Starts polling for the given check function
1108
+ *
1109
+ * @param emergentWindow - The emergent window to monitor (optional)
1110
+ * @param checkFn - Function that returns true when polling should stop
1111
+ */
1112
+ start(emergentWindow, checkFn) {
1113
+ this.emergentWindow = emergentWindow;
1114
+ this.stop();
1115
+ this.pollIntervalId = window.setInterval(() => {
1116
+ void (async () => {
1117
+ try {
1118
+ const isComplete = await checkFn();
1119
+ if (isComplete) {
1120
+ this.finalize();
1121
+ this.config.onComplete();
1122
+ }
1123
+ } catch (error) {
1124
+ logger.logError(error, {
1125
+ context: this.start.name
1126
+ });
1127
+ }
1128
+ })();
1129
+ }, this.config.intervalMs);
1130
+ }
1131
+ /**
1132
+ * Stops polling and cleans up resources
1133
+ */
1134
+ stop() {
1135
+ if (this.pollIntervalId !== null) {
1136
+ clearInterval(this.pollIntervalId);
1137
+ this.pollIntervalId = null;
1138
+ }
1139
+ }
1140
+ /**
1141
+ * Finalizes polling by closing emergent window, stopping interval, and returning focus
1142
+ */
1143
+ finalize() {
1144
+ closeEmergentWindow(this.emergentWindow);
1145
+ this.emergentWindow = null;
1146
+ this.stop();
1147
+ focusMainWindow();
1148
+ }
1149
+ /**
1150
+ * Cleans up resources
1151
+ */
1152
+ dispose() {
1153
+ this.finalize();
1154
+ }
1155
+ };
1156
+
1157
+ // src/helpers/random.ts
1158
+ var randomNumber = (opts) => {
1159
+ const { value, min, max } = opts;
1160
+ let hash = 0;
1161
+ for (let i = 0; i < value.length; i++) {
1162
+ hash = (hash << 5) - hash + value.charCodeAt(i);
1163
+ hash |= 0;
1164
+ }
1165
+ const normalizedHash = Math.abs(hash);
1166
+ return Math.floor(normalizedHash % (max - min + 1)) + min;
1167
+ };
1168
+
1169
+ // src/helpers/sdk-loader.ts
1170
+ var DEFAULT_SDK_TIMEOUT = 1e4;
1171
+ async function loadExternalSdk(config) {
1172
+ if (typeof window === "undefined") {
1173
+ throw new Error(`${config.name} SDK can only be loaded in the browser`);
1174
+ }
1175
+ const timeout = config.timeout ?? DEFAULT_SDK_TIMEOUT;
1176
+ return new Promise((resolve, reject) => {
1177
+ const timeoutId = setTimeout(() => {
1178
+ reject(
1179
+ new Error(`${config.name} SDK loading timed out after ${timeout}ms`)
1180
+ );
1181
+ }, timeout);
1182
+ const script = document.createElement("script");
1183
+ script.src = config.src;
1184
+ script.async = true;
1185
+ script.onload = () => {
1186
+ clearTimeout(timeoutId);
1187
+ resolve();
1188
+ };
1189
+ script.onerror = () => {
1190
+ clearTimeout(timeoutId);
1191
+ reject(new Error(`Failed to load ${config.name} SDK from ${config.src}`));
1192
+ };
1193
+ document.body.appendChild(script);
1194
+ });
1195
+ }
1196
+ function isScriptLoaded(src) {
1197
+ if (typeof window === "undefined") {
1198
+ return false;
1199
+ }
1200
+ const scripts = document.getElementsByTagName("script");
1201
+ for (let i = 0; i < scripts.length; i++) {
1202
+ if (scripts[i]?.src === src) {
1203
+ return true;
1204
+ }
1205
+ }
1206
+ return false;
1207
+ }
1208
+
1209
+ // src/helpers/signatures.ts
1210
+ var formatSignatureToEIP2098 = (signature) => {
1211
+ const ensureHexPrefix = (value) => value.startsWith("0x") ? value : `0x${value}`;
1212
+ const vNum = Number.parseInt(signature.v, 16);
1213
+ const yParity = (() => {
1214
+ if (Number.isNaN(vNum)) return 0;
1215
+ if (vNum <= 1) return vNum;
1216
+ return vNum % 2 === 0 ? 1 : 0;
1217
+ })();
1218
+ return {
1219
+ yParity,
1220
+ r: ensureHexPrefix(signature.r),
1221
+ s: ensureHexPrefix(signature.s)
1222
+ };
1223
+ };
1224
+
1225
+ // src/helpers/string.ts
1226
+ var capitalize = (str) => {
1227
+ if (!str) return str;
1228
+ return str.charAt(0).toUpperCase() + str.slice(1);
1229
+ };
1230
+ var toTitleCase = (str) => {
1231
+ if (!str) return str;
1232
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
1233
+ };
1234
+
1235
+ // src/helpers/types.ts
1236
+ var isError = (value) => value instanceof Error;
1237
+ var isFunction = (value) => typeof value === "function";
1238
+ var isObject = (value) => typeof value === "object" && value !== null;
1239
+ var isNumber = (value) => typeof value === "number";
1240
+ var isString = (value) => typeof value === "string";
1241
+ var isUndefined = (value) => typeof value === "undefined";
1242
+ var isBoolean = (value) => typeof value === "boolean";
1243
+ var extractString = (value, fallback) => {
1244
+ return isString(value) ? value : fallback;
1245
+ };
1246
+ var extractNumber = (value) => {
1247
+ if (isNumber(value)) {
1248
+ return value;
1249
+ }
1250
+ if (isString(value)) {
1251
+ const parsed = Number.parseFloat(value);
1252
+ return Number.isNaN(parsed) ? void 0 : parsed;
1253
+ }
1254
+ return void 0;
1255
+ };
1256
+
1257
+ // src/helpers/url.ts
1258
+ function buildQueryString(params) {
1259
+ const usp = new URLSearchParams();
1260
+ Object.entries(params).forEach(([key, value]) => {
1261
+ if (value === void 0 || value === null) return;
1262
+ usp.set(key, String(value));
1263
+ });
1264
+ const qs = usp.toString();
1265
+ return qs ? `?${qs}` : "";
1266
+ }
1267
+ function buildUrl(path, params) {
1268
+ const qs = params ? buildQueryString(params) : "";
1269
+ return `${path}${qs}`;
1270
+ }
1271
+
1272
+ // src/helpers/zod.ts
1273
+ var import_zod6 = require("zod");
1274
+ var composeValidators = (validators) => {
1275
+ return (data, ctx) => {
1276
+ for (const validator of validators) {
1277
+ validator(data, ctx);
1278
+ }
1279
+ };
1280
+ };
1281
+ var secondsToHumanReadable = (seconds) => {
1282
+ if (seconds >= 3600) {
1283
+ const hours = seconds / 3600;
1284
+ const roundedHours = Math.round(hours * 10) / 10;
1285
+ return roundedHours === 1 ? "1 hour" : `${roundedHours} hours`;
1286
+ } else if (seconds >= 60) {
1287
+ const minutes = seconds / 60;
1288
+ const roundedMinutes = Math.round(minutes * 10) / 10;
1289
+ return roundedMinutes === 1 ? "1 minute" : `${roundedMinutes} minutes`;
1290
+ } else {
1291
+ return seconds === 1 ? "1 second" : `${seconds} seconds`;
1292
+ }
1293
+ };
1294
+ var createTimeUnitValidator = (fieldName, options = {}) => {
1295
+ const {
1296
+ minSeconds = 60,
1297
+ allowZero = false,
1298
+ useHumanReadable = true
1299
+ } = options;
1300
+ return import_zod6.z.string().optional().refine(
1301
+ (value) => {
1302
+ if (!value) return true;
1303
+ const parsed = parseTimeUnitValue(value);
1304
+ if (!parsed) return false;
1305
+ const seconds = getSecondsFromTimeUnitValue(parsed);
1306
+ return allowZero ? seconds >= 0 : seconds >= minSeconds;
1307
+ },
1308
+ {
1309
+ message: useHumanReadable ? `${fieldName} must be at least ${secondsToHumanReadable(minSeconds)}` : `${fieldName} must be at least ${minSeconds} seconds`
1310
+ }
1311
+ );
1312
+ };
1313
+ var parseSchema = (values, schema) => {
1314
+ const inputValues = schema.safeParse(values);
1315
+ if (!inputValues.success) {
1316
+ throw new Error(
1317
+ `parseSchema: invalid input values ${JSON.stringify(inputValues.error)}`
1318
+ );
1319
+ }
1320
+ return inputValues.data;
1321
+ };
1322
+ //# sourceMappingURL=index.js.map