@dcl/shop 0.5.1-30934281711.commit-71d435d → 0.5.1-30936490891.commit-42e2634

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 (181) hide show
  1. package/_assets/Activity-CIJJTSUp.js +336 -0
  2. package/_assets/{AnimatedBackground-COSG1YHZ.js → AnimatedBackground-Bv2erZC5.js} +1 -1
  3. package/_assets/{Assets-hxHJCxJp.js → Assets-BoR-QJY6.js} +15 -15
  4. package/_assets/{Assets.styles-CqHMtvn6.js → Assets.styles-BePHQ_QA.js} +1 -1
  5. package/_assets/{Authorizations-Z_3XHseF.js → Authorizations-BCA1IImf.js} +3 -3
  6. package/_assets/{Cart-Csx5bd_E.js → Cart-DTe7zox3.js} +6 -6
  7. package/_assets/{CircularProgress-CxdmiPfO.js → CircularProgress-DzeFXlov.js} +1 -1
  8. package/_assets/{Collection-CCy2cdeV.js → Collection-DHHXSeak.js} +6 -6
  9. package/_assets/{CollectionCarousel-CKFxOqjb.js → CollectionCarousel-Orp4rJm9.js} +7 -7
  10. package/_assets/{Creator-plYQGi53.js → Creator-AMjYkiKe.js} +9 -9
  11. package/_assets/{ErrorNotice-C-nXSZqX.js → ErrorNotice-I9zAvGEr.js} +1 -1
  12. package/_assets/{ExchangeController-DY7abnKb.js → ExchangeController-B-TJWUiW.js} +1 -1
  13. package/_assets/{GetCredits-TNPm_zAt.js → GetCredits-BNkvpwnR.js} +7 -7
  14. package/_assets/{HelpersUtil-DxyZBMvo.js → HelpersUtil-ylN16m8a.js} +1 -1
  15. package/_assets/{ItemDetail-CuLGfIRL.js → ItemDetail-k2BANQ0W.js} +6 -6
  16. package/_assets/{LoadMore-yAi8vsa6.js → LoadMore-DPVuoR5W.js} +1 -1
  17. package/_assets/ManaPricingBanner.styles-nRVCJe8Y.js +74 -0
  18. package/_assets/{MenuList-CtnltPtJ.js → MenuList-yS83NC0F.js} +1 -1
  19. package/_assets/MyAssets-Ds0TK1z5.js +381 -0
  20. package/_assets/{MyFavorites-DvP0qwpm.js → MyFavorites-CDmtpdZP.js} +2 -2
  21. package/_assets/{NotFound-BfV911SO.js → NotFound-CVe0kC-t.js} +1 -1
  22. package/_assets/{NotificationsBell-LBfk_tmW.js → NotificationsBell-Fprokx0Q.js} +1 -1
  23. package/_assets/{OutfitDetail-CUGDW7tY.js → OutfitDetail-CdEsz8A4.js} +10 -10
  24. package/_assets/{OutfitPreview-BbEqr4QU.js → OutfitPreview-Y1WhUQaY.js} +2 -2
  25. package/_assets/{OutfitStudio-C7sSmIlF.js → OutfitStudio-B9G6xI3H.js} +11 -11
  26. package/_assets/{StoreSettings-CPNAijT4.js → StoreSettings-RMqF_ccU.js} +9 -9
  27. package/_assets/{Success-CoreUida.js → Success-rJNIKLQ6.js} +6 -6
  28. package/_assets/{SwapController-CEnoFZxK.js → SwapController-CgtlXeu5.js} +1 -1
  29. package/_assets/{Tooltip-D2z-c3xY.js → Tooltip-D1Bg11IA.js} +1 -1
  30. package/_assets/{TradeService-C0WM0IK5.js → TradeService-BhQmC5tm.js} +1 -1
  31. package/_assets/{W3MFrameProviderSingleton-DHADoYvF.js → W3MFrameProviderSingleton-D-orryVV.js} +3 -3
  32. package/_assets/{WebCryptoP256-D3CAJ1hZ.js → WebCryptoP256-Ckj1TqYw.js} +1 -1
  33. package/_assets/{authorizations-DKmCykqz.js → authorizations-vn6dbOqY.js} +1 -1
  34. package/_assets/{basic-CEhjKQJL.js → basic-D2f8I1xA.js} +1 -1
  35. package/_assets/{biconomy-BykCCfMc.js → biconomy-BZAxWDGN.js} +1 -1
  36. package/_assets/{browseLayout.styles-BrABo9Hf.js → browseLayout.styles-BYrLBkl5.js} +4 -4
  37. package/_assets/{builder-BkXoi_6e.js → builder-DT_IucDZ.js} +1 -1
  38. package/_assets/{buy-gasless-CGeqOHtJ.js → buy-gasless-DP35z8wI.js} +1 -1
  39. package/_assets/buy-k-76F4x2.js +1 -0
  40. package/_assets/{categories-2xUKydml.js → categories-_gS0pssw.js} +1 -1
  41. package/_assets/{ccip-BlVvJTli.js → ccip-B4KLf1_A.js} +1 -1
  42. package/_assets/{ccip-CADVZTOO.js → ccip-skuYIwjJ.js} +1 -1
  43. package/_assets/{clsx-CqnJSHSW.js → clsx-BtU7gPvo.js} +1 -1
  44. package/_assets/{controller-BP8z62yr.js → controller-BkNCBo5Z.js} +2 -2
  45. package/_assets/{core-CI5jAIo9.js → core-NV0Q-IPg.js} +4 -4
  46. package/_assets/{createSvgIcon-C_0Xv0NV.js → createSvgIcon-ONkmiYB6.js} +1 -1
  47. package/_assets/{custom-iCYkgXy_.js → custom-B2TqKkEi.js} +1 -1
  48. package/_assets/{data-capture-Bvpb1Gue.js → data-capture-ubD-gh1z.js} +1 -1
  49. package/_assets/{email-DGY8FmZr.js → email-yk5CxwkK.js} +1 -1
  50. package/_assets/{embedded-wallet-DGdykNIW.js → embedded-wallet-Sdgu7IIM.js} +1 -1
  51. package/_assets/{emotion-styled.browser.esm-BcV8HqIx.js → emotion-styled.browser.esm-Bi-gHJrz.js} +1 -1
  52. package/_assets/{engine-CG5_hJfk.js → engine-tdlero6P.js} +1 -1
  53. package/_assets/{errors-N8U87ba-.js → errors-WsZgWksO.js} +1 -1
  54. package/_assets/{estimate-l1-fee-BOQxb4ii.js → estimate-l1-fee-CyMpT0rk.js} +1 -1
  55. package/_assets/{execute-fo7nVUhk.js → execute-C4cl9W-o.js} +2 -2
  56. package/_assets/{features-Dg1ILYcD.js → features-CZqcLmC4.js} +1 -1
  57. package/_assets/{fetchTokenMetadata-WWZG1mk5.js → fetchTokenMetadata-CS5UBL6x.js} +2 -2
  58. package/_assets/{field.styles-D-WXHTOH.js → field.styles-CJlWBLbF.js} +1 -1
  59. package/_assets/{get-ecosystem-wallet-info-CImjdvym.js → get-ecosystem-wallet-info-07JzLM0i.js} +1 -1
  60. package/_assets/{getBalance-CRQfFcYC.js → getBalance-DL9ADD0u.js} +1 -1
  61. package/_assets/{getNFT-D3KLRabb.js → getNFT-D17z9oKn.js} +1 -1
  62. package/_assets/{getNFT-B2PC0-g2.js → getNFT-DoaFm4AC.js} +1 -1
  63. package/_assets/{getThemeProps-DmYVP8OC.js → getThemeProps-Cl72yIFf.js} +1 -1
  64. package/_assets/{grid.styles-wzi16hJ0.js → grid.styles-BZnnDTVu.js} +1 -1
  65. package/_assets/{hashTypedData-BDhBKMw7.js → hashTypedData-CrsUYWGu.js} +1 -1
  66. package/_assets/{hashTypedData-7f24Qmm1.js → hashTypedData-wJwJpwvj.js} +1 -1
  67. package/_assets/{in-app-Dw1uWQch.js → in-app-Btz7IDiL.js} +1 -1
  68. package/_assets/{in-app-wallet-calls-Ced-Hk1u.js → in-app-wallet-calls-DP3IphiJ.js} +1 -1
  69. package/_assets/{index-miM7OoYW.js → index-639jix5x.js} +1 -1
  70. package/_assets/{index-Bv6jRoUh.js → index-7BMeGSgL.js} +1 -1
  71. package/_assets/{index-HcU1BZGi.js → index-8SWxdM-1.js} +1 -1
  72. package/_assets/{index-BSJOsaoy.js → index-B59Gh8B7.js} +1 -1
  73. package/_assets/{index-DGhB3WMs.js → index-B5UKanqd.js} +1 -1
  74. package/_assets/{index-Dh2nN1pf.js → index-BE-fLnWc.js} +1 -1
  75. package/_assets/{index-C0tjFuh4.js → index-BM3ki5xD.js} +1 -1
  76. package/_assets/{index-B1-7yuu3.js → index-BQimjtyT.js} +3 -3
  77. package/_assets/{index-cgof2fbB.js → index-BVdlPUJG.js} +1 -1
  78. package/_assets/{index-BUZJwPmQ.js → index-BYbz0Puw.js} +1 -1
  79. package/_assets/{index-Bbu6XUqy.js → index-BbQMVOsy.js} +3 -3
  80. package/_assets/{index-B1l_Uvp9.js → index-BeQhSahz.js} +1 -1
  81. package/_assets/{index-Bkg0Qrp6.js → index-Bi_Apm6j.js} +1 -1
  82. package/_assets/{index-D3jBjpLf.js → index-BlQcf37-.js} +1 -1
  83. package/_assets/{index-Nu_iUU26.js → index-BtwYGrhd.js} +1 -1
  84. package/_assets/{index-BQE1lbNd.js → index-BxzWlq1h.js} +1 -1
  85. package/_assets/{index-DRMZKNFH.js → index-C0xJOFUc.js} +1 -1
  86. package/_assets/{index-BRAjDYmB.js → index-C1Z_9GsV.js} +1 -1
  87. package/_assets/{index-Drfl98A2.js → index-C45bHTUp.js} +1 -1
  88. package/_assets/{index-DyghLCFO.js → index-C7KsfPUz.js} +1 -1
  89. package/_assets/{index-DfnFAWTr.js → index-CBXYUzDZ.js} +2 -2
  90. package/_assets/{index-B0rKW0gc.js → index-CFksIzM4.js} +1 -1
  91. package/_assets/{index-DDu4b2rq.js → index-CL530K8Y.js} +1 -1
  92. package/_assets/{index-CRdySivd.js → index-CMFliAhY.js} +1 -1
  93. package/_assets/{index-uh1KT2cw.js → index-CPdKHNCF.js} +1 -1
  94. package/_assets/{index-CFw8nBxU.js → index-CQQrdcNQ.js} +1 -1
  95. package/_assets/{index-C53xszMs.js → index-CZF0PGAb.js} +1 -1
  96. package/_assets/{index-B_dncyHS.js → index-CbHNXAwv.js} +2 -2
  97. package/_assets/{index-DQsiee3b.js → index-Ci8PIdRp.js} +1 -1
  98. package/_assets/{index-CBpSiNz5.js → index-ClHp2_nl.js} +1 -1
  99. package/_assets/{index-DpqAhSTM.js → index-CrWSaqPI.js} +1 -1
  100. package/_assets/{index-BPGvNzFI.js → index-CtASwK4E.js} +1 -1
  101. package/_assets/{index-x992Sn-f.js → index-CtaCRDRI.js} +1 -1
  102. package/_assets/{index-DHYMCRcr.js → index-Cxty1u3d.js} +1 -1
  103. package/_assets/{index-lG7DN5xF.js → index-CzghBU6C.js} +1 -1
  104. package/_assets/{index-_SEhAywg.js → index-D4hVVIWp.js} +1 -1
  105. package/_assets/{index-BCvO08kk.js → index-DJ-CxX91.js} +1 -1
  106. package/_assets/{index-BD0M18Fj.js → index-DKnXZSeg.js} +1 -1
  107. package/_assets/{index-CiM8C2LD.js → index-DQM4pVOP.js} +1 -1
  108. package/_assets/{index-DLdGvRZQ.js → index-DcebaGnX.js} +1 -1
  109. package/_assets/{index-DFzINjaK.js → index-DimCwX0M.js} +1 -1
  110. package/_assets/{index-B3Hj28R0.js → index-DjltGmXq.js} +1 -1
  111. package/_assets/{index-DaLiUn8r.js → index-Dlg6tqPP.js} +1 -1
  112. package/_assets/{index-BpZz3bw9.js → index-DpOehH6H.js} +3 -3
  113. package/_assets/{index-Da1IWtza.js → index-Dy5Vw1H0.js} +91 -91
  114. package/_assets/{index-WEZnjywW.js → index-EECYRahm.js} +1 -1
  115. package/_assets/index-EheyvR55.js +472 -0
  116. package/_assets/{index-BiDNavgD.js → index-IsmxguMZ.js} +1 -1
  117. package/_assets/{index-D0Aqcjc0.js → index-O4FksRMn.js} +1 -1
  118. package/_assets/{index-BKjuIcZ1.js → index-grgWjFlo.js} +1 -1
  119. package/_assets/{index-BxR8fKca.js → index-m00Y2hq4.js} +1 -1
  120. package/_assets/{index-CgIgZ8TZ.js → index-nNKO8ftl.js} +2 -2
  121. package/_assets/{index.es-4XDsATwL.js → index.es-BzqwGWTI.js} +4 -4
  122. package/_assets/{index.es-DSpyirS0.js → index.es-KzvQwqfO.js} +1 -1
  123. package/_assets/{index.es-teXV_ogJ.js → index.es-StMi_Ya4.js} +1 -1
  124. package/_assets/{localBatchGatewayRequest-DeyVc56J.js → localBatchGatewayRequest-DQGGi_PU.js} +1 -1
  125. package/_assets/{mana-convert-DnJmYgcw.js → mana-convert-D_y2vjtn.js} +1 -1
  126. package/_assets/{networks-1b8NsW4Y.js → networks-DDcMYhGU.js} +1 -1
  127. package/_assets/{onramp-hTLhj5ti.js → onramp-CBdambV_.js} +1 -1
  128. package/_assets/{openzeppelin-BJlHJFSk.js → openzeppelin-DSxwqs4i.js} +1 -1
  129. package/_assets/{parseNft-DkIiwdC7.js → parseNft-DHPQc0OX.js} +2 -2
  130. package/_assets/{parseSignature-DQwihZkm.js → parseSignature-CGumShnk.js} +1 -1
  131. package/_assets/{parseSignature-CvH9K2oI.js → parseSignature-DJF5siOG.js} +3 -3
  132. package/_assets/{passkeys-IvY3Iqv-.js → passkeys-C9h38bzo.js} +1 -1
  133. package/_assets/{pay-with-exchange-BdHjrEQV.js → pay-with-exchange-CdWIlkYG.js} +1 -1
  134. package/_assets/{qr-overlay-BYsKakQ3.js → qr-overlay-DfYnP7zW.js} +1 -1
  135. package/_assets/{receive-YK_fd_CU.js → receive-BDPZr_50.js} +1 -1
  136. package/_assets/{resolveImplementation-DPilssBn.js → resolveImplementation-1IibNw8J.js} +1 -1
  137. package/_assets/{rpc-Sc56-gmm.js → rpc-Be4cuLO-.js} +1 -1
  138. package/_assets/{secp256k1-D_5VBkHj.js → secp256k1-C2A9iNFQ.js} +1 -1
  139. package/_assets/{secp256k1-Cc4QlgFt.js → secp256k1-CBaRftLy.js} +1 -1
  140. package/_assets/{secp256k1-mkhJYubv.js → secp256k1-CfSstl_L.js} +1 -1
  141. package/_assets/{send-DeNQyeKY.js → send-DpFdmYN7.js} +1 -1
  142. package/_assets/{send-batch-transaction-DNMKl7ky.js → send-batch-transaction-Bfap8p0Z.js} +1 -1
  143. package/_assets/{send-eip712-transaction-CDu2CS-m.js → send-eip712-transaction-Ca7s6qzX.js} +2 -2
  144. package/_assets/{send-gasless-transaction-BfQQxuNb.js → send-gasless-transaction-DPOigmTX.js} +2 -2
  145. package/_assets/{send-transaction-egO16iDc.js → send-transaction-D2BNOa_n.js} +2 -2
  146. package/_assets/{sendMetaTransaction-kBil2Ej7.js → sendMetaTransaction-feJSI2TG.js} +1 -1
  147. package/_assets/{sendRawTransaction-8z5-lN6F.js → sendRawTransaction-B-XApuqY.js} +3 -3
  148. package/_assets/{serializeTransaction-D2h63c4_.js → serializeTransaction-I8okodGI.js} +1 -1
  149. package/_assets/{session-proposal-DW2kA8O7.js → session-proposal-DvL8lvR_.js} +1 -1
  150. package/_assets/{session-request-CPMpN15W.js → session-request-BXYdMjrw.js} +2 -2
  151. package/_assets/{signing-DPwEu2UU.js → signing-DT63E54M.js} +3 -3
  152. package/_assets/{socials-CBKa2AOj.js → socials-ClcK9a8P.js} +1 -1
  153. package/_assets/{swaps-xpOfH90g.js → swaps-C0ufdoJC.js} +1 -1
  154. package/_assets/{thirdweb-DzBPyGMD.js → thirdweb-B50LsjvD.js} +3 -3
  155. package/_assets/{to-serializable-transaction-Cq1PN1aZ.js → to-serializable-transaction-D0wz5egz.js} +2 -2
  156. package/_assets/{trade-encoding-4xiglK48.js → trade-encoding-SVWWPYXU.js} +1 -1
  157. package/_assets/{transactionReceipt-Bx1LFZ2X.js → transactionReceipt-BW33bMK1.js} +1 -1
  158. package/_assets/{transactions-ncGplKHW.js → transactions-Dydjvljn.js} +1 -1
  159. package/_assets/{useCreditPacks-BElseyte.js → useCreditPacks-BFQph8eD.js} +1 -1
  160. package/_assets/useImportable-BP4DqZ-f.js +1 -0
  161. package/_assets/{useInfiniteGrid-RdlgtcqE.js → useInfiniteGrid-Dz6b_PHh.js} +1 -1
  162. package/_assets/useManaRate-CfhYfW7C.js +1 -0
  163. package/_assets/{useStore-C66JN0w6.js → useStore-ff9cCCX6.js} +1 -1
  164. package/_assets/{useTheme-DO99UzMT.js → useTheme-BzWpoSXD.js} +1 -1
  165. package/_assets/{verifyHash-DdYLeP97.js → verifyHash-6ZvXkv0_.js} +1 -1
  166. package/_assets/{w3m-modal-CD6HTrJ3.js → w3m-modal-B5LvO_YQ.js} +1 -1
  167. package/_assets/{w3m-modal-C0b4AnQ3.js → w3m-modal-BI6MOh7J.js} +1 -1
  168. package/_assets/{wait-for-tx-receipt-CYCUuRY7.js → wait-for-tx-receipt-B6htZpEq.js} +1 -1
  169. package/_assets/{wallets-B_igN3zv.js → wallets-cwZJIsw-.js} +5 -5
  170. package/_assets/{web-connector-DtLrUYHU.js → web-connector-BMBh8mIE.js} +3 -3
  171. package/_assets/{writeContract-CvTh4kpk.js → writeContract-C3lGbTIC.js} +1 -1
  172. package/_assets/{zoraTestnet-vikR0D9L.js → zoraTestnet-Dvb_L0a4.js} +1 -1
  173. package/index.html +11 -11
  174. package/package.json +2 -2
  175. package/_assets/Activity-DbEcN_ip.js +0 -291
  176. package/_assets/ImportListings-BJ0q3u26.js +0 -472
  177. package/_assets/ManaPricingBanner.styles-ByRxQdOU.js +0 -74
  178. package/_assets/MyAssets-CkgpQXbD.js +0 -381
  179. package/_assets/buy-DKJg2rHj.js +0 -1
  180. package/_assets/mana-rate-CC5D3Meh.js +0 -1
  181. package/_assets/useManaRate-DAwFZ75M.js +0 -1
@@ -1,4 +1,4 @@
1
- import{L as j,u as J,j as e,r as m}from"./react-DehiWSvs.js";import{s as t,I as y,t as X,A as Y,D as Z,E as ee,B as v,F as te,n as P,G as ie,u as se,m as ae,b as a,H as N,J as ne,K as re,L as oe,M as le,N as de,O as ce,P as pe,Q as he,R as me,S as xe,V as ue,W as ge,X as fe,Y as be,p as I,Z as ye,$ as ve,a0 as je,a1 as we,a2 as $e,a3 as ke}from"./index-Da1IWtza.js";import{E as R}from"./ErrorNotice-C-nXSZqX.js";import{O as Ie}from"./OutfitPreview-BbEqr4QU.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./disposePreview-DIA1G1eQ.js";const{colors:r,radius:Ce,media:l}=X,B=t.div`
1
+ import{L as j,u as J,j as e,r as m}from"./react-DehiWSvs.js";import{s as t,I as y,t as X,F as Y,G as Z,H as ee,B as v,J as te,n as P,K as ie,u as se,q as ae,b as a,L as A,M as ne,N as re,O as oe,P as le,Q as de,R as ce,S as pe,V as he,W as me,X as xe,Y as ue,Z as ge,$ as fe,a0 as be,w as I,a1 as ye,a2 as ve,a3 as je,a4 as we,a5 as $e,a6 as ke}from"./index-Dy5Vw1H0.js";import{E as R}from"./ErrorNotice-I9zAvGEr.js";import{O as Ie}from"./OutfitPreview-Y1WhUQaY.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./disposePreview-DIA1G1eQ.js";const{colors:r,radius:Ce,media:l}=X,B=t.div`
2
2
  max-width: 1721px;
3
3
  margin: 0 auto;
4
4
  `,ze=t.nav`
@@ -14,7 +14,7 @@ import{L as j,u as J,j as e,r as m}from"./react-DehiWSvs.js";import{s as t,I as
14
14
  &:hover {
15
15
  color: ${r.text};
16
16
  }
17
- `,Ee=t.span`
17
+ `,Le=t.span`
18
18
  color: ${r.text};
19
19
  font-weight: 600;
20
20
  overflow: hidden;
@@ -56,7 +56,7 @@ import{L as j,u as J,j as e,r as m}from"./react-DehiWSvs.js";import{s as t,I as
56
56
  inset: 0;
57
57
  pointer-events: none;
58
58
  }
59
- `,Le=t.img`
59
+ `,Ee=t.img`
60
60
  position: absolute;
61
61
  inset: 0;
62
62
  width: 100%;
@@ -71,13 +71,13 @@ import{L as j,u as J,j as e,r as m}from"./react-DehiWSvs.js";import{s as t,I as
71
71
  font-size: 28px;
72
72
  font-weight: 600;
73
73
  overflow-wrap: anywhere;
74
- `,Ae=t.p`
74
+ `,Ne=t.p`
75
75
  font-size: 12px;
76
76
  font-weight: 500;
77
77
  letter-spacing: 0.04em;
78
78
  text-transform: uppercase;
79
79
  color: ${r.muted1};
80
- `,Ne=t.div`
80
+ `,Ae=t.div`
81
81
  flex: 0 1 auto;
82
82
  min-height: 0;
83
83
  overflow-y: auto;
@@ -252,7 +252,7 @@ import{L as j,u as J,j as e,r as m}from"./react-DehiWSvs.js";import{s as t,I as
252
252
  align-items: flex-start;
253
253
  gap: 12px;
254
254
  padding: 8px 0;
255
- `,De=t.div`
255
+ `,He=t.div`
256
256
  display: flex;
257
257
  flex-direction: column;
258
258
  gap: 12px;
@@ -273,7 +273,7 @@ import{L as j,u as J,j as e,r as m}from"./react-DehiWSvs.js";import{s as t,I as
273
273
  background: ${r.softWhite};
274
274
  box-shadow: 0 -4px 16px rgba(22, 21, 24, 0.12);
275
275
  }
276
- `,He=t.div`
276
+ `,qe=t.div`
277
277
  display: flex;
278
278
  align-items: center;
279
279
  justify-content: space-between;
@@ -282,13 +282,13 @@ import{L as j,u as J,j as e,r as m}from"./react-DehiWSvs.js";import{s as t,I as
282
282
  /* The phone CTA carries the price itself (the Figma bar). */
283
283
  display: none;
284
284
  }
285
- `,Ve=t.span`
285
+ `,De=t.span`
286
286
  font-size: 14px;
287
287
  font-weight: 600;
288
288
  letter-spacing: 0.04em;
289
289
  text-transform: uppercase;
290
290
  color: ${r.muted1};
291
- `,qe=t.span`
291
+ `,Ve=t.span`
292
292
  display: inline-flex;
293
293
  align-items: center;
294
294
  gap: 6px;
@@ -323,4 +323,4 @@ import{L as j,u as J,j as e,r as m}from"./react-DehiWSvs.js";import{s as t,I as
323
323
  opacity: 0.4;
324
324
  `,Je=t.h1`
325
325
  font-size: 24px;
326
- `,Xe="outfit-detail-preview";function dt(){const{id:i}=J(),n=P(u=>u.session),d=ie(),x=d==="creator",{data:c,isError:w,refetch:p}=se({queryKey:["outfit",i,x],enabled:N()&&!!i,staleTime:6e4,queryFn:()=>ke(i,x&&n?n.identity:void 0)}),o=!N()||!i||c===null&&d!=="pending";return ae(o?{title:a("seo.outfit.notFoundTitle"),noindex:!0}:c?{title:c.name}:{}),o?e.jsxs(W,{"data-testid":"outfit-notfound",children:[e.jsx(Ue,{name:"cart",size:44}),e.jsx(Je,{children:a("outfits.detail.notFoundTitle")}),e.jsx("p",{className:"muted",children:a("outfits.detail.notFoundBody")}),e.jsx(v,{as:j,to:"/items",variant:"purple",children:a("notFound.cta")})]}):w?e.jsxs(W,{"data-testid":"outfit-detail-error",children:[e.jsx(R,{message:a("outfits.errors.generic")}),e.jsx(v,{variant:"purple",onClick:()=>void p(),children:a("outfits.detail.retry")})]}):c?e.jsx(Ze,{outfit:c}):e.jsx(B,{"aria-busy":"true","data-testid":"outfit-detail-loading",children:e.jsxs(M,{children:[e.jsx(_,{children:e.jsx("span",{className:"skeleton",style:{position:"absolute",inset:0},"aria-hidden":!0})}),e.jsxs(K,{children:[e.jsx("span",{className:"skeleton",style:{width:"60%",height:32},"aria-hidden":!0}),e.jsx("span",{className:"skeleton",style:{width:"40%",height:16},"aria-hidden":!0}),e.jsx("span",{className:"skeleton",style:{width:"100%",height:48},"aria-hidden":!0})]})]})})}function Ye({item:i}){const n=ye(i),d=ve(i.gender);return e.jsxs(Me,{children:[i.rarity?e.jsx(b,{"data-variant":"rarity",style:{background:$e(i.rarity),color:we(i.rarity)},title:je(i.rarity),children:i.rarity}):null,i.isSmart?e.jsxs(b,{"data-variant":"smart",children:[e.jsx(y,{name:"smart",size:13}),a("assetCard.smart")]}):null,n?e.jsx(b,{"data-variant":"icon",children:e.jsx(y,{name:n})}):null,d?e.jsx(b,{"data-variant":"icon",children:e.jsx(y,{name:d})}):null]})}function Ze({outfit:i}){const n=ne(i),{split:d,availableCount:x,totalCredits:c,addOutfit:w,isAdding:p}=re(i,n),o=P(s=>{var h;return(h=s.session)==null?void 0:h.address}),u=oe(s=>s.items),z=m.useMemo(()=>new Set(u.map(le)),[u]),E=de(i.thumbnailHash),L=m.useRef(null);m.useEffect(()=>{L.current!==i.id&&(L.current=i.id,ce("Shop Outfit Viewed",{outfit_id:i.id,item_count:i.items.length}))},[i.id,i.items.length]);const $=m.useMemo(()=>i.items.map(s=>{const h=pe(s),k=n.byKey.get(h)??null;return{key:h,item:k,state:k?he(k,{address:o,cartKeys:z}):"missing"}}),[i,n.byKey,o,z]),{data:D,isFetched:H}=me(o),V=!o||H,S=!!o&&!!D,q=S?o:"default",G=i.bodyShape==="female"?xe:i.bodyShape==="male"?ue:void 0,A=m.useMemo(()=>$.map(s=>s.item?ge(s.item):null).filter(s=>!!s),[$]),Q=i.items.length,U=!n.isLoading&&!n.isError,g=d.purchasable.length;return e.jsxs(B,{"data-testid":"outfit-detail",children:[e.jsxs(ze,{"aria-label":a("outfits.detail.breadcrumbAria"),children:[e.jsx(F,{to:"/overview",children:a("nav.overview")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(F,{to:"/overview",children:a("outfits.detail.breadcrumbLooks")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(Ee,{children:i.name})]}),e.jsxs(M,{children:[e.jsx(_,{"data-testid":"outfit-detail-preview",style:{background:fe(i)},children:E&&!n.isLoading&&A.length===0?e.jsx(Le,{src:E,alt:i.name}):e.jsx(Ie,{id:Xe,profile:q,bodyShape:S?void 0:G,urns:A,enabled:V&&!n.isLoading})}),e.jsxs(K,{children:[e.jsx(Se,{children:i.name}),e.jsx(Ae,{"data-testid":"outfit-detail-meta",children:a("outfits.detail.itemsCount",{count:Q})}),n.isError?e.jsxs(Ke,{children:[e.jsx(R,{message:a("outfits.detail.resolveError"),testId:"outfit-detail-resolve-error"}),e.jsx(v,{variant:"outline","data-testid":"outfit-detail-retry",onClick:n.retry,children:a("outfits.detail.retry")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ne,{children:[e.jsx(Fe,{children:$.map(s=>e.jsx(Oe,{"data-testid":"outfit-detail-item","data-state":s.state,children:s.item?e.jsxs(e.Fragment,{children:[e.jsx(Te,{to:`/item/${s.item.contractAddress}/${s.item.itemId}`,state:{item:s.item},"aria-label":s.item.name}),e.jsx(We,{src:s.item.thumbnail,alt:"",loading:"lazy"}),e.jsxs(O,{children:[e.jsx(C,{children:s.item.name}),s.item.creator?e.jsx(Re,{to:`/items/creator/${s.item.creator}`,children:e.jsx(be,{address:s.item.creator})}):null,e.jsxs(T,{children:[s.state!=="unavailable"?e.jsxs(Be,{children:[e.jsx(I,{size:15}),s.item.priceCredits.toLocaleString()]}):null,s.state==="unavailable"?e.jsx(f,{children:a("outfits.card.unavailable")}):s.state==="own_listing"?e.jsx(f,{children:a("outfits.detail.yourListing")}):s.state==="in_cart"?e.jsx(f,{children:a("outfits.detail.inCart")}):null,e.jsx(Ye,{item:s.item})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:n.isLoading?"skeleton":void 0,"aria-hidden":!0}),e.jsx(O,{children:n.isLoading?e.jsx(C,{children:e.jsx("span",{className:"skeleton",style:{display:"block",width:"70%",height:14}})}):e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"muted",children:a("outfits.card.unavailable")}),e.jsx(T,{children:e.jsx(f,{children:a("outfits.card.unavailable")})})]})})]})},s.key))}),U&&d.ownListing.length>0?e.jsx(_e,{className:"muted small",children:a("outfits.detail.yourListingHint")}):null]}),e.jsxs(De,{"data-testid":"outfit-detail-ctabar",children:[e.jsxs(He,{children:[e.jsx(Ve,{children:a("outfits.detail.totalPrice")}),n.isLoading?e.jsx("span",{className:"skeleton",style:{width:64,height:26},"aria-hidden":!0}):e.jsxs(qe,{children:[e.jsx(I,{size:22}),c.toLocaleString()]})]}),n.isLoading?e.jsx("span",{className:"skeleton",style:{width:"100%",height:52,borderRadius:26},"aria-hidden":!0}):e.jsxs(Ge,{variant:"purple","data-testid":"outfit-detail-cta",onClick:w,disabled:p||g===0,"aria-busy":p||void 0,children:[p?a("outfits.card.adding"):g>0?a("outfits.detail.addCount",{count:g}):x>0?a("outfits.detail.nothingToAdd"):a("outfits.card.unavailable"),!p&&g>0?e.jsxs(Qe,{children:[e.jsx(I,{size:16}),c.toLocaleString()]}):null]})]})]})]})]})]})}export{dt as OutfitDetail,dt as default};
326
+ `,Xe="outfit-detail-preview";function dt(){const{id:i}=J(),n=P(u=>u.session),d=ie(),x=d==="creator",{data:c,isError:w,refetch:p}=se({queryKey:["outfit",i,x],enabled:A()&&!!i,staleTime:6e4,queryFn:()=>ke(i,x&&n?n.identity:void 0)}),o=!A()||!i||c===null&&d!=="pending";return ae(o?{title:a("seo.outfit.notFoundTitle"),noindex:!0}:c?{title:c.name}:{}),o?e.jsxs(W,{"data-testid":"outfit-notfound",children:[e.jsx(Ue,{name:"cart",size:44}),e.jsx(Je,{children:a("outfits.detail.notFoundTitle")}),e.jsx("p",{className:"muted",children:a("outfits.detail.notFoundBody")}),e.jsx(v,{as:j,to:"/items",variant:"purple",children:a("notFound.cta")})]}):w?e.jsxs(W,{"data-testid":"outfit-detail-error",children:[e.jsx(R,{message:a("outfits.errors.generic")}),e.jsx(v,{variant:"purple",onClick:()=>void p(),children:a("outfits.detail.retry")})]}):c?e.jsx(Ze,{outfit:c}):e.jsx(B,{"aria-busy":"true","data-testid":"outfit-detail-loading",children:e.jsxs(M,{children:[e.jsx(_,{children:e.jsx("span",{className:"skeleton",style:{position:"absolute",inset:0},"aria-hidden":!0})}),e.jsxs(K,{children:[e.jsx("span",{className:"skeleton",style:{width:"60%",height:32},"aria-hidden":!0}),e.jsx("span",{className:"skeleton",style:{width:"40%",height:16},"aria-hidden":!0}),e.jsx("span",{className:"skeleton",style:{width:"100%",height:48},"aria-hidden":!0})]})]})})}function Ye({item:i}){const n=ye(i),d=ve(i.gender);return e.jsxs(Me,{children:[i.rarity?e.jsx(b,{"data-variant":"rarity",style:{background:$e(i.rarity),color:we(i.rarity)},title:je(i.rarity),children:i.rarity}):null,i.isSmart?e.jsxs(b,{"data-variant":"smart",children:[e.jsx(y,{name:"smart",size:13}),a("assetCard.smart")]}):null,n?e.jsx(b,{"data-variant":"icon",children:e.jsx(y,{name:n})}):null,d?e.jsx(b,{"data-variant":"icon",children:e.jsx(y,{name:d})}):null]})}function Ze({outfit:i}){const n=ne(i),{split:d,availableCount:x,totalCredits:c,addOutfit:w,isAdding:p}=re(i,n),o=P(s=>{var h;return(h=s.session)==null?void 0:h.address}),u=oe(s=>s.items),z=m.useMemo(()=>new Set(u.map(le)),[u]),L=de(i.thumbnailHash),E=m.useRef(null);m.useEffect(()=>{E.current!==i.id&&(E.current=i.id,ce("Shop Outfit Viewed",{outfit_id:i.id,item_count:i.items.length}))},[i.id,i.items.length]);const $=m.useMemo(()=>i.items.map(s=>{const h=pe(s),k=n.byKey.get(h)??null;return{key:h,item:k,state:k?he(k,{address:o,cartKeys:z}):"missing"}}),[i,n.byKey,o,z]),{data:H,isFetched:q}=me(o),D=!o||q,S=!!o&&!!H,V=S?o:"default",G=i.bodyShape==="female"?xe:i.bodyShape==="male"?ue:void 0,N=m.useMemo(()=>$.map(s=>s.item?ge(s.item):null).filter(s=>!!s),[$]),Q=i.items.length,U=!n.isLoading&&!n.isError,g=d.purchasable.length;return e.jsxs(B,{"data-testid":"outfit-detail",children:[e.jsxs(ze,{"aria-label":a("outfits.detail.breadcrumbAria"),children:[e.jsx(F,{to:"/overview",children:a("nav.overview")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(F,{to:"/overview",children:a("outfits.detail.breadcrumbLooks")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(Le,{children:i.name})]}),e.jsxs(M,{children:[e.jsx(_,{"data-testid":"outfit-detail-preview",style:{background:fe(i)},children:L&&!n.isLoading&&N.length===0?e.jsx(Ee,{src:L,alt:i.name}):e.jsx(Ie,{id:Xe,profile:V,bodyShape:S?void 0:G,urns:N,enabled:D&&!n.isLoading})}),e.jsxs(K,{children:[e.jsx(Se,{children:i.name}),e.jsx(Ne,{"data-testid":"outfit-detail-meta",children:a("outfits.detail.itemsCount",{count:Q})}),n.isError?e.jsxs(Ke,{children:[e.jsx(R,{message:a("outfits.detail.resolveError"),testId:"outfit-detail-resolve-error"}),e.jsx(v,{variant:"outline","data-testid":"outfit-detail-retry",onClick:n.retry,children:a("outfits.detail.retry")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ae,{children:[e.jsx(Fe,{children:$.map(s=>e.jsx(Oe,{"data-testid":"outfit-detail-item","data-state":s.state,children:s.item?e.jsxs(e.Fragment,{children:[e.jsx(Te,{to:`/item/${s.item.contractAddress}/${s.item.itemId}`,state:{item:s.item},"aria-label":s.item.name}),e.jsx(We,{src:s.item.thumbnail,alt:"",loading:"lazy"}),e.jsxs(O,{children:[e.jsx(C,{children:s.item.name}),s.item.creator?e.jsx(Re,{to:`/items/creator/${s.item.creator}`,children:e.jsx(be,{address:s.item.creator})}):null,e.jsxs(T,{children:[s.state!=="unavailable"?e.jsxs(Be,{children:[e.jsx(I,{size:15}),s.item.priceCredits.toLocaleString()]}):null,s.state==="unavailable"?e.jsx(f,{children:a("outfits.card.unavailable")}):s.state==="own_listing"?e.jsx(f,{children:a("outfits.detail.yourListing")}):s.state==="in_cart"?e.jsx(f,{children:a("outfits.detail.inCart")}):null,e.jsx(Ye,{item:s.item})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:n.isLoading?"skeleton":void 0,"aria-hidden":!0}),e.jsx(O,{children:n.isLoading?e.jsx(C,{children:e.jsx("span",{className:"skeleton",style:{display:"block",width:"70%",height:14}})}):e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"muted",children:a("outfits.card.unavailable")}),e.jsx(T,{children:e.jsx(f,{children:a("outfits.card.unavailable")})})]})})]})},s.key))}),U&&d.ownListing.length>0?e.jsx(_e,{className:"muted small",children:a("outfits.detail.yourListingHint")}):null]}),e.jsxs(He,{"data-testid":"outfit-detail-ctabar",children:[e.jsxs(qe,{children:[e.jsx(De,{children:a("outfits.detail.totalPrice")}),n.isLoading?e.jsx("span",{className:"skeleton",style:{width:64,height:26},"aria-hidden":!0}):e.jsxs(Ve,{children:[e.jsx(I,{size:22}),c.toLocaleString()]})]}),n.isLoading?e.jsx("span",{className:"skeleton",style:{width:"100%",height:52,borderRadius:26},"aria-hidden":!0}):e.jsxs(Ge,{variant:"purple","data-testid":"outfit-detail-cta",onClick:w,disabled:p||g===0,"aria-busy":p||void 0,children:[p?a("outfits.card.adding"):g>0?a("outfits.detail.addCount",{count:g}):x>0?a("outfits.detail.nothingToAdd"):a("outfits.card.unavailable"),!p&&g>0?e.jsxs(Qe,{children:[e.jsx(I,{size:16}),c.toLocaleString()]}):null]})]})]})]})]})]})}export{dt as OutfitDetail,dt as default};
@@ -1,6 +1,6 @@
1
- import{r as i,j as r}from"./react-DehiWSvs.js";import{d as u}from"./dcl-schemas-Dr9BTjb7.js";import{s as j,L as P,c as h,a4 as A,b as R}from"./index-Da1IWtza.js";import{u as b,d as O}from"./disposePreview-DIA1G1eQ.js";const L=j.div`
1
+ import{r as i,j as r}from"./react-DehiWSvs.js";import{d as u}from"./dcl-schemas-Dr9BTjb7.js";import{s as j,O as P,c as h,a7 as A,b as R}from"./index-Dy5Vw1H0.js";import{u as b,d as O}from"./disposePreview-DIA1G1eQ.js";const F=j.div`
2
2
  position: absolute;
3
3
  inset: 0;
4
4
  display: grid;
5
5
  place-items: center;
6
- `;function T({id:d,profile:s,bodyShape:m,urns:e,enabled:c=!0,skin:l,hair:f,eyes:p}){const v=P(n=>n.fittingOpen),{ref:g,active:w}=b(),t=c&&e.length>0&&w&&!v,y=e.length>0?e[0].includes(":amoy:"):h.chainId===80002,[E,a]=i.useState(!1),x=e.join(",");i.useEffect(()=>{a(!1)},[x,s,l,f,p]),i.useEffect(()=>{t&&a(!1)},[t]);const o=i.useRef(null);return i.useEffect(()=>{if(t)return()=>{O(o.current),o.current=null}},[t]),r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:g,"data-preview-viewport":!0,"aria-hidden":!0}),t?r.jsx(A,{id:d,profile:s,bodyShape:m,urns:e,skin:l,hair:f,eyes:p,type:u.PreviewType.AVATAR,emote:u.PreviewEmote.FASHION,disableBackground:!0,disableFadeEffect:!0,dev:y,unity:!0,unityMode:u.PreviewUnityMode.MARKETPLACE,onLoad:()=>{var n;a(!0),o.current=((n=document.getElementById(d))==null?void 0:n.contentWindow)??null}},s):null,c&&e.length===0?null:!t||!E?r.jsx(L,{"aria-busy":"true","aria-label":R("spinner.loading"),children:r.jsx("span",{className:"spinner","aria-hidden":!0})}):null]})}export{T as O};
6
+ `;function T({id:d,profile:s,bodyShape:m,urns:e,enabled:c=!0,skin:l,hair:f,eyes:p}){const v=P(n=>n.fittingOpen),{ref:g,active:w}=b(),t=c&&e.length>0&&w&&!v,y=e.length>0?e[0].includes(":amoy:"):h.chainId===80002,[E,a]=i.useState(!1),x=e.join(",");i.useEffect(()=>{a(!1)},[x,s,l,f,p]),i.useEffect(()=>{t&&a(!1)},[t]);const o=i.useRef(null);return i.useEffect(()=>{if(t)return()=>{O(o.current),o.current=null}},[t]),r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:g,"data-preview-viewport":!0,"aria-hidden":!0}),t?r.jsx(A,{id:d,profile:s,bodyShape:m,urns:e,skin:l,hair:f,eyes:p,type:u.PreviewType.AVATAR,emote:u.PreviewEmote.FASHION,disableBackground:!0,disableFadeEffect:!0,dev:y,unity:!0,unityMode:u.PreviewUnityMode.MARKETPLACE,onLoad:()=>{var n;a(!0),o.current=((n=document.getElementById(d))==null?void 0:n.contentWindow)??null}},s):null,c&&e.length===0?null:!t||!E?r.jsx(F,{"aria-busy":"true","aria-label":R("spinner.loading"),children:r.jsx("span",{className:"spinner","aria-hidden":!0})}):null]})}export{T as O};
@@ -1,4 +1,4 @@
1
- import{r as u,j as t,L as O,u as Gt,b as qt,d as Wt}from"./react-DehiWSvs.js";import{s as o,t as st,I as U,aq as Qt,b as e,p as Y,B as m,a9 as vt,n as q,G as Vt,m as Jt,q as wt,u as St,J as Xt,P as B,ar as K,as as Yt,at as G,W as Zt,S as te,V as ee,N as $t,X as ie,au as Z,av as se,aw as oe,ax as ae,w as F,ay as kt,az as Tt,aA as R,j as tt,aB as et,aC as ne,aD as re,aE as de,O as le,aF as ue,aG as ce,a3 as pe}from"./index-Da1IWtza.js";import{E as D}from"./ErrorNotice-C-nXSZqX.js";import{L as fe}from"./LoadMore-yAi8vsa6.js";import{u as he}from"./useInfiniteGrid-RdlgtcqE.js";import{O as me}from"./OutfitPreview-BbEqr4QU.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./disposePreview-DIA1G1eQ.js";const{colors:x,radius:ot,media:xe}=st,ge=o.div`
1
+ import{r as u,j as t,L as O,u as Gt,b as qt,d as Wt}from"./react-DehiWSvs.js";import{s as o,t as st,I as M,at as Qt,b as e,w as Y,B as m,ac as vt,n as q,K as Jt,q as Vt,x as wt,u as $t,M as Xt,S as B,au as K,av as Yt,aw as G,Z as Zt,X as te,Y as ee,Q as St,$ as ie,ax as Z,ay as se,az as oe,aA as ae,z as F,aB as kt,aC as Tt,aD as P,j as tt,aE as et,aF as ne,aG as re,aH as de,R as le,aI as ue,aJ as ce,a6 as pe}from"./index-Dy5Vw1H0.js";import{E as D}from"./ErrorNotice-I9zAvGEr.js";import{L as fe}from"./LoadMore-DPVuoR5W.js";import{u as he}from"./useInfiniteGrid-Dz6b_PHh.js";import{O as me}from"./OutfitPreview-Y1WhUQaY.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./disposePreview-DIA1G1eQ.js";const{colors:x,radius:ot,media:xe}=st,ge=o.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: 12px;
@@ -70,20 +70,20 @@ import{r as u,j as t,L as O,u as Gt,b as qt,d as Wt}from"./react-DehiWSvs.js";im
70
70
  white-space: nowrap;
71
71
  overflow: hidden;
72
72
  text-overflow: ellipsis;
73
- `,Se=o.span`
73
+ `,$e=o.span`
74
74
  display: inline-flex;
75
75
  align-items: center;
76
76
  gap: 4px;
77
77
  font-size: 12px;
78
78
  color: ${x.muted};
79
- `,$e=o(U)`
79
+ `,Se=o(M)`
80
80
  position: absolute;
81
81
  top: 12px;
82
82
  right: 12px;
83
83
  color: ${x.accent};
84
84
  background: ${x.bg};
85
85
  border-radius: 50%;
86
- `;function ke({selectedKeys:r,onPick:h,canPick:f}){const[p,g]=u.useState(""),[j,b]=u.useState("");u.useEffect(()=>{const d=setTimeout(()=>b(p.trim()),300);return()=>clearTimeout(d)},[p]);const{items:s,isLoading:k,isPlaceholderData:w,isError:T,hasNextPage:l,isFetchingNextPage:C,fetchNextPage:I}=he(["outfit-picker",j],d=>Qt({search:j||void 0,category:"wearable",onSale:!0,listingType:"primary",first:24,skip:d,sortBy:"cheapest"})),M=new Set,y=s.filter(d=>{if(!d.itemId)return!1;const S=`${d.contractAddress.toLowerCase()}-${d.itemId}`;return M.has(S)?!1:(M.add(S),!0)});return t.jsxs(ge,{"data-testid":"outfit-picker",children:[t.jsxs(be,{children:[t.jsx(U,{name:"search",color:st.colors.muted}),t.jsx("input",{value:p,placeholder:e("outfits.studio.searchPlaceholder"),"aria-label":e("outfits.studio.searchPlaceholder"),onChange:d=>g(d.target.value),"data-testid":"outfit-picker-search"})]}),T?t.jsx("p",{className:"muted small",children:e("outfits.errors.generic")}):k||w?t.jsx(xt,{"aria-busy":"true",children:Array.from({length:8},(d,S)=>t.jsx(ye,{className:"skeleton","aria-hidden":!0},S))}):y.length===0?t.jsx("p",{className:"muted small",children:e("outfits.studio.noResults")}):t.jsx(xt,{children:y.map(d=>{const S=`${d.contractAddress.toLowerCase()}-${d.itemId}`,P=r.has(S);return t.jsxs(je,{type:"button","data-testid":"outfit-picker-item","data-selected":P||void 0,disabled:!P&&!f(d),onClick:()=>h(d),title:d.name,children:[t.jsx(ve,{src:d.thumbnail,alt:"",loading:"lazy"}),t.jsx(we,{children:d.name}),t.jsxs(Se,{children:[t.jsx(Y,{size:12}),d.priceCredits.toLocaleString()]}),P?t.jsx($e,{name:"check-rounded",size:18}):null]},S)})}),!T&&!k&&!w?t.jsx(fe,{auto:!1,hasNextPage:!!l,isFetching:C,onLoadMore:()=>void I()}):null]})}const{colors:a,radius:v,media:W,z:Te}=st,Ct=o.div`
86
+ `;function ke({selectedKeys:r,onPick:h,canPick:f}){const[p,g]=u.useState(""),[j,b]=u.useState("");u.useEffect(()=>{const d=setTimeout(()=>b(p.trim()),300);return()=>clearTimeout(d)},[p]);const{items:s,isLoading:k,isPlaceholderData:w,isError:T,hasNextPage:l,isFetchingNextPage:C,fetchNextPage:I}=he(["outfit-picker",j],d=>Qt({search:j||void 0,category:"wearable",onSale:!0,listingType:"primary",first:24,skip:d,sortBy:"cheapest"})),U=new Set,y=s.filter(d=>{if(!d.itemId)return!1;const $=`${d.contractAddress.toLowerCase()}-${d.itemId}`;return U.has($)?!1:(U.add($),!0)});return t.jsxs(ge,{"data-testid":"outfit-picker",children:[t.jsxs(be,{children:[t.jsx(M,{name:"search",color:st.colors.muted}),t.jsx("input",{value:p,placeholder:e("outfits.studio.searchPlaceholder"),"aria-label":e("outfits.studio.searchPlaceholder"),onChange:d=>g(d.target.value),"data-testid":"outfit-picker-search"})]}),T?t.jsx("p",{className:"muted small",children:e("outfits.errors.generic")}):k||w?t.jsx(xt,{"aria-busy":"true",children:Array.from({length:8},(d,$)=>t.jsx(ye,{className:"skeleton","aria-hidden":!0},$))}):y.length===0?t.jsx("p",{className:"muted small",children:e("outfits.studio.noResults")}):t.jsx(xt,{children:y.map(d=>{const $=`${d.contractAddress.toLowerCase()}-${d.itemId}`,R=r.has($);return t.jsxs(je,{type:"button","data-testid":"outfit-picker-item","data-selected":R||void 0,disabled:!R&&!f(d),onClick:()=>h(d),title:d.name,children:[t.jsx(ve,{src:d.thumbnail,alt:"",loading:"lazy"}),t.jsx(we,{children:d.name}),t.jsxs($e,{children:[t.jsx(Y,{size:12}),d.priceCredits.toLocaleString()]}),R?t.jsx(Se,{name:"check-rounded",size:18}):null]},$)})}),!T&&!k&&!w?t.jsx(fe,{auto:!1,hasNextPage:!!l,isFetching:C,onLoadMore:()=>void I()}):null]})}const{colors:a,radius:v,media:W,z:Te}=st,Ct=o.div`
87
87
  max-width: 1200px;
88
88
  margin: 0 auto;
89
89
  display: flex;
@@ -176,13 +176,13 @@ import{r as u,j as t,L as O,u as Gt,b as qt,d as Wt}from"./react-DehiWSvs.js";im
176
176
  display: flex;
177
177
  flex-direction: column;
178
178
  gap: 4px;
179
- `,Pe=o.span`
179
+ `,Re=o.span`
180
180
  font-size: 15px;
181
181
  font-weight: 700;
182
182
  white-space: nowrap;
183
183
  overflow: hidden;
184
184
  text-overflow: ellipsis;
185
- `,Re=o.span`
185
+ `,Pe=o.span`
186
186
  display: inline-flex;
187
187
  align-items: center;
188
188
  gap: 8px;
@@ -239,10 +239,10 @@ import{r as u,j as t,L as O,u as Gt,b as qt,d as Wt}from"./react-DehiWSvs.js";im
239
239
  display: flex;
240
240
  flex-direction: column;
241
241
  gap: 12px;
242
- `,Ue=o.h2`
242
+ `,Me=o.h2`
243
243
  font-size: 18px;
244
244
  font-weight: 800;
245
- `,Me=o.div`
245
+ `,Ue=o.div`
246
246
  display: flex;
247
247
  flex-wrap: wrap;
248
248
  gap: 10px;
@@ -324,7 +324,7 @@ import{r as u,j as t,L as O,u as Gt,b as qt,d as Wt}from"./react-DehiWSvs.js";im
324
324
  background: ${a.accent};
325
325
  color: ${a.white};
326
326
  }
327
- `,Ve=o.div`
327
+ `,Je=o.div`
328
328
  width: 240px;
329
329
  aspect-ratio: 3 / 4;
330
330
  border-radius: ${v.card};
@@ -341,7 +341,7 @@ import{r as u,j as t,L as O,u as Gt,b as qt,d as Wt}from"./react-DehiWSvs.js";im
341
341
  object-fit: cover;
342
342
  display: block;
343
343
  }
344
- `,Je=o.div`
344
+ `,Ve=o.div`
345
345
  display: flex;
346
346
  align-items: center;
347
347
  gap: 12px;
@@ -497,4 +497,4 @@ import{r as u,j as t,L as O,u as Gt,b as qt,d as Wt}from"./react-DehiWSvs.js";im
497
497
  display: flex;
498
498
  flex-wrap: wrap;
499
499
  gap: 10px;
500
- `;function Ni(){const{id:r}=Gt(),{pathname:h}=qt(),f=q(b=>b.session),p=q(b=>b.signIn),g=Vt();Jt({title:e("outfits.studio.title"),noindex:!0});const j=h.endsWith("/new")?"new":r?"edit":"list";return g==="pending"?t.jsx(z,{"aria-busy":"true","data-testid":"outfit-studio-loading",children:t.jsx("span",{className:"spinner","aria-hidden":!0})}):f?g!=="creator"?t.jsxs(z,{"data-testid":"outfit-studio-unavailable",children:[t.jsx(gt,{children:e("outfits.studio.title")}),t.jsx("p",{className:"muted",children:e("outfits.studio.notAvailable")}),t.jsx(m,{as:O,to:"/overview",variant:"purple",children:e("outfits.studio.backToShop")})]}):j==="list"?t.jsx(xi,{}):t.jsx(yi,{outfitId:j==="edit"?r:null},r??"new"):t.jsxs(z,{"data-testid":"outfit-studio-signin",children:[t.jsx(gt,{children:e("outfits.studio.title")}),t.jsx("p",{className:"muted",children:e("outfits.studio.signInPrompt")}),t.jsx(m,{variant:"purple",onClick:()=>p(),children:e("outfits.studio.signIn")})]})}function mi({outfit:r}){const h=$t(r.thumbnailHash);return h?t.jsx(Le,{style:{background:oe(r)},children:t.jsx("img",{src:h,alt:"",loading:"lazy"})}):t.jsx(Ne,{"aria-hidden":!0})}function xi(){const r=q(l=>l.session),h=wt(),[f,p]=u.useState(null),[g,j]=u.useState(null),{data:b=[],isLoading:s,isError:k,refetch:w}=St({queryKey:["outfits-all"],enabled:!!r,staleTime:3e4,queryFn:()=>ce(r.identity)});async function T(l,C){if(r){j(l.id);try{C==="delete"?(await ae(l.id,r.identity),F.success(e("outfits.studio.deleted"))):(await kt({...it(l),published:!1},r.identity,"update"),F.success(e("outfits.studio.unpublished"))),Tt(h)}catch(I){I instanceof R||tt(I,{flow:`outfit-${C}`}),F.error(e(I instanceof R?et(I.code):"outfits.errors.generic"))}finally{j(null),p(null)}}}return t.jsxs(Ct,{"data-testid":"outfit-studio-list",children:[t.jsxs(It,{children:[t.jsx(Et,{children:e("outfits.studio.myOutfits")}),t.jsx(m,{as:O,to:"/outfits/new",variant:"purple","data-testid":"outfit-studio-new",children:e("outfits.studio.new")})]}),s?t.jsx(bt,{"aria-busy":"true",children:Array.from({length:3},(l,C)=>t.jsx(Ie,{className:"skeleton","aria-hidden":!0},C))}):k?t.jsxs(z,{children:[t.jsx(D,{message:e("outfits.errors.generic")}),t.jsx(m,{variant:"purple",onClick:()=>void w(),children:e("outfits.detail.retry")})]}):b.length===0?t.jsx("p",{className:"muted",children:e("outfits.studio.empty")}):t.jsx(bt,{children:b.map(l=>t.jsxs(Ee,{"data-testid":"outfit-studio-row","data-published":l.published||void 0,children:[t.jsx(mi,{outfit:l}),t.jsxs(ze,{children:[t.jsx(Pe,{children:l.name||e("outfits.studio.untitled")}),t.jsxs(Re,{children:[t.jsx(Lt,{"data-state":l.published?"published":"draft",children:l.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")}),e("outfits.card.items",{count:l.items.length})]})]}),t.jsxs(Oe,{children:[l.published?t.jsx(m,{as:O,to:`/items/outfits/${l.id}`,variant:"ghost",size:"sm",children:e("outfits.studio.view")}):null,t.jsx(m,{as:O,to:`/outfits/${l.id}/edit`,variant:"outline",size:"sm","data-testid":"outfit-studio-edit",children:e("outfits.studio.edit")}),t.jsx(Fe,{type:"button","data-testid":"outfit-studio-delete","aria-label":e("outfits.studio.confirmDelete"),disabled:g===l.id,onClick:()=>p(l),children:t.jsx(U,{name:"trash",size:18})})]})]},l.id))}),f?t.jsxs(Ae,{role:"dialog","aria-modal":"true","aria-label":e("outfits.studio.deleteTitle"),"data-testid":"outfit-studio-confirm",children:[t.jsx(Be,{onClick:()=>p(null)}),t.jsxs(De,{children:[t.jsx(Ue,{children:e("outfits.studio.deleteTitle")}),t.jsx("p",{className:"muted",children:e("outfits.studio.deleteBody")}),t.jsxs(Me,{children:[f.published?t.jsx(m,{variant:"purple","data-testid":"outfit-studio-confirm-unpublish",disabled:g===f.id,onClick:()=>void T(f,"unpublish"),children:e("outfits.studio.unpublish")}):null,t.jsx(m,{variant:f.published?"outline":"purple","data-testid":"outfit-studio-confirm-delete",disabled:g===f.id,onClick:()=>void T(f,"delete"),children:e("outfits.studio.confirmDelete")}),t.jsx(m,{variant:"ghost",onClick:()=>p(null),children:e("outfits.studio.cancel")})]})]})]}):null]})}const jt=["image/png","image/jpeg","image/webp"];function gi(){return{id:crypto.randomUUID(),name:"",thumbnailHash:"",items:[],bodyShape:"unisex",gradientFrom:Z.from,gradientTo:Z.to,published:!1}}function it(r){return{id:r.id,name:r.name,thumbnailHash:r.thumbnailHash,items:r.items,bodyShape:r.bodyShape,gradientFrom:r.gradientFrom,gradientTo:r.gradientTo,published:r.published}}function bi(r){try{const h=sessionStorage.getItem(r);return h?JSON.parse(h):null}catch{return null}}function yi({outfitId:r}){const h=r===null,f=`outfit-draft:${r??"new"}`,p=q(i=>i.session),g=wt(),j=Wt(),[b]=u.useState(()=>bi(f)),[s,k]=u.useState(()=>b??(h?gi():null)),[w,T]=u.useState(!!b),{data:l,isLoading:C,isError:I,refetch:M}=St({queryKey:["outfit",r,!0],enabled:!h&&!!p,staleTime:0,queryFn:()=>pe(r,p.identity)});u.useEffect(()=>{l&&k(i=>i??it(l))},[l]);function y(i){k(n=>n&&{...n,...i}),T(!0)}u.useEffect(()=>{if(!(!s||!w))try{sessionStorage.setItem(f,JSON.stringify(s))}catch{}},[s,w,f]),u.useEffect(()=>{if(!w)return;const i=n=>n.preventDefault();return window.addEventListener("beforeunload",i),()=>window.removeEventListener("beforeunload",i)},[w]),u.useEffect(()=>()=>sessionStorage.removeItem(f),[f]);const d=Xt(s??void 0),S=u.useMemo(()=>new Set(((s==null?void 0:s.items)??[]).map(B)),[s]),P=i=>ue((s==null?void 0:s.items)??[],i,d.byKey),at=i=>!!i.itemId&&P(i).length<=G;function Pt(i){!s||!at(i)||y({items:P(i)})}const[Rt,nt]=u.useState(null),E=u.useRef(null),Q=u.useRef(!0);u.useEffect(()=>(Q.current=!0,()=>{Q.current=!1}),[]);const[H,rt]=u.useState(!1),[Ot,_]=u.useState(null),[V,dt]=u.useState(""),[Ft,lt]=u.useState(null),[$,At]=u.useState();u.useEffect(()=>()=>{E.current&&URL.revokeObjectURL(E.current)},[]);function ut(){const i=de(V);if(!i){lt(e("outfits.studio.importError"));return}lt(null),dt(""),At(i.colors),y({items:i.items,...i.bodyShape?{bodyShape:i.bodyShape}:{}}),F.success(e("outfits.studio.importSuccess",{count:i.items.length}))}async function Bt(i){if(!i||!p)return;if(_(null),!jt.includes(i.type)){_(e("outfits.errors.unsupportedType"));return}if(i.size>ne){_(e("outfits.errors.tooLarge"));return}E.current&&URL.revokeObjectURL(E.current);const n=URL.createObjectURL(i);E.current=n,nt(n),rt(!0);try{const c=await re(i,p.identity);y({thumbnailHash:c})}catch(c){c instanceof R||tt(c,{flow:"outfit-thumbnail"}),_(e(c instanceof R?et(c.code):"outfits.errors.generic")),E.current&&(URL.revokeObjectURL(E.current),E.current=null),nt(null)}finally{rt(!1)}}const[A,ct]=u.useState(!1),[Dt,pt]=u.useState(null),J=!!s&&s.name.trim().length>0&&s.name.length<=60,Ut=!!s&&K(s.gradientFrom)&&K(s.gradientTo),ft=!!s&&J&&!!s.thumbnailHash&&Ut&&s.items.length>=Yt&&s.items.length<=G;async function X(i){if(!(!p||!s||A)){ct(!0),pt(null);try{const n=await kt({...s,published:i},p.identity,h?"create":"update");if(!Q.current)return;sessionStorage.removeItem(f),k(it(n)),T(!1),Tt(g),i&&!s.published?(le("Shop Outfit Published",{outfit_id:n.id,item_count:n.items.length}),F.success(e("outfits.studio.publishedToast"))):F.success(e("outfits.studio.saved")),h&&(g.setQueryData(["outfit",n.id,!0],n),j(`/outfits/${n.id}/edit`,{replace:!0}))}catch(n){n instanceof R||tt(n,{flow:"outfit-save"}),pt(e(n instanceof R?et(n.code):"outfits.errors.generic"))}finally{ct(!1)}}}const ht=u.useMemo(()=>((s==null?void 0:s.items)??[]).map(i=>d.byKey.get(B(i))).map(i=>i?Zt(i):null).filter(i=>!!i),[s,d.byKey]),Mt=(s==null?void 0:s.bodyShape)==="female"?te:(s==null?void 0:s.bodyShape)==="male"?ee:void 0;if(!p)return null;if(!s)return I?t.jsxs(z,{children:[t.jsx(D,{message:e("outfits.errors.generic")}),t.jsx(m,{variant:"purple",onClick:()=>void M(),children:e("outfits.detail.retry")})]}):!C&&l===null?t.jsxs(z,{"data-testid":"outfit-studio-missing",children:[t.jsx("p",{className:"muted",children:e("outfits.errors.notFound")}),t.jsx(m,{as:O,to:"/outfits/manage",variant:"purple",children:e("outfits.studio.myOutfits")})]}):t.jsx(z,{"aria-busy":"true",children:t.jsx("span",{className:"spinner","aria-hidden":!0})});const mt=Rt??$t(s.thumbnailHash),Ht={...s,authorAddress:(p==null?void 0:p.address)??"",createdAt:0,updatedAt:0},_t=s.items.reduce((i,n)=>{var c;return i+(((c=d.byKey.get(B(n)))==null?void 0:c.priceCredits)??0)},0);return t.jsxs(Ct,{"data-testid":"outfit-studio-editor",children:[t.jsxs(It,{children:[t.jsx(Ce,{to:"/outfits/manage","aria-label":e("outfits.studio.myOutfits"),"data-testid":"outfit-studio-back",children:t.jsx(U,{name:"arrow-left",size:18})}),t.jsx(Et,{children:h?e("outfits.studio.new"):e("outfits.studio.editTitle")}),t.jsx(Lt,{"data-state":s.published?"published":"draft",children:s.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")})]}),t.jsxs(He,{children:[t.jsxs(_e,{children:[t.jsxs(Ge,{"data-testid":"outfit-studio-preview",style:{background:ie(s)},children:[t.jsx(me,{id:"outfit-studio-preview-frame",profile:"default",bodyShape:Mt,urns:ht,skin:$==null?void 0:$.skin,hair:$==null?void 0:$.hair,eyes:$==null?void 0:$.eyes,enabled:!d.isLoading}),ht.length===0&&!d.isLoading?t.jsx(qe,{className:"muted",children:e("outfits.studio.previewEmpty")}):null]}),t.jsxs(L,{children:[t.jsx(N,{as:"span",children:e("outfits.studio.bodyShape")}),t.jsx(We,{role:"group","aria-label":e("outfits.studio.bodyShape"),children:["unisex","male","female"].map(i=>t.jsx(Qe,{type:"button","data-selected":s.bodyShape===i||void 0,onClick:()=>y({bodyShape:i}),children:e(`outfits.studio.shape.${i}`)},i))})]}),t.jsxs(L,{children:[t.jsx(N,{as:"span",children:e("outfits.studio.gradient")}),t.jsx(Je,{children:["gradientFrom","gradientTo"].map(i=>t.jsxs(Xe,{children:[t.jsx(Ye,{type:"color",value:K(s[i])?s[i]:Z.from,"aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom"),"data-testid":i==="gradientFrom"?"outfit-studio-gradient-from":"outfit-studio-gradient-to",onChange:n=>y({[i]:n.target.value.toLowerCase()})}),t.jsxs(Ze,{children:[t.jsx("span",{children:e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom")}),t.jsx(ti,{value:s[i],maxLength:7,spellCheck:!1,placeholder:"#000000","aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTopHex":"outfits.studio.gradientBottomHex"),"data-invalid":!K(s[i])||void 0,onChange:n=>{const c=n.target.value.trim().toLowerCase();y({[i]:c.startsWith("#")||c===""?c:`#${c}`})}})]})]},i))}),t.jsx("p",{className:"muted small",children:e("outfits.studio.gradientHint")})]}),t.jsxs(L,{children:[t.jsx(N,{as:"span",children:e("outfits.studio.thumbnail")}),mt?t.jsx(Ve,{"data-busy":H||void 0,children:t.jsx("img",{src:mt,alt:""})}):null,t.jsxs(ii,{as:"label",variant:"outline",size:"sm","data-busy":H||void 0,children:[H?e("outfits.studio.uploading"):e("outfits.studio.upload"),t.jsx("input",{type:"file",accept:jt.join(","),hidden:!0,disabled:H,onChange:i=>{var n;return void Bt((n=i.target.files)==null?void 0:n[0])},"data-testid":"outfit-studio-thumb-input"})]}),t.jsx("p",{className:"muted small",children:e("outfits.studio.thumbnailHint")}),t.jsx(D,{message:Ot,testId:"outfit-studio-thumb-error"})]}),t.jsxs(L,{children:[t.jsx(N,{as:"span",children:e("outfits.studio.cardPreview")}),t.jsx(ei,{"data-testid":"outfit-studio-card-preview",onClickCapture:i=>{i.preventDefault(),i.stopPropagation()},children:t.jsx(se,{outfit:Ht,resolution:d})})]})]}),t.jsxs(Ke,{children:[t.jsxs(L,{children:[t.jsx(N,{htmlFor:"outfit-import",children:e("outfits.studio.import")}),t.jsxs(si,{children:[t.jsx(yt,{id:"outfit-import",value:V,spellCheck:!1,placeholder:e("outfits.studio.importPlaceholder"),onChange:i=>dt(i.target.value),onKeyDown:i=>{i.key==="Enter"&&ut()},"data-testid":"outfit-studio-import"}),t.jsx(m,{variant:"outline",size:"sm",onClick:ut,disabled:V.trim()==="","data-testid":"outfit-studio-import-apply",children:e("outfits.studio.importApply")})]}),t.jsx("p",{className:"muted small",children:e("outfits.studio.importHint")}),t.jsx(D,{message:Ft,testId:"outfit-studio-import-error"})]}),t.jsxs(L,{children:[t.jsx(N,{htmlFor:"outfit-name",children:e("outfits.studio.name")}),t.jsx(yt,{id:"outfit-name",value:s.name,maxLength:60,placeholder:e("outfits.studio.namePlaceholder"),onChange:i=>y({name:i.target.value}),"data-testid":"outfit-studio-name"})]}),t.jsxs(L,{children:[t.jsxs(N,{as:"span",children:[e("outfits.studio.items")," (",s.items.length,"/",G,")"]}),s.items.length===0?t.jsx("p",{className:"muted small",children:e("outfits.studio.noItems")}):t.jsx(oi,{children:s.items.map(i=>{const n=B(i),c=d.byKey.get(n);return t.jsxs(ai,{"data-testid":"outfit-studio-selected","data-missing":!c||void 0,children:[c?t.jsx(ni,{src:c.thumbnail,alt:""}):t.jsx(ri,{className:d.isLoading?"skeleton":void 0,"aria-hidden":!0}),t.jsx(di,{className:c?void 0:"muted",children:c?c.name:d.isLoading?"…":e("outfits.card.unavailable")}),c?t.jsxs(li,{children:[t.jsx(Y,{size:12}),c.priceCredits.toLocaleString()]}):null,t.jsx(pi,{type:"button","aria-label":e("outfits.studio.remove"),title:e("outfits.studio.remove"),onClick:()=>y({items:s.items.filter(Kt=>B(Kt)!==n)}),children:t.jsx(U,{name:"trash",size:16})})]},n)})}),s.items.length>0?t.jsxs(ui,{"data-testid":"outfit-studio-total",children:[t.jsx("span",{children:e("outfits.detail.totalPrice")}),t.jsxs(ci,{children:[t.jsx(Y,{size:14}),_t.toLocaleString()]})]}):null,s.items.length>=G?t.jsx("p",{className:"muted small",children:e("outfits.studio.maxItems")}):null]}),t.jsx(ke,{selectedKeys:S,onPick:Pt,canPick:at})]})]}),t.jsxs(fi,{"data-testid":"outfit-studio-savebar",children:[t.jsx(D,{message:Dt,testId:"outfit-studio-save-error"}),J?!ft&&!s.published?t.jsx("p",{className:"muted small",children:e("outfits.errors.notPublishable")}):null:t.jsx("p",{className:"muted small",children:e("outfits.studio.needName")}),t.jsxs(hi,{children:[t.jsx(m,{variant:"outline","data-testid":"outfit-studio-save",disabled:A||!J,onClick:()=>void X(s.published),children:A?e("outfits.studio.saving"):e("outfits.studio.saveDraft")}),s.published?t.jsx(m,{variant:"purple","data-testid":"outfit-studio-unpublish",disabled:A,onClick:()=>void X(!1),children:e("outfits.studio.unpublish")}):t.jsx(m,{variant:"purple","data-testid":"outfit-studio-publish",disabled:A||!ft,onClick:()=>void X(!0),children:e("outfits.studio.publish")})]})]})]})}export{Ni as OutfitStudio,Ni as default};
500
+ `;function Ni(){const{id:r}=Gt(),{pathname:h}=qt(),f=q(b=>b.session),p=q(b=>b.signIn),g=Jt();Vt({title:e("outfits.studio.title"),noindex:!0});const j=h.endsWith("/new")?"new":r?"edit":"list";return g==="pending"?t.jsx(z,{"aria-busy":"true","data-testid":"outfit-studio-loading",children:t.jsx("span",{className:"spinner","aria-hidden":!0})}):f?g!=="creator"?t.jsxs(z,{"data-testid":"outfit-studio-unavailable",children:[t.jsx(gt,{children:e("outfits.studio.title")}),t.jsx("p",{className:"muted",children:e("outfits.studio.notAvailable")}),t.jsx(m,{as:O,to:"/overview",variant:"purple",children:e("outfits.studio.backToShop")})]}):j==="list"?t.jsx(xi,{}):t.jsx(yi,{outfitId:j==="edit"?r:null},r??"new"):t.jsxs(z,{"data-testid":"outfit-studio-signin",children:[t.jsx(gt,{children:e("outfits.studio.title")}),t.jsx("p",{className:"muted",children:e("outfits.studio.signInPrompt")}),t.jsx(m,{variant:"purple",onClick:()=>p(),children:e("outfits.studio.signIn")})]})}function mi({outfit:r}){const h=St(r.thumbnailHash);return h?t.jsx(Le,{style:{background:oe(r)},children:t.jsx("img",{src:h,alt:"",loading:"lazy"})}):t.jsx(Ne,{"aria-hidden":!0})}function xi(){const r=q(l=>l.session),h=wt(),[f,p]=u.useState(null),[g,j]=u.useState(null),{data:b=[],isLoading:s,isError:k,refetch:w}=$t({queryKey:["outfits-all"],enabled:!!r,staleTime:3e4,queryFn:()=>ce(r.identity)});async function T(l,C){if(r){j(l.id);try{C==="delete"?(await ae(l.id,r.identity),F.success(e("outfits.studio.deleted"))):(await kt({...it(l),published:!1},r.identity,"update"),F.success(e("outfits.studio.unpublished"))),Tt(h)}catch(I){I instanceof P||tt(I,{flow:`outfit-${C}`}),F.error(e(I instanceof P?et(I.code):"outfits.errors.generic"))}finally{j(null),p(null)}}}return t.jsxs(Ct,{"data-testid":"outfit-studio-list",children:[t.jsxs(It,{children:[t.jsx(Et,{children:e("outfits.studio.myOutfits")}),t.jsx(m,{as:O,to:"/outfits/new",variant:"purple","data-testid":"outfit-studio-new",children:e("outfits.studio.new")})]}),s?t.jsx(bt,{"aria-busy":"true",children:Array.from({length:3},(l,C)=>t.jsx(Ie,{className:"skeleton","aria-hidden":!0},C))}):k?t.jsxs(z,{children:[t.jsx(D,{message:e("outfits.errors.generic")}),t.jsx(m,{variant:"purple",onClick:()=>void w(),children:e("outfits.detail.retry")})]}):b.length===0?t.jsx("p",{className:"muted",children:e("outfits.studio.empty")}):t.jsx(bt,{children:b.map(l=>t.jsxs(Ee,{"data-testid":"outfit-studio-row","data-published":l.published||void 0,children:[t.jsx(mi,{outfit:l}),t.jsxs(ze,{children:[t.jsx(Re,{children:l.name||e("outfits.studio.untitled")}),t.jsxs(Pe,{children:[t.jsx(Lt,{"data-state":l.published?"published":"draft",children:l.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")}),e("outfits.card.items",{count:l.items.length})]})]}),t.jsxs(Oe,{children:[l.published?t.jsx(m,{as:O,to:`/items/outfits/${l.id}`,variant:"ghost",size:"sm",children:e("outfits.studio.view")}):null,t.jsx(m,{as:O,to:`/outfits/${l.id}/edit`,variant:"outline",size:"sm","data-testid":"outfit-studio-edit",children:e("outfits.studio.edit")}),t.jsx(Fe,{type:"button","data-testid":"outfit-studio-delete","aria-label":e("outfits.studio.confirmDelete"),disabled:g===l.id,onClick:()=>p(l),children:t.jsx(M,{name:"trash",size:18})})]})]},l.id))}),f?t.jsxs(Ae,{role:"dialog","aria-modal":"true","aria-label":e("outfits.studio.deleteTitle"),"data-testid":"outfit-studio-confirm",children:[t.jsx(Be,{onClick:()=>p(null)}),t.jsxs(De,{children:[t.jsx(Me,{children:e("outfits.studio.deleteTitle")}),t.jsx("p",{className:"muted",children:e("outfits.studio.deleteBody")}),t.jsxs(Ue,{children:[f.published?t.jsx(m,{variant:"purple","data-testid":"outfit-studio-confirm-unpublish",disabled:g===f.id,onClick:()=>void T(f,"unpublish"),children:e("outfits.studio.unpublish")}):null,t.jsx(m,{variant:f.published?"outline":"purple","data-testid":"outfit-studio-confirm-delete",disabled:g===f.id,onClick:()=>void T(f,"delete"),children:e("outfits.studio.confirmDelete")}),t.jsx(m,{variant:"ghost",onClick:()=>p(null),children:e("outfits.studio.cancel")})]})]})]}):null]})}const jt=["image/png","image/jpeg","image/webp"];function gi(){return{id:crypto.randomUUID(),name:"",thumbnailHash:"",items:[],bodyShape:"unisex",gradientFrom:Z.from,gradientTo:Z.to,published:!1}}function it(r){return{id:r.id,name:r.name,thumbnailHash:r.thumbnailHash,items:r.items,bodyShape:r.bodyShape,gradientFrom:r.gradientFrom,gradientTo:r.gradientTo,published:r.published}}function bi(r){try{const h=sessionStorage.getItem(r);return h?JSON.parse(h):null}catch{return null}}function yi({outfitId:r}){const h=r===null,f=`outfit-draft:${r??"new"}`,p=q(i=>i.session),g=wt(),j=Wt(),[b]=u.useState(()=>bi(f)),[s,k]=u.useState(()=>b??(h?gi():null)),[w,T]=u.useState(!!b),{data:l,isLoading:C,isError:I,refetch:U}=$t({queryKey:["outfit",r,!0],enabled:!h&&!!p,staleTime:0,queryFn:()=>pe(r,p.identity)});u.useEffect(()=>{l&&k(i=>i??it(l))},[l]);function y(i){k(n=>n&&{...n,...i}),T(!0)}u.useEffect(()=>{if(!(!s||!w))try{sessionStorage.setItem(f,JSON.stringify(s))}catch{}},[s,w,f]),u.useEffect(()=>{if(!w)return;const i=n=>n.preventDefault();return window.addEventListener("beforeunload",i),()=>window.removeEventListener("beforeunload",i)},[w]),u.useEffect(()=>()=>sessionStorage.removeItem(f),[f]);const d=Xt(s??void 0),$=u.useMemo(()=>new Set(((s==null?void 0:s.items)??[]).map(B)),[s]),R=i=>ue((s==null?void 0:s.items)??[],i,d.byKey),at=i=>!!i.itemId&&R(i).length<=G;function Rt(i){!s||!at(i)||y({items:R(i)})}const[Pt,nt]=u.useState(null),E=u.useRef(null),Q=u.useRef(!0);u.useEffect(()=>(Q.current=!0,()=>{Q.current=!1}),[]);const[H,rt]=u.useState(!1),[Ot,_]=u.useState(null),[J,dt]=u.useState(""),[Ft,lt]=u.useState(null),[S,At]=u.useState();u.useEffect(()=>()=>{E.current&&URL.revokeObjectURL(E.current)},[]);function ut(){const i=de(J);if(!i){lt(e("outfits.studio.importError"));return}lt(null),dt(""),At(i.colors),y({items:i.items,...i.bodyShape?{bodyShape:i.bodyShape}:{}}),F.success(e("outfits.studio.importSuccess",{count:i.items.length}))}async function Bt(i){if(!i||!p)return;if(_(null),!jt.includes(i.type)){_(e("outfits.errors.unsupportedType"));return}if(i.size>ne){_(e("outfits.errors.tooLarge"));return}E.current&&URL.revokeObjectURL(E.current);const n=URL.createObjectURL(i);E.current=n,nt(n),rt(!0);try{const c=await re(i,p.identity);y({thumbnailHash:c})}catch(c){c instanceof P||tt(c,{flow:"outfit-thumbnail"}),_(e(c instanceof P?et(c.code):"outfits.errors.generic")),E.current&&(URL.revokeObjectURL(E.current),E.current=null),nt(null)}finally{rt(!1)}}const[A,ct]=u.useState(!1),[Dt,pt]=u.useState(null),V=!!s&&s.name.trim().length>0&&s.name.length<=60,Mt=!!s&&K(s.gradientFrom)&&K(s.gradientTo),ft=!!s&&V&&!!s.thumbnailHash&&Mt&&s.items.length>=Yt&&s.items.length<=G;async function X(i){if(!(!p||!s||A)){ct(!0),pt(null);try{const n=await kt({...s,published:i},p.identity,h?"create":"update");if(!Q.current)return;sessionStorage.removeItem(f),k(it(n)),T(!1),Tt(g),i&&!s.published?(le("Shop Outfit Published",{outfit_id:n.id,item_count:n.items.length}),F.success(e("outfits.studio.publishedToast"))):F.success(e("outfits.studio.saved")),h&&(g.setQueryData(["outfit",n.id,!0],n),j(`/outfits/${n.id}/edit`,{replace:!0}))}catch(n){n instanceof P||tt(n,{flow:"outfit-save"}),pt(e(n instanceof P?et(n.code):"outfits.errors.generic"))}finally{ct(!1)}}}const ht=u.useMemo(()=>((s==null?void 0:s.items)??[]).map(i=>d.byKey.get(B(i))).map(i=>i?Zt(i):null).filter(i=>!!i),[s,d.byKey]),Ut=(s==null?void 0:s.bodyShape)==="female"?te:(s==null?void 0:s.bodyShape)==="male"?ee:void 0;if(!p)return null;if(!s)return I?t.jsxs(z,{children:[t.jsx(D,{message:e("outfits.errors.generic")}),t.jsx(m,{variant:"purple",onClick:()=>void U(),children:e("outfits.detail.retry")})]}):!C&&l===null?t.jsxs(z,{"data-testid":"outfit-studio-missing",children:[t.jsx("p",{className:"muted",children:e("outfits.errors.notFound")}),t.jsx(m,{as:O,to:"/outfits/manage",variant:"purple",children:e("outfits.studio.myOutfits")})]}):t.jsx(z,{"aria-busy":"true",children:t.jsx("span",{className:"spinner","aria-hidden":!0})});const mt=Pt??St(s.thumbnailHash),Ht={...s,authorAddress:(p==null?void 0:p.address)??"",createdAt:0,updatedAt:0},_t=s.items.reduce((i,n)=>{var c;return i+(((c=d.byKey.get(B(n)))==null?void 0:c.priceCredits)??0)},0);return t.jsxs(Ct,{"data-testid":"outfit-studio-editor",children:[t.jsxs(It,{children:[t.jsx(Ce,{to:"/outfits/manage","aria-label":e("outfits.studio.myOutfits"),"data-testid":"outfit-studio-back",children:t.jsx(M,{name:"arrow-left",size:18})}),t.jsx(Et,{children:h?e("outfits.studio.new"):e("outfits.studio.editTitle")}),t.jsx(Lt,{"data-state":s.published?"published":"draft",children:s.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")})]}),t.jsxs(He,{children:[t.jsxs(_e,{children:[t.jsxs(Ge,{"data-testid":"outfit-studio-preview",style:{background:ie(s)},children:[t.jsx(me,{id:"outfit-studio-preview-frame",profile:"default",bodyShape:Ut,urns:ht,skin:S==null?void 0:S.skin,hair:S==null?void 0:S.hair,eyes:S==null?void 0:S.eyes,enabled:!d.isLoading}),ht.length===0&&!d.isLoading?t.jsx(qe,{className:"muted",children:e("outfits.studio.previewEmpty")}):null]}),t.jsxs(L,{children:[t.jsx(N,{as:"span",children:e("outfits.studio.bodyShape")}),t.jsx(We,{role:"group","aria-label":e("outfits.studio.bodyShape"),children:["unisex","male","female"].map(i=>t.jsx(Qe,{type:"button","data-selected":s.bodyShape===i||void 0,onClick:()=>y({bodyShape:i}),children:e(`outfits.studio.shape.${i}`)},i))})]}),t.jsxs(L,{children:[t.jsx(N,{as:"span",children:e("outfits.studio.gradient")}),t.jsx(Ve,{children:["gradientFrom","gradientTo"].map(i=>t.jsxs(Xe,{children:[t.jsx(Ye,{type:"color",value:K(s[i])?s[i]:Z.from,"aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom"),"data-testid":i==="gradientFrom"?"outfit-studio-gradient-from":"outfit-studio-gradient-to",onChange:n=>y({[i]:n.target.value.toLowerCase()})}),t.jsxs(Ze,{children:[t.jsx("span",{children:e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom")}),t.jsx(ti,{value:s[i],maxLength:7,spellCheck:!1,placeholder:"#000000","aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTopHex":"outfits.studio.gradientBottomHex"),"data-invalid":!K(s[i])||void 0,onChange:n=>{const c=n.target.value.trim().toLowerCase();y({[i]:c.startsWith("#")||c===""?c:`#${c}`})}})]})]},i))}),t.jsx("p",{className:"muted small",children:e("outfits.studio.gradientHint")})]}),t.jsxs(L,{children:[t.jsx(N,{as:"span",children:e("outfits.studio.thumbnail")}),mt?t.jsx(Je,{"data-busy":H||void 0,children:t.jsx("img",{src:mt,alt:""})}):null,t.jsxs(ii,{as:"label",variant:"outline",size:"sm","data-busy":H||void 0,children:[H?e("outfits.studio.uploading"):e("outfits.studio.upload"),t.jsx("input",{type:"file",accept:jt.join(","),hidden:!0,disabled:H,onChange:i=>{var n;return void Bt((n=i.target.files)==null?void 0:n[0])},"data-testid":"outfit-studio-thumb-input"})]}),t.jsx("p",{className:"muted small",children:e("outfits.studio.thumbnailHint")}),t.jsx(D,{message:Ot,testId:"outfit-studio-thumb-error"})]}),t.jsxs(L,{children:[t.jsx(N,{as:"span",children:e("outfits.studio.cardPreview")}),t.jsx(ei,{"data-testid":"outfit-studio-card-preview",onClickCapture:i=>{i.preventDefault(),i.stopPropagation()},children:t.jsx(se,{outfit:Ht,resolution:d})})]})]}),t.jsxs(Ke,{children:[t.jsxs(L,{children:[t.jsx(N,{htmlFor:"outfit-import",children:e("outfits.studio.import")}),t.jsxs(si,{children:[t.jsx(yt,{id:"outfit-import",value:J,spellCheck:!1,placeholder:e("outfits.studio.importPlaceholder"),onChange:i=>dt(i.target.value),onKeyDown:i=>{i.key==="Enter"&&ut()},"data-testid":"outfit-studio-import"}),t.jsx(m,{variant:"outline",size:"sm",onClick:ut,disabled:J.trim()==="","data-testid":"outfit-studio-import-apply",children:e("outfits.studio.importApply")})]}),t.jsx("p",{className:"muted small",children:e("outfits.studio.importHint")}),t.jsx(D,{message:Ft,testId:"outfit-studio-import-error"})]}),t.jsxs(L,{children:[t.jsx(N,{htmlFor:"outfit-name",children:e("outfits.studio.name")}),t.jsx(yt,{id:"outfit-name",value:s.name,maxLength:60,placeholder:e("outfits.studio.namePlaceholder"),onChange:i=>y({name:i.target.value}),"data-testid":"outfit-studio-name"})]}),t.jsxs(L,{children:[t.jsxs(N,{as:"span",children:[e("outfits.studio.items")," (",s.items.length,"/",G,")"]}),s.items.length===0?t.jsx("p",{className:"muted small",children:e("outfits.studio.noItems")}):t.jsx(oi,{children:s.items.map(i=>{const n=B(i),c=d.byKey.get(n);return t.jsxs(ai,{"data-testid":"outfit-studio-selected","data-missing":!c||void 0,children:[c?t.jsx(ni,{src:c.thumbnail,alt:""}):t.jsx(ri,{className:d.isLoading?"skeleton":void 0,"aria-hidden":!0}),t.jsx(di,{className:c?void 0:"muted",children:c?c.name:d.isLoading?"…":e("outfits.card.unavailable")}),c?t.jsxs(li,{children:[t.jsx(Y,{size:12}),c.priceCredits.toLocaleString()]}):null,t.jsx(pi,{type:"button","aria-label":e("outfits.studio.remove"),title:e("outfits.studio.remove"),onClick:()=>y({items:s.items.filter(Kt=>B(Kt)!==n)}),children:t.jsx(M,{name:"trash",size:16})})]},n)})}),s.items.length>0?t.jsxs(ui,{"data-testid":"outfit-studio-total",children:[t.jsx("span",{children:e("outfits.detail.totalPrice")}),t.jsxs(ci,{children:[t.jsx(Y,{size:14}),_t.toLocaleString()]})]}):null,s.items.length>=G?t.jsx("p",{className:"muted small",children:e("outfits.studio.maxItems")}):null]}),t.jsx(ke,{selectedKeys:$,onPick:Rt,canPick:at})]})]}),t.jsxs(fi,{"data-testid":"outfit-studio-savebar",children:[t.jsx(D,{message:Dt,testId:"outfit-studio-save-error"}),V?!ft&&!s.published?t.jsx("p",{className:"muted small",children:e("outfits.errors.notPublishable")}):null:t.jsx("p",{className:"muted small",children:e("outfits.studio.needName")}),t.jsxs(hi,{children:[t.jsx(m,{variant:"outline","data-testid":"outfit-studio-save",disabled:A||!V,onClick:()=>void X(s.published),children:A?e("outfits.studio.saving"):e("outfits.studio.saveDraft")}),s.published?t.jsx(m,{variant:"purple","data-testid":"outfit-studio-unpublish",disabled:A,onClick:()=>void X(!1),children:e("outfits.studio.unpublish")}):t.jsx(m,{variant:"purple","data-testid":"outfit-studio-publish",disabled:A||!ft,onClick:()=>void X(!0),children:e("outfits.studio.publish")})]})]})]})}export{Ni as OutfitStudio,Ni as default};
@@ -1,4 +1,4 @@
1
- import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{b as s,t as j,s as a,l as ce,B as q,m as de,n as pe,q as ue,I as z,w as F}from"./index-Da1IWtza.js";import{u as ge,d as me,t as xe,L as he,i as A,a as f,s as fe}from"./useStore-C66JN0w6.js";import{E as M}from"./ErrorNotice-C-nXSZqX.js";import{F as w}from"./field.styles-D-WXHTOH.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";const ve="https://cdn.decentraland.org/@dcl/shop/0.5.1-30934281711.commit-71d435d/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/0.5.1-30934281711.commit-71d435d/_assets/template-cover-2-Dni9s0i_.jpeg",we=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ve,"../assets/creator-covers/template-cover-2.jpeg":be}),v=Object.entries(we).sort(([r],[u])=>r.localeCompare(u)).map(([r,u])=>({name:r.split("/").pop(),url:u})),je=ce`
1
+ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{b as s,t as w,s as a,o as ce,B as q,q as de,n as pe,x as ue,I as N,z as F}from"./index-Dy5Vw1H0.js";import{u as ge,d as me,t as xe,L as he,i as A,a as f,s as fe}from"./useStore-ff9cCCX6.js";import{E as M}from"./ErrorNotice-I9zAvGEr.js";import{F as j}from"./field.styles-CJlWBLbF.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";const ve="https://cdn.decentraland.org/@dcl/shop/0.5.1-30936490891.commit-42e2634/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/0.5.1-30936490891.commit-42e2634/_assets/template-cover-2-Dni9s0i_.jpeg",je=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ve,"../assets/creator-covers/template-cover-2.jpeg":be}),v=Object.entries(je).sort(([r],[u])=>r.localeCompare(u)).map(([r,u])=>({name:r.split("/").pop(),url:u})),we=ce`
2
2
  to {
3
3
  transform: rotate(360deg);
4
4
  }
@@ -7,7 +7,7 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{b as s,t a
7
7
  align-items: center;
8
8
  justify-content: center;
9
9
  gap: 12px;
10
- color: ${j.colors.muted};
10
+ color: ${w.colors.muted};
11
11
 
12
12
  &[data-direction='row'] {
13
13
  flex-direction: row;
@@ -20,9 +20,9 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{b as s,t a
20
20
  flex: none;
21
21
  border-radius: 50%;
22
22
  border-style: solid;
23
- border-color: ${j.colors.line};
24
- border-top-color: ${j.colors.accent};
25
- animation: ${je} 0.8s linear infinite;
23
+ border-color: ${w.colors.line};
24
+ border-top-color: ${w.colors.accent};
25
+ animation: ${we} 0.8s linear infinite;
26
26
 
27
27
  &[data-size='small'] {
28
28
  width: 18px;
@@ -46,11 +46,11 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{b as s,t a
46
46
  `,$e=a.span`
47
47
  font-size: 14px;
48
48
  font-weight: 600;
49
- `;function ye({label:r,size:u="medium",direction:S="column",className:k}){return t.jsxs(Se,{className:k,"data-testid":"spinner-box","data-direction":S,role:"status","aria-live":"polite","aria-label":r?void 0:s("spinner.loading"),children:[t.jsx(ke,{"data-testid":"spinner-box-ring","data-size":u,"aria-hidden":!0}),r?t.jsx($e,{children:r}):null]})}const{colors:n,radius:_e,media:G}=j,Ee=a(ye)`
49
+ `;function ye({label:r,size:u="medium",direction:S="column",className:k}){return t.jsxs(Se,{className:k,"data-testid":"spinner-box","data-direction":S,role:"status","aria-live":"polite","aria-label":r?void 0:s("spinner.loading"),children:[t.jsx(ke,{"data-testid":"spinner-box-ring","data-size":u,"aria-hidden":!0}),r?t.jsx($e,{children:r}):null]})}const{colors:n,radius:_e,media:G}=w,Ee=a(ye)`
50
50
  display: grid;
51
51
  place-items: center;
52
52
  min-height: 60vh;
53
- `,Ne=a(q)`
53
+ `,ze=a(q)`
54
54
  align-self: center;
55
55
  min-width: 200px;
56
56
  margin-top: 8px;
@@ -84,7 +84,7 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{b as s,t a
84
84
  resize: vertical;
85
85
  min-height: 88px;
86
86
  }
87
- `,ze=a.div`
87
+ `,Ne=a.div`
88
88
  display: flex;
89
89
  align-items: baseline;
90
90
  justify-content: space-between;
@@ -236,4 +236,4 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{b as s,t a
236
236
  ${G.maxWidth("mobile")} {
237
237
  width: 100%;
238
238
  }
239
- `,V=1e6,W={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function Y(r){return`${(r/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function Ke(){de({title:s("seo.storeSettings.title"),noindex:!0});const{session:r,signIn:u}=pe(),S=le(),k=ue(),p=r==null?void 0:r.address,{data:$,isLoading:K}=ge(p),[o,g]=l.useState(W),[C,H]=l.useState(W),[y,x]=l.useState(),[h,I]=l.useState(!1),[c,_]=l.useState(null),[b,J]=l.useState({}),T=l.useRef(null);l.useEffect(()=>{if($){const e=me($);g(e),H(e),x(void 0),_(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[$]),l.useEffect(()=>{let e=!1;return Promise.all(v.map(async i=>[i.name,await xe(i.url)])).then(i=>{e||J(Object.fromEntries(i))}).catch(()=>{}),()=>{e=!0}},[]);const E=l.useMemo(()=>{const e=v.find(d=>o.coverName===`cover/${d.name}`);if(e)return e.name;const i=o.coverHash?v.find(d=>b[d.name]===o.coverHash):void 0;return i==null?void 0:i.name},[o.coverName,o.coverHash,b]);l.useEffect(()=>{c!=null&&c.hash&&v.some(e=>b[e.name]===c.hash)&&_(null)},[b,c]);const B=y!==void 0&&y>V,Q=l.useMemo(()=>he.filter(e=>!A(e,o.links[e])),[o.links]),U=B||Q.length>0,N=l.useMemo(()=>JSON.stringify(o)!==JSON.stringify(C),[o,C]),X=N&&!U&&!h;if(l.useEffect(()=>{if(!N)return;const e=i=>{i.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[N]),!r)return t.jsxs(O,{"data-signin":!0,"aria-label":s("storeSettings.title"),children:[t.jsx(D,{children:s("storeSettings.title")}),t.jsx("p",{className:"muted",children:s("storeSettings.signInPrompt")}),t.jsx(Ne,{variant:"purple",onClick:u,children:s("storeSettings.signIn")})]});function Z(e,i){x(void 0),g(d=>({...d,cover:i,coverName:`cover/${e}`,coverHash:""}))}const ee=["image/png","image/jpeg","image/webp"];function te(e){var P;const i=(P=e.target.files)==null?void 0:P[0];if(!i||!ee.includes(i.type))return;x(i.size);const d=`cover/${i.name}`,m=new FileReader;m.onload=()=>{const R=m.result;_({url:R,name:d,hash:""}),g(re=>({...re,cover:R,coverName:d,coverHash:""}))},m.readAsDataURL(i)}function ie(){c&&(x(void 0),g(e=>({...e,cover:c.url,coverName:c.name,coverHash:c.hash})))}function se(e,i){const d=i?(f[e]+i).replace(/\s/g,""):"";g(m=>({...m,links:{...m.links,[e]:d}}))}function ne(e){const i=o.links[e];return e==="website"?i:i.replace(f[e],"")}async function ae(){if(!(!p||!r)){I(!0);try{await fe(p,o,r.identity),H(o),x(void 0),await k.invalidateQueries({queryKey:["store",p.toLowerCase()]}),F.success(s("storeSettings.saved")),S(`/items/creator/${p}`)}catch{F.error(s("storeSettings.saveError"))}finally{I(!1)}}}return t.jsxs(O,{"aria-label":s("storeSettings.title"),children:[t.jsxs(ze,{children:[t.jsxs(Le,{children:[p?t.jsx(Ce,{to:`/items/creator/${p}`,title:s("storeSettings.back"),"aria-label":s("storeSettings.back"),children:t.jsx(z,{name:"arrow-left"})}):null,t.jsx(D,{children:s("storeSettings.title")})]}),p?t.jsxs(He,{href:`/items/creator/${p}`,target:"_blank",rel:"noopener noreferrer",children:[s("storeSettings.seeAsGuest"),t.jsx(z,{name:"external-link"})]}):null]}),K?t.jsx(Ee,{size:"large",label:s("storeSettings.loading")}):t.jsxs(t.Fragment,{children:[t.jsxs(w,{children:[t.jsx("span",{className:"field__label",children:s("storeSettings.cover")}),t.jsxs(Be,{role:"group","aria-label":s("storeSettings.cover"),children:[v.map(e=>{const i=E===e.name;return t.jsx(L,{type:"button","data-testid":"cover-picker-tile","data-selected":i,"aria-pressed":i,onClick:()=>Z(e.name,e.url),children:t.jsx("img",{src:e.url,alt:"",loading:"lazy"})},e.name)}),c?t.jsx(L,{type:"button","data-testid":"cover-picker-tile","data-variant":"custom","data-selected":!E,"aria-pressed":!E,onClick:ie,children:t.jsx("img",{src:c.url,alt:""})}):null,t.jsxs(L,{type:"button","data-testid":"cover-picker-tile","data-variant":"upload",onClick:()=>{var e;return(e=T.current)==null?void 0:e.click()},children:[t.jsx(z,{name:"upload"}),t.jsx("span",{children:s("storeSettings.upload")})]}),t.jsx(Pe,{ref:T,type:"file",accept:"image/png, image/jpeg, image/webp","data-testid":"cover-picker-input",onChange:te})]}),B?t.jsx(M,{message:s("storeSettings.sizeError",{max:Y(V),current:Y(y)})}):null]}),t.jsxs(w,{as:"label",children:[t.jsx("span",{className:"field__label",children:s("storeSettings.description")}),t.jsx("textarea",{value:o.description,rows:4,disabled:h,onChange:e=>g(i=>({...i,description:e.target.value}))})]}),t.jsxs(w,{as:"label",children:[t.jsx("span",{className:"field__label",children:s("storeSettings.website")}),t.jsx("input",{type:"url",value:o.links.website,placeholder:f.website,disabled:h,onChange:e=>g(i=>({...i,links:{...i.links,website:e.target.value.replace(/\s/g,"")}}))}),A("website",o.links.website)?null:t.jsx(M,{message:s("storeSettings.linkError",{value:f.website})})]}),["twitter","discord","facebook"].map(e=>t.jsxs(w,{as:"label",children:[t.jsx("span",{className:"field__label",children:s(`storeSettings.${e}`)}),t.jsxs(Ie,{children:[t.jsx(Te,{children:f[e]}),t.jsx("input",{type:"text",value:ne(e),disabled:h,onChange:i=>se(e,i.target.value)})]})]},e)),t.jsx(Re,{children:t.jsx(Fe,{variant:"purple","data-testid":"store-settings-save",onClick:()=>void ae(),disabled:!X,children:h?s("storeSettings.saving"):s("storeSettings.save")})})]})]})}export{Ke as StoreSettings,Ke as default};
239
+ `,V=1e6,W={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function Y(r){return`${(r/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function Ke(){de({title:s("seo.storeSettings.title"),noindex:!0});const{session:r,signIn:u}=pe(),S=le(),k=ue(),p=r==null?void 0:r.address,{data:$,isLoading:K}=ge(p),[o,g]=l.useState(W),[C,H]=l.useState(W),[y,x]=l.useState(),[h,I]=l.useState(!1),[c,_]=l.useState(null),[b,J]=l.useState({}),T=l.useRef(null);l.useEffect(()=>{if($){const e=me($);g(e),H(e),x(void 0),_(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[$]),l.useEffect(()=>{let e=!1;return Promise.all(v.map(async i=>[i.name,await xe(i.url)])).then(i=>{e||J(Object.fromEntries(i))}).catch(()=>{}),()=>{e=!0}},[]);const E=l.useMemo(()=>{const e=v.find(d=>o.coverName===`cover/${d.name}`);if(e)return e.name;const i=o.coverHash?v.find(d=>b[d.name]===o.coverHash):void 0;return i==null?void 0:i.name},[o.coverName,o.coverHash,b]);l.useEffect(()=>{c!=null&&c.hash&&v.some(e=>b[e.name]===c.hash)&&_(null)},[b,c]);const B=y!==void 0&&y>V,Q=l.useMemo(()=>he.filter(e=>!A(e,o.links[e])),[o.links]),U=B||Q.length>0,z=l.useMemo(()=>JSON.stringify(o)!==JSON.stringify(C),[o,C]),X=z&&!U&&!h;if(l.useEffect(()=>{if(!z)return;const e=i=>{i.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[z]),!r)return t.jsxs(O,{"data-signin":!0,"aria-label":s("storeSettings.title"),children:[t.jsx(D,{children:s("storeSettings.title")}),t.jsx("p",{className:"muted",children:s("storeSettings.signInPrompt")}),t.jsx(ze,{variant:"purple",onClick:u,children:s("storeSettings.signIn")})]});function Z(e,i){x(void 0),g(d=>({...d,cover:i,coverName:`cover/${e}`,coverHash:""}))}const ee=["image/png","image/jpeg","image/webp"];function te(e){var P;const i=(P=e.target.files)==null?void 0:P[0];if(!i||!ee.includes(i.type))return;x(i.size);const d=`cover/${i.name}`,m=new FileReader;m.onload=()=>{const R=m.result;_({url:R,name:d,hash:""}),g(re=>({...re,cover:R,coverName:d,coverHash:""}))},m.readAsDataURL(i)}function ie(){c&&(x(void 0),g(e=>({...e,cover:c.url,coverName:c.name,coverHash:c.hash})))}function se(e,i){const d=i?(f[e]+i).replace(/\s/g,""):"";g(m=>({...m,links:{...m.links,[e]:d}}))}function ne(e){const i=o.links[e];return e==="website"?i:i.replace(f[e],"")}async function ae(){if(!(!p||!r)){I(!0);try{await fe(p,o,r.identity),H(o),x(void 0),await k.invalidateQueries({queryKey:["store",p.toLowerCase()]}),F.success(s("storeSettings.saved")),S(`/items/creator/${p}`)}catch{F.error(s("storeSettings.saveError"))}finally{I(!1)}}}return t.jsxs(O,{"aria-label":s("storeSettings.title"),children:[t.jsxs(Ne,{children:[t.jsxs(Le,{children:[p?t.jsx(Ce,{to:`/items/creator/${p}`,title:s("storeSettings.back"),"aria-label":s("storeSettings.back"),children:t.jsx(N,{name:"arrow-left"})}):null,t.jsx(D,{children:s("storeSettings.title")})]}),p?t.jsxs(He,{href:`/items/creator/${p}`,target:"_blank",rel:"noopener noreferrer",children:[s("storeSettings.seeAsGuest"),t.jsx(N,{name:"external-link"})]}):null]}),K?t.jsx(Ee,{size:"large",label:s("storeSettings.loading")}):t.jsxs(t.Fragment,{children:[t.jsxs(j,{children:[t.jsx("span",{className:"field__label",children:s("storeSettings.cover")}),t.jsxs(Be,{role:"group","aria-label":s("storeSettings.cover"),children:[v.map(e=>{const i=E===e.name;return t.jsx(L,{type:"button","data-testid":"cover-picker-tile","data-selected":i,"aria-pressed":i,onClick:()=>Z(e.name,e.url),children:t.jsx("img",{src:e.url,alt:"",loading:"lazy"})},e.name)}),c?t.jsx(L,{type:"button","data-testid":"cover-picker-tile","data-variant":"custom","data-selected":!E,"aria-pressed":!E,onClick:ie,children:t.jsx("img",{src:c.url,alt:""})}):null,t.jsxs(L,{type:"button","data-testid":"cover-picker-tile","data-variant":"upload",onClick:()=>{var e;return(e=T.current)==null?void 0:e.click()},children:[t.jsx(N,{name:"upload"}),t.jsx("span",{children:s("storeSettings.upload")})]}),t.jsx(Pe,{ref:T,type:"file",accept:"image/png, image/jpeg, image/webp","data-testid":"cover-picker-input",onChange:te})]}),B?t.jsx(M,{message:s("storeSettings.sizeError",{max:Y(V),current:Y(y)})}):null]}),t.jsxs(j,{as:"label",children:[t.jsx("span",{className:"field__label",children:s("storeSettings.description")}),t.jsx("textarea",{value:o.description,rows:4,disabled:h,onChange:e=>g(i=>({...i,description:e.target.value}))})]}),t.jsxs(j,{as:"label",children:[t.jsx("span",{className:"field__label",children:s("storeSettings.website")}),t.jsx("input",{type:"url",value:o.links.website,placeholder:f.website,disabled:h,onChange:e=>g(i=>({...i,links:{...i.links,website:e.target.value.replace(/\s/g,"")}}))}),A("website",o.links.website)?null:t.jsx(M,{message:s("storeSettings.linkError",{value:f.website})})]}),["twitter","discord","facebook"].map(e=>t.jsxs(j,{as:"label",children:[t.jsx("span",{className:"field__label",children:s(`storeSettings.${e}`)}),t.jsxs(Ie,{children:[t.jsx(Te,{children:f[e]}),t.jsx("input",{type:"text",value:ne(e),disabled:h,onChange:i=>se(e,i.target.value)})]})]},e)),t.jsx(Re,{children:t.jsx(Fe,{variant:"purple","data-testid":"store-settings-save",onClick:()=>void ae(),disabled:!X,children:h?s("storeSettings.saving"):s("storeSettings.save")})})]})]})}export{Ke as StoreSettings,Ke as default};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_assets/index.es-DQ3AciL_.js","_assets/react-DehiWSvs.js"])))=>i.map(i=>d[i]);
2
- import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as t,_ as I,t as F,p as _,an as O,a9 as W,n as D,m as q,b as n,o as U,d as V,ao as H,c as B,B as J,ap as X}from"./index-Da1IWtza.js";import{w as G,S as K}from"./buy-gasless-CGeqOHtJ.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./authorizations-DKmCykqz.js";import"./sendMetaTransaction-kBil2Ej7.js";import"./trade-encoding-4xiglK48.js";const Q=t.div`
2
+ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as t,_ as I,t as F,w as _,aq as O,ac as W,n as D,q,b as n,v as U,C as V,ar as H,c as B,B as J,as as X}from"./index-Dy5Vw1H0.js";import{w as G,S as K}from"./buy-gasless-DP35z8wI.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./authorizations-vn6dbOqY.js";import"./sendMetaTransaction-feJSI2TG.js";import"./trade-encoding-SVWWPYXU.js";const Q=t.div`
3
3
  position: fixed;
4
4
  inset: 0;
5
5
  /**
@@ -125,12 +125,12 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
125
125
  width: 30px;
126
126
  height: 30px;
127
127
  color: ${s.text};
128
- `,pe=t.p`
128
+ `,he=t.p`
129
129
  display: inline-flex;
130
130
  align-items: baseline;
131
131
  gap: 6px;
132
132
  margin: 0;
133
- `,he=t.span`
133
+ `,pe=t.span`
134
134
  font-size: 24px;
135
135
  font-weight: 700;
136
136
  text-transform: capitalize;
@@ -201,7 +201,7 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
201
201
  font-weight: 600;
202
202
  font-size: 13px;
203
203
  color: ${s.muted};
204
- `,ye=t(O)`
204
+ `,ve=t(O)`
205
205
  position: relative;
206
206
  z-index: 1;
207
207
  color: ${s.muted};
@@ -210,7 +210,7 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
210
210
  & [data-avatar] {
211
211
  display: none;
212
212
  }
213
- `,ve=t.div`
213
+ `,ye=t.div`
214
214
  flex-shrink: 0;
215
215
  display: flex;
216
216
  align-items: center;
@@ -293,4 +293,4 @@ import{r as g,j as e,b as P,d as N,N as M}from"./react-DehiWSvs.js";import{s as
293
293
  `,R=t(J)`
294
294
  min-width: 160px;
295
295
  text-align: center;
296
- `;function Ae(c){return null}const Se=c=>new Promise(r=>setTimeout(r,c));function Ie(c,r){const[i,a]=g.useState(c?"pending":"confirmed"),x=r?`${r.owner}-${r.contractAddress}-${r.itemId}`:"";return g.useEffect(()=>{if(!c)return;let l=!1;return(async()=>{let f=!1;for(let o=0;o<20&&!l;o++)try{await G(c,{timeoutMs:15e3}),f=!0;break}catch(v){if(v instanceof K)continue;l||a("failed");return}if(!l){if(!f){a("timed-out");return}if(!r){a("confirmed");return}a("indexing");for(let o=0;o<40&&!l;o++){if(await X(r.owner,r.contractAddress,r.itemId)){l||a("confirmed");return}await Se(3e3)}l||a("timed-out")}})(),()=>{l=!0}},[c,x]),i}const Le=B.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",Te=B.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function Ue(){var S;const{state:c,search:r}=P(),i=c??Ae(),a=N(),{session:x}=D(),l=i==null?void 0:i.txHash,y=(i==null?void 0:i.items)??[],f=i!=null&&i.creditsAdded&&i.creditsAdded>0?i.creditsAdded:null,o=y[0],v=x!=null&&x.address&&(o!=null&&o.contractAddress)&&(o!=null&&o.itemId)?{owner:x.address,contractAddress:o.contractAddress,itemId:o.itemId}:null,u=Ie(i!=null&&i.settled?void 0:l,v);q({title:n("seo.success.title"),noindex:!0});const h=y;if(h.length===0)return e.jsx(M,{to:"/items",replace:!0});const A=h[0],w=(S=i==null?void 0:i.txHashes)!=null&&S.length?i.txHashes:l?[l]:[],p=w.length>0&&U(x==null?void 0:x.providerType)?w.map((d,k)=>e.jsx(ne,{href:`${Te}${d}`,target:"_blank",rel:"noreferrer",children:w.length>1?n("success.viewTransactionNumbered",{n:k+1,total:w.length}):n("success.viewTransaction")},d)):null;return u!=="confirmed"?e.jsx(L,{children:e.jsx(ee,{children:u==="pending"||u==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"spinner","aria-hidden":!0}),e.jsx(C,{children:u==="indexing"?n("success.finalizing"):n("success.processing")}),e.jsx(z,{children:u==="indexing"?e.jsxs(e.Fragment,{children:[n("success.indexingBefore")," ",h.length===1?e.jsx("strong",{children:A.name}):n("success.itemCount",{count:h.length})," ",n("success.indexingAfter")]}):e.jsxs(e.Fragment,{children:[n("success.confirmingBefore")," ",h.length===1?e.jsx("strong",{children:A.name}):n("success.itemCount",{count:h.length})," ",n("success.confirmingAfter")]})}),p?e.jsx(b,{children:p}):null]}):u==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx(C,{children:n("success.stillProcessingTitle")}),e.jsxs(z,{children:[n("success.timedOutBefore")," ",e.jsx("button",{className:"link",onClick:()=>a("/activity"),children:n("nav.activity")})," ",n("success.timedOutAfter")]}),p?e.jsx(b,{children:p}):null,e.jsxs(T,{children:[e.jsx(R,{variant:"purple",onClick:()=>a("/activity"),children:n("success.viewActivity")}),e.jsx(R,{variant:"ghost",onClick:()=>a("/items"),children:n("success.keepShopping")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{children:n("success.failedTitle")}),e.jsx(z,{children:n("success.failedBody")}),p?e.jsx(b,{children:p}):null,e.jsx(T,{children:e.jsx(R,{variant:"purple",onClick:()=>a("/items"),children:n("success.backToShop")})})]})})}):e.jsxs(L,{children:[e.jsx(Z,{}),e.jsxs(ie,{children:[e.jsxs(se,{role:"status",children:[e.jsx(re,{"aria-hidden":!0,children:e.jsxs("svg",{viewBox:"0 0 60 60",width:"60",height:"60",children:[e.jsx("circle",{cx:"30",cy:"30",r:"30",fill:"#34ce77"}),e.jsx("path",{d:"M18 31l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"4.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsxs(oe,{children:[e.jsx("b",{children:n("success.bannerTitle")})," ",n("success.bannerBody")]})]}),e.jsxs(ce,{children:[f?e.jsxs(le,{"data-testid":"success-credits",children:[e.jsx(xe,{}),e.jsxs(pe,{children:[e.jsx(he,{children:n("getCredits.creditsAmount",{credits:f,currency:V.name})})," ",e.jsx(ue,{children:n("getCredits.creditsAdded")})]})]}):null,h.map((d,k)=>{const $=d.quantity??1;return e.jsxs(ae,{children:[k>0?e.jsx(de,{"aria-hidden":!0}):null,e.jsxs(fe,{children:[e.jsxs(ge,{children:[d.thumbnail?e.jsx("img",{src:d.thumbnail,alt:""}):null,e.jsx(me,{"aria-hidden":!0,children:e.jsx("svg",{viewBox:"0 0 18 18",width:"12",height:"12",children:e.jsx("path",{d:"M4 9l3.5 3.5L14 5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs(je,{children:[e.jsxs(we,{title:d.name,children:[d.name||n("buyModal.itemFallback"),$>1?e.jsx(be,{children:n("cartCheckout.qty",{count:$})}):null]}),d.creator?e.jsx(ye,{address:d.creator,linkToProfile:!0}):null]}),e.jsxs(ve,{children:[e.jsx(ke,{}),e.jsx("span",{children:H(d.priceCredits*$)})]})]})]},d.id)})]}),p?e.jsx(b,{"data-receipt":!0,children:p}):null,e.jsxs($e,{children:[e.jsx(Ce,{"data-variant":"ghost",onClick:()=>a("/my-items"),children:n("success.myAssets")}),e.jsxs(ze,{"data-variant":"ruby",href:Le,target:"_blank",rel:"noreferrer",children:[n("success.tryInWorld"),e.jsx(Re,{"aria-hidden":!0,children:e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})]})}export{Ue as Success,Ue as default};
296
+ `;function Ae(c){return null}const Se=c=>new Promise(r=>setTimeout(r,c));function Ie(c,r){const[i,a]=g.useState(c?"pending":"confirmed"),x=r?`${r.owner}-${r.contractAddress}-${r.itemId}`:"";return g.useEffect(()=>{if(!c)return;let l=!1;return(async()=>{let f=!1;for(let o=0;o<20&&!l;o++)try{await G(c,{timeoutMs:15e3}),f=!0;break}catch(y){if(y instanceof K)continue;l||a("failed");return}if(!l){if(!f){a("timed-out");return}if(!r){a("confirmed");return}a("indexing");for(let o=0;o<40&&!l;o++){if(await X(r.owner,r.contractAddress,r.itemId)){l||a("confirmed");return}await Se(3e3)}l||a("timed-out")}})(),()=>{l=!0}},[c,x]),i}const Le=B.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",Te=B.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function Ue(){var S;const{state:c,search:r}=P(),i=c??Ae(),a=N(),{session:x}=D(),l=i==null?void 0:i.txHash,v=(i==null?void 0:i.items)??[],f=i!=null&&i.creditsAdded&&i.creditsAdded>0?i.creditsAdded:null,o=v[0],y=x!=null&&x.address&&(o!=null&&o.contractAddress)&&(o!=null&&o.itemId)?{owner:x.address,contractAddress:o.contractAddress,itemId:o.itemId}:null,u=Ie(i!=null&&i.settled?void 0:l,y);q({title:n("seo.success.title"),noindex:!0});const p=v;if(p.length===0)return e.jsx(M,{to:"/items",replace:!0});const A=p[0],w=(S=i==null?void 0:i.txHashes)!=null&&S.length?i.txHashes:l?[l]:[],h=w.length>0&&U(x==null?void 0:x.providerType)?w.map((d,k)=>e.jsx(ne,{href:`${Te}${d}`,target:"_blank",rel:"noreferrer",children:w.length>1?n("success.viewTransactionNumbered",{n:k+1,total:w.length}):n("success.viewTransaction")},d)):null;return u!=="confirmed"?e.jsx(L,{children:e.jsx(ee,{children:u==="pending"||u==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"spinner","aria-hidden":!0}),e.jsx(C,{children:u==="indexing"?n("success.finalizing"):n("success.processing")}),e.jsx(z,{children:u==="indexing"?e.jsxs(e.Fragment,{children:[n("success.indexingBefore")," ",p.length===1?e.jsx("strong",{children:A.name}):n("success.itemCount",{count:p.length})," ",n("success.indexingAfter")]}):e.jsxs(e.Fragment,{children:[n("success.confirmingBefore")," ",p.length===1?e.jsx("strong",{children:A.name}):n("success.itemCount",{count:p.length})," ",n("success.confirmingAfter")]})}),h?e.jsx(b,{children:h}):null]}):u==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx(C,{children:n("success.stillProcessingTitle")}),e.jsxs(z,{children:[n("success.timedOutBefore")," ",e.jsx("button",{className:"link",onClick:()=>a("/activity"),children:n("nav.activity")})," ",n("success.timedOutAfter")]}),h?e.jsx(b,{children:h}):null,e.jsxs(T,{children:[e.jsx(R,{variant:"purple",onClick:()=>a("/activity"),children:n("success.viewActivity")}),e.jsx(R,{variant:"ghost",onClick:()=>a("/items"),children:n("success.keepShopping")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{children:n("success.failedTitle")}),e.jsx(z,{children:n("success.failedBody")}),h?e.jsx(b,{children:h}):null,e.jsx(T,{children:e.jsx(R,{variant:"purple",onClick:()=>a("/items"),children:n("success.backToShop")})})]})})}):e.jsxs(L,{children:[e.jsx(Z,{}),e.jsxs(ie,{children:[e.jsxs(se,{role:"status",children:[e.jsx(re,{"aria-hidden":!0,children:e.jsxs("svg",{viewBox:"0 0 60 60",width:"60",height:"60",children:[e.jsx("circle",{cx:"30",cy:"30",r:"30",fill:"#34ce77"}),e.jsx("path",{d:"M18 31l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"4.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsxs(oe,{children:[e.jsx("b",{children:n("success.bannerTitle")})," ",n("success.bannerBody")]})]}),e.jsxs(ce,{children:[f?e.jsxs(le,{"data-testid":"success-credits",children:[e.jsx(xe,{}),e.jsxs(he,{children:[e.jsx(pe,{children:n("getCredits.creditsAmount",{credits:f,currency:V.name})})," ",e.jsx(ue,{children:n("getCredits.creditsAdded")})]})]}):null,p.map((d,k)=>{const $=d.quantity??1;return e.jsxs(ae,{children:[k>0?e.jsx(de,{"aria-hidden":!0}):null,e.jsxs(fe,{children:[e.jsxs(ge,{children:[d.thumbnail?e.jsx("img",{src:d.thumbnail,alt:""}):null,e.jsx(me,{"aria-hidden":!0,children:e.jsx("svg",{viewBox:"0 0 18 18",width:"12",height:"12",children:e.jsx("path",{d:"M4 9l3.5 3.5L14 5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs(je,{children:[e.jsxs(we,{title:d.name,children:[d.name||n("buyModal.itemFallback"),$>1?e.jsx(be,{children:n("cartCheckout.qty",{count:$})}):null]}),d.creator?e.jsx(ve,{address:d.creator,linkToProfile:!0}):null]}),e.jsxs(ye,{children:[e.jsx(ke,{}),e.jsx("span",{children:H(d.priceCredits*$)})]})]})]},d.id)})]}),h?e.jsx(b,{"data-receipt":!0,children:h}):null,e.jsxs($e,{children:[e.jsx(Ce,{"data-variant":"ghost",onClick:()=>a("/my-items"),children:n("success.myAssets")}),e.jsxs(ze,{"data-variant":"ruby",href:Le,target:"_blank",rel:"noreferrer",children:[n("success.tryInWorld"),e.jsx(Re,{"aria-hidden":!0,children:e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})]})}export{Ue as Success,Ue 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-DHADoYvF.js";import{au as C}from"./NetworkUtil-EoWQDMpU.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-D-orryVV.js";import{au as C}from"./NetworkUtil-EoWQDMpU.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,4 +1,4 @@
1
- import{r as o,j as C,a as T}from"./react-DehiWSvs.js";import{s as P,t as i}from"./index-Da1IWtza.js";const B=(...t)=>({shouldForwardProp:p=>!t.includes(p)}),A=P("span",B("block"))`
1
+ import{r as o,j as C,a as T}from"./react-DehiWSvs.js";import{s as P,t as i}from"./index-Dy5Vw1H0.js";const B=(...t)=>({shouldForwardProp:p=>!t.includes(p)}),A=P("span",B("block"))`
2
2
  display: ${({block:t})=>t?"flex":"inline-flex"};
3
3
  ${({block:t})=>t?"width: 100%;":""}
4
4
  `,I=P("span",B("placement"))`
@@ -1 +1 @@
1
- var ve=Object.defineProperty;var xe=(r,t,e)=>t in r?ve(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var p=(r,t,e)=>xe(r,typeof t!="symbol"?t+"":t,e);import{W as ue,a as Q,C as ge,B as Ce,f as X}from"./ethers-CtNGBird.js";import{a as Ee,d as B}from"./dcl-schemas-Dr9BTjb7.js";import{c as ee}from"./react-DehiWSvs.js";import{bV as Re,e as te,g as re}from"./index-Da1IWtza.js";import{c as q,e as be}from"./index-B_dncyHS.js";import{s as Ie}from"./sendMetaTransaction-kBil2Ej7.js";import"./sentry-973sfbO9.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function Pe(r){const t=await de();if(t){const e=await new ue(t).getSigner().getChainId();if(r===e)return t}return q.createProvider(Ee.ProviderType.NETWORK,r)}async function de(){try{return await q.getProvider()}catch{try{const{provider:r}=await q.tryPreviousConnection();return r}catch{return null}}}function ne(r){return Math.floor(r/1e3)}function ae(r){switch(r.assetType){case B.TradeAssetType.ERC721:return r.tokenId;case B.TradeAssetType.COLLECTION_ITEM:return r.itemId;case B.TradeAssetType.ERC20:return r.amount;default:return console.error("Invalid asset type:",r),""}}function Ae(r){var t;return{checks:{uses:r.checks.uses,expiration:ne(r.checks.expiration),effective:ne(r.checks.effective),salt:Q(r.checks.salt,32),contractSignatureIndex:r.checks.contractSignatureIndex,signerSignatureIndex:r.checks.signerSignatureIndex,allowedRoot:Q(r.checks.allowedRoot,32),externalChecks:(t=r.checks.externalChecks)==null?void 0:t.map(e=>({contractAddress:e.contractAddress,selector:e.selector,value:e.value?e.value:"0x",required:e.required}))},sent:r.sent.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x"})),received:r.received.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x",beneficiary:e.beneficiary}))}}function se(r,t){const e=Ae(r);return{signer:r.signer,signature:r.signature,...e,checks:{...e.checks,allowedProof:[]},sent:e.sent.map(i=>({...i,beneficiary:t}))}}async function Se(r){const t=await r.request({method:"eth_chainId",params:[]});let e;return typeof t=="string"?e=parseInt(t,16):e=t,e}async function Fe(r){const t=await Pe(r);return new ue(t)}const S=new be.EventEmitter;var C;(function(r){r.ERROR="error",r.SUCCESS="success",r.PROMPT="prompt",r.ACCEPT="accept",r.REJECT="reject"})(C||(C={}));let Le="https://transactions-api.decentraland.org/v1";const ke=()=>Le,Ue=()=>new Promise((r,t)=>{const e=()=>{S.removeAllListeners(C.REJECT),r(!0)},i=()=>{S.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};S.addListener(C.ACCEPT,e),S.addListener(C.REJECT,i)});async function oe(...r){const[t,e,...i]=r;try{const s=await de();if(!s)throw new Error("Provider not connected");const c=await Se(s),l=await Fe(t.chainId),b=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(b.populateTransaction):b.populateTransaction[e](...i));if(c===t.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let U=Ce.from(0);try{const _=await v.getGasPrice(),k=await v.estimateGas(T);U=_.mul(k)}catch{}if(!U.isZero()){const _=Ue(),k=await v.getBalance();S.emit(C.PROMPT,{transactionGasPrice:X(U),userBalance:X(k),chainId:t.chainId}),await _}}const P=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:P.hash}),P.hash}else{const v=await Ie(s,l,T.data,t,{serverURL:ke()});return S.emit(C.SUCCESS,{txHash:v}),v}}catch(s){const c={type:C.ERROR,error:s};throw S.emit(C.ERROR,c),s}}var M={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var _e=M.exports,ie;function Oe(){return ie||(ie=1,(function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,c=typeof ee=="object"&&ee;(c.global===c||c.window===c||c.self===c)&&(e=c);var l,b=2147483647,T=36,v=1,P=26,U=38,_=700,k=72,G=128,J="-",he=/^xn--/,fe=/[^\x20-\x7E]/,pe=/[\x2E\u3002\uFF0E\uFF61]/g,ye={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=T-v,E=Math.floor,O=String.fromCharCode,N;function F(n){throw new RangeError(ye[n])}function V(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function $(n,a){var o=n.split("@"),u="";o.length>1&&(u=o[0]+"@",n=o[1]),n=n.replace(pe,".");var d=n.split("."),y=V(d,a).join(".");return u+y}function H(n){for(var a=[],o=0,u=n.length,d,y;o<u;)d=n.charCodeAt(o++),d>=55296&&d<=56319&&o<u?(y=n.charCodeAt(o++),(y&64512)==56320?a.push(((d&1023)<<10)+(y&1023)+65536):(a.push(d),o--)):a.push(d);return a}function W(n){return V(n,function(a){var o="";return a>65535&&(a-=65536,o+=O(a>>>10&1023|55296),a=56320|a&1023),o+=O(a),o}).join("")}function Te(n){return n-48<10?n-22:n-65<26?n-65:n-97<26?n-97:T}function Y(n,a){return n+22+75*(n<26)-((a!=0)<<5)}function Z(n,a,o){var u=0;for(n=o?E(n/_):n>>1,n+=E(n/a);n>D*P>>1;u+=T)n=E(n/D);return E(u+(D+1)*n/(n+U))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=k,w,x,R,I,f,m,g,A,L;for(w=n.lastIndexOf(J),w<0&&(w=0),x=0;x<w;++x)n.charCodeAt(x)>=128&&F("not-basic"),a.push(n.charCodeAt(x));for(R=w>0?w+1:0;R<o;){for(I=d,f=1,m=T;R>=o&&F("invalid-input"),g=Te(n.charCodeAt(R++)),(g>=T||g>E((b-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+P?P:m-h,!(g<A);m+=T)L=T-A,f>E(b/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-I,u,I==0),E(d/u)>b-y&&F("overflow"),y+=E(d/u),d%=u,a.splice(d++,0,y)}return W(a)}function z(n){var a,o,u,d,y,h,w,x,R,I,f,m=[],g,A,L,j;for(n=H(n),g=n.length,a=G,o=0,y=k,h=0;h<g;++h)f=n[h],f<128&&m.push(O(f));for(u=d=m.length,d&&m.push(J);u<g;){for(w=b,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((b-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>b&&F("overflow"),f==a){for(x=o,R=T;I=R<=y?v:R>=y+P?P:R-y,!(x<I);R+=T)j=x-I,L=T-I,m.push(O(Y(I+j%L,0))),x=E(j/L);m.push(O(Y(x,0))),y=Z(o,A,u==d),o=0,++u}++o,++a}return m.join("")}function we(n){return $(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function me(n){return $(n,function(a){return fe.test(a)?"xn--"+z(a):a})}if(l={version:"1.4.1",ucs2:{decode:H,encode:W},decode:K,encode:z,toASCII:me,toUnicode:we},i&&s)if(r.exports==i)s.exports=l;else for(N in l)l.hasOwnProperty(N)&&(i[N]=l[N]);else e.punycode=l})(_e)})(M,M.exports)),M.exports}Oe();var le=(function(r){function t(){var i=this||self;return delete r.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return t();r.defineProperty(r.prototype,"__magic__",{configurable:!0,get:t});var e=__magic__;return e})(Object),Me=le.URL;le.URLSearchParams;var Ne={URL:Me};class ce extends Error{constructor(e,i,s){super(e);p(this,"status");p(this,"data");this.status=i,this.data=s}}const De=3,je=1e3,Be=[400,401,403,404,409,422],qe=(globalThis==null?void 0:globalThis.URL)??Ne.URL;class Ge{constructor(t,e){p(this,"baseUrl");p(this,"retries");p(this,"retryDelay");p(this,"nonRetryableStatuses");p(this,"identity");p(this,"sleep",t=>new Promise(e=>{setTimeout(e,t)}));p(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);p(this,"rawFetch",(t,e)=>{const i=new qe(t,this.baseUrl),s=(e==null?void 0:e.identity)??this.getIdentity();return Re.signedFetchFactory()(i.toString(),{...e,identity:s})});p(this,"fetch",async(t,e)=>{for(let i=0;i<=this.retries;i++)try{let s,c;try{s=await this.rawFetch(t,e);const l=await s.text();l.length===0?c={ok:!0,data:null}:c=JSON.parse(l)}catch(l){throw new ce(l.message,void 0,null)}if(!s.ok||c.ok===!1){const l=c.message??c.error;throw new ce(l??`Request failed with status code ${s.status}`,s.status,c.data)}return c.ok===!0?c.data:c}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===i||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=e==null?void 0:e.identity,this.retries=(e==null?void 0:e.retries)??De,this.retryDelay=(e==null?void 0:e.retryDelay)??je,this.nonRetryableStatuses=(e==null?void 0:e.nonRetryableStatuses)??Be}}class Je extends Ge{constructor(e,i,s){super(i,s);p(this,"signer");p(this,"addTrade",async e=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(e),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));p(this,"fetchTrade",async e=>this.fetch(`/v1/trades/${e}`,{method:"GET"}));this.signer=e}}class et{constructor(t,e,i){p(this,"tradesAPI");this.tradesAPI=new Je(t,e,{identity:i,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"accept",[c])}async cancel(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"cancelSignature",[c])}}export{et as TradeService};
1
+ var ve=Object.defineProperty;var xe=(r,t,e)=>t in r?ve(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var p=(r,t,e)=>xe(r,typeof t!="symbol"?t+"":t,e);import{W as ue,a as Q,C as ge,B as Ce,f as X}from"./ethers-CtNGBird.js";import{a as Ee,d as B}from"./dcl-schemas-Dr9BTjb7.js";import{c as ee}from"./react-DehiWSvs.js";import{bV as Re,d as te,g as re}from"./index-Dy5Vw1H0.js";import{c as q,e as be}from"./index-CbHNXAwv.js";import{s as Ie}from"./sendMetaTransaction-feJSI2TG.js";import"./sentry-973sfbO9.js";import"./intl-CBcMB1D2.js";import"./events-DQ172AOg.js";async function Pe(r){const t=await de();if(t){const e=await new ue(t).getSigner().getChainId();if(r===e)return t}return q.createProvider(Ee.ProviderType.NETWORK,r)}async function de(){try{return await q.getProvider()}catch{try{const{provider:r}=await q.tryPreviousConnection();return r}catch{return null}}}function ne(r){return Math.floor(r/1e3)}function ae(r){switch(r.assetType){case B.TradeAssetType.ERC721:return r.tokenId;case B.TradeAssetType.COLLECTION_ITEM:return r.itemId;case B.TradeAssetType.ERC20:return r.amount;default:return console.error("Invalid asset type:",r),""}}function Ae(r){var t;return{checks:{uses:r.checks.uses,expiration:ne(r.checks.expiration),effective:ne(r.checks.effective),salt:Q(r.checks.salt,32),contractSignatureIndex:r.checks.contractSignatureIndex,signerSignatureIndex:r.checks.signerSignatureIndex,allowedRoot:Q(r.checks.allowedRoot,32),externalChecks:(t=r.checks.externalChecks)==null?void 0:t.map(e=>({contractAddress:e.contractAddress,selector:e.selector,value:e.value?e.value:"0x",required:e.required}))},sent:r.sent.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x"})),received:r.received.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x",beneficiary:e.beneficiary}))}}function se(r,t){const e=Ae(r);return{signer:r.signer,signature:r.signature,...e,checks:{...e.checks,allowedProof:[]},sent:e.sent.map(i=>({...i,beneficiary:t}))}}async function Se(r){const t=await r.request({method:"eth_chainId",params:[]});let e;return typeof t=="string"?e=parseInt(t,16):e=t,e}async function Fe(r){const t=await Pe(r);return new ue(t)}const S=new be.EventEmitter;var C;(function(r){r.ERROR="error",r.SUCCESS="success",r.PROMPT="prompt",r.ACCEPT="accept",r.REJECT="reject"})(C||(C={}));let Le="https://transactions-api.decentraland.org/v1";const ke=()=>Le,Ue=()=>new Promise((r,t)=>{const e=()=>{S.removeAllListeners(C.REJECT),r(!0)},i=()=>{S.removeAllListeners(C.ACCEPT),t(new Error("User rejected transaction"))};S.addListener(C.ACCEPT,e),S.addListener(C.REJECT,i)});async function oe(...r){const[t,e,...i]=r;try{const s=await de();if(!s)throw new Error("Provider not connected");const c=await Se(s),l=await Fe(t.chainId),b=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(b.populateTransaction):b.populateTransaction[e](...i));if(c===t.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let U=Ce.from(0);try{const _=await v.getGasPrice(),k=await v.estimateGas(T);U=_.mul(k)}catch{}if(!U.isZero()){const _=Ue(),k=await v.getBalance();S.emit(C.PROMPT,{transactionGasPrice:X(U),userBalance:X(k),chainId:t.chainId}),await _}}const P=await v.sendTransaction(T);return S.emit(C.SUCCESS,{txHash:P.hash}),P.hash}else{const v=await Ie(s,l,T.data,t,{serverURL:ke()});return S.emit(C.SUCCESS,{txHash:v}),v}}catch(s){const c={type:C.ERROR,error:s};throw S.emit(C.ERROR,c),s}}var M={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var _e=M.exports,ie;function Oe(){return ie||(ie=1,(function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,c=typeof ee=="object"&&ee;(c.global===c||c.window===c||c.self===c)&&(e=c);var l,b=2147483647,T=36,v=1,P=26,U=38,_=700,k=72,G=128,J="-",he=/^xn--/,fe=/[^\x20-\x7E]/,pe=/[\x2E\u3002\uFF0E\uFF61]/g,ye={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=T-v,E=Math.floor,O=String.fromCharCode,N;function F(n){throw new RangeError(ye[n])}function V(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function $(n,a){var o=n.split("@"),u="";o.length>1&&(u=o[0]+"@",n=o[1]),n=n.replace(pe,".");var d=n.split("."),y=V(d,a).join(".");return u+y}function H(n){for(var a=[],o=0,u=n.length,d,y;o<u;)d=n.charCodeAt(o++),d>=55296&&d<=56319&&o<u?(y=n.charCodeAt(o++),(y&64512)==56320?a.push(((d&1023)<<10)+(y&1023)+65536):(a.push(d),o--)):a.push(d);return a}function W(n){return V(n,function(a){var o="";return a>65535&&(a-=65536,o+=O(a>>>10&1023|55296),a=56320|a&1023),o+=O(a),o}).join("")}function Te(n){return n-48<10?n-22:n-65<26?n-65:n-97<26?n-97:T}function Y(n,a){return n+22+75*(n<26)-((a!=0)<<5)}function Z(n,a,o){var u=0;for(n=o?E(n/_):n>>1,n+=E(n/a);n>D*P>>1;u+=T)n=E(n/D);return E(u+(D+1)*n/(n+U))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=k,w,x,R,I,f,m,g,A,L;for(w=n.lastIndexOf(J),w<0&&(w=0),x=0;x<w;++x)n.charCodeAt(x)>=128&&F("not-basic"),a.push(n.charCodeAt(x));for(R=w>0?w+1:0;R<o;){for(I=d,f=1,m=T;R>=o&&F("invalid-input"),g=Te(n.charCodeAt(R++)),(g>=T||g>E((b-d)/f))&&F("overflow"),d+=g*f,A=m<=h?v:m>=h+P?P:m-h,!(g<A);m+=T)L=T-A,f>E(b/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-I,u,I==0),E(d/u)>b-y&&F("overflow"),y+=E(d/u),d%=u,a.splice(d++,0,y)}return W(a)}function z(n){var a,o,u,d,y,h,w,x,R,I,f,m=[],g,A,L,j;for(n=H(n),g=n.length,a=G,o=0,y=k,h=0;h<g;++h)f=n[h],f<128&&m.push(O(f));for(u=d=m.length,d&&m.push(J);u<g;){for(w=b,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((b-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>b&&F("overflow"),f==a){for(x=o,R=T;I=R<=y?v:R>=y+P?P:R-y,!(x<I);R+=T)j=x-I,L=T-I,m.push(O(Y(I+j%L,0))),x=E(j/L);m.push(O(Y(x,0))),y=Z(o,A,u==d),o=0,++u}++o,++a}return m.join("")}function we(n){return $(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function me(n){return $(n,function(a){return fe.test(a)?"xn--"+z(a):a})}if(l={version:"1.4.1",ucs2:{decode:H,encode:W},decode:K,encode:z,toASCII:me,toUnicode:we},i&&s)if(r.exports==i)s.exports=l;else for(N in l)l.hasOwnProperty(N)&&(i[N]=l[N]);else e.punycode=l})(_e)})(M,M.exports)),M.exports}Oe();var le=(function(r){function t(){var i=this||self;return delete r.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return t();r.defineProperty(r.prototype,"__magic__",{configurable:!0,get:t});var e=__magic__;return e})(Object),Me=le.URL;le.URLSearchParams;var Ne={URL:Me};class ce extends Error{constructor(e,i,s){super(e);p(this,"status");p(this,"data");this.status=i,this.data=s}}const De=3,je=1e3,Be=[400,401,403,404,409,422],qe=(globalThis==null?void 0:globalThis.URL)??Ne.URL;class Ge{constructor(t,e){p(this,"baseUrl");p(this,"retries");p(this,"retryDelay");p(this,"nonRetryableStatuses");p(this,"identity");p(this,"sleep",t=>new Promise(e=>{setTimeout(e,t)}));p(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);p(this,"rawFetch",(t,e)=>{const i=new qe(t,this.baseUrl),s=(e==null?void 0:e.identity)??this.getIdentity();return Re.signedFetchFactory()(i.toString(),{...e,identity:s})});p(this,"fetch",async(t,e)=>{for(let i=0;i<=this.retries;i++)try{let s,c;try{s=await this.rawFetch(t,e);const l=await s.text();l.length===0?c={ok:!0,data:null}:c=JSON.parse(l)}catch(l){throw new ce(l.message,void 0,null)}if(!s.ok||c.ok===!1){const l=c.message??c.error;throw new ce(l??`Request failed with status code ${s.status}`,s.status,c.data)}return c.ok===!0?c.data:c}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===i||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=t,this.identity=e==null?void 0:e.identity,this.retries=(e==null?void 0:e.retries)??De,this.retryDelay=(e==null?void 0:e.retryDelay)??je,this.nonRetryableStatuses=(e==null?void 0:e.nonRetryableStatuses)??Be}}class Je extends Ge{constructor(e,i,s){super(i,s);p(this,"signer");p(this,"addTrade",async e=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(e),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));p(this,"fetchTrade",async e=>this.fetch(`/v1/trades/${e}`,{method:"GET"}));this.signer=e}}class et{constructor(t,e,i){p(this,"tradesAPI");this.tradesAPI=new Je(t,e,{identity:i,retries:0})}async addTrade(t){return this.tradesAPI.addTrade(t)}async fetchTrade(t){return this.tradesAPI.fetchTrade(t)}async accept(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"accept",[c])}async cancel(t,e){const i=te(t.contract),s=re(i,t.chainId),c=se(t,e);return oe(s,"cancelSignature",[c])}}export{et as TradeService};