@dcl/shop 0.2.1-30916078746.commit-989f656 → 0.2.1-30921445463.commit-34f2a86

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 (180) hide show
  1. package/_assets/{Activity-CQaltjiY.js → Activity-BoIRA50E.js} +2 -2
  2. package/_assets/{AnimatedBackground-DykVDDEL.js → AnimatedBackground-C15oCmrF.js} +1 -1
  3. package/_assets/{Assets-D-OZRxeT.js → Assets-CTcD3v4r.js} +2 -2
  4. package/_assets/{Assets.styles-Cp5E53TW.js → Assets.styles-CmOeJsQS.js} +1 -1
  5. package/_assets/{Authorizations-DYNGMfu5.js → Authorizations-BQ9tQZxy.js} +2 -2
  6. package/_assets/{Cart-vdTvrb1T.js → Cart-B9KtumgS.js} +3 -3
  7. package/_assets/{CircularProgress-CCdQsv8A.js → CircularProgress-Dy63KEvV.js} +1 -1
  8. package/_assets/{Collection-BXT5TK4k.js → Collection-BbuIMAo5.js} +2 -2
  9. package/_assets/{CollectionCarousel-C88U7Rbz.js → CollectionCarousel-cncbnsqo.js} +1 -1
  10. package/_assets/{Creator-umbV4MLL.js → Creator-CrgiLMuo.js} +2 -2
  11. package/_assets/{ErrorNotice-BwAPlZ6y.js → ErrorNotice-XjVFuzN3.js} +1 -1
  12. package/_assets/{ExchangeController-g8wn2fKk.js → ExchangeController-CwaFCJRt.js} +1 -1
  13. package/_assets/{GetCredits-CBSwYuVI.js → GetCredits-uxrMKnug.js} +2 -2
  14. package/_assets/{HelpersUtil-Cpjvvf7m.js → HelpersUtil-o7qKVU1p.js} +1 -1
  15. package/_assets/{ImportListings-BJwxygaC.js → ImportListings-OoXrTNo4.js} +3 -3
  16. package/_assets/{ItemDetail-CvunBWyN.js → ItemDetail-BkccfVeR.js} +7 -7
  17. package/_assets/{ItemPreview.styles-WfFUfSEV.js → ItemPreview.styles-SFSASq-j.js} +1 -1
  18. package/_assets/{LoadMore-Dmv_9BPG.js → LoadMore-tHPMTUfG.js} +1 -1
  19. package/_assets/{ManaPricingBanner.styles-B9a44w0w.js → ManaPricingBanner.styles-BmAo3VRH.js} +1 -1
  20. package/_assets/{MenuList-B6_AtDDA.js → MenuList-Be4N8KEH.js} +1 -1
  21. package/_assets/{MyAssets-ClniNvkB.js → MyAssets-Cw7jURxh.js} +2 -2
  22. package/_assets/{MyFavorites-CLUcEh3u.js → MyFavorites-CbIZvpeo.js} +2 -2
  23. package/_assets/{NotFound-BMKZ9oJq.js → NotFound-CFrP3KQe.js} +3 -3
  24. package/_assets/{NotificationsBell-CnKPRAUE.js → NotificationsBell-Dym5DQDh.js} +1 -1
  25. package/_assets/{OutfitDetail-BZCHdXWK.js → OutfitDetail-D_yHIojF.js} +2 -2
  26. package/_assets/{OutfitPreview-CDPITsPV.js → OutfitPreview-DtMsimLx.js} +1 -1
  27. package/_assets/{OutfitStudio-KoKLjCti.js → OutfitStudio-D7srvgat.js} +2 -2
  28. package/_assets/{StoreSettings-CUyPa9A2.js → StoreSettings-BPLIq1zr.js} +43 -43
  29. package/_assets/{Success-OzJBN4dV.js → Success-C7DebDOe.js} +2 -2
  30. package/_assets/{SwapController-W50LrDpI.js → SwapController-DK7lUJcI.js} +1 -1
  31. package/_assets/{Tooltip-Dtw4IyxU.js → Tooltip-CzKg4cVA.js} +1 -1
  32. package/_assets/{TradeService-BTP6M2Cr.js → TradeService-B-WTOy1k.js} +1 -1
  33. package/_assets/{W3MFrameProviderSingleton-BI_TOfLF.js → W3MFrameProviderSingleton-CDxwqwto.js} +3 -3
  34. package/_assets/{WebCryptoP256-Bm3o4NbU.js → WebCryptoP256-D6tJ5hv2.js} +1 -1
  35. package/_assets/{authorizations-DbQrG6Db.js → authorizations-eWQ5yn7V.js} +1 -1
  36. package/_assets/{basic-DC72Lhzk.js → basic-DC6BsSBx.js} +1 -1
  37. package/_assets/{biconomy-BUC9LDmo.js → biconomy-BycsEdrd.js} +1 -1
  38. package/_assets/{browseLayout.styles-CxS8iNjf.js → browseLayout.styles-BMiUQdzf.js} +1 -1
  39. package/_assets/{builder-CfEOD9tN.js → builder-D1TSWmHR.js} +1 -1
  40. package/_assets/{buy-ncwLOesB.js → buy-BXNscfy0.js} +1 -1
  41. package/_assets/{buy-gasless-D7NJzDMT.js → buy-gasless-C38DcgRt.js} +1 -1
  42. package/_assets/{categories-BmPNPsb3.js → categories-BY0gCzd0.js} +1 -1
  43. package/_assets/{ccip-ORA4oqQC.js → ccip-B7a-t5TU.js} +1 -1
  44. package/_assets/{ccip-km2wYbp6.js → ccip-dmwjYJKN.js} +1 -1
  45. package/_assets/{clsx-HIGn_cGX.js → clsx-DrCITOv7.js} +1 -1
  46. package/_assets/{controller-C0d8rAWe.js → controller-BMF-rmwD.js} +2 -2
  47. package/_assets/{core-5Wp9HrjK.js → core-BfLiLiwP.js} +4 -4
  48. package/_assets/{createSvgIcon-BmHsfCd-.js → createSvgIcon-EC4tp4Zd.js} +1 -1
  49. package/_assets/{custom-BSvJI1CW.js → custom-BRHLD6px.js} +1 -1
  50. package/_assets/{data-capture-11vj00ow.js → data-capture-BUKe8NT8.js} +1 -1
  51. package/_assets/{email-yMdgJov_.js → email-BVAyZzSV.js} +1 -1
  52. package/_assets/{embedded-wallet-f2VuX_Ba.js → embedded-wallet-DVf-le6u.js} +1 -1
  53. package/_assets/{emotion-styled.browser.esm-LdWFzTF_.js → emotion-styled.browser.esm-D0SGxKuN.js} +1 -1
  54. package/_assets/{engine-BISng9P1.js → engine-BNCygbKe.js} +1 -1
  55. package/_assets/{errors-CDxB6Bde.js → errors-BjLe2q2Z.js} +1 -1
  56. package/_assets/{estimate-l1-fee-Dupi50zV.js → estimate-l1-fee-ChRfHvQQ.js} +1 -1
  57. package/_assets/{execute-Sk9grUoC.js → execute-78dEOMTZ.js} +2 -2
  58. package/_assets/{features-CDAzG09c.js → features-Dv_qbkd9.js} +1 -1
  59. package/_assets/{fetchTokenMetadata-BDffXmB-.js → fetchTokenMetadata-CC0iTLYV.js} +2 -2
  60. package/_assets/{field.styles-BqkhGo_h.js → field.styles-9dS3kPdP.js} +1 -1
  61. package/_assets/{get-ecosystem-wallet-info-D4ngQg60.js → get-ecosystem-wallet-info-CWoAJpic.js} +1 -1
  62. package/_assets/{getBalance-B1-dion7.js → getBalance-DyFZ3tET.js} +1 -1
  63. package/_assets/{getNFT-BmKoYqQJ.js → getNFT-DouluRBb.js} +1 -1
  64. package/_assets/{getNFT-BBBlgO1C.js → getNFT-IUGtDAQ-.js} +1 -1
  65. package/_assets/{getThemeProps-jLK1b2Tq.js → getThemeProps-CG1KSSA3.js} +1 -1
  66. package/_assets/{grid.styles-DVxxH3aB.js → grid.styles-BNSMIvVc.js} +1 -1
  67. package/_assets/{hashTypedData-CKuz2aVt.js → hashTypedData-BxzDekGk.js} +1 -1
  68. package/_assets/{hashTypedData-CBiIuCVc.js → hashTypedData-DFJ96qRY.js} +1 -1
  69. package/_assets/{in-app-DcNtj5Xf.js → in-app-D7Rpeg5W.js} +1 -1
  70. package/_assets/{in-app-wallet-calls-U7iYBP7P.js → in-app-wallet-calls-BzVflGxW.js} +1 -1
  71. package/_assets/{index-CAFU7lWi.js → index-2ZeifRk9.js} +1 -1
  72. package/_assets/{index-MJsXL1L_.js → index-3FUScibk.js} +1 -1
  73. package/_assets/{index-CcPSHB7t.js → index-5LcPoGN6.js} +1 -1
  74. package/_assets/{index-Vgun69Mk.js → index-7ZaclCl0.js} +1 -1
  75. package/_assets/{index-C-UihQWz.js → index-91O4BefV.js} +3 -3
  76. package/_assets/{index-Dxrd4kNb.js → index-9QIia5F9.js} +2 -2
  77. package/_assets/{index-BVEcrjSI.js → index-ANWj8Sqw.js} +1 -1
  78. package/_assets/{index-Cs-6860O.js → index-B7-XHIJJ.js} +1 -1
  79. package/_assets/{index-BgHFMsKp.js → index-BBFpvc2W.js} +1 -1
  80. package/_assets/{index-DrJMdewM.js → index-BFae0Yjq.js} +1 -1
  81. package/_assets/{index-Dy-7dgf2.js → index-BG67T4Jr.js} +1 -1
  82. package/_assets/{index-Di2R91qn.js → index-BGXmKK0u.js} +3 -3
  83. package/_assets/{index-U0qUGjk7.js → index-BU_D8iEq.js} +1 -1
  84. package/_assets/{index-CEkldQl_.js → index-BfQRErZJ.js} +1 -1
  85. package/_assets/{index-DA6GN-Db.js → index-Bhh4O98t.js} +1 -1
  86. package/_assets/{index-r2TSIBxl.js → index-BnYCToBA.js} +1 -1
  87. package/_assets/{index-1uEqxM3l.js → index-BsZV2_h1.js} +1 -1
  88. package/_assets/{index-C_Ihlx92.js → index-COWPP-vt.js} +1 -1
  89. package/_assets/{index-d9t-2lof.js → index-CYQLPXuC.js} +1 -1
  90. package/_assets/{index-D_2aPTiB.js → index-CZecYErV.js} +1 -1
  91. package/_assets/{index-ipRgknyO.js → index-CcA88RLC.js} +3 -3
  92. package/_assets/{index-CkyGmZQo.js → index-Ci5P4Jpq.js} +1 -1
  93. package/_assets/{index-DAm4Gv1_.js → index-CkZ1oJLv.js} +1 -1
  94. package/_assets/{index-mU-K9kj3.js → index-Clr488V2.js} +1 -1
  95. package/_assets/{index-DDRf5d3O.js → index-CoUWE1ex.js} +1 -1
  96. package/_assets/{index-BGP6XJ6r.js → index-CsxKfQFv.js} +1 -1
  97. package/_assets/{index-E4Vv2B-y.js → index-CuIApqWy.js} +1 -1
  98. package/_assets/{index-CyRlG-Pt.js → index-Cv4d8yN8.js} +1 -1
  99. package/_assets/{index-Dy9gdJSt.js → index-CwH978UI.js} +1 -1
  100. package/_assets/{index-CEoJjnxL.js → index-DEkfSXQJ.js} +2 -2
  101. package/_assets/{index-f7Sd2SDd.js → index-DFLZPjOE.js} +1 -1
  102. package/_assets/{index-C-r1JIF1.js → index-DJSFekUz.js} +2 -2
  103. package/_assets/{index-8fiSAahQ.js → index-DWR0HS6j.js} +1 -1
  104. package/_assets/index-DePx8ct8.js +3488 -0
  105. package/_assets/{index-6GjaXl23.js → index-DgLPL7-_.js} +1 -1
  106. package/_assets/{index-BB5cWZJ7.js → index-DmyA09la.js} +1 -1
  107. package/_assets/{index-BvsJ1ITB.js → index-DrASBUXQ.js} +1 -1
  108. package/_assets/{index-DKJyAQAA.js → index-Dv3cAufG.js} +1 -1
  109. package/_assets/{index-Boq2MAgc.js → index-DwxaVzC1.js} +1 -1
  110. package/_assets/{index-Dw0feoKt.js → index-JBm75TN4.js} +1 -1
  111. package/_assets/{index-CSayWKDg.js → index-O4jvmpJS.js} +1 -1
  112. package/_assets/{index-DhzsXLVu.js → index-R1IY26o2.js} +1 -1
  113. package/_assets/{index-CgFzmzgX.js → index-US6qdKM8.js} +1 -1
  114. package/_assets/{index-Cj8gk05j.js → index-WHK53yZB.js} +1 -1
  115. package/_assets/{index-DhcnvapZ.js → index-aKYOwr46.js} +1 -1
  116. package/_assets/{index-BB6uvg7H.js → index-hBeS7sb7.js} +1 -1
  117. package/_assets/{index-CZUmrJQF.js → index-jDKI_WJS.js} +1 -1
  118. package/_assets/{index-DaRzHoEw.js → index-jiwr3r22.js} +1 -1
  119. package/_assets/{index-Dsgk5YeS.js → index-snhmPSDV.js} +1 -1
  120. package/_assets/{index-Dpgvm87a.js → index-xTvlnBYc.js} +1 -1
  121. package/_assets/{index-DOxFNsoK.js → index-xUyOtMfo.js} +1 -1
  122. package/_assets/{index.es-DChg2mKP.js → index.es-BUvCCFNu.js} +1 -1
  123. package/_assets/{index.es-BXjppxwS.js → index.es-BXGFuv7Z.js} +4 -4
  124. package/_assets/{index.es-DKsHjh1R.js → index.es-UWIpiePd.js} +1 -1
  125. package/_assets/{localBatchGatewayRequest-7FI2GJ0g.js → localBatchGatewayRequest-ni3FHw_2.js} +1 -1
  126. package/_assets/{mana-convert--3TPFouV.js → mana-convert-BOXCTVoL.js} +1 -1
  127. package/_assets/{mana-rate-Bede0UMr.js → mana-rate-DaU9XU1l.js} +1 -1
  128. package/_assets/{networks-Cflv25kF.js → networks-BwRutolt.js} +1 -1
  129. package/_assets/{onramp-CUAIypvs.js → onramp-fBAOf7fb.js} +1 -1
  130. package/_assets/{openzeppelin-BzYLrAgZ.js → openzeppelin-CtHPNGcM.js} +1 -1
  131. package/_assets/{parseNft-BYWTDAIA.js → parseNft-JZmACcaS.js} +2 -2
  132. package/_assets/{parseSignature-DGzjGvOo.js → parseSignature-mhGIqRDh.js} +1 -1
  133. package/_assets/{parseSignature-BBiGryaG.js → parseSignature-uZKiG-6n.js} +3 -3
  134. package/_assets/{passkeys-CxPHPoqy.js → passkeys-BYVkFpDE.js} +1 -1
  135. package/_assets/{pay-with-exchange-CLrQ1nB8.js → pay-with-exchange-DhADu8jc.js} +1 -1
  136. package/_assets/{qr-overlay-DXd6Ykqa.js → qr-overlay-D7yGrwfO.js} +1 -1
  137. package/_assets/{receive-DkT3Hj18.js → receive-NmR3aYZ7.js} +1 -1
  138. package/_assets/{resolveImplementation-1zhF6aFr.js → resolveImplementation-Dqt8TpOp.js} +1 -1
  139. package/_assets/{rpc-C3tAhXNy.js → rpc-BBFBIpVZ.js} +1 -1
  140. package/_assets/{secp256k1-B7N6bwzz.js → secp256k1-BorK87Ts.js} +1 -1
  141. package/_assets/{secp256k1-BK54m-Gt.js → secp256k1-Cklg-Kvh.js} +1 -1
  142. package/_assets/{secp256k1-Cmukinmx.js → secp256k1-ylzUMPjZ.js} +1 -1
  143. package/_assets/{send-CtVAEXrQ.js → send-D9ktyliO.js} +1 -1
  144. package/_assets/{send-batch-transaction-B1C9OTs3.js → send-batch-transaction-DQpEddV3.js} +1 -1
  145. package/_assets/{send-eip712-transaction-udw-zOvI.js → send-eip712-transaction-D-B24fRE.js} +2 -2
  146. package/_assets/{send-gasless-transaction-BGJmJVoh.js → send-gasless-transaction-yDtpY1O_.js} +2 -2
  147. package/_assets/{send-transaction-DMZ95iWn.js → send-transaction-Ck2VRdWA.js} +2 -2
  148. package/_assets/{sendMetaTransaction-5i0Mv0tj.js → sendMetaTransaction-Bg6BL7gG.js} +1 -1
  149. package/_assets/{sendRawTransaction-DhYnxQWd.js → sendRawTransaction-BNy2bA_s.js} +3 -3
  150. package/_assets/{serializeTransaction-bMhqP7E9.js → serializeTransaction-CsjJZLTm.js} +1 -1
  151. package/_assets/{session-proposal-IA1AKlb1.js → session-proposal-C07lgpdZ.js} +1 -1
  152. package/_assets/{session-request-BkPdWJgm.js → session-request-BHMeTM8a.js} +2 -2
  153. package/_assets/{signing-B4gLkfiP.js → signing-6KlQ42K6.js} +3 -3
  154. package/_assets/{socials-DFJ1w8fR.js → socials-DYLkf3lq.js} +1 -1
  155. package/_assets/{swaps-C61OUWYJ.js → swaps-nrGvbfdS.js} +1 -1
  156. package/_assets/{thirdweb-DOCHhNkG.js → thirdweb-DS3bchL-.js} +3 -3
  157. package/_assets/{to-serializable-transaction-Cf5xKymd.js → to-serializable-transaction-B6hH1Hhs.js} +2 -2
  158. package/_assets/{trade-encoding-DnT4n-4b.js → trade-encoding-DekYVkoi.js} +1 -1
  159. package/_assets/{transactionReceipt-DOYRbTI1.js → transactionReceipt-CF6nODTY.js} +1 -1
  160. package/_assets/{transactions-wR1ibP_x.js → transactions-RKjC2NGt.js} +1 -1
  161. package/_assets/{useCreditPacks-1JCLw1fK.js → useCreditPacks-BAruXyco.js} +1 -1
  162. package/_assets/{useInfiniteGrid-C87CcLUH.js → useInfiniteGrid-CwYY2Fft.js} +1 -1
  163. package/_assets/useManaRate-Du38Lqvm.js +1 -0
  164. package/_assets/{useSecondarySales-pbD8MHXU.js → useSecondarySales-DxgvcGEA.js} +1 -1
  165. package/_assets/{useStore-B52W6lZt.js → useStore-bJteqWYj.js} +1 -1
  166. package/_assets/{useTheme-CPZgbEEt.js → useTheme-D0Jcib3d.js} +1 -1
  167. package/_assets/{verifyHash-D0TBEeBk.js → verifyHash-CjF8jfbB.js} +1 -1
  168. package/_assets/{w3m-modal-inhp6iRR.js → w3m-modal-BqryXzlj.js} +1 -1
  169. package/_assets/{w3m-modal-3ljJOlRA.js → w3m-modal-C_nBjZiQ.js} +1 -1
  170. package/_assets/{wait-for-tx-receipt-BzjeCD4B.js → wait-for-tx-receipt-D2iBHlKW.js} +1 -1
  171. package/_assets/{wallets-Bicov52W.js → wallets-ei4GvBp_.js} +5 -5
  172. package/_assets/{web-connector-BQQbNDWY.js → web-connector-BsGUrTZM.js} +3 -3
  173. package/_assets/{writeContract-DIHVeRVL.js → writeContract-buPjKicP.js} +1 -1
  174. package/_assets/{zoraTestnet-D5VxqDUA.js → zoraTestnet-Dkkyyq4K.js} +1 -1
  175. package/index.html +11 -11
  176. package/package.json +2 -2
  177. package/robots.txt +3 -1
  178. package/sitemap.xml +7 -4
  179. package/_assets/index-CnG2Xd4V.js +0 -3488
  180. package/_assets/useManaRate--yo-xwQf.js +0 -1
@@ -1,4 +1,4 @@
1
- import{L as w,u as ne,j as e,r as p}from"./react-DehiWSvs.js";import{d as P}from"./dcl-schemas-Dr9BTjb7.js";import{s as t,I as y,t as re,A as oe,D as le,E as de,B as j,F as ce,n as D,G as pe,u as he,m as me,e as s,H as F,J as xe,K as ue,L as ge,M as fe,N as be,O as ve,P as ye,Q as je,R as we,S as ke,V as $e,W as Ie,X as Ce,Y as ze,p as z,Z as Le,$ as Ee,a0 as Te,a1 as Se,a2 as Ae,a3 as Ne}from"./index-CnG2Xd4V.js";import{E as H}from"./ErrorNotice-BwAPlZ6y.js";import{O as Pe}from"./OutfitPreview-CDPITsPV.js";import{T as Fe,a as O,b as R,c as W}from"./ItemPreview.styles-WfFUfSEV.js";import"./sentry-973sfbO9.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./disposePreview-DIA1G1eQ.js";const{colors:r,radius:Oe,media:o}=re,V=t.div`
1
+ import{L as w,u as ne,j as e,r as p}from"./react-DehiWSvs.js";import{d as P}from"./dcl-schemas-Dr9BTjb7.js";import{s as t,I as y,t as re,A as oe,D as le,E as de,B as j,F as ce,n as D,G as pe,u as he,m as me,e as s,H as F,J as xe,K as ue,L as ge,M as fe,N as be,O as ve,P as ye,Q as je,R as we,S as ke,V as $e,W as Ie,X as Ce,Y as ze,p as z,Z as Le,$ as Ee,a0 as Te,a1 as Se,a2 as Ae,a3 as Ne}from"./index-DePx8ct8.js";import{E as H}from"./ErrorNotice-XjVFuzN3.js";import{O as Pe}from"./OutfitPreview-DtMsimLx.js";import{T as Fe,a as O,b as R,c as W}from"./ItemPreview.styles-SFSASq-j.js";import"./sentry-973sfbO9.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./disposePreview-DIA1G1eQ.js";const{colors:r,radius:Oe,media:o}=re,V=t.div`
2
2
  max-width: 1721px;
3
3
  margin: 0 auto;
4
4
  `,Re=t.nav`
@@ -354,4 +354,4 @@ import{L as w,u as ne,j as e,r as p}from"./react-DehiWSvs.js";import{d as P}from
354
354
  opacity: 0.4;
355
355
  `,rt=t.h1`
356
356
  font-size: 24px;
357
- `,ot="outfit-detail-preview";function yt(){const{id:i}=ne(),n=D(g=>g.session),d=pe(),u=d==="creator",{data:c,isError:k,refetch:h}=he({queryKey:["outfit",i,u],enabled:F()&&!!i,staleTime:6e4,queryFn:()=>Ne(i,u&&n?n.identity:void 0)}),l=!F()||!i||c===null&&d!=="pending";return me(l?{title:s("seo.outfit.notFoundTitle"),noindex:!0}:c?{title:c.name}:{}),l?e.jsxs(K,{"data-testid":"outfit-notfound",children:[e.jsx(nt,{name:"cart",size:44}),e.jsx(rt,{children:s("outfits.detail.notFoundTitle")}),e.jsx("p",{className:"muted",children:s("outfits.detail.notFoundBody")}),e.jsx(j,{as:w,to:"/assets",variant:"purple",children:s("notFound.cta")})]}):k?e.jsxs(K,{"data-testid":"outfit-detail-error",children:[e.jsx(H,{message:s("outfits.errors.generic")}),e.jsx(j,{variant:"purple",onClick:()=>void h(),children:s("outfits.detail.retry")})]}):c?e.jsx(dt,{outfit:c}):e.jsx(V,{"aria-busy":"true","data-testid":"outfit-detail-loading",children:e.jsxs(q,{children:[e.jsx(G,{children:e.jsx("span",{className:"skeleton",style:{position:"absolute",inset:0},"aria-hidden":!0})}),e.jsxs(U,{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 lt({item:i}){const n=Le(i),d=Ee(i.gender);return e.jsxs(Qe,{children:[i.rarity?e.jsx(v,{"data-variant":"rarity",style:{background:Ae(i.rarity),color:Se(i.rarity)},title:Te(i.rarity),children:i.rarity}):null,i.isSmart?e.jsxs(v,{"data-variant":"smart",children:[e.jsx(y,{name:"smart",size:13}),s("assetCard.smart")]}):null,n?e.jsx(v,{"data-variant":"icon",children:e.jsx(y,{name:n})}):null,d?e.jsx(v,{"data-variant":"icon",children:e.jsx(y,{name:d})}):null]})}function dt({outfit:i}){const n=xe(i),{split:d,availableCount:u,totalCredits:c,addOutfit:k,isAdding:h}=ue(i,n),l=D(a=>{var x;return(x=a.session)==null?void 0:x.address}),g=ge(a=>a.items),E=p.useMemo(()=>new Set(g.map(fe)),[g]),$=be(i.thumbnailHash),[m,T]=p.useState("avatar"),[Y,Q]=p.useState(P.PreviewRenderer.UNITY),J=Y===P.PreviewRenderer.BABYLON&&!!$,S=p.useRef(null);p.useEffect(()=>{S.current!==i.id&&(S.current=i.id,ve("Shop Outfit Viewed",{outfit_id:i.id,item_count:i.items.length}))},[i.id,i.items.length]);const I=p.useMemo(()=>i.items.map(a=>{const x=ye(a),C=n.byKey.get(x)??null;return{key:x,item:C,state:C?je(C,{address:l,cartKeys:E}):"missing"}}),[i,n.byKey,l,E]),{data:X,isFetched:Z}=we(l),ee=!l||Z,A=!!l&&!!X,te=A?l:"default",ie=i.bodyShape==="female"?ke:i.bodyShape==="male"?$e:void 0,N=p.useMemo(()=>I.map(a=>a.item?Ie(a.item):null).filter(a=>!!a),[I]),ae=i.items.length,se=!n.isLoading&&!n.isError,f=d.purchasable.length;return e.jsxs(V,{"data-testid":"outfit-detail",children:[e.jsxs(Re,{"aria-label":s("outfits.detail.breadcrumbAria"),children:[e.jsx(B,{to:"/overview",children:s("nav.overview")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(B,{to:"/overview",children:s("outfits.detail.breadcrumbLooks")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(We,{children:i.name})]}),e.jsxs(q,{children:[e.jsxs(G,{"data-testid":"outfit-detail-preview",style:{background:Ce(i)},children:[$&&(m==="item"||!n.isLoading&&N.length===0)?e.jsx(Be,{src:$,alt:i.name}):e.jsx(Pe,{id:ot,profile:te,bodyShape:A?void 0:ie,urns:N,enabled:ee&&!n.isLoading,onRenderer:Q}),J?e.jsxs(Fe,{"data-preview-toggle":!0,"data-testid":"outfit-detail-toggle",role:"group","aria-label":s("itemPreview.previewMode"),children:[e.jsxs(O,{type:"button","data-active":m==="avatar"||void 0,"aria-pressed":m==="avatar","aria-label":s("itemPreview.onAvatar"),onClick:()=>T("avatar"),children:[e.jsx(R,{name:"view-avatar",size:18}),e.jsx(W,{children:s("itemPreview.onAvatar")})]}),e.jsxs(O,{type:"button","data-active":m==="item"||void 0,"aria-pressed":m==="item","aria-label":s("itemPreview.item"),onClick:()=>T("item"),children:[e.jsx(R,{name:"view-item",size:18}),e.jsx(W,{children:s("itemPreview.item")})]})]}):null]}),e.jsxs(U,{children:[e.jsx(Me,{children:i.name}),e.jsx(_e,{"data-testid":"outfit-detail-meta",children:s("outfits.detail.itemsCount",{count:ae})}),n.isError?e.jsxs(Xe,{children:[e.jsx(H,{message:s("outfits.detail.resolveError"),testId:"outfit-detail-resolve-error"}),e.jsx(j,{variant:"outline","data-testid":"outfit-detail-retry",onClick:n.retry,children:s("outfits.detail.retry")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ke,{children:[e.jsx(De,{children:I.map(a=>e.jsx(He,{"data-testid":"outfit-detail-item","data-state":a.state,children:a.item?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{to:`/item/${a.item.contractAddress}/${a.item.itemId}`,state:{item:a.item},"aria-label":a.item.name}),e.jsx(qe,{src:a.item.thumbnail,alt:"",loading:"lazy"}),e.jsxs(M,{children:[e.jsx(L,{children:a.item.name}),a.item.creator?e.jsx(Ue,{to:`/assets/creator/${a.item.creator}`,children:e.jsx(ze,{address:a.item.creator})}):null,e.jsxs(_,{children:[a.state!=="unavailable"?e.jsxs(Ye,{children:[e.jsx(z,{size:15}),a.item.priceCredits.toLocaleString()]}):null,a.state==="unavailable"?e.jsx(b,{children:s("outfits.card.unavailable")}):a.state==="own_listing"?e.jsx(b,{children:s("outfits.detail.yourListing")}):a.state==="in_cart"?e.jsx(b,{children:s("outfits.detail.inCart")}):null,e.jsx(lt,{item:a.item})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ge,{className:n.isLoading?"skeleton":void 0,"aria-hidden":!0}),e.jsx(M,{children:n.isLoading?e.jsx(L,{children:e.jsx("span",{className:"skeleton",style:{display:"block",width:"70%",height:14}})}):e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"muted",children:s("outfits.card.unavailable")}),e.jsx(_,{children:e.jsx(b,{children:s("outfits.card.unavailable")})})]})})]})},a.key))}),se&&d.ownListing.length>0?e.jsx(Je,{className:"muted small",children:s("outfits.detail.yourListingHint")}):null]}),e.jsxs(Ze,{"data-testid":"outfit-detail-ctabar",children:[e.jsxs(et,{children:[e.jsx(tt,{children:s("outfits.detail.totalPrice")}),n.isLoading?e.jsx("span",{className:"skeleton",style:{width:64,height:26},"aria-hidden":!0}):e.jsxs(it,{children:[e.jsx(z,{size:22}),c.toLocaleString()]})]}),n.isLoading?e.jsx("span",{className:"skeleton",style:{width:"100%",height:52,borderRadius:26},"aria-hidden":!0}):e.jsxs(at,{variant:"purple","data-testid":"outfit-detail-cta",onClick:k,disabled:h||f===0,"aria-busy":h||void 0,children:[h?s("outfits.card.adding"):f>0?s("outfits.detail.addCount",{count:f}):u>0?s("outfits.detail.nothingToAdd"):s("outfits.card.unavailable"),!h&&f>0?e.jsxs(st,{children:[e.jsx(z,{size:16}),c.toLocaleString()]}):null]})]})]})]})]})]})}export{yt as OutfitDetail,yt as default};
357
+ `,ot="outfit-detail-preview";function yt(){const{id:i}=ne(),n=D(g=>g.session),d=pe(),u=d==="creator",{data:c,isError:k,refetch:h}=he({queryKey:["outfit",i,u],enabled:F()&&!!i,staleTime:6e4,queryFn:()=>Ne(i,u&&n?n.identity:void 0)}),l=!F()||!i||c===null&&d!=="pending";return me(l?{title:s("seo.outfit.notFoundTitle"),noindex:!0}:c?{title:c.name}:{}),l?e.jsxs(K,{"data-testid":"outfit-notfound",children:[e.jsx(nt,{name:"cart",size:44}),e.jsx(rt,{children:s("outfits.detail.notFoundTitle")}),e.jsx("p",{className:"muted",children:s("outfits.detail.notFoundBody")}),e.jsx(j,{as:w,to:"/items",variant:"purple",children:s("notFound.cta")})]}):k?e.jsxs(K,{"data-testid":"outfit-detail-error",children:[e.jsx(H,{message:s("outfits.errors.generic")}),e.jsx(j,{variant:"purple",onClick:()=>void h(),children:s("outfits.detail.retry")})]}):c?e.jsx(dt,{outfit:c}):e.jsx(V,{"aria-busy":"true","data-testid":"outfit-detail-loading",children:e.jsxs(q,{children:[e.jsx(G,{children:e.jsx("span",{className:"skeleton",style:{position:"absolute",inset:0},"aria-hidden":!0})}),e.jsxs(U,{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 lt({item:i}){const n=Le(i),d=Ee(i.gender);return e.jsxs(Qe,{children:[i.rarity?e.jsx(v,{"data-variant":"rarity",style:{background:Ae(i.rarity),color:Se(i.rarity)},title:Te(i.rarity),children:i.rarity}):null,i.isSmart?e.jsxs(v,{"data-variant":"smart",children:[e.jsx(y,{name:"smart",size:13}),s("assetCard.smart")]}):null,n?e.jsx(v,{"data-variant":"icon",children:e.jsx(y,{name:n})}):null,d?e.jsx(v,{"data-variant":"icon",children:e.jsx(y,{name:d})}):null]})}function dt({outfit:i}){const n=xe(i),{split:d,availableCount:u,totalCredits:c,addOutfit:k,isAdding:h}=ue(i,n),l=D(a=>{var x;return(x=a.session)==null?void 0:x.address}),g=ge(a=>a.items),E=p.useMemo(()=>new Set(g.map(fe)),[g]),$=be(i.thumbnailHash),[m,T]=p.useState("avatar"),[Y,Q]=p.useState(P.PreviewRenderer.UNITY),J=Y===P.PreviewRenderer.BABYLON&&!!$,S=p.useRef(null);p.useEffect(()=>{S.current!==i.id&&(S.current=i.id,ve("Shop Outfit Viewed",{outfit_id:i.id,item_count:i.items.length}))},[i.id,i.items.length]);const I=p.useMemo(()=>i.items.map(a=>{const x=ye(a),C=n.byKey.get(x)??null;return{key:x,item:C,state:C?je(C,{address:l,cartKeys:E}):"missing"}}),[i,n.byKey,l,E]),{data:X,isFetched:Z}=we(l),ee=!l||Z,A=!!l&&!!X,te=A?l:"default",ie=i.bodyShape==="female"?ke:i.bodyShape==="male"?$e:void 0,N=p.useMemo(()=>I.map(a=>a.item?Ie(a.item):null).filter(a=>!!a),[I]),ae=i.items.length,se=!n.isLoading&&!n.isError,f=d.purchasable.length;return e.jsxs(V,{"data-testid":"outfit-detail",children:[e.jsxs(Re,{"aria-label":s("outfits.detail.breadcrumbAria"),children:[e.jsx(B,{to:"/overview",children:s("nav.overview")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(B,{to:"/overview",children:s("outfits.detail.breadcrumbLooks")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(We,{children:i.name})]}),e.jsxs(q,{children:[e.jsxs(G,{"data-testid":"outfit-detail-preview",style:{background:Ce(i)},children:[$&&(m==="item"||!n.isLoading&&N.length===0)?e.jsx(Be,{src:$,alt:i.name}):e.jsx(Pe,{id:ot,profile:te,bodyShape:A?void 0:ie,urns:N,enabled:ee&&!n.isLoading,onRenderer:Q}),J?e.jsxs(Fe,{"data-preview-toggle":!0,"data-testid":"outfit-detail-toggle",role:"group","aria-label":s("itemPreview.previewMode"),children:[e.jsxs(O,{type:"button","data-active":m==="avatar"||void 0,"aria-pressed":m==="avatar","aria-label":s("itemPreview.onAvatar"),onClick:()=>T("avatar"),children:[e.jsx(R,{name:"view-avatar",size:18}),e.jsx(W,{children:s("itemPreview.onAvatar")})]}),e.jsxs(O,{type:"button","data-active":m==="item"||void 0,"aria-pressed":m==="item","aria-label":s("itemPreview.item"),onClick:()=>T("item"),children:[e.jsx(R,{name:"view-item",size:18}),e.jsx(W,{children:s("itemPreview.item")})]})]}):null]}),e.jsxs(U,{children:[e.jsx(Me,{children:i.name}),e.jsx(_e,{"data-testid":"outfit-detail-meta",children:s("outfits.detail.itemsCount",{count:ae})}),n.isError?e.jsxs(Xe,{children:[e.jsx(H,{message:s("outfits.detail.resolveError"),testId:"outfit-detail-resolve-error"}),e.jsx(j,{variant:"outline","data-testid":"outfit-detail-retry",onClick:n.retry,children:s("outfits.detail.retry")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ke,{children:[e.jsx(De,{children:I.map(a=>e.jsx(He,{"data-testid":"outfit-detail-item","data-state":a.state,children:a.item?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{to:`/item/${a.item.contractAddress}/${a.item.itemId}`,state:{item:a.item},"aria-label":a.item.name}),e.jsx(qe,{src:a.item.thumbnail,alt:"",loading:"lazy"}),e.jsxs(M,{children:[e.jsx(L,{children:a.item.name}),a.item.creator?e.jsx(Ue,{to:`/items/creator/${a.item.creator}`,children:e.jsx(ze,{address:a.item.creator})}):null,e.jsxs(_,{children:[a.state!=="unavailable"?e.jsxs(Ye,{children:[e.jsx(z,{size:15}),a.item.priceCredits.toLocaleString()]}):null,a.state==="unavailable"?e.jsx(b,{children:s("outfits.card.unavailable")}):a.state==="own_listing"?e.jsx(b,{children:s("outfits.detail.yourListing")}):a.state==="in_cart"?e.jsx(b,{children:s("outfits.detail.inCart")}):null,e.jsx(lt,{item:a.item})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ge,{className:n.isLoading?"skeleton":void 0,"aria-hidden":!0}),e.jsx(M,{children:n.isLoading?e.jsx(L,{children:e.jsx("span",{className:"skeleton",style:{display:"block",width:"70%",height:14}})}):e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"muted",children:s("outfits.card.unavailable")}),e.jsx(_,{children:e.jsx(b,{children:s("outfits.card.unavailable")})})]})})]})},a.key))}),se&&d.ownListing.length>0?e.jsx(Je,{className:"muted small",children:s("outfits.detail.yourListingHint")}):null]}),e.jsxs(Ze,{"data-testid":"outfit-detail-ctabar",children:[e.jsxs(et,{children:[e.jsx(tt,{children:s("outfits.detail.totalPrice")}),n.isLoading?e.jsx("span",{className:"skeleton",style:{width:64,height:26},"aria-hidden":!0}):e.jsxs(it,{children:[e.jsx(z,{size:22}),c.toLocaleString()]})]}),n.isLoading?e.jsx("span",{className:"skeleton",style:{width:"100%",height:52,borderRadius:26},"aria-hidden":!0}):e.jsxs(at,{variant:"purple","data-testid":"outfit-detail-cta",onClick:k,disabled:h||f===0,"aria-busy":h||void 0,children:[h?s("outfits.card.adding"):f>0?s("outfits.detail.addCount",{count:f}):u>0?s("outfits.detail.nothingToAdd"):s("outfits.card.unavailable"),!h&&f>0?e.jsxs(st,{children:[e.jsx(z,{size:16}),c.toLocaleString()]}):null]})]})]})]})]})]})}export{yt as OutfitDetail,yt as default};
@@ -1,4 +1,4 @@
1
- import{r as n,j as r}from"./react-DehiWSvs.js";import{d as p}from"./dcl-schemas-Dr9BTjb7.js";import{s as h,L as P,c as R,a4 as b,e as A}from"./index-CnG2Xd4V.js";import{u as O,d as F}from"./disposePreview-DIA1G1eQ.js";const I=h.div`
1
+ import{r as n,j as r}from"./react-DehiWSvs.js";import{d as p}from"./dcl-schemas-Dr9BTjb7.js";import{s as h,L as P,c as R,a4 as b,e as A}from"./index-DePx8ct8.js";import{u as O,d as F}from"./disposePreview-DIA1G1eQ.js";const I=h.div`
2
2
  position: absolute;
3
3
  inset: 0;
4
4
  display: grid;
@@ -1,4 +1,4 @@
1
- import{r as u,j as t,L as O,u as qt,b as Gt,d as Wt}from"./react-DehiWSvs.js";import{s as o,t as st,I as U,aq as Qt,e,p as Y,B as m,a9 as vt,n as G,G as Vt,m as Jt,q as wt,u as $t,J as Xt,P as B,ar as K,as as q,W as Yt,S as Zt,V as te,N as St,X as ee,at as Z,au as ie,av as se,aw as oe,w as F,ax as kt,ay as Tt,az as R,l as tt,aA as et,aB as ae,aC as ne,aD as re,O as de,aE as le,aF as ue,a3 as ce}from"./index-CnG2Xd4V.js";import{E as D}from"./ErrorNotice-BwAPlZ6y.js";import{L as pe}from"./LoadMore-Dmv_9BPG.js";import{u as fe}from"./useInfiniteGrid-C87CcLUH.js";import{O as he}from"./OutfitPreview-CDPITsPV.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:me}=st,xe=o.div`
1
+ import{r as u,j as t,L as O,u as qt,b as Gt,d as Wt}from"./react-DehiWSvs.js";import{s as o,t as st,I as U,aq as Qt,e,p as Y,B as m,a9 as vt,n as G,G as Vt,m as Jt,q as wt,u as $t,J as Xt,P as B,ar as K,as as q,W as Yt,S as Zt,V as te,N as St,X as ee,at as Z,au as ie,av as se,aw as oe,w as F,ax as kt,ay as Tt,az as R,l as tt,aA as et,aB as ae,aC as ne,aD as re,O as de,aE as le,aF as ue,a3 as ce}from"./index-DePx8ct8.js";import{E as D}from"./ErrorNotice-XjVFuzN3.js";import{L as pe}from"./LoadMore-tHPMTUfG.js";import{u as fe}from"./useInfiniteGrid-CwYY2Fft.js";import{O as he}from"./OutfitPreview-DtMsimLx.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:me}=st,xe=o.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: 12px;
@@ -497,4 +497,4 @@ import{r as u,j as t,L as O,u as qt,b as Gt,d as Wt}from"./react-DehiWSvs.js";im
497
497
  display: flex;
498
498
  flex-wrap: wrap;
499
499
  gap: 10px;
500
- `;function Li(){const{id:r}=qt(),{pathname:h}=Gt(),f=G(b=>b.session),p=G(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(mi,{}):t.jsx(bi,{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 hi({outfit:r}){const h=St(r.thumbnailHash);return h?t.jsx(Ie,{style:{background:se(r)},children:t.jsx("img",{src:h,alt:"",loading:"lazy"})}):t.jsx(Le,{"aria-hidden":!0})}function mi(){const r=G(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:()=>ue(r.identity)});async function T(l,C){if(r){j(l.id);try{C==="delete"?(await oe(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(E){E instanceof R||tt(E,{flow:`outfit-${C}`}),F.error(e(E instanceof R?et(E.code):"outfits.errors.generic"))}finally{j(null),p(null)}}}return t.jsxs(Ct,{"data-testid":"outfit-studio-list",children:[t.jsxs(Et,{children:[t.jsx(It,{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(Ce,{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(hi,{outfit:l}),t.jsxs(Ne,{children:[t.jsx(ze,{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(Re,{children:[l.published?t.jsx(m,{as:O,to:`/assets/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(Oe,{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(Fe,{role:"dialog","aria-modal":"true","aria-label":e("outfits.studio.deleteTitle"),"data-testid":"outfit-studio-confirm",children:[t.jsx(Ae,{onClick:()=>p(null)}),t.jsxs(Be,{children:[t.jsx(De,{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 xi(){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 gi(r){try{const h=sessionStorage.getItem(r);return h?JSON.parse(h):null}catch{return null}}function bi({outfitId:r}){const h=r===null,f=`outfit-draft:${r??"new"}`,p=G(i=>i.session),g=wt(),j=Wt(),[b]=u.useState(()=>gi(f)),[s,k]=u.useState(()=>b??(h?xi():null)),[w,T]=u.useState(!!b),{data:l,isLoading:C,isError:E,refetch:H}=$t({queryKey:["outfit",r,!0],enabled:!h&&!!p,staleTime:0,queryFn:()=>ce(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]),P=i=>le((s==null?void 0:s.items)??[],i,d.byKey),at=i=>!!i.itemId&&P(i).length<=q;function Pt(i){!s||!at(i)||y({items:P(i)})}const[Rt,nt]=u.useState(null),I=u.useRef(null),Q=u.useRef(!0);u.useEffect(()=>(Q.current=!0,()=>{Q.current=!1}),[]);const[M,rt]=u.useState(!1),[Ot,_]=u.useState(null),[V,dt]=u.useState(""),[Ft,lt]=u.useState(null),[S,At]=u.useState();u.useEffect(()=>()=>{I.current&&URL.revokeObjectURL(I.current)},[]);function ut(){const i=re(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>ae){_(e("outfits.errors.tooLarge"));return}I.current&&URL.revokeObjectURL(I.current);const n=URL.createObjectURL(i);I.current=n,nt(n),rt(!0);try{const c=await ne(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")),I.current&&(URL.revokeObjectURL(I.current),I.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>=2&&s.items.length<=q;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?(de("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?Yt(i):null).filter(i=>!!i),[s,d.byKey]),Ht=(s==null?void 0:s.bodyShape)==="female"?Zt:(s==null?void 0:s.bodyShape)==="male"?te:void 0;if(!p)return null;if(!s)return E?t.jsxs(z,{children:[t.jsx(D,{message:e("outfits.errors.generic")}),t.jsx(m,{variant:"purple",onClick:()=>void H(),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??St(s.thumbnailHash),Mt={...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(Et,{children:[t.jsx(Te,{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(It,{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(Me,{children:[t.jsxs(Ke,{"data-testid":"outfit-studio-preview",style:{background:ee(s)},children:[t.jsx(he,{id:"outfit-studio-preview-frame",profile:"default",bodyShape:Ht,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(Ge,{role:"group","aria-label":e("outfits.studio.bodyShape"),children:["unisex","male","female"].map(i=>t.jsx(We,{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(Je,{children:[t.jsx(Xe,{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(Ye,{children:[t.jsx("span",{children:e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom")}),t.jsx(Ze,{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(Qe,{"data-busy":M||void 0,children:t.jsx("img",{src:mt,alt:""})}):null,t.jsxs(ei,{as:"label",variant:"outline",size:"sm","data-busy":M||void 0,children:[M?e("outfits.studio.uploading"):e("outfits.studio.upload"),t.jsx("input",{type:"file",accept:jt.join(","),hidden:!0,disabled:M,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(ti,{"data-testid":"outfit-studio-card-preview",onClickCapture:i=>{i.preventDefault(),i.stopPropagation()},children:t.jsx(ie,{outfit:Mt,resolution:d})})]})]}),t.jsxs(_e,{children:[t.jsxs(L,{children:[t.jsx(N,{htmlFor:"outfit-import",children:e("outfits.studio.import")}),t.jsxs(ii,{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,"/",q,")"]}),s.items.length===0?t.jsx("p",{className:"muted small",children:e("outfits.studio.noItems")}):t.jsx(si,{children:s.items.map(i=>{const n=B(i),c=d.byKey.get(n);return t.jsxs(oi,{"data-testid":"outfit-studio-selected","data-missing":!c||void 0,children:[c?t.jsx(ai,{src:c.thumbnail,alt:""}):t.jsx(ni,{className:d.isLoading?"skeleton":void 0,"aria-hidden":!0}),t.jsx(ri,{className:c?void 0:"muted",children:c?c.name:d.isLoading?"…":e("outfits.card.unavailable")}),c?t.jsxs(di,{children:[t.jsx(Y,{size:12}),c.priceCredits.toLocaleString()]}):null,t.jsx(ci,{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(li,{"data-testid":"outfit-studio-total",children:[t.jsx("span",{children:e("outfits.detail.totalPrice")}),t.jsxs(ui,{children:[t.jsx(Y,{size:14}),_t.toLocaleString()]})]}):null,s.items.length>=q?t.jsx("p",{className:"muted small",children:e("outfits.studio.maxItems")}):null]}),t.jsx(Se,{selectedKeys:$,onPick:Pt,canPick:at})]})]}),t.jsxs(pi,{"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(fi,{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{Li as OutfitStudio,Li as default};
500
+ `;function Li(){const{id:r}=qt(),{pathname:h}=Gt(),f=G(b=>b.session),p=G(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(mi,{}):t.jsx(bi,{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 hi({outfit:r}){const h=St(r.thumbnailHash);return h?t.jsx(Ie,{style:{background:se(r)},children:t.jsx("img",{src:h,alt:"",loading:"lazy"})}):t.jsx(Le,{"aria-hidden":!0})}function mi(){const r=G(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:()=>ue(r.identity)});async function T(l,C){if(r){j(l.id);try{C==="delete"?(await oe(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(E){E instanceof R||tt(E,{flow:`outfit-${C}`}),F.error(e(E instanceof R?et(E.code):"outfits.errors.generic"))}finally{j(null),p(null)}}}return t.jsxs(Ct,{"data-testid":"outfit-studio-list",children:[t.jsxs(Et,{children:[t.jsx(It,{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(Ce,{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(hi,{outfit:l}),t.jsxs(Ne,{children:[t.jsx(ze,{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(Re,{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(Oe,{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(Fe,{role:"dialog","aria-modal":"true","aria-label":e("outfits.studio.deleteTitle"),"data-testid":"outfit-studio-confirm",children:[t.jsx(Ae,{onClick:()=>p(null)}),t.jsxs(Be,{children:[t.jsx(De,{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 xi(){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 gi(r){try{const h=sessionStorage.getItem(r);return h?JSON.parse(h):null}catch{return null}}function bi({outfitId:r}){const h=r===null,f=`outfit-draft:${r??"new"}`,p=G(i=>i.session),g=wt(),j=Wt(),[b]=u.useState(()=>gi(f)),[s,k]=u.useState(()=>b??(h?xi():null)),[w,T]=u.useState(!!b),{data:l,isLoading:C,isError:E,refetch:H}=$t({queryKey:["outfit",r,!0],enabled:!h&&!!p,staleTime:0,queryFn:()=>ce(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]),P=i=>le((s==null?void 0:s.items)??[],i,d.byKey),at=i=>!!i.itemId&&P(i).length<=q;function Pt(i){!s||!at(i)||y({items:P(i)})}const[Rt,nt]=u.useState(null),I=u.useRef(null),Q=u.useRef(!0);u.useEffect(()=>(Q.current=!0,()=>{Q.current=!1}),[]);const[M,rt]=u.useState(!1),[Ot,_]=u.useState(null),[V,dt]=u.useState(""),[Ft,lt]=u.useState(null),[S,At]=u.useState();u.useEffect(()=>()=>{I.current&&URL.revokeObjectURL(I.current)},[]);function ut(){const i=re(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>ae){_(e("outfits.errors.tooLarge"));return}I.current&&URL.revokeObjectURL(I.current);const n=URL.createObjectURL(i);I.current=n,nt(n),rt(!0);try{const c=await ne(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")),I.current&&(URL.revokeObjectURL(I.current),I.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>=2&&s.items.length<=q;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?(de("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?Yt(i):null).filter(i=>!!i),[s,d.byKey]),Ht=(s==null?void 0:s.bodyShape)==="female"?Zt:(s==null?void 0:s.bodyShape)==="male"?te:void 0;if(!p)return null;if(!s)return E?t.jsxs(z,{children:[t.jsx(D,{message:e("outfits.errors.generic")}),t.jsx(m,{variant:"purple",onClick:()=>void H(),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??St(s.thumbnailHash),Mt={...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(Et,{children:[t.jsx(Te,{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(It,{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(Me,{children:[t.jsxs(Ke,{"data-testid":"outfit-studio-preview",style:{background:ee(s)},children:[t.jsx(he,{id:"outfit-studio-preview-frame",profile:"default",bodyShape:Ht,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(Ge,{role:"group","aria-label":e("outfits.studio.bodyShape"),children:["unisex","male","female"].map(i=>t.jsx(We,{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(Je,{children:[t.jsx(Xe,{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(Ye,{children:[t.jsx("span",{children:e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom")}),t.jsx(Ze,{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(Qe,{"data-busy":M||void 0,children:t.jsx("img",{src:mt,alt:""})}):null,t.jsxs(ei,{as:"label",variant:"outline",size:"sm","data-busy":M||void 0,children:[M?e("outfits.studio.uploading"):e("outfits.studio.upload"),t.jsx("input",{type:"file",accept:jt.join(","),hidden:!0,disabled:M,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(ti,{"data-testid":"outfit-studio-card-preview",onClickCapture:i=>{i.preventDefault(),i.stopPropagation()},children:t.jsx(ie,{outfit:Mt,resolution:d})})]})]}),t.jsxs(_e,{children:[t.jsxs(L,{children:[t.jsx(N,{htmlFor:"outfit-import",children:e("outfits.studio.import")}),t.jsxs(ii,{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,"/",q,")"]}),s.items.length===0?t.jsx("p",{className:"muted small",children:e("outfits.studio.noItems")}):t.jsx(si,{children:s.items.map(i=>{const n=B(i),c=d.byKey.get(n);return t.jsxs(oi,{"data-testid":"outfit-studio-selected","data-missing":!c||void 0,children:[c?t.jsx(ai,{src:c.thumbnail,alt:""}):t.jsx(ni,{className:d.isLoading?"skeleton":void 0,"aria-hidden":!0}),t.jsx(ri,{className:c?void 0:"muted",children:c?c.name:d.isLoading?"…":e("outfits.card.unavailable")}),c?t.jsxs(di,{children:[t.jsx(Y,{size:12}),c.priceCredits.toLocaleString()]}):null,t.jsx(ci,{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(li,{"data-testid":"outfit-studio-total",children:[t.jsx("span",{children:e("outfits.detail.totalPrice")}),t.jsxs(ui,{children:[t.jsx(Y,{size:14}),_t.toLocaleString()]})]}):null,s.items.length>=q?t.jsx("p",{className:"muted small",children:e("outfits.studio.maxItems")}):null]}),t.jsx(Se,{selectedKeys:$,onPick:Pt,canPick:at})]})]}),t.jsxs(pi,{"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(fi,{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{Li as OutfitStudio,Li as default};
@@ -1,8 +1,8 @@
1
- import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{e as s,t as j,s as n,k as ce,B as q,m as de,n as pe,q as ue,I as z,w as F}from"./index-CnG2Xd4V.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-B52W6lZt.js";import{E as M}from"./ErrorNotice-BwAPlZ6y.js";import{F as w}from"./field.styles-BqkhGo_h.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.2.1-30916078746.commit-989f656/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/0.2.1-30916078746.commit-989f656/_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{e as s,t as j,s as a,k as ce,B as q,m as de,n as pe,q as ue,I as z,w as F}from"./index-DePx8ct8.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-bJteqWYj.js";import{E as M}from"./ErrorNotice-XjVFuzN3.js";import{F as w}from"./field.styles-9dS3kPdP.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.2.1-30921445463.commit-34f2a86/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/0.2.1-30921445463.commit-34f2a86/_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`
2
2
  to {
3
3
  transform: rotate(360deg);
4
4
  }
5
- `,Se=n.div`
5
+ `,Se=a.div`
6
6
  display: flex;
7
7
  align-items: center;
8
8
  justify-content: center;
@@ -16,7 +16,7 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{e as s,t a
16
16
  flex-direction: column;
17
17
  text-align: center;
18
18
  }
19
- `,ke=n.span`
19
+ `,ke=a.span`
20
20
  flex: none;
21
21
  border-radius: 50%;
22
22
  border-style: solid;
@@ -43,18 +43,18 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{e as s,t a
43
43
  @media (prefers-reduced-motion: reduce) {
44
44
  animation-duration: 2s;
45
45
  }
46
- `,$e=n.span`
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:a,radius:_e,media:G}=j,Ee=n(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}=j,Ee=a(ye)`
50
50
  display: grid;
51
51
  place-items: center;
52
52
  min-height: 60vh;
53
- `,Ne=n(q)`
53
+ `,Ne=a(q)`
54
54
  align-self: center;
55
55
  min-width: 200px;
56
56
  margin-top: 8px;
57
- `,O=n.section`
57
+ `,O=a.section`
58
58
  max-width: 640px;
59
59
  margin: 0 auto;
60
60
  padding: 8px 0 48px;
@@ -72,50 +72,50 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{e as s,t a
72
72
 
73
73
  & .field__label {
74
74
  font-weight: 700;
75
- color: ${a.text};
75
+ color: ${n.text};
76
76
  }
77
77
  & textarea {
78
- background: ${a.white};
79
- border: 1px solid ${a.lineStrong};
78
+ background: ${n.white};
79
+ border: 1px solid ${n.lineStrong};
80
80
  border-radius: 8px;
81
81
  padding: 10px 12px;
82
- color: ${a.text};
82
+ color: ${n.text};
83
83
  font: inherit;
84
84
  resize: vertical;
85
85
  min-height: 88px;
86
86
  }
87
- `,ze=n.div`
87
+ `,ze=a.div`
88
88
  display: flex;
89
89
  align-items: baseline;
90
90
  justify-content: space-between;
91
91
  gap: 16px;
92
92
  flex-wrap: wrap;
93
- `,Le=n.div`
93
+ `,Le=a.div`
94
94
  display: flex;
95
95
  align-items: center;
96
96
  gap: 10px;
97
- `,Ce=n(oe)`
97
+ `,Ce=a(oe)`
98
98
  display: flex;
99
99
  align-items: center;
100
100
  justify-content: center;
101
- color: ${a.text};
101
+ color: ${n.text};
102
102
  transition: color 0.15s linear;
103
103
 
104
104
  &:hover {
105
- color: ${a.accent};
105
+ color: ${n.accent};
106
106
  }
107
107
  & .ico {
108
108
  width: 22px;
109
109
  height: 22px;
110
110
  }
111
- `,D=n.h1`
111
+ `,D=a.h1`
112
112
  font-size: 24px;
113
113
  font-weight: 800;
114
- `,He=n.a`
114
+ `,He=a.a`
115
115
  display: inline-flex;
116
116
  align-items: center;
117
117
  gap: 6px;
118
- color: ${a.accent};
118
+ color: ${n.accent};
119
119
  font-weight: 700;
120
120
  font-size: 14px;
121
121
  text-decoration: none;
@@ -127,13 +127,13 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{e as s,t a
127
127
  width: 15px;
128
128
  height: 15px;
129
129
  }
130
- `,Ie=n.div`
130
+ `,Ie=a.div`
131
131
  display: flex;
132
132
  align-items: stretch;
133
- border: 1px solid ${a.lineStrong};
133
+ border: 1px solid ${n.lineStrong};
134
134
  border-radius: 8px;
135
135
  overflow: hidden;
136
- background: ${a.white};
136
+ background: ${n.white};
137
137
 
138
138
  & input {
139
139
  border: 0 !important;
@@ -141,16 +141,16 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{e as s,t a
141
141
  flex: 1;
142
142
  min-width: 0;
143
143
  }
144
- `,Te=n.span`
144
+ `,Te=a.span`
145
145
  display: flex;
146
146
  align-items: center;
147
147
  padding: 0 10px;
148
148
  background: rgba(0, 0, 0, 0.04);
149
- color: ${a.muted};
149
+ color: ${n.muted};
150
150
  font-size: 13px;
151
151
  white-space: nowrap;
152
- border-right: 1px solid ${a.lineStrong};
153
- `,Be=n.div`
152
+ border-right: 1px solid ${n.lineStrong};
153
+ `,Be=a.div`
154
154
  display: grid;
155
155
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
156
156
  gap: 12px;
@@ -158,14 +158,14 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{e as s,t a
158
158
  ${G.maxWidth("mobile")} {
159
159
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
160
160
  }
161
- `,L=n.button`
161
+ `,L=a.button`
162
162
  position: relative;
163
163
  padding: 0;
164
- border: 2px solid ${a.lineStrong};
164
+ border: 2px solid ${n.lineStrong};
165
165
  border-radius: ${_e.card};
166
166
  overflow: hidden;
167
167
  aspect-ratio: 16 / 9;
168
- background: ${a.media};
168
+ background: ${n.media};
169
169
  cursor: pointer;
170
170
 
171
171
  & img {
@@ -176,8 +176,8 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{e as s,t a
176
176
  }
177
177
 
178
178
  &[data-selected='true'] {
179
- border-color: ${a.accent};
180
- box-shadow: 0 0 0 2px ${a.accent};
179
+ border-color: ${n.accent};
180
+ box-shadow: 0 0 0 2px ${n.accent};
181
181
  }
182
182
  &[data-selected='true']::after {
183
183
  content: '✓';
@@ -189,8 +189,8 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{e as s,t a
189
189
  display: grid;
190
190
  place-items: center;
191
191
  border-radius: 50%;
192
- background: ${a.accent};
193
- color: ${a.white};
192
+ background: ${n.accent};
193
+ color: ${n.white};
194
194
  font-size: 13px;
195
195
  font-weight: 700;
196
196
  }
@@ -202,38 +202,38 @@ import{j as t,L as oe,d as le,r as l}from"./react-DehiWSvs.js";import{e as s,t a
202
202
  justify-content: center;
203
203
  gap: 6px;
204
204
  border-style: dashed;
205
- color: ${a.muted};
205
+ color: ${n.muted};
206
206
  font-size: 13px;
207
207
  font-weight: 700;
208
- background: ${a.white};
208
+ background: ${n.white};
209
209
  }
210
210
  &[data-variant='upload'] .ico {
211
211
  width: 22px;
212
212
  height: 22px;
213
- background: ${a.muted};
213
+ background: ${n.muted};
214
214
  }
215
215
  &[data-variant='upload']:hover {
216
- border-color: ${a.accent};
217
- color: ${a.accent};
216
+ border-color: ${n.accent};
217
+ color: ${n.accent};
218
218
  }
219
219
  &[data-variant='upload']:hover .ico {
220
- background: ${a.accent};
220
+ background: ${n.accent};
221
221
  }
222
- `,Pe=n.input`
222
+ `,Pe=a.input`
223
223
  position: absolute;
224
224
  width: 1px;
225
225
  height: 1px;
226
226
  opacity: 0;
227
227
  pointer-events: none;
228
- `,Re=n.div`
228
+ `,Re=a.div`
229
229
  display: flex;
230
230
  justify-content: flex-end;
231
231
  gap: 12px;
232
232
  margin-top: 8px;
233
- `,Fe=n(q)`
233
+ `,Fe=a(q)`
234
234
  min-width: 180px;
235
235
 
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 ae(e){const i=o.links[e];return e==="website"?i:i.replace(f[e],"")}async function ne(){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(`/assets/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:`/assets/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:`/assets/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:ae(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 ne(),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,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};
@@ -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,e as n,o as U,f as V,ao as H,c as B,B as J,ap as X}from"./index-CnG2Xd4V.js";import{w as G,S as K}from"./buy-gasless-D7NJzDMT.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./authorizations-DbQrG6Db.js";import"./sendMetaTransaction-5i0Mv0tj.js";import"./trade-encoding-DnT4n-4b.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,p as _,an as O,a9 as W,n as D,m as q,e as n,o as U,f as V,ao as H,c as B,B as J,ap as X}from"./index-DePx8ct8.js";import{w as G,S as K}from"./buy-gasless-C38DcgRt.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./authorizations-eWQ5yn7V.js";import"./sendMetaTransaction-Bg6BL7gG.js";import"./trade-encoding-DekYVkoi.js";const Q=t.div`
3
3
  position: fixed;
4
4
  inset: 0;
5
5
  /**
@@ -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,b=(i==null?void 0:i.items)??[],f=i!=null&&i.creditsAdded&&i.creditsAdded>0?i.creditsAdded:null,o=b[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=b;if(h.length===0)return e.jsx(M,{to:"/assets",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(y,{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(y,{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("/assets"),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(y,{children:p}):null,e.jsx(T,{children:e.jsx(R,{variant:"purple",onClick:()=>a("/assets"),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(ye,{children:n("cartCheckout.qty",{count:$})}):null]}),d.creator?e.jsx(be,{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(y,{"data-receipt":!0,children:p}):null,e.jsxs($e,{children:[e.jsx(Ce,{"data-variant":"ghost",onClick:()=>a("/my-assets"),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(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,b=(i==null?void 0:i.items)??[],f=i!=null&&i.creditsAdded&&i.creditsAdded>0?i.creditsAdded:null,o=b[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=b;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(y,{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(y,{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(y,{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(ye,{children:n("cartCheckout.qty",{count:$})}):null]}),d.creator?e.jsx(be,{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(y,{"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};
@@ -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-BI_TOfLF.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-CDxwqwto.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-CnG2Xd4V.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-DePx8ct8.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{bT as be,b as te,a as re}from"./index-CnG2Xd4V.js";import{c as q,e as Re}from"./index-Dxrd4kNb.js";import{s as Ie}from"./sendMetaTransaction-5i0Mv0tj.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 Re.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),R=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(R.populateTransaction):R.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,R=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 $(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function V(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=$(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 $(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,b,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(b=w>0?w+1:0;b<o;){for(I=d,f=1,m=T;b>=o&&F("invalid-input"),g=Te(n.charCodeAt(b++)),(g>=T||g>E((R-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(R/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-I,u,I==0),E(d/u)>R-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,b,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=R,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((R-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>R&&F("overflow"),f==a){for(x=o,b=T;I=b<=y?v:b>=y+P?P:b-y,!(x<I);b+=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 V(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function me(n){return V(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 be.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{bT as be,b as te,a as re}from"./index-DePx8ct8.js";import{c as q,e as Re}from"./index-9QIia5F9.js";import{s as Ie}from"./sendMetaTransaction-Bg6BL7gG.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 Re.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),R=new ge(t.address,t.abi,l),T=await(typeof e=="function"?e(R.populateTransaction):R.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,R=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 $(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function V(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=$(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 $(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,b,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(b=w>0?w+1:0;b<o;){for(I=d,f=1,m=T;b>=o&&F("invalid-input"),g=Te(n.charCodeAt(b++)),(g>=T||g>E((R-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(R/L)&&F("overflow"),f*=L;u=a.length+1,h=Z(d-I,u,I==0),E(d/u)>R-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,b,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=R,h=0;h<g;++h)f=n[h],f>=a&&f<w&&(w=f);for(A=u+1,w-a>E((R-o)/A)&&F("overflow"),o+=(w-a)*A,a=w,h=0;h<g;++h)if(f=n[h],f<a&&++o>R&&F("overflow"),f==a){for(x=o,b=T;I=b<=y?v:b>=y+P?P:b-y,!(x<I);b+=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 V(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function me(n){return V(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 be.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};