@dcl/shop 0.1.0-29571500722.commit-8ea45d8 → 0.1.0-29588264451.commit-627b4b7

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 (225) hide show
  1. package/assets/{AnimatedBackground-Y-secaKv.js → AnimatedBackground-psFU9eqJ.js} +3 -3
  2. package/assets/Assets-iKVqmFqq.js +1 -0
  3. package/assets/Cart-B0oxrKWW.js +1 -0
  4. package/assets/Cart-C612IvK3.css +1 -0
  5. package/assets/{CircularProgress-DF1tx4Pz.js → CircularProgress-Fg-Nhc1W.js} +2 -2
  6. package/assets/Collection-D5Q48x8i.js +1 -0
  7. package/assets/{ConstantsUtil-BTo1-KgH.js → ConstantsUtil-CCJ0yRd8.js} +1 -1
  8. package/assets/{ContentClient-DahG0FsN.js → ContentClient-CiSvC4he.js} +1 -1
  9. package/assets/Creator-Cw25k_kz.js +1 -0
  10. package/assets/CssVarsProvider-D1D1cNqm.js +24 -0
  11. package/assets/{DeploymentBuilder-DCLyMp7S.js → DeploymentBuilder-Du1wr7ad.js} +1 -1
  12. package/assets/{ExchangeController-5UZnaMYm.js → ExchangeController-DR6BBi2L.js} +1 -1
  13. package/assets/GetCredits-HKG4BM_P.js +1 -0
  14. package/assets/{HelpersUtil-DsOycveq.js → HelpersUtil-31KPVf4r.js} +1 -1
  15. package/assets/{ImportListings-Ry47KtP_.js → ImportListings-dKZfPQUt.js} +1 -1
  16. package/assets/ItemDetail-BMi8a81V.css +1 -0
  17. package/assets/ItemDetail-Cx-6T0Eg.js +2 -0
  18. package/assets/{LoadMore-DsKzH4Rv.js → LoadMore-CiZkVzux.js} +1 -1
  19. package/assets/MarketCheckout-Qn1ixrkb.js +1 -0
  20. package/assets/MyAssets-DxI94ipn.js +1 -0
  21. package/assets/{MyFavorites-BfWQjhlL.js → MyFavorites-D2VaWS1B.js} +1 -1
  22. package/assets/{MyPurchases-DbU97xcR.js → MyPurchases-B9emkBFN.js} +1 -1
  23. package/assets/{NetworkUtil-DInevqnn.js → NetworkUtil-Yv-DdqEo.js} +1 -1
  24. package/assets/{NotFound-CWys1EXA.js → NotFound-E0wDMFCK.js} +1 -1
  25. package/assets/{StoreSettings-C-yDm4Ah.js → StoreSettings-DfKsXLjF.js} +1 -1
  26. package/assets/Success-D8vbmLlB.js +1 -0
  27. package/assets/{SwapController-Bau8y3ss.js → SwapController-BhWJpnsS.js} +1 -1
  28. package/assets/{TradeService-sWmitO7N.js → TradeService-CzTJfCBU.js} +1 -1
  29. package/assets/{W3MFrameProviderSingleton-BrDTQqcr.js → W3MFrameProviderSingleton-QTe845Ty.js} +3 -3
  30. package/assets/{WebCryptoP256-Clorun9S.js → WebCryptoP256-C9DwfYdN.js} +1 -1
  31. package/assets/{basic-Co2ks3tP.js → basic-BZccaaZw.js} +1 -1
  32. package/assets/{biconomy-DAm_-Hm_.js → biconomy-DB7oVSPZ.js} +1 -1
  33. package/assets/{browser-9oFjBwrz.js → browser-L8b8z1bK.js} +1 -1
  34. package/assets/browser-ponyfill-Cl4XgbUp.js +1 -0
  35. package/assets/{browser-ponyfill-DMgE6PM5.js → browser-ponyfill-jziBOMa-.js} +1 -1
  36. package/assets/{buy-y9zg-9gr.js → buy-D_7yggiZ.js} +1 -1
  37. package/assets/{buy-gasless-B4g8GiJr.js → buy-gasless-DdXBIm99.js} +1 -1
  38. package/assets/cart-checkout-C6slCzLp.js +1 -0
  39. package/assets/categories-CBvVTfQE.css +1 -0
  40. package/assets/categories-CS5KEV15.js +1 -0
  41. package/assets/{ccip-i7tJF0Hj.js → ccip-Bs_9Z_ZN.js} +1 -1
  42. package/assets/{ccip-B8JdVFq5.js → ccip-CRir71Ts.js} +1 -1
  43. package/assets/{chains-BQ5Swd2q.js → chains-sL9nr1ux.js} +1 -1
  44. package/assets/collection-BB4WIsDf.js +1 -0
  45. package/assets/colors-LINLm1ux.js +1 -0
  46. package/assets/{common-CBPtpBt7.js → common-Dyx8k-hp.js} +1 -1
  47. package/assets/{controller-BVAEs_Ol.js → controller-8YCt_5kO.js} +2 -2
  48. package/assets/{core-DXAXZQxt.js → core-_p71vehW.js} +4 -4
  49. package/assets/{custom-C00ZS-dv.js → custom-D5gy9Lbk.js} +1 -1
  50. package/assets/{data-capture-BfGns_F9.js → data-capture-D4KpcM2w.js} +1 -1
  51. package/assets/decimals-Bkiwsrz3.js +1 -0
  52. package/assets/{decimals-7LZbjdh-.js → decimals-DAdpv8M5.js} +1 -1
  53. package/assets/{detectExtension-C_qqqhXd.js → detectExtension-BwC-gZ7s.js} +1 -1
  54. package/assets/{email-10XDB7Ed.js → email-DoKqUCg3.js} +1 -1
  55. package/assets/{embedded-wallet-Coq3FP2j.js → embedded-wallet-DFjP-9W6.js} +1 -1
  56. package/assets/{emotion-styled.browser.esm-Col8rSBp.js → emotion-styled.browser.esm-B7PezGnO.js} +1 -1
  57. package/assets/{engine-DNO34GZS.js → engine-C07V9FFP.js} +1 -1
  58. package/assets/{estimate-l1-fee-ttG5TVsi.js → estimate-l1-fee-CbSYXxVq.js} +1 -1
  59. package/assets/eth_estimateGas-CHt9spnf.js +1 -0
  60. package/assets/{eth_getStorageAt-ZjeD4sfh.js → eth_getStorageAt-Dzigs9Zu.js} +1 -1
  61. package/assets/eth_getTransactionCount-CDY9h_Rg.js +1 -0
  62. package/assets/{ethereum-CD3dxaW_.js → ethereum-gQdvRN4F.js} +1 -1
  63. package/assets/{ethers-DwWf2RqE.js → ethers-DArfy-QF.js} +1 -1
  64. package/assets/{extractIPFS-CFw95IDm.js → extractIPFS-BOTNSryE.js} +1 -1
  65. package/assets/{features-BBwkLwo8.js → features-C90RUzSP.js} +1 -1
  66. package/assets/{fetchTokenMetadata-BbJeox1b.js → fetchTokenMetadata-BKZfKsNV.js} +2 -2
  67. package/assets/{fortmatic-DhmlcDbL.js → fortmatic-BAdaY-Dp.js} +1 -1
  68. package/assets/get-ecosystem-wallet-info-WLLUCIzd.js +1 -0
  69. package/assets/{getBalance-BVXxyvdU.js → getBalance-Bb_-F40S.js} +2 -2
  70. package/assets/{getInstalledModules-92CJz4J0.js → getInstalledModules-BOPp6l-B.js} +1 -1
  71. package/assets/{getNFT-By7tEt1z.js → getNFT-DsdBNES9.js} +1 -1
  72. package/assets/{getNFT-6Z-JCPcj.js → getNFT-jiRKQ5Oo.js} +2 -2
  73. package/assets/getOverlayAlpha-CM9JvcJV.js +1 -0
  74. package/assets/{hashTypedData-UUOD4hvk.js → hashTypedData-DONiI8QZ.js} +1 -1
  75. package/assets/{hashTypedData-78L5umOY.js → hashTypedData-vGDzeBcA.js} +1 -1
  76. package/assets/{import-BCIlZ3yx.js → import-DM-iC_9y.js} +1 -1
  77. package/assets/{in-app-wallet-calls-Dx8qnM7-.js → in-app-wallet-calls-C_aNlFmv.js} +1 -1
  78. package/assets/{index-BlFZSvWx.js → index--gVKrRw0.js} +1 -1
  79. package/assets/{index-DFGIa8d3.js → index-57pYnjcK.js} +1 -1
  80. package/assets/{index-Dfn1y1uF.js → index-7DJmnNdg.js} +1 -1
  81. package/assets/{index-BVRx9Ot1.js → index-7PEMu-vS.js} +1 -1
  82. package/assets/{index-CIx1sZmW.js → index-8TBzmL0l.js} +1 -1
  83. package/assets/{index-DNT62M3w.js → index-B2Zw4G7Z.js} +1 -1
  84. package/assets/index-BAYW-Y7J.css +1 -0
  85. package/assets/{index-BsVbqXUp.js → index-BEob012O.js} +3 -3
  86. package/assets/{index-BAoHOXze.js → index-BIJTdhnz.js} +2 -2
  87. package/assets/{index-B7PXWLXB.js → index-BNKsMdm-.js} +1 -1
  88. package/assets/{index-DLXELZQv.js → index-BNsBOmtc.js} +1 -1
  89. package/assets/{index-DKP6gkl4.js → index-BQrBXxNO.js} +1 -1
  90. package/assets/{index-DjVz63Zr.js → index-BUzSFM10.js} +1 -1
  91. package/assets/{index-D-BMnyQb.js → index-BVEDAipP.js} +1 -1
  92. package/assets/{index-C4JAp-Oa.js → index-BVpuOhLG.js} +3 -3
  93. package/assets/{index-CApcD-t8.js → index-Bj7GkEZm.js} +1 -1
  94. package/assets/{index-DN8pYCNl.js → index-Bn_Nt76C.js} +1 -1
  95. package/assets/{index-BYRbnzmu.js → index-BpQeHVbA.js} +1 -1
  96. package/assets/{index-C1wVfhuw.js → index-BtVa_Kh7.js} +1 -1
  97. package/assets/{index-Ds-AFLHc.js → index-Bv4pyelF.js} +1 -1
  98. package/assets/{index-C3xlbPh_.js → index-C02-3pKD.js} +2 -2
  99. package/assets/{index-KYyY5J5u.js → index-C2G2lljO.js} +1 -1
  100. package/assets/{index-DsVVBfxP.js → index-C5j8nmW-.js} +1 -1
  101. package/assets/{index-CjpJ162L.js → index-C6Uar8kN.js} +1 -1
  102. package/assets/{index-ZvQFinLo.js → index-C7gttTv8.js} +1 -1
  103. package/assets/{index-CAMCLJ-3.js → index-C8i-4YQe.js} +1 -1
  104. package/assets/index-CBVNSjCQ.js +74 -0
  105. package/assets/{index-DUc6Q2Iz.js → index-CE5ZSWni.js} +1 -1
  106. package/assets/{index-By6STTNb.js → index-CFasXWsQ.js} +1 -1
  107. package/assets/{index-DcmcHRml.js → index-CFy8QjLL.js} +1 -1
  108. package/assets/index-CIiavQLK.js +1 -0
  109. package/assets/{index-Bvx0NOxN.js → index-CRTJ7_WQ.js} +1 -1
  110. package/assets/{index-D8XPW5rW.js → index-CSm8067w.js} +1 -1
  111. package/assets/{index-C_x2eFau.js → index-CThtDCr0.js} +3 -3
  112. package/assets/{index-DhQcB2cI.js → index-C__ZUWCs.js} +1 -1
  113. package/assets/index-ChMOJahJ.js +2 -0
  114. package/assets/{index-94XD4C5w.js → index-Ckj9N8kM.js} +1 -1
  115. package/assets/{index-CBWS4Ml_.js → index-Cmhu1R9V.js} +1 -1
  116. package/assets/{index-DHM1o-4K.js → index-CnWEn3Fl.js} +1 -1
  117. package/assets/{index-lt7oq_YM.js → index-CsTr0LfC.js} +1 -1
  118. package/assets/{index-Bsx6GubH.js → index-Cv14wakP.js} +1 -1
  119. package/assets/{index-CeR8VFbd.js → index-D3SxIXox.js} +1 -1
  120. package/assets/{index-CJD-gYKv.js → index-D66LUjvb.js} +1 -1
  121. package/assets/{index-CPYtbWCQ.js → index-D8WLCETG.js} +1 -1
  122. package/assets/{index-6jN-_TNa.js → index-D8WMIH5c.js} +1 -1
  123. package/assets/index-DD6TVIkI.js +1 -0
  124. package/assets/{index-CC32N6uw.js → index-DHJgxESc.js} +1 -1
  125. package/assets/{index-CGbJjZCV.js → index-DO9rihjD.js} +1 -1
  126. package/assets/{index-DIYL1_Ov.js → index-DSs6L904.js} +1 -1
  127. package/assets/{index-DhedohT0.js → index-DaIODAHU.js} +1 -1
  128. package/assets/index-DgPN63Jh.js +103 -0
  129. package/assets/{index-D7Fx-Qac.js → index-Dgwg-DaP.js} +1 -1
  130. package/assets/{index-BBZ21lbu.js → index-DmQaEVTR.js} +1 -1
  131. package/assets/index-DxBzK74p.js +1 -0
  132. package/assets/{index-Ct0w7Ogt.js → index-DzmAUU0P.js} +1 -1
  133. package/assets/{index-DkjQWYoB.js → index-MqZwF8o9.js} +2 -2
  134. package/assets/{index-P4QO1O0D.js → index-QHZTwn8s.js} +1 -1
  135. package/assets/{index-BlNwDD1i.js → index-SOuBSYKv.js} +1 -1
  136. package/assets/{index-DaDHmqAS.js → index-TNdqfy5A.js} +2 -2
  137. package/assets/{index-BsFR4koq.js → index-fGWdBWqW.js} +1 -1
  138. package/assets/{index-DPyb1X7J.js → index-gEVnIhEr.js} +1 -1
  139. package/assets/{index-DNGhO1UM.js → index-gt71uI0K.js} +1 -1
  140. package/assets/{index-Dp3Py-Ws.js → index-sFssfP96.js} +1 -1
  141. package/assets/{index-B0PF-s9M.js → index-xHNUVGAh.js} +1 -1
  142. package/assets/{index-ClxTTupQ.js → index-zHd02W0T.js} +1 -1
  143. package/assets/{index.es-CNLSXMT-.js → index.es-B5B8Zcyr.js} +1 -1
  144. package/assets/{index.es-DGT1W3bC.js → index.es-C122sfII.js} +1 -1
  145. package/assets/{index.es-EcAKXlCW.js → index.es-D2JDwbaX.js} +4 -4
  146. package/assets/{localBatchGatewayRequest-CUupTU5s.js → localBatchGatewayRequest-aLhcfaIA.js} +1 -1
  147. package/assets/{mana-rate-TrkgOUFu.js → mana-rate-DM_I1GlP.js} +1 -1
  148. package/assets/{native-B49T_qnV.js → native-DBJATukw.js} +1 -1
  149. package/assets/network-Dev_1fOd.js +1 -0
  150. package/assets/{networks-BEAzlz87.js → networks-C5Fm0Wg2.js} +1 -1
  151. package/assets/{onramp-BHjPyFrf.js → onramp-DkCes_uB.js} +1 -1
  152. package/assets/{openzeppelin-BqEz23oI.js → openzeppelin-Do5qc-L4.js} +1 -1
  153. package/assets/{ownerOf-D2Ruvcgr.js → ownerOf-B7-bZ1Kj.js} +1 -1
  154. package/assets/{parseNft-C4rXbAm3.js → parseNft-BnBeb8zU.js} +2 -2
  155. package/assets/{parseSignature-1_3SuD3y.js → parseSignature-BXiUrtE0.js} +3 -3
  156. package/assets/{parseSignature-B6_wXS1t.js → parseSignature-gA3whR_I.js} +1 -1
  157. package/assets/{pay-with-exchange-AvS-iWv3.js → pay-with-exchange-Bfj0m_wp.js} +1 -1
  158. package/assets/payments-Cz9uOQEa.js +1 -0
  159. package/assets/{qr-overlay-Di1sYsV2.js → qr-overlay-tCTGCDoP.js} +3 -3
  160. package/assets/{react-C51i12iP.js → react-yytiy0wi.js} +1 -1
  161. package/assets/{receive-CGzdSteR.js → receive-BB-3p_8X.js} +1 -1
  162. package/assets/{resolveImplementation-CaXsKbDx.js → resolveImplementation-AZ8V1faE.js} +1 -1
  163. package/assets/resume-buy-Bf0zIH7y.js +1 -0
  164. package/assets/{rpc-DG-6qjB5.js → rpc-DfJIwLRx.js} +1 -1
  165. package/assets/{secp256k1-ChfveZcd.js → secp256k1-Bmuoeuaz.js} +1 -1
  166. package/assets/{secp256k1-DWucSlB-.js → secp256k1-D5GxePTM.js} +1 -1
  167. package/assets/{secp256k1-B9CXpvLY.js → secp256k1-lxVndZFi.js} +1 -1
  168. package/assets/{send-D5cFILBF.js → send-DmW5J-Nc.js} +1 -1
  169. package/assets/{send-batch-transaction-B3lTEUOF.js → send-batch-transaction-CZjLQhJF.js} +1 -1
  170. package/assets/{send-eip712-transaction-ByX_--Vb.js → send-eip712-transaction-BhyQ0a_B.js} +2 -2
  171. package/assets/{send-gasless-transaction-sFztvg-i.js → send-gasless-transaction-CXbVlKhB.js} +2 -2
  172. package/assets/{sendRawTransaction-CR5Mmi6b.js → sendRawTransaction-BGdiWFeb.js} +3 -3
  173. package/assets/{serializeTransaction-D79jfd3_.js → serializeTransaction-DykKczc7.js} +1 -1
  174. package/assets/{session-proposal-Cwo9ltsm.js → session-proposal-BEX_HaKf.js} +1 -1
  175. package/assets/{session-request-l_FrHUZo.js → session-request-DR4MsaR6.js} +2 -2
  176. package/assets/{sha256-B1PPmRn9.js → sha256-Dlxe-c_a.js} +1 -1
  177. package/assets/{signing-Sn5rFCHS.js → signing-DznnvpB3.js} +5 -5
  178. package/assets/{socials-CqUkp7RR.js → socials-BIESIfY8.js} +1 -1
  179. package/assets/{swaps-hvkTELkc.js → swaps-CA_8qfYn.js} +1 -1
  180. package/assets/{thirdweb-Bfq5h25u.js → thirdweb-UauMP3KV.js} +3 -3
  181. package/assets/{totalSupply-yip6OCLy.js → totalSupply-V0CpLejD.js} +1 -1
  182. package/assets/{trade-encoding-42N07h92.js → trade-encoding-CWQaROcB.js} +1 -1
  183. package/assets/{transactionReceipt-DADNrKU6.js → transactionReceipt-T_4Pqj5L.js} +1 -1
  184. package/assets/{transactions-DQBiQzWz.js → transactions-CCKmzO8P.js} +1 -1
  185. package/assets/{useInfiniteGrid-CjcJxtXA.js → useInfiniteGrid-BwrFUhaa.js} +1 -1
  186. package/assets/useStore-D9l09yvh.js +2 -0
  187. package/assets/useTheme-B2pFHCn2.js +1 -0
  188. package/assets/useTheme-Bf8Lxsxi.js +1 -0
  189. package/assets/{utils-rl7KiNyp.js → utils-BDQ8DS2k.js} +1 -1
  190. package/assets/{verifyHash-CNDR4v8f.js → verifyHash-DictgvCd.js} +1 -1
  191. package/assets/{w3m-modal-Clo6bKVE.js → w3m-modal-DEg0nzZj.js} +1 -1
  192. package/assets/{w3m-modal-GMd0MTV7.js → w3m-modal-DjfQ6wwU.js} +1 -1
  193. package/assets/{wait-for-tx-receipt-uU57b-HM.js → wait-for-tx-receipt-agyY9QD2.js} +1 -1
  194. package/assets/{wallet-kind-PnN45EW0.js → wallet-kind-Jzl4cyiP.js} +1 -1
  195. package/assets/{wallets-CgInyYuE.js → wallets-_A4Bjek9.js} +6 -6
  196. package/assets/{web-connector-DitPEy2c.js → web-connector-BaXQsZJI.js} +3 -3
  197. package/assets/{writeContract-CzZHvjcP.js → writeContract-D9YLPdhX.js} +1 -1
  198. package/assets/{zora-sepolia-Cmu9LYjr.js → zora-sepolia-B35hC1NB.js} +1 -1
  199. package/assets/{zoraTestnet-l_-faq0L.js → zoraTestnet-BC6E1i5C.js} +1 -1
  200. package/index.html +8 -8
  201. package/package.json +2 -2
  202. package/assets/Assets-sWyggSzY.js +0 -1
  203. package/assets/Cart-DVt0m7-J.js +0 -1
  204. package/assets/Collection-D-dr6oYY.js +0 -1
  205. package/assets/Creator-DpZ1qFEV.js +0 -1
  206. package/assets/GetCredits-B-2Nu_Cx.js +0 -1
  207. package/assets/ItemDetail--AzXh8S2.css +0 -1
  208. package/assets/ItemDetail-CblzRtB5.js +0 -2
  209. package/assets/MyAssets-26oYZL-x.js +0 -1
  210. package/assets/Success-CW65bxXN.js +0 -1
  211. package/assets/browser-ponyfill-Djb5Py6a.js +0 -1
  212. package/assets/categories-DbX2Gw4H.js +0 -1
  213. package/assets/categories-FoGfjyVm.css +0 -1
  214. package/assets/collection-CS59m6GL.js +0 -1
  215. package/assets/decimals-CeoXdXWM.js +0 -1
  216. package/assets/eth_estimateGas-BiFrKNU-.js +0 -1
  217. package/assets/eth_getTransactionCount-BjHbR3QT.js +0 -1
  218. package/assets/get-ecosystem-wallet-info-BotVMG7h.js +0 -1
  219. package/assets/index-B4tMFfvy.js +0 -74
  220. package/assets/index-BcX-FSIU.css +0 -1
  221. package/assets/index-C1u3RQ96.js +0 -103
  222. package/assets/index-DH3Yzbz3.js +0 -1
  223. package/assets/index-QnApYtWL.js +0 -1
  224. package/assets/network-44dqSlR2.js +0 -1
  225. package/assets/useStore-zhFVY9fU.js +0 -2
@@ -1 +1 @@
1
- import{C as l,E as w,b as E,S as A,d as k,O as U,N as P,g as f,B as x,e as N,i as I,p as L}from"./W3MFrameProviderSingleton-BrDTQqcr.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-C4JAp-Oa.js";const D=0,C={paymentAsset:null,amount:null,tokenAmount:0,priceLoading:!1,error:null,exchanges:[],isLoading:!1,currentPayment:void 0,isPaymentInProgress:!1,paymentId:"",assets:[]},e=L(C),m={state:e,subscribe(t){return I(e,()=>t(e))},subscribeKey(t,n){return N(e,t,n)},resetState(){Object.assign(e,{...C})},async getAssetsForNetwork(t){const n=v(t),s=await m.getAssetsImageAndPrice(n),r=n.map(a=>{var c,o,p,y;const u=a.asset==="native"?f():`${a.network}:${a.asset}`,i=s.find(S=>{var g,d,h;return((h=(d=(g=S.fungibles)==null?void 0:g[0])==null?void 0:d.address)==null?void 0:h.toLowerCase())===u.toLowerCase()});return{...a,price:((o=(c=i==null?void 0:i.fungibles)==null?void 0:c[0])==null?void 0:o.price)||1,metadata:{...a.metadata,iconUrl:(y=(p=i==null?void 0:i.fungibles)==null?void 0:p[0])==null?void 0:y.iconUrl}}});return e.assets=r,r},async getAssetsImageAndPrice(t){const n=t.map(r=>r.asset==="native"?f():`${r.network}:${r.asset}`);return await Promise.all(n.map(r=>x.fetchTokenPrice({addresses:[r]})))},getTokenAmount(){var s;if(!((s=e==null?void 0:e.paymentAsset)!=null&&s.price))throw new Error("Cannot get token price");const t=P.bigNumber(e.amount??0).round(8),n=P.bigNumber(e.paymentAsset.price).round(8);return t.div(n).round(8).toNumber()},setAmount(t){var n;e.amount=t,(n=e.paymentAsset)!=null&&n.price&&(e.tokenAmount=m.getTokenAmount())},setPaymentAsset(t){e.paymentAsset=t},isPayWithExchangeEnabled(){var t;return(t=U.state.remoteFeatures)==null?void 0:t.payWithExchange},isPayWithExchangeSupported(){return m.isPayWithExchangeEnabled()&&l.state.activeCaipNetwork&&k.PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES.includes(l.state.activeCaipNetwork.chainNamespace)},async fetchExchanges(){var t;try{const n=m.isPayWithExchangeSupported();if(!e.paymentAsset||!n){e.exchanges=[],e.isLoading=!1;return}e.isLoading=!0;const s=await _({page:D,asset:b(e.paymentAsset.network,e.paymentAsset.asset),amount:((t=e.amount)==null?void 0:t.toString())??"0"});e.exchanges=s.exchanges.slice(0,2)}catch{throw A.showError("Unable to get exchanges"),new Error("Unable to get exchanges")}finally{e.isLoading=!1}},async getPayUrl(t,n){try{const s=Number(n.amount),r=await W({exchangeId:t,asset:b(n.network,n.asset),amount:s.toString(),recipient:`${n.network}:${n.recipient}`});return w.sendEvent({type:"track",event:"PAY_EXCHANGE_SELECTED",properties:{exchange:{id:t},configuration:{network:n.network,asset:n.asset,recipient:n.recipient,amount:s},currentPayment:{type:"exchange",exchangeId:t},source:"fund-from-exchange",headless:!1}}),r}catch(s){throw s instanceof Error&&s.message.includes("is not supported")?new Error("Asset not supported"):new Error(s.message)}},async handlePayWithExchange(t){var n;try{const s=(n=l.getAccountData())==null?void 0:n.address;if(!s)throw new Error("No account connected");if(!e.paymentAsset)throw new Error("No payment asset selected");const r=E.returnOpenHref("","popupWindow","scrollbar=yes,width=480,height=720");if(!r)throw new Error("Could not create popup window");e.isPaymentInProgress=!0,e.paymentId=crypto.randomUUID(),e.currentPayment={type:"exchange",exchangeId:t};const{network:a,asset:u}=e.paymentAsset,i={network:a,asset:u,amount:e.tokenAmount,recipient:s},c=await m.getPayUrl(t,i);if(!c){try{r.close()}catch(o){console.error("Unable to close popup window",o)}throw new Error("Unable to initiate payment")}e.currentPayment.sessionId=c.sessionId,e.currentPayment.status="IN_PROGRESS",e.currentPayment.exchangeId=t,r.location.href=c.url}catch{e.error="Unable to initiate payment",A.showError(e.error)}},async waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r=20}){const a=await m.getBuyStatus(t,n,s);if(a.status==="SUCCESS"||a.status==="FAILED")return a;if(r===0)throw new Error("Unable to get deposit status");return await new Promise(u=>{setTimeout(u,5e3)}),m.waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r-1})},async getBuyStatus(t,n,s){var r,a,u,i,c;try{if(!e.currentPayment)throw new Error("No current payment");const o=await T({sessionId:n,exchangeId:t});if(e.currentPayment.status=o.status,o.status==="SUCCESS"||o.status==="FAILED"){const p=(r=l.getAccountData())==null?void 0:r.address;e.currentPayment.result=o.txHash,e.isPaymentInProgress=!1,w.sendEvent({type:"track",event:o.status==="SUCCESS"?"PAY_SUCCESS":"PAY_ERROR",properties:{message:o.status==="FAILED"?E.parseError(e.error):void 0,source:"fund-from-exchange",paymentId:s,configuration:{network:((a=e.paymentAsset)==null?void 0:a.network)||"",asset:((u=e.paymentAsset)==null?void 0:u.asset)||"",recipient:p||"",amount:e.amount??0},currentPayment:{type:"exchange",exchangeId:(i=e.currentPayment)==null?void 0:i.exchangeId,sessionId:(c=e.currentPayment)==null?void 0:c.sessionId,result:o.txHash}}})}return o}catch{return{status:"UNKNOWN",txHash:""}}},reset(){e.currentPayment=void 0,e.isPaymentInProgress=!1,e.paymentId="",e.paymentAsset=null,e.amount=0,e.tokenAmount=0,e.priceLoading=!1,e.error=null,e.exchanges=[],e.isLoading=!1}};export{m as E};
1
+ import{C as l,E as w,b as E,S as A,d as k,O as U,N as P,g as f,B as x,e as N,i as I,p as L}from"./W3MFrameProviderSingleton-QTe845Ty.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-BVpuOhLG.js";const D=0,C={paymentAsset:null,amount:null,tokenAmount:0,priceLoading:!1,error:null,exchanges:[],isLoading:!1,currentPayment:void 0,isPaymentInProgress:!1,paymentId:"",assets:[]},e=L(C),m={state:e,subscribe(t){return I(e,()=>t(e))},subscribeKey(t,n){return N(e,t,n)},resetState(){Object.assign(e,{...C})},async getAssetsForNetwork(t){const n=v(t),s=await m.getAssetsImageAndPrice(n),r=n.map(a=>{var c,o,p,y;const u=a.asset==="native"?f():`${a.network}:${a.asset}`,i=s.find(S=>{var g,d,h;return((h=(d=(g=S.fungibles)==null?void 0:g[0])==null?void 0:d.address)==null?void 0:h.toLowerCase())===u.toLowerCase()});return{...a,price:((o=(c=i==null?void 0:i.fungibles)==null?void 0:c[0])==null?void 0:o.price)||1,metadata:{...a.metadata,iconUrl:(y=(p=i==null?void 0:i.fungibles)==null?void 0:p[0])==null?void 0:y.iconUrl}}});return e.assets=r,r},async getAssetsImageAndPrice(t){const n=t.map(r=>r.asset==="native"?f():`${r.network}:${r.asset}`);return await Promise.all(n.map(r=>x.fetchTokenPrice({addresses:[r]})))},getTokenAmount(){var s;if(!((s=e==null?void 0:e.paymentAsset)!=null&&s.price))throw new Error("Cannot get token price");const t=P.bigNumber(e.amount??0).round(8),n=P.bigNumber(e.paymentAsset.price).round(8);return t.div(n).round(8).toNumber()},setAmount(t){var n;e.amount=t,(n=e.paymentAsset)!=null&&n.price&&(e.tokenAmount=m.getTokenAmount())},setPaymentAsset(t){e.paymentAsset=t},isPayWithExchangeEnabled(){var t;return(t=U.state.remoteFeatures)==null?void 0:t.payWithExchange},isPayWithExchangeSupported(){return m.isPayWithExchangeEnabled()&&l.state.activeCaipNetwork&&k.PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES.includes(l.state.activeCaipNetwork.chainNamespace)},async fetchExchanges(){var t;try{const n=m.isPayWithExchangeSupported();if(!e.paymentAsset||!n){e.exchanges=[],e.isLoading=!1;return}e.isLoading=!0;const s=await _({page:D,asset:b(e.paymentAsset.network,e.paymentAsset.asset),amount:((t=e.amount)==null?void 0:t.toString())??"0"});e.exchanges=s.exchanges.slice(0,2)}catch{throw A.showError("Unable to get exchanges"),new Error("Unable to get exchanges")}finally{e.isLoading=!1}},async getPayUrl(t,n){try{const s=Number(n.amount),r=await W({exchangeId:t,asset:b(n.network,n.asset),amount:s.toString(),recipient:`${n.network}:${n.recipient}`});return w.sendEvent({type:"track",event:"PAY_EXCHANGE_SELECTED",properties:{exchange:{id:t},configuration:{network:n.network,asset:n.asset,recipient:n.recipient,amount:s},currentPayment:{type:"exchange",exchangeId:t},source:"fund-from-exchange",headless:!1}}),r}catch(s){throw s instanceof Error&&s.message.includes("is not supported")?new Error("Asset not supported"):new Error(s.message)}},async handlePayWithExchange(t){var n;try{const s=(n=l.getAccountData())==null?void 0:n.address;if(!s)throw new Error("No account connected");if(!e.paymentAsset)throw new Error("No payment asset selected");const r=E.returnOpenHref("","popupWindow","scrollbar=yes,width=480,height=720");if(!r)throw new Error("Could not create popup window");e.isPaymentInProgress=!0,e.paymentId=crypto.randomUUID(),e.currentPayment={type:"exchange",exchangeId:t};const{network:a,asset:u}=e.paymentAsset,i={network:a,asset:u,amount:e.tokenAmount,recipient:s},c=await m.getPayUrl(t,i);if(!c){try{r.close()}catch(o){console.error("Unable to close popup window",o)}throw new Error("Unable to initiate payment")}e.currentPayment.sessionId=c.sessionId,e.currentPayment.status="IN_PROGRESS",e.currentPayment.exchangeId=t,r.location.href=c.url}catch{e.error="Unable to initiate payment",A.showError(e.error)}},async waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r=20}){const a=await m.getBuyStatus(t,n,s);if(a.status==="SUCCESS"||a.status==="FAILED")return a;if(r===0)throw new Error("Unable to get deposit status");return await new Promise(u=>{setTimeout(u,5e3)}),m.waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r-1})},async getBuyStatus(t,n,s){var r,a,u,i,c;try{if(!e.currentPayment)throw new Error("No current payment");const o=await T({sessionId:n,exchangeId:t});if(e.currentPayment.status=o.status,o.status==="SUCCESS"||o.status==="FAILED"){const p=(r=l.getAccountData())==null?void 0:r.address;e.currentPayment.result=o.txHash,e.isPaymentInProgress=!1,w.sendEvent({type:"track",event:o.status==="SUCCESS"?"PAY_SUCCESS":"PAY_ERROR",properties:{message:o.status==="FAILED"?E.parseError(e.error):void 0,source:"fund-from-exchange",paymentId:s,configuration:{network:((a=e.paymentAsset)==null?void 0:a.network)||"",asset:((u=e.paymentAsset)==null?void 0:u.asset)||"",recipient:p||"",amount:e.amount??0},currentPayment:{type:"exchange",exchangeId:(i=e.currentPayment)==null?void 0:i.exchangeId,sessionId:(c=e.currentPayment)==null?void 0:c.sessionId,result:o.txHash}}})}return o}catch{return{status:"UNKNOWN",txHash:""}}},reset(){e.currentPayment=void 0,e.isPaymentInProgress=!1,e.paymentId="",e.paymentAsset=null,e.amount=0,e.tokenAmount=0,e.priceLoading=!1,e.error=null,e.exchanges=[],e.isLoading=!1}};export{m as E};
@@ -0,0 +1 @@
1
+ import{a as K,u as q,r as n,j as e}from"./react-yytiy0wi.js";import{b as Q,u as z,t as p,j as i,k as $,l as G,C as k,m as F}from"./index-DgPN63Jh.js";import{R as Y}from"./resume-buy-Bf0zIH7y.js";import{R as J}from"./cart-checkout-C6slCzLp.js";import{p as L,c as O,i as H,C as W}from"./payments-Cz9uOQEa.js";import{C as I}from"./CircularProgress-Fg-Nhc1W.js";import"./ethers-DArfy-QF.js";const f=H()?"mock":"stripe";function A(c){const s=c;if((s==null?void 0:s.name)==="AbortError")return"You cancelled the request.";const o=((s==null?void 0:s.message)??"").toLowerCase();return o.includes("sign in")?`Sign in to get ${i.name}.`:o.includes("timed out")?`This is taking longer than usual — your ${i.name} will appear shortly.`:"Couldn't complete your purchase — please try again."}function le(){const c=K(),{session:s,signIn:o}=Q(),_=z(),[u,x]=q(),[h,l]=n.useState("select"),[a,S]=n.useState(null),[j,w]=n.useState(null),[T,P]=n.useState(null),[M,g]=n.useState(null),[U,N]=n.useState(!1),C=n.useRef(null);n.useEffect(()=>()=>{var t;return(t=C.current)==null?void 0:t.abort()},[]);const E=n.useCallback(()=>{x(t=>{const r=new URLSearchParams(t);return r.delete("order"),r.delete("canceled"),r},{replace:!0})},[x]),b=n.useCallback(async t=>{l("processing");const r=new AbortController;C.current=r;try{const m=await L(t,{signal:r.signal,address:s==null?void 0:s.address,identity:s==null?void 0:s.identity});if(m.status==="credited"){P(m.creditsGranted??(a==null?void 0:a.credits)??0),l("success"),p("Shop Completed Buy Credits",{order_id:t,pack_usd:(a==null?void 0:a.usd)??null,credits:m.creditsGranted??(a==null?void 0:a.credits)??0,provider:f}),_.invalidateQueries({queryKey:["usd-balance"]});try{if(sessionStorage.getItem(J)){c("/cart",{state:{resumeCheckout:!0}});return}}catch{}try{const R=sessionStorage.getItem(Y);if(R){sessionStorage.removeItem(Y);const d=JSON.parse(R),B=(d==null?void 0:d.tokenId)??(d==null?void 0:d.itemId);if(d!=null&&d.contractAddress&&B){c(`/item/${d.contractAddress}/${B}`,{state:{item:d,resumeBuy:!0}});return}}}catch{}}else m.status==="pending"?(p("Shop Buy Credits Pending",{step:"grant",pack_usd:(a==null?void 0:a.usd)??null}),_.invalidateQueries({queryKey:["usd-balance"]}),l("pending")):(p("Shop Buy Credits Failed",{step:"grant",error_code:"grant_failed",pack_usd:(a==null?void 0:a.usd)??null}),g(m.error??`Couldn't add your ${i.name} — please try again.`),l("error"))}catch(m){$(m,{flow:"get_credits",step:"grant",order_id:t}),p("Shop Buy Credits Failed",{step:"grant",error_code:G(m),pack_usd:(a==null?void 0:a.usd)??null}),g(A(m)),l("error")}},[a,s,_]),V=n.useCallback(async t=>{if(!s){o();return}g(null),N(!1),S(t),l("paying"),p("Shop Started Buy Credits",{pack_usd:t.usd,credits:t.credits,provider:f});try{const r=await O(t.id,{address:s.address,identity:s.identity});if(r.mock)w(r);else if(r.url)p("Shop Redirected To Stripe",{order_id:r.orderId,pack_usd:t.usd,credits:t.credits}),window.location.href=r.url;else throw new Error("Checkout did not return a redirect url")}catch(r){$(r,{flow:"get_credits",step:"checkout",provider:f}),p("Shop Buy Credits Failed",{step:"checkout",error_code:G(r),pack_usd:t.usd}),g(A(r)),l("error")}},[s,o]),D=n.useCallback(()=>{j&&b(j.orderId)},[j,b]),v=n.useRef(!1);n.useEffect(()=>{if(v.current)return;const t=u.get("order");if(u.get("canceled")!=null){v.current=!0,p("Shop Buy Credits Cancelled",{order_id:t,provider:f}),E(),N(!0),l("select");return}t&&(l("processing"),s&&(v.current=!0,E(),b(t)))},[u,s]);function y(){var t;(t=C.current)==null||t.abort(),l("select"),S(null),w(null),P(null),g(null),N(!1)}return e.jsxs("div",{className:"getcredits",children:[e.jsxs("header",{className:"getcredits__head",children:[e.jsxs("h1",{className:"getcredits__title",children:["Get ",i.name]}),e.jsxs("p",{className:"muted",children:["Add ",i.name," to your account to shop. Pay with any card."]})]}),s?e.jsxs(e.Fragment,{children:[h==="select"&&e.jsxs(e.Fragment,{children:[U&&e.jsx("p",{className:"getcredits__note muted",role:"status",children:"Payment canceled — no charge was made. Pick a pack whenever you’re ready."}),e.jsx(X,{onSelect:t=>void V(t)})]}),h==="paying"&&a&&e.jsx(Z,{pack:a,checkout:j,onPaid:D,onCancel:y}),h==="processing"&&e.jsxs("div",{className:"getcredits__status",role:"status","aria-live":"polite",children:[e.jsx(I,{size:40}),e.jsxs("p",{className:"getcredits__status-title",children:["Adding your ",i.name,"…"]}),e.jsx("p",{className:"muted",children:"Payment received. Just a moment while we top up your balance."})]}),h==="success"&&e.jsxs("div",{className:"getcredits__status getcredits__status--ok",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"getcredits__confetti","aria-hidden":!0,children:"🎉"}),e.jsx("p",{className:"getcredits__status-title",children:"You’re all set!"}),e.jsxs("p",{className:"muted",children:[e.jsxs("strong",{children:[e.jsx(k,{className:"ccy-mark"})," ",T]})," ",i.name," added to your account."]}),e.jsxs("div",{className:"getcredits__status-actions",children:[e.jsx("button",{className:"btn",onClick:()=>c("/cart"),children:"Back to cart"}),e.jsxs("button",{className:"btn btn--ghost",onClick:y,children:["Get more ",i.name]})]})]}),h==="pending"&&e.jsxs("div",{className:"getcredits__status",role:"status","aria-live":"polite",children:[e.jsxs("p",{className:"getcredits__status-title",children:["Your ",i.name," are on the way"]}),e.jsx("p",{className:"muted",children:"Your payment went through. It’s taking a little longer than usual to confirm — your balance will update automatically as soon as it lands, no need to pay again."}),e.jsxs("div",{className:"getcredits__status-actions",children:[e.jsx("button",{className:"btn",onClick:()=>c("/cart"),children:"Back to cart"}),e.jsx("button",{className:"btn btn--ghost",onClick:y,children:"Done"})]})]}),h==="error"&&e.jsxs("div",{className:"getcredits__status getcredits__status--err",role:"alert",children:[e.jsx("p",{className:"getcredits__status-title",children:"Something went wrong"}),e.jsx("p",{className:"error",children:M}),e.jsx("div",{className:"getcredits__status-actions",children:e.jsx("button",{className:"btn",onClick:y,children:"Try again"})})]})]}):e.jsxs("div",{className:"getcredits__status",role:"status",children:[e.jsxs("p",{className:"getcredits__status-title",children:["Sign in to get ",i.name]}),e.jsxs("p",{className:"muted",children:["Connect your account to buy ",i.name," and start shopping."]}),e.jsx("div",{className:"getcredits__status-actions",children:e.jsx("button",{className:"btn btn--purple",onClick:o,children:"Sign in"})})]})]})}function X({onSelect:c}){return e.jsx("div",{className:"packs",children:W.map(s=>e.jsxs("button",{type:"button",className:`pack${s.bestValue?" pack--best":""}`,onClick:()=>c(s),"aria-label":`Get ${F(s.credits)} for $${s.usd}`,children:[s.bestValue&&e.jsx("span",{className:"pack__ribbon",children:"Best value"}),e.jsxs("span",{className:"pack__credits",children:[e.jsx(k,{className:"pack__credits-ico"}),s.credits]}),e.jsx("span",{className:"pack__label",children:i.name}),e.jsxs("span",{className:"pack__price",children:["$",s.usd]}),e.jsxs("span",{className:"pack__cta",children:["Get ",i.name]})]},s.id))})}function Z({pack:c,checkout:s,onPaid:o,onCancel:_}){return e.jsxs("div",{className:"pay",children:[e.jsxs("div",{className:"pay__summary",children:[e.jsx("button",{className:"link",onClick:_,children:"← Choose a different pack"}),e.jsxs("div",{className:"pay__summary-row",children:[e.jsx("span",{children:"You’ll get"}),e.jsxs("strong",{children:[e.jsx(k,{className:"ccy-mark"})," ",F(c.credits)]})]}),e.jsxs("div",{className:"pay__summary-row pay__summary-row--total",children:[e.jsx("span",{children:"You pay"}),e.jsxs("strong",{children:["$",c.usd]})]})]}),e.jsx("div",{className:"pay__form",children:s!=null&&s.mock?e.jsx(ee,{onPaid:o,amountUsd:c.usd}):e.jsxs("div",{className:"getcredits__status",role:"status","aria-live":"polite",children:[e.jsx(I,{size:32}),e.jsx("p",{className:"muted",children:"Getting the payment form ready…"})]})})]})}function ee({onPaid:c,amountUsd:s}){const[o,_]=n.useState("4242 4242 4242 4242"),[u,x]=n.useState(!1);function h(){x(!0),setTimeout(()=>c(),700)}return e.jsxs("div",{className:"card-form","aria-label":"Payment details",children:[e.jsx("p",{className:"muted small card-form__note",children:"Demo mode — no real charge is made."}),e.jsxs("label",{className:"field",children:[e.jsx("span",{children:"Card number"}),e.jsx("input",{value:o,onChange:l=>_(l.target.value),disabled:u,inputMode:"numeric"})]}),e.jsxs("div",{className:"card-form__row",children:[e.jsxs("label",{className:"field",children:[e.jsx("span",{children:"Expiry"}),e.jsx("input",{defaultValue:"12 / 34",disabled:u})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{children:"CVC"}),e.jsx("input",{defaultValue:"123",disabled:u,inputMode:"numeric"})]})]}),e.jsx("button",{className:"btn btn--purple card-form__pay",onClick:h,disabled:u,children:u?"Processing…":`Pay $${s}`})]})}export{le as GetCredits,le as default};
@@ -1,4 +1,4 @@
1
- import{i as f,b as h}from"./lit-element-B3y9oplH.js";import{n as m}from"./class-map-CxwNmq0D.js";import{c as p}from"./index-D7Fx-Qac.js";import{d as g,r as v}from"./index-C4JAp-Oa.js";import{C as c}from"./ConstantsUtil-BTo1-KgH.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-BrDTQqcr.js";import{au as y}from"./NetworkUtil-DInevqnn.js";const b=g`
1
+ import{i as f,b as h}from"./lit-element-B3y9oplH.js";import{n as m}from"./class-map-CxwNmq0D.js";import{c as p}from"./index-Dgwg-DaP.js";import{d as g,r as v}from"./index-BVpuOhLG.js";import{C as c}from"./ConstantsUtil-CCJ0yRd8.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-QTe845Ty.js";import{au as y}from"./NetworkUtil-Yv-DdqEo.js";const b=g`
2
2
  :host {
3
3
  display: flex;
4
4
  justify-content: center;
@@ -1 +1 @@
1
- import{u as E,r as h,j as e,L as A}from"./react-C51i12iP.js";import{s as C,C as I,v as Q,i as L,a as R,n as F,b as K,ae as P}from"./index-C1u3RQ96.js";import{i as W,R as Y,f as G}from"./import-BCIlZ3yx.js";import{s as O}from"./wallet-kind-PnN45EW0.js";import"./ethers-DwWf2RqE.js";import"./buy-y9zg-9gr.js";import"./trade-encoding-42N07h92.js";import"./index-DNT62M3w.js";import"./mana-rate-TrkgOUFu.js";function B({queue:n,session:w,onClose:x,onDone:u}){const j=E(),c=O(w.providerType),[d,N]=h.useState(()=>n.map(()=>"pending")),[b,T]=h.useState("running"),S=h.useRef(!1);h.useEffect(()=>{if(S.current)return;S.current=!0;let i=!1;return(async()=>{for(let a=0;a<n.length;a++){if(i)return;N(m=>m.map((p,o)=>o===a?"active":p));try{await W(n[a].item,n[a].priceCredits,w),Q("Shop Migrated Listing",{item_id:n[a].item.itemId??n[a].item.oldTradeId??null,contract_address:n[a].item.contractAddress,new_price_credits:n[a].priceCredits,new_price_usd:n[a].priceCredits/10}),i||N(m=>m.map((p,o)=>o===a?"done":p))}catch(m){if(m instanceof Y)L(m,{flow:"import_listing",step:"relist",itemId:n[a].item.itemId??n[a].item.oldTradeId}),i||N(p=>p.map((o,v)=>v===a?"unlisted":o));else{const p=m,o=p.code===4001||/reject|denied|cancel/i.test(p.message??"");o||L(m,{flow:"import_listing",itemId:n[a].item.itemId??n[a].item.oldTradeId}),i||N(v=>v.map((t,r)=>r===a?o?"skipped":"failed":t))}}}i||T("finished")})(),()=>{i=!0}},[]);const _=d.filter(i=>i==="done").length,f=d.findIndex(i=>i==="active"),g=Math.round(d.filter(i=>i!=="pending"&&i!=="active").length/n.length*100);function y(){u(),x()}if(b==="finished"){const i=d.filter(a=>a==="skipped"||a==="failed").length,l=d.filter(a=>a==="unlisted").length;return e.jsx("div",{className:"modal-backdrop",role:"presentation",children:e.jsxs("div",{className:"modal modal--success",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),e.jsx("h2",{className:"modal__title",children:_>0?"You're in the Shop! 🎉":"Nothing listed"}),e.jsxs("p",{className:"muted",style:{margin:0},children:[_>0?`${_} ${_===1?"item is":"items are"} now for sale with ${C.name}.`:"No items were listed.",i>0?` ${i} skipped — you can try those again anytime.`:"",l>0?` ${l} ${l===1?"item was":"items were"} taken off the old marketplace but couldn't be re-listed — re-list ${l===1?"it":"them"} from My Assets.`:""]}),e.jsxs("div",{className:"modal__actions",children:[e.jsx("button",{className:"btn btn--ghost",onClick:y,children:"Done"}),l>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{u(),x(),j("/my-assets")},children:"Go to My Assets"}):_>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{u(),x(),j("/assets")},children:"View in Shop"}):null]})]})})}return e.jsx("div",{className:"modal-backdrop",role:"presentation",children:e.jsxs("div",{className:"modal migrate",role:"dialog","aria-modal":"true","aria-live":"polite",children:[e.jsx("h2",{className:"modal__title",children:"Listing your items"}),e.jsxs("p",{className:"muted small",style:{margin:"0 0 4px"},children:[c?"We take down each old listing and re-list it for credits — confirm each step.":"Moving your items to the Shop."," ",f>=0?`${f+1} of ${n.length}`:""]}),e.jsx("div",{className:"migrate__progress",children:e.jsx("div",{className:"migrate__bar",style:{width:`${g}%`}})}),e.jsx("ul",{className:"migrate__list",children:n.map((i,l)=>e.jsxs("li",{className:`migrate__row migrate__row--${d[l]}`,children:[e.jsx("span",{className:"migrate__thumb",children:i.item.thumbnail?e.jsx("img",{src:i.item.thumbnail,alt:""}):null}),e.jsx("span",{className:"migrate__name",title:i.item.name,children:i.item.name||"Item"}),e.jsxs("span",{className:"migrate__price",children:[e.jsx(I,{className:"ccy-mark"})," ",i.priceCredits.toLocaleString()]}),e.jsx("span",{className:"migrate__status",children:d[l]==="active"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner migrate__spin","aria-hidden":!0})," ",c?"Confirm…":"Adding…"]}):d[l]==="done"?e.jsx("span",{className:"migrate__tick",children:"✓"}):d[l]==="skipped"?e.jsx("span",{className:"migrate__skip",children:"Skipped"}):d[l]==="failed"?e.jsx("span",{className:"migrate__skip",children:"Failed"}):d[l]==="unlisted"?e.jsx("span",{className:"migrate__skip",title:"Removed from the old marketplace but not re-listed — re-list it from My Assets.",children:"Not listed"}):e.jsx("span",{className:"migrate__wait",children:"Waiting"})})]},i.item.oldTradeId))}),e.jsx("p",{className:"muted small migrate__hint",children:c?"A couple of quick confirmations pop up per item (take down + re-list). Keep this open.":"This only takes a moment — keep this open."})]})})}const U=[{key:"creations",title:"Your creations",sub:"Items you made. Put them on sale in the Shop."},{key:"owned",title:"Items you own",sub:"Things you've bought elsewhere — resell them in the Shop."}];function se(){const{session:n,signIn:w,restore:x}=R(),u=F(),j=n==null?void 0:n.address;h.useEffect(()=>{x()},[x]);const{data:c,isLoading:d}=K({queryKey:["importable",j],queryFn:()=>G(j),enabled:!!j}),[N,b]=h.useState({}),[T,S]=h.useState(new Set),[_,f]=h.useState(null),g=h.useMemo(()=>[...(c==null?void 0:c.creations)??[],...(c==null?void 0:c.owned)??[]],[c]);h.useEffect(()=>{g.length&&b(t=>{const r={...t};for(const s of g)r[s.oldTradeId]==null&&(r[s.oldTradeId]=s.suggestedCredits);return r})},[g]);const y=t=>!T.has(t),i=t=>N[t.oldTradeId]??t.suggestedCredits,l=g.filter(t=>y(t.oldTradeId)),a=l.reduce((t,r)=>t+i(r),0);function m(t,r){const s=r.replace(/[^\d]/g,"");b(k=>({...k,[t]:s===""?0:parseInt(s,10)}))}function p(t){S(r=>{const s=new Set(r);return s.has(t)?s.delete(t):s.add(t),s})}function o(t){return t.map(r=>({item:r,priceCredits:Math.max(1,i(r))}))}function v(){u.invalidateQueries({queryKey:["importable"]}),u.invalidateQueries({queryKey:["unified-listings"]}),u.invalidateQueries({queryKey:["my-assets"]}),u.invalidateQueries({queryKey:["collection-sale-state"]}),P.success("Your Shop is updated.")}return n?!d&&g.length===0?e.jsxs("div",{className:"imp-empty",children:[e.jsx("span",{className:"imp-empty__ico","aria-hidden":!0,children:"✨"}),e.jsx("h1",{className:"imp-empty__title",children:"You're all caught up"}),e.jsx("p",{className:"muted",children:"Everything you sell is already in the Shop — nothing to import."}),e.jsx(A,{className:"btn btn--purple",to:"/my-assets",children:"Go to My Assets"})]}):e.jsxs("div",{className:"imp",children:[e.jsxs("header",{className:"imp__head",children:[e.jsx("span",{className:"imp__eyebrow",children:"Import to the Shop"}),e.jsxs("h1",{className:"imp__title",children:["Bring your listings ",e.jsx("span",{className:"imp__grad",children:"into the Shop"})]}),e.jsxs("p",{className:"imp__lede",children:["These items are already for sale elsewhere. We suggested a price in ",C.name," for each — matched to today's rate and rounded up. Adjust anything, then list them."]})]}),e.jsxs("div",{className:"imp__ratebar",children:[e.jsx(I,{className:"ccy-mark imp__diamond"})," 1 ",C.nameSingular," = $0.10 · prices rounded up"]}),d?e.jsx("div",{className:"imp__list",children:Array.from({length:4}).map((t,r)=>e.jsx("div",{className:"imp-row imp-row--skeleton"},r))}):U.map(t=>{const r=(c==null?void 0:c[t.key])??[];return r.length===0?null:e.jsxs("section",{className:"imp__section",children:[e.jsxs("div",{className:"imp__section-head",children:[e.jsx("h2",{className:"imp__section-title",children:t.title}),e.jsx("span",{className:"imp__section-sub",children:t.sub})]}),e.jsx("div",{className:"imp__list",children:r.map(s=>{const k=i(s),M=k!==s.suggestedCredits;return e.jsxs("article",{className:`imp-row${y(s.oldTradeId)?"":" is-off"}`,children:[e.jsx("input",{type:"checkbox",className:"imp-check",checked:y(s.oldTradeId),onChange:()=>p(s.oldTradeId),"aria-label":`Include ${s.name}`}),e.jsx("div",{className:"imp-thumb",children:s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:""}):null}),e.jsxs("div",{className:"imp-meta",children:[e.jsx("div",{className:"imp-name",title:s.name,children:s.name||"Item"}),e.jsx("span",{className:"imp-chip",children:s.rarity})]}),e.jsxs("div",{className:"imp-price",children:[e.jsxs("div",{className:"imp-price__field",children:[e.jsx(I,{className:"ccy-mark imp-price__diamond"}),e.jsx("input",{className:"imp-price__input",inputMode:"numeric",value:k.toLocaleString(),onChange:$=>m(s.oldTradeId,$.target.value),"aria-label":`Price in ${C.name} for ${s.name}`})]}),e.jsxs("div",{className:"imp-price__sub",children:[e.jsxs("span",{children:["$",(k*.1).toFixed(2)]}),M?e.jsxs("button",{className:"imp-price__reset",onClick:()=>b($=>({...$,[s.oldTradeId]:s.suggestedCredits})),children:["Reset to ",e.jsx(I,{className:"ccy-mark"}),s.suggestedCredits.toLocaleString()]}):null]})]}),e.jsx("div",{className:"imp-action",children:e.jsx("button",{className:"btn btn--sm imp-row__list",disabled:!y(s.oldTradeId),onClick:()=>f(o([s])),children:"List"})})]},s.oldTradeId)})})]},t.key)}),e.jsx("div",{className:"imp-dock",children:e.jsxs("div",{className:"imp-dock__inner",children:[e.jsxs("div",{className:"imp-dock__summary",children:[e.jsxs("div",{className:"imp-dock__total",children:[e.jsx(I,{className:"ccy-mark imp__diamond"})," ",a.toLocaleString()]}),e.jsxs("div",{className:"imp-dock__sub",children:[l.length," item",l.length===1?"":"s"," selected · $",(a*.1).toFixed(2)]})]}),e.jsx("span",{className:"imp-dock__spacer"}),e.jsxs("button",{className:"btn btn--purple imp-dock__cta",disabled:l.length===0,onClick:()=>f(o(l)),children:["List all (",l.length,")"]})]})}),_&&n?e.jsx(B,{queue:_,session:n,onClose:()=>f(null),onDone:v}):null]}):e.jsxs("div",{className:"imp-empty",children:[e.jsx("span",{className:"imp-empty__ico","aria-hidden":!0,children:"📦"}),e.jsx("h1",{className:"imp-empty__title",children:"Import your listings"}),e.jsx("p",{className:"muted",children:"Sign in to bring the items you already sell into the Shop."}),e.jsx("button",{className:"btn btn--purple",onClick:()=>w(),children:"Sign in"})]})}export{se as ImportListings};
1
+ import{a as E,r as h,j as e,L as A}from"./react-yytiy0wi.js";import{j as C,C as I,t as Q,k as L,b as R,u as F,d as K,ad as P}from"./index-DgPN63Jh.js";import{i as W,R as Y,f as G}from"./import-DM-iC_9y.js";import{s as O}from"./wallet-kind-Jzl4cyiP.js";import"./ethers-DArfy-QF.js";import"./buy-D_7yggiZ.js";import"./trade-encoding-CWQaROcB.js";import"./index-B2Zw4G7Z.js";import"./mana-rate-DM_I1GlP.js";function B({queue:n,session:w,onClose:x,onDone:u}){const j=E(),c=O(w.providerType),[d,N]=h.useState(()=>n.map(()=>"pending")),[b,T]=h.useState("running"),S=h.useRef(!1);h.useEffect(()=>{if(S.current)return;S.current=!0;let i=!1;return(async()=>{for(let a=0;a<n.length;a++){if(i)return;N(m=>m.map((p,o)=>o===a?"active":p));try{await W(n[a].item,n[a].priceCredits,w),Q("Shop Migrated Listing",{item_id:n[a].item.itemId??n[a].item.oldTradeId??null,contract_address:n[a].item.contractAddress,new_price_credits:n[a].priceCredits,new_price_usd:n[a].priceCredits/10}),i||N(m=>m.map((p,o)=>o===a?"done":p))}catch(m){if(m instanceof Y)L(m,{flow:"import_listing",step:"relist",itemId:n[a].item.itemId??n[a].item.oldTradeId}),i||N(p=>p.map((o,v)=>v===a?"unlisted":o));else{const p=m,o=p.code===4001||/reject|denied|cancel/i.test(p.message??"");o||L(m,{flow:"import_listing",itemId:n[a].item.itemId??n[a].item.oldTradeId}),i||N(v=>v.map((t,r)=>r===a?o?"skipped":"failed":t))}}}i||T("finished")})(),()=>{i=!0}},[]);const _=d.filter(i=>i==="done").length,f=d.findIndex(i=>i==="active"),g=Math.round(d.filter(i=>i!=="pending"&&i!=="active").length/n.length*100);function y(){u(),x()}if(b==="finished"){const i=d.filter(a=>a==="skipped"||a==="failed").length,l=d.filter(a=>a==="unlisted").length;return e.jsx("div",{className:"modal-backdrop",role:"presentation",children:e.jsxs("div",{className:"modal modal--success",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),e.jsx("h2",{className:"modal__title",children:_>0?"You're in the Shop! 🎉":"Nothing listed"}),e.jsxs("p",{className:"muted",style:{margin:0},children:[_>0?`${_} ${_===1?"item is":"items are"} now for sale with ${C.name}.`:"No items were listed.",i>0?` ${i} skipped — you can try those again anytime.`:"",l>0?` ${l} ${l===1?"item was":"items were"} taken off the old marketplace but couldn't be re-listed — re-list ${l===1?"it":"them"} from My Assets.`:""]}),e.jsxs("div",{className:"modal__actions",children:[e.jsx("button",{className:"btn btn--ghost",onClick:y,children:"Done"}),l>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{u(),x(),j("/my-assets")},children:"Go to My Assets"}):_>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{u(),x(),j("/assets")},children:"View in Shop"}):null]})]})})}return e.jsx("div",{className:"modal-backdrop",role:"presentation",children:e.jsxs("div",{className:"modal migrate",role:"dialog","aria-modal":"true","aria-live":"polite",children:[e.jsx("h2",{className:"modal__title",children:"Listing your items"}),e.jsxs("p",{className:"muted small",style:{margin:"0 0 4px"},children:[c?"We take down each old listing and re-list it for credits — confirm each step.":"Moving your items to the Shop."," ",f>=0?`${f+1} of ${n.length}`:""]}),e.jsx("div",{className:"migrate__progress",children:e.jsx("div",{className:"migrate__bar",style:{width:`${g}%`}})}),e.jsx("ul",{className:"migrate__list",children:n.map((i,l)=>e.jsxs("li",{className:`migrate__row migrate__row--${d[l]}`,children:[e.jsx("span",{className:"migrate__thumb",children:i.item.thumbnail?e.jsx("img",{src:i.item.thumbnail,alt:""}):null}),e.jsx("span",{className:"migrate__name",title:i.item.name,children:i.item.name||"Item"}),e.jsxs("span",{className:"migrate__price",children:[e.jsx(I,{className:"ccy-mark"})," ",i.priceCredits.toLocaleString()]}),e.jsx("span",{className:"migrate__status",children:d[l]==="active"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner migrate__spin","aria-hidden":!0})," ",c?"Confirm…":"Adding…"]}):d[l]==="done"?e.jsx("span",{className:"migrate__tick",children:"✓"}):d[l]==="skipped"?e.jsx("span",{className:"migrate__skip",children:"Skipped"}):d[l]==="failed"?e.jsx("span",{className:"migrate__skip",children:"Failed"}):d[l]==="unlisted"?e.jsx("span",{className:"migrate__skip",title:"Removed from the old marketplace but not re-listed — re-list it from My Assets.",children:"Not listed"}):e.jsx("span",{className:"migrate__wait",children:"Waiting"})})]},i.item.oldTradeId))}),e.jsx("p",{className:"muted small migrate__hint",children:c?"A couple of quick confirmations pop up per item (take down + re-list). Keep this open.":"This only takes a moment — keep this open."})]})})}const U=[{key:"creations",title:"Your creations",sub:"Items you made. Put them on sale in the Shop."},{key:"owned",title:"Items you own",sub:"Things you've bought elsewhere — resell them in the Shop."}];function se(){const{session:n,signIn:w,restore:x}=R(),u=F(),j=n==null?void 0:n.address;h.useEffect(()=>{x()},[x]);const{data:c,isLoading:d}=K({queryKey:["importable",j],queryFn:()=>G(j),enabled:!!j}),[N,b]=h.useState({}),[T,S]=h.useState(new Set),[_,f]=h.useState(null),g=h.useMemo(()=>[...(c==null?void 0:c.creations)??[],...(c==null?void 0:c.owned)??[]],[c]);h.useEffect(()=>{g.length&&b(t=>{const r={...t};for(const s of g)r[s.oldTradeId]==null&&(r[s.oldTradeId]=s.suggestedCredits);return r})},[g]);const y=t=>!T.has(t),i=t=>N[t.oldTradeId]??t.suggestedCredits,l=g.filter(t=>y(t.oldTradeId)),a=l.reduce((t,r)=>t+i(r),0);function m(t,r){const s=r.replace(/[^\d]/g,"");b(k=>({...k,[t]:s===""?0:parseInt(s,10)}))}function p(t){S(r=>{const s=new Set(r);return s.has(t)?s.delete(t):s.add(t),s})}function o(t){return t.map(r=>({item:r,priceCredits:Math.max(1,i(r))}))}function v(){u.invalidateQueries({queryKey:["importable"]}),u.invalidateQueries({queryKey:["unified-listings"]}),u.invalidateQueries({queryKey:["my-assets"]}),u.invalidateQueries({queryKey:["collection-sale-state"]}),P.success("Your Shop is updated.")}return n?!d&&g.length===0?e.jsxs("div",{className:"imp-empty",children:[e.jsx("span",{className:"imp-empty__ico","aria-hidden":!0,children:"✨"}),e.jsx("h1",{className:"imp-empty__title",children:"You're all caught up"}),e.jsx("p",{className:"muted",children:"Everything you sell is already in the Shop — nothing to import."}),e.jsx(A,{className:"btn btn--purple",to:"/my-assets",children:"Go to My Assets"})]}):e.jsxs("div",{className:"imp",children:[e.jsxs("header",{className:"imp__head",children:[e.jsx("span",{className:"imp__eyebrow",children:"Import to the Shop"}),e.jsxs("h1",{className:"imp__title",children:["Bring your listings ",e.jsx("span",{className:"imp__grad",children:"into the Shop"})]}),e.jsxs("p",{className:"imp__lede",children:["These items are already for sale elsewhere. We suggested a price in ",C.name," for each — matched to today's rate and rounded up. Adjust anything, then list them."]})]}),e.jsxs("div",{className:"imp__ratebar",children:[e.jsx(I,{className:"ccy-mark imp__diamond"})," 1 ",C.nameSingular," = $0.10 · prices rounded up"]}),d?e.jsx("div",{className:"imp__list",children:Array.from({length:4}).map((t,r)=>e.jsx("div",{className:"imp-row imp-row--skeleton"},r))}):U.map(t=>{const r=(c==null?void 0:c[t.key])??[];return r.length===0?null:e.jsxs("section",{className:"imp__section",children:[e.jsxs("div",{className:"imp__section-head",children:[e.jsx("h2",{className:"imp__section-title",children:t.title}),e.jsx("span",{className:"imp__section-sub",children:t.sub})]}),e.jsx("div",{className:"imp__list",children:r.map(s=>{const k=i(s),M=k!==s.suggestedCredits;return e.jsxs("article",{className:`imp-row${y(s.oldTradeId)?"":" is-off"}`,children:[e.jsx("input",{type:"checkbox",className:"imp-check",checked:y(s.oldTradeId),onChange:()=>p(s.oldTradeId),"aria-label":`Include ${s.name}`}),e.jsx("div",{className:"imp-thumb",children:s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:""}):null}),e.jsxs("div",{className:"imp-meta",children:[e.jsx("div",{className:"imp-name",title:s.name,children:s.name||"Item"}),e.jsx("span",{className:"imp-chip",children:s.rarity})]}),e.jsxs("div",{className:"imp-price",children:[e.jsxs("div",{className:"imp-price__field",children:[e.jsx(I,{className:"ccy-mark imp-price__diamond"}),e.jsx("input",{className:"imp-price__input",inputMode:"numeric",value:k.toLocaleString(),onChange:$=>m(s.oldTradeId,$.target.value),"aria-label":`Price in ${C.name} for ${s.name}`})]}),e.jsxs("div",{className:"imp-price__sub",children:[e.jsxs("span",{children:["$",(k*.1).toFixed(2)]}),M?e.jsxs("button",{className:"imp-price__reset",onClick:()=>b($=>({...$,[s.oldTradeId]:s.suggestedCredits})),children:["Reset to ",e.jsx(I,{className:"ccy-mark"}),s.suggestedCredits.toLocaleString()]}):null]})]}),e.jsx("div",{className:"imp-action",children:e.jsx("button",{className:"btn btn--sm imp-row__list",disabled:!y(s.oldTradeId),onClick:()=>f(o([s])),children:"List"})})]},s.oldTradeId)})})]},t.key)}),e.jsx("div",{className:"imp-dock",children:e.jsxs("div",{className:"imp-dock__inner",children:[e.jsxs("div",{className:"imp-dock__summary",children:[e.jsxs("div",{className:"imp-dock__total",children:[e.jsx(I,{className:"ccy-mark imp__diamond"})," ",a.toLocaleString()]}),e.jsxs("div",{className:"imp-dock__sub",children:[l.length," item",l.length===1?"":"s"," selected · $",(a*.1).toFixed(2)]})]}),e.jsx("span",{className:"imp-dock__spacer"}),e.jsxs("button",{className:"btn btn--purple imp-dock__cta",disabled:l.length===0,onClick:()=>f(o(l)),children:["List all (",l.length,")"]})]})}),_&&n?e.jsx(B,{queue:_,session:n,onClose:()=>f(null),onDone:v}):null]}):e.jsxs("div",{className:"imp-empty",children:[e.jsx("span",{className:"imp-empty__ico","aria-hidden":!0,children:"📦"}),e.jsx("h1",{className:"imp-empty__title",children:"Import your listings"}),e.jsx("p",{className:"muted",children:"Sign in to bring the items you already sell into the Shop."}),e.jsx("button",{className:"btn btn--purple",onClick:()=>w(),children:"Sign in"})]})}export{se as ImportListings};
@@ -0,0 +1 @@
1
+ .item-detail{max-width:1721px;margin:0 auto}.item-detail__crumbs{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--muted);margin-bottom:24px}.item-detail__crumb-link{background:none;border:0;padding:0;font:inherit;color:var(--muted)}.item-detail__crumb-link:hover{color:var(--text)}.item-detail__crumb-sep{color:var(--muted-2)}.item-detail__crumb-current{color:var(--text);font-weight:600}.item-detail__main{display:grid;grid-template-columns:minmax(0,1045fr) minmax(0,514fr);gap:48px;align-items:start;max-width:1607px;margin:0 auto}@media(max-width:900px){.item-detail__main{grid-template-columns:1fr;gap:24px;max-width:none}}.item-detail__preview{position:relative;aspect-ratio:1045 / 752;border-radius:16px;overflow:hidden;background:var(--media)}@media(max-width:900px){.item-detail__preview{aspect-ratio:1 / 1}}.item-detail__preview iframe,.item-detail__preview>*{width:100%;height:100%;border:0;display:block}.item-detail__preview>.item-preview__toggle{position:absolute;top:16px;left:16px;z-index:2;width:auto;height:auto;display:inline-flex;gap:2px;padding:3px;background:#ffffffeb;border:1px solid var(--line);border-radius:999px;box-shadow:0 1px 4px #0000001f}.item-preview__toggle button{border:0;background:none;cursor:pointer;padding:6px 16px;border-radius:999px;font-weight:600;font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);transition:background .12s ease,color .12s ease}.item-preview__toggle button.is-active{background:var(--text);color:#fff}.item-preview__toggle button:not(.is-active):hover{color:var(--text)}.item-preview__toggle-ico{display:none;width:18px;height:18px}.item-detail__preview>.item-preview__emote-controls{position:absolute;bottom:16px;left:50%;transform:translate(-50%);z-index:2;width:min(360px,88%);height:auto;display:flex;align-items:center;background:#fffffff0;-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);border:1px solid var(--line);border-radius:var(--radius-pill);padding:6px 12px;box-shadow:0 2px 10px #1615181f}.item-preview__emote-controls .MuiBox-root{position:static;width:100%;margin:0;padding:0;display:flex;align-items:center;gap:10px}.item-preview__emote-controls .MuiButtonBase-root{min-width:0;padding:0;margin:0;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;background:none!important;box-shadow:none!important;color:var(--muted);flex:0 0 auto;transition:background .12s ease,color .12s ease}.item-preview__emote-controls .MuiButtonBase-root .MuiSvgIcon-root{font-size:20px;margin:0}.item-preview__emote-controls .MuiBox-root>.MuiButtonBase-root:first-child{width:34px;height:34px;background:var(--accent)!important;color:#fff}.item-preview__emote-controls .MuiBox-root>.MuiButtonBase-root:first-child:hover{background:var(--text)!important}.item-preview__emote-controls .MuiBox-root>input+.MuiButtonBase-root{width:30px;height:30px;color:var(--muted)}.item-preview__emote-controls .MuiBox-root>input+.MuiButtonBase-root:hover{background:var(--media)!important;color:var(--text)}.item-preview__emote-controls input[type=range]{flex:1 1 auto;width:auto;min-width:0;height:4px;margin:0;padding:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;cursor:pointer}.item-preview__emote-controls input[type=range]::-webkit-slider-runnable-track{height:4px;border-radius:999px;background:var(--line-strong)}.item-preview__emote-controls input[type=range]::-moz-range-track{height:4px;border-radius:999px;background:var(--line-strong)}.item-preview__emote-controls input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:13px;height:13px;margin-top:-4.5px;border-radius:50%;background:var(--accent);border:2px solid #fff;box-shadow:0 1px 3px #1615184d;cursor:pointer}.item-preview__emote-controls input[type=range]::-moz-range-thumb{width:13px;height:13px;border-radius:50%;background:var(--accent);border:2px solid #fff;box-shadow:0 1px 3px #1615184d;cursor:pointer}.item-preview__emote-controls input[type=range]:focus-visible{outline:none}.item-preview__emote-controls input[type=range]:focus-visible::-webkit-slider-thumb{outline:2px solid var(--accent);outline-offset:2px}.item-detail__preview>.item-preview__note{position:absolute;bottom:14px;left:50%;transform:translate(-50%);z-index:2;width:auto;height:auto;max-width:88%;margin:0;text-align:center;background:#161518c7;color:#fff;font-size:12px;font-weight:500;padding:6px 12px;border-radius:999px}.item-detail__preview>.item-preview__loading{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;display:flex;align-items:center;justify-content:center;width:100%;height:100%;background:transparent}.item-preview__spinner{width:34px;height:34px;border-radius:50%;border:3px solid var(--line);border-top-color:var(--accent);animation:item-preview-spin .8s linear infinite}@keyframes item-preview-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.item-preview__spinner{animation-duration:2.4s}}.item-detail__info{display:flex;flex-direction:column;gap:0}.item-detail__info-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.item-detail__title{font-size:28px;font-weight:600;line-height:34px;color:var(--text-2)}.item-detail__fav{flex:none;width:40px;height:40px;border-radius:50%;border:0;background:var(--media);display:grid;place-items:center;color:var(--text-2);cursor:pointer;transition:color .12s ease,background .12s ease}.item-detail__fav:hover{background:var(--line)}.item-detail__fav.is-on{color:var(--dcl-red)}.item-detail__fav .ico-heart{width:18px;height:18px}.item-detail__preview>.item-detail__fav--preview{display:none}.item-detail__label{display:inline-flex;align-items:center;gap:5px;font-size:12px;font-weight:500;text-transform:uppercase;letter-spacing:0;color:var(--muted)}.item-detail__chips{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:12px}.item-detail__chips .chip{height:24px;padding:0 8px;gap:3px;font-size:13px;font-weight:500;border-radius:4px;letter-spacing:.02em;text-transform:uppercase}.item-detail__chip{background:var(--chip);color:var(--text-2)}.item-detail__chip-ico{width:18px;height:18px;color:var(--text-2)}.item-detail__section{display:flex;flex-direction:column;align-items:flex-start;gap:8px}.item-detail__description{margin-top:15px;gap:11px}.item-detail__desc-text{margin:0;color:var(--text-2);font-size:14px;line-height:30px;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:4;overflow:hidden}.item-detail__desc-text.is-expanded{-webkit-line-clamp:unset;overflow:visible}.item-detail__desc-toggle{font-size:13px;align-self:flex-start}.item-detail__meta{display:flex;justify-content:space-between;gap:16px;margin-top:32px}.item-detail__meta-col{display:flex;flex-direction:column;gap:15px;min-width:0}.item-detail__meta-col--collection{align-items:flex-start}.item-detail__creator.creator{color:var(--accent);font-size:14px;gap:12px}.item-detail__creator .creator__ava{width:48px;height:48px}.item-detail__creator .creator__ava--letter{font-size:18px}.item-detail__creator .creator__name{color:var(--accent);font-weight:500;text-decoration:underline}.item-detail__creator.creator--link:hover .creator__name{color:var(--brand-violet)}.collection-collage{display:flex;flex-direction:column;overflow:hidden;gap:1px;background:var(--line-strong)}.collection-collage__row{display:flex;flex:1 1 50%;min-height:0;gap:1px}.collection-collage__row--full{flex-basis:100%}.collection-collage__row img{flex:1 1 0;min-width:0;width:100%;height:100%;object-fit:cover;display:block}.item-detail__divider{border:0;border-top:1px solid #cfcdd4;margin:24px 0 0;width:100%}.item-detail__price-block{margin-top:16px}.item-detail__price-row{display:flex;align-items:flex-start;gap:16px;width:100%}.item-detail__price-col{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:8px}.item-detail__stock-col{flex:0 0 auto;display:flex;flex-direction:column;align-items:flex-end;gap:8px;text-align:right}.item-detail__stock-value{font-size:18px;font-weight:500;line-height:1;color:var(--text-2)}.item-detail__price-label{font-size:14px;font-weight:600;text-transform:uppercase;letter-spacing:0;color:#5e5b67}.item-detail__price{display:flex;align-items:center;gap:10px;font-weight:700;color:var(--text)}.item-detail__diamond{width:30px;height:30px;color:var(--brand-violet)}.item-detail__price-value{font-size:30px;line-height:1}.item-detail__price--none{font-size:18px;color:var(--muted)}.item-detail__approx{font-size:24px;font-weight:700;color:var(--text);margin-right:-2px}.item-detail__market-note{font-size:13px;margin-top:6px}.item-detail__price--sale{flex-wrap:wrap;gap:10px 14px}.item-detail__price--sale .item-detail__price,.item-detail__price--sale .item-detail__price-value,.item-detail__price--sale .item-detail__diamond{color:var(--dcl-red)}.item-detail__price-was{display:inline-flex;align-items:center;gap:6px;color:var(--muted);text-decoration:line-through;font-weight:600;font-size:20px}.item-detail__diamond--was{width:18px;height:18px;color:var(--muted)}.item-detail__sale-badge{display:inline-flex;align-items:center;background:var(--dcl-red);color:#fff;font-weight:800;font-size:13px;letter-spacing:.03em;text-transform:uppercase;border-radius:6px;padding:4px 10px}.item-detail__countdown{display:inline-flex;align-items:center;gap:5px;background:var(--rarity-bg);color:var(--accent);font-size:13px;font-weight:700;border-radius:6px;padding:4px 10px;white-space:nowrap}.item-detail__countdown .sale-countdown__ico{width:14px;height:14px}.item-detail__ctas{display:flex;flex-direction:column;gap:12px;margin-top:20px}.item-detail__cta{width:100%;height:48px;border-radius:8px;font-size:15px;font-weight:600;letter-spacing:.46px;display:flex;align-items:center;justify-content:center;gap:8px}.item-detail__cta-price{display:none;align-items:center;gap:6px}.item-detail__cta-diamond{width:20px;height:20px;color:#fff}.item-detail__addcart{width:100%;height:48px;display:flex;align-items:center;justify-content:center;gap:8px;background:var(--black-btn);color:var(--soft-white);border:0;border-radius:8px;font-weight:600;font-size:15px;text-transform:uppercase;letter-spacing:.46px;cursor:pointer;transition:filter .15s ease}.item-detail__addcart:hover:not(:disabled){filter:brightness(1.35)}.item-detail__addcart:disabled{opacity:.55;cursor:default}.item-detail__addcart-ico{width:20px;height:20px}.item-detail__status{margin:0;font-size:13px}.item-detail__own-note{margin:0;font-size:14px}.item-detail__own-note a{color:var(--accent);font-weight:600}@media(max-width:900px){.item-detail__title{font-size:20px;line-height:24px}.item-detail__info-head{order:0}.item-detail__chips{order:1;margin-top:10px}.item-detail__meta{order:2;margin-top:20px}.item-detail__description{order:3;margin-top:20px}.item-detail__divider{order:4;margin-top:20px}.item-detail__price-block{order:5;margin-top:16px}.item-detail__ctas{order:6}.item-detail__status{order:7}.item-detail{padding-bottom:88px}.item-detail__ctas--buttons{position:fixed;left:0;right:0;bottom:0;z-index:40;margin-top:0;padding:12px 16px calc(12px + env(safe-area-inset-bottom));background:var(--soft-white);box-shadow:0 -4px 16px #1615181f}.item-detail__ctas--dual{flex-direction:row;align-items:stretch;gap:12px}.item-detail__ctas--dual .item-detail__cta{flex:1 1 auto;width:auto}.item-detail__ctas--dual .item-detail__cta-price{display:inline-flex}.item-detail__ctas--dual .item-detail__addcart{flex:0 0 auto;width:56px;padding:0}.item-detail__ctas--dual .item-detail__addcart-label{display:none}.item-detail__ctas--dual .item-detail__addcart-ico{margin:0}.item-detail__info-head .item-detail__fav{display:none}.item-detail__preview>.item-detail__fav--preview{display:grid;position:absolute;top:12px;right:12px;z-index:3;width:40px;height:40px;background:#ffffffeb;box-shadow:0 1px 4px #1615182e}.item-detail__preview>.item-detail__fav--preview:hover{background:#fff}.item-detail__preview>.item-preview__toggle{top:auto;left:auto;bottom:12px;right:12px;gap:0;padding:0;background:transparent;border:0;box-shadow:0 1px 4px #1615182e;overflow:hidden}.item-preview__toggle-label{display:none}.item-preview__toggle-ico{display:block}.item-preview__toggle button{padding:9px 13px;border-radius:0;background:#fff;color:var(--text-2)}.item-preview__toggle button.is-active{background:var(--text);color:#fff}.item-preview__toggle button:first-child{border-top-left-radius:999px;border-bottom-left-radius:999px}.item-preview__toggle button:last-child{border-top-right-radius:999px;border-bottom-right-radius:999px}}.collection-carousel{margin-top:64px}.collection-carousel__head{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px}.collection-carousel__title{font-size:22px;font-weight:700;color:var(--text)}.collection-carousel__viewall{display:inline-flex;align-items:center;gap:4px;background:none;border:0;padding:0;color:var(--accent);font-weight:700;font-size:13px;letter-spacing:.046em;text-transform:uppercase;cursor:pointer;white-space:nowrap}.collection-carousel__viewall:hover{text-decoration:underline}.collection-carousel__viewall-ico{width:16px;height:16px;transform:rotate(-90deg)}.collection-carousel__viewport{position:relative}.collection-carousel__arrow{position:absolute;top:112px;transform:translateY(-50%);z-index:5;width:53px;height:53px;padding:0;border:0;background:transparent;cursor:pointer;filter:drop-shadow(0 2px 6px rgba(0,0,0,.18));transition:transform .15s ease,filter .15s ease,opacity .15s ease}.collection-carousel__arrow img{display:block;width:100%;height:100%}.collection-carousel__arrow--left{left:-40px}.collection-carousel__arrow--right{right:-40px}.collection-carousel__arrow--left img{transform:scaleX(-1)}.collection-carousel__arrow:hover:not(:disabled){transform:translateY(-50%) scale(1.07)}.collection-carousel__arrow:disabled{opacity:0;pointer-events:none}@media(prefers-reduced-motion:reduce){.collection-carousel__arrow{transition:none}}@media(max-width:900px){.collection-carousel__arrow{display:none}}.collection-carousel__track{display:flex;gap:16px;overflow-x:auto;padding:12px 10px;margin:0 -10px;scroll-snap-type:x proximity;scrollbar-width:none}.collection-carousel__track::-webkit-scrollbar{display:none}.collection-carousel__track>.card{flex:0 0 281px;scroll-snap-align:start}@media(max-width:720px){.collection-carousel__track>.card{flex:0 0 85%}}.collection-carousel__dots{display:flex;align-items:center;justify-content:center;gap:8px;margin-top:18px}.collection-carousel__dot{width:10px;height:10px;border-radius:50%;border:0;padding:0;background:var(--line-strong);opacity:.5;cursor:pointer;transition:opacity .12s ease,background .12s ease,transform .12s ease}.collection-carousel__dot:hover{opacity:.8}.collection-carousel__dot.is-active{background:var(--accent);opacity:1;transform:scale(1.1)}.item-detail--notfound{min-height:46vh;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:14px}.item-detail__notfound-ico{width:44px;height:44px;opacity:.4}.item-detail__notfound-title{font-size:22px}.item-detail--notfound .btn{margin-top:6px}
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CBVNSjCQ.js","assets/react-yytiy0wi.js","assets/index-DgPN63Jh.js","assets/ethers-DArfy-QF.js","assets/index-BAYW-Y7J.css","assets/emotion-styled.browser.esm-B7PezGnO.js","assets/useTheme-Bf8Lxsxi.js","assets/CircularProgress-Fg-Nhc1W.js","assets/index-ChMOJahJ.js","assets/useTheme-B2pFHCn2.js","assets/CssVarsProvider-D1D1cNqm.js","assets/getOverlayAlpha-CM9JvcJV.js","assets/index-DD6TVIkI.js","assets/colors-LINLm1ux.js"])))=>i.map(i=>d[i]);
2
+ import{a as ae,r as n,j as e,d as Ie,b as Ae,L as Se}from"./react-yytiy0wi.js";import{b as se,v as Ee,u as Le,ai as Pe,n as Be,o as Me,y as Re,w as Q,t as z,l as de,z as X,aj as Fe,k as oe,C as S,ae as J,_ as ee,G as Te,J as $e,I as We,aw as Ve,W as qe,i as $,h as fe,ax as Oe,ay as me,A as ze,az as De,af as ue,a as _e,d as O,aA as Ke,aB as Ye,aC as Ge,aD as Ue,aE as He,ap as Qe,aF as Je,aG as Ze,aH as Xe,ag as ea,aI as he,aJ as aa,an as sa,aK as ta,aL as ia,ao as ra,aM as la}from"./index-DgPN63Jh.js";import{b as pe}from"./buy-D_7yggiZ.js";import{g as na,b as ca,w as da,S as oa,G as ma}from"./buy-gasless-DdXBIm99.js";import{C as ua,c as _a}from"./payments-Cz9uOQEa.js";import{R as be}from"./resume-buy-Bf0zIH7y.js";import{C as ha}from"./CircularProgress-Fg-Nhc1W.js";import{u as pa,M as ba}from"./MarketCheckout-Qn1ixrkb.js";import"./ethers-DArfy-QF.js";import"./trade-encoding-CWQaROcB.js";import"./index-B2Zw4G7Z.js";import"./mana-rate-DM_I1GlP.js";function xe(t){const r=t,s=(r.message??"").toLowerCase();return r.code===4001||s.includes("reject")||s.includes("denied")||s.includes("cancel")?"You cancelled the request.":s.includes("not for sale")||s.includes("not found")||s.includes("404")?"This item was just sold or removed.":s.includes("your own listing")?"You can't buy your own listing.":"Couldn't complete the purchase — please try again."}function xa(t){const r=t;return r.code===402||r.status===402||(r.message??"").toLowerCase().includes("insufficient")}const T=ua.slice(0,3);function ya({item:t,onClose:r,resume:s=!1}){var I,G;const{session:l}=se(),{data:c}=Ee(l),h=Le(),f=ae(),[_,d]=n.useState("loading"),[N,a]=n.useState(null),[j,y]=n.useState(""),[g,P]=n.useState(t.priceCredits),[u,o]=n.useState(null),C=n.useRef(null),E=(u==null?void 0:u.credits)??g,w=(c==null?void 0:c.credits)??0;n.useEffect(()=>{let m=!1;if(!l){d("error"),a("Sign in to check out.");return}const v=p=>{const b=p-((c==null?void 0:c.credits)??0),x=T.find(A=>A.credits>=b)??T[T.length-1];y(x.id),z("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:p,credits_balance:(c==null?void 0:c.credits)??0,shortfall:Math.max(0,b)}),d("nofunds")};return(async()=>{var p,b;try{const x=await Pe(t);if(!x)throw new Error("not for sale");if(Be(x,l.address))throw new Error("You can't buy your own listing.");const A=Me((b=(p=x.received)==null?void 0:p[0])==null?void 0:b.amount);if(!Number.isFinite(A)||A<=0)throw new Error("price unavailable");const R=Math.ceil(A/10);if(m)return;if(P(R),c!=null&&c.credits<R){v(R);return}try{const{credit:B,maxCreditedValue:V,usdCents:F}=await Re(l.identity,A,x.id);if(m){Q(l.identity,[B.id]).catch(()=>{});return}C.current=B.id;const k=Math.ceil(F/10);P(k);const q={trade:x,credit:B,maxCreditedValue:V,usdCents:F,credits:k};o(q),s?D(q):d("ready")}catch(B){if(m)return;if(xa(B)){v(R);return}throw B}}catch(x){if(m)return;z(X(x)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:de(x)}),d("error"),a(xe(x))}})(),()=>{m=!0,C.current&&l&&(Q(l.identity,[C.current]).catch(()=>{}),C.current=null)}},[]);async function D(m=u){if(!l||!m)return;d("processing"),a(null);let v=!1;try{const p={trade:m.trade,buyer:l.address,signer:l.signer,credits:[m.credit],maxCreditedValue:m.maxCreditedValue};let b;if(na())try{b=await ca(p),await da(b),v=!0}catch(x){if(x instanceof oa)v=!0;else if(x instanceof ma)b=await pe(p);else throw x}else b=await pe(p);C.current=null,z("Shop Completed Purchase",{...Fe([t]),payment_type:"credits",no_crypto_step:v,transaction_hash:b??null}),h.invalidateQueries({queryKey:["usd-balance"]}),d("complete")}catch(p){X(p)||oe(p,{flow:"buy",step:"submit",gasless:v}),Q(l.identity,[m.credit.id]).catch(()=>{}),C.current=null,z(X(p)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:de(p)}),h.invalidateQueries({queryKey:["usd-balance"]}),a(xe(p)),d("error")}}async function K(){if(!(!j||!l)){try{sessionStorage.setItem(be,JSON.stringify(t))}catch{}u&&Q(l.identity,[u.credit.id]).catch(()=>{}),C.current=null,d("loading");try{const m=await _a(j,{address:l.address,identity:l.identity});if(m.url){window.location.href=m.url;return}f("/credits")}catch(m){oe(m,{flow:"buy_credits_and_item"});try{sessionStorage.removeItem(be)}catch{}a("Couldn't start the credits checkout — please try again."),d("error")}}}const Y=_==="processing",W=_==="complete"?"Purchase complete!":_==="nofunds"?"Buy Credits and Item":"Buy Asset";return e.jsxs("div",{className:"buy-modal",role:"dialog","aria-modal":"true","aria-label":`Buy ${t.name}`,children:[e.jsx("div",{className:"buy-modal__scrim",onClick:Y?void 0:r,"aria-hidden":!0}),e.jsxs("div",{className:`buy-modal__card${_==="processing"||_==="loading"?" buy-modal__card--tall":""}`,children:[e.jsxs("div",{className:"buy-modal__head",children:[e.jsxs("div",{className:"buy-modal__head-row",children:[e.jsx("h2",{className:"buy-modal__title",children:W}),!Y&&e.jsx("button",{className:"buy-modal__x",onClick:r,"aria-label":"Close",children:e.jsx("svg",{viewBox:"0 0 18 18",width:"18",height:"18","aria-hidden":!0,children:e.jsx("path",{d:"M4 4l10 10M14 4L4 14",stroke:"#161518",strokeWidth:"1.8",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"buy-modal__balance",children:[e.jsx("span",{className:"buy-modal__balance-label",children:_==="nofunds"?"DCL Balance:":"My Credits Balance:"}),e.jsx(S,{className:"buy-modal__balance-ico"}),e.jsx("span",{className:"buy-modal__balance-value",children:J(w)})]})]}),_==="loading"&&e.jsx("div",{className:"buy-modal__body buy-modal__processing",children:e.jsx(ha,{size:44})}),_==="error"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx("p",{className:"buy-modal__error",children:N}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:r,children:"Close"})})]}),_==="nofunds"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__warning",children:[e.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":!0,className:"buy-modal__warning-ico",children:[e.jsx("path",{d:"M12 3L2 20h20L12 3z",fill:"none",stroke:"#691fa9",strokeWidth:"1.8",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 9v5",stroke:"#691fa9",strokeWidth:"1.8",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"17",r:"1.1",fill:"#691fa9"})]}),e.jsxs("p",{className:"buy-modal__warning-text",children:[e.jsx("b",{children:"Insufficient Funds."})," You will need to buy"," ",e.jsxs("b",{children:[Math.max(0,E-w)," Credits"]})," to purchase this item."]})]}),e.jsx(ye,{item:t,priceCredits:E}),e.jsx("div",{className:"buy-modal__packs",children:T.map(m=>{const v=m.credits,p=m.id===j;return e.jsxs("button",{className:`buy-modal__pack${p?" buy-modal__pack--on":""}`,onClick:()=>y(m.id),children:[e.jsx(S,{className:"buy-modal__pack-ico"}),e.jsx("span",{className:"buy-modal__pack-amount",children:J(v)}),e.jsxs("span",{className:"buy-modal__pack-usd",children:["($",m.usd.toFixed(2),")"]})]},m.id)})}),e.jsxs("div",{className:"buy-modal__total",children:[e.jsxs("div",{className:"buy-modal__total-credits",children:[e.jsx(S,{className:"buy-modal__total-ico"}),e.jsx("span",{children:J(((I=T.find(m=>m.id===j))==null?void 0:I.credits)??0)})]}),e.jsxs("span",{className:"buy-modal__total-usd",children:["$",(((G=T.find(m=>m.id===j))==null?void 0:G.usd)??0).toFixed(2)]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:r,children:"Cancel"}),e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:K,children:"Buy"})]})]}),_==="ready"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(ye,{item:t,priceCredits:E}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient buy-modal__btn--full",onClick:()=>D(),children:"Buy"})})]}),_==="processing"&&e.jsxs("div",{className:"buy-modal__body buy-modal__processing",children:[e.jsx("img",{className:"buy-modal__logo",src:"/icon-192.png",alt:"",width:61,height:61}),e.jsx("div",{className:"buy-modal__processing-text",children:s?"Completing Purchase…":"Completing transaction…"}),e.jsx("div",{className:"buy-modal__progress","aria-hidden":!0,children:e.jsx("span",{className:"buy-modal__progress-fill"})})]}),_==="complete"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__success",children:[e.jsxs("svg",{viewBox:"0 0 64 64",width:"64",height:"64","aria-hidden":!0,children:[e.jsx("circle",{cx:"32",cy:"32",r:"32",fill:"#34ce74"}),e.jsx("path",{d:"M20 33l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsxs("p",{className:"buy-modal__success-text",children:[e.jsx("b",{children:"Your purchase was successful!"})," You can find your item in the My Assets tab."]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:()=>f("/assets?tab=mine"),children:"My assets"}),e.jsxs("button",{className:"buy-modal__btn buy-modal__btn--ruby",onClick:r,children:["Try in world",e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":!0,children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]})]})]})}function ye({item:t,priceCredits:r}){return e.jsxs("div",{className:"buy-modal__asset",children:[e.jsx("div",{className:"buy-modal__asset-thumb",children:t.thumbnail?e.jsx("img",{src:t.thumbnail,alt:""}):null}),e.jsxs("div",{className:"buy-modal__asset-info",children:[e.jsxs("div",{children:[e.jsx("div",{className:"buy-modal__asset-name",title:t.name,children:t.name||"Item"}),t.creator?e.jsxs("div",{className:"buy-modal__asset-creator",children:["By ",t.creator]}):null]}),e.jsxs("div",{className:"buy-modal__asset-price",children:[e.jsx(S,{className:"buy-modal__asset-price-ico"}),e.jsx("span",{children:J(r)})]})]})]})}const fa=n.lazy(async()=>{const[{EmoteControls:t},{Experimental_CssVarsProvider:r},{light:s}]=await Promise.all([ee(()=>import("./index-CBVNSjCQ.js").then(l=>l.i),__vite__mapDeps([0,1,2,3,4,5,6,7])),ee(()=>import("./index-ChMOJahJ.js"),__vite__mapDeps([8,2,1,3,4,9,6,10,11])),ee(()=>import("./index-DD6TVIkI.js"),__vite__mapDeps([12,2,1,3,4,13,11,10,6]))]);return{default:l=>e.jsx(r,{theme:s,children:e.jsx(t,{...l})})}});function va(t){return e.jsx(n.Suspense,{fallback:null,children:e.jsx(fa,{...t})})}function ja({item:t}){const r=se(u=>{var o;return(o=u.session)==null?void 0:o.address}),{data:s,isLoading:l}=Te(r),c=r&&s?r:"default",h=t.category==="emote",[f,_]=n.useState("avatar"),d=!h&&f==="item",[N,a]=n.useState(!0);n.useEffect(()=>{a(!0)},[t.id,d]);const j=!!r&&!!s,y=j&&$e(t,We(s)),g=Ve(t)[0],P=j&&!y&&!h;return e.jsxs(e.Fragment,{children:[l?null:e.jsx(qe,{id:"shop-item-preview",contractAddress:t.contractAddress,tokenId:t.tokenId??void 0,itemId:t.tokenId?void 0:t.itemId??void 0,profile:d?void 0:y?c:"default",bodyShape:d||y?void 0:g,type:h?void 0:d?$.PreviewType.WEARABLE:$.PreviewType.AVATAR,emote:h||d?void 0:$.PreviewEmote.FASHION,disableBackground:!0,wheelZoom:h?1.5:void 0,wheelStart:h?100:void 0,dev:fe.chainId===80002,onLoad:()=>a(!1)},t.id),l||N?e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":"Loading preview",children:e.jsx("span",{className:"item-preview__spinner","aria-hidden":!0})}):null,P&&!d?e.jsxs("p",{className:"item-preview__note",children:["Shown on a ",Oe(g)," body — this item isn’t made for your avatar’s shape."]}):null,h?e.jsx("div",{className:"item-preview__emote-controls",children:e.jsx(va,{wearablePreviewId:"shop-item-preview",hideFrameInput:!0})}):e.jsxs("div",{className:"item-preview__toggle",role:"group","aria-label":"Preview mode",children:[e.jsxs("button",{type:"button",className:f==="avatar"?"is-active":"","aria-pressed":f==="avatar","aria-label":"On avatar",onClick:()=>_("avatar"),children:[e.jsxs("svg",{className:"item-preview__toggle-ico",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"7.5",r:"4"}),e.jsx("path",{d:"M4 20c0-4.2 3.6-6.5 8-6.5s8 2.3 8 6.5v.5H4z"})]}),e.jsx("span",{className:"item-preview__toggle-label",children:"On avatar"})]}),e.jsxs("button",{type:"button",className:f==="item"?"is-active":"","aria-pressed":f==="item","aria-label":"Item",onClick:()=>_("item"),children:[e.jsx("svg",{className:"item-preview__toggle-ico",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M8.5 3 3 6l1.8 3.8 2.2-1V21h10V8.8l2.2 1L22 6l-5.5-3a2.6 2.6 0 0 1-4.5 1.4A2.6 2.6 0 0 1 8.5 3z"})}),e.jsx("span",{className:"item-preview__toggle-label",children:"Item"})]})]})]})}function ga({title:t,items:r,onViewAll:s}){const l=n.useRef(null),[c,h]=n.useState(1),[f,_]=n.useState(0),[d,N]=n.useState(!0),[a,j]=n.useState(!1),y=n.useCallback(()=>{const u=l.current;if(!u)return;const{scrollLeft:o,scrollWidth:C,clientWidth:E}=u,w=Math.max(1,Math.ceil(C/E));h(w),_(Math.min(w-1,Math.round(o/E))),N(o<=1),j(o+E>=C-1)},[]);if(n.useEffect(()=>{y();const u=l.current;if(u)return u.addEventListener("scroll",y,{passive:!0}),window.addEventListener("resize",y),()=>{u.removeEventListener("scroll",y),window.removeEventListener("resize",y)}},[y,r.length]),r.length===0)return null;function g(u){const o=l.current;o&&o.scrollBy({left:u*o.clientWidth,behavior:"smooth"})}function P(u){const o=l.current;o&&o.scrollTo({left:u*o.clientWidth,behavior:"smooth"})}return e.jsxs("section",{className:"collection-carousel",children:[e.jsxs("div",{className:"collection-carousel__head",children:[e.jsx("h2",{className:"collection-carousel__title",children:t}),s?e.jsxs("button",{className:"collection-carousel__viewall",onClick:s,children:["View all",e.jsx("span",{className:"ico ico-chevron collection-carousel__viewall-ico","aria-hidden":!0})]}):null]}),e.jsxs("div",{className:"collection-carousel__viewport",children:[e.jsx("button",{className:"collection-carousel__arrow collection-carousel__arrow--left",onClick:()=>g(-1),"aria-label":"Scroll left",disabled:d,children:e.jsx("img",{src:me,alt:"","aria-hidden":!0})}),e.jsx("div",{className:"collection-carousel__track",ref:l,children:r.map(u=>e.jsx(ze,{item:u},u.id))}),e.jsx("button",{className:"collection-carousel__arrow collection-carousel__arrow--right",onClick:()=>g(1),"aria-label":"Scroll right",disabled:a,children:e.jsx("img",{src:me,alt:"","aria-hidden":!0})})]}),c>1?e.jsx("div",{className:"collection-carousel__dots","aria-label":"Carousel pages",children:Array.from({length:c}).map((u,o)=>e.jsx("button",{className:`collection-carousel__dot${o===f?" is-active":""}`,"aria-label":`Go to page ${o+1}`,"aria-current":o===f?"true":void 0,onClick:()=>P(o)},o))}):null]})}function Na({contractAddress:t,name:r,items:s,className:l}){const c=ae();if(!t||!r)return null;const h=(s??[]).map(d=>d.thumbnail).filter(d=>!!d).slice(0,4),f=h.slice(0,2),_=h.slice(2,4);return e.jsxs("button",{className:`creator creator--link${l?` ${l}`:""}`,onClick:d=>{d.stopPropagation(),c(`/collection/${t}`)},children:[h.length>0?e.jsxs("span",{className:"creator__ava collection-collage","aria-hidden":!0,children:[e.jsx("span",{className:`collection-collage__row${_.length===0?" collection-collage__row--full":""}`,children:f.map((d,N)=>e.jsx("img",{src:d,alt:""},N))}),_.length>0?e.jsx("span",{className:"collection-collage__row",children:_.map((d,N)=>e.jsx("img",{src:d,alt:""},N))}):null]}):null,e.jsx("span",{className:"creator__name",children:De(r)})]})}function wa(t){return Object.values($.Rarity).includes(t)}function Ca(t){return t==="male"?"Male":t==="female"?"Female":t==="unisex"?"Unisex":null}function ka(t){return t.wearableCategory?t.wearableCategory.replace(/_/g," "):t.category==="emote"?"Emote":"Wearable"}function Wa(){const{contractAddress:t,tokenId:r}=Ie(),{state:s}=Ae(),l=ae(),c=!!(s!=null&&s.market),h=(s==null?void 0:s.marketPriceCredits)??null,f=ue(i=>i.add),_=ue(i=>i.items),d=_e(i=>i.toggle),{session:N}=se(),[a,j]=n.useState(()=>s!=null&&s.item?{...s.item,tradeId:s.tradeId??s.item.tradeId}:{id:`${t}-${r}`,name:"",creator:"",contractAddress:t??"",itemId:null,category:"wearable",rarity:"common",network:"MATIC",chainId:fe.chainId,thumbnail:"",priceCredits:0,gender:null,isSmart:!1,tokenId:r??void 0,tradeId:s==null?void 0:s.tradeId}),[y,g]=n.useState(!1),[P,u]=n.useState(!!(s!=null&&s.resumeBuy));n.useEffect(()=>{s!=null&&s.resumeBuy&&g(!0)},[s==null?void 0:s.resumeBuy]);const{data:o=[],isFetched:C}=O({queryKey:["collection-items",a.contractAddress],enabled:!!a.contractAddress,queryFn:()=>sa(a.contractAddress,{first:20}).then(i=>i.items)}),E=a.available==null&&!a.tokenId,{data:w,isLoading:D}=O({queryKey:["shop-item",a.contractAddress,r],enabled:!c&&!!a.contractAddress&&!!r&&(!(s!=null&&s.item)||E),queryFn:()=>ta(a.contractAddress,r)});n.useEffect(()=>{w&&j(i=>i.tradeId?i.available!=null&&i.wearableCategory?i:{...i,available:i.available??w.available,wearableCategory:i.wearableCategory??w.wearableCategory}:{...w})},[w]);const[K,Y]=n.useState(!1),{data:W=""}=O({queryKey:["item-desc",a.contractAddress,a.itemId],enabled:!!a.contractAddress&&!!a.itemId,staleTime:5*6e4,queryFn:()=>ia(a.contractAddress,a.itemId)}),{data:I}=O({queryKey:["collection-meta",a.contractAddress],enabled:!!a.contractAddress,staleTime:5*6e4,queryFn:()=>ra(a.contractAddress)});n.useEffect(()=>{if(a.name||w||o.length===0)return;const i=r&&o.find(L=>L.tokenId===r||L.itemId===r)||o.find(L=>L.contractAddress===a.contractAddress);i&&j(L=>({...i,tradeId:L.tradeId??i.tradeId}))},[o,w]);const G=n.useMemo(()=>{const i=new Set,L=[];for(const M of o){if(M.id===a.id||a.itemId&&M.itemId===a.itemId||a.tokenId&&M.tokenId===a.tokenId)continue;const ce=`${M.contractAddress}-${M.itemId??M.tokenId??M.id}`;i.has(ce)||(i.add(ce),L.push(M))}return L},[o,a.id,a.itemId,a.tokenId]),{data:m,isLoading:v}=O({queryKey:["detail-trade",a.id,a.tradeId,a.contractAddress,a.itemId],enabled:!!a.contractAddress,queryFn:async()=>{if(a.tradeId)return a.tradeId;if(a.itemId){const i=await la(a.contractAddress,a.itemId);return(i==null?void 0:i.id)??null}return null}}),p=a.tradeId??m??void 0,b=!!p,{data:x}=pa(c),A=n.useMemo(()=>{if(!c||!(s!=null&&s.item))return null;const i=s.item;return i.manaWei?{tradeId:i.tradeId??i.id,listingType:"primary",contractAddress:i.contractAddress,itemId:i.itemId??"",name:i.name,thumbnail:i.thumbnail,rarity:i.rarity,category:i.category,wearableCategory:i.wearableCategory??null,creator:i.creator,manaWei:i.manaWei,available:1,network:i.network,chainId:i.chainId,createdAt:0}:null},[c,s==null?void 0:s.item]),R=c&&h!=null&&!!x&&!!A,B=Ke({priceCredits:a.priceCredits,compareAtCredits:a.compareAtCredits,saleEndsAt:a.saleEndsAt}),V=n.useMemo(()=>({...a,tradeId:p,id:p??a.id}),[a,p]),F=_.some(i=>i.id===V.id),k=_e(i=>!!i.items[a.id]),q=n.useRef(null);n.useEffect(()=>{!a.name||v||q.current===a.id||(q.current=a.id,z("Shop Viewed Item",{...Ye(a),for_sale:b}),Ge(a))},[a.id,a.name,v,b]);const U=`${t}/${r}`,te=n.useRef(U);n.useEffect(()=>{te.current!==U&&(te.current=U,s!=null&&s.item&&j({...s.item,tradeId:s.tradeId??s.item.tradeId}),typeof window<"u"&&window.scrollTo({top:0,behavior:"smooth"}))},[U]);function ve(){!b||F||H||f(V,"item_detail")}const Z=wa(a.rarity)?a.rarity:$.Rarity.COMMON,ie=Ca(a.gender),re=Ue(a),le=He(a.gender),je=b&&B,ge="More from this collection",H=Qe(a,N==null?void 0:N.address),ne=b?F?"In cart":v?"Checking…":"Add to cart":"Not for sale",Ne=typeof a.available=="number"&&a.available>0&&!a.tokenId&&!c,we=!H&&b&&!c,Ce=c||!H,ke=D||!!a.contractAddress&&!C;return!a.name&&!ke?e.jsxs("div",{className:"item-detail item-detail--notfound",children:[e.jsx("span",{className:"ico ico-cart item-detail__notfound-ico","aria-hidden":!0}),e.jsx("h1",{className:"item-detail__notfound-title",children:"This item isn’t available"}),e.jsx("p",{className:"muted",children:"It may have been delisted or moved. Browse Collectibles for something else."}),e.jsx("button",{className:"btn btn--purple",onClick:()=>l("/assets"),children:"Browse Collectibles"})]}):e.jsxs("div",{className:"item-detail",children:[e.jsxs("nav",{className:"item-detail__crumbs","aria-label":"Breadcrumb",children:[e.jsx("button",{className:"item-detail__crumb-link",onClick:()=>l("/assets"),children:"Collectibles"}),e.jsx("span",{className:"item-detail__crumb-sep",children:"/"}),e.jsx("span",{className:"item-detail__crumb-current",children:a.name||"Item"})]}),e.jsxs("div",{className:"item-detail__main",children:[e.jsxs("div",{className:"item-detail__preview",children:[a.name?e.jsx(ja,{item:a}):e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":"Loading preview",children:e.jsx("span",{className:"item-preview__spinner","aria-hidden":!0})}),e.jsx("button",{className:`item-detail__fav item-detail__fav--preview${k?" is-on":""}`,onClick:()=>d(a),"aria-pressed":k,"aria-label":k?"Remove from favorites":"Add to favorites",children:e.jsx("span",{className:`ico ${k?"ico-heart-solid":"ico-heart"}`,"aria-hidden":!0})})]}),e.jsxs("div",{className:"item-detail__info",children:[e.jsxs("div",{className:"item-detail__info-head",children:[e.jsx("h1",{className:"item-detail__title",children:a.name||"Loading…"}),e.jsx("button",{className:`item-detail__fav${k?" is-on":""}`,onClick:()=>d(a),"aria-pressed":k,"aria-label":k?"Remove from favorites":"Add to favorites",children:e.jsx("span",{className:`ico ${k?"ico-heart-solid":"ico-heart"}`,"aria-hidden":!0})})]}),e.jsxs("div",{className:"item-detail__chips",children:[e.jsx("span",{className:"chip chip--rarity",style:{background:Xe(Z),color:Ze(Z)},title:Je(a.rarity),children:a.rarity}),e.jsxs("span",{className:"chip item-detail__chip",children:[re?e.jsx("span",{className:`ico ico-${re} item-detail__chip-ico`,"aria-hidden":!0}):null,ka(a)]}),ie?e.jsxs("span",{className:"chip item-detail__chip",children:[le?e.jsx("span",{className:`ico ico-${le} item-detail__chip-ico`,"aria-hidden":!0}):null,ie]}):null]}),W?e.jsxs("div",{className:"item-detail__section item-detail__description",children:[e.jsx("div",{className:"item-detail__label",children:"Description"}),e.jsx("p",{className:`item-detail__desc-text${K?" is-expanded":""}`,children:W}),W.length>140?e.jsx("button",{className:"link item-detail__desc-toggle",onClick:()=>Y(i=>!i),children:K?"Show less":"Read more"}):null]}):null,a.creator||I!=null&&I.name?e.jsxs("div",{className:"item-detail__meta",children:[a.creator?e.jsxs("div",{className:"item-detail__meta-col",children:[e.jsx("div",{className:"item-detail__label",children:"Creator"}),e.jsx(ea,{address:a.creator,className:"item-detail__creator",linkToProfile:!0,hidePrefix:!0})]}):null,I!=null&&I.name?e.jsxs("div",{className:"item-detail__meta-col item-detail__meta-col--collection",children:[e.jsx("div",{className:"item-detail__label",children:"Collection"}),e.jsx(Na,{contractAddress:a.contractAddress,name:I.name,items:o,className:"item-detail__creator"})]}):null]}):null,e.jsx("hr",{className:"item-detail__divider"}),e.jsx("div",{className:"item-detail__price-block",children:e.jsxs("div",{className:"item-detail__price-row",children:[e.jsxs("div",{className:"item-detail__price-col",children:[e.jsx("div",{className:"item-detail__price-label",children:"Price"}),c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"item-detail__price item-detail__price--market",children:h==null?e.jsx("span",{className:"item-detail__price-value",children:"—"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"item-detail__approx","aria-hidden":!0,children:"≈"}),e.jsx(S,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:h})]})}),e.jsx("div",{className:"item-detail__market-note muted",children:"Market price"})]}):b?je?e.jsxs("div",{className:"item-detail__price item-detail__price--sale",children:[e.jsxs("span",{className:"item-detail__price",children:[e.jsx(S,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:a.priceCredits})]}),e.jsxs("span",{className:"item-detail__price-was",children:[e.jsx(S,{className:"item-detail__diamond item-detail__diamond--was"}),a.compareAtCredits]}),he(a.compareAtCredits,a.priceCredits)>0?e.jsxs("span",{className:"item-detail__sale-badge",children:["SALE -",he(a.compareAtCredits,a.priceCredits),"%"]}):null,e.jsx(aa,{endsAt:a.saleEndsAt,className:"item-detail__countdown"})]}):e.jsxs("div",{className:"item-detail__price",children:[e.jsx(S,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:a.priceCredits})]}):e.jsx("div",{className:"item-detail__price item-detail__price--none",children:"Not for sale"})]}),Ne?e.jsxs("div",{className:"item-detail__stock-col",children:[e.jsx("div",{className:"item-detail__price-label",children:"Stock"}),e.jsxs("div",{className:"item-detail__stock-value",children:[(a.available??0).toLocaleString(),"/",$.Rarity.getMaxSupply(Z).toLocaleString()]})]}):null]})}),e.jsx("div",{className:`item-detail__ctas${Ce?" item-detail__ctas--buttons":""}${we?" item-detail__ctas--dual":""}`,children:c?e.jsxs("button",{className:"btn btn--purple item-detail__cta",onClick:()=>g(!0),disabled:!R,children:[e.jsx("span",{className:"item-detail__cta-label",children:"Buy now"}),h!=null?e.jsxs("span",{className:"item-detail__cta-price","aria-hidden":!0,children:[e.jsx(S,{className:"item-detail__cta-diamond"}),h]}):null]}):H?e.jsxs("p",{className:"item-detail__own-note muted",children:["This is your item — manage it in ",e.jsx(Se,{to:"/my-assets",children:"My Assets"}),"."]}):e.jsxs(e.Fragment,{children:[b?e.jsxs("button",{className:"btn btn--purple item-detail__cta",onClick:()=>g(!0),disabled:v,children:[e.jsx("span",{className:"item-detail__cta-label",children:"Buy now"}),e.jsxs("span",{className:"item-detail__cta-price","aria-hidden":!0,children:[e.jsx(S,{className:"item-detail__cta-diamond"}),a.priceCredits]})]}):null,e.jsxs("button",{className:"item-detail__addcart",onClick:ve,disabled:!b||F||v,"aria-label":ne,children:[e.jsx("span",{className:"ico ico-cart-solid item-detail__addcart-ico","aria-hidden":!0}),e.jsx("span",{className:"item-detail__addcart-label",children:ne})]})]})})]})]}),e.jsx(ga,{title:ge,items:G,onViewAll:a.contractAddress?()=>l(`/collection/${a.contractAddress}`):void 0}),y&&c&&A&&x?e.jsx(ba,{listing:A,rate:x,onClose:()=>g(!1),onSold:()=>g(!1)}):y&&!c?e.jsx(ya,{item:V,resume:P,onClose:()=>{g(!1),u(!1)}}):null]})}export{Wa as ItemDetail,Wa as default};
@@ -1 +1 @@
1
- import{r as i,j as l}from"./react-C51i12iP.js";function a({hasNextPage:e,isFetching:r,onLoadMore:n}){const t=i.useRef(null);return i.useEffect(()=>{const s=t.current;if(!s||!e)return;const o=new IntersectionObserver(u=>{var c;(c=u[0])!=null&&c.isIntersecting&&!r&&n()},{rootMargin:"600px 0px"});return o.observe(s),()=>o.disconnect()},[e,r,n]),e?l.jsx("div",{className:"load-more",ref:t,children:l.jsx("button",{className:"btn btn--ghost",onClick:n,disabled:r,children:r?"Loading…":"Load more"})}):null}export{a as L};
1
+ import{r as i,j as l}from"./react-yytiy0wi.js";function a({hasNextPage:e,isFetching:r,onLoadMore:n}){const t=i.useRef(null);return i.useEffect(()=>{const s=t.current;if(!s||!e)return;const o=new IntersectionObserver(u=>{var c;(c=u[0])!=null&&c.isIntersecting&&!r&&n()},{rootMargin:"600px 0px"});return o.observe(s),()=>o.disconnect()},[e,r,n]),e?l.jsx("div",{className:"load-more",ref:t,children:l.jsx("button",{className:"btn btn--ghost",onClick:n,disabled:r,children:r?"Loading…":"Load more"})}):null}export{a as L};
@@ -0,0 +1 @@
1
+ import{d as B,h as F,b as Q,v as $,u as K,w as h,C as b,m as M,x as V,j,g as H,n as O,y as D,t as y,l as R,z as U}from"./index-DgPN63Jh.js";import{r as J,a as C}from"./mana-rate-DM_I1GlP.js";import{a as X,r as m,j as a}from"./react-yytiy0wi.js";import{b as q}from"./buy-D_7yggiZ.js";import{g as Z,b as ee,w as ae,S as re,G as te}from"./buy-gasless-DdXBIm99.js";function le(e=!0){return B({queryKey:["mana-rate",F.chainId],queryFn:()=>J(F.chainId),enabled:e,staleTime:6e4,refetchInterval:6e4,retry:1})}function L(e){const u=e,i=(u.message??"").toLowerCase();return u.code===4001||i.includes("reject")||i.includes("denied")||i.includes("cancel")?"You cancelled the request.":i.includes("insufficient")?`Not enough ${j.name} — get more first.`:i.includes("not found")||i.includes("no active listing")||i.includes("404")?"This item was just sold or removed. Refreshing the market…":i.includes("your own listing")?"You can't buy your own listing.":"Couldn't complete checkout — please try again."}function se(e){return{id:e.tradeId,tradeId:e.tradeId,name:e.name,creator:e.creator,contractAddress:e.contractAddress,itemId:e.itemId,category:e.category,wearableCategory:e.wearableCategory??void 0,rarity:e.rarity,network:e.network,chainId:e.chainId,thumbnail:e.thumbnail,priceCredits:0,gender:null,isSmart:!1}}function ue({listing:e,rate:u,onClose:i,onSold:T}){const{session:s}=Q(),{data:n,isError:W}=$(s),w=K(),N=X(),[g,p]=m.useState("confirm"),[k,I]=m.useState("Locking today’s price…"),[S,_]=m.useState(null),[r,Y]=m.useState(null),c=m.useRef(null),A=Math.ceil(C(e.manaWei,u)/10);m.useEffect(()=>{let o=!1;if(!s){p("error"),_("Sign in to check out.");return}return(async()=>{try{const t=await H(e.tradeId);if(!t)throw new Error("not found");if(O(t,s.address))throw new Error("You can't buy your own listing.");const l=C(e.manaWei,u);if(!Number.isFinite(l)||l<=0)throw new Error("price unavailable");const{credit:x,maxCreditedValue:z,usdCents:P}=await D(s.identity,l,e.tradeId);if(o){h(s.identity,[x.id]).catch(()=>{});return}c.current=x.id,Y({trade:t,credit:x,maxCreditedValue:z,usdCents:P,credits:Math.ceil(P/10)}),I("")}catch(t){if(o)return;console.error("[market] authorize failed",t),y(U(t)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:R(t),value_usd:Math.round(C(e.manaWei,u))/100}),p("error"),_(L(t))}})(),()=>{o=!0,c.current&&s&&(h(s.identity,[c.current]).catch(()=>{}),c.current=null)}},[]);const v=!!r&&n!=null&&n.credits<r.credits;async function G(){if(!s||!r)return;if(v){y("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:r.credits,credits_balance:(n==null?void 0:n.credits)??0,shortfall:Math.max(0,r.credits-((n==null?void 0:n.credits)??0))}),h(s.identity,[r.credit.id]).catch(()=>{}),c.current=null,N("/credits");return}p("working"),_(null);let o=!1;try{I("Confirming your purchase…");const d={trade:r.trade,buyer:s.address,signer:s.signer,credits:[r.credit],maxCreditedValue:r.maxCreditedValue};let t;if(Z())try{t=await ee(d),await ae(t),o=!0}catch(l){if(l instanceof re)o=!0;else if(l instanceof te)t=await q(d);else throw l}else t=await q(d);c.current=null,y("Shop Completed Purchase",{items:[{item_id:e.itemId??null,contract_address:e.contractAddress,token_id:null,price_usd:r.usdCents/100}],value_credits:r.credits,value_usd:r.usdCents/100,purchase_type:"item",is_primary:!0,payment_type:"credits",no_crypto_step:o,transaction_hash:t??null}),w.invalidateQueries({queryKey:["usd-balance"]}),N("/success",{state:{items:[se(e)],txHash:t}})}catch(d){console.error("[market] buy now failed",d),h(s.identity,[r.credit.id]).catch(()=>{}),c.current=null,y(U(d)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:R(d),value_usd:r.usdCents/100}),w.invalidateQueries({queryKey:["usd-balance"]});const t=L(d);_(t),p("error"),/sold or removed/i.test(t)&&T()}}function E(){s&&r&&h(s.identity,[r.credit.id]).catch(()=>{}),c.current=null,i()}const f=g==="working";return a.jsxs("div",{className:"mkt-modal",role:"dialog","aria-modal":"true","aria-label":`Buy ${e.name}`,children:[a.jsx("div",{className:"mkt-modal__scrim",onClick:f?void 0:E,"aria-hidden":!0}),a.jsxs("div",{className:"mkt-modal__card",children:[a.jsxs("div",{className:"mkt-modal__head",children:[a.jsx("div",{className:"mkt-modal__thumb",children:e.thumbnail?a.jsx("img",{src:e.thumbnail,alt:""}):null}),a.jsxs("div",{children:[a.jsx("div",{className:"mkt-modal__name",title:e.name,children:e.name||"Item"}),a.jsx("span",{className:"chip chip--rarity",children:e.rarity})]})]}),a.jsx("div",{className:"mkt-modal__price",children:r?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mkt-modal__price-label",children:"Final price"}),a.jsxs("div",{className:"mkt-modal__price-value",children:[a.jsx(b,{className:"mkt-modal__diamond"}),M(r.credits)]}),a.jsxs("div",{className:"mkt-modal__price-sub muted",children:["Locked for this purchase · $",(r.usdCents/100).toFixed(2)]})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mkt-modal__price-label",children:"Today’s price"}),a.jsxs("div",{className:"mkt-modal__price-value mkt-modal__price-value--approx",children:[a.jsx("span",{className:"mkt-modal__approx","aria-hidden":!0,children:"≈"}),a.jsx(b,{className:"mkt-modal__diamond"}),M(A)]}),a.jsx("div",{className:"mkt-modal__price-sub muted",children:k||"Locking today’s price…"})]})}),s?a.jsxs("div",{className:"mkt-modal__balance muted",children:["Your balance: ",a.jsx(b,{className:"ccy-mark"})," ",V(n,W)]}):null,v?a.jsxs("p",{className:"muted mkt-modal__note",children:["You’ll need a few more ",j.name," to buy this."]}):null,k&&g==="working"?a.jsx("p",{className:"muted mkt-modal__note",children:k}):null,S?a.jsx("p",{className:"error mkt-modal__note",children:S}):null,a.jsxs("div",{className:"mkt-modal__actions",children:[a.jsx("button",{className:"btn btn--ghost",onClick:E,disabled:f,children:"Cancel"}),a.jsx("button",{className:"btn btn--purple",onClick:()=>void G(),disabled:f||!r,children:f?"Buying…":v?`Get ${j.name}`:"Confirm purchase"})]})]})]})}export{ue as M,le as u};
@@ -0,0 +1 @@
1
+ import{a as U,r as d,j as s,L as re}from"./react-yytiy0wi.js";import{i as z,h as V,E as le,u as B,C as q,j as w,p as ee,t as P,ad as G,k as W,l as se,b as ce,d as D,aq as oe,g as de,ar as me}from"./index-DgPN63Jh.js";import{f as ue}from"./import-DM-iC_9y.js";import{c as he}from"./buy-D_7yggiZ.js";import{a as pe,b as ge,i as be,e as ye,c as xe}from"./trade-encoding-CWQaROcB.js";import{s as je}from"./wallet-kind-Jzl4cyiP.js";import{L as fe}from"./LoadMore-CiZkVzux.js";import{u as _e}from"./useInfiniteGrid-BwrFUhaa.js";import"./ethers-DArfy-QF.js";import"./mana-rate-DM_I1GlP.js";import"./index-B2Zw4G7Z.js";const F=()=>`${V.builderServerUrl}/v1`;function ae(e){return Array.isArray(e)?e:"results"in e&&Array.isArray(e.results)?e.results:"data"in e&&Array.isArray(e.data)?e.data:[]}async function ne(e,i){const n=await le(e,{method:"GET",identity:i,metadata:{}});if(!n.ok)throw new Error(`builder-server ${n.status}: ${await n.text()}`);const c=await n.json();return c.data??c}function Ne(e,i){const n=i-e;return n>0?n:0}function ve(e){var i,n,c,r,l;return((n=(i=e.data)==null?void 0:i.wearable)==null?void 0:n.category)??((r=(c=e.data)==null?void 0:c.emote)==null?void 0:r.category)??((l=e.data)==null?void 0:l.category)??e.type??"wearable"}function J(e){return`${F()}/storage/contents/${e}`}function $(e,i){if(!e)return"";if(/^https?:\/\//.test(e))return e;const n=i==null?void 0:i[e];return n?J(n):/^(ba|Qm)/.test(e)?J(e):""}async function Ie(e,i){try{const n=await fetch(`${F()}/items/${e}/${i}/contents`);if(!n.ok)return{};const c=await n.json();return c.data??c}catch{return{}}}async function ke(e,i,n){const c=$(e.thumbnail,e.contents)||$("thumbnail.png",e.contents);if(c)return c;if(i&&n){const r=await Ie(i,n);return $(e.thumbnail,r)||$("thumbnail.png",r)||$("image.png",r)}return""}async function Se(e,i){const n=`${F()}/${e.toLowerCase()}/collections?is_published=true`,c=await ne(n,i);return ae(c).filter(r=>r.is_published&&!!r.contract_address).map(r=>({id:r.id,name:r.name,contractAddress:r.contract_address.toLowerCase(),isPublished:r.is_published,isApproved:r.is_approved,minters:(r.minters??[]).map(l=>l.toLowerCase())}))}async function we(e,i){const n=`${F()}/collections/${e.id}/items`,c=await ne(n,i);return(await Promise.all(ae(c).map(async l=>{const v=l.rarity??"common",f=Number(l.total_supply??0)||0;let m;try{m=z.Rarity.getMaxSupply(v)}catch{m=0}const _=(l.contract_address??e.contractAddress).toLowerCase(),p=l.blockchain_item_id??"";return{id:l.id,collectionId:e.id,collectionName:e.name,contractAddress:_,blockchainItemId:p,name:l.name,category:ve(l),rarity:v,thumbnail:await ke(l,_,p),type:l.type??"wearable",isPublished:l.is_published??e.isPublished,isApproved:l.is_approved??e.isApproved,totalSupply:f,maxSupply:m,remainingSupply:Ne(f,m),minters:e.minters}}))).filter(Ce)}function Ce(e){return e.isPublished&&e.isApproved&&e.blockchainItemId!==""&&e.blockchainItemId!=null&&e.remainingSupply>0}async function Ae(e,i){const n=await Se(e,i);return(await Promise.all(n.map(async r=>{try{return await we(r,i)}catch{return[]}}))).flat()}const Pe=1e3*60*60*24*182;function $e(e){const i=e,n=(i.message??"").toLowerCase();return i.code===4001||n.includes("reject")||n.includes("denied")||n.includes("cancel")?"You cancelled the request.":"Couldn't list your item — please try again."}function Le({asset:e,session:i,onClose:n}){const c=B(),r=U(),[l,v]=d.useState("10"),[f,m]=d.useState(null),[_,p]=d.useState(null),[g,k]=d.useState(!1),[j,I]=d.useState(null);async function C(){p(null);const o=Number(l);if(!Number.isInteger(o)||o<=0){p("Enter a whole number of credits");return}k(!0);try{m("Getting your item ready…"),await pe({signer:i.signer,contractAddress:e.contractAddress,chainId:e.chainId}),m("Listing your item…");const N=await ge({signer:i.signer,nft:{contractAddress:e.contractAddress,tokenId:e.tokenId,network:e.network,chainId:e.chainId},usdPrice:o/10,expiresAtMs:Date.now()+Pe});m("Publishing…"),await ee(N,i.identity),m(null),I(o),P("Shop Listed Item",{item_id:e.itemId??e.tokenId??null,contract_address:e.contractAddress,price_credits:o,price_usd:o/10,listing_type:"secondary",is_primary:!1}),G.success(`“${e.name}” is now on sale!`),c.invalidateQueries({queryKey:["my-assets",i.address]})}catch(N){W(N,{flow:"list_secondary"}),P("Shop Listing Failed",{listing_type:"secondary",error_code:se(N)}),p($e(N)),m(null)}finally{k(!1)}}function x(){n(),r(`/item/${e.contractAddress}/${e.tokenId}`)}return j!==null?s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:"It’s on sale! 🎉"}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:["Listed for"," ",s.jsxs("strong",{children:[s.jsx(q,{className:"ccy-mark"})," ",j]})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,children:"Done"}),s.jsx("button",{className:"btn btn--purple",onClick:x,children:"View in Shop"})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsxs("h2",{className:"modal__title",children:["List “",e.name,"”"]}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsxs("label",{className:"field",children:[s.jsxs("span",{children:["Price (",w.name,")"]}),s.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:o=>v(o.target.value),disabled:g})]}),s.jsxs("p",{className:"muted small",children:["Priced in whole ",w.name," (1 ",w.nameSingular," = $0.10)."]}),f?s.jsx("p",{className:"muted",children:f}):null,_?s.jsx("p",{className:"error",children:_}):null,s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,disabled:g,children:"Cancel"}),s.jsx("button",{className:"btn",onClick:()=>void C(),disabled:g,children:g?"Listing…":"Put on sale"})]})]})})}const Ee=1e3*60*60*24*182;function Me(e){const i=e,n=(i.message??"").toLowerCase();return i.code===4001||n.includes("reject")||n.includes("denied")||n.includes("cancel")?"You cancelled the request.":"Couldn't publish your item — please try again."}function qe({item:e,session:i,onClose:n}){const c=B(),r=U(),[l,v]=d.useState("10"),[f,m]=d.useState(null),[_,p]=d.useState(null),[g,k]=d.useState(!1),[j,I]=d.useState(null),[C,x]=d.useState(null),o=V.chainId,N=je(i.providerType);d.useEffect(()=>{let u=!1;return(async()=>{try{const b=await be({contractAddress:e.contractAddress,chainId:o});u||I(b)}catch{u||I(!1)}})(),()=>{u=!0}},[e.contractAddress,o]);async function T(){p(null);const u=Number(l);if(!Number.isInteger(u)||u<=0){p("Enter a whole number of credits");return}k(!0);try{j||(m("Enabling sales for this collection…"),await ye({signer:i.signer,contractAddress:e.contractAddress,chainId:o}),I(!0)),m("Publishing your item…");const b=await xe({signer:i.signer,item:{contractAddress:e.contractAddress,itemId:e.blockchainItemId,network:z.Network.MATIC,chainId:o},usdPrice:u/10,uses:e.remainingSupply,expiresAtMs:Date.now()+Ee});m("Finishing up…"),await ee(b,i.identity),m(null),x(u),P("Shop Listed Item",{item_id:e.blockchainItemId,contract_address:e.contractAddress,price_credits:u,price_usd:u/10,listing_type:"primary",is_primary:!0}),G.success(`“${e.name}” is now on sale!`),c.invalidateQueries({queryKey:["publishable-items"]}),c.invalidateQueries({queryKey:["collection-sale-state"]})}catch(b){W(b,{flow:"list_primary"}),P("Shop Listing Failed",{listing_type:"primary",error_code:se(b)}),p(Me(b)),m(null)}finally{k(!1)}}function O(){n(),r(`/item/${e.contractAddress}/${e.blockchainItemId}`)}const L=g?"Listing…":j===!1?"Enable & put on sale":"Put on sale";return C!==null?s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:"It’s on sale! 🎉"}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:["Listed for"," ",s.jsxs("strong",{children:[s.jsx(q,{className:"ccy-mark"})," ",C]})," ","· ",e.remainingSupply.toLocaleString()," available"]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,children:"Done"}),s.jsx("button",{className:"btn btn--purple",onClick:O,children:"View in Shop"})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsxs("h2",{className:"modal__title",children:["Publish “",e.name,"”"]}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsxs("p",{className:"muted small",children:["From your collection “",e.collectionName,"” · ",e.remainingSupply.toLocaleString()," available"]}),s.jsxs("label",{className:"field",children:[s.jsxs("span",{children:["Price (",w.name,")"]}),s.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:u=>v(u.target.value),disabled:g})]}),s.jsxs("p",{className:"muted small",children:["Priced in whole ",w.name," (1 ",w.nameSingular," = $0.10)."]}),j===!1&&!g?N?s.jsxs("p",{className:"muted small primary-note",children:["First time selling from “",e.collectionName,"”? It needs a one-time approval, then you’ll confirm the listing — two quick confirmations. After this, listing more items from this collection is a single step."]}):s.jsxs("p",{className:"muted small primary-note",children:["First time selling from “",e.collectionName,"”? Setting it up takes a moment — after that, listing more items from this collection is instant."]}):j===!0&&!g?N?s.jsx("p",{className:"muted small primary-note",children:"This collection is ready — publishing is a single confirmation."}):s.jsx("p",{className:"muted small primary-note",children:"This collection is ready — publishing is instant."}):null,f?s.jsx("p",{className:"muted",children:f}):null,_?s.jsx("p",{className:"error",children:_}):null,s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,disabled:g,children:"Cancel"}),s.jsx("button",{className:"btn",onClick:()=>void T(),disabled:g||j===null,children:j===null?"Checking…":L})]})]})})}const Fe=48;function Te(e){return{id:e.id,name:e.name,creator:"",contractAddress:e.contractAddress,itemId:e.itemId,category:e.category,rarity:e.rarity??"common",network:e.network,chainId:e.chainId,thumbnail:e.image,priceCredits:e.listingPrice??0,gender:null,isSmart:!1,tokenId:e.tokenId}}function Z(e){return{id:`${e.contractAddress}-${e.blockchainItemId}`,name:e.name,creator:"",contractAddress:e.contractAddress,itemId:e.blockchainItemId,category:e.category,rarity:e.rarity,network:"MATIC",chainId:V.chainId,thumbnail:e.thumbnail,priceCredits:0,gender:null,isSmart:!1}}function He(){const{session:e,error:i,signIn:n,restore:c}=ce(),r=U(),l=B(),[v,f]=d.useState(null),[m,_]=d.useState(null),[p,g]=d.useState(null),[k,j]=d.useState(null);function I(a){const t=a.tokenId??a.itemId??"";!a.contractAddress||!t||r(`/item/${a.contractAddress}/${t}`,{state:{item:a}})}async function C(a,t,h){if(e){j(null),g(h);try{const y=await de(a);await he({trade:y,signer:e.signer}),G.success(`“${t}” is no longer for sale.`),await l.invalidateQueries({queryKey:["my-assets",e.address]}),await l.invalidateQueries({queryKey:["collection-sale-state"]})}catch(y){const E=y,M=(E.message??"").toLowerCase(),X=E.code===4001||M.includes("reject")||M.includes("denied");X||W(y,{flow:"remove-listing",tradeId:a}),j(X?"You cancelled the request.":"Couldn't remove the listing — please try again.")}finally{g(null)}}}d.useEffect(()=>{c()},[c]);const x=e==null?void 0:e.address,{items:o,isLoading:N,error:T,hasNextPage:O,isFetchingNextPage:L,fetchNextPage:u}=_e(["my-assets",x],a=>oe(x,{first:Fe,skip:a}).then(t=>({items:t.assets,total:t.total})),{enabled:!!x}),{data:b}=D({queryKey:["importable",x],queryFn:()=>ue(x),enabled:!!x}),R=((b==null?void 0:b.creations.length)??0)+((b==null?void 0:b.owned.length)??0),{data:A,isLoading:te,isError:ie}=D({queryKey:["publishable-items",x],queryFn:()=>Ae(x,e.identity),enabled:!!e,retry:!1}),K=d.useMemo(()=>[...new Set((A??[]).map(a=>a.contractAddress))],[A]),{data:S}=D({queryKey:["collection-sale-state",x,K],enabled:K.length>0,queryFn:async()=>{const a=await Promise.all(K.map(async h=>[h,await me(h)])),t={};for(const[h,y]of a)for(const[E,M]of Object.entries(y))t[`${h}-${E}`]=M;return t}}),Q=a=>S==null?void 0:S[`${a.contractAddress}-${a.blockchainItemId}`],Y=d.useMemo(()=>(A??[]).filter(a=>{var t;return(t=Q(a))==null?void 0:t.isOnSale}),[A,S]),H=d.useMemo(()=>{var t;const a=new Map;for(const h of A??[]){if((t=S==null?void 0:S[`${h.contractAddress}-${h.blockchainItemId}`])!=null&&t.isOnSale)continue;const y=a.get(h.collectionId)??{id:h.collectionId,name:h.collectionName,items:[]};y.items.push(h),a.set(h.collectionId,y)}return[...a.values()]},[A,S]);return e?s.jsxs("section",{className:"myassets",children:[s.jsx("h1",{children:"My Assets"}),R>0?s.jsxs(re,{className:"import-banner",to:"/import",children:[s.jsx("span",{className:"import-banner__ico","aria-hidden":!0,children:"📦"}),s.jsxs("span",{className:"import-banner__text",children:[s.jsx("strong",{children:"Import your listings"}),s.jsxs("span",{className:"import-banner__sub",children:["You have ",R," item",R===1?"":"s"," for sale elsewhere — bring them into the Shop."]})]}),s.jsx("span",{className:"import-banner__cta",children:"Import"})]}):null,s.jsxs("div",{className:"myassets__section",children:[s.jsxs("div",{className:"myassets__section-head",children:[s.jsx("h2",{className:"myassets__section-title",children:"Items you own"}),s.jsx("p",{className:"myassets__section-sub",children:"Wearables & emotes you’ve bought — resell them in the Shop."})]}),T?s.jsx("p",{className:"error",children:"Couldn’t load your items — please try again."}):null,k?s.jsx("p",{className:"error",children:k}):null,s.jsxs("div",{className:"asset-grid",children:[N?Array.from({length:8}).map((a,t)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`sk-${t}`)):o.map(a=>s.jsxs("article",{className:"asset-card asset-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":`View ${a.name}`,onClick:()=>I(Te(a))}),s.jsx("div",{className:"asset-card__img",children:a.image?s.jsx("img",{src:a.image,alt:a.name}):null}),s.jsx("div",{className:"asset-card__name",title:a.name,children:a.name}),a.isOnSale?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"asset-card__listed",children:[s.jsxs("span",{className:"asset-card__price",children:[s.jsx(q,{className:"ccy-mark"})," ",a.listingPrice]}),s.jsx("span",{className:"badge",children:"On sale"})]}),s.jsx("button",{className:"btn btn--sm btn--ghost asset-card__remove",disabled:p===a.id||!a.tradeId,onClick:t=>{t.stopPropagation(),a.tradeId&&C(a.tradeId,a.name,a.id)},children:p===a.id?"Removing…":"Remove listing"})]}):s.jsx("button",{className:"btn btn--sm",onClick:t=>{t.stopPropagation(),P("Shop Started Listing",{listing_type:"secondary",item_id:a.itemId??a.tokenId??null}),f(a)},children:"Put on sale"})]},a.id)),L?Array.from({length:4}).map((a,t)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`msk-${t}`)):null]}),s.jsx(fe,{hasNextPage:O,isFetching:L,onLoadMore:()=>void u()}),!N&&o.length===0?s.jsx("p",{className:"muted",children:"No items in your wardrobe yet."}):null]}),s.jsxs("div",{className:"myassets__section",children:[s.jsxs("div",{className:"myassets__section-head",children:[s.jsx("h2",{className:"myassets__section-title",children:"Your creations"}),s.jsxs("p",{className:"myassets__section-sub",children:["Items you made. Put them on sale in the Shop — set a price in ",w.name," and buyers pay with"," ",w.name,"."]})]}),te?s.jsx("div",{className:"publish-grid",children:Array.from({length:4}).map((a,t)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`pub-sk-${t}`))}):ie?s.jsx("p",{className:"publish-empty",children:"We couldn’t load your collections right now. Please try again in a moment."}):Y.length===0&&H.length===0?s.jsx("p",{className:"publish-empty",children:"You don’t have any items to publish yet."}):s.jsxs(s.Fragment,{children:[Y.length>0?s.jsxs("div",{className:"creations-collection",children:[s.jsx("h3",{className:"creations-collection__name",children:"On sale"}),s.jsx("div",{className:"publish-grid",children:Y.map(a=>{var t;return s.jsxs("article",{className:"publish-card publish-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":`View ${a.name}`,onClick:()=>I(Z(a))}),s.jsx("div",{className:"publish-card__img",children:a.thumbnail?s.jsx("img",{src:a.thumbnail,alt:a.name}):null}),s.jsx("div",{className:"publish-card__name",title:a.name,children:a.name}),s.jsxs("div",{className:"publish-card__listed",children:[s.jsxs("span",{className:"publish-card__price",children:[s.jsx(q,{className:"ccy-mark"})," ",((t=Q(a))==null?void 0:t.priceCredits)??0]}),s.jsx("span",{className:"badge",children:"On sale"})]}),s.jsx("button",{className:"btn btn--sm btn--ghost publish-card__cta",disabled:p===a.id,onClick:h=>{h.stopPropagation();const y=Q(a);y!=null&&y.tradeId&&C(y.tradeId,a.name,a.id)},children:p===a.id?"Removing…":"Remove listing"})]},`${a.contractAddress}-${a.blockchainItemId}`)})})]}):null,H.map(a=>s.jsxs("div",{className:"creations-collection",children:[s.jsx("h3",{className:"creations-collection__name",children:a.name}),s.jsx("div",{className:"publish-grid",children:a.items.map(t=>s.jsxs("article",{className:"publish-card publish-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":`View ${t.name}`,onClick:()=>I(Z(t))}),s.jsx("div",{className:"publish-card__img",children:t.thumbnail?s.jsx("img",{src:t.thumbnail,alt:t.name}):null}),s.jsx("div",{className:"publish-card__name",title:t.name,children:t.name}),s.jsxs("div",{className:"publish-card__meta",children:[s.jsx("span",{className:"publish-chip publish-chip--rarity",children:t.rarity}),s.jsxs("span",{className:"publish-card__supply",children:[t.remainingSupply.toLocaleString()," available"]})]}),s.jsx("button",{className:"btn btn--sm btn--purple publish-card__cta",onClick:h=>{h.stopPropagation(),P("Shop Started Listing",{listing_type:"primary",item_id:t.blockchainItemId}),_(t)},children:"Put on sale"})]},`${t.contractAddress}-${t.blockchainItemId}`))})]},a.id))]})]}),v?s.jsx(Le,{asset:v,session:e,onClose:()=>f(null)}):null,m?s.jsx(qe,{item:m,session:e,onClose:()=>_(null)}):null]}):s.jsxs("section",{className:"myassets",children:[s.jsx("h1",{children:"My Assets"}),s.jsx("p",{className:"muted",children:"Sign in to sell your items."}),s.jsx("div",{className:"connect-row",children:s.jsx("button",{className:"btn btn--purple",onClick:()=>n(),children:"Sign in"})}),i?s.jsx("p",{className:"error",children:i}):null]})}export{He as MyAssets};
@@ -1 +1 @@
1
- import{r as o,j as s,L as n}from"./react-C51i12iP.js";import{u as c,A as l}from"./index-C1u3RQ96.js";import{L as m}from"./LoadMore-DsKzH4Rv.js";import"./ethers-DwWf2RqE.js";const i=24;function v(){const t=c(e=>Object.values(e.items)),[a,r]=o.useState(i);return t.length===0?s.jsxs("div",{className:"favorites-empty",children:[s.jsx("span",{className:"ico ico-heart favorites-empty__ico","aria-hidden":!0}),s.jsx("p",{className:"favorites-empty__title",children:"No favorites yet"}),s.jsx("p",{className:"muted",children:"Tap the heart on any item to save it here."}),s.jsx(n,{className:"btn btn--purple",to:"/assets",children:"Browse Collectibles"})]}):s.jsxs("section",{className:"favorites",children:[s.jsxs("div",{className:"favorites__head",children:[s.jsx("h1",{children:"My Favorites"}),s.jsxs("span",{className:"favorites__count",children:[t.length," item",t.length>1?"s":""]})]}),s.jsx("div",{className:"grid",children:t.slice(0,a).map(e=>s.jsx(l,{item:e},e.id))}),s.jsx(m,{hasNextPage:a<t.length,isFetching:!1,onLoadMore:()=>r(e=>e+i)})]})}export{v as MyFavorites};
1
+ import{r as o,j as s,L as n}from"./react-yytiy0wi.js";import{a as c,A as l}from"./index-DgPN63Jh.js";import{L as m}from"./LoadMore-CiZkVzux.js";import"./ethers-DArfy-QF.js";const i=24;function v(){const t=c(e=>Object.values(e.items)),[a,r]=o.useState(i);return t.length===0?s.jsxs("div",{className:"favorites-empty",children:[s.jsx("span",{className:"ico ico-heart favorites-empty__ico","aria-hidden":!0}),s.jsx("p",{className:"favorites-empty__title",children:"No favorites yet"}),s.jsx("p",{className:"muted",children:"Tap the heart on any item to save it here."}),s.jsx(n,{className:"btn btn--purple",to:"/assets",children:"Browse Collectibles"})]}):s.jsxs("section",{className:"favorites",children:[s.jsxs("div",{className:"favorites__head",children:[s.jsx("h1",{children:"My Favorites"}),s.jsxs("span",{className:"favorites__count",children:[t.length," item",t.length>1?"s":""]})]}),s.jsx("div",{className:"grid",children:t.slice(0,a).map(e=>s.jsx(l,{item:e},e.id))}),s.jsx(m,{hasNextPage:a<t.length,isFetching:!1,onLoadMore:()=>r(e=>e+i)})]})}export{v as MyFavorites};
@@ -1 +1 @@
1
- import{j as e,L as o}from"./react-C51i12iP.js";import{a as l,f as u,b as m,C as p,c as x}from"./index-C1u3RQ96.js";import{L as _}from"./LoadMore-DsKzH4Rv.js";import{u as j}from"./useInfiniteGrid-CjcJxtXA.js";import"./ethers-DwWf2RqE.js";const N=24;function g(s){try{return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function f({status:s}){return s==="PENDING"?e.jsx("span",{className:"purchase__badge purchase__badge--pending",children:"Processing"}):e.jsx("span",{className:"purchase__badge purchase__badge--done",children:"Completed"})}function y({purchase:s}){const{data:a}=m({queryKey:["trade-display",s.tradeId],queryFn:()=>x(s.tradeId),enabled:!!s.tradeId,staleTime:3e5}),t=(a==null?void 0:a.name)??"Item",i=(a==null?void 0:a.thumbnail)??"",n=(a==null?void 0:a.tokenId)??(a==null?void 0:a.itemId)??"",d=a!=null&&a.contractAddress&&n?`/item/${a.contractAddress}/${n}`:void 0,c=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"purchase__thumb",children:i?e.jsx("img",{src:i,alt:t}):null}),e.jsxs("div",{className:"purchase__info",children:[e.jsx("div",{className:"purchase__name",title:t,children:t}),e.jsx("div",{className:"muted purchase__date",children:g(s.createdAt)})]}),e.jsx(f,{status:s.status}),e.jsxs("div",{className:"purchase__price",children:[e.jsx(p,{className:"ccy-mark"})," ",s.credits]})]});return d?e.jsx(o,{className:"purchase",to:d,children:c}):e.jsx("div",{className:"purchase",children:c})}function A(){const{session:s}=l(),{items:a,isLoading:t,hasNextPage:i,isFetchingNextPage:n,fetchNextPage:d}=j(["purchases",s==null?void 0:s.address],r=>u(s.address,s.identity,{first:N,skip:r}),{enabled:!!s});if(!s)return e.jsxs("div",{className:"purchases-empty",children:[e.jsx("span",{className:"ico ico-cart purchases-empty__ico","aria-hidden":!0}),e.jsx("p",{className:"purchases-empty__title",children:"Sign in to see your purchases"}),e.jsx("p",{className:"muted",children:"Your order history shows up here once you sign in."})]});const c=a.filter(r=>r.status!=="EXPIRED");return!t&&c.length===0?e.jsxs("div",{className:"purchases-empty",children:[e.jsx("span",{className:"ico ico-cart purchases-empty__ico","aria-hidden":!0}),e.jsx("p",{className:"purchases-empty__title",children:"No purchases yet"}),e.jsx("p",{className:"muted",children:"When you buy something it’ll appear here."}),e.jsx(o,{className:"btn btn--purple",to:"/assets",children:"Browse Collectibles"})]}):e.jsxs("section",{className:"purchases",children:[e.jsxs("div",{className:"purchases__head",children:[e.jsx("h1",{children:"My Purchases"}),t?null:e.jsxs("span",{className:"purchases__count",children:[c.length," order",c.length>1?"s":""]})]}),e.jsx("div",{className:"purchases__list",children:t?Array.from({length:4}).map((r,h)=>e.jsx("div",{className:"purchase purchase--skeleton"},h)):e.jsxs(e.Fragment,{children:[c.map(r=>e.jsx(y,{purchase:r},r.id)),n?Array.from({length:2}).map((r,h)=>e.jsx("div",{className:"purchase purchase--skeleton"},`m-${h}`)):null]})}),e.jsx(_,{hasNextPage:i,isFetching:n,onLoadMore:()=>void d()})]})}export{A as MyPurchases};
1
+ import{j as e,L as o}from"./react-yytiy0wi.js";import{b as l,c as u,d as m,C as p,e as x}from"./index-DgPN63Jh.js";import{L as _}from"./LoadMore-CiZkVzux.js";import{u as j}from"./useInfiniteGrid-BwrFUhaa.js";import"./ethers-DArfy-QF.js";const N=24;function g(s){try{return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function f({status:s}){return s==="PENDING"?e.jsx("span",{className:"purchase__badge purchase__badge--pending",children:"Processing"}):e.jsx("span",{className:"purchase__badge purchase__badge--done",children:"Completed"})}function y({purchase:s}){const{data:a}=m({queryKey:["trade-display",s.tradeId],queryFn:()=>x(s.tradeId),enabled:!!s.tradeId,staleTime:3e5}),t=(a==null?void 0:a.name)??"Item",i=(a==null?void 0:a.thumbnail)??"",n=(a==null?void 0:a.tokenId)??(a==null?void 0:a.itemId)??"",d=a!=null&&a.contractAddress&&n?`/item/${a.contractAddress}/${n}`:void 0,c=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"purchase__thumb",children:i?e.jsx("img",{src:i,alt:t}):null}),e.jsxs("div",{className:"purchase__info",children:[e.jsx("div",{className:"purchase__name",title:t,children:t}),e.jsx("div",{className:"muted purchase__date",children:g(s.createdAt)})]}),e.jsx(f,{status:s.status}),e.jsxs("div",{className:"purchase__price",children:[e.jsx(p,{className:"ccy-mark"})," ",s.credits]})]});return d?e.jsx(o,{className:"purchase",to:d,children:c}):e.jsx("div",{className:"purchase",children:c})}function A(){const{session:s}=l(),{items:a,isLoading:t,hasNextPage:i,isFetchingNextPage:n,fetchNextPage:d}=j(["purchases",s==null?void 0:s.address],r=>u(s.address,s.identity,{first:N,skip:r}),{enabled:!!s});if(!s)return e.jsxs("div",{className:"purchases-empty",children:[e.jsx("span",{className:"ico ico-cart purchases-empty__ico","aria-hidden":!0}),e.jsx("p",{className:"purchases-empty__title",children:"Sign in to see your purchases"}),e.jsx("p",{className:"muted",children:"Your order history shows up here once you sign in."})]});const c=a.filter(r=>r.status!=="EXPIRED");return!t&&c.length===0?e.jsxs("div",{className:"purchases-empty",children:[e.jsx("span",{className:"ico ico-cart purchases-empty__ico","aria-hidden":!0}),e.jsx("p",{className:"purchases-empty__title",children:"No purchases yet"}),e.jsx("p",{className:"muted",children:"When you buy something it’ll appear here."}),e.jsx(o,{className:"btn btn--purple",to:"/assets",children:"Browse Collectibles"})]}):e.jsxs("section",{className:"purchases",children:[e.jsxs("div",{className:"purchases__head",children:[e.jsx("h1",{children:"My Purchases"}),t?null:e.jsxs("span",{className:"purchases__count",children:[c.length," order",c.length>1?"s":""]})]}),e.jsx("div",{className:"purchases__list",children:t?Array.from({length:4}).map((r,h)=>e.jsx("div",{className:"purchase purchase--skeleton"},h)):e.jsxs(e.Fragment,{children:[c.map(r=>e.jsx(y,{purchase:r},r.id)),n?Array.from({length:2}).map((r,h)=>e.jsx("div",{className:"purchase purchase--skeleton"},`m-${h}`)):null]})}),e.jsx(_,{hasNextPage:i,isFetching:n,onLoadMore:()=>void d()})]})}export{A as MyPurchases};
@@ -1,4 +1,4 @@
1
- import{p as ee}from"./ethers-DwWf2RqE.js";const ae="2.54.1";let T={getDocsUrl:({docsBaseUrl:r,docsPath:e="",docsSlug:t})=>e?`${r??"https://viem.sh"}${e}${t?`#${t}`:""}`:void 0,version:`viem@${ae}`};class o extends Error{constructor(e,t={}){var p;const n=(()=>{var u;return t.cause instanceof o?t.cause.details:(u=t.cause)!=null&&u.message?t.cause.message:t.details})(),a=t.cause instanceof o&&t.cause.docsPath||t.docsPath,s=(p=T.getDocsUrl)==null?void 0:p.call(T,{...t,docsPath:a}),i=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...T.version?[`Version: ${T.version}`]:[]].join(`
1
+ import{p as ee}from"./ethers-DArfy-QF.js";const ae="2.54.1";let T={getDocsUrl:({docsBaseUrl:r,docsPath:e="",docsSlug:t})=>e?`${r??"https://viem.sh"}${e}${t?`#${t}`:""}`:void 0,version:`viem@${ae}`};class o extends Error{constructor(e,t={}){var p;const n=(()=>{var u;return t.cause instanceof o?t.cause.details:(u=t.cause)!=null&&u.message?t.cause.message:t.details})(),a=t.cause instanceof o&&t.cause.docsPath||t.docsPath,s=(p=T.getDocsUrl)==null?void 0:p.call(T,{...t,docsPath:a}),i=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...T.version?[`Version: ${T.version}`]:[]].join(`
2
2
  `);super(i,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=a,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=ae}walk(e){return se(this,e)}}function se(r,e){return e!=null&&e(r)?r:r&&typeof r=="object"&&"cause"in r&&r.cause!==void 0?se(r.cause,e):e?null:r}class oe extends o{constructor({max:e,min:t,signed:n,size:a,value:s}){super(`Number "${s}" is not in safe ${a?`${a*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class Ke extends o{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class fe extends o{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}class me extends o{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function ie(r,{strict:e=!0}={}){return!r||typeof r!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(r):r.startsWith("0x")}function te(r){return ie(r,{strict:!1})?Math.ceil((r.length-2)/2):r.length}function v(r,{dir:e="left"}={}){let t=typeof r=="string"?r.replace("0x",""):r,n=0;for(let a=0;a<t.length-1&&t[e==="left"?a:t.length-a-1].toString()==="0";a++)n++;return t=e==="left"?t.slice(n):t.slice(0,t.length-n),typeof r=="string"?(t.length===1&&e==="right"&&(t=`${t}0`),`0x${t.length%2===1?`0${t}`:t}`):t}class Ve extends o{constructor({offset:e,position:t,size:n}){super(`Slice ${t==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class ue extends o{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}class Ye extends o{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${t} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function g(r,{dir:e,size:t=32}={}){return typeof r=="string"?he(r,{dir:e,size:t}):ye(r,{dir:e,size:t})}function he(r,{dir:e,size:t=32}={}){if(t===null)return r;const n=r.replace("0x","");if(n.length>t*2)throw new ue({size:Math.ceil(n.length/2),targetSize:t,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](t*2,"0")}`}function ye(r,{dir:e,size:t=32}={}){if(t===null)return r;if(r.length>t)throw new ue({size:r.length,targetSize:t,type:"bytes"});const n=new Uint8Array(t);for(let a=0;a<t;a++){const s=e==="right";n[s?a:t-a-1]=r[s?a:r.length-a-1]}return n}const ge=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Xe(r,e={}){return typeof r=="number"||typeof r=="bigint"?le(r,e):typeof r=="string"?Te(r,e):typeof r=="boolean"?Ee(r,e):ce(r,e)}function Ee(r,e={}){const t=`0x${Number(r)}`;return typeof e.size=="number"?(y(t,{size:e.size}),g(t,{size:e.size})):t}function ce(r,e={}){let t="";for(let a=0;a<r.length;a++)t+=ge[r[a]];const n=`0x${t}`;return typeof e.size=="number"?(y(n,{size:e.size}),g(n,{dir:"right",size:e.size})):n}function le(r,e={}){const{signed:t,size:n}=e,a=BigInt(r);let s;n?t?s=(1n<<BigInt(n)*8n-1n)-1n:s=2n**(BigInt(n)*8n)-1n:typeof r=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const i=typeof s=="bigint"&&t?-s-1n:0;if(s&&a>s||a<i){const u=typeof r=="bigint"?"n":"";throw new oe({max:s?`${s}${u}`:void 0,min:`${i}${u}`,signed:t,size:n,value:`${r}${u}`})}const p=`0x${(t&&a<0?(1n<<BigInt(n*8))+BigInt(a):a).toString(16)}`;return n?g(p,{size:n}):p}const Ne=new TextEncoder;function Te(r,e={}){const t=Ne.encode(r);return ce(t,e)}const ve=new TextEncoder;function Je(r,e={}){return typeof r=="number"||typeof r=="bigint"?Oe(r,e):typeof r=="boolean"?we(r,e):ie(r)?O(r,e):Ae(r,e)}function we(r,e={}){const t=new Uint8Array(1);return t[0]=Number(r),typeof e.size=="number"?(y(t,{size:e.size}),g(t,{size:e.size})):t}const m={zero:48,nine:57,A:65,F:70,a:97,f:102};function re(r){if(r>=m.zero&&r<=m.nine)return r-m.zero;if(r>=m.A&&r<=m.F)return r-(m.A-10);if(r>=m.a&&r<=m.f)return r-(m.a-10)}function O(r,e={}){let t=r;e.size&&(y(t,{size:e.size}),t=g(t,{dir:"right",size:e.size}));let n=t.slice(2);n.length%2&&(n=`0${n}`);const a=n.length/2,s=new Uint8Array(a);for(let i=0,p=0;i<a;i++){const u=re(n.charCodeAt(p++)),E=re(n.charCodeAt(p++));if(u===void 0||E===void 0)throw new o(`Invalid byte sequence ("${n[p-2]}${n[p-1]}" in "${n}").`);s[i]=u*16+E}return s}function Oe(r,e){const t=le(r,e);return O(t)}function Ae(r,e={}){const t=ve.encode(r);return typeof e.size=="number"?(y(t,{size:e.size}),g(t,{dir:"right",size:e.size})):t}function y(r,{size:e}){if(te(r)>e)throw new me({givenSize:te(r),maxSize:e})}function Qe(r,e){const t={to:e},n=t.to;return n==="number"?Me(r,t):n==="bigint"?de(r,t):n==="string"?Ce(r,t):n==="boolean"?xe(r,t):O(r,t)}function de(r,e={}){const{signed:t}=e;e.size&&y(r,{size:e.size});const n=BigInt(r);if(!t)return n;const a=(r.length-2)/2,s=(1n<<BigInt(a)*8n-1n)-1n;return n<=s?n:n-BigInt(`0x${"f".padStart(a*2,"f")}`)-1n}function xe(r,e={}){let t=r;if(e.size&&(y(t,{size:e.size}),t=v(t)),v(t)==="0x00")return!1;if(v(t)==="0x01")return!0;throw new fe(t)}function Me(r,e={}){const t=de(r,e),n=Number(t);if(!Number.isSafeInteger(n))throw new oe({max:`${Number.MAX_SAFE_INTEGER}`,min:`${Number.MIN_SAFE_INTEGER}`,signed:e.signed,size:e.size,value:`${t}n`});return n}function Ce(r,e={}){let t=O(r);return e.size&&(y(t,{size:e.size}),t=v(t,{dir:"right"})),new TextDecoder().decode(t)}const Ze={gwei:9,wei:18},Re={ether:-9,wei:9};function Se(r,e){let t=r.toString();const n=t.startsWith("-");n&&(t=t.slice(1)),t=t.padStart(e,"0");let[a,s]=[t.slice(0,t.length-e),t.slice(t.length-e)];return s=s.replace(/(0+)$/,""),`${n?"-":""}${a||"0"}${s?`.${s}`:""}`}function w(r,e="wei"){return Se(r,Re[e])}class pe extends o{constructor({cause:e,message:t}={}){var a;const n=(a=t==null?void 0:t.replace("execution reverted: ",""))==null?void 0:a.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(pe,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(pe,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class Pe extends o{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${w(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Pe,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class _e extends o{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${w(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(_e,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class Ie extends o{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(Ie,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class $e extends o{constructor({cause:e,nonce:t}={}){super([`Nonce provided for the transaction ${t?`(${t}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
3
3
  `),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty($e,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class Ue extends o{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(Ue,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class De extends o{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
4
4
  `),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(De,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class je extends o{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(je,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Le extends o{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(Le,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class ze extends o{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(ze,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Be extends o{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${w(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${w(n)} gwei`:""}).`].join(`
@@ -1 +1 @@
1
- import{j as t,L as n}from"./react-C51i12iP.js";import{t as o}from"./index-C1u3RQ96.js";import"./ethers-DwWf2RqE.js";function i(){return t.jsxs("div",{className:"notfound",children:[t.jsx("span",{className:"ico ico-cart notfound__ico","aria-hidden":!0}),t.jsx("h1",{className:"notfound__title",children:o("notFound.title")}),t.jsx("p",{className:"muted",children:o("notFound.body")}),t.jsx(n,{className:"btn btn--purple",to:"/assets",children:o("notFound.cta")})]})}export{i as NotFound,i as default};
1
+ import{j as t,L as n}from"./react-yytiy0wi.js";import{q as o}from"./index-DgPN63Jh.js";import"./ethers-DArfy-QF.js";function i(){return t.jsxs("div",{className:"notfound",children:[t.jsx("span",{className:"ico ico-cart notfound__ico","aria-hidden":!0}),t.jsx("h1",{className:"notfound__title",children:o("notFound.title")}),t.jsx("p",{className:"muted",children:o("notFound.body")}),t.jsx(n,{className:"btn btn--purple",to:"/assets",children:o("notFound.cta")})]})}export{i as NotFound,i as default};
@@ -1 +1 @@
1
- import{j as s,u as U,r as i,L as W}from"./react-C51i12iP.js";import{a as X,n as Z,t as a,ae as T}from"./index-C1u3RQ96.js";import{u as ee,d as se,t as te,L as ae,i as I,a as v,s as re}from"./useStore-zhFVY9fU.js";import"./ethers-DwWf2RqE.js";const ne="https://cdn.decentraland.org/@dcl/shop/0.1.0-29571500722.commit-8ea45d8/assets/template-cover-1-BETekfHg.jpeg",ie="https://cdn.decentraland.org/@dcl/shop/0.1.0-29571500722.commit-8ea45d8/assets/template-cover-2-Dni9s0i_.jpeg",oe=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ne,"../assets/creator-covers/template-cover-2.jpeg":ie}),h=Object.entries(oe).sort(([r],[d])=>r.localeCompare(d)).map(([r,d])=>({name:r.split("/").pop(),url:d}));function le({label:r,size:d="medium",direction:b="column",className:f}){return s.jsxs("div",{className:`spinner-box spinner-box--${b}${f?` ${f}`:""}`,role:"status","aria-live":"polite","aria-label":r?void 0:"Loading",children:[s.jsx("span",{className:`spinner-box__ring spinner-box__ring--${d}`,"aria-hidden":!0}),r?s.jsx("span",{className:"spinner-box__label",children:r}):null]})}const M=1e6,O={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function R(r){return`${(r/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function ge(){const{session:r,signIn:d}=X(),b=U(),f=Z(),c=r==null?void 0:r.address,{data:x,isLoading:z}=ee(c),[n,u]=i.useState(O),[E,w]=i.useState(O),[j,g]=i.useState(),[p,C]=i.useState(!1),[o,N]=i.useState(null),[_,A]=i.useState({}),L=i.useRef(null);i.useEffect(()=>{if(x){const e=se(x);u(e),w(e),g(void 0),N(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[x]),i.useEffect(()=>{let e=!1;return Promise.all(h.map(async t=>[t.name,await te(t.url)])).then(t=>{e||A(Object.fromEntries(t))}).catch(()=>{}),()=>{e=!0}},[]);const S=i.useMemo(()=>{const e=h.find(l=>n.coverName===`cover/${l.name}`);if(e)return e.name;const t=n.coverHash?h.find(l=>_[l.name]===n.coverHash):void 0;return t==null?void 0:t.name},[n.coverName,n.coverHash,_]);i.useEffect(()=>{o!=null&&o.hash&&h.some(e=>_[e.name]===o.hash)&&N(null)},[_,o]);const $=j!==void 0&&j>M,D=i.useMemo(()=>ae.filter(e=>!I(e,n.links[e])),[n.links]),P=$||D.length>0,k=i.useMemo(()=>JSON.stringify(n)!==JSON.stringify(E),[n,E]),F=k&&!P&&!p;if(i.useEffect(()=>{if(!k)return;const e=t=>{t.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[k]),!r)return s.jsxs("section",{className:"store-settings store-settings--signin","aria-label":a("storeSettings.title"),children:[s.jsx("h1",{className:"store-settings__title",children:a("storeSettings.title")}),s.jsx("p",{className:"muted",children:a("storeSettings.signInPrompt")}),s.jsx("button",{className:"btn btn--purple store-settings__signin-btn",onClick:d,children:a("storeSettings.signIn")})]});function B(e,t){g(void 0),u(l=>({...l,cover:t,coverName:`cover/${e}`,coverHash:""}))}const V=["image/png","image/jpeg","image/webp"];function Y(e){var y;const t=(y=e.target.files)==null?void 0:y[0];if(!t||!V.includes(t.type))return;g(t.size);const l=`cover/${t.name}`,m=new FileReader;m.onload=()=>{const H=m.result;N({url:H,name:l,hash:""}),u(Q=>({...Q,cover:H,coverName:l,coverHash:""}))},m.readAsDataURL(t)}function K(){o&&(g(void 0),u(e=>({...e,cover:o.url,coverName:o.name,coverHash:o.hash})))}function q(e,t){const l=t?(v[e]+t).replace(/\s/g,""):"";u(m=>({...m,links:{...m.links,[e]:l}}))}function G(e){const t=n.links[e];return e==="website"?t:t.replace(v[e],"")}async function J(){if(!(!c||!r)){C(!0);try{await re(c,n,r.identity),w(n),g(void 0),await f.invalidateQueries({queryKey:["store",c.toLowerCase()]}),T.success(a("storeSettings.saved")),b(`/assets/creator/${c}`)}catch{T.error(a("storeSettings.saveError"))}finally{C(!1)}}}return s.jsxs("section",{className:"store-settings","aria-label":a("storeSettings.title"),children:[s.jsxs("div",{className:"store-settings__head",children:[s.jsxs("div",{className:"store-settings__heading",children:[c?s.jsx(W,{className:"store-settings__back",to:`/assets/creator/${c}`,title:a("storeSettings.back"),"aria-label":a("storeSettings.back"),children:s.jsx("span",{className:"ico ico-arrow-left","aria-hidden":!0})}):null,s.jsx("h1",{className:"store-settings__title",children:a("storeSettings.title")})]}),c?s.jsxs("a",{className:"store-settings__guest",href:`/assets/creator/${c}`,target:"_blank",rel:"noopener noreferrer",children:[a("storeSettings.seeAsGuest"),s.jsx("span",{className:"ico ico-external","aria-hidden":!0})]}):null]}),z?s.jsx(le,{size:"large",label:a("storeSettings.loading"),className:"store-settings__loading"}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.cover")}),s.jsxs("div",{className:"cover-picker",role:"group","aria-label":a("storeSettings.cover"),children:[h.map(e=>{const t=S===e.name;return s.jsx("button",{type:"button",className:`cover-picker__tile${t?" is-selected":""}`,"aria-pressed":t,onClick:()=>B(e.name,e.url),children:s.jsx("img",{src:e.url,alt:"",loading:"lazy"})},e.name)}),o?s.jsx("button",{type:"button",className:`cover-picker__tile cover-picker__tile--custom${S?"":" is-selected"}`,"aria-pressed":!S,onClick:K,children:s.jsx("img",{src:o.url,alt:""})}):null,s.jsxs("button",{type:"button",className:"cover-picker__tile cover-picker__upload",onClick:()=>{var e;return(e=L.current)==null?void 0:e.click()},children:[s.jsx("span",{className:"ico ico-upload","aria-hidden":!0}),s.jsx("span",{children:a("storeSettings.upload")})]}),s.jsx("input",{ref:L,type:"file",accept:"image/png, image/jpeg, image/webp",className:"cover-picker__input",onChange:Y})]}),$?s.jsx("p",{className:"error",children:a("storeSettings.sizeError",{max:R(M),current:R(j)})}):null]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.description")}),s.jsx("textarea",{value:n.description,rows:4,disabled:p,onChange:e=>u(t=>({...t,description:e.target.value}))})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.website")}),s.jsx("input",{type:"url",value:n.links.website,placeholder:v.website,disabled:p,onChange:e=>u(t=>({...t,links:{...t.links,website:e.target.value.replace(/\s/g,"")}}))}),I("website",n.links.website)?null:s.jsx("p",{className:"error",children:a("storeSettings.linkError",{value:v.website})})]}),["twitter","discord","facebook"].map(e=>s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a(`storeSettings.${e}`)}),s.jsxs("div",{className:"field__prefixed",children:[s.jsx("span",{className:"field__prefix",children:v[e]}),s.jsx("input",{type:"text",value:G(e),disabled:p,onChange:t=>q(e,t.target.value)})]})]},e)),s.jsx("div",{className:"store-settings__actions",children:s.jsx("button",{className:"btn btn--purple store-settings__save",onClick:()=>void J(),disabled:!F,children:p?a("storeSettings.saving"):a("storeSettings.save")})})]})]})}export{ge as StoreSettings,ge as default};
1
+ import{j as s,a as U,r as i,L as W}from"./react-yytiy0wi.js";import{b as X,u as Z,q as a,ad as T}from"./index-DgPN63Jh.js";import{u as ee,d as se,t as te,L as ae,i as I,a as v,s as re}from"./useStore-D9l09yvh.js";import"./ethers-DArfy-QF.js";const ne="https://cdn.decentraland.org/@dcl/shop/0.1.0-29588264451.commit-627b4b7/assets/template-cover-1-BETekfHg.jpeg",ie="https://cdn.decentraland.org/@dcl/shop/0.1.0-29588264451.commit-627b4b7/assets/template-cover-2-Dni9s0i_.jpeg",oe=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ne,"../assets/creator-covers/template-cover-2.jpeg":ie}),h=Object.entries(oe).sort(([r],[d])=>r.localeCompare(d)).map(([r,d])=>({name:r.split("/").pop(),url:d}));function le({label:r,size:d="medium",direction:b="column",className:f}){return s.jsxs("div",{className:`spinner-box spinner-box--${b}${f?` ${f}`:""}`,role:"status","aria-live":"polite","aria-label":r?void 0:"Loading",children:[s.jsx("span",{className:`spinner-box__ring spinner-box__ring--${d}`,"aria-hidden":!0}),r?s.jsx("span",{className:"spinner-box__label",children:r}):null]})}const M=1e6,O={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function R(r){return`${(r/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function ge(){const{session:r,signIn:d}=X(),b=U(),f=Z(),c=r==null?void 0:r.address,{data:x,isLoading:z}=ee(c),[n,u]=i.useState(O),[E,w]=i.useState(O),[j,g]=i.useState(),[p,C]=i.useState(!1),[o,N]=i.useState(null),[_,A]=i.useState({}),L=i.useRef(null);i.useEffect(()=>{if(x){const e=se(x);u(e),w(e),g(void 0),N(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[x]),i.useEffect(()=>{let e=!1;return Promise.all(h.map(async t=>[t.name,await te(t.url)])).then(t=>{e||A(Object.fromEntries(t))}).catch(()=>{}),()=>{e=!0}},[]);const S=i.useMemo(()=>{const e=h.find(l=>n.coverName===`cover/${l.name}`);if(e)return e.name;const t=n.coverHash?h.find(l=>_[l.name]===n.coverHash):void 0;return t==null?void 0:t.name},[n.coverName,n.coverHash,_]);i.useEffect(()=>{o!=null&&o.hash&&h.some(e=>_[e.name]===o.hash)&&N(null)},[_,o]);const $=j!==void 0&&j>M,D=i.useMemo(()=>ae.filter(e=>!I(e,n.links[e])),[n.links]),P=$||D.length>0,k=i.useMemo(()=>JSON.stringify(n)!==JSON.stringify(E),[n,E]),F=k&&!P&&!p;if(i.useEffect(()=>{if(!k)return;const e=t=>{t.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[k]),!r)return s.jsxs("section",{className:"store-settings store-settings--signin","aria-label":a("storeSettings.title"),children:[s.jsx("h1",{className:"store-settings__title",children:a("storeSettings.title")}),s.jsx("p",{className:"muted",children:a("storeSettings.signInPrompt")}),s.jsx("button",{className:"btn btn--purple store-settings__signin-btn",onClick:d,children:a("storeSettings.signIn")})]});function B(e,t){g(void 0),u(l=>({...l,cover:t,coverName:`cover/${e}`,coverHash:""}))}const V=["image/png","image/jpeg","image/webp"];function Y(e){var y;const t=(y=e.target.files)==null?void 0:y[0];if(!t||!V.includes(t.type))return;g(t.size);const l=`cover/${t.name}`,m=new FileReader;m.onload=()=>{const H=m.result;N({url:H,name:l,hash:""}),u(Q=>({...Q,cover:H,coverName:l,coverHash:""}))},m.readAsDataURL(t)}function q(){o&&(g(void 0),u(e=>({...e,cover:o.url,coverName:o.name,coverHash:o.hash})))}function K(e,t){const l=t?(v[e]+t).replace(/\s/g,""):"";u(m=>({...m,links:{...m.links,[e]:l}}))}function G(e){const t=n.links[e];return e==="website"?t:t.replace(v[e],"")}async function J(){if(!(!c||!r)){C(!0);try{await re(c,n,r.identity),w(n),g(void 0),await f.invalidateQueries({queryKey:["store",c.toLowerCase()]}),T.success(a("storeSettings.saved")),b(`/assets/creator/${c}`)}catch{T.error(a("storeSettings.saveError"))}finally{C(!1)}}}return s.jsxs("section",{className:"store-settings","aria-label":a("storeSettings.title"),children:[s.jsxs("div",{className:"store-settings__head",children:[s.jsxs("div",{className:"store-settings__heading",children:[c?s.jsx(W,{className:"store-settings__back",to:`/assets/creator/${c}`,title:a("storeSettings.back"),"aria-label":a("storeSettings.back"),children:s.jsx("span",{className:"ico ico-arrow-left","aria-hidden":!0})}):null,s.jsx("h1",{className:"store-settings__title",children:a("storeSettings.title")})]}),c?s.jsxs("a",{className:"store-settings__guest",href:`/assets/creator/${c}`,target:"_blank",rel:"noopener noreferrer",children:[a("storeSettings.seeAsGuest"),s.jsx("span",{className:"ico ico-external","aria-hidden":!0})]}):null]}),z?s.jsx(le,{size:"large",label:a("storeSettings.loading"),className:"store-settings__loading"}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.cover")}),s.jsxs("div",{className:"cover-picker",role:"group","aria-label":a("storeSettings.cover"),children:[h.map(e=>{const t=S===e.name;return s.jsx("button",{type:"button",className:`cover-picker__tile${t?" is-selected":""}`,"aria-pressed":t,onClick:()=>B(e.name,e.url),children:s.jsx("img",{src:e.url,alt:"",loading:"lazy"})},e.name)}),o?s.jsx("button",{type:"button",className:`cover-picker__tile cover-picker__tile--custom${S?"":" is-selected"}`,"aria-pressed":!S,onClick:q,children:s.jsx("img",{src:o.url,alt:""})}):null,s.jsxs("button",{type:"button",className:"cover-picker__tile cover-picker__upload",onClick:()=>{var e;return(e=L.current)==null?void 0:e.click()},children:[s.jsx("span",{className:"ico ico-upload","aria-hidden":!0}),s.jsx("span",{children:a("storeSettings.upload")})]}),s.jsx("input",{ref:L,type:"file",accept:"image/png, image/jpeg, image/webp",className:"cover-picker__input",onChange:Y})]}),$?s.jsx("p",{className:"error",children:a("storeSettings.sizeError",{max:R(M),current:R(j)})}):null]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.description")}),s.jsx("textarea",{value:n.description,rows:4,disabled:p,onChange:e=>u(t=>({...t,description:e.target.value}))})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a("storeSettings.website")}),s.jsx("input",{type:"url",value:n.links.website,placeholder:v.website,disabled:p,onChange:e=>u(t=>({...t,links:{...t.links,website:e.target.value.replace(/\s/g,"")}}))}),I("website",n.links.website)?null:s.jsx("p",{className:"error",children:a("storeSettings.linkError",{value:v.website})})]}),["twitter","discord","facebook"].map(e=>s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field__label",children:a(`storeSettings.${e}`)}),s.jsxs("div",{className:"field__prefixed",children:[s.jsx("span",{className:"field__prefix",children:v[e]}),s.jsx("input",{type:"text",value:G(e),disabled:p,onChange:t=>K(e,t.target.value)})]})]},e)),s.jsx("div",{className:"store-settings__actions",children:s.jsx("button",{className:"btn btn--purple store-settings__save",onClick:()=>void J(),disabled:!F,children:p?a("storeSettings.saving"):a("storeSettings.save")})})]})]})}export{ge as StoreSettings,ge as default};
@@ -0,0 +1 @@
1
+ import{j as e,b as E,a as $,N as F,r as w}from"./react-yytiy0wi.js";import{b as T,G as C,H as V,I as M,J as R,K as L,L as B,W as I,i as _,h as g,M as K}from"./index-DgPN63Jh.js";import{s as O}from"./wallet-kind-Jzl4cyiP.js";import{w as U,S as W}from"./buy-gasless-DdXBIm99.js";import"./ethers-DArfy-QF.js";import"./trade-encoding-CWQaROcB.js";import"./index-B2Zw4G7Z.js";function Y(){return e.jsxs("div",{className:"success-anim",role:"img","aria-label":"Purchase successful",children:[e.jsxs("svg",{className:"success-anim__svg",viewBox:"0 0 120 120",children:[e.jsx("circle",{className:"success-anim__ring",cx:"60",cy:"60",r:"54"}),e.jsx("path",{className:"success-anim__check",d:"M37 61 l16 16 l30 -34"})]}),e.jsx("span",{className:"success-anim__spark success-anim__spark--1","aria-hidden":!0,children:"✦"}),e.jsx("span",{className:"success-anim__spark success-anim__spark--2","aria-hidden":!0,children:"✦"}),e.jsx("span",{className:"success-anim__spark success-anim__spark--3","aria-hidden":!0,children:"◈"}),e.jsx("span",{className:"success-anim__spark success-anim__spark--4","aria-hidden":!0,children:"✦"})]})}const z=t=>new Promise(s=>setTimeout(s,t));function H(t,s){const[a,o]=w.useState(t?"pending":"confirmed"),d=s?`${s.owner}-${s.contractAddress}-${s.itemId}`:"";return w.useEffect(()=>{if(!t)return;let r=!1;return(async()=>{let h=!1;for(let n=0;n<20&&!r;n++)try{await U(t,{timeoutMs:15e3}),h=!0;break}catch(c){if(c instanceof W)continue;r||o("failed");return}if(!r){if(!h){o("timed-out");return}if(!s){o("confirmed");return}o("indexing");for(let n=0;n<40&&!r;n++){if(await K(s.owner,s.contractAddress,s.itemId)){r||o("confirmed");return}await z(3e3)}r||o("timed-out")}})(),()=>{r=!0}},[t,d]),a}const J=g.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",x=g.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function se(){const{state:t}=E(),s=$(),{session:a}=T(),{data:o}=C(a==null?void 0:a.address),d=t==null?void 0:t.txHash,r=(t==null?void 0:t.items)??[],l=r[0],h=a!=null&&a.address&&(l!=null&&l.contractAddress)&&(l!=null&&l.itemId)?{owner:a.address,contractAddress:l.contractAddress,itemId:l.itemId}:null,n=H(d,h),c=r;if(c.length===0)return e.jsx(F,{to:"/assets",replace:!0});const u=c[0],j=c.filter(i=>i.category!=="emote"),A=c.find(i=>i.category==="emote")??null,b=j.map(V).filter(i=>!!i),f=M(o),S=!!f&&j.every(i=>R(i,f)),P=L(j)??f??B,v=!!(a!=null&&a.address)&&S,y=v?a.address:"default",k=v?void 0:P,m=A??u,N=m.category==="emote",p=!!d&&O(a==null?void 0:a.providerType);return e.jsxs("div",{className:"success",children:[e.jsx("div",{className:"success__preview",children:b.length>0?e.jsx(I,{profile:y,bodyShape:k,urns:b,type:_.PreviewType.AVATAR,emote:_.PreviewEmote.FASHION,background:"ecebed",dev:g.chainId===80002},u.id):e.jsx(I,{contractAddress:m.contractAddress,tokenId:m.tokenId??void 0,itemId:m.tokenId?void 0:m.itemId??void 0,profile:y,bodyShape:N?void 0:k,type:N?void 0:_.PreviewType.AVATAR,emote:N?void 0:_.PreviewEmote.FASHION,background:"ecebed",dev:g.chainId===80002},m.id)}),e.jsx("div",{className:"success__panel",children:n==="pending"||n==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner success__spinner","aria-hidden":!0}),e.jsx("h1",{className:"success__title",children:n==="indexing"?"Finalizing your purchase…":"Processing your purchase…"}),e.jsx("p",{className:"success__sub",children:n==="indexing"?e.jsxs(e.Fragment,{children:["Payment confirmed — adding"," ",c.length===1?e.jsx("strong",{children:u.name}):`${c.length} items`," to your wardrobe. Almost there."]}):e.jsxs(e.Fragment,{children:["Confirming ",c.length===1?e.jsx("strong",{children:u.name}):`${c.length} items`," on-chain. This usually takes a few seconds — keep this tab open."]})}),p?e.jsx("div",{className:"success__links",children:e.jsx("a",{className:"success__receipt",href:`${x}${d}`,target:"_blank",rel:"noreferrer",children:"View transaction ↗"})}):null]}):n==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"success__title",children:"Still processing…"}),e.jsxs("p",{className:"success__sub",children:["This is taking longer than usual to confirm. Your purchase may still complete — check"," ",e.jsx("button",{className:"link",onClick:()=>s("/my-purchases"),children:"My Purchases"})," ","in a few minutes to see the final status. No need to buy again."]}),e.jsx("div",{className:"success__links",children:p?e.jsx("a",{className:"success__receipt",href:`${x}${d}`,target:"_blank",rel:"noreferrer",children:"View transaction ↗"}):null}),e.jsxs("div",{className:"success__actions",children:[e.jsx("button",{className:"btn btn--purple",onClick:()=>s("/my-purchases"),children:"View my purchases"}),e.jsx("button",{className:"btn btn--ghost",onClick:()=>s("/assets"),children:"Keep shopping"})]})]}):n==="failed"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"success__title",children:"Your purchase didn’t go through"}),e.jsx("p",{className:"success__sub",children:"The transaction failed on-chain, so nothing was delivered. Your credits weren’t spent (any hold is released shortly) — you can try again."}),e.jsx("div",{className:"success__links",children:p?e.jsx("a",{className:"success__receipt",href:`${x}${d}`,target:"_blank",rel:"noreferrer",children:"View transaction ↗"}):null}),e.jsx("div",{className:"success__actions",children:e.jsx("button",{className:"btn btn--purple",onClick:()=>s("/assets"),children:"Back to shop"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{}),e.jsx("h1",{className:"success__title",children:"It’s yours!"}),c.length===1?e.jsxs("p",{className:"success__sub",children:[e.jsx("strong",{children:u.name})," is now in your wardrobe."]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"success__sub",children:[c.length," items are now in your wardrobe."]}),e.jsx("ul",{className:"success__list",children:c.map(i=>e.jsx("li",{children:i.name},i.id))})]}),e.jsxs("div",{className:"success__links",children:[e.jsx("button",{className:"success__receipt",onClick:()=>s("/my-purchases"),children:"View order"}),p?e.jsx("a",{className:"success__receipt",href:`${x}${d}`,target:"_blank",rel:"noreferrer",children:"View transaction ↗"}):null]}),e.jsxs("div",{className:"success__actions",children:[e.jsx("a",{className:"btn btn--purple",href:J,target:"_blank",rel:"noreferrer",children:"Use it in-world"}),e.jsx("button",{className:"btn btn--ghost",onClick:()=>s("/assets"),children:"Keep shopping"})]})]})})]})}export{se as Success,se as default};
@@ -1 +1 @@
1
- import{N as T,j as G,R as I,S as f,k as B,E as M,l as F,W as L,C as g,B as N,b as W,m as E,A as O,n as z,d as _,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-BrDTQqcr.js";import{au as C}from"./NetworkUtil-DInevqnn.js";const b={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=b.getGasPriceInEther(o,t);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:s}){const c=T.bigNumber(n).times(o),r=T.bigNumber(s).times(t);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,o){const t=T.bigNumber(n).div(100);return T.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return T.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){var r,d;const s=(d=(r=t==null?void 0:t.find(l=>l.address===o))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},x=15e4,Q=6,m={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:_.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=$({...m}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,h,y,A,S,P;const n=g.state.activeChain,o=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,t=W.getPlainAddress(o),s=R(),c=H.getConnectorId(g.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((w=e.sourceToken)!=null&&w.address)||!((h=e.sourceToken)!=null&&h.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(y=e.sourceToken)==null?void 0:y.address,toTokenAddress:(A=e.toToken)==null?void 0:A.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(S=e.toToken)==null?void 0:S.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:o&&!r&&!d&&!l,isAuthConnector:c===C.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(o),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=m.myTokensWithBalance,e.tokensPriceMap=m.tokensPriceMap,e.initialized=m.initialized,e.initializing=m.initializing,e.switchingTokens=m.switchingTokens,e.sourceToken=m.sourceToken,e.sourceTokenAmount=m.sourceTokenAmount,e.sourceTokenPriceInUSD=m.sourceTokenPriceInUSD,e.toToken=m.toToken,e.toTokenAmount=m.toTokenAmount,e.toTokenPriceInUSD=m.toTokenPriceInUSD,e.networkPrice=m.networkPrice,e.networkTokenSymbol=m.networkTokenSymbol,e.networkBalanceInUSD=m.networkBalanceInUSD,e.inputError=m.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),o=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(o),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,f.showError("Failed to initialize swap"),I.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const o=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);o&&(e.networkTokenSymbol=o.symbol,a.setSourceToken(o),a.setSourceTokenAmount("0"))},async getTokenList(){var o,t;const n=(o=g.state.activeCaipNetwork)==null?void 0:o.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await E.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((t=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const o=e.tokensPriceMap[n];if(o)return o;const t=await N.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),t=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(f.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const o=await z.getMyTokensWithBalance({forceUpdate:n,caipNetwork:g.state.activeCaipNetwork,address:(s=g.getAccountData())==null?void 0:s.address}),t=E.mapBalancesToSwapTokens(o);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:o}=a.getParams(),t=g.state.activeCaipNetwork;if(!t)return;const s=n.find(c=>c.address===o);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var o,t;const n=await E.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(o=g.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case C.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case C.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=b.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=g.getAccountData())==null?void 0:r.address,o=e.sourceToken,t=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!o||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){O.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await E.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!o||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await E.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{I.goBack(),f.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:o,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:o,to:t,userAddress:n}),c=W.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{I.goBack(),f.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d,l;const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!o||!t||!s||!c)return;let r=(d=B.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const i=s.address===n;let u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:r,disableEstimate:!0}),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice);if(i&&r){const A=(l=e.myTokensWithBalance)==null?void 0:l.find(S=>S.address===n);if(A){const S=parseInt(A.quantity.decimals,10),P=B.parseUnits(A.quantity.numeric,S)??0n,v=p*w;if(BigInt(r)+v>P){const k=P>v?P-v:0n;k>0n&&(u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:k.toString(),disableEstimate:!0}),r=k.toString(),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice))}}}const h=W.getPlainAddress(u.tx.to);if(!h)throw new Error("SwapController:createSwapTransaction - address is required");const y={data:u.tx.data,to:h,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=y,y}catch{I.goBack(),f.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){f.showLoading("Approve limit increase in your wallet"),I.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:o,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?I.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):f.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,f.showError((i==null?void 0:i.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,h,y,A,S,P,v;if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(t,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?I.pushTransactionStack({onSuccess(){I.replace("Account"),f.showLoading(c),D.resetState()}}):f.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(w=e.toToken)==null?void 0:w.address].join(","),k=await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((h=g.state.activeCaipNetwork)==null?void 0:h.caipNetworkId)||"",swapFromToken:((y=a.state.sourceToken)==null?void 0:y.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}}),D.resetState(),s||I.replace("Account"),D.getMyTokensWithBalance(U),k}catch(U){const k=U;e.transactionError=k==null?void 0:k.displayMessage,e.loadingTransaction=!1,f.showError((k==null?void 0:k.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(k==null?void 0:k.displayMessage)||(k==null?void 0:k.message)||"Unknown",network:((S=g.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((v=a.state.toToken)==null?void 0:v.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return b.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=b.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=b.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=b.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
1
+ import{N as T,j as G,R as I,S as f,k as B,E as M,l as F,W as L,C as g,B as N,b as W,m as E,A as O,n as z,d as _,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-QTe845Ty.js";import{au as C}from"./NetworkUtil-Yv-DdqEo.js";const b={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=b.getGasPriceInEther(o,t);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:s}){const c=T.bigNumber(n).times(o),r=T.bigNumber(s).times(t);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,o){const t=T.bigNumber(n).div(100);return T.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return T.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){var r,d;const s=(d=(r=t==null?void 0:t.find(l=>l.address===o))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},x=15e4,Q=6,m={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:_.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=$({...m}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,h,y,A,S,P;const n=g.state.activeChain,o=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,t=W.getPlainAddress(o),s=R(),c=H.getConnectorId(g.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((w=e.sourceToken)!=null&&w.address)||!((h=e.sourceToken)!=null&&h.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(y=e.sourceToken)==null?void 0:y.address,toTokenAddress:(A=e.toToken)==null?void 0:A.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(S=e.toToken)==null?void 0:S.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:o&&!r&&!d&&!l,isAuthConnector:c===C.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(o),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=m.myTokensWithBalance,e.tokensPriceMap=m.tokensPriceMap,e.initialized=m.initialized,e.initializing=m.initializing,e.switchingTokens=m.switchingTokens,e.sourceToken=m.sourceToken,e.sourceTokenAmount=m.sourceTokenAmount,e.sourceTokenPriceInUSD=m.sourceTokenPriceInUSD,e.toToken=m.toToken,e.toTokenAmount=m.toTokenAmount,e.toTokenPriceInUSD=m.toTokenPriceInUSD,e.networkPrice=m.networkPrice,e.networkTokenSymbol=m.networkTokenSymbol,e.networkBalanceInUSD=m.networkBalanceInUSD,e.inputError=m.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),o=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(o),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,f.showError("Failed to initialize swap"),I.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const o=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);o&&(e.networkTokenSymbol=o.symbol,a.setSourceToken(o),a.setSourceTokenAmount("0"))},async getTokenList(){var o,t;const n=(o=g.state.activeCaipNetwork)==null?void 0:o.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await E.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((t=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const o=e.tokensPriceMap[n];if(o)return o;const t=await N.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),t=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(f.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const o=await z.getMyTokensWithBalance({forceUpdate:n,caipNetwork:g.state.activeCaipNetwork,address:(s=g.getAccountData())==null?void 0:s.address}),t=E.mapBalancesToSwapTokens(o);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:o}=a.getParams(),t=g.state.activeCaipNetwork;if(!t)return;const s=n.find(c=>c.address===o);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var o,t;const n=await E.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(o=g.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case C.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case C.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=b.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=g.getAccountData())==null?void 0:r.address,o=e.sourceToken,t=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!o||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){O.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await E.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!o||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await E.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{I.goBack(),f.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:o,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:o,to:t,userAddress:n}),c=W.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{I.goBack(),f.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d,l;const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!o||!t||!s||!c)return;let r=(d=B.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const i=s.address===n;let u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:r,disableEstimate:!0}),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice);if(i&&r){const A=(l=e.myTokensWithBalance)==null?void 0:l.find(S=>S.address===n);if(A){const S=parseInt(A.quantity.decimals,10),P=B.parseUnits(A.quantity.numeric,S)??0n,v=p*w;if(BigInt(r)+v>P){const k=P>v?P-v:0n;k>0n&&(u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:k.toString(),disableEstimate:!0}),r=k.toString(),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice))}}}const h=W.getPlainAddress(u.tx.to);if(!h)throw new Error("SwapController:createSwapTransaction - address is required");const y={data:u.tx.data,to:h,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=y,y}catch{I.goBack(),f.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){f.showLoading("Approve limit increase in your wallet"),I.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:o,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?I.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):f.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,f.showError((i==null?void 0:i.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,h,y,A,S,P,v;if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(t,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?I.pushTransactionStack({onSuccess(){I.replace("Account"),f.showLoading(c),D.resetState()}}):f.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(w=e.toToken)==null?void 0:w.address].join(","),k=await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:C.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((h=g.state.activeCaipNetwork)==null?void 0:h.caipNetworkId)||"",swapFromToken:((y=a.state.sourceToken)==null?void 0:y.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}}),D.resetState(),s||I.replace("Account"),D.getMyTokensWithBalance(U),k}catch(U){const k=U;e.transactionError=k==null?void 0:k.displayMessage,e.loadingTransaction=!1,f.showError((k==null?void 0:k.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(k==null?void 0:k.displayMessage)||(k==null?void 0:k.message)||"Unknown",network:((S=g.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((v=a.state.toToken)==null?void 0:v.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return b.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=b.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=b.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=b.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};