@dcl/shop 0.1.0-30565861644.commit-86fa62d → 0.1.0-30612955316.commit-0d9b744

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 (173) hide show
  1. package/assets/{Activity-YIu0M1Kf.js → Activity-BF3WNwMh.js} +1 -1
  2. package/assets/{AnimatedBackground-BrxVl8X0.js → AnimatedBackground-DTgtqP8R.js} +1 -1
  3. package/assets/{Assets-Dwlho6_C.js → Assets-B9KXwYG0.js} +2 -2
  4. package/assets/{Assets.styles-CfTWTkg9.js → Assets.styles-Dm_MgfhY.js} +1 -1
  5. package/assets/{Authorizations-BMPo5lsC.js → Authorizations--gatNHIW.js} +1 -1
  6. package/assets/{Cart-DS3i-ZcL.js → Cart-Cs0FD0IN.js} +2 -2
  7. package/assets/{CircularProgress-BrgD7rFE.js → CircularProgress-BRaMu2HF.js} +1 -1
  8. package/assets/{Collection-wJlJYfNj.js → Collection-BIR5xrVe.js} +1 -1
  9. package/assets/{CollectionCarousel-Bns794gp.js → CollectionCarousel-oh8d08gi.js} +1 -1
  10. package/assets/{Creator-Bz4Ol9VJ.js → Creator-jKJMNfvf.js} +1 -1
  11. package/assets/{ErrorNotice-Z0D8os9s.js → ErrorNotice-C2qBxBzo.js} +1 -1
  12. package/assets/{ExchangeController-DWJqUlaQ.js → ExchangeController-BJ20Rri0.js} +1 -1
  13. package/assets/{GetCredits-DaqSIDEt.js → GetCredits-DWkdHCSk.js} +97 -60
  14. package/assets/{HelpersUtil-BmEt66tk.js → HelpersUtil-Bc_-rYa4.js} +1 -1
  15. package/assets/{ImportListings-tR_OXub1.js → ImportListings-C61E-WD4.js} +1 -1
  16. package/assets/{ItemDetail-n9hpow28.js → ItemDetail-BFNeFxLh.js} +3 -3
  17. package/assets/{LoadMore-DI4Wyn-C.js → LoadMore-BI2cyij4.js} +1 -1
  18. package/assets/{MenuList-CYC3zRYf.js → MenuList-CsoSKANx.js} +1 -1
  19. package/assets/{MyAssets-CRBhFPGQ.js → MyAssets-B8jlwAvA.js} +1 -1
  20. package/assets/{MyFavorites-B6grtRZj.js → MyFavorites-B6kCgq1h.js} +1 -1
  21. package/assets/{NotFound-0L1xj8db.js → NotFound-CWtlpg63.js} +1 -1
  22. package/assets/{NotificationsBell-B5Q9EIqa.js → NotificationsBell-wPKuEs_b.js} +1 -1
  23. package/assets/{StoreSettings-CUyzwheq.js → StoreSettings-BW2EY9gn.js} +1 -1
  24. package/assets/{Success-DXPvtMrB.js → Success-CTKJzQjE.js} +1 -1
  25. package/assets/{SwapController-CP6wYtUi.js → SwapController-DHr7xvAI.js} +1 -1
  26. package/assets/{Tooltip-BbHzoPIy.js → Tooltip-DFmfpHxa.js} +1 -1
  27. package/assets/{TradeService-CbR5e6j8.js → TradeService-BxS-ssTi.js} +1 -1
  28. package/assets/{W3MFrameProviderSingleton-CAciSeGb.js → W3MFrameProviderSingleton-D3RatyJZ.js} +3 -3
  29. package/assets/{WebCryptoP256-BJObUJ75.js → WebCryptoP256-DLlMYv1t.js} +1 -1
  30. package/assets/{authorizations-B6wWjXdQ.js → authorizations-BrAVsIY_.js} +1 -1
  31. package/assets/{basic-PrtqXBMx.js → basic-B1iPuZqz.js} +1 -1
  32. package/assets/{biconomy-CXoNqd-Z.js → biconomy-CReC5_o1.js} +1 -1
  33. package/assets/{browseLayout.styles-B_NNL83E.js → browseLayout.styles-Ck-h2OX5.js} +1 -1
  34. package/assets/{builder-DJzcrQAM.js → builder-BW_vsdgs.js} +1 -1
  35. package/assets/{buy-D3hY4JG8.js → buy-DLi3_94e.js} +1 -1
  36. package/assets/{buy-gasless-CmOMFX1L.js → buy-gasless-DoEdxK3L.js} +1 -1
  37. package/assets/{categories-CX6i4K78.js → categories-P1zgLmzy.js} +1 -1
  38. package/assets/{ccip-Dd-dexDO.js → ccip-BHjcKqJV.js} +1 -1
  39. package/assets/{ccip-w3FPfxqw.js → ccip-CZBbVQi3.js} +1 -1
  40. package/assets/{clsx-BRGjhjlu.js → clsx-DhFqZi_3.js} +1 -1
  41. package/assets/{controller-DwX-jKZc.js → controller-DGy85CgR.js} +2 -2
  42. package/assets/{core-D2eU58P9.js → core-Db5S1VHS.js} +4 -4
  43. package/assets/{createSvgIcon-BVcvIe2E.js → createSvgIcon-DLpGC0um.js} +1 -1
  44. package/assets/{custom-C8kunAUg.js → custom-ClweN61f.js} +1 -1
  45. package/assets/{data-capture-5SXe7x0r.js → data-capture-z84EsTtU.js} +1 -1
  46. package/assets/{email-Bn0Sv8j4.js → email-CcLkWyvu.js} +1 -1
  47. package/assets/{embedded-wallet-C8c_78Uv.js → embedded-wallet-COy2jXd-.js} +1 -1
  48. package/assets/{emotion-styled.browser.esm-3ejjGoWk.js → emotion-styled.browser.esm-Bl0xNQms.js} +1 -1
  49. package/assets/{engine-CNGw5SdF.js → engine-D5VFTt2U.js} +1 -1
  50. package/assets/{errors-BYKPLdNJ.js → errors-D660SWgT.js} +1 -1
  51. package/assets/{estimate-l1-fee-BrG1mArn.js → estimate-l1-fee-D0AZXU9d.js} +1 -1
  52. package/assets/{execute-BuBESW09.js → execute-B7xe5F3I.js} +2 -2
  53. package/assets/{features-DJEePSdY.js → features-CDbo6Rgb.js} +1 -1
  54. package/assets/{fetchTokenMetadata-DbJ4fJYd.js → fetchTokenMetadata-CTdt9CEd.js} +2 -2
  55. package/assets/{get-ecosystem-wallet-info-BVDQHXZz.js → get-ecosystem-wallet-info-DSZkSx4X.js} +1 -1
  56. package/assets/{getBalance-Dwa97iHq.js → getBalance-BDX5XOeM.js} +1 -1
  57. package/assets/{getNFT-KnOGHpCx.js → getNFT-CVs2H6Tl.js} +1 -1
  58. package/assets/{getNFT-8vTqe5mx.js → getNFT-DINbSeyy.js} +1 -1
  59. package/assets/{getThemeProps-BkCaIJdf.js → getThemeProps-CGtqDWEq.js} +1 -1
  60. package/assets/{grid.styles-Cflo-ZKg.js → grid.styles-D4B-EHGj.js} +1 -1
  61. package/assets/{hashTypedData-zHAZUnlP.js → hashTypedData-B7lV4LZj.js} +1 -1
  62. package/assets/{hashTypedData-ByA_PXdL.js → hashTypedData-Dz79Rf5q.js} +1 -1
  63. package/assets/{import-Da_I6gAZ.js → import-DSm0v4af.js} +1 -1
  64. package/assets/{in-app-DAfU34Xj.js → in-app-C5pWpM6r.js} +1 -1
  65. package/assets/{in-app-wallet-calls-C8MSEj6u.js → in-app-wallet-calls-DXx7lWeR.js} +1 -1
  66. package/assets/{index-BkQsw_6m.js → index-1c_qW8yi.js} +1 -1
  67. package/assets/{index-BCGTwY9C.js → index-1koyBXBc.js} +1 -1
  68. package/assets/{index-DTvh0ZYF.js → index-3ZTohoUZ.js} +1 -1
  69. package/assets/{index-CVY0sxwP.js → index-B81PeozV.js} +1 -1
  70. package/assets/{index-IEBvb9g0.js → index-B8zb5Fyq.js} +1 -1
  71. package/assets/{index-DX8GIl1w.js → index-BBkUTtNV.js} +1 -1
  72. package/assets/{index-DhHGVFYf.js → index-BFSsZJPW.js} +1 -1
  73. package/assets/{index-D34PBlHH.js → index-BJ-25Q5l.js} +1 -1
  74. package/assets/{index-B6EsaBwe.js → index-BZocXWA4.js} +1 -1
  75. package/assets/{index-CGd-1UpW.js → index-BgoikptS.js} +1 -1
  76. package/assets/{index-BnWc8jyR.js → index-BobbFiKW.js} +1 -1
  77. package/assets/{index-BFQ3WGPq.js → index-C-C5pEJc.js} +1 -1
  78. package/assets/{index-CkshIr8A.js → index-C0LSKXhw.js} +1 -1
  79. package/assets/{index-DeUn3r_V.js → index-C0odNd_G.js} +1 -1
  80. package/assets/{index-CuYL-Baw.js → index-CJgXTNhS.js} +1 -1
  81. package/assets/{index-BOei64ey.js → index-CKEG3W2m.js} +1 -1
  82. package/assets/{index-SG2QR9w5.js → index-CLBmEx6A.js} +3 -3
  83. package/assets/{index-DQwfF15K.js → index-CX5Ekh69.js} +1 -1
  84. package/assets/{index-CzKTIGRh.js → index-CXntdDwE.js} +2 -2
  85. package/assets/{index-vQ_2c6zv.js → index-CZ1tNVf6.js} +1 -1
  86. package/assets/{index-DMlJeY00.js → index-CZTqkynu.js} +1 -1
  87. package/assets/{index-CRiWMT-r.js → index-CbITlqFn.js} +1 -1
  88. package/assets/{index-CkqeusMi.js → index-CdsKR_zs.js} +1 -1
  89. package/assets/{index-DmUPrDg1.js → index-CkBDyoGg.js} +1 -1
  90. package/assets/{index-Dltarl5j.js → index-Cl-v7TvL.js} +1 -1
  91. package/assets/{index-BKmu2o-E.js → index-CpqhaC2H.js} +1 -1
  92. package/assets/{index-DTtN3FMo.js → index-CuPPMOVj.js} +1 -1
  93. package/assets/{index-Bvsc2jDb.js → index-Cw6mXTIQ.js} +1 -1
  94. package/assets/{index-CkzcSx5U.js → index-CwVjvkdk.js} +1 -1
  95. package/assets/{index-Azrqm6Av.js → index-CzByZQWv.js} +1 -1
  96. package/assets/{index-Dla9ohqE.js → index-D7R57an8.js} +2 -2
  97. package/assets/{index-CvD8tr1x.js → index-DIR4uPmO.js} +1 -1
  98. package/assets/{index-DWsuciPI.js → index-DMjEzVVJ.js} +1 -1
  99. package/assets/{index-Dl_EomMH.js → index-DQ2sE8uD.js} +1 -1
  100. package/assets/{index-Ddw9OYjW.js → index-DU8_EWWx.js} +1 -1
  101. package/assets/{index-MmxQtN7S.js → index-DZg10nMY.js} +1 -1
  102. package/assets/{index-DJk-Gyy6.js → index-DfTLbDYm.js} +1 -1
  103. package/assets/{index-MBO4iF-x.js → index-DiOmLLPI.js} +1 -1
  104. package/assets/{index-Q9aqPNo3.js → index-DjbRx8bI.js} +1 -1
  105. package/assets/{index-BRBJXQFj.js → index-Dr4K4hFL.js} +3 -3
  106. package/assets/{index-CfiHgp7t.js → index-Dw4Gh8Hk.js} +2 -2
  107. package/assets/{index-I6AhOucd.js → index-G1xB9dvf.js} +1 -1
  108. package/assets/{index-BzmmiLep.js → index-NPIY1Vbs.js} +1 -1
  109. package/assets/{index-Kl09Ztwk.js → index-ODLNljC7.js} +1 -1
  110. package/assets/{index-CgmlJw-S.js → index-P_XHlb3T.js} +1 -1
  111. package/assets/{index-DiUDVsbw.js → index-b_a6Xe2g.js} +3 -3
  112. package/assets/{index-CSAUfzci.js → index-frQRdZ2q.js} +1 -1
  113. package/assets/{index-DHNHHzGW.js → index-gKwUmrp3.js} +1 -1
  114. package/assets/{index-1YMH7MTk.js → index-tdQJ2A6x.js} +1 -1
  115. package/assets/{index-BBHWbqVq.js → index-xZ3i_Adn.js} +1 -1
  116. package/assets/{index-BnbwrW-6.js → index-yJi2QIJf.js} +11 -11
  117. package/assets/{index.es-1Eex98-c.js → index.es-CZz1nBev.js} +1 -1
  118. package/assets/{index.es-Dcl8xzFM.js → index.es-CdLNKigl.js} +4 -4
  119. package/assets/{index.es-8mJw4ztI.js → index.es-CeoIh9-h.js} +1 -1
  120. package/assets/{localBatchGatewayRequest-DLZcpxp5.js → localBatchGatewayRequest-Dbz593U8.js} +1 -1
  121. package/assets/{mana-convert-Bc7WVBn5.js → mana-convert-DTic_WF4.js} +1 -1
  122. package/assets/{mana-rate-CFfqtCHS.js → mana-rate-DTd_zYK_.js} +1 -1
  123. package/assets/{networks-C9v8SYzv.js → networks-D-WgnPJO.js} +1 -1
  124. package/assets/{onramp-vHeI0Bdi.js → onramp-CxZE_awn.js} +1 -1
  125. package/assets/{openzeppelin-yMR9b1FL.js → openzeppelin-BicG6fZ-.js} +1 -1
  126. package/assets/{parseNft-DOgBlFyM.js → parseNft-crNNmDcM.js} +2 -2
  127. package/assets/{parseSignature-B_BQDXEi.js → parseSignature-TUf4MZpE.js} +1 -1
  128. package/assets/{parseSignature-CCtT275H.js → parseSignature-xro4_AeM.js} +3 -3
  129. package/assets/{passkeys-DC9ui3MW.js → passkeys-DlsWo5hj.js} +1 -1
  130. package/assets/{pay-with-exchange-DzS3VV5h.js → pay-with-exchange-uJFVzJz2.js} +1 -1
  131. package/assets/{qr-overlay-DBMFsWbT.js → qr-overlay-D1DRCZeg.js} +1 -1
  132. package/assets/{receive-DL6eap6Y.js → receive-jEtfcBkz.js} +1 -1
  133. package/assets/{resolveImplementation-CbIwAEHk.js → resolveImplementation-Dfr_x2D4.js} +1 -1
  134. package/assets/{rpc-4rFMN8E0.js → rpc-HxGwRhjl.js} +1 -1
  135. package/assets/{secp256k1-CJEeTac_.js → secp256k1-BeCdbOwL.js} +1 -1
  136. package/assets/{secp256k1-7K_lKgAG.js → secp256k1-Bmo0zLoN.js} +1 -1
  137. package/assets/{secp256k1-Cc-OBcqq.js → secp256k1-CPsxfMTn.js} +1 -1
  138. package/assets/{send-LziflfC8.js → send-SCYWhWgO.js} +1 -1
  139. package/assets/{send-batch-transaction-cPuMc9MS.js → send-batch-transaction-ClJpcx_r.js} +1 -1
  140. package/assets/{send-eip712-transaction-DrVlY4sm.js → send-eip712-transaction-DCKQGfPC.js} +2 -2
  141. package/assets/{send-gasless-transaction-C7GQuNPZ.js → send-gasless-transaction-C6PqTuT4.js} +2 -2
  142. package/assets/{send-transaction-DsHae-07.js → send-transaction-DCRA_QBx.js} +2 -2
  143. package/assets/{sendMetaTransaction-DVALeVb8.js → sendMetaTransaction-BOtIj1YL.js} +1 -1
  144. package/assets/{sendRawTransaction-BwoXNrfy.js → sendRawTransaction-BkrUK6tH.js} +3 -3
  145. package/assets/{serializeTransaction-HjwgZYgE.js → serializeTransaction-bVNzq6Wv.js} +1 -1
  146. package/assets/{session-proposal-D2B7jyYw.js → session-proposal-BwFRVt7g.js} +1 -1
  147. package/assets/{session-request-qG7jHYd4.js → session-request-4TbdsxSC.js} +2 -2
  148. package/assets/{signing-2d-SxI7E.js → signing-BxAbixw6.js} +3 -3
  149. package/assets/{socials-C5lHDsWb.js → socials-B5zVEegD.js} +1 -1
  150. package/assets/{swaps-D-FCeao1.js → swaps-DQ1LcBTU.js} +1 -1
  151. package/assets/{thirdweb-BzCYZVQU.js → thirdweb-r2nvH1Ph.js} +3 -3
  152. package/assets/{to-serializable-transaction-mtITaKz7.js → to-serializable-transaction-DMc2E6fk.js} +2 -2
  153. package/assets/{trade-encoding-ZhCceq00.js → trade-encoding-BFXwI1r3.js} +1 -1
  154. package/assets/{transactionReceipt-C0Zt7siR.js → transactionReceipt-DFdTIN3F.js} +1 -1
  155. package/assets/{transactions-3oKW7X2A.js → transactions-DnRd57Kk.js} +1 -1
  156. package/assets/useCreditPacks-DnQLmQo7.js +1 -0
  157. package/assets/{useInfiniteGrid-DxkPmxZ9.js → useInfiniteGrid-CDkGdzFf.js} +1 -1
  158. package/assets/useManaRate-DwO6H8fK.js +1 -0
  159. package/assets/{useSecondarySales-uafEfAWN.js → useSecondarySales-BLnZD7gi.js} +1 -1
  160. package/assets/{useStore-HaFF1p2U.js → useStore-Dt337zVA.js} +1 -1
  161. package/assets/{useTheme-DVLL-c1A.js → useTheme-DlRIY8zD.js} +1 -1
  162. package/assets/{verifyHash-DR9pCFUe.js → verifyHash-D8nhWUT9.js} +1 -1
  163. package/assets/{w3m-modal-B4U6A0YE.js → w3m-modal-D1mPkWGM.js} +1 -1
  164. package/assets/{w3m-modal-CaY0gxk7.js → w3m-modal-Z-IBP9yL.js} +1 -1
  165. package/assets/{wait-for-tx-receipt-BDXxYIXq.js → wait-for-tx-receipt-8bgpdxSo.js} +1 -1
  166. package/assets/{wallets-Y1872Ad0.js → wallets-BTh4qQ9L.js} +5 -5
  167. package/assets/{web-connector-CYEfuYp5.js → web-connector-DXtL7d_s.js} +3 -3
  168. package/assets/{writeContract-DrFAVNON.js → writeContract-B7vnLdJy.js} +1 -1
  169. package/assets/{zoraTestnet-CZflXjbY.js → zoraTestnet-kFdaoH4G.js} +1 -1
  170. package/index.html +11 -11
  171. package/package.json +2 -2
  172. package/assets/useCreditPacks-DTZSsQrR.js +0 -1
  173. package/assets/useManaRate-DJlj41tJ.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as b,j as e,L as _,d as dt}from"./react-vyZjIDcS.js";import{aI as lt,s as l,t as o,x as ut,B as ht,m as xt,e as d,n as pt,u as j,I as g,aJ as R,aK as G,aL as mt,z as v,aM as gt,ap as T,D as J,J as ft,aN as yt,aO as Q}from"./index-BnbwrW-6.js";import{m as bt}from"./mana-convert-Bc7WVBn5.js";import{u as jt}from"./useManaRate-DJlj41tJ.js";import{L as vt}from"./LoadMore-DI4Wyn-C.js";import{u as f}from"./useInfiniteGrid-DxkPmxZ9.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";import"./mana-rate-CFfqtCHS.js";const kt=15e3;function wt(t,i){return t.txHash&&i.txHash?t.txHash===i.txHash:t.txHash||i.txHash?!1:t.status===i.status&&Math.abs(t.createdAt-i.createdAt)<=kt}function It(t){const i=[...t].sort((a,n)=>n.createdAt-a.createdAt),s=[];for(const a of i){const n=s[s.length-1];n&&wt(n[n.length-1],a)?n.push(a):s.push([a])}return s.map(a=>{var n;return{id:((n=a.find(c=>c.txHash))==null?void 0:n.txHash)??a[a.length-1].id,createdAt:Math.max(...a.map(c=>c.createdAt)),status:a.some(c=>c.status==="PENDING")?"PENDING":"SETTLED",totalCredits:a.reduce((c,h)=>c+h.credits,0),lines:a}})}function At(t){const i=[],s=new Map;for(const a of t)if(a.tradeId){const n=s.get(a.tradeId);if(n){n.quantity+=1,n.credits+=a.credits;continue}const c={key:a.tradeId,tradeId:a.tradeId,quantity:1,credits:a.credits};s.set(a.tradeId,c),i.push(c)}else i.push({key:a.id,tradeId:null,quantity:1,credits:a.credits});return i}function $t(t,i){return{id:t.id,contractAddress:t.contractAddress,tokenId:t.tokenId,itemId:t.itemId,counterparty:t.buyer,credits:i?bt(t.manaWei,i):null,manaWei:t.manaWei,createdAt:t.createdAt,txHash:t.txHash}}function Pt(t){const s=It(t.purchases.filter(r=>r.status!=="EXPIRED")).map(r=>({kind:"purchase",id:`purchase:${r.id}`,createdAt:r.createdAt,order:r})),a=t.sales.map(r=>{const x=$t(r,t.rate);return{kind:"sale",id:`sale:${x.id}`,createdAt:x.createdAt,sale:x}}),n=(t.creditOrders??[]).filter(r=>r.status!=="failed"&&r.status!=="abandoned").map(r=>({kind:"credit",id:`credit:${r.id}`,createdAt:r.createdAt,order:r})),c=new Set(t.purchases.filter(r=>r.txHash).map(r=>r.txHash.toLowerCase())),h=(t.manaPurchases??[]).filter(r=>!c.has(r.txHash.toLowerCase())).map(r=>({kind:"mana-purchase",id:`mana-purchase:${r.id}`,createdAt:r.createdAt,sale:r}));return[...s,...a,...n,...h].sort((r,x)=>x.createdAt-r.createdAt||(r.id<x.id?-1:1))}function Lt(t,i){return i==="all"?t:i==="sales"?t.filter(s=>s.kind==="sale"):t.filter(s=>s.kind==="purchase"||s.kind==="credit"||s.kind==="mana-purchase")}const X=t=>t.trim().toLowerCase();function Nt(t){const i=new Map;for(const s of t??[]){const a=X(s.txHash??"");if(!a)continue;const n=i.get(a);n?n.push(s):i.set(a,[s])}return i}function Tt(t,i,s=Date.now()){const a=i.txHash?t.get(X(i.txHash)):void 0;if(!a||a.length===0)return{kind:"direct"};const n=a.length===1?Et(a[0].netCents):null,c=a.filter(r=>!r.available&&r.availableAt>s);if(c.length===0)return{kind:"credited",credits:n};const h=c.reduce((r,x)=>Math.max(r,x.availableAt),0);return{kind:"pending",credits:n,availableAt:h}}function Et(t){return lt(t)}const Ct="https://cdn.decentraland.org/@dcl/shop/0.1.0-30565861644.commit-86fa62d/assets/credits-product-vs4Q6u6l.svg",E=ut`
1
+ import{r as b,j as e,L as _,d as dt}from"./react-vyZjIDcS.js";import{aI as lt,s as l,t as o,x as ut,B as ht,m as xt,e as d,n as pt,u as j,I as g,aJ as R,aK as G,aL as mt,z as v,aM as gt,ap as T,D as J,J as ft,aN as yt,aO as Q}from"./index-yJi2QIJf.js";import{m as bt}from"./mana-convert-DTic_WF4.js";import{u as jt}from"./useManaRate-DwO6H8fK.js";import{L as vt}from"./LoadMore-BI2cyij4.js";import{u as f}from"./useInfiniteGrid-CDkGdzFf.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";import"./mana-rate-DTd_zYK_.js";const kt=15e3;function wt(t,i){return t.txHash&&i.txHash?t.txHash===i.txHash:t.txHash||i.txHash?!1:t.status===i.status&&Math.abs(t.createdAt-i.createdAt)<=kt}function It(t){const i=[...t].sort((a,n)=>n.createdAt-a.createdAt),s=[];for(const a of i){const n=s[s.length-1];n&&wt(n[n.length-1],a)?n.push(a):s.push([a])}return s.map(a=>{var n;return{id:((n=a.find(c=>c.txHash))==null?void 0:n.txHash)??a[a.length-1].id,createdAt:Math.max(...a.map(c=>c.createdAt)),status:a.some(c=>c.status==="PENDING")?"PENDING":"SETTLED",totalCredits:a.reduce((c,h)=>c+h.credits,0),lines:a}})}function At(t){const i=[],s=new Map;for(const a of t)if(a.tradeId){const n=s.get(a.tradeId);if(n){n.quantity+=1,n.credits+=a.credits;continue}const c={key:a.tradeId,tradeId:a.tradeId,quantity:1,credits:a.credits};s.set(a.tradeId,c),i.push(c)}else i.push({key:a.id,tradeId:null,quantity:1,credits:a.credits});return i}function $t(t,i){return{id:t.id,contractAddress:t.contractAddress,tokenId:t.tokenId,itemId:t.itemId,counterparty:t.buyer,credits:i?bt(t.manaWei,i):null,manaWei:t.manaWei,createdAt:t.createdAt,txHash:t.txHash}}function Pt(t){const s=It(t.purchases.filter(r=>r.status!=="EXPIRED")).map(r=>({kind:"purchase",id:`purchase:${r.id}`,createdAt:r.createdAt,order:r})),a=t.sales.map(r=>{const x=$t(r,t.rate);return{kind:"sale",id:`sale:${x.id}`,createdAt:x.createdAt,sale:x}}),n=(t.creditOrders??[]).filter(r=>r.status!=="failed"&&r.status!=="abandoned").map(r=>({kind:"credit",id:`credit:${r.id}`,createdAt:r.createdAt,order:r})),c=new Set(t.purchases.filter(r=>r.txHash).map(r=>r.txHash.toLowerCase())),h=(t.manaPurchases??[]).filter(r=>!c.has(r.txHash.toLowerCase())).map(r=>({kind:"mana-purchase",id:`mana-purchase:${r.id}`,createdAt:r.createdAt,sale:r}));return[...s,...a,...n,...h].sort((r,x)=>x.createdAt-r.createdAt||(r.id<x.id?-1:1))}function Lt(t,i){return i==="all"?t:i==="sales"?t.filter(s=>s.kind==="sale"):t.filter(s=>s.kind==="purchase"||s.kind==="credit"||s.kind==="mana-purchase")}const X=t=>t.trim().toLowerCase();function Nt(t){const i=new Map;for(const s of t??[]){const a=X(s.txHash??"");if(!a)continue;const n=i.get(a);n?n.push(s):i.set(a,[s])}return i}function Tt(t,i,s=Date.now()){const a=i.txHash?t.get(X(i.txHash)):void 0;if(!a||a.length===0)return{kind:"direct"};const n=a.length===1?Et(a[0].netCents):null,c=a.filter(r=>!r.available&&r.availableAt>s);if(c.length===0)return{kind:"credited",credits:n};const h=c.reduce((r,x)=>Math.max(r,x.availableAt),0);return{kind:"pending",credits:n,availableAt:h}}function Et(t){return lt(t)}const Ct="https://cdn.decentraland.org/@dcl/shop/0.1.0-30612955316.commit-0d9b744/assets/credits-product-vs4Q6u6l.svg",E=ut`
2
2
  0% { background-position: 200% 0; }
3
3
  100% { background-position: -200% 0; }
4
4
  `,Ft=l.section`
@@ -1,4 +1,4 @@
1
- import{r as l,j as v}from"./react-vyZjIDcS.js";import{s as u}from"./index-BnbwrW-6.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";const S="https://cdn.decentraland.org/@dcl/shop/0.1.0-30565861644.commit-86fa62d/assets/custom-welcome-background-BxlFQma9.webp",b="https://cdn.decentraland.org/@dcl/shop/0.1.0-30565861644.commit-86fa62d/assets/DCL_LogoPattern-BryBPc3d.png",U=`
1
+ import{r as l,j as v}from"./react-vyZjIDcS.js";import{s as u}from"./index-yJi2QIJf.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";const S="https://cdn.decentraland.org/@dcl/shop/0.1.0-30612955316.commit-0d9b744/assets/custom-welcome-background-BxlFQma9.webp",b="https://cdn.decentraland.org/@dcl/shop/0.1.0-30612955316.commit-0d9b744/assets/DCL_LogoPattern-BryBPc3d.png",U=`
2
2
  attribute vec2 a_position;
3
3
  varying vec2 v_uv;
4
4
  void main() {
@@ -1,4 +1,4 @@
1
- import{b as ze,r as m,j as e,u as Ve}from"./react-vyZjIDcS.js";import{c as B,au as Ze,av as Je,d as Ke,s as n,t,n as Ie,al as Qe,E as Xe,J as Ae,y as Ye,e as s,I as R,z as W,aR as he,aj as et,ar as K,ay as tt,ax as nt,m as Ne,o as st,S as fe,A as O,aS as ot,aT as it}from"./index-BnbwrW-6.js";import{u as rt}from"./useSecondarySales-uafEfAWN.js";import{a as at,m as Me}from"./mana-convert-Bc7WVBn5.js";import{u as Pe}from"./useManaRate-DJlj41tJ.js";import{g as lt,h as ct,i as dt,j as pt,k as xt,C as ht,l as ft,o as mt,m as ut,n as gt,M as bt,p as yt,E as wt,q as jt,r as vt,s as $t,t as Ct,u as kt,v as St}from"./Assets.styles-CfTWTkg9.js";import{c as me,R as Et,F as Rt,S as Tt}from"./categories-CX6i4K78.js";import{L as _t}from"./LoadMore-DI4Wyn-C.js";import{u as zt}from"./useInfiniteGrid-DxkPmxZ9.js";import{E as It}from"./ErrorNotice-Z0D8os9s.js";import{d as At}from"./dcl-schemas-BICTSpB5.js";import{s as Nt,G as Mt,w as Pt,S as Wt}from"./buy-gasless-CmOMFX1L.js";import{s as Bt}from"./buy-D3hY4JG8.js";import{i as Ft}from"./trade-encoding-ZhCceq00.js";import{r as Lt}from"./mana-rate-CFfqtCHS.js";import{f as Ht}from"./errors-BYKPLdNJ.js";import{J as Ut,C as Ot,B as ee}from"./ethers-CXBJm_wN.js";import{n as Gt}from"./Tooltip-BbHzoPIy.js";import{G as Dt}from"./grid.styles-Cflo-ZKg.js";import"./sentry-B35L1FdR.js";import"./intl-CBcMB1D2.js";import"./authorizations-B6wWjXdQ.js";import"./sendMetaTransaction-DVALeVb8.js";function G(o){const i=o.source??"item",l=o.tradeId||`${o.contractAddress}-${o.tokenId??o.itemId??""}`;return`${i}:${l}`}const F="100000000000000000000",We=2,Q=15,qt=/^[a-zA-Z0-9]+$/;function ue(o){const i=o.trim();return i.length===0?{ok:!1,reason:"empty"}:qt.test(i)?i.length<We?{ok:!1,reason:"too-short"}:i.length>Q?{ok:!1,reason:"too-long"}:{ok:!0}:{ok:!1,reason:"invalid-chars"}}function Vt(o){return o.replace(/[^a-zA-Z0-9]/g,"").slice(0,Q)}const Zt=["function available(string _subdomain) view returns (bool)"],ge={mainnet:{rpc:"https://rpc.decentraland.org/mainnet",address:"0x2a187453064356c898cae034eaed119e1663acb8"},sepolia:{rpc:"https://rpc.decentraland.org/sepolia",address:"0x7518456ae93eb98f3e64571b689c626616bb7f30"}};function Jt(){return B.chainId===Number(At.ChainId.MATIC_MAINNET)?ge.mainnet:ge.sepolia}async function Kt(o,i={}){var p;const{rpc:l,address:x}=Jt(),c=new Ut(l),d=new Ot(x,Zt,c);console.info(`[names] availability check → DCLRegistrar(${x}).available("${o}") on ${l}`);const h=await d.available(o);if((p=i.signal)!=null&&p.aborted)throw new DOMException("Aborted","AbortError");return console.info(`[names] "${o}" available=${h}`),h?"available":"taken"}const Qt="https://app.across.to/api";class Be extends Error{constructor(){super("Name registration is temporarily unavailable due to high network costs"),this.name="NameRouteCostTooHighError"}}function Xt(o){return at(F,o)}async function Yt(o,i,l={}){var p;const x=l.chainId??B.chainId,c=l.provider??"across",d=`${B.creditsServerUrl}/credits-name-route?name=${encodeURIComponent(i)}&chainId=${x}&provider=${c}`,h=await Ke(d,{method:"GET",identity:o,metadata:{}});if(!h.ok){let a;try{a=(p=await h.json())==null?void 0:p.code}catch{}throw a==="ROUTE_COST_TOO_HIGH"?new Be:new Error(`fetchNameCreditRoute ${h.status}`)}return h.json()}function en(o,i){const l=ee.from(o.availableAmount),c=ee.from(F).sub(l);return{credits:[{value:o.amount,expiresAt:Number(o.expiresAt),salt:Ft(o.id)}],creditsSignatures:[o.signature],externalCall:{target:i.externalCall.target,selector:i.externalCall.selector,data:i.externalCall.data,expiresAt:i.externalCall.expiresAt,salt:i.externalCall.salt},customExternalCallSignature:i.customExternalCallSignature,maxUncreditedValue:c.isNegative()?"0":c.toString(),maxCreditedValue:F}}async function tn(o,i={}){const l=Qt,x=i.intervalMs??1e4,c=i.maxAttempts??60;let d={status:"pending",destinationTxHash:null,actionsSucceeded:!1};for(let h=0;h<c;h++){try{const p=await fetch(`${l}/deposit/status?originChainId=137&depositTxHash=${o}`);if(p.ok){const a=await p.json(),u=(a.status??"pending").toLowerCase(),b=a.fillTx??a.fillTxnRef??null,w=a.actionsSucceeded!==!1;if(u==="filled")return{status:"filled",destinationTxHash:b,actionsSucceeded:w};if(u==="refunded"||u==="expired")return{status:u,destinationTxHash:null,actionsSucceeded:!1};d={status:"pending",destinationTxHash:b,actionsSucceeded:w}}}catch{}h<c-1&&await new Promise(p=>setTimeout(p,x))}return d}async function nn(o){const{name:i,identity:l,signer:x}=o,c=o.chainId??B.chainId,d=o.provider??"across",h=(o.beneficiary??await x.getAddress()).toLowerCase();let p=null,a=!1;console.info("[names] register start",{name:i,buyer:h,chainId:c,provider:d});try{const u=await Lt(c),b=Xt(u);console.info("[names] step 1/6 sized reservation",{usdCents:b,manaRate:u});const w=await Yt(l,i,{chainId:c,provider:d});console.info("[names] step 2/6 route fetched",{target:w.externalCall.target,selector:w.externalCall.selector,provider:w.provider,quoteId:w.quoteId});const j=await Ze(l,b);if(p=j.credit.id,console.info("[names] step 3/6 credit authorized",{creditId:j.credit.id,maxCreditedValue:j.maxCreditedValue}),ee.from(j.maxCreditedValue).lt(F))throw new Error("Credit under-sized for the name price");const $=en(j.credit,w);let f;try{f=await Nt({chainId:c,buyer:h,signer:x,args:$})}catch(y){if(!(y instanceof Mt))throw y;f=await Bt(c,$,x)}if(console.info("[names] step 4/6 useCredits submitted (Polygon origin tx)",{originTxHash:f}),await Pt(f),a=!0,console.info("[names] step 5/6 origin tx confirmed",{originTxHash:f}),d==="across"){const y=await tn(f,o.acrossPoll);if(console.info("[names] step 6/6 across status",y),y.status==="pending")return{status:"pending",originTxHash:f};if(y.status!=="filled"||!y.actionsSucceeded)throw new Error("The name could not be registered on Ethereum; your funds were recovered.");return{status:"registered",originTxHash:f,destinationTxHash:y.destinationTxHash}}return{status:"pending",originTxHash:f}}catch(u){if(console.error("[names] register failed — raw error:",u,{name:i,buyer:h,originConfirmed:a}),u instanceof Wt)return{status:"pending",originTxHash:u.txHash};if(p&&!a&&await Je(l,[p]).catch(()=>{}),u instanceof Be)throw u;const b=new Error(Ht(u,"Couldn't register the name. Please try again.",{sale:!0}));throw b.cause=u,b}}const sn=n.div`
1
+ import{b as ze,r as m,j as e,u as Ve}from"./react-vyZjIDcS.js";import{c as B,au as Ze,av as Je,d as Ke,s as n,t,n as Ie,al as Qe,E as Xe,J as Ae,y as Ye,e as s,I as R,z as W,aR as he,aj as et,ar as K,ay as tt,ax as nt,m as Ne,o as st,S as fe,A as O,aS as ot,aT as it}from"./index-yJi2QIJf.js";import{u as rt}from"./useSecondarySales-BLnZD7gi.js";import{a as at,m as Me}from"./mana-convert-DTic_WF4.js";import{u as Pe}from"./useManaRate-DwO6H8fK.js";import{g as lt,h as ct,i as dt,j as pt,k as xt,C as ht,l as ft,o as mt,m as ut,n as gt,M as bt,p as yt,E as wt,q as jt,r as vt,s as $t,t as Ct,u as kt,v as St}from"./Assets.styles-Dm_MgfhY.js";import{c as me,R as Et,F as Rt,S as Tt}from"./categories-P1zgLmzy.js";import{L as _t}from"./LoadMore-BI2cyij4.js";import{u as zt}from"./useInfiniteGrid-CDkGdzFf.js";import{E as It}from"./ErrorNotice-C2qBxBzo.js";import{d as At}from"./dcl-schemas-BICTSpB5.js";import{s as Nt,G as Mt,w as Pt,S as Wt}from"./buy-gasless-DoEdxK3L.js";import{s as Bt}from"./buy-DLi3_94e.js";import{i as Ft}from"./trade-encoding-BFXwI1r3.js";import{r as Lt}from"./mana-rate-DTd_zYK_.js";import{f as Ht}from"./errors-D660SWgT.js";import{J as Ut,C as Ot,B as ee}from"./ethers-CXBJm_wN.js";import{n as Gt}from"./Tooltip-DFmfpHxa.js";import{G as Dt}from"./grid.styles-D4B-EHGj.js";import"./sentry-B35L1FdR.js";import"./intl-CBcMB1D2.js";import"./authorizations-BrAVsIY_.js";import"./sendMetaTransaction-BOtIj1YL.js";function G(o){const i=o.source??"item",l=o.tradeId||`${o.contractAddress}-${o.tokenId??o.itemId??""}`;return`${i}:${l}`}const F="100000000000000000000",We=2,Q=15,qt=/^[a-zA-Z0-9]+$/;function ue(o){const i=o.trim();return i.length===0?{ok:!1,reason:"empty"}:qt.test(i)?i.length<We?{ok:!1,reason:"too-short"}:i.length>Q?{ok:!1,reason:"too-long"}:{ok:!0}:{ok:!1,reason:"invalid-chars"}}function Vt(o){return o.replace(/[^a-zA-Z0-9]/g,"").slice(0,Q)}const Zt=["function available(string _subdomain) view returns (bool)"],ge={mainnet:{rpc:"https://rpc.decentraland.org/mainnet",address:"0x2a187453064356c898cae034eaed119e1663acb8"},sepolia:{rpc:"https://rpc.decentraland.org/sepolia",address:"0x7518456ae93eb98f3e64571b689c626616bb7f30"}};function Jt(){return B.chainId===Number(At.ChainId.MATIC_MAINNET)?ge.mainnet:ge.sepolia}async function Kt(o,i={}){var p;const{rpc:l,address:x}=Jt(),c=new Ut(l),d=new Ot(x,Zt,c);console.info(`[names] availability check → DCLRegistrar(${x}).available("${o}") on ${l}`);const h=await d.available(o);if((p=i.signal)!=null&&p.aborted)throw new DOMException("Aborted","AbortError");return console.info(`[names] "${o}" available=${h}`),h?"available":"taken"}const Qt="https://app.across.to/api";class Be extends Error{constructor(){super("Name registration is temporarily unavailable due to high network costs"),this.name="NameRouteCostTooHighError"}}function Xt(o){return at(F,o)}async function Yt(o,i,l={}){var p;const x=l.chainId??B.chainId,c=l.provider??"across",d=`${B.creditsServerUrl}/credits-name-route?name=${encodeURIComponent(i)}&chainId=${x}&provider=${c}`,h=await Ke(d,{method:"GET",identity:o,metadata:{}});if(!h.ok){let a;try{a=(p=await h.json())==null?void 0:p.code}catch{}throw a==="ROUTE_COST_TOO_HIGH"?new Be:new Error(`fetchNameCreditRoute ${h.status}`)}return h.json()}function en(o,i){const l=ee.from(o.availableAmount),c=ee.from(F).sub(l);return{credits:[{value:o.amount,expiresAt:Number(o.expiresAt),salt:Ft(o.id)}],creditsSignatures:[o.signature],externalCall:{target:i.externalCall.target,selector:i.externalCall.selector,data:i.externalCall.data,expiresAt:i.externalCall.expiresAt,salt:i.externalCall.salt},customExternalCallSignature:i.customExternalCallSignature,maxUncreditedValue:c.isNegative()?"0":c.toString(),maxCreditedValue:F}}async function tn(o,i={}){const l=Qt,x=i.intervalMs??1e4,c=i.maxAttempts??60;let d={status:"pending",destinationTxHash:null,actionsSucceeded:!1};for(let h=0;h<c;h++){try{const p=await fetch(`${l}/deposit/status?originChainId=137&depositTxHash=${o}`);if(p.ok){const a=await p.json(),u=(a.status??"pending").toLowerCase(),b=a.fillTx??a.fillTxnRef??null,w=a.actionsSucceeded!==!1;if(u==="filled")return{status:"filled",destinationTxHash:b,actionsSucceeded:w};if(u==="refunded"||u==="expired")return{status:u,destinationTxHash:null,actionsSucceeded:!1};d={status:"pending",destinationTxHash:b,actionsSucceeded:w}}}catch{}h<c-1&&await new Promise(p=>setTimeout(p,x))}return d}async function nn(o){const{name:i,identity:l,signer:x}=o,c=o.chainId??B.chainId,d=o.provider??"across",h=(o.beneficiary??await x.getAddress()).toLowerCase();let p=null,a=!1;console.info("[names] register start",{name:i,buyer:h,chainId:c,provider:d});try{const u=await Lt(c),b=Xt(u);console.info("[names] step 1/6 sized reservation",{usdCents:b,manaRate:u});const w=await Yt(l,i,{chainId:c,provider:d});console.info("[names] step 2/6 route fetched",{target:w.externalCall.target,selector:w.externalCall.selector,provider:w.provider,quoteId:w.quoteId});const j=await Ze(l,b);if(p=j.credit.id,console.info("[names] step 3/6 credit authorized",{creditId:j.credit.id,maxCreditedValue:j.maxCreditedValue}),ee.from(j.maxCreditedValue).lt(F))throw new Error("Credit under-sized for the name price");const $=en(j.credit,w);let f;try{f=await Nt({chainId:c,buyer:h,signer:x,args:$})}catch(y){if(!(y instanceof Mt))throw y;f=await Bt(c,$,x)}if(console.info("[names] step 4/6 useCredits submitted (Polygon origin tx)",{originTxHash:f}),await Pt(f),a=!0,console.info("[names] step 5/6 origin tx confirmed",{originTxHash:f}),d==="across"){const y=await tn(f,o.acrossPoll);if(console.info("[names] step 6/6 across status",y),y.status==="pending")return{status:"pending",originTxHash:f};if(y.status!=="filled"||!y.actionsSucceeded)throw new Error("The name could not be registered on Ethereum; your funds were recovered.");return{status:"registered",originTxHash:f,destinationTxHash:y.destinationTxHash}}return{status:"pending",originTxHash:f}}catch(u){if(console.error("[names] register failed — raw error:",u,{name:i,buyer:h,originConfirmed:a}),u instanceof Wt)return{status:"pending",originTxHash:u.txHash};if(p&&!a&&await Je(l,[p]).catch(()=>{}),u instanceof Be)throw u;const b=new Error(Ht(u,"Couldn't register the name. Please try again.",{sale:!0}));throw b.cause=u,b}}const sn=n.div`
2
2
  position: fixed;
3
3
  inset: 0;
4
4
  z-index: 10000;
@@ -366,7 +366,7 @@ import{b as ze,r as m,j as e,u as Ve}from"./react-vyZjIDcS.js";import{c as B,au
366
366
  flex: none;
367
367
  color: ${t.colors.dclRed};
368
368
  }
369
- `;function Sn({name:o,priceCredits:i,onClose:l}){const{session:x}=Ie(),{data:c,isError:d}=Qe(x),h=Xe(),p=ze(),[a,u]=m.useState("confirm"),[b,w]=m.useState(""),[j,$]=m.useState(null),f=m.useRef(!1),y=b.trim().toLowerCase()===o.toLowerCase(),v=a==="completing",k=i!=null?Ae(i):"—";m.useEffect(()=>{const g=T=>{T.key==="Escape"&&!v&&l()};document.addEventListener("keydown",g);const I=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",g),document.body.style.overflow=I}},[v,l]);async function C(){if(!(!x||!y||f.current)){f.current=!0,u("completing"),$(null);try{await nn({name:o,identity:x.identity,signer:x.signer}),K("Shop Completed Purchase",{purchase_type:"name",is_primary:!0,payment_type:"credits",value_credits:i??null}),h.invalidateQueries({queryKey:["usd-balance"]}),h.invalidateQueries({queryKey:["my-assets"]}),u("success")}catch(g){K(nt(g)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:tt(g),purchase_type:"name"}),$((g==null?void 0:g.message)||s("names.errorGeneric")),u("error")}finally{f.current=!1}}}const z=a!=="success",E=Ye(x==null?void 0:x.providerType);return e.jsx(sn,{onClick:v?void 0:l,role:"presentation",children:e.jsxs(on,{role:"dialog","aria-modal":"true","aria-label":s("names.buyTitle"),onClick:g=>g.stopPropagation(),children:[z&&e.jsxs(e.Fragment,{children:[e.jsxs(be,{children:[e.jsx(ye,{children:a==="error"?s("names.errorTitle"):s("names.buyTitle")}),e.jsx(we,{onClick:l,disabled:v,"aria-label":s("buyModal.close"),children:e.jsx(R,{name:"close"})})]}),e.jsxs(je,{children:[s("names.myCreditsBalance")," ",e.jsx(W,{})," ",he(c,d)]}),e.jsx(ve,{})]}),(a==="confirm"||a==="error")&&e.jsxs(e.Fragment,{children:[e.jsxs($e,{children:[e.jsx(Ce,{"aria-hidden":!0,children:"@"}),e.jsxs(ke,{children:[e.jsxs(Se,{children:[o,e.jsx("span",{children:".dcl.eth"})]}),e.jsx(Ee,{children:s("names.subtitle")})]}),e.jsxs(Re,{children:[e.jsx(W,{}),k]})]}),a==="error"?e.jsxs(e.Fragment,{children:[e.jsxs(kn,{children:[e.jsx(R,{name:"info","aria-hidden":!0}),e.jsx("span",{children:j})]}),e.jsx(Te,{onClick:()=>u("confirm"),children:s("names.tryAgain")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(rn,{children:[e.jsx(an,{children:s("names.confirmTitle")}),e.jsx(ln,{dangerouslySetInnerHTML:{__html:s("names.confirmBody",{name:`<b>@${En(o)}</b>`})}}),e.jsxs(cn,{children:[e.jsx(dn,{"aria-hidden":!0,children:"@"}),e.jsx(pn,{value:b,onChange:g=>w(g.target.value.replace(/[^a-zA-Z0-9]/g,"")),placeholder:"yourname","aria-label":s("names.reenterAria"),autoComplete:"off",spellCheck:!1,style:{width:`${Math.max(b.length,8)}ch`}}),e.jsx(xn,{children:".dcl.eth"})]})]}),e.jsx(Te,{onClick:()=>void C(),disabled:!y||!x,children:s("names.buyCta")})]})]}),a==="completing"&&e.jsxs(hn,{children:[e.jsx(fn,{src:et,alt:"",width:56,height:56}),e.jsx(mn,{children:E?s("names.confirming"):s("names.completing")}),e.jsxs(un,{children:[e.jsx(gn,{"aria-hidden":!0,children:e.jsx("span",{})}),e.jsx(bn,{children:"1/1"})]})]}),a==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs(be,{children:[e.jsx(ye,{children:s("names.successHeaderTitle")}),e.jsx(we,{onClick:l,"aria-label":s("buyModal.close"),children:e.jsx(R,{name:"close"})})]}),e.jsxs(je,{children:[s("names.myCreditsBalance")," ",e.jsx(W,{})," ",he(c,d)]}),e.jsx(ve,{}),e.jsxs(yn,{children:[e.jsx(wn,{"aria-hidden":!0,children:e.jsx(R,{name:"check"})}),e.jsxs(jn,{children:[e.jsx("b",{children:s("names.successBannerBold")})," ",s("names.successBannerRest")]})]}),e.jsxs($e,{style:{marginTop:20},children:[e.jsx(Ce,{"aria-hidden":!0,children:"@"}),e.jsxs(ke,{children:[e.jsxs(Se,{children:[o,e.jsx("span",{children:".dcl.eth"})]}),e.jsx(Ee,{children:s("names.subtitle")})]}),e.jsxs(Re,{children:[e.jsx(W,{}),k]})]}),e.jsxs(vn,{children:[e.jsx($n,{onClick:()=>{l(),p("/my-assets")},children:s("names.myItems")}),e.jsx(Cn,{href:B.profileUrl,target:"_blank",rel:"noopener noreferrer",children:s("names.assignToAvatar")})]})]})]})})}function En(o){return o.replace(/[&<>"']/g,i=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[i])}const Rn="https://cdn.decentraland.org/@dcl/shop/0.1.0-30565861644.commit-86fa62d/assets/identity-B4DXDuJP.webp",Tn="https://cdn.decentraland.org/@dcl/shop/0.1.0-30565861644.commit-86fa62d/assets/world-B-9aPlxu.webp",_n="https://cdn.decentraland.org/@dcl/shop/0.1.0-30565861644.commit-86fa62d/assets/invite-BfwIhP2C.webp",zn="https://cdn.decentraland.org/@dcl/shop/0.1.0-30565861644.commit-86fa62d/assets/governance-DnazlIjy.webp",In=n.div`
369
+ `;function Sn({name:o,priceCredits:i,onClose:l}){const{session:x}=Ie(),{data:c,isError:d}=Qe(x),h=Xe(),p=ze(),[a,u]=m.useState("confirm"),[b,w]=m.useState(""),[j,$]=m.useState(null),f=m.useRef(!1),y=b.trim().toLowerCase()===o.toLowerCase(),v=a==="completing",k=i!=null?Ae(i):"—";m.useEffect(()=>{const g=T=>{T.key==="Escape"&&!v&&l()};document.addEventListener("keydown",g);const I=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",g),document.body.style.overflow=I}},[v,l]);async function C(){if(!(!x||!y||f.current)){f.current=!0,u("completing"),$(null);try{await nn({name:o,identity:x.identity,signer:x.signer}),K("Shop Completed Purchase",{purchase_type:"name",is_primary:!0,payment_type:"credits",value_credits:i??null}),h.invalidateQueries({queryKey:["usd-balance"]}),h.invalidateQueries({queryKey:["my-assets"]}),u("success")}catch(g){K(nt(g)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:tt(g),purchase_type:"name"}),$((g==null?void 0:g.message)||s("names.errorGeneric")),u("error")}finally{f.current=!1}}}const z=a!=="success",E=Ye(x==null?void 0:x.providerType);return e.jsx(sn,{onClick:v?void 0:l,role:"presentation",children:e.jsxs(on,{role:"dialog","aria-modal":"true","aria-label":s("names.buyTitle"),onClick:g=>g.stopPropagation(),children:[z&&e.jsxs(e.Fragment,{children:[e.jsxs(be,{children:[e.jsx(ye,{children:a==="error"?s("names.errorTitle"):s("names.buyTitle")}),e.jsx(we,{onClick:l,disabled:v,"aria-label":s("buyModal.close"),children:e.jsx(R,{name:"close"})})]}),e.jsxs(je,{children:[s("names.myCreditsBalance")," ",e.jsx(W,{})," ",he(c,d)]}),e.jsx(ve,{})]}),(a==="confirm"||a==="error")&&e.jsxs(e.Fragment,{children:[e.jsxs($e,{children:[e.jsx(Ce,{"aria-hidden":!0,children:"@"}),e.jsxs(ke,{children:[e.jsxs(Se,{children:[o,e.jsx("span",{children:".dcl.eth"})]}),e.jsx(Ee,{children:s("names.subtitle")})]}),e.jsxs(Re,{children:[e.jsx(W,{}),k]})]}),a==="error"?e.jsxs(e.Fragment,{children:[e.jsxs(kn,{children:[e.jsx(R,{name:"info","aria-hidden":!0}),e.jsx("span",{children:j})]}),e.jsx(Te,{onClick:()=>u("confirm"),children:s("names.tryAgain")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(rn,{children:[e.jsx(an,{children:s("names.confirmTitle")}),e.jsx(ln,{dangerouslySetInnerHTML:{__html:s("names.confirmBody",{name:`<b>@${En(o)}</b>`})}}),e.jsxs(cn,{children:[e.jsx(dn,{"aria-hidden":!0,children:"@"}),e.jsx(pn,{value:b,onChange:g=>w(g.target.value.replace(/[^a-zA-Z0-9]/g,"")),placeholder:"yourname","aria-label":s("names.reenterAria"),autoComplete:"off",spellCheck:!1,style:{width:`${Math.max(b.length,8)}ch`}}),e.jsx(xn,{children:".dcl.eth"})]})]}),e.jsx(Te,{onClick:()=>void C(),disabled:!y||!x,children:s("names.buyCta")})]})]}),a==="completing"&&e.jsxs(hn,{children:[e.jsx(fn,{src:et,alt:"",width:56,height:56}),e.jsx(mn,{children:E?s("names.confirming"):s("names.completing")}),e.jsxs(un,{children:[e.jsx(gn,{"aria-hidden":!0,children:e.jsx("span",{})}),e.jsx(bn,{children:"1/1"})]})]}),a==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs(be,{children:[e.jsx(ye,{children:s("names.successHeaderTitle")}),e.jsx(we,{onClick:l,"aria-label":s("buyModal.close"),children:e.jsx(R,{name:"close"})})]}),e.jsxs(je,{children:[s("names.myCreditsBalance")," ",e.jsx(W,{})," ",he(c,d)]}),e.jsx(ve,{}),e.jsxs(yn,{children:[e.jsx(wn,{"aria-hidden":!0,children:e.jsx(R,{name:"check"})}),e.jsxs(jn,{children:[e.jsx("b",{children:s("names.successBannerBold")})," ",s("names.successBannerRest")]})]}),e.jsxs($e,{style:{marginTop:20},children:[e.jsx(Ce,{"aria-hidden":!0,children:"@"}),e.jsxs(ke,{children:[e.jsxs(Se,{children:[o,e.jsx("span",{children:".dcl.eth"})]}),e.jsx(Ee,{children:s("names.subtitle")})]}),e.jsxs(Re,{children:[e.jsx(W,{}),k]})]}),e.jsxs(vn,{children:[e.jsx($n,{onClick:()=>{l(),p("/my-assets")},children:s("names.myItems")}),e.jsx(Cn,{href:B.profileUrl,target:"_blank",rel:"noopener noreferrer",children:s("names.assignToAvatar")})]})]})]})})}function En(o){return o.replace(/[&<>"']/g,i=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[i])}const Rn="https://cdn.decentraland.org/@dcl/shop/0.1.0-30612955316.commit-0d9b744/assets/identity-B4DXDuJP.webp",Tn="https://cdn.decentraland.org/@dcl/shop/0.1.0-30612955316.commit-0d9b744/assets/world-B-9aPlxu.webp",_n="https://cdn.decentraland.org/@dcl/shop/0.1.0-30612955316.commit-0d9b744/assets/invite-BfwIhP2C.webp",zn="https://cdn.decentraland.org/@dcl/shop/0.1.0-30612955316.commit-0d9b744/assets/governance-DnazlIjy.webp",In=n.div`
370
370
  width: 100%;
371
371
  min-width: 0;
372
372
  `,An=n.nav`
@@ -1,4 +1,4 @@
1
- import{r as $,j as t}from"./react-vyZjIDcS.js";import{R as C,a as oe,C as ie,b as ne}from"./categories-CX6i4K78.js";import{n as c,T as se}from"./Tooltip-BbHzoPIy.js";import{t as e,s as o,I as g,e as s,o as ae,h as v}from"./index-BnbwrW-6.js";const re=o.div`
1
+ import{r as $,j as t}from"./react-vyZjIDcS.js";import{R as C,a as oe,C as ie,b as ne}from"./categories-P1zgLmzy.js";import{n as c,T as se}from"./Tooltip-DFmfpHxa.js";import{t as e,s as o,I as g,e as s,o as ae,h as v}from"./index-yJi2QIJf.js";const re=o.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: 12px;
@@ -1,4 +1,4 @@
1
- import{j as t,L as R,r as M}from"./react-vyZjIDcS.js";import{s as a,B as N,t as o,x as I,m as F,e,n as B,y as W,I as f,z as G,D as K,u as w,E as P,c as Q,F as k,l as H,q as $}from"./index-BnbwrW-6.js";import{a as O,b as _,c as X,d as J,s as U,f as V}from"./authorizations-B6wWjXdQ.js";import{a as Y}from"./builder-DJzcrQAM.js";import{f as Z}from"./errors-BYKPLdNJ.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";import"./sendMetaTransaction-DVALeVb8.js";const tt=I`
1
+ import{j as t,L as R,r as M}from"./react-vyZjIDcS.js";import{s as a,B as N,t as o,x as I,m as F,e,n as B,y as W,I as f,z as G,D as K,u as w,E as P,c as Q,F as k,l as H,q as $}from"./index-yJi2QIJf.js";import{a as O,b as _,c as X,d as J,s as U,f as V}from"./authorizations-BrAVsIY_.js";import{a as Y}from"./builder-BW_vsdgs.js";import{f as Z}from"./errors-D660SWgT.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";import"./sendMetaTransaction-BOtIj1YL.js";const tt=I`
2
2
  to { transform: rotate(360deg); }
3
3
  `,it=I`
4
4
  to { background-position: -200% 0; }
@@ -1,4 +1,4 @@
1
- import{j as e,L as ge,r as S,b as Rt,a as Wt}from"./react-vyZjIDcS.js";import{t as Z,s as i,e as a,J as X,aj as Ft,G as Lt,I as _,z as ut,H as Pe,m as Kt,ak as q,Q as Ye,n as Nt,u as Qt,al as Ut,E as Ot,am as Ht,an as Vt,ao as Gt,ap as Dt,y as Yt,aq as Je,ar as N,as as Xe,at as Jt,l as V,c as Ze,h as Xt,au as et,av as je,aw as ke,ax as oe,ay as tt,a as ce,b as Zt,C as $e,az as ea}from"./index-BnbwrW-6.js";import{M as ta,S as aa,C as sa,H as na,a as ia,T as ra,X as oa,b as ca,B as la,c as da,d as at,e as ua,f as he,P as ht,m as ha,g as pa,h as ga,i as xa,j as pt,k as pe,L as ma,l as fa,n as st,o as nt,W as ya,p as ba,q as va,A as Ca,r as wa,s as ja,t as ka,u as $a,v as Sa,w as Ma,x as Ta,y as za,z as Pa,D as Aa,E as Ia,F as qa,G as _a,I as Ba,J as Ea,K as Se,N as Ra,O as Wa,Q as Fa,R as La,U as it,V as Ka,Y as Na,Z as Qa,_ as Ua}from"./CollectionCarousel-Bns794gp.js";import{u as Oa}from"./useManaRate-DJlj41tJ.js";import{r as Ha}from"./mana-rate-CFfqtCHS.js";import{i as Va,j as Ga,f as Da,n as Ya,h as Ja,A as Xa}from"./authorizations-B6wWjXdQ.js";import{b as Me}from"./buy-D3hY4JG8.js";import{b as Za,w as es,S as ts,G as as}from"./buy-gasless-CmOMFX1L.js";import{u as ss,M as ns,R as le,r as is,c as rs}from"./useCreditPacks-DTZSsQrR.js";import{i as os,a as cs}from"./errors-BYKPLdNJ.js";import{E as ls}from"./ErrorNotice-Z0D8os9s.js";import{u as rt}from"./mana-convert-Bc7WVBn5.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-ZhCceq00.js";import"./sendMetaTransaction-DVALeVb8.js";const{colors:G,radius:ds}=Z,us=i.div`
1
+ import{j as e,L as ge,r as S,b as Rt,a as Wt}from"./react-vyZjIDcS.js";import{t as Z,s as i,e as a,J as X,aj as Ft,G as Lt,I as _,z as ut,H as Pe,m as Kt,ak as q,Q as Ye,n as Nt,u as Qt,al as Ut,E as Ot,am as Ht,an as Vt,ao as Gt,ap as Dt,y as Yt,aq as Je,ar as N,as as Xe,at as Jt,l as V,c as Ze,h as Xt,au as et,av as je,aw as ke,ax as oe,ay as tt,a as ce,b as Zt,C as $e,az as ea}from"./index-yJi2QIJf.js";import{M as ta,S as aa,C as sa,H as na,a as ia,T as ra,X as oa,b as ca,B as la,c as da,d as at,e as ua,f as he,P as ht,m as ha,g as pa,h as ga,i as xa,j as pt,k as pe,L as ma,l as fa,n as st,o as nt,W as ya,p as ba,q as va,A as Ca,r as wa,s as ja,t as ka,u as $a,v as Sa,w as Ma,x as Ta,y as za,z as Pa,D as Aa,E as Ia,F as qa,G as _a,I as Ba,J as Ea,K as Se,N as Ra,O as Wa,Q as Fa,R as La,U as it,V as Ka,Y as Na,Z as Qa,_ as Ua}from"./CollectionCarousel-oh8d08gi.js";import{u as Oa}from"./useManaRate-DwO6H8fK.js";import{r as Ha}from"./mana-rate-DTd_zYK_.js";import{i as Va,j as Ga,f as Da,n as Ya,h as Ja,A as Xa}from"./authorizations-BrAVsIY_.js";import{b as Me}from"./buy-DLi3_94e.js";import{b as Za,w as es,S as ts,G as as}from"./buy-gasless-DoEdxK3L.js";import{u as ss,M as ns,R as le,r as is,c as rs}from"./useCreditPacks-DnQLmQo7.js";import{i as os,a as cs}from"./errors-D660SWgT.js";import{E as ls}from"./ErrorNotice-C2qBxBzo.js";import{u as rt}from"./mana-convert-DTic_WF4.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-BFXwI1r3.js";import"./sendMetaTransaction-BOtIj1YL.js";const{colors:G,radius:ds}=Z,us=i.div`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
@@ -58,7 +58,7 @@ import{j as e,L as ge,r as S,b as Rt,a as Wt}from"./react-vyZjIDcS.js";import{t
58
58
  font-weight: 700;
59
59
  color: ${G.text};
60
60
  }
61
- `,ms="https://cdn.decentraland.org/@dcl/shop/0.1.0-30565861644.commit-86fa62d/assets/buy-error-22UunaPC.png";function fs(c){const{phase:d,balanceCredits:$,onClose:M}=c,B=d==="processing",W=d==="error"?a("cartCheckout.errorTitle"):d==="nofunds"?a("cartCheckout.titleNoFunds"):d==="choose"?a("buyModal.choosePayment"):a("cartCheckout.titleBuy"),F=d==="processing";return e.jsxs(ta,{role:"dialog","aria-modal":"true","aria-label":a("cartCheckout.dialogAria"),children:[e.jsx(aa,{onClick:B?void 0:M,"aria-hidden":!0}),e.jsxs(sa,{"data-tall":F||void 0,children:[e.jsxs(na,{children:[e.jsxs(ia,{children:[e.jsx(ra,{children:W}),!B&&e.jsx(oa,{onClick:M,"aria-label":a("buyModal.close"),children:e.jsx(ca,{})})]}),e.jsxs(la,{children:[e.jsx(da,{children:d==="nofunds"?a("buyModal.dclBalance"):a("buyModal.myCreditsBalance")}),e.jsx(at,{}),e.jsx(ua,{children:X($)})]})]}),d==="choose"&&e.jsxs(he,{children:[e.jsxs(xs,{children:[e.jsx("span",{children:a("cart.purchaseSummary")}),e.jsxs("strong",{children:[e.jsx(at,{}),X(c.totalCredits??0)]})]}),e.jsx(ht,{options:c.options??[],totalCents:c.totalCents??0,onPay:c.onPay??(()=>{}),rateNote:(()=>{const P=ha(c.totalCents??0,c.totalManaWei??0n);return P!=null?a("buyModal.manaRate",{mana:P.toLocaleString("en",{maximumFractionDigits:2})}):null})()})]}),d==="processing"&&e.jsx(ys,{stage:c.stage??"reserving",step:c.step??1,total:c.total??1,isSelfCustody:!!c.isSelfCustody}),d==="nofunds"&&e.jsx(bs,{lines:c.lines??[],shortfallCredits:c.shortfallCredits??0,packs:c.packs??[],selectedPack:c.selectedPack??"",onSelectPack:c.onSelectPack??(()=>{}),onBuyPacks:c.onBuyPacks??(()=>{}),onCancel:M}),d==="error"&&e.jsxs(he,{children:[e.jsxs(pa,{"data-testid":"buy-error",children:[e.jsx(ga,{src:ms,alt:"",width:64,height:80}),e.jsxs(xa,{children:[e.jsx("b",{children:a("cartCheckout.errorHeadline")})," ",a("cartCheckout.errorBody")]})]}),e.jsxs(pt,{children:[e.jsx(pe,{"data-variant":"outline",onClick:M,children:a("buyModal.cancel")}),e.jsx(pe,{"data-variant":"purple",onClick:c.onRetry??M,children:a("cartCheckout.tryAgain")})]})]})]})]})}function ys({stage:c,step:d,total:$,isSelfCustody:M}){const B=c==="reserving",W=$>0?Math.min(100,Math.round(d/$*100)):0,F=c==="awaiting-signature"?M?a("buyModal.confirmToContinue"):a("buyModal.completingTransaction"):c==="settling"?a("buyModal.completingTransaction"):a("cartCheckout.preparing");return e.jsxs(he,{"data-processing":!0,children:[e.jsx(ma,{src:Ft,alt:"",width:61,height:61}),e.jsx(fa,{children:F}),B?e.jsxs(us,{children:[e.jsx(st,{"aria-hidden":!0,children:e.jsx(nt,{"data-step":!0,style:{width:`${W}%`}})}),$>1?e.jsxs(hs,{children:[d,"/",$]}):null]}):e.jsx(st,{"aria-hidden":!0,children:e.jsx(nt,{})})]})}function bs({lines:c,shortfallCredits:d,packs:$,selectedPack:M,onSelectPack:B,onBuyPacks:W,onCancel:F}){const P=$.find(n=>n.id===M),xe=c.reduce((n,I)=>n+(I.quantity??1),0);return e.jsxs(he,{children:[e.jsxs(ya,{"data-testid":"nofunds-warning",children:[e.jsx(ba,{}),e.jsxs(va,{children:[e.jsx("b",{children:a("buyModal.insufficientFunds")})," ",a("buyModal.warningNeedToBuy")," ",e.jsx("b",{children:a("buyModal.warningCreditsAmount",{count:Math.max(0,d)})})," ",a("buyModal.warningToPurchase",{count:xe})]})]}),e.jsx(ps,{children:c.map(n=>{const I=n.quantity??1;return e.jsxs(Ca,{children:[e.jsx(wa,{children:n.item.thumbnail?e.jsx("img",{src:n.item.thumbnail,alt:""}):null}),e.jsxs(ja,{children:[e.jsxs("div",{children:[e.jsxs(ka,{title:n.item.name,children:[n.item.name||a("buyModal.itemFallback"),I>1?e.jsx(gs,{children:a("cartCheckout.qty",{count:I})}):null]}),n.item.creator?e.jsx($a,{address:n.item.creator}):null]}),e.jsxs(Sa,{children:[e.jsx(Ma,{}),e.jsx("span",{children:X(n.priceCredits*I)})]})]})]},n.item.id)})}),e.jsx(Ta,{children:$.map(n=>{const I=n.id===M;return e.jsxs(za,{"data-testid":"credit-pack","data-on":I||void 0,onClick:()=>B(n.id),children:[e.jsx(Pa,{}),e.jsx(Aa,{children:X(n.credits)}),e.jsxs(Ia,{children:["($",n.usd.toFixed(2),")"]})]},n.id)})}),e.jsxs(qa,{children:[e.jsxs(_a,{children:[e.jsx(Ba,{}),e.jsx("span",{children:X((P==null?void 0:P.credits)??0)})]}),e.jsxs(Ea,{children:["$",((P==null?void 0:P.usd)??0).toFixed(2)]})]}),e.jsxs(pt,{children:[e.jsx(pe,{"data-variant":"outline",onClick:F,children:a("buyModal.cancel")}),e.jsx(pe,{"data-variant":"gradient",onClick:W,children:a("buyModal.buy")})]})]})}const{colors:o,gradients:gt,radius:Q}=Z,xt="@media (max-width: 1080px)",k="@media (max-width: 880px)",ot=i.div`
61
+ `,ms="https://cdn.decentraland.org/@dcl/shop/0.1.0-30612955316.commit-0d9b744/assets/buy-error-22UunaPC.png";function fs(c){const{phase:d,balanceCredits:$,onClose:M}=c,B=d==="processing",W=d==="error"?a("cartCheckout.errorTitle"):d==="nofunds"?a("cartCheckout.titleNoFunds"):d==="choose"?a("buyModal.choosePayment"):a("cartCheckout.titleBuy"),F=d==="processing";return e.jsxs(ta,{role:"dialog","aria-modal":"true","aria-label":a("cartCheckout.dialogAria"),children:[e.jsx(aa,{onClick:B?void 0:M,"aria-hidden":!0}),e.jsxs(sa,{"data-tall":F||void 0,children:[e.jsxs(na,{children:[e.jsxs(ia,{children:[e.jsx(ra,{children:W}),!B&&e.jsx(oa,{onClick:M,"aria-label":a("buyModal.close"),children:e.jsx(ca,{})})]}),e.jsxs(la,{children:[e.jsx(da,{children:d==="nofunds"?a("buyModal.dclBalance"):a("buyModal.myCreditsBalance")}),e.jsx(at,{}),e.jsx(ua,{children:X($)})]})]}),d==="choose"&&e.jsxs(he,{children:[e.jsxs(xs,{children:[e.jsx("span",{children:a("cart.purchaseSummary")}),e.jsxs("strong",{children:[e.jsx(at,{}),X(c.totalCredits??0)]})]}),e.jsx(ht,{options:c.options??[],totalCents:c.totalCents??0,onPay:c.onPay??(()=>{}),rateNote:(()=>{const P=ha(c.totalCents??0,c.totalManaWei??0n);return P!=null?a("buyModal.manaRate",{mana:P.toLocaleString("en",{maximumFractionDigits:2})}):null})()})]}),d==="processing"&&e.jsx(ys,{stage:c.stage??"reserving",step:c.step??1,total:c.total??1,isSelfCustody:!!c.isSelfCustody}),d==="nofunds"&&e.jsx(bs,{lines:c.lines??[],shortfallCredits:c.shortfallCredits??0,packs:c.packs??[],selectedPack:c.selectedPack??"",onSelectPack:c.onSelectPack??(()=>{}),onBuyPacks:c.onBuyPacks??(()=>{}),onCancel:M}),d==="error"&&e.jsxs(he,{children:[e.jsxs(pa,{"data-testid":"buy-error",children:[e.jsx(ga,{src:ms,alt:"",width:64,height:80}),e.jsxs(xa,{children:[e.jsx("b",{children:a("cartCheckout.errorHeadline")})," ",a("cartCheckout.errorBody")]})]}),e.jsxs(pt,{children:[e.jsx(pe,{"data-variant":"outline",onClick:M,children:a("buyModal.cancel")}),e.jsx(pe,{"data-variant":"purple",onClick:c.onRetry??M,children:a("cartCheckout.tryAgain")})]})]})]})]})}function ys({stage:c,step:d,total:$,isSelfCustody:M}){const B=c==="reserving",W=$>0?Math.min(100,Math.round(d/$*100)):0,F=c==="awaiting-signature"?M?a("buyModal.confirmToContinue"):a("buyModal.completingTransaction"):c==="settling"?a("buyModal.completingTransaction"):a("cartCheckout.preparing");return e.jsxs(he,{"data-processing":!0,children:[e.jsx(ma,{src:Ft,alt:"",width:61,height:61}),e.jsx(fa,{children:F}),B?e.jsxs(us,{children:[e.jsx(st,{"aria-hidden":!0,children:e.jsx(nt,{"data-step":!0,style:{width:`${W}%`}})}),$>1?e.jsxs(hs,{children:[d,"/",$]}):null]}):e.jsx(st,{"aria-hidden":!0,children:e.jsx(nt,{})})]})}function bs({lines:c,shortfallCredits:d,packs:$,selectedPack:M,onSelectPack:B,onBuyPacks:W,onCancel:F}){const P=$.find(n=>n.id===M),xe=c.reduce((n,I)=>n+(I.quantity??1),0);return e.jsxs(he,{children:[e.jsxs(ya,{"data-testid":"nofunds-warning",children:[e.jsx(ba,{}),e.jsxs(va,{children:[e.jsx("b",{children:a("buyModal.insufficientFunds")})," ",a("buyModal.warningNeedToBuy")," ",e.jsx("b",{children:a("buyModal.warningCreditsAmount",{count:Math.max(0,d)})})," ",a("buyModal.warningToPurchase",{count:xe})]})]}),e.jsx(ps,{children:c.map(n=>{const I=n.quantity??1;return e.jsxs(Ca,{children:[e.jsx(wa,{children:n.item.thumbnail?e.jsx("img",{src:n.item.thumbnail,alt:""}):null}),e.jsxs(ja,{children:[e.jsxs("div",{children:[e.jsxs(ka,{title:n.item.name,children:[n.item.name||a("buyModal.itemFallback"),I>1?e.jsx(gs,{children:a("cartCheckout.qty",{count:I})}):null]}),n.item.creator?e.jsx($a,{address:n.item.creator}):null]}),e.jsxs(Sa,{children:[e.jsx(Ma,{}),e.jsx("span",{children:X(n.priceCredits*I)})]})]})]},n.item.id)})}),e.jsx(Ta,{children:$.map(n=>{const I=n.id===M;return e.jsxs(za,{"data-testid":"credit-pack","data-on":I||void 0,onClick:()=>B(n.id),children:[e.jsx(Pa,{}),e.jsx(Aa,{children:X(n.credits)}),e.jsxs(Ia,{children:["($",n.usd.toFixed(2),")"]})]},n.id)})}),e.jsxs(qa,{children:[e.jsxs(_a,{children:[e.jsx(Ba,{}),e.jsx("span",{children:X((P==null?void 0:P.credits)??0)})]}),e.jsxs(Ea,{children:["$",((P==null?void 0:P.usd)??0).toFixed(2)]})]}),e.jsxs(pt,{children:[e.jsx(pe,{"data-variant":"outline",onClick:F,children:a("buyModal.cancel")}),e.jsx(pe,{"data-variant":"gradient",onClick:W,children:a("buyModal.buy")})]})]})}const{colors:o,gradients:gt,radius:Q}=Z,xt="@media (max-width: 1080px)",k="@media (max-width: 880px)",ot=i.div`
62
62
  max-width: 1510px;
63
63
  margin: 0 auto;
64
64
  /* Grows into the page's leftover height and passes it down to Upsell, so the white cross-sell band ends at
@@ -1,4 +1,4 @@
1
- import{M as N,N as U,O as o,P as n,H as D,x as M}from"./index-BnbwrW-6.js";import{r as w,j as g}from"./react-vyZjIDcS.js";import{g as z,a as E,c as I,b as F,s as v}from"./clsx-BRGjhjlu.js";function K(r){return z("MuiCircularProgress",r)}E("MuiCircularProgress",["root","determinate","indeterminate","colorPrimary","colorSecondary","svg","circle","circleDeterminate","circleIndeterminate","circleDisableShrink"]);const W=["className","color","disableShrink","size","style","thickness","value","variant"];let l=r=>r,P,b,S,$;const t=44,B=M(P||(P=l`
1
+ import{M as N,N as U,O as o,P as n,H as D,x as M}from"./index-yJi2QIJf.js";import{r as w,j as g}from"./react-vyZjIDcS.js";import{g as z,a as E,c as I,b as F,s as v}from"./clsx-DhFqZi_3.js";function K(r){return z("MuiCircularProgress",r)}E("MuiCircularProgress",["root","determinate","indeterminate","colorPrimary","colorSecondary","svg","circle","circleDeterminate","circleIndeterminate","circleDisableShrink"]);const W=["className","color","disableShrink","size","style","thickness","value","variant"];let l=r=>r,P,b,S,$;const t=44,B=M(P||(P=l`
2
2
  0% {
3
3
  transform: rotate(0deg);
4
4
  }
@@ -1,4 +1,4 @@
1
- import{j as e,r as m,e as Y,b as Z}from"./react-vyZjIDcS.js";import{t as v,s as c,af as J,ag as z,I as X,e as a,c as ee,l as te,u as ae,m as re,h as oe,S as E,A as ie,ah as se,ai as ne}from"./index-BnbwrW-6.js";import{E as ce}from"./ErrorNotice-Z0D8os9s.js";import{d as le,g as de,a as pe,P as xe,C as ue,b as me,c as ge,B as he,S as be,M as fe,A as je}from"./browseLayout.styles-B_NNL83E.js";import{u as ve}from"./useStore-HaFF1p2U.js";import{c as F,a as ye,F as Ce,d as we,P as Se,e as ke,H as Ae,S as Ne}from"./categories-CX6i4K78.js";import{L as $e}from"./LoadMore-DI4Wyn-C.js";import{u as Pe}from"./useInfiniteGrid-DxkPmxZ9.js";import{G as Me}from"./grid.styles-Cflo-ZKg.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";const Re=c.section`
1
+ import{j as e,r as m,e as Y,b as Z}from"./react-vyZjIDcS.js";import{t as v,s as c,af as J,ag as z,I as X,e as a,c as ee,l as te,u as ae,m as re,h as oe,S as E,A as ie,ah as se,ai as ne}from"./index-yJi2QIJf.js";import{E as ce}from"./ErrorNotice-C2qBxBzo.js";import{d as le,g as de,a as pe,P as xe,C as ue,b as me,c as ge,B as he,S as be,M as fe,A as je}from"./browseLayout.styles-Ck-h2OX5.js";import{u as ve}from"./useStore-Dt337zVA.js";import{c as F,a as ye,F as Ce,d as we,P as Se,e as ke,H as Ae,S as Ne}from"./categories-P1zgLmzy.js";import{L as $e}from"./LoadMore-BI2cyij4.js";import{u as Pe}from"./useInfiniteGrid-CDkGdzFf.js";import{G as Me}from"./grid.styles-D4B-EHGj.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";const Re=c.section`
2
2
  position: relative;
3
3
  border-radius: ${v.radius.card};
4
4
  overflow: hidden;
@@ -1,4 +1,4 @@
1
- import{j as t,r as v}from"./react-vyZjIDcS.js";import{s as e,t as o,e as g,z as k,J as j,bc as C,h as G,x as Y,I as Q,l as X,a as W,C as B,b as J,bd as Z,be as F,A as q}from"./index-BnbwrW-6.js";import{s as ee,h as U,A as H,g as K,r as te,m as ne,e as ae}from"./authorizations-B6wWjXdQ.js";import{i as ie}from"./errors-BYKPLdNJ.js";import{E as oe}from"./ErrorNotice-Z0D8os9s.js";import{a as se}from"./buy-D3hY4JG8.js";import{g as re,d as ce}from"./trade-encoding-ZhCceq00.js";import{s as de,M as le,E as pe}from"./sendMetaTransaction-DVALeVb8.js";import{I as he,C as ue}from"./ethers-CXBJm_wN.js";const L="shop:resume_after_signin",xe=900*1e3;function rt(a){try{sessionStorage.setItem(L,JSON.stringify({...a,at:Date.now()}))}catch{}}function ct(a){let n;try{n=sessionStorage.getItem(L)}catch{return null}if(!n)return null;try{sessionStorage.removeItem(L)}catch{}let i;try{i=JSON.parse(n)}catch{return null}return!i||i.type!==a||typeof i.at!="number"||Date.now()-i.at>xe?null:i.type==="cart-checkout"?{type:"cart-checkout"}:{type:"item-buy",path:i.path}}function ge(a,n){return(a+n-1n)/n}function fe(a,n,i){return a<=0||n<=0?0n:a>=n?i:ge(i*BigInt(a),BigInt(n))}function dt(a){var m,f,w;const n=Number.isFinite(a.priceCents)?Math.max(0,Math.trunc(a.priceCents)):0,i=Number.isFinite(a.balanceCents)?Math.max(0,Math.trunc(a.balanceCents)):0,s=a.priceManaWei>0n?a.priceManaWei:0n,d=a.manaBalanceWei>0n?a.manaBalanceWei:0n;if(n<=0)return{options:[],preferred:null,manaShortfall:null};const c=[];if(i>=n&&c.push({method:"credits",creditsCents:n,manaWei:0n}),s>0n&&i>0&&i<n){const l=n-i,b=fe(l,n,s);d>=b&&c.push({method:"combined",creditsCents:i,manaWei:b})}s>0n&&d>=s&&c.push({method:"mana",creditsCents:0,manaWei:s});const p=((m=c.find(l=>l.method==="credits"))==null?void 0:m.method)??((f=c.find(l=>l.method==="combined"))==null?void 0:f.method)??((w=c.find(l=>l.method==="mana"))==null?void 0:w.method)??null,y=!c.some(l=>l.method==="mana"||l.method==="combined")&&s>0n&&d>0n?{manaWei:d,manaCents:me(d,n,s),priceCents:n}:null;return{options:c,preferred:p,manaShortfall:y}}function me(a,n,i){return Number(a*BigInt(n)/i)}function lt(a,n){let i=Number.isFinite(n)?Math.max(0,Math.trunc(n)):0;return a.map(s=>{const d=Number.isFinite(s)?Math.max(0,Math.trunc(s)):0,c=Math.min(d,i);return i-=c,c})}function z(a){return Number.isFinite(a)?Math.max(0,a)/10:0}function pt(a,n){return a.options.find(i=>i.method===n)??null}function ht(a,n){if(!Number.isFinite(a)||a<=0||n<=0n)return null;const i=a/10;return Number(n)/1e18/i}const T="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Group%201'%3e%3cpath%20id='Vector'%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12%202L22%2012L12%2022L2%2012L12%202ZM12%204.8L19.2%2012L12%2019.2L4.8%2012L12%204.8ZM12%2015.6C12.9548%2015.6001%2013.8705%2015.2209%2014.5457%2014.5459C15.2209%2013.8708%2015.6003%2012.9552%2015.6004%2012.0004C15.6005%2011.0456%2015.2213%2010.1299%2014.5463%209.45471C13.8712%208.7795%2012.9556%208.40011%2012.0008%208.4C11.0461%208.4%2010.1304%208.77928%209.45525%209.45442C8.78012%2010.1295%208.40083%2011.0452%208.40083%2012C8.40083%2012.9548%208.78012%2013.8705%209.45525%2014.5456C10.1304%2015.2207%2011.0461%2015.6%2012.0008%2015.6H12Z'%20fill='white'/%3e%3cg%20id='Rectangle%201'%3e%3c/g%3e%3c/g%3e%3c/svg%3e",be=e.div`
1
+ import{j as t,r as v}from"./react-vyZjIDcS.js";import{s as e,t as o,e as g,z as k,J as j,bc as C,h as G,x as Y,I as Q,l as X,a as W,C as B,b as J,bd as Z,be as F,A as q}from"./index-yJi2QIJf.js";import{s as ee,h as U,A as H,g as K,r as te,m as ne,e as ae}from"./authorizations-BrAVsIY_.js";import{i as ie}from"./errors-D660SWgT.js";import{E as oe}from"./ErrorNotice-C2qBxBzo.js";import{a as se}from"./buy-DLi3_94e.js";import{g as re,d as ce}from"./trade-encoding-BFXwI1r3.js";import{s as de,M as le,E as pe}from"./sendMetaTransaction-BOtIj1YL.js";import{I as he,C as ue}from"./ethers-CXBJm_wN.js";const L="shop:resume_after_signin",xe=900*1e3;function rt(a){try{sessionStorage.setItem(L,JSON.stringify({...a,at:Date.now()}))}catch{}}function ct(a){let n;try{n=sessionStorage.getItem(L)}catch{return null}if(!n)return null;try{sessionStorage.removeItem(L)}catch{}let i;try{i=JSON.parse(n)}catch{return null}return!i||i.type!==a||typeof i.at!="number"||Date.now()-i.at>xe?null:i.type==="cart-checkout"?{type:"cart-checkout"}:{type:"item-buy",path:i.path}}function ge(a,n){return(a+n-1n)/n}function fe(a,n,i){return a<=0||n<=0?0n:a>=n?i:ge(i*BigInt(a),BigInt(n))}function dt(a){var m,f,w;const n=Number.isFinite(a.priceCents)?Math.max(0,Math.trunc(a.priceCents)):0,i=Number.isFinite(a.balanceCents)?Math.max(0,Math.trunc(a.balanceCents)):0,s=a.priceManaWei>0n?a.priceManaWei:0n,d=a.manaBalanceWei>0n?a.manaBalanceWei:0n;if(n<=0)return{options:[],preferred:null,manaShortfall:null};const c=[];if(i>=n&&c.push({method:"credits",creditsCents:n,manaWei:0n}),s>0n&&i>0&&i<n){const l=n-i,b=fe(l,n,s);d>=b&&c.push({method:"combined",creditsCents:i,manaWei:b})}s>0n&&d>=s&&c.push({method:"mana",creditsCents:0,manaWei:s});const p=((m=c.find(l=>l.method==="credits"))==null?void 0:m.method)??((f=c.find(l=>l.method==="combined"))==null?void 0:f.method)??((w=c.find(l=>l.method==="mana"))==null?void 0:w.method)??null,y=!c.some(l=>l.method==="mana"||l.method==="combined")&&s>0n&&d>0n?{manaWei:d,manaCents:me(d,n,s),priceCents:n}:null;return{options:c,preferred:p,manaShortfall:y}}function me(a,n,i){return Number(a*BigInt(n)/i)}function lt(a,n){let i=Number.isFinite(n)?Math.max(0,Math.trunc(n)):0;return a.map(s=>{const d=Number.isFinite(s)?Math.max(0,Math.trunc(s)):0,c=Math.min(d,i);return i-=c,c})}function z(a){return Number.isFinite(a)?Math.max(0,a)/10:0}function pt(a,n){return a.options.find(i=>i.method===n)??null}function ht(a,n){if(!Number.isFinite(a)||a<=0||n<=0n)return null;const i=a/10;return Number(n)/1e18/i}const T="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Group%201'%3e%3cpath%20id='Vector'%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12%202L22%2012L12%2022L2%2012L12%202ZM12%204.8L19.2%2012L12%2019.2L4.8%2012L12%204.8ZM12%2015.6C12.9548%2015.6001%2013.8705%2015.2209%2014.5457%2014.5459C15.2209%2013.8708%2015.6003%2012.9552%2015.6004%2012.0004C15.6005%2011.0456%2015.2213%2010.1299%2014.5463%209.45471C13.8712%208.7795%2012.9556%208.40011%2012.0008%208.4C11.0461%208.4%2010.1304%208.77928%209.45525%209.45442C8.78012%2010.1295%208.40083%2011.0452%208.40083%2012C8.40083%2012.9548%208.78012%2013.8705%209.45525%2014.5456C10.1304%2015.2207%2011.0461%2015.6%2012.0008%2015.6H12Z'%20fill='white'/%3e%3cg%20id='Rectangle%201'%3e%3c/g%3e%3c/g%3e%3c/svg%3e",be=e.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: 12px;
@@ -1,4 +1,4 @@
1
- import{b as Y,j as e,L as ue,e as fe,u as be,r as y}from"./react-vyZjIDcS.js";import{t as Z,aA as we,aB as R,aC as _,s as a,aD as je,G as ve,aE as Ce,e as t,aF as W,B as ye,H as q,af as J,n as $e,ag as Q,I as T,c as ke,m as Ne,S,h as Pe,A as Se,az as Le,aG as Ae}from"./index-BnbwrW-6.js";import{d as Me,g as ze,a as Fe,P as Be,C as Ee,b as Ie,c as Re,A as _e,B as We,S as Te,M as Ge,e as He,f as Ue}from"./browseLayout.styles-B_NNL83E.js";import{u as De,L as Ke}from"./useStore-HaFF1p2U.js";import{c as G,a as Oe,F as Ve,d as Ye,P as Ze,e as qe,H as Je,S as Qe}from"./categories-CX6i4K78.js";import{L as H}from"./LoadMore-DI4Wyn-C.js";import{u as U}from"./useInfiniteGrid-DxkPmxZ9.js";import{E as D}from"./ErrorNotice-Z0D8os9s.js";import{G as K}from"./grid.styles-Cflo-ZKg.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";const{colors:m,radius:X,media:Xe}=Z,et=a.article`
1
+ import{b as Y,j as e,L as ue,e as fe,u as be,r as y}from"./react-vyZjIDcS.js";import{t as Z,aA as we,aB as R,aC as _,s as a,aD as je,G as ve,aE as Ce,e as t,aF as W,B as ye,H as q,af as J,n as $e,ag as Q,I as T,c as ke,m as Ne,S,h as Pe,A as Se,az as Le,aG as Ae}from"./index-yJi2QIJf.js";import{d as Me,g as ze,a as Fe,P as Be,C as Ee,b as Ie,c as Re,A as _e,B as We,S as Te,M as Ge,e as He,f as Ue}from"./browseLayout.styles-Ck-h2OX5.js";import{u as De,L as Ke}from"./useStore-Dt337zVA.js";import{c as G,a as Oe,F as Ve,d as Ye,P as Ze,e as qe,H as Je,S as Qe}from"./categories-P1zgLmzy.js";import{L as H}from"./LoadMore-BI2cyij4.js";import{u as U}from"./useInfiniteGrid-CDkGdzFf.js";import{E as D}from"./ErrorNotice-C2qBxBzo.js";import{G as K}from"./grid.styles-D4B-EHGj.js";import"./sentry-B35L1FdR.js";import"./dcl-schemas-BICTSpB5.js";import"./ethers-CXBJm_wN.js";import"./intl-CBcMB1D2.js";const{colors:m,radius:X,media:Xe}=Z,et=a.article`
2
2
  height: 300px;
3
3
  background: ${m.bg};
4
4
  border-radius: ${X.card};
@@ -1 +1 @@
1
- import{j as r}from"./react-vyZjIDcS.js";import{I as i}from"./index-BnbwrW-6.js";function a({message:e,className:o,testId:t}){return e?r.jsxs("p",{className:o?`error-notice ${o}`:"error-notice","data-testid":t,role:"alert",children:[r.jsx(i,{name:"alert",className:"error-notice__ico",size:18}),r.jsx("span",{className:"error-notice__msg",children:e})]}):null}export{a as E};
1
+ import{j as r}from"./react-vyZjIDcS.js";import{I as i}from"./index-yJi2QIJf.js";function a({message:e,className:o,testId:t}){return e?r.jsxs("p",{className:o?`error-notice ${o}`:"error-notice","data-testid":t,role:"alert",children:[r.jsx(i,{name:"alert",className:"error-notice__ico",size:18}),r.jsx("span",{className:"error-notice__msg",children:e})]}):null}export{a as E};
@@ -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-CAciSeGb.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-DiUDVsbw.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-D3RatyJZ.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-b_a6Xe2g.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};