@abtnode/blocklet-services 1.17.8-beta-20260121-102603-f9d0176f → 1.17.8-beta-20260125-093329-64b43854

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 (247) hide show
  1. package/api/index.js +5 -0
  2. package/api/libs/connect/session.js +33 -39
  3. package/api/middlewares/launcher-login.js +1 -2
  4. package/api/routes/federated.js +1 -2
  5. package/api/routes/oauth/server.js +1 -2
  6. package/api/routes/user-session.js +0 -2
  7. package/api/routes/user.js +61 -41
  8. package/api/services/auth/connect/destroy-self.js +0 -2
  9. package/api/services/auth/connect/invite.js +0 -2
  10. package/api/services/auth/connect/issue-passport.js +0 -2
  11. package/api/services/auth/connect/receive-transfer-app-owner.js +0 -2
  12. package/api/services/auth/connect/verify-destroy.js +0 -2
  13. package/api/services/auth/connect/verify-elevated.js +0 -2
  14. package/api/services/auth/session.js +1 -36
  15. package/api/util/user-util.js +1 -2
  16. package/dist/assets/{AdapterDayjs-QqQc9YbA.js → AdapterDayjs-B5owpIH3.js} +1 -1
  17. package/dist/assets/{Google-PffSpBc2.js → Google-efeywUOs.js} +1 -1
  18. package/dist/assets/{access-control-B6JglGtO.js → access-control-BzsCJj-F.js} +1 -1
  19. package/dist/assets/{actions-DydkTgA0.js → actions-DbuL4r3Z.js} +1 -1
  20. package/dist/assets/{actions-Do5Z9cxZ.js → actions-Dm98-Dap.js} +2 -2
  21. package/dist/assets/{add-component-core-CLOpD7CB.js → add-component-core-BKVGCdxY.js} +7 -7
  22. package/dist/assets/add-resource-Cxa0mbrd.js +1 -0
  23. package/dist/assets/{addon-CrVdMlFe.js → addon-B1KwZDQ5.js} +1 -1
  24. package/dist/assets/advanced-B62UUhxe.js +14 -0
  25. package/dist/assets/{aigne-CeD5Xo7t.js → aigne-jjaGOQQ7.js} +1 -1
  26. package/dist/assets/{appearance-BJuIABu8.js → appearance-_ZB7EroL.js} +1 -1
  27. package/dist/assets/{ar-xXK-6slW.js → ar-BJmSv7rn.js} +1 -1
  28. package/dist/assets/{audit-logs-DxVzMUJK.js → audit-logs-DF2wcdWX.js} +2 -2
  29. package/dist/assets/{authorize-BxQgoA5F.js → authorize-C6nOsMWm.js} +1 -1
  30. package/dist/assets/{base-chart-CQOyckBN.js → base-chart-D_u2nVGm.js} +1 -1
  31. package/dist/assets/{base32-CyUpiYTu.js → base32-D79Y2AcQ.js} +1 -1
  32. package/dist/assets/{bind-account-D5gBazop.js → bind-account-BIj9FA7d.js} +1 -1
  33. package/dist/assets/{branding-CDPvtKJm.js → branding-BEGHWROe.js} +1 -1
  34. package/dist/assets/{branding-CtbvPvdK.js → branding-C86_64it.js} +1 -1
  35. package/dist/assets/branding-Dqv4_zpD.js +1 -0
  36. package/dist/assets/{bundle-avatar-2ugE80w1.js → bundle-avatar-Cy8tSSSQ.js} +1 -1
  37. package/dist/assets/button-DMYwcDVh.js +1 -0
  38. package/dist/assets/{click-to-copy-CgakrWoh.js → click-to-copy-BCjXD9Nd.js} +1 -1
  39. package/dist/assets/{collapse-RMuUWnK3.js → collapse-CBrasNzu.js} +1 -1
  40. package/dist/assets/{complete-B_lyTPVv.js → complete-CCe1VfI6.js} +1 -1
  41. package/dist/assets/{component-pjnMydek.js → component-DLlaIYmq.js} +2 -2
  42. package/dist/assets/{config-CyDF6KG9.js → config-BccEmD3I.js} +2 -2
  43. package/dist/assets/{config-BcCR6bUQ.js → config-C0CmuuRP.js} +1 -1
  44. package/dist/assets/{config-BsWCoWa6.js → config-CsQBU86s.js} +1 -1
  45. package/dist/assets/{config-navigation-B36NPLt0.js → config-navigation-D46rq0IX.js} +2 -2
  46. package/dist/assets/{config-space-DUkjNtdL.js → config-space-DLjHQVCq.js} +1 -1
  47. package/dist/assets/{confirm-CoDiNrSj.js → confirm-ClxC2cDv.js} +1 -1
  48. package/dist/assets/{connect-ULEL84iL.js → connect-9CgvkPOq.js} +1 -1
  49. package/dist/assets/{connect-SOuN9k8I.js → connect-C1q4hvQ3.js} +1 -1
  50. package/dist/assets/connect-DXjJ46DL.js +5 -0
  51. package/dist/assets/{connect-to-DnBUF-KE.js → connect-to-CbgQNAwh.js} +1 -1
  52. package/dist/assets/{content-layout-Dlmn5DW6.js → content-layout-BH_g_OCf.js} +1 -1
  53. package/dist/assets/{create-passport-svg-BSRyjG0k.js → create-passport-svg-Ct68e5tm.js} +1 -1
  54. package/dist/assets/{createClass-DKvdNmc_.js → createClass-CeMEAEuP.js} +1 -1
  55. package/dist/assets/{dashboard-CkDdshHQ.js → dashboard-y1fk-IQM.js} +2 -2
  56. package/dist/assets/{de-CzlQlDUl.js → de-B2IoQCYX.js} +1 -1
  57. package/dist/assets/{delete-confirm-Cq9MJasT.js → delete-confirm-CxRbnJU_.js} +1 -1
  58. package/dist/assets/{did-address-CtvTDc_I.js → did-address-BhAIkFPZ.js} +1 -1
  59. package/dist/assets/{domain-BOIdkJ_V.js → domain-CMJp7emz.js} +1 -1
  60. package/dist/assets/{domain-action-card-DuiLZ6sE.js → domain-action-card-CKlATj2V.js} +2 -2
  61. package/dist/assets/domains-CQs-XM9-.js +1 -0
  62. package/dist/assets/{email-DN8lH7fV.js → email-CYR31d5d.js} +2 -2
  63. package/dist/assets/{empty-spinner-DB1GKIOS.js → empty-spinner-DzVQ0tC1.js} +1 -1
  64. package/dist/assets/engine-ByRLynLu.js +1 -0
  65. package/dist/assets/{es-BpsyeJfJ.js → es-nlHqTKrO.js} +1 -1
  66. package/dist/assets/{exchange-passport-BvS_8Ud6.js → exchange-passport-BAD6oRbd.js} +1 -1
  67. package/dist/assets/{fallback-CuXkR699.js → fallback-CJFJeDKq.js} +1 -1
  68. package/dist/assets/{form-text-input-BT3t62-a.js → form-text-input-Dq_8KU_Y.js} +2 -2
  69. package/dist/assets/{form-wrapper-kWYD3nZz.js → form-wrapper-YOmD-sDI.js} +1 -1
  70. package/dist/assets/{form-CZjONW3r.js → form-zHvITlPG.js} +1 -1
  71. package/dist/assets/{fr-BawgvFA1.js → fr-LrrW00cI.js} +1 -1
  72. package/dist/assets/{fuel-dijAR437.js → fuel-CU-CpANh.js} +1 -1
  73. package/dist/assets/{gen-access-key-DaJCt-T5.js → gen-access-key-Fb9M1v-f.js} +1 -1
  74. package/dist/assets/{gen-simple-access-key-DLZy8UKi.js → gen-simple-access-key-BgYT9wM-.js} +1 -1
  75. package/dist/assets/get-safe-url-CCXmZ6Ty.js +1 -0
  76. package/dist/assets/hi-DxZE2HUh.js +5 -0
  77. package/dist/assets/{home-ChU7yi5l.js → home-Cy8jLKNF.js} +1 -1
  78. package/dist/assets/{id-_HQ0of3E.js → id-C3U8Kyb0.js} +1 -1
  79. package/dist/assets/{iframe-CYVXxx1r.js → iframe-CZ9tjsFz.js} +1 -1
  80. package/dist/assets/{index-C3UXSk-k.js → index-B-yh2KQb.js} +1 -1
  81. package/dist/assets/{index-DKeuwD_Y.js → index-B2LgdSh1.js} +15 -15
  82. package/dist/assets/{index-DswHt4-F.js → index-BJ69cdwn.js} +2 -2
  83. package/dist/assets/index-BJCzMYyG.js +832 -0
  84. package/dist/assets/{index-DF1j89BT.js → index-BZxTtTlP.js} +1 -1
  85. package/dist/assets/{index-Boc2cNQ7.js → index-Bg0Lw3eZ.js} +7 -7
  86. package/dist/assets/{index-D8oCzSQW.js → index-Bij9abGY.js} +2 -2
  87. package/dist/assets/{index-CD7hq5dy.js → index-BkgA3JrZ.js} +2 -2
  88. package/dist/assets/{index-Ci7zZ36D.js → index-BqISx1lI.js} +1 -1
  89. package/dist/assets/index-BsIQdVmB.js +29 -0
  90. package/dist/assets/{index-D7Er4cge.js → index-BtHiIOEI.js} +1 -1
  91. package/dist/assets/index-BtxDkXoY.js +7 -0
  92. package/dist/assets/{index-Dvc-Bpkc.js → index-CKgbiYHC.js} +2 -2
  93. package/dist/assets/{index-NHiSMvgy.js → index-CQz-yW1Q.js} +4 -4
  94. package/dist/assets/{index-Cax1AxL9.js → index-CSdd2W7t.js} +1 -1
  95. package/dist/assets/{index-CVuESID5.js → index-CYam9iu7.js} +3 -3
  96. package/dist/assets/{index-s8xAfo-W.js → index-CZc0agHR.js} +1 -1
  97. package/dist/assets/index-Cb9H09Dz.js +1 -0
  98. package/dist/assets/{index-B5VPb4FA.js → index-CtCzpHpi.js} +1 -1
  99. package/dist/assets/{index-iOa1BVMr.js → index-D0VFBmtN.js} +5 -5
  100. package/dist/assets/{index-CNlJloMN.js → index-D1HHdOwz.js} +2 -2
  101. package/dist/assets/{index-B9FojAjj.js → index-DDpk_EEp.js} +1 -1
  102. package/dist/assets/{index-B4A3W4qJ.js → index-DPbBn0Vu.js} +1 -1
  103. package/dist/assets/{index-C2O2gJSR.js → index-DbbtJMIS.js} +1 -1
  104. package/dist/assets/index-DgwyiIiW.js +1 -0
  105. package/dist/assets/{index-BVTsYhIX.js → index-Dh38UJiv.js} +1 -1
  106. package/dist/assets/{index-Zxy2t-7f.js → index-DvtkahBB.js} +1 -1
  107. package/dist/assets/{index-BDSBuO5S.js → index-Dw9kO-TK.js} +2 -2
  108. package/dist/assets/{index-Dn9eNAe6.js → index-E0k6Os1B.js} +1 -1
  109. package/dist/assets/{index-5Sys1Zsb.js → index-L6md5GCk.js} +2 -2
  110. package/dist/assets/{index-5RRpshJe.js → index-VTJ4vv2F.js} +7 -7
  111. package/dist/assets/{index-CZ-qZTKi.js → index-WY8_4PO1.js} +1 -1
  112. package/dist/assets/{index-uUS1eXYF.js → index-lGLHoHAP.js} +1 -1
  113. package/dist/assets/{index-WzGP4BGm.js → index-rh1DYsh2.js} +3 -3
  114. package/dist/assets/{index-B9YNNXOw.js → index-u8Hqob_G.js} +1 -1
  115. package/dist/assets/{index-C6vJzTmT.js → index-vQWAt26Z.js} +2 -2
  116. package/dist/assets/{info-outline-rounded-DovRYvXo.js → info-outline-rounded-CTki6xsp.js} +1 -1
  117. package/dist/assets/{invitation-DAWt0g1f.js → invitation-CrLJgh5y.js} +6 -6
  118. package/dist/assets/{invitations-B18y415k.js → invitations-Cs7LYbh9.js} +1 -1
  119. package/dist/assets/invite-B0wKu-K4.js +1 -0
  120. package/dist/assets/{issue-passport-Dd43b9Se.js → issue-passport-B1azomgq.js} +1 -1
  121. package/dist/assets/item-CcfCB60B.js +1 -0
  122. package/dist/assets/{ja-LErFaY57.js → ja-Cv-fddix.js} +1 -1
  123. package/dist/assets/{ko-D4ub28je.js → ko-Cy3G6t2o.js} +1 -1
  124. package/dist/assets/{landing-page-CZoTtLnc.js → landing-page-3yvA3dHp.js} +1 -1
  125. package/dist/assets/{launch-result-message-DJqF-slD.js → launch-result-message-CYcW9uFA.js} +1 -1
  126. package/dist/assets/{layout-U4Obhm5w.js → layout-DPEeowZp.js} +1 -1
  127. package/dist/assets/{list-D-9AeBju.js → list-BtmehYr0.js} +2 -2
  128. package/dist/assets/{list-header-BEZSwSji.js → list-header-DqG9VFur.js} +1 -1
  129. package/dist/assets/{list-BD3g0v2E.js → list-qef9ITY3.js} +1 -1
  130. package/dist/assets/localization-VGnaiTRr.js +1 -0
  131. package/dist/assets/{log-BWxaKOTA.js → log-BDLuou50.js} +1 -1
  132. package/dist/assets/logger-Cn2_Ur4V.js +1 -0
  133. package/dist/assets/{login-BWZaWrBW.js → login-BTzBeYdR.js} +1 -1
  134. package/dist/assets/{login-method-item-aEisznLn.js → login-method-item-T1v3TnPG.js} +1 -1
  135. package/dist/assets/{login-oauth-callback-CB-osgdG.js → login-oauth-callback-f1uXdv_Y.js} +1 -1
  136. package/dist/assets/{logo-uploader-DOPycN59.js → logo-uploader-YNwnzUQw.js} +1 -1
  137. package/dist/assets/{lost-passport-H1fCptmJ.js → lost-passport-Cv4fSebj.js} +2 -2
  138. package/dist/assets/metadata-BeJTujvj.js +55 -0
  139. package/dist/assets/{nav-menu-D7Sf6VZj.js → nav-menu-CefEor9d.js} +1 -1
  140. package/dist/assets/{open-window-By98Pw1o.js → open-window-Cq_Eb4d0.js} +1 -1
  141. package/dist/assets/over-due-invoice-payment-Cx9nVkCY.js +1 -0
  142. package/dist/assets/{overview-DEkktSML.js → overview-UWHPi3tV.js} +2 -2
  143. package/dist/assets/{page-header-qdK3sAJh.js → page-header-DayahqMa.js} +1 -1
  144. package/dist/assets/passport-D7GEY4wO.js +1 -0
  145. package/dist/assets/{passport-item-CIv8Q8Ng.js → passport-item-CpICtT-w.js} +1 -1
  146. package/dist/assets/{permission-B22pCnUb.js → permission-ozcooui7.js} +1 -1
  147. package/dist/assets/preferences-RHaCYv9t.js +1 -0
  148. package/dist/assets/profile-embed-BLPUgZl6.js +1 -0
  149. package/dist/assets/{provider-icon-DbnLu_85.js → provider-icon-Blmpf_9p.js} +1 -1
  150. package/dist/assets/pt-CLIZ5rGV.js +5 -0
  151. package/dist/assets/publish-resource-Cn5CEQma.js +1 -0
  152. package/dist/assets/{react-beautiful-dnd.esm-D7zp9L4b.js → react-beautiful-dnd.esm-L71UpeRK.js} +1 -1
  153. package/dist/assets/{react-stripe.esm-B-FTN8ep.js → react-stripe.esm-B1zA7yon.js} +1 -1
  154. package/dist/assets/{required-DnQpCGsD.js → required-jUJP5eu8.js} +1 -1
  155. package/dist/assets/ru-DoXNa8xl.js +5 -0
  156. package/dist/assets/{runtime-MjoLSEeg.js → runtime-CGShJ0Po.js} +1 -1
  157. package/dist/assets/sdk-C05lZFmW.js +1 -0
  158. package/dist/assets/{section-CZylgxjz.js → section-BHNJgwmP.js} +1 -1
  159. package/dist/assets/{security-BtD9TnGk.js → security-_Iru3mSY.js} +1 -1
  160. package/dist/assets/{session-UEzmH-IS.js → session-DpYXqKUu.js} +1 -1
  161. package/dist/assets/{setup-Bts0WUxD.js → setup-DCnaHhf3.js} +1 -1
  162. package/dist/assets/{shorten-label-CuBHsWUR.js → shorten-label-NmLkBKIj.js} +1 -1
  163. package/dist/assets/{simple-select-C6gRUbia.js → simple-select--uh08-vW.js} +1 -1
  164. package/dist/assets/{spaces-DtMVp8Fn.js → spaces-gCrHfJB8.js} +1 -1
  165. package/dist/assets/{start-Dabk9waT.js → start-S0ZFYLEE.js} +1 -1
  166. package/dist/assets/{starting-progress-Ds2lnMge.js → starting-progress-BSgBADJS.js} +1 -1
  167. package/dist/assets/{status-CicPnfGJ.js → status-DqZ0B8Xa.js} +1 -1
  168. package/dist/assets/{step-actions-CnJCnymc.js → step-actions-DxJMBPwi.js} +1 -1
  169. package/dist/assets/{studio-D7qZJqJ7.js → studio-B2SgpXxn.js} +1 -1
  170. package/dist/assets/{switch-qh9YpwMi.js → switch-D9wb-oPu.js} +1 -1
  171. package/dist/assets/{switch-control-C5gj6NIz.js → switch-control-Dl1BCyFd.js} +1 -1
  172. package/dist/assets/{table-tips-BSl1oNMX.js → table-tips-C5NrUDu8.js} +1 -1
  173. package/dist/assets/{team-Djzt5BWc.js → team-DXPe7dCA.js} +1 -1
  174. package/dist/assets/th-DmzEcJam.js +5 -0
  175. package/dist/assets/theme-mode-toggle-BYQvzsDR.js +1 -0
  176. package/dist/assets/{traffic-BtuX1qMz.js → traffic-BandB_6R.js} +1 -1
  177. package/dist/assets/{transfer-UdrQjD9F.js → transfer-Dky9H1bl.js} +1 -1
  178. package/dist/assets/{unsubscribe-Bj2S8OkH.js → unsubscribe-D0la_6Ib.js} +1 -1
  179. package/dist/assets/{use-app-logo-DyU2iSXF.js → use-app-logo-0G6x82Xn.js} +1 -1
  180. package/dist/assets/{use-blocklet-logo-ys-h-CV_.js → use-blocklet-logo-IV_8xnB2.js} +1 -1
  181. package/dist/assets/{use-mobile-DFkQ5N0b.js → use-mobile-CEr7zhO3.js} +1 -1
  182. package/dist/assets/{use-mobile-DwGMuJlg.js → use-mobile-DAngW3li.js} +1 -1
  183. package/dist/assets/{use-mobile-CyUZDIaX.js → use-mobile-kXWiSSQD.js} +1 -1
  184. package/dist/assets/{use-server-logo-KZn9RrZd.js → use-server-logo-BVKQ1t0s.js} +1 -1
  185. package/dist/assets/{use-window-close-CT9brY7I.js → use-window-close-C-WcChaL.js} +1 -1
  186. package/dist/assets/{useAsync-WuOY1bFS.js → useAsync-DRrTtbU_.js} +1 -1
  187. package/dist/assets/{useAsync-DbIyJl2v.js → useAsync-D_y3bEgl.js} +1 -1
  188. package/dist/assets/{useAsyncRetry-cAGDIsw4.js → useAsyncRetry-BZ4R17gr.js} +2 -2
  189. package/dist/assets/useLocalStorage-C5E7FrUa.js +1 -0
  190. package/dist/assets/{user-center-DLgnUI1s.js → user-center-D-UOqGpV.js} +5 -5
  191. package/dist/assets/{user-follower-BbQfOSyh.js → user-follower-_9B1O2CU.js} +4 -4
  192. package/dist/assets/{util-tg9hB6_c.js → util-Bf1lWzn8.js} +1 -1
  193. package/dist/assets/{util-BCpVIbwL.js → util-Dn9RqFJI.js} +1 -1
  194. package/dist/assets/utils-eOkzHJzR.js +1 -0
  195. package/dist/assets/{vendor-arcblock-Xw2zMy0D.js → vendor-arcblock-B6JCofz3.js} +1 -1
  196. package/dist/assets/vendor-hooks-Bt9Vv36g.js +1 -0
  197. package/dist/assets/{vendor-mui-core-CV-FnYH_.js → vendor-mui-core-D6nniiQs.js} +2 -2
  198. package/dist/assets/{vendor-mui-x-DwN6dcQH.js → vendor-mui-x-Ds-5Y7YM.js} +1 -1
  199. package/dist/assets/{vendor-ux-BGqHwkOM.js → vendor-ux-hzekFYg2.js} +123 -123
  200. package/dist/assets/vi-6MG7Pp6O.js +5 -0
  201. package/dist/assets/{wait-connect-BED_xYYA.js → wait-connect-DmtX5SsS.js} +1 -1
  202. package/dist/assets/wallet-hidden-topbar-OBN14KiV.js +68 -0
  203. package/dist/assets/{wizard-C6DvqdjM.js → wizard-Q2Vm8Y9G.js} +1 -1
  204. package/dist/assets/{wizard-components-1u7l8zuE.js → wizard-components-CON7Dump.js} +1 -1
  205. package/dist/assets/wrap-locale-BGMozDAq.js +1 -0
  206. package/dist/assets/{zh-DK-_Edsp.js → zh-B9y8LJ3-.js} +1 -1
  207. package/dist/assets/zh-Dfkd9CXx.js +1 -0
  208. package/dist/assets/{zh-tw-Us2SjBNr.js → zh-tw-CbtwifV_.js} +1 -1
  209. package/dist/index.html +1 -1
  210. package/package.json +44 -44
  211. package/dist/assets/add-resource-ipDE-D6W.js +0 -1
  212. package/dist/assets/advanced-C3qjZMWH.js +0 -14
  213. package/dist/assets/branding-Dv3-0Q39.js +0 -1
  214. package/dist/assets/button-d8gvZuHP.js +0 -1
  215. package/dist/assets/connect--GxmDNr3.js +0 -5
  216. package/dist/assets/domains-C5GLc_A-.js +0 -1
  217. package/dist/assets/engine-Crd5Z3lP.js +0 -1
  218. package/dist/assets/get-safe-url-czY77v8f.js +0 -1
  219. package/dist/assets/hi-ClGNxnSL.js +0 -5
  220. package/dist/assets/index-B4EOqUNT.js +0 -1
  221. package/dist/assets/index-BOoRVhLj.js +0 -29
  222. package/dist/assets/index-DGZbt7_m.js +0 -1
  223. package/dist/assets/index-tRQj1y79.js +0 -6
  224. package/dist/assets/index-yoaLEniz.js +0 -832
  225. package/dist/assets/invite-DNSyQ-zG.js +0 -1
  226. package/dist/assets/item-Cr70mAvV.js +0 -1
  227. package/dist/assets/joi-browser.min-CUdv8seQ.js +0 -1
  228. package/dist/assets/joi-browser.min-eEVeW7LC.js +0 -1
  229. package/dist/assets/localization-ByZI4mSj.js +0 -1
  230. package/dist/assets/logger-B962sOsB.js +0 -1
  231. package/dist/assets/metadata-DftwYKum.js +0 -55
  232. package/dist/assets/over-due-invoice-payment-DeFNS-Us.js +0 -1
  233. package/dist/assets/passport-BxMVp3TG.js +0 -1
  234. package/dist/assets/preferences-BY_s4EkY.js +0 -1
  235. package/dist/assets/profile-embed-DUKyv_oX.js +0 -1
  236. package/dist/assets/pt-BU7pvSz6.js +0 -5
  237. package/dist/assets/publish-resource-Be5Gs98x.js +0 -1
  238. package/dist/assets/ru-CtjyU-qF.js +0 -5
  239. package/dist/assets/sdk-Dy-R7tw7.js +0 -1
  240. package/dist/assets/th-C0DkNnMF.js +0 -5
  241. package/dist/assets/theme-mode-toggle-Jvn37gNg.js +0 -1
  242. package/dist/assets/useLocalStorage-D8kgfBAn.js +0 -1
  243. package/dist/assets/vendor-hooks-164oA5kM.js +0 -1
  244. package/dist/assets/vi-nXB9zTif.js +0 -5
  245. package/dist/assets/wallet-hidden-topbar-dnCLvPpW.js +0 -68
  246. package/dist/assets/wrap-locale-C2lxMNe7.js +0 -1
  247. package/dist/assets/zh-QEwKQjt8.js +0 -1
@@ -1,5 +1,5 @@
1
- import{j as e,X as m,a7 as L,T as j,aT as Ne,G as _e,e9 as V,ap as J,ea as We,al as h,b3 as F,bb as Fe,s as fe,eb as be,bd as Ge,an as ge,cE as Ye,M as Y,aM as K,bB as Ke,aN as q,R as qe,ce as $e,aP as He,ec as Qe,ed as Xe,ee as Ve,dF as Je,a_ as he}from"./vendor-mui-core-CV-FnYH_.js";import{r as Ze,p as ke,a as ue}from"./vendor-hooks-164oA5kM.js";import{r as b,j as et}from"./vendor-react-DX7tU9aY.js";import{V as M,X as N,M as E,F as U,bq as tt,bH as st,ab as ot,cp as I,w as nt}from"./index-yoaLEniz.js";import{y as B,V as D,b2 as at,b8 as $,aJ as rt,R as it,b3 as le,ba as ct}from"./vendor-ux-BGqHwkOM.js";import{u as lt}from"./use-mobile-DwGMuJlg.js";import{a as H,d as je,p as dt,c as pt,E as Ce,z as me}from"./vendor-utils-BbcnEeJI.js";import{o as we}from"./vendor-arcblock-Xw2zMy0D.js";import{a as ut,u as mt,c as xt,D as de,b as ft}from"./index-BOoRVhLj.js";import"./index-BojVbZw0.js";import"./api-BMcHDEnt.js";import{u as Be,C as gt,D as ht,a as St}from"./connect-to-DnBUF-KE.js";import{c as yt,g as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Bt}from"./spaces-DtMVp8Fn.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-B4A3W4qJ.js";import{a as Et}from"./dashboard-CkDdshHQ.js";import{E as Tt}from"./index-B5VPb4FA.js";import{x as It}from"./index-D29L5UKE.js";import{g as Se}from"./get-safe-url-czY77v8f.js";import{S as Rt}from"./switch-control-C5gj6NIz.js";import{C as vt,u as zt}from"./config-space-DUkjNtdL.js";import{L as ye}from"./list-header-BEZSwSji.js";import"./index-BVTsYhIX.js";import"./session-UEzmH-IS.js";import"./team-Djzt5BWc.js";import"./purify.es-HRjpPm7y.js";import"./wallet-hidden-topbar-dnCLvPpW.js";import"./theme-mode-toggle-Jvn37gNg.js";import"./use-mobile-CyUZDIaX.js";import"./index-CZ-qZTKi.js";import"./isURL-CpQHQuaa.js";import"./isIP-BBY240SU.js";import"./use-blocklet-logo-ys-h-CV_.js";import"./use-app-logo-DyU2iSXF.js";import"./useAsyncRetry-cAGDIsw4.js";import"./useAsync-WuOY1bFS.js";import"./useSetState-CUbypYGT.js";import"./fallback-CuXkR699.js";import"./index-CNlJloMN.js";import"./nav-menu-D7Sf6VZj.js";import"./zh-QEwKQjt8.js";import"./over-due-invoice-payment-DeFNS-Us.js";import"./useLocalStorage-D8kgfBAn.js";import"./confirm-CoDiNrSj.js";import"./passport-BxMVp3TG.js";import"./create-passport-svg-BSRyjG0k.js";import"./provider-icon-DbnLu_85.js";import"./google-icon-vNOJy67F.js";import"./passkey-rounded-_WDHIZVd.js";import"./index-B9YNNXOw.js";async function Ot({blockletDid:t,nodeApi:n,spaceGateways:a}){let s=!1;const r=await Promise.all(a.map(async o=>{let{name:c}=o;const i=await yt(o.endpoint);return!H(i)&&i!==c&&(c=i,s=!0),{...o,name:c}}));return s&&await Promise.all(r.filter(o=>o.did).map(o=>n.updateBlockletSpaceGateway({input:{did:t,where:{did:o.did},spaceGateway:{...o}}}))),r}function Lt({refresh:t}={}){const{blocklet:n}=M(),a=n?.meta?.did,{api:s}=N();return Ze(async()=>{if(!a)return[];const{spaceGateways:r}=await s.getBlockletSpaceGateways({input:{did:a}});return await Ot({blockletDid:a,nodeApi:s,spaceGateways:r})??[]},{refreshDeps:[a,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),B.error(Q(r)))}})}function De({deps:t,setLoading:n,backupDate:a}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=M(),[r,o]=b.useState([]),{api:c}=N(),[i,d]=b.useMemo(()=>a?[E(a).startOf("day").toISOString(),E(a).endOf("day").toISOString()]:[E().startOf("year").toISOString(),E().endOf("day").toISOString()],[a]),l=je(async()=>{try{if(n(!0),!s){o([]);return}const{backups:x}=await c.getBlockletBackups({input:{did:s.meta.did,startTime:i,endTime:d}});o(x??[])}catch(x){console.error(x),B.error(Q(x))}finally{n(!1)}},1e3);return ke(async()=>{l()},[s?.meta?.did].concat(t)),{backups:r}}function Pt({appDid:t}){const{backups:n}=De(),[a,s]=b.useState({message:"",progress:0,completed:!1}),r=N(),{ws:{useSubscription:o}}=r;return o(U.BlockletEvents.backupProgress,c=>{t===c?.appDid&&s(()=>({...c}))},[t]),b.useEffect(()=>{if(n?.length&&dt(n[0]?.status)){const[c]=n;s(()=>({message:c.message,progress:c.progress,completed:c.progress>=100}))}},[n]),a}function At({deps:t=[],setLoading:n=()=>{}}={}){const{blocklet:a}=M(),[s,r]=b.useState([]),{api:o}=N(),c=b.useCallback(je(async()=>{if(!o||!a?.meta?.did){r([]);return}try{n(!0);const i=E(),d=i.subtract(1,"year"),{summary:l}=await o.getBlockletBackupSummary({input:{did:a.meta.did,startTime:d.toISOString(),endTime:i.toISOString()}}),x=Array.isArray(l)?l.map(p=>({...p,successCount:+p.successCount,errorCount:+p.errorCount})):[];r(x)}catch(i){console.error("Failed to fetch backup summary:",i),B.error(Q(i)),r([])}finally{n(!1)}},1e3),[]);return ke(async()=>(await c(),()=>{c.cancel()}),[a?.meta?.did].concat(t)),{backupSummary:s}}const Ee=b.createContext({}),{Provider:Ut,Consumer:qs}=Ee;function Te({children:t}){const{t:n}=D(),{api:a}=N(),{blocklet:s}=M(),[r,o]=b.useState(null),[c,i]=b.useState(!1),{data:d,loading:l,mutate:x}=Lt({refresh:c}),p=pt(d),f=Pt({appDid:s?.appDid}),u=b.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=b.useState(!1),[S,y]=b.useState(0),{backups:Z}=De({deps:[S,r],setLoading:w,backupDate:r}),[ee,te]=b.useState(0),{backupSummary:se}=At({deps:[ee]}),[_,A]=b.useState(d?.find(g=>g.endpoint===u)),T=s?.settings?.autoBackup,v=()=>{i(g=>!g)},oe=()=>{te(g=>g+1)},ne=()=>{y(g=>g+1)},G=async g=>{await a.updateAutoBackup({input:{did:s.meta.did,autoBackup:g}})},X=async()=>{await a.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(g,O)=>{try{x(R=>{const z=[...R];return z.push({...g,loading:!0}),z}),await a.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:g}}),u!==O&&await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:O}]}}),A(g),v(),B.success(n("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(z=>[...z].filter(W=>W.did!==g.did)),R}},re=async g=>{g&&(g.endpoint===u&&(await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),T?.enabled&&await G({enabled:!1})),await a.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:g?.did}}),x(O=>{const R=[...O];return R.splice(R.indexOf(g),1),R}),A(g),v())},ie=async g=>{await Promise.all([a.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:g.did},spaceGateway:g}}),u!==g.endpoint&&a.configBlocklet({input:{did:[s.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:g.endpoint}]}})]),B.success(n("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"})),v()},C=g=>g?.endpoint===u;return e.jsx(Ut,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:v,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:p,spaceGatewayIsSelected:C,updateAutoBackup:G,abortBlockletBackup:X,backupEndpoint:u,backupProgress:f,backups:Z,backupSummary:se,refreshBackupSummary:oe,refreshBackups:ne,setBackupDate:o,backupsLoading:k,autoBackup:T},children:t})}Te.propTypes={children:m.any.isRequired};function P(){return b.useContext(Ee)}function Ie({...t}){const{blocklet:n}=M(),{info:a}=N(),{t:s}=D(),r=Be({blocklet:n}),o=tt(a),{spaceGateways:c,addSpaceGateway:i}=P(),d={checkFn:Ce.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:o,extraParams:{appPid:n.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:a.did}},l=async({endpoint:p,name:f,did:u})=>{const k=await kt(p);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(c.some(y=>y.endpoint===p)){B.error(s("storage.spaces.gateway.add.duplicate",{name:f}));return}await i({name:f,did:u,url:k,endpoint:p},p)},x=async({spaceGateway:p})=>{try{await l(p)}catch(f){console.error(f),B.error(Q(f))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:x})}function Re({...t}){const{t:n}=b.useContext(at),{blocklet:a,loading:s}=Et();if(a?.diskInfo){const r=(i,d,l)=>e.jsxs(j,{children:[i," ",e.jsx("strong",{children:d?ot(d):"empty"})]}),o=a.environments.reduce((i,d)=>(i[d.key]=d.value,i),{}),c=[{key:"appDir",name:n("blocklet.diskInfo.appDir"),value:r(o.BLOCKLET_APP_DIR,a.diskInfo.app)},{key:"dataDir",name:n("blocklet.diskInfo.dataDir"),value:r(o.BLOCKLET_DATA_DIR,a.diskInfo.data)},{key:"logDir",name:n("blocklet.diskInfo.logDir"),value:r(o.BLOCKLET_LOG_DIR,a.diskInfo.log)},{key:"cacheDir",name:n("blocklet.diskInfo.cacheDir"),value:r(o.BLOCKLET_CACHE_DIR,a.diskInfo.cache)}];return e.jsx(Mt,{component:"div",...t,children:c.map(i=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:i.name,children:i.value},i.key))})}return s?e.jsx(L,{}):e.jsx(j,{children:n("blocklet.diskInfo.empty")})}const Mt=Ne(j)``;function ve(){const{t}=D(),{setBackupDate:n,backupSummary:a}=P(),s=mt({key:"lg"}),r=b.useRef(null),o=_e(),c=b.useCallback(l=>{n(l)},[n]),i=b.useMemo(()=>{const l=E().add(1,"day"),x=l.subtract(1,"year"),p=new Map(a.map(u=>[u.date,{date:u.date,successCount:u.successCount,errorCount:u.errorCount}])),f=[];for(let u=x.clone();E(u).isBefore(l);u=u.add(1,"day")){const k=u.format("YYYY-MM-DD");f.push(p.get(k)||{date:k,successCount:0,errorCount:0})}return f},[a]),d=b.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:S,errorCount:y}=i[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${y}</div>`].join(`
2
- `)},backgroundColor:o.palette.background.paper,borderColor:o.palette.divider,textStyle:{color:o.palette.text.primary,fontSize:14},extraCssText:`box-shadow: ${o.shadows[2]}; border-radius: 4px;`,padding:[8,10]},visualMap:{show:!1,min:-12,max:12,pieces:[{min:Number.MIN_SAFE_INTEGER,max:-9,color:V[600]},{min:-9,max:-6,color:V[500]},{min:-6,max:-3,color:V[400]},{min:-3,max:-1,color:V[300]},{min:0,max:0,color:o.palette.grey[200]},{min:1,max:3,color:J[300]},{min:3,max:6,color:J[400]},{min:6,max:9,color:J[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:J[600]}],orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:12,textStyle:{color:o.palette.text.secondary,fontSize:12}},calendar:{top:30,left:50,right:10,bottom:4,cellSize:[8,8],splitLine:{show:!1},itemStyle:{borderWidth:2,borderColor:o.palette.background.default,color:o.palette.background.default},dayLabel:{show:!0,firstDay:0,nameMap:["","Mon","","Wed","","Fri",""],position:"start",margin:4,fontSize:10,color:o.palette.text.primary,fontWeight:"400",width:20},monthLabel:{show:!0,nameMap:"cn",align:"left",color:o.palette.text.primary,fontWeight:"400",fontSize:12,position:"start",margin:4,width:30,padding:[0,2]},yearLabel:{show:!1},range:[E().subtract(11,"month").startOf("month").format("YYYY-MM-DD"),E().endOf("month").format("YYYY-MM-DD")],orient:"horizontal"},series:{type:"heatmap",coordinateSystem:"calendar",data:i.map(k=>[k.date,k.errorCount?-k.errorCount:k.successCount]),label:{show:!1},itemStyle:{borderWidth:2,borderColor:o.palette.background.default,borderRadius:4},emphasis:{itemStyle:{borderWidth:2,borderColor:We[200],color:"inherit"}}}}),[i,t,o]);return e.jsxs(e.Fragment,{children:[e.jsx(h,{ref:r,sx:{maxWidth:"1280px",border:"1px solid",borderColor:"divider",padding:"8px",overflowX:"auto"},children:e.jsx(h,{sx:{width:"1200px",height:"180px",position:"relative"},children:e.jsx(Tt,{option:d,style:{height:"100%",width:"100%"},notMerge:!0,lazyUpdate:!1,opts:{renderer:"canvas"},onEvents:{click:l=>{l.componentType==="series"&&l.data&&c(l.data[0])}}})})}),e.jsx(h,{sx:{display:"flex",justifyContent:"flex-end",mt:1,mr:s?2:5,mb:2},children:e.jsxs(F,{direction:s?"column":"row",spacing:s?2:1,sx:{width:"100%",justifyContent:"flex-start",alignItems:s?"flex-start":"center"},children:[e.jsxs(F,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #8B5000 0%, #A36200 33%, #C17700 66%, #E29000 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.failed")})]}),e.jsxs(F,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,bgcolor:"grey.200",border:"1px solid",borderColor:"grey.200"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.without")})]}),e.jsxs(F,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #9be9a8 0%, #40c463 33%, #30a14e 66%, #216e39 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.succeeded")})]})]})})]})}const Nt=fe(({className:t,...n})=>e.jsx(ge,{...n,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function ze({status:t,message:n="",createdAt:a}){const{t:s}=D(),r=t===I.STATUS.PROGRESS&&E().diff(a,"hours")>=I.TIMEOUT_HOURS,o=r&&s("common.timeoutError"),c=t===I.STATUS.PROGRESS&&!r,i=t===I.STATUS.SUCCEEDED&&!r;return c?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(L,{sx:{marginRight:"4px"},size:"12px"}),s("common.progress")]}):i?e.jsx($,{type:"success",children:s("common.succeeded")}):e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx($,{type:"error",children:s("common.failed")}),e.jsx(ge,{style:{display:"flex",alignItems:"center",flexShrink:0},title:n||o,children:e.jsx(be,{children:e.jsx(Ye,{style:{width:"24px",height:"24px"},color:"error"})})})]})}ze.propTypes={status:m.string.isRequired,message:m.string,createdAt:m.string.isRequired};function Oe({metadata:t={}}){const{t:n}=D();if(H(t))return e.jsx($,{type:"success",children:n("common.succeeded")});const a=t.count||0,s=t.size||0,r=It(s,{iec:!0}),o=e.jsxs(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:[e.jsxs(j,{variant:"body2",children:[n("common.fileCount"),": ",a]}),e.jsxs(j,{variant:"body2",children:[n("common.fileSize"),": ",r]})]});return e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx($,{type:"success",children:n("common.succeeded")}),e.jsx(Nt,{title:o,style:{display:"flex",alignItems:"center",flexShrink:0},placement:"left",children:e.jsx(be,{children:e.jsx(Ge,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}Oe.propTypes={metadata:m.object};function Le(){const{t,locale:n}=D(),{spaceGateways:a,backups:s,backupsLoading:r}=P(),o=b.useMemo(()=>[{label:"DID Space",name:"target",options:{customBodyRenderLite:i=>{const{targetUrl:d,targetName:l,status:x,createdAt:p}=s[i],f=x===I.STATUS.PROGRESS&&E().diff(p,"hours")>=I.TIMEOUT_HOURS,u=x===I.STATUS.SUCCEEDED&&!f,k=l||a.find(w=>d?.includes(xe(w?.endpoint)))?.name||"Unknown DID Space";return u?e.jsx(Fe,{href:d,target:"_blank",sx:{fontSize:"16px"},children:k}):e.jsx(j,{variant:"body1",sx:{fontSize:"16px"},children:k})}}},{label:t("common.strategy"),name:"strategy",options:{customBodyRender:i=>{const d=t(i===0?"common.auto":"common.manual");return e.jsx($,{children:d})}}},{label:t("common.startTime"),name:"createdAt",options:{customBodyRender:i=>E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.endTime"),name:"updatedAt",options:{customBodyRender:i=>H(i)?"":E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:i=>{const d=s?.[i]??{},{status:l,message:x,createdAt:p,metadata:f}=d,u=l===I.STATUS.PROGRESS&&E().diff(p,"hours")>=I.TIMEOUT_HOURS,k=l===I.STATUS.PROGRESS&&!u,w=l===I.STATUS.SUCCEEDED&&!u;return k?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(L,{sx:{marginRight:"4px"},size:"12px"}),t("common.progress")]}):w?e.jsx(Oe,{metadata:f}):e.jsx(ze,{status:l,message:x,createdAt:p})}}}],[s,a,t]),c=b.useMemo(()=>!s?.length,[s]);return e.jsx(e.Fragment,{children:c?e.jsx(h,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px",color:"#9397A1",marginTop:"16px",marginBottom:"24px"},children:t("storage.spaces.record.emptyData")}):e.jsx(rt,{title:"",loading:r,data:s,columns:o,emptyNode:t("storage.spaces.record.emptyData",n),options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}})})}function _t(){const{t}=D();return e.jsxs(h,{children:[e.jsxs(h,{sx:{display:"flex",gap:3,flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",minWidth:240},children:[e.jsx(xt,{style:{cursor:"pointer",width:"150px",height:"100%",maxHeight:160}}),e.jsx(j,{sx:{my:2,textAlign:"center",color:"text.secondary"},children:t("storage.spaces.connect.provider")}),e.jsx(Ie,{})]}),e.jsxs(h,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.spaces.backup.records")})}),e.jsx(ve,{})]})]}),e.jsx(Le,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2,mt:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function Pe({spaceGateway:t,onConfirm:n=()=>{},onCancel:a=()=>{}}){const{t:s}=D(),[r,o]=b.useState(!1),[c,i]=b.useState(!1),d=(p,f)=>{p?.preventDefault(),p?.stopPropagation(),o(f)},l=async p=>{try{p?.stopPropagation(),i(!0),await n?.(t),o(!1)}catch(f){console.error(f),B.error(`${s("storage.space.gateway.delete.failed")}: ${Q(f)}`)}finally{o(!1),i(!1)}},x=p=>{d(p,!1),a?.(p)};return e.jsxs(e.Fragment,{children:[e.jsxs(Y,{color:"red",onClick:p=>d(p,!0),children:[e.jsx(K,{style:{minWidth:24,color:"red"},children:e.jsx(Ke,{fontSize:"small"})}),e.jsx(q,{style:{color:"red"},children:s("common.disconnect")})]}),e.jsx(it,{title:s("storage.spaces.gateway.delete.title"),open:r,confirmButton:{text:s("common.confirm"),props:{size:"small",variant:"contained",color:"error",loading:c}},cancelButton:{text:s("common.cancel"),props:{size:"small",variant:"outlined",disabled:c}},onConfirm:l,onCancel:x,children:e.jsx(j,{sx:{wordWrap:"break-word"},children:s("storage.spaces.gateway.delete.descForBackup",{name:`${t?.name}`})})})]})}Pe.propTypes={spaceGateway:m.shape({name:m.string.isRequired,url:m.string.isRequired,protected:m.bool}).isRequired,onConfirm:m.func,onCancel:m.func};function Ae({spaceGateway:t,selected:n,onDelete:a=()=>{},onConnect:s=()=>{},enableSwitchToSpace:r=!0,backupInProgress:o=!1,...c}){const{abortBlockletBackup:i}=P(),[d,l]=b.useState(null),{t:x}=D(),[p,f]=b.useState(!1),u=(S,y)=>{S.stopPropagation(),S.preventDefault(),l(y&&S.currentTarget)},k=async S=>{try{f(!0),u(S,!1),await s(t)}catch(y){console.error(y),B.error(y.message)}finally{f(!1)}},w=async S=>{try{f(!0),u(S,!1),await i()}catch(y){console.error(y),B.error(y.message)}finally{f(!1)}};return e.jsxs(e.Fragment,{children:[p||t?.loading?e.jsx(L,{sx:{ml:1},size:"24px"}):e.jsx(qe,{"aria-label":"more","aria-controls":"actions-menu","aria-haspopup":"true","data-cy":"trigger-blocklet-actions",variant:"outlined",size:"small",onClick:S=>u(S,!0),...c,children:e.jsx($e,{})}),e.jsxs(He,{id:"simple-menu",anchorEl:d,keepMounted:!0,open:!!d,onClose:S=>u(S,!1),children:[e.jsxs(Y,{onClick:S=>{u(S,!1),window.open(Se(t.endpoint?Ct(t.endpoint):t.url,{allowDomains:null}))},children:[e.jsx(K,{style:{minWidth:24},children:e.jsx(Qe,{fontSize:"small"})}),e.jsx(q,{children:x("common.open")})]}),e.jsxs(Y,{onClick:S=>{u(S,!1),window.open(Se(wt(t.endpoint),{allowDomains:null}))},children:[e.jsx(K,{style:{minWidth:24},children:e.jsx(Xe,{fontSize:"small"})}),e.jsx(q,{children:x("storage.spaces.strategy.viewBackupFiles")})]}),!n&&r&&e.jsxs(Y,{onClick:k,children:[e.jsx(K,{style:{minWidth:24},children:e.jsx(Ve,{fontSize:"small"})}),e.jsx(q,{children:x("storage.spaces.connect.switchToSpace")})]}),o&&e.jsxs(Y,{onClick:w,children:[e.jsx(K,{style:{minWidth:24},children:e.jsx(Je,{fontSize:"small"})}),e.jsx(q,{children:x("storage.spaces.connect.abortBlockletBackup")})]}),!o&&e.jsx(Pe,{spaceGateway:t,onConfirm:async()=>{l(null),await a?.(t)},onCancel:()=>l(null)})]})]})}Ae.propTypes={spaceGateway:m.shape({name:m.string.isRequired,url:m.string.isRequired,protected:m.bool,endpoint:m.string.isRequired,loading:m.bool}).isRequired,selected:m.bool.isRequired,enableSwitchToSpace:m.bool,onDelete:m.func,onConnect:m.func,backupInProgress:m.bool};const Wt=fe(({className:t,...n})=>e.jsx(ge,{...n,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Ue({spaceGateway:t,spaceStatus:n,selected:a,onConnected:s=()=>{},onDeleted:r=()=>{},onBackedUp:o=()=>{}}){const{t:c,locale:i}=D(),{blocklet:d}=M(),{api:l,info:{did:x}}=N(),{appDid:p,appName:f,appDescription:u,scopes:k,appUrl:w,referrer:S}=Be({blocklet:d}),{backupProgress:y,updateSpaceGateway:Z,deleteSpaceGateway:ee,refreshBackupSummary:te,refreshBackups:se}=P(),[_,A]=b.useState(!1),[T,v]=b.useState({open:!1,action:"one-click-authorization",checkTimeout:1e3*300,messages:{title:c("storage.spaces.authorize.title",{appName:f},i),scan:c("storage.spaces.authorize.scan",{appName:f},i),confirm:"",success:e.jsx(j,{gutterBottom:!0,children:c("storage.spaces.authorize.success")})},onClose:()=>{v(C=>({...C,open:!1}))}}),oe=a&&!_&&n===de.DISCONNECTED,ne=a&&!_&&!t.loading&&n===de.CONNECTED,G=a&&_&&n===de.CONNECTED&&y?.progress>=0,X=async()=>{try{if(await Bt(t?.endpoint)){await l.configBlocklet({input:{did:[d.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:t.endpoint}]}}),B.success(c("storage.spaces.connect.switchToSpaceSucceeded",{name:t.name?`(${t.name})`:""})),s?.(null,t);return}}catch(C){console.error(C),s?.(C,t);return}v(C=>({...C,open:!0,prefix:me(t.url,"space/api/did"),baseUrl:new URL(t.url).origin,checkFn:Ce.create({baseURL:me(t.url,"space")}).get,extraParams:{appDid:p,appName:f,appDescription:u,scopes:k,appUrl:w,referrer:S,nodeDid:x,spaceDid:t.did}}))},ae=async(C,g)=>{const O=g(C.endpoint),R=xe(O),z=C.space?g(C.space):{};if(t.did&&R!==t.did){v(Me=>({...Me,open:!1}));const W=c("storage.spaces.gateway.switch.failedForMismatchSpace",{name:z?.name?z.name:""});B.error(W),s?.(new Error(W),t);return}const ce={...t,name:z.name??"DID Space",did:z.did??xe(O),endpoint:O};await Z(ce),v(W=>({...W,open:!1})),s?.(null,ce)},re=async()=>{try{if(_)return;A(!0),await l.backupBlocklet({input:{appDid:d.appDid,to:"spaces"}})}catch(C){console.error(C),B.error(C.message),o?.(C,t)}finally{A(!0)}},ie=async()=>{try{await ee(t),B.success(c("storage.spaces.gateway.delete.succeeded",{name:t.name?`(${t.name})`:""})),r?.(null,t)}catch(C){console.error(C),r?.(C,t)}};return b.useEffect(()=>{y?.completed?(a&&(y?.progress===100?(B.success(c("storage.spaces.backupSuccessfully")),o?.(null,t)):y.message&&o?.(new Error(y?.message),t),y.progress=0,y.message=""),A(!1),te(),se()):y.progress&&A(!0)},[y]),e.jsxs(e.Fragment,{children:[e.jsxs(h,{sx:{display:"flex",alignItems:"center",".action-btn":{borderRadius:1,marginLeft:1}},children:[ne&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:re,children:c("storage.spaces.strategy.backupNow")}),oe&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:X,children:c("storage.spaces.disconnected.reconnectNow")}),G&&e.jsx(Wt,{title:y?.message&&e.jsx(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:e.jsx(j,{variant:"body2",children:y.message})}),children:e.jsxs(le,{className:"action-btn",variant:"outlined",size:"small",sx:{minWidth:70},children:[e.jsx(L,{variant:"determinate",value:y?.progress,size:14,sx:{mr:1}}),y?.progress,"%"]})}),e.jsx(nt,{forceConnected:!1,saveConnect:!1,prefix:T.prefix,open:T.open,popup:!0,action:T.action,baseUrl:T.baseUrl,checkFn:T.checkFn,onSuccess:ae,onClose:T.onClose,checkTimeout:T.checkTimeout,extraParams:T.extraParams,messages:T.messages,locale:i},"get-endpoint")]}),e.jsx(Ae,{sx:{minWidth:32,padding:"2px 4px",ml:1},spaceGateway:t,selected:a,onDelete:ie,onConnect:X,enableSwitchToSpace:y?.completed||H(y?.message),backupInProgress:G})]})}Ue.propTypes={spaceGateway:m.shape({did:m.string.isRequired,name:m.string.isRequired,url:m.string.isRequired,endpoint:m.string.isRequired,protected:m.bool,loading:m.bool}).isRequired,spaceStatus:m.string.isRequired,selected:m.bool.isRequired,onConnected:m.func,onDeleted:m.func,onBackedUp:m.func};function Ft({...t}){const{t:n}=D();return e.jsxs(h,{...t,children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:n("storage.spaces.backup.records")})}),e.jsx(ve,{}),e.jsx(Le,{})]})}function Gt({...t}){const{t:n}=D(),{autoBackup:a,updateAutoBackup:s}=P(),r=async()=>{try{const o=!a?.enabled;await s({enabled:o}),B.success(n(o?"storage.spaces.autoBackup.enabled":"storage.spaces.autoBackup.disabled"))}catch(o){B.error(o.message)}};return e.jsx(Rt,{checked:!!a?.enabled,onChange:r,name:"enableWelcomePage",labelProps:{label:e.jsx(j,{sx:{marginRight:"8px"},children:e.jsx("span",{children:n("storage.spaces.autoBackup.title")})})},style:{...t.style}})}function Yt(){const{t}=D(),{spaceGateways:n,spaceGatewaysLoading:a,spaceGatewayIsSelected:s}=P(),r=a&&!n?.length,o=({spaceGateway:c,spaceStatus:i,selected:d,refresh:l})=>e.jsx(Ue,{spaceGateway:c,spaceStatus:i,selected:d,onConnected:()=>l(),onBackedUp:x=>x&&l()});return e.jsxs(h,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},gap:{xs:1,md:2},justifyContent:{xs:"center",md:"flex-start"},alignItems:{xs:"flex-start",md:"center"}},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",flexGrow:1},children:t("storage.spaces.connected.title")}),e.jsx(Gt,{}),e.jsx(Ie,{})]}),e.jsx(h,{sx:{mt:2},children:r?e.jsx(h,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(L,{})}):e.jsx(he,{container:!0,spacing:2,children:e.jsx(e.Fragment,{children:n.map(c=>e.jsx(he,{size:{xs:12,md:6},children:e.jsx(ft,{endpoint:c.endpoint,selected:s(c),action:o},c.endpoint)},c.endpoint))})})}),e.jsx(Ft,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function Kt(){const{spaceGatewaysFirstLoading:t,spaceGateways:n}=P();return t?e.jsx(we,{relative:"parent",children:e.jsx(L,{})}):H(n)?e.jsx(_t,{}):e.jsx(Yt,{})}function qt(){return e.jsx(Te,{children:e.jsx(Kt,{})})}function $t(){const{spaceGateway:t,settingStorageEndpoint:n,updateSpaceGateway:a,hasStorageEndpoint:s,loading:r,storageEndpoint:o}=zt(),c=ue(()=>({display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"16px"}));return r?e.jsx(we,{relative:"parent",children:e.jsx(L,{})}):e.jsxs(h,{sx:{maxWidth:"md",position:"relative"},children:[s?e.jsx(gt,{spaceGateway:t,settingStorageEndpoint:n}):e.jsx(ht,{}),e.jsx(h,{sx:c,children:e.jsx(St,{onConnect:a,storageEndpoint:o})})]})}function Ht(){const{t}=D();return e.jsxs(vt,{children:[e.jsxs(F,{spacing:1,sx:{marginBottom:2},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.appLevel.title")}),e.jsx(j,{sx:{color:"text.secondary"},children:t("storage.appLevel.description")})]}),e.jsx($t,{})]})}function Qt({navOrientation:t="vertical",...n}){const{t:a,locale:s}=D(),{blocklet:r}=M(),o=lt({key:"md"}),[c,i]=et(),d=c.get("tab")||"backup",l=o?"horizontal":t,x=ue(()=>{const w=[{label:a("common.backup"),value:"backup"}],S=r?.capabilities?.didSpace;return(S===U.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED||S===U.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP)&&w.push({label:a("common.storage"),value:"storage"}),w},[s,l]),f=ue(()=>({backup:e.jsx(qt,{}),storage:e.jsx(Ht,{})}))[d],u=w=>{i(S=>(w==="backup"?S.delete("tab"):S.set("tab",w),S))};if(x.length<=1)return e.jsx(pe,{children:f});const k=e.jsx(ct,{tabs:x,current:d,orientation:l,onChange:u,sx:[{borderRight:1,height:"100%",borderColor:"divider"},l==="horizontal"&&{borderRight:0}]});if(l==="vertical")return e.jsx(h,{...n,children:e.jsxs(F,{direction:{md:"column",lg:"row"},sx:{gap:2},children:[e.jsx(h,{sx:{flexShrink:0},children:e.jsx(ye,{left:k})}),e.jsx(h,{sx:{flexGrow:1,minWidth:0},children:e.jsx(pe,{sx:{mt:1},children:f})})]})});if(l==="horizontal")return e.jsxs(h,{...n,children:[e.jsx(ye,{left:k}),e.jsx(pe,{sx:{mt:2},children:f})]})}Qt.propTypes={navOrientation:m.oneOf(["vertical","horizontal"])};const pe=fe(h)`
1
+ import{j as e,X as m,a7 as L,T as j,aT as Ne,G as _e,ea as V,ap as J,eb as We,al as h,b3 as G,bb as Ge,s as fe,ec as be,bd as Fe,an as ge,cF as Ye,M as Y,aM as K,bB as Ke,aN as q,R as qe,ce as $e,aP as He,ed as Qe,ee as Xe,ef as Ve,dG as Je,a_ as he}from"./vendor-mui-core-D6nniiQs.js";import{r as Ze,p as ke,a as ue}from"./vendor-hooks-Bt9Vv36g.js";import{r as b,j as et}from"./vendor-react-DX7tU9aY.js";import{V as M,X as N,M as E,F as U,bq as tt,bH as st,ab as ot,cp as I,w as nt}from"./index-BJCzMYyG.js";import{y as B,V as D,b1 as at,b7 as $,aI as rt,R as it,b2 as le,b9 as ct}from"./vendor-ux-hzekFYg2.js";import{u as lt}from"./use-mobile-CEr7zhO3.js";import{a as H,d as je,p as dt,c as pt,E as Ce,z as me}from"./vendor-utils-BbcnEeJI.js";import{o as we}from"./vendor-arcblock-B6JCofz3.js";import{a as ut,u as mt,c as xt,D as de,b as ft}from"./index-BsIQdVmB.js";import"./index-BojVbZw0.js";import"./api-BMcHDEnt.js";import{u as Be,C as gt,D as ht,a as St}from"./connect-to-CbgQNAwh.js";import{c as yt,g as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Bt}from"./spaces-gCrHfJB8.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-DPbBn0Vu.js";import{a as Et}from"./dashboard-y1fk-IQM.js";import{E as Tt}from"./index-CtCzpHpi.js";import{x as It}from"./index-D29L5UKE.js";import{g as Se}from"./get-safe-url-CCXmZ6Ty.js";import{S as Rt}from"./switch-control-Dl1BCyFd.js";import{C as vt,u as zt}from"./config-space-DLjHQVCq.js";import{L as ye}from"./list-header-DqG9VFur.js";import"./index-Dh38UJiv.js";import"./session-DpYXqKUu.js";import"./team-DXPe7dCA.js";import"./purify.es-HRjpPm7y.js";import"./wallet-hidden-topbar-OBN14KiV.js";import"./theme-mode-toggle-BYQvzsDR.js";import"./use-mobile-kXWiSSQD.js";import"./index-WY8_4PO1.js";import"./isURL-CpQHQuaa.js";import"./isIP-BBY240SU.js";import"./use-blocklet-logo-IV_8xnB2.js";import"./use-app-logo-0G6x82Xn.js";import"./useAsyncRetry-BZ4R17gr.js";import"./useAsync-DRrTtbU_.js";import"./useSetState-CUbypYGT.js";import"./fallback-CJFJeDKq.js";import"./index-D1HHdOwz.js";import"./nav-menu-CefEor9d.js";import"./zh-Dfkd9CXx.js";import"./over-due-invoice-payment-Cx9nVkCY.js";import"./useLocalStorage-C5E7FrUa.js";import"./confirm-ClxC2cDv.js";import"./passport-D7GEY4wO.js";import"./create-passport-svg-Ct68e5tm.js";import"./provider-icon-Blmpf_9p.js";import"./google-icon-vNOJy67F.js";import"./passkey-rounded-_WDHIZVd.js";import"./index-u8Hqob_G.js";async function Ot({blockletDid:t,nodeApi:n,spaceGateways:a}){let s=!1;const r=await Promise.all(a.map(async o=>{let{name:c}=o;const i=await yt(o.endpoint);return!H(i)&&i!==c&&(c=i,s=!0),{...o,name:c}}));return s&&await Promise.all(r.filter(o=>o.did).map(o=>n.updateBlockletSpaceGateway({input:{did:t,where:{did:o.did},spaceGateway:{...o}}}))),r}function Lt({refresh:t}={}){const{blocklet:n}=M(),a=n?.meta?.did,{api:s}=N();return Ze(async()=>{if(!a)return[];const{spaceGateways:r}=await s.getBlockletSpaceGateways({input:{did:a}});return await Ot({blockletDid:a,nodeApi:s,spaceGateways:r})??[]},{refreshDeps:[a,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),B.error(Q(r)))}})}function De({deps:t,setLoading:n,backupDate:a}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=M(),[r,o]=b.useState([]),{api:c}=N(),[i,d]=b.useMemo(()=>a?[E(a).startOf("day").toISOString(),E(a).endOf("day").toISOString()]:[E().startOf("year").toISOString(),E().endOf("day").toISOString()],[a]),l=je(async()=>{try{if(n(!0),!s){o([]);return}const{backups:x}=await c.getBlockletBackups({input:{did:s.meta.did,startTime:i,endTime:d}});o(x??[])}catch(x){console.error(x),B.error(Q(x))}finally{n(!1)}},1e3);return ke(async()=>{l()},[s?.meta?.did].concat(t)),{backups:r}}function Pt({appDid:t}){const{backups:n}=De(),[a,s]=b.useState({message:"",progress:0,completed:!1}),r=N(),{ws:{useSubscription:o}}=r;return o(U.BlockletEvents.backupProgress,c=>{t===c?.appDid&&s(()=>({...c}))},[t]),b.useEffect(()=>{if(n?.length&&dt(n[0]?.status)){const[c]=n;s(()=>({message:c.message,progress:c.progress,completed:c.progress>=100}))}},[n]),a}function At({deps:t=[],setLoading:n=()=>{}}={}){const{blocklet:a}=M(),[s,r]=b.useState([]),{api:o}=N(),c=b.useCallback(je(async()=>{if(!o||!a?.meta?.did){r([]);return}try{n(!0);const i=E(),d=i.subtract(1,"year"),{summary:l}=await o.getBlockletBackupSummary({input:{did:a.meta.did,startTime:d.toISOString(),endTime:i.toISOString()}}),x=Array.isArray(l)?l.map(p=>({...p,successCount:+p.successCount,errorCount:+p.errorCount})):[];r(x)}catch(i){console.error("Failed to fetch backup summary:",i),B.error(Q(i)),r([])}finally{n(!1)}},1e3),[]);return ke(async()=>(await c(),()=>{c.cancel()}),[a?.meta?.did].concat(t)),{backupSummary:s}}const Ee=b.createContext({}),{Provider:Ut,Consumer:qs}=Ee;function Te({children:t}){const{t:n}=D(),{api:a}=N(),{blocklet:s}=M(),[r,o]=b.useState(null),[c,i]=b.useState(!1),{data:d,loading:l,mutate:x}=Lt({refresh:c}),p=pt(d),f=Pt({appDid:s?.appDid}),u=b.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=b.useState(!1),[S,y]=b.useState(0),{backups:Z}=De({deps:[S,r],setLoading:w,backupDate:r}),[ee,te]=b.useState(0),{backupSummary:se}=At({deps:[ee]}),[_,A]=b.useState(d?.find(g=>g.endpoint===u)),T=s?.settings?.autoBackup,v=()=>{i(g=>!g)},oe=()=>{te(g=>g+1)},ne=()=>{y(g=>g+1)},F=async g=>{await a.updateAutoBackup({input:{did:s.meta.did,autoBackup:g}})},X=async()=>{await a.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(g,O)=>{try{x(R=>{const z=[...R];return z.push({...g,loading:!0}),z}),await a.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:g}}),u!==O&&await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:O}]}}),A(g),v(),B.success(n("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(z=>[...z].filter(W=>W.did!==g.did)),R}},re=async g=>{g&&(g.endpoint===u&&(await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),T?.enabled&&await F({enabled:!1})),await a.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:g?.did}}),x(O=>{const R=[...O];return R.splice(R.indexOf(g),1),R}),A(g),v())},ie=async g=>{await Promise.all([a.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:g.did},spaceGateway:g}}),u!==g.endpoint&&a.configBlocklet({input:{did:[s.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:g.endpoint}]}})]),B.success(n("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"})),v()},C=g=>g?.endpoint===u;return e.jsx(Ut,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:v,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:p,spaceGatewayIsSelected:C,updateAutoBackup:F,abortBlockletBackup:X,backupEndpoint:u,backupProgress:f,backups:Z,backupSummary:se,refreshBackupSummary:oe,refreshBackups:ne,setBackupDate:o,backupsLoading:k,autoBackup:T},children:t})}Te.propTypes={children:m.any.isRequired};function P(){return b.useContext(Ee)}function Ie({...t}){const{blocklet:n}=M(),{info:a}=N(),{t:s}=D(),r=Be({blocklet:n}),o=tt(a),{spaceGateways:c,addSpaceGateway:i}=P(),d={checkFn:Ce.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:o,extraParams:{appPid:n.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:a.did}},l=async({endpoint:p,name:f,did:u})=>{const k=await kt(p);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(c.some(y=>y.endpoint===p)){B.error(s("storage.spaces.gateway.add.duplicate",{name:f}));return}await i({name:f,did:u,url:k,endpoint:p},p)},x=async({spaceGateway:p})=>{try{await l(p)}catch(f){console.error(f),B.error(Q(f))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:x})}function Re({...t}){const{t:n}=b.useContext(at),{blocklet:a,loading:s}=Et();if(a?.diskInfo){const r=(i,d,l)=>e.jsxs(j,{children:[i," ",e.jsx("strong",{children:d?ot(d):"empty"})]}),o=a.environments.reduce((i,d)=>(i[d.key]=d.value,i),{}),c=[{key:"appDir",name:n("blocklet.diskInfo.appDir"),value:r(o.BLOCKLET_APP_DIR,a.diskInfo.app)},{key:"dataDir",name:n("blocklet.diskInfo.dataDir"),value:r(o.BLOCKLET_DATA_DIR,a.diskInfo.data)},{key:"logDir",name:n("blocklet.diskInfo.logDir"),value:r(o.BLOCKLET_LOG_DIR,a.diskInfo.log)},{key:"cacheDir",name:n("blocklet.diskInfo.cacheDir"),value:r(o.BLOCKLET_CACHE_DIR,a.diskInfo.cache)}];return e.jsx(Mt,{component:"div",...t,children:c.map(i=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:i.name,children:i.value},i.key))})}return s?e.jsx(L,{}):e.jsx(j,{children:n("blocklet.diskInfo.empty")})}const Mt=Ne(j)``;function ve(){const{t}=D(),{setBackupDate:n,backupSummary:a}=P(),s=mt({key:"lg"}),r=b.useRef(null),o=_e(),c=b.useCallback(l=>{n(l)},[n]),i=b.useMemo(()=>{const l=E().add(1,"day"),x=l.subtract(1,"year"),p=new Map(a.map(u=>[u.date,{date:u.date,successCount:u.successCount,errorCount:u.errorCount}])),f=[];for(let u=x.clone();E(u).isBefore(l);u=u.add(1,"day")){const k=u.format("YYYY-MM-DD");f.push(p.get(k)||{date:k,successCount:0,errorCount:0})}return f},[a]),d=b.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:S,errorCount:y}=i[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${y}</div>`].join(`
2
+ `)},backgroundColor:o.palette.background.paper,borderColor:o.palette.divider,textStyle:{color:o.palette.text.primary,fontSize:14},extraCssText:`box-shadow: ${o.shadows[2]}; border-radius: 4px;`,padding:[8,10]},visualMap:{show:!1,min:-12,max:12,pieces:[{min:Number.MIN_SAFE_INTEGER,max:-9,color:V[600]},{min:-9,max:-6,color:V[500]},{min:-6,max:-3,color:V[400]},{min:-3,max:-1,color:V[300]},{min:0,max:0,color:o.palette.grey[200]},{min:1,max:3,color:J[300]},{min:3,max:6,color:J[400]},{min:6,max:9,color:J[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:J[600]}],orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:12,textStyle:{color:o.palette.text.secondary,fontSize:12}},calendar:{top:30,left:50,right:10,bottom:4,cellSize:[8,8],splitLine:{show:!1},itemStyle:{borderWidth:2,borderColor:o.palette.background.default,color:o.palette.background.default},dayLabel:{show:!0,firstDay:0,nameMap:["","Mon","","Wed","","Fri",""],position:"start",margin:4,fontSize:10,color:o.palette.text.primary,fontWeight:"400",width:20},monthLabel:{show:!0,nameMap:"cn",align:"left",color:o.palette.text.primary,fontWeight:"400",fontSize:12,position:"start",margin:4,width:30,padding:[0,2]},yearLabel:{show:!1},range:[E().subtract(11,"month").startOf("month").format("YYYY-MM-DD"),E().endOf("month").format("YYYY-MM-DD")],orient:"horizontal"},series:{type:"heatmap",coordinateSystem:"calendar",data:i.map(k=>[k.date,k.errorCount?-k.errorCount:k.successCount]),label:{show:!1},itemStyle:{borderWidth:2,borderColor:o.palette.background.default,borderRadius:4},emphasis:{itemStyle:{borderWidth:2,borderColor:We[200],color:"inherit"}}}}),[i,t,o]);return e.jsxs(e.Fragment,{children:[e.jsx(h,{ref:r,sx:{maxWidth:"1280px",border:"1px solid",borderColor:"divider",padding:"8px",overflowX:"auto"},children:e.jsx(h,{sx:{width:"1200px",height:"180px",position:"relative"},children:e.jsx(Tt,{option:d,style:{height:"100%",width:"100%"},notMerge:!0,lazyUpdate:!1,opts:{renderer:"canvas"},onEvents:{click:l=>{l.componentType==="series"&&l.data&&c(l.data[0])}}})})}),e.jsx(h,{sx:{display:"flex",justifyContent:"flex-end",mt:1,mr:s?2:5,mb:2},children:e.jsxs(G,{direction:s?"column":"row",spacing:s?2:1,sx:{width:"100%",justifyContent:"flex-start",alignItems:s?"flex-start":"center"},children:[e.jsxs(G,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #8B5000 0%, #A36200 33%, #C17700 66%, #E29000 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.failed")})]}),e.jsxs(G,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,bgcolor:"grey.200",border:"1px solid",borderColor:"grey.200"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.without")})]}),e.jsxs(G,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #9be9a8 0%, #40c463 33%, #30a14e 66%, #216e39 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.succeeded")})]})]})})]})}const Nt=fe(({className:t,...n})=>e.jsx(ge,{...n,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function ze({status:t,message:n="",createdAt:a}){const{t:s}=D(),r=t===I.STATUS.PROGRESS&&E().diff(a,"hours")>=I.TIMEOUT_HOURS,o=r&&s("common.timeoutError"),c=t===I.STATUS.PROGRESS&&!r,i=t===I.STATUS.SUCCEEDED&&!r;return c?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(L,{sx:{marginRight:"4px"},size:"12px"}),s("common.progress")]}):i?e.jsx($,{type:"success",children:s("common.succeeded")}):e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx($,{type:"error",children:s("common.failed")}),e.jsx(ge,{style:{display:"flex",alignItems:"center",flexShrink:0},title:n||o,children:e.jsx(be,{children:e.jsx(Ye,{style:{width:"24px",height:"24px"},color:"error"})})})]})}ze.propTypes={status:m.string.isRequired,message:m.string,createdAt:m.string.isRequired};function Oe({metadata:t={}}){const{t:n}=D();if(H(t))return e.jsx($,{type:"success",children:n("common.succeeded")});const a=t.count||0,s=t.size||0,r=It(s,{iec:!0}),o=e.jsxs(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:[e.jsxs(j,{variant:"body2",children:[n("common.fileCount"),": ",a]}),e.jsxs(j,{variant:"body2",children:[n("common.fileSize"),": ",r]})]});return e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx($,{type:"success",children:n("common.succeeded")}),e.jsx(Nt,{title:o,style:{display:"flex",alignItems:"center",flexShrink:0},placement:"left",children:e.jsx(be,{children:e.jsx(Fe,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}Oe.propTypes={metadata:m.object};function Le(){const{t,locale:n}=D(),{spaceGateways:a,backups:s,backupsLoading:r}=P(),o=b.useMemo(()=>[{label:"DID Space",name:"target",options:{customBodyRenderLite:i=>{const{targetUrl:d,targetName:l,status:x,createdAt:p}=s[i],f=x===I.STATUS.PROGRESS&&E().diff(p,"hours")>=I.TIMEOUT_HOURS,u=x===I.STATUS.SUCCEEDED&&!f,k=l||a.find(w=>d?.includes(xe(w?.endpoint)))?.name||"Unknown DID Space";return u?e.jsx(Ge,{href:d,target:"_blank",sx:{fontSize:"16px"},children:k}):e.jsx(j,{variant:"body1",sx:{fontSize:"16px"},children:k})}}},{label:t("common.strategy"),name:"strategy",options:{customBodyRender:i=>{const d=t(i===0?"common.auto":"common.manual");return e.jsx($,{children:d})}}},{label:t("common.startTime"),name:"createdAt",options:{customBodyRender:i=>E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.endTime"),name:"updatedAt",options:{customBodyRender:i=>H(i)?"":E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:i=>{const d=s?.[i]??{},{status:l,message:x,createdAt:p,metadata:f}=d,u=l===I.STATUS.PROGRESS&&E().diff(p,"hours")>=I.TIMEOUT_HOURS,k=l===I.STATUS.PROGRESS&&!u,w=l===I.STATUS.SUCCEEDED&&!u;return k?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(L,{sx:{marginRight:"4px"},size:"12px"}),t("common.progress")]}):w?e.jsx(Oe,{metadata:f}):e.jsx(ze,{status:l,message:x,createdAt:p})}}}],[s,a,t]),c=b.useMemo(()=>!s?.length,[s]);return e.jsx(e.Fragment,{children:c?e.jsx(h,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px",color:"#9397A1",marginTop:"16px",marginBottom:"24px"},children:t("storage.spaces.record.emptyData")}):e.jsx(rt,{title:"",loading:r,data:s,columns:o,emptyNode:t("storage.spaces.record.emptyData",n),options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}})})}function _t(){const{t}=D();return e.jsxs(h,{children:[e.jsxs(h,{sx:{display:"flex",gap:3,flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",minWidth:240},children:[e.jsx(xt,{style:{cursor:"pointer",width:"150px",height:"100%",maxHeight:160}}),e.jsx(j,{sx:{my:2,textAlign:"center",color:"text.secondary"},children:t("storage.spaces.connect.provider")}),e.jsx(Ie,{})]}),e.jsxs(h,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.spaces.backup.records")})}),e.jsx(ve,{})]})]}),e.jsx(Le,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2,mt:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function Pe({spaceGateway:t,onConfirm:n=()=>{},onCancel:a=()=>{}}){const{t:s}=D(),[r,o]=b.useState(!1),[c,i]=b.useState(!1),d=(p,f)=>{p?.preventDefault(),p?.stopPropagation(),o(f)},l=async p=>{try{p?.stopPropagation(),i(!0),await n?.(t),o(!1)}catch(f){console.error(f),B.error(`${s("storage.space.gateway.delete.failed")}: ${Q(f)}`)}finally{o(!1),i(!1)}},x=p=>{d(p,!1),a?.(p)};return e.jsxs(e.Fragment,{children:[e.jsxs(Y,{color:"red",onClick:p=>d(p,!0),children:[e.jsx(K,{style:{minWidth:24,color:"red"},children:e.jsx(Ke,{fontSize:"small"})}),e.jsx(q,{style:{color:"red"},children:s("common.disconnect")})]}),e.jsx(it,{title:s("storage.spaces.gateway.delete.title"),open:r,confirmButton:{text:s("common.confirm"),props:{size:"small",variant:"contained",color:"error",loading:c}},cancelButton:{text:s("common.cancel"),props:{size:"small",variant:"outlined",disabled:c}},onConfirm:l,onCancel:x,children:e.jsx(j,{sx:{wordWrap:"break-word"},children:s("storage.spaces.gateway.delete.descForBackup",{name:`${t?.name}`})})})]})}Pe.propTypes={spaceGateway:m.shape({name:m.string.isRequired,url:m.string.isRequired,protected:m.bool}).isRequired,onConfirm:m.func,onCancel:m.func};function Ae({spaceGateway:t,selected:n,onDelete:a=()=>{},onConnect:s=()=>{},enableSwitchToSpace:r=!0,backupInProgress:o=!1,...c}){const{abortBlockletBackup:i}=P(),[d,l]=b.useState(null),{t:x}=D(),[p,f]=b.useState(!1),u=(S,y)=>{S.stopPropagation(),S.preventDefault(),l(y&&S.currentTarget)},k=async S=>{try{f(!0),u(S,!1),await s(t)}catch(y){console.error(y),B.error(y.message)}finally{f(!1)}},w=async S=>{try{f(!0),u(S,!1),await i()}catch(y){console.error(y),B.error(y.message)}finally{f(!1)}};return e.jsxs(e.Fragment,{children:[p||t?.loading?e.jsx(L,{sx:{ml:1},size:"24px"}):e.jsx(qe,{"aria-label":"more","aria-controls":"actions-menu","aria-haspopup":"true","data-cy":"trigger-blocklet-actions",variant:"outlined",size:"small",onClick:S=>u(S,!0),...c,children:e.jsx($e,{})}),e.jsxs(He,{id:"simple-menu",anchorEl:d,keepMounted:!0,open:!!d,onClose:S=>u(S,!1),children:[e.jsxs(Y,{onClick:S=>{u(S,!1),window.open(Se(t.endpoint?Ct(t.endpoint):t.url,{allowDomains:null}))},children:[e.jsx(K,{style:{minWidth:24},children:e.jsx(Qe,{fontSize:"small"})}),e.jsx(q,{children:x("common.open")})]}),e.jsxs(Y,{onClick:S=>{u(S,!1),window.open(Se(wt(t.endpoint),{allowDomains:null}))},children:[e.jsx(K,{style:{minWidth:24},children:e.jsx(Xe,{fontSize:"small"})}),e.jsx(q,{children:x("storage.spaces.strategy.viewBackupFiles")})]}),!n&&r&&e.jsxs(Y,{onClick:k,children:[e.jsx(K,{style:{minWidth:24},children:e.jsx(Ve,{fontSize:"small"})}),e.jsx(q,{children:x("storage.spaces.connect.switchToSpace")})]}),o&&e.jsxs(Y,{onClick:w,children:[e.jsx(K,{style:{minWidth:24},children:e.jsx(Je,{fontSize:"small"})}),e.jsx(q,{children:x("storage.spaces.connect.abortBlockletBackup")})]}),!o&&e.jsx(Pe,{spaceGateway:t,onConfirm:async()=>{l(null),await a?.(t)},onCancel:()=>l(null)})]})]})}Ae.propTypes={spaceGateway:m.shape({name:m.string.isRequired,url:m.string.isRequired,protected:m.bool,endpoint:m.string.isRequired,loading:m.bool}).isRequired,selected:m.bool.isRequired,enableSwitchToSpace:m.bool,onDelete:m.func,onConnect:m.func,backupInProgress:m.bool};const Wt=fe(({className:t,...n})=>e.jsx(ge,{...n,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Ue({spaceGateway:t,spaceStatus:n,selected:a,onConnected:s=()=>{},onDeleted:r=()=>{},onBackedUp:o=()=>{}}){const{t:c,locale:i}=D(),{blocklet:d}=M(),{api:l,info:{did:x}}=N(),{appDid:p,appName:f,appDescription:u,scopes:k,appUrl:w,referrer:S}=Be({blocklet:d}),{backupProgress:y,updateSpaceGateway:Z,deleteSpaceGateway:ee,refreshBackupSummary:te,refreshBackups:se}=P(),[_,A]=b.useState(!1),[T,v]=b.useState({open:!1,action:"one-click-authorization",checkTimeout:1e3*300,messages:{title:c("storage.spaces.authorize.title",{appName:f},i),scan:c("storage.spaces.authorize.scan",{appName:f},i),confirm:"",success:e.jsx(j,{gutterBottom:!0,children:c("storage.spaces.authorize.success")})},onClose:()=>{v(C=>({...C,open:!1}))}}),oe=a&&!_&&n===de.DISCONNECTED,ne=a&&!_&&!t.loading&&n===de.CONNECTED,F=a&&_&&n===de.CONNECTED&&y?.progress>=0,X=async()=>{try{if(await Bt(t?.endpoint)){await l.configBlocklet({input:{did:[d.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:t.endpoint}]}}),B.success(c("storage.spaces.connect.switchToSpaceSucceeded",{name:t.name?`(${t.name})`:""})),s?.(null,t);return}}catch(C){console.error(C),s?.(C,t);return}v(C=>({...C,open:!0,prefix:me(t.url,"space/api/did"),baseUrl:new URL(t.url).origin,checkFn:Ce.create({baseURL:me(t.url,"space")}).get,extraParams:{appDid:p,appName:f,appDescription:u,scopes:k,appUrl:w,referrer:S,nodeDid:x,spaceDid:t.did}}))},ae=async(C,g)=>{const O=g(C.endpoint),R=xe(O),z=C.space?g(C.space):{};if(t.did&&R!==t.did){v(Me=>({...Me,open:!1}));const W=c("storage.spaces.gateway.switch.failedForMismatchSpace",{name:z?.name?z.name:""});B.error(W),s?.(new Error(W),t);return}const ce={...t,name:z.name??"DID Space",did:z.did??xe(O),endpoint:O};await Z(ce),v(W=>({...W,open:!1})),s?.(null,ce)},re=async()=>{try{if(_)return;A(!0),await l.backupBlocklet({input:{appDid:d.appDid,to:"spaces"}})}catch(C){console.error(C),B.error(C.message),o?.(C,t)}finally{A(!0)}},ie=async()=>{try{await ee(t),B.success(c("storage.spaces.gateway.delete.succeeded",{name:t.name?`(${t.name})`:""})),r?.(null,t)}catch(C){console.error(C),r?.(C,t)}};return b.useEffect(()=>{y?.completed?(a&&(y?.progress===100?(B.success(c("storage.spaces.backupSuccessfully")),o?.(null,t)):y.message&&o?.(new Error(y?.message),t),y.progress=0,y.message=""),A(!1),te(),se()):y.progress&&A(!0)},[y]),e.jsxs(e.Fragment,{children:[e.jsxs(h,{sx:{display:"flex",alignItems:"center",".action-btn":{borderRadius:1,marginLeft:1}},children:[ne&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:re,children:c("storage.spaces.strategy.backupNow")}),oe&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:X,children:c("storage.spaces.disconnected.reconnectNow")}),F&&e.jsx(Wt,{title:y?.message&&e.jsx(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:e.jsx(j,{variant:"body2",children:y.message})}),children:e.jsxs(le,{className:"action-btn",variant:"outlined",size:"small",sx:{minWidth:70},children:[e.jsx(L,{variant:"determinate",value:y?.progress,size:14,sx:{mr:1}}),y?.progress,"%"]})}),e.jsx(nt,{forceConnected:!1,saveConnect:!1,prefix:T.prefix,open:T.open,popup:!0,action:T.action,baseUrl:T.baseUrl,checkFn:T.checkFn,onSuccess:ae,onClose:T.onClose,checkTimeout:T.checkTimeout,extraParams:T.extraParams,messages:T.messages,locale:i},"get-endpoint")]}),e.jsx(Ae,{sx:{minWidth:32,padding:"2px 4px",ml:1},spaceGateway:t,selected:a,onDelete:ie,onConnect:X,enableSwitchToSpace:y?.completed||H(y?.message),backupInProgress:F})]})}Ue.propTypes={spaceGateway:m.shape({did:m.string.isRequired,name:m.string.isRequired,url:m.string.isRequired,endpoint:m.string.isRequired,protected:m.bool,loading:m.bool}).isRequired,spaceStatus:m.string.isRequired,selected:m.bool.isRequired,onConnected:m.func,onDeleted:m.func,onBackedUp:m.func};function Gt({...t}){const{t:n}=D();return e.jsxs(h,{...t,children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:n("storage.spaces.backup.records")})}),e.jsx(ve,{}),e.jsx(Le,{})]})}function Ft({...t}){const{t:n}=D(),{autoBackup:a,updateAutoBackup:s}=P(),r=async()=>{try{const o=!a?.enabled;await s({enabled:o}),B.success(n(o?"storage.spaces.autoBackup.enabled":"storage.spaces.autoBackup.disabled"))}catch(o){B.error(o.message)}};return e.jsx(Rt,{checked:!!a?.enabled,onChange:r,name:"enableWelcomePage",labelProps:{label:e.jsx(j,{sx:{marginRight:"8px"},children:e.jsx("span",{children:n("storage.spaces.autoBackup.title")})})},style:{...t.style}})}function Yt(){const{t}=D(),{spaceGateways:n,spaceGatewaysLoading:a,spaceGatewayIsSelected:s}=P(),r=a&&!n?.length,o=({spaceGateway:c,spaceStatus:i,selected:d,refresh:l})=>e.jsx(Ue,{spaceGateway:c,spaceStatus:i,selected:d,onConnected:()=>l(),onBackedUp:x=>x&&l()});return e.jsxs(h,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},gap:{xs:1,md:2},justifyContent:{xs:"center",md:"flex-start"},alignItems:{xs:"flex-start",md:"center"}},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",flexGrow:1},children:t("storage.spaces.connected.title")}),e.jsx(Ft,{}),e.jsx(Ie,{})]}),e.jsx(h,{sx:{mt:2},children:r?e.jsx(h,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(L,{})}):e.jsx(he,{container:!0,spacing:2,children:e.jsx(e.Fragment,{children:n.map(c=>e.jsx(he,{size:{xs:12,md:6},children:e.jsx(ft,{endpoint:c.endpoint,selected:s(c),action:o},c.endpoint)},c.endpoint))})})}),e.jsx(Gt,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function Kt(){const{spaceGatewaysFirstLoading:t,spaceGateways:n}=P();return t?e.jsx(we,{relative:"parent",children:e.jsx(L,{})}):H(n)?e.jsx(_t,{}):e.jsx(Yt,{})}function qt(){return e.jsx(Te,{children:e.jsx(Kt,{})})}function $t(){const{spaceGateway:t,settingStorageEndpoint:n,updateSpaceGateway:a,hasStorageEndpoint:s,loading:r,storageEndpoint:o}=zt(),c=ue(()=>({display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"16px"}));return r?e.jsx(we,{relative:"parent",children:e.jsx(L,{})}):e.jsxs(h,{sx:{maxWidth:"md",position:"relative"},children:[s?e.jsx(gt,{spaceGateway:t,settingStorageEndpoint:n}):e.jsx(ht,{}),e.jsx(h,{sx:c,children:e.jsx(St,{onConnect:a,storageEndpoint:o})})]})}function Ht(){const{t}=D();return e.jsxs(vt,{children:[e.jsxs(G,{spacing:1,sx:{marginBottom:2},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.appLevel.title")}),e.jsx(j,{sx:{color:"text.secondary"},children:t("storage.appLevel.description")})]}),e.jsx($t,{})]})}function Qt({navOrientation:t="vertical",...n}){const{t:a,locale:s}=D(),{blocklet:r}=M(),o=lt({key:"md"}),[c,i]=et(),d=c.get("tab")||"backup",l=o?"horizontal":t,x=ue(()=>{const w=[{label:a("common.backup"),value:"backup"}],S=r?.capabilities?.didSpace;return(S===U.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED||S===U.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP)&&w.push({label:a("common.storage"),value:"storage"}),w},[s,l]),f=ue(()=>({backup:e.jsx(qt,{}),storage:e.jsx(Ht,{})}))[d],u=w=>{i(S=>(w==="backup"?S.delete("tab"):S.set("tab",w),S))};if(x.length<=1)return e.jsx(pe,{children:f});const k=e.jsx(ct,{tabs:x,current:d,orientation:l,onChange:u,sx:[{borderRight:1,height:"100%",borderColor:"divider"},l==="horizontal"&&{borderRight:0}]});if(l==="vertical")return e.jsx(h,{...n,children:e.jsxs(G,{direction:{md:"column",lg:"row"},sx:{gap:2},children:[e.jsx(h,{sx:{flexShrink:0},children:e.jsx(ye,{left:k})}),e.jsx(h,{sx:{flexGrow:1,minWidth:0},children:e.jsx(pe,{sx:{mt:1},children:f})})]})});if(l==="horizontal")return e.jsxs(h,{...n,children:[e.jsx(ye,{left:k}),e.jsx(pe,{sx:{mt:2},children:f})]})}Qt.propTypes={navOrientation:m.oneOf(["vertical","horizontal"])};const pe=fe(h)`
3
3
  position: relative;
4
4
  min-height: 66vh;
5
5
  overflow: hidden;
@@ -1,4 +1,4 @@
1
- import{r as b,g as _e,a as $e}from"./vendor-react-DX7tU9aY.js";import{i as qe,r as V}from"./vendor-hooks-164oA5kM.js";import{j as e,al as t,aT as _,b3 as G,a7 as F,b4 as Ue,an as H,bd as He,V as Ge,T as E,a4 as Ke,X as S,A as M,M as X,I as O,d_ as ge,ct as ye,C as Ye,y as Ve,cp as Xe,cq as Q,c3 as Ze,F as Je,bN as Qe,s as es}from"./vendor-mui-core-CV-FnYH_.js";import{V as A,aG as W,ba as ss,aJ as ae,bk as ee,y as D,b3 as N,aI as re,bX as je,bW as ts,u as as,b8 as rs,bC as os}from"./vendor-ux-BGqHwkOM.js";import{X as P,A as ns,M as be,cI as se,cJ as is,E as J,V as ls,n as cs,F as ds,at as ps,e as Y,cx as us,cy as ms,cF as fs}from"./index-yoaLEniz.js";import{W as oe}from"./did-address-CtvTDc_I.js";import{b as z}from"./team-Djzt5BWc.js";import{r as ne,a as ie,b as le,c as ve,d as Z,e as xs,u as hs,f as gs}from"./passport-item-CIv8Q8Ng.js";import{p as Se}from"./util-tg9hB6_c.js";import{u as ys}from"./use-mobile-DwGMuJlg.js";import{O as U}from"./index-BVTsYhIX.js";import{w as $,P as js}from"./permission-B22pCnUb.js";import{C as bs}from"./Google-PffSpBc2.js";import{c as vs}from"./create-passport-svg-BSRyjG0k.js";import{A as Ss}from"./vendor-arcblock-Xw2zMy0D.js";import{C as K,aC as Cs}from"./vendor-utils-BbcnEeJI.js";import{e as Ce}from"./edit.svg-BGhTyO6h.js";import{h as ce,b as ws}from"./index-DswHt4-F.js";import{C as we}from"./confirm-CoDiNrSj.js";import{L as Te}from"./list-header-BEZSwSji.js";import{f as te}from"./index-DBs9Ljax.js";import{u as Ts}from"./useSetState-CUbypYGT.js";import"./session-UEzmH-IS.js";import"./purify.es-HRjpPm7y.js";import"./wallet-hidden-topbar-dnCLvPpW.js";import"./theme-mode-toggle-Jvn37gNg.js";import"./use-mobile-CyUZDIaX.js";import"./index-CZ-qZTKi.js";import"./isURL-CpQHQuaa.js";import"./isIP-BBY240SU.js";import"./use-blocklet-logo-ys-h-CV_.js";import"./use-app-logo-DyU2iSXF.js";import"./ua-parser-D6QF1h5N.js";import"./base32-CyUpiYTu.js";import"./cloneDeep-q2Jbqwkh.js";import"./lock.svg-BOhdQlHW.js";const me="info";function Ie({createPassportSvg:c,passport:s,onCancel:p,onSwitchPassport:u=()=>{}}){const{t:f}=A(),i=qe({tab:me}),d={info:{label:f("common.basicInfo"),value:me,component:()=>e.jsx(De,{passport:s,createPassportSvg:c})},logs:{label:f("common.logs"),value:"logs",component:()=>e.jsx(Re,{passport:s})},related:{label:f("team.passport.related"),value:"related",component:()=>e.jsx(Ae,{passport:s,onSwitchPassport:u})}},l=Object.values(d).map(({label:h,value:m})=>({label:h,value:m})).filter(h=>h.value==="related"?s.parentDid:!0),r=d[i.tab]||d.info,n=h=>{i.tab=h};return e.jsx(W,{title:f("common.passport"),onClose:p,open:!0,PaperProps:{style:{maxWidth:800,minHeight:"80vh"}},fullWidth:!0,children:e.jsxs(Is,{children:[e.jsx(t,{className:"tabs",children:e.jsx(ss,{tabs:l,current:i.tab,onChange:n,scrollButtons:"auto"})}),e.jsx(t,{className:"body",children:e.jsx(r.component,{})})]})})}Ie.propTypes={createPassportSvg:S.func.isRequired,passport:S.object.isRequired,onCancel:S.func.isRequired,onSwitchPassport:S.func};const Is=_(t)`
1
+ import{r as b,g as We,a as _e}from"./vendor-react-DX7tU9aY.js";import{i as qe,r as V}from"./vendor-hooks-Bt9Vv36g.js";import{j as e,al as t,aT as W,b3 as G,a7 as F,b4 as Ue,an as H,bd as He,V as Ge,T as E,a4 as Ke,X as S,A as M,M as Z,I as O,d$ as ge,cu as ye,C as Ye,y as Ve,cq as Ze,cr as Q,c3 as Xe,F as Je,bN as Qe,s as es}from"./vendor-mui-core-D6nniiQs.js";import{V as A,aG as $,b9 as ss,aI as ae,bi as ee,y as D,b2 as N,aH as re,b$ as je,b_ as ts,u as as,b7 as rs,bA as os}from"./vendor-ux-hzekFYg2.js";import{X as P,A as ns,M as be,cI as se,cJ as is,E as J,V as ls,n as cs,F as ds,at as ps,e as Y,cx as us,cy as ms,cF as fs}from"./index-BJCzMYyG.js";import{W as oe}from"./did-address-BhAIkFPZ.js";import{b as z}from"./team-DXPe7dCA.js";import{r as ne,a as ie,b as le,c as ve,d as X,e as xs,u as hs,f as gs}from"./passport-item-CpICtT-w.js";import{p as Se}from"./util-Bf1lWzn8.js";import{u as ys}from"./use-mobile-CEr7zhO3.js";import{O as U}from"./index-Dh38UJiv.js";import{w as _,P as js}from"./permission-ozcooui7.js";import{C as bs}from"./Google-efeywUOs.js";import{c as vs}from"./create-passport-svg-Ct68e5tm.js";import{A as Ss}from"./vendor-arcblock-B6JCofz3.js";import{C as K,aC as Cs}from"./vendor-utils-BbcnEeJI.js";import{e as Ce}from"./edit.svg-BGhTyO6h.js";import{h as ce,b as ws}from"./index-BJ69cdwn.js";import{C as we}from"./confirm-ClxC2cDv.js";import{L as Te}from"./list-header-DqG9VFur.js";import{f as te}from"./index-DBs9Ljax.js";import{u as Ts}from"./useSetState-CUbypYGT.js";import"./session-DpYXqKUu.js";import"./purify.es-HRjpPm7y.js";import"./wallet-hidden-topbar-OBN14KiV.js";import"./theme-mode-toggle-BYQvzsDR.js";import"./use-mobile-kXWiSSQD.js";import"./index-WY8_4PO1.js";import"./isURL-CpQHQuaa.js";import"./isIP-BBY240SU.js";import"./use-blocklet-logo-IV_8xnB2.js";import"./use-app-logo-0G6x82Xn.js";import"./ua-parser-D6QF1h5N.js";import"./base32-D79Y2AcQ.js";import"./cloneDeep-q2Jbqwkh.js";import"./lock.svg-BOhdQlHW.js";const me="info";function Ie({createPassportSvg:c,passport:s,onCancel:p,onSwitchPassport:u=()=>{}}){const{t:f}=A(),i=qe({tab:me}),d={info:{label:f("common.basicInfo"),value:me,component:()=>e.jsx(De,{passport:s,createPassportSvg:c})},logs:{label:f("common.logs"),value:"logs",component:()=>e.jsx(Re,{passport:s})},related:{label:f("team.passport.related"),value:"related",component:()=>e.jsx(Ae,{passport:s,onSwitchPassport:u})}},l=Object.values(d).map(({label:h,value:m})=>({label:h,value:m})).filter(h=>h.value==="related"?s.parentDid:!0),r=d[i.tab]||d.info,n=h=>{i.tab=h};return e.jsx($,{title:f("common.passport"),onClose:p,open:!0,PaperProps:{style:{maxWidth:800,minHeight:"80vh"}},fullWidth:!0,children:e.jsxs(Is,{children:[e.jsx(t,{className:"tabs",children:e.jsx(ss,{tabs:l,current:i.tab,onChange:n,scrollButtons:"auto"})}),e.jsx(t,{className:"body",children:e.jsx(r.component,{})})]})})}Ie.propTypes={createPassportSvg:S.func.isRequired,passport:S.object.isRequired,onCancel:S.func.isRequired,onSwitchPassport:S.func};const Is=W(t)`
2
2
  margin-top: -16px;
3
3
 
4
4
  .tabs {
@@ -9,7 +9,7 @@ import{r as b,g as _e,a as $e}from"./vendor-react-DX7tU9aY.js";import{i as qe,r
9
9
  .body {
10
10
  margin-top: 24px;
11
11
  }
12
- `;function De({createPassportSvg:c,passport:s}){const{t:p,locale:u}=A(),{teamDid:f}=z(),{inService:i}=P(),d=ys(),l=[{items:[{label:p("common.role"),content:ne(s.title)},{label:p("common.did"),content:e.jsx(oe,{did:s.id})},{label:p("team.passport.status"),content:le(s.status)},{label:p("common.type"),content:e.jsx(t,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:(s.type||[]).map(n=>e.jsx(Ge,{label:n,variant:"outlined",size:"small",sx:{borderRadius:1}},n))})}]}],r=[{title:p("team.passport.owner"),items:[{label:p("team.passport.owner"),content:e.jsx(t,{children:ie(s.user,i)})}]},{title:p("common.timeInfo"),items:[{label:p("team.passport.issuanceTime"),content:s.issuanceDate?e.jsx(ee,{value:s.issuanceDate,type:"all",locale:u}):"-"},{label:p("team.member.lastLogin"),content:s.lastLoginAt?e.jsx(ee,{value:s.lastLoginAt,type:"all",locale:u}):"-"},{label:p("common.expires"),content:s.expirationDate?e.jsx(ee,{value:s.expirationDate,type:"all",locale:u}):"-"}]},{title:p("blocklet.overview.source"),items:[{label:p("blocklet.overview.source"),content:Z(s.source)}]}];return e.jsxs(Ds,{gap:3,children:[e.jsxs(t,{sx:{display:"flex",flexDirection:d?"column":"row",alignItems:d?"flex-start":"center",justifyContent:d?"center":"flex-start",width:"100%",overflow:"hidden",gap:d?2:4},children:[e.jsx(t,{sx:{display:"flex",width:"180px"},className:"passport-image",dangerouslySetInnerHTML:{__html:c({scope:s.scope,role:s.role,title:s.scope==="kyc"?s.name:s.title,issuer:s.issuer&&s.issuer.name,issuerDid:s.issuer&&s.issuer.id,ownerName:s.user?.fullName,ownerDid:s.user?.did,ownerAvatarUrl:s.user?.avatar?Se(s.user?.avatar,f,i):"",revoked:s.revoked,extra:s?.expirationDate?{key:"Exp",value:be(s.expirationDate).format("YYYY-MM-DD HH:mm:ss")}:null})}}),e.jsx(t,{className:"info-area",children:l.map(n=>e.jsxs(t,{children:[n.title&&e.jsx(E,{variant:"h6",sx:{mb:2},children:n.title}),e.jsx(t,{className:"info-grid",sx:{gap:"12px !important"},children:n.items.map(h=>e.jsxs(t,{className:"info-item",children:[e.jsx(t,{className:"info-label",sx:{maxWidth:40},children:e.jsx(E,{variant:"subtitle2",color:"textSecondary",children:h.label})}),e.jsx(t,{sx:{display:"flex",flexWrap:"wrap",gap:.5,minWidth:0},children:h.content})]},h.label))})]},n.title))})]}),e.jsx(Ke,{}),e.jsx(t,{className:"info-area",children:r.map(n=>e.jsxs(t,{children:[e.jsx(E,{variant:"h5",sx:{mb:1.5},children:n.title}),e.jsx(t,{className:"info-grid",children:n.items.map(h=>e.jsxs(t,{className:"info-item",children:[e.jsx(t,{className:"info-label",children:e.jsx(E,{variant:"subtitle2",color:"textSecondary",children:h.label})}),e.jsx(t,{sx:{minWidth:500},children:h.content})]},h.label))})]},n.title))})]})}De.propTypes={passport:S.object.isRequired,createPassportSvg:S.func.isRequired};const Ds=_(G)`
12
+ `;function De({createPassportSvg:c,passport:s}){const{t:p,locale:u}=A(),{teamDid:f}=z(),{inService:i}=P(),d=ys(),l=[{items:[{label:p("common.role"),content:ne(s.title)},{label:p("common.did"),content:e.jsx(oe,{did:s.id})},{label:p("team.passport.status"),content:le(s.status)},{label:p("common.type"),content:e.jsx(t,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:(s.type||[]).map(n=>e.jsx(Ge,{label:n,variant:"outlined",size:"small",sx:{borderRadius:1}},n))})}]}],r=[{title:p("team.passport.owner"),items:[{label:p("team.passport.owner"),content:e.jsx(t,{children:ie(s.user,i)})}]},{title:p("common.timeInfo"),items:[{label:p("team.passport.issuanceTime"),content:s.issuanceDate?e.jsx(ee,{value:s.issuanceDate,type:"all",locale:u}):"-"},{label:p("team.member.lastLogin"),content:s.lastLoginAt?e.jsx(ee,{value:s.lastLoginAt,type:"all",locale:u}):"-"},{label:p("common.expires"),content:s.expirationDate?e.jsx(ee,{value:s.expirationDate,type:"all",locale:u}):"-"}]},{title:p("blocklet.overview.source"),items:[{label:p("blocklet.overview.source"),content:X(s.source)}]}];return e.jsxs(Ds,{gap:3,children:[e.jsxs(t,{sx:{display:"flex",flexDirection:d?"column":"row",alignItems:d?"flex-start":"center",justifyContent:d?"center":"flex-start",width:"100%",overflow:"hidden",gap:d?2:4},children:[e.jsx(t,{sx:{display:"flex",width:"180px"},className:"passport-image",dangerouslySetInnerHTML:{__html:c({scope:s.scope,role:s.role,title:s.scope==="kyc"?s.name:s.title,issuer:s.issuer&&s.issuer.name,issuerDid:s.issuer&&s.issuer.id,ownerName:s.user?.fullName,ownerDid:s.user?.did,ownerAvatarUrl:s.user?.avatar?Se(s.user?.avatar,f,i):"",revoked:s.revoked,extra:s?.expirationDate?{key:"Exp",value:be(s.expirationDate).format("YYYY-MM-DD HH:mm:ss")}:null})}}),e.jsx(t,{className:"info-area",children:l.map(n=>e.jsxs(t,{children:[n.title&&e.jsx(E,{variant:"h6",sx:{mb:2},children:n.title}),e.jsx(t,{className:"info-grid",sx:{gap:"12px !important"},children:n.items.map(h=>e.jsxs(t,{className:"info-item",children:[e.jsx(t,{className:"info-label",sx:{maxWidth:40},children:e.jsx(E,{variant:"subtitle2",color:"textSecondary",children:h.label})}),e.jsx(t,{sx:{display:"flex",flexWrap:"wrap",gap:.5,minWidth:0},children:h.content})]},h.label))})]},n.title))})]}),e.jsx(Ke,{}),e.jsx(t,{className:"info-area",children:r.map(n=>e.jsxs(t,{children:[e.jsx(E,{variant:"h5",sx:{mb:1.5},children:n.title}),e.jsx(t,{className:"info-grid",children:n.items.map(h=>e.jsxs(t,{className:"info-item",children:[e.jsx(t,{className:"info-label",children:e.jsx(E,{variant:"subtitle2",color:"textSecondary",children:h.label})}),e.jsx(t,{sx:{minWidth:500},children:h.content})]},h.label))})]},n.title))})]})}De.propTypes={passport:S.object.isRequired,createPassportSvg:S.func.isRequired};const Ds=W(G)`
13
13
  .info-card {
14
14
  margin-bottom: 24px;
15
15
  overflow: hidden;
@@ -87,7 +87,7 @@ import{r as b,g as _e,a as $e}from"./vendor-react-DX7tU9aY.js";import{i as qe,r
87
87
  margin: 0;
88
88
  }
89
89
  }
90
- `,Pe=10,ke=1;function Re({passport:c}){const{api:s}=P(),{teamDid:p}=z(),{t:u,locale:f}=A(),[i,d]=b.useState({pageSize:Pe,page:ke}),{data:l,loading:r}=V(async()=>{const x={teamDid:p,query:{passportId:c.id},paging:{page:i.page,pageSize:i.pageSize}},a=await s.getPassportLogs({input:x});return{logs:a.passportLogs||[],total:a.paging.total}},{refreshDeps:[i.page,i.pageSize],onError:x=>D.error(x.message)}),n=b.useMemo(()=>l?.logs||[],[l?.logs]),h=x=>x.action===se.APPROVE||x.action===se.REVOKE?x?.metadata?.operator?.fullName?`${u("common.operator")}: ${x?.metadata?.operator?.fullName}`:null:x.action===se.ISSUE&&x.metadata?.action===is.ISSUE_ON_INVITE?x?.metadata?.inviter?.fullName?`${u("common.inviter")}: ${x?.metadata?.inviter?.fullName}`:null:`passportId: ${x.passportId}`,m=b.useMemo(()=>[{label:u("common.action"),name:"action",options:{customBodyRender:(x,{rowIndex:a})=>{const o=n[a];return e.jsx(H,{title:h(o),children:`${x} ${o.metadata?.action?`(${o.metadata.action})`:""}`})}}},{label:"IP",name:"operatorIp",options:{customBodyRender:x=>e.jsx(t,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsx("span",{children:x||"-"})})}},{label:"UA",width:250,name:"operatorUa",options:{customBodyRender:(x,{rowIndex:a})=>{const o=n[a];return e.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1},children:[o.operatorUa&&e.jsx(t,{children:xs(o.operatorUa)}),o.operatorUa&&e.jsx(H,{title:o.operatorUa,children:e.jsx(He,{fontSize:"small",color:"action",sx:{fontSize:16,cursor:"pointer"}})})]})}}},{label:u("common.createdAt"),name:"createdAt",options:{customBodyRender:x=>ns(x,f)}}],[u,f,n]),g=({page:x,rowsPerPage:a})=>{i.pageSize!==a?d(o=>({...o,pageSize:a,page:1})):i.page!==x+1&&d(o=>({...o,page:x+1}))},T={sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,search:!1,page:i.page-1,rowsPerPage:i.pageSize,count:l?.total||0};return r?e.jsx(t,{sx:{py:2},children:e.jsx(G,{direction:"row",spacing:1,sx:{position:"relative",pb:2},children:e.jsx(F,{})})}):e.jsx(t,{children:e.jsx(ae,{className:"logs-table",verticalKeyWidth:100,locale:f,data:n,columns:m,options:T,loading:r,onChange:g})})}Re.propTypes={passport:S.object.isRequired};function Ae({passport:c,onSwitchPassport:s}){const{api:p}=P(),{teamDid:u}=z(),{t:f,locale:i}=A(),[d,l]=b.useState({pageSize:Pe,page:ke}),{data:r,loading:n}=V(async()=>{const a={teamDid:u,passportId:c.parentDid,paging:{page:d.page,pageSize:d.pageSize}},o=await p.getRelatedPassports({input:a});return{passports:o.passports||[],total:o.paging.total}},{refreshDeps:[d.page,d.pageSize],onError:a=>D.error(a.message)}),h=b.useMemo(()=>r?.passports||[],[r?.passports]),m=b.useMemo(()=>[{label:f("team.passport.role"),name:"role",options:{customBodyRender:ne}},{label:f("team.passport.owner"),name:"user",options:{customBodyRender:ie}},{label:f("team.passport.status"),name:"status",options:{customBodyRender:le}},{label:f("team.member.lastLogin"),name:"lastLoginAt",options:{customBodyRender:a=>ve(a,i)}},{label:f("blocklet.overview.source"),name:"source",options:{customBodyRender:Z}}],[f,i]),g=({page:a,rowsPerPage:o})=>{d.pageSize!==o?l(v=>({...v,pageSize:o,page:1})):d.page!==a+1&&l(v=>({...v,page:a+1}))},T=b.useRef(null),x={sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,search:!1,page:d.page-1,rowsPerPage:d.pageSize,count:r?.total||0,onRowClick(a,{dataIndex:o},v){if(T.current?.contains(v.target)){const j=h[o];s(j)}}};return n?e.jsx(t,{sx:{py:2},children:e.jsx(G,{direction:"row",spacing:1,sx:{position:"relative",pb:2},children:e.jsx(F,{})})}):e.jsxs(G,{spacing:1,children:[e.jsx(Ue,{severity:"warning",children:f("team.passport.relatedDescription")}),e.jsx(t,{ref:T,sx:{".MuiTableRow-root":{cursor:"pointer"}},children:e.jsx(ae,{className:"related-table",verticalKeyWidth:100,locale:i,data:h.filter(a=>a.id!==c.id),columns:m,options:x,loading:n,onChange:g})})]})}Ae.propTypes={passport:S.object.isRequired,onSwitchPassport:S.func.isRequired};function de({onCancel:c,onSuccess:s}){const{api:p}=P(),{blocklet:u}=ls(),{t:f}=A(),[i,d]=b.useState(!1),l=(u.environments.find(g=>g.key==="BLOCKLET_PASSPORT_COLOR")||{}).value||"auto",r=l==="auto"?Ss(u.appDid):l,[n,h]=b.useState(r),m=async()=>{const g=[{key:ds.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_PASSPORT_COLOR,value:n}];try{d(!0),await p.configBlocklet({input:{did:u.meta.did,configs:g}}),s()}catch(T){D.error(T.message)}finally{d(!1)}};return e.jsx(W,{title:f("team.passport.color"),onClose:c,open:!0,fullWidth:!0,actions:e.jsxs(e.Fragment,{children:[e.jsx(N,{onClick:c,color:"inherit",children:f("common.cancel")}),e.jsxs(N,{onClick:m,color:"primary",disabled:i,variant:"contained",autoFocus:!0,"data-cy":"color-btn-confirm",children:[i&&e.jsx(F,{size:16}),f("common.save")]})]}),children:e.jsxs(t,{className:"dialog-content",sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:[e.jsx(bs,{disableAlpha:!0,color:n,onChange:g=>h(g.hex)}),e.jsx("div",{style:{width:220,marginLeft:24},dangerouslySetInnerHTML:{__html:vs({scope:"passport",role:"owner",title:"Owner",issuer:cs.getDisplayName(u),issuerDid:u.appDid,ownerName:"Your Name",ownerDid:u.appDid,preferredColor:n})}})]})})}const Ps=$(de,"mutate_team"),ks=$(de,"",J);function Rs(c){const{inService:s}=P();return s?e.jsx(ks,{...c}):e.jsx(Ps,{...c})}de.propTypes={onCancel:S.func.isRequired,onSuccess:S.func.isRequired};var Le=function(s){return e.jsx("svg",{...s,children:e.jsx("path",{d:"M64.707 8.707a1 1 0 0 0 0-1.414L58.343.929a1 1 0 1 0-1.414 1.414L62.586 8l-5.657 5.657a1 1 0 0 0 1.414 1.414l6.364-6.364ZM0 9h64V7H0v2Z",fill:"#666"})})};Le.defaultProps={width:"65",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg"};const As=(c,s)=>c?!s.some(p=>!p.from.passport||!p.to.role):!1;function Ne({onCancel:c,onSuccess:s,data:p={},trustedPassports:u=[]}){const{api:f}=P(),{roles:i,teamDid:d}=z(),{t:l}=A(),[r,n]=b.useState(!1),[h,m]=b.useState(p.issuerDid||""),[g,T]=b.useState(p.remark||""),[x,a]=b.useState(K(p.mappings)||[]),o=u.findIndex(j=>j.issuerDid===p.issuerDid),v=async()=>{if(r)return;const j={issuerDid:h,remark:g,mappings:x.map(w=>({...w,to:{...w.to,ttl:w.to.ttl||0}}))},C=[...u];o===-1?C.unshift(j):C[o]=j;try{n(!0),await f.configTrustedPassports({input:{teamDid:d,trustedPassports:C}}),await Y(800),n(!1),D.success(l("common.saveSuccess")),s()}catch(w){n(!1),D.error(te(w))}};return e.jsx(W,{title:l("team.passport.trustedIssuers"),open:!0,showCloseButton:!1,PaperProps:{style:{minHeight:"80vh"}},fullWidth:!0,prepend:e.jsx(O,{onClick:c,"data-cy":"trusted-issuer-close",size:"large",children:e.jsx(ge,{})}),actions:e.jsxs(e.Fragment,{children:[e.jsx(N,{onClick:c,color:"inherit",children:l("common.cancel")}),e.jsxs(N,{onClick:()=>v(),color:"primary",disabled:!As(h,x)||!g||r,variant:"contained",autoFocus:!0,"data-cy":"save-mapping",children:[r&&e.jsx(F,{size:16}),l("common.save")]})]}),children:e.jsx(Ls,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx(M,{fullWidth:!0,"data-cy":"input-issuer-did",placeholder:l("team.passport.issuerDid"),value:h,onChange:j=>{m(j.target.value)}}),e.jsx(M,{style:{marginTop:16},fullWidth:!0,"data-cy":"input-issuer-remark",placeholder:l("common.remark"),value:g,onChange:j=>{T(j.target.value)}}),e.jsxs(t,{sx:{mt:"30px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(t,{className:"dialog-h1",children:l("team.passport.mappingRule")}),e.jsx(t,{children:e.jsx(N,{variant:"outlined",color:"primary","data-cy":"add-mapping",onClick:()=>{a(j=>{const C=[...j];return C.unshift({from:{passport:""},to:{role:ps.GUEST}}),C})},children:l("team.add")})})]}),e.jsxs(t,{className:"list",sx:{mt:-.5},children:[x.map((j,C)=>e.jsxs(t,{className:"mapping-item",sx:{display:"flex",alignItems:"center",justifyContent:"space-between",my:1},children:[e.jsxs(t,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[e.jsx(t,{sx:{flexGrow:1,flexBasis:1},children:e.jsx(M,{fullWidth:!0,size:"small","data-cy":`input-${C}-from`,placeholder:"Issuer’s Passport Name/ID *",value:j.from.passport,onChange:w=>{const{value:k}=w.target;a(L=>{const q=[...L];return q[C].from.passport=k,q})},sx:{"& .MuiInputBase-input::placeholder":{fontSize:14},"& .Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}}})}),e.jsx(t,{sx:{flexShrink:0,mx:1,width:65,height:16},children:e.jsx(Le,{})}),e.jsx(t,{sx:{flexGrow:1,flexBasis:1},children:e.jsx(M,{fullWidth:!0,size:"small",select:!0,value:j.to.role,onChange:w=>{a(k=>{const L=[...k];return L[C].to.role=w.target.value,L})},variant:"outlined",children:i.filter(w=>w.name!=="owner").map(w=>e.jsx(X,{value:w.name,"data-cy":`passport-mapping-select-option-${w.name}`,children:e.jsx("span",{children:w.title||w.name})},w.name))})})]}),e.jsx(t,{sx:{flexShrink:0},children:e.jsx(O,{onClick:()=>{a(w=>{const k=[...w];return k.splice(C,1),k})},size:"large",children:e.jsx(ce,{})})})]},`mapping-${C}`)),!x.length&&e.jsx(t,{sx:{my:2,color:"text.secondary",fontSize:"16px"},children:e.jsx(re,{children:l("common.empty")})})]})]})})})}Ne.propTypes={onCancel:S.func.isRequired,onSuccess:S.func.isRequired,trustedPassports:S.array,data:S.object};const Ls=_.div`
90
+ `,Pe=10,ke=1;function Re({passport:c}){const{api:s}=P(),{teamDid:p}=z(),{t:u,locale:f}=A(),[i,d]=b.useState({pageSize:Pe,page:ke}),{data:l,loading:r}=V(async()=>{const x={teamDid:p,query:{passportId:c.id},paging:{page:i.page,pageSize:i.pageSize}},a=await s.getPassportLogs({input:x});return{logs:a.passportLogs||[],total:a.paging.total}},{refreshDeps:[i.page,i.pageSize],onError:x=>D.error(x.message)}),n=b.useMemo(()=>l?.logs||[],[l?.logs]),h=x=>x.action===se.APPROVE||x.action===se.REVOKE?x?.metadata?.operator?.fullName?`${u("common.operator")}: ${x?.metadata?.operator?.fullName}`:null:x.action===se.ISSUE&&x.metadata?.action===is.ISSUE_ON_INVITE?x?.metadata?.inviter?.fullName?`${u("common.inviter")}: ${x?.metadata?.inviter?.fullName}`:null:`passportId: ${x.passportId}`,m=b.useMemo(()=>[{label:u("common.action"),name:"action",options:{customBodyRender:(x,{rowIndex:a})=>{const o=n[a];return e.jsx(H,{title:h(o),children:`${x} ${o.metadata?.action?`(${o.metadata.action})`:""}`})}}},{label:"IP",name:"operatorIp",options:{customBodyRender:x=>e.jsx(t,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsx("span",{children:x||"-"})})}},{label:"UA",width:250,name:"operatorUa",options:{customBodyRender:(x,{rowIndex:a})=>{const o=n[a];return e.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1},children:[o.operatorUa&&e.jsx(t,{children:xs(o.operatorUa)}),o.operatorUa&&e.jsx(H,{title:o.operatorUa,children:e.jsx(He,{fontSize:"small",color:"action",sx:{fontSize:16,cursor:"pointer"}})})]})}}},{label:u("common.createdAt"),name:"createdAt",options:{customBodyRender:x=>ns(x,f)}}],[u,f,n]),g=({page:x,rowsPerPage:a})=>{i.pageSize!==a?d(o=>({...o,pageSize:a,page:1})):i.page!==x+1&&d(o=>({...o,page:x+1}))},T={sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,search:!1,page:i.page-1,rowsPerPage:i.pageSize,count:l?.total||0};return r?e.jsx(t,{sx:{py:2},children:e.jsx(G,{direction:"row",spacing:1,sx:{position:"relative",pb:2},children:e.jsx(F,{})})}):e.jsx(t,{children:e.jsx(ae,{className:"logs-table",verticalKeyWidth:100,locale:f,data:n,columns:m,options:T,loading:r,onChange:g})})}Re.propTypes={passport:S.object.isRequired};function Ae({passport:c,onSwitchPassport:s}){const{api:p}=P(),{teamDid:u}=z(),{t:f,locale:i}=A(),[d,l]=b.useState({pageSize:Pe,page:ke}),{data:r,loading:n}=V(async()=>{const a={teamDid:u,passportId:c.parentDid,paging:{page:d.page,pageSize:d.pageSize}},o=await p.getRelatedPassports({input:a});return{passports:o.passports||[],total:o.paging.total}},{refreshDeps:[d.page,d.pageSize],onError:a=>D.error(a.message)}),h=b.useMemo(()=>r?.passports||[],[r?.passports]),m=b.useMemo(()=>[{label:f("team.passport.role"),name:"role",options:{customBodyRender:ne}},{label:f("team.passport.owner"),name:"user",options:{customBodyRender:ie}},{label:f("team.passport.status"),name:"status",options:{customBodyRender:le}},{label:f("team.member.lastLogin"),name:"lastLoginAt",options:{customBodyRender:a=>ve(a,i)}},{label:f("blocklet.overview.source"),name:"source",options:{customBodyRender:X}}],[f,i]),g=({page:a,rowsPerPage:o})=>{d.pageSize!==o?l(v=>({...v,pageSize:o,page:1})):d.page!==a+1&&l(v=>({...v,page:a+1}))},T=b.useRef(null),x={sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,search:!1,page:d.page-1,rowsPerPage:d.pageSize,count:r?.total||0,onRowClick(a,{dataIndex:o},v){if(T.current?.contains(v.target)){const j=h[o];s(j)}}};return n?e.jsx(t,{sx:{py:2},children:e.jsx(G,{direction:"row",spacing:1,sx:{position:"relative",pb:2},children:e.jsx(F,{})})}):e.jsxs(G,{spacing:1,children:[e.jsx(Ue,{severity:"warning",children:f("team.passport.relatedDescription")}),e.jsx(t,{ref:T,sx:{".MuiTableRow-root":{cursor:"pointer"}},children:e.jsx(ae,{className:"related-table",verticalKeyWidth:100,locale:i,data:h.filter(a=>a.id!==c.id),columns:m,options:x,loading:n,onChange:g})})]})}Ae.propTypes={passport:S.object.isRequired,onSwitchPassport:S.func.isRequired};function de({onCancel:c,onSuccess:s}){const{api:p}=P(),{blocklet:u}=ls(),{t:f}=A(),[i,d]=b.useState(!1),l=(u.environments.find(g=>g.key==="BLOCKLET_PASSPORT_COLOR")||{}).value||"auto",r=l==="auto"?Ss(u.appDid):l,[n,h]=b.useState(r),m=async()=>{const g=[{key:ds.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_PASSPORT_COLOR,value:n}];try{d(!0),await p.configBlocklet({input:{did:u.meta.did,configs:g}}),s()}catch(T){D.error(T.message)}finally{d(!1)}};return e.jsx($,{title:f("team.passport.color"),onClose:c,open:!0,fullWidth:!0,actions:e.jsxs(e.Fragment,{children:[e.jsx(N,{onClick:c,color:"inherit",children:f("common.cancel")}),e.jsxs(N,{onClick:m,color:"primary",disabled:i,variant:"contained",autoFocus:!0,"data-cy":"color-btn-confirm",children:[i&&e.jsx(F,{size:16}),f("common.save")]})]}),children:e.jsxs(t,{className:"dialog-content",sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:[e.jsx(bs,{disableAlpha:!0,color:n,onChange:g=>h(g.hex)}),e.jsx("div",{style:{width:220,marginLeft:24},dangerouslySetInnerHTML:{__html:vs({scope:"passport",role:"owner",title:"Owner",issuer:cs.getDisplayName(u),issuerDid:u.appDid,ownerName:"Your Name",ownerDid:u.appDid,preferredColor:n})}})]})})}const Ps=_(de,"mutate_team"),ks=_(de,"",J);function Rs(c){const{inService:s}=P();return s?e.jsx(ks,{...c}):e.jsx(Ps,{...c})}de.propTypes={onCancel:S.func.isRequired,onSuccess:S.func.isRequired};var Le=function(s){return e.jsx("svg",{...s,children:e.jsx("path",{d:"M64.707 8.707a1 1 0 0 0 0-1.414L58.343.929a1 1 0 1 0-1.414 1.414L62.586 8l-5.657 5.657a1 1 0 0 0 1.414 1.414l6.364-6.364ZM0 9h64V7H0v2Z",fill:"#666"})})};Le.defaultProps={width:"65",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg"};const As=(c,s)=>c?!s.some(p=>!p.from.passport||!p.to.role):!1;function Ne({onCancel:c,onSuccess:s,data:p={},trustedPassports:u=[]}){const{api:f}=P(),{roles:i,teamDid:d}=z(),{t:l}=A(),[r,n]=b.useState(!1),[h,m]=b.useState(p.issuerDid||""),[g,T]=b.useState(p.remark||""),[x,a]=b.useState(K(p.mappings)||[]),o=u.findIndex(j=>j.issuerDid===p.issuerDid),v=async()=>{if(r)return;const j={issuerDid:h,remark:g,mappings:x.map(w=>({...w,to:{...w.to,ttl:w.to.ttl||0}}))},C=[...u];o===-1?C.unshift(j):C[o]=j;try{n(!0),await f.configTrustedPassports({input:{teamDid:d,trustedPassports:C}}),await Y(800),n(!1),D.success(l("common.saveSuccess")),s()}catch(w){n(!1),D.error(te(w))}};return e.jsx($,{title:l("team.passport.trustedIssuers"),open:!0,showCloseButton:!1,PaperProps:{style:{minHeight:"80vh"}},fullWidth:!0,prepend:e.jsx(O,{onClick:c,"data-cy":"trusted-issuer-close",size:"large",children:e.jsx(ge,{})}),actions:e.jsxs(e.Fragment,{children:[e.jsx(N,{onClick:c,color:"inherit",children:l("common.cancel")}),e.jsxs(N,{onClick:()=>v(),color:"primary",disabled:!As(h,x)||!g||r,variant:"contained",autoFocus:!0,"data-cy":"save-mapping",children:[r&&e.jsx(F,{size:16}),l("common.save")]})]}),children:e.jsx(Ls,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx(M,{fullWidth:!0,"data-cy":"input-issuer-did",placeholder:l("team.passport.issuerDid"),value:h,onChange:j=>{m(j.target.value)}}),e.jsx(M,{style:{marginTop:16},fullWidth:!0,"data-cy":"input-issuer-remark",placeholder:l("common.remark"),value:g,onChange:j=>{T(j.target.value)}}),e.jsxs(t,{sx:{mt:"30px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(t,{className:"dialog-h1",children:l("team.passport.mappingRule")}),e.jsx(t,{children:e.jsx(N,{variant:"outlined",color:"primary","data-cy":"add-mapping",onClick:()=>{a(j=>{const C=[...j];return C.unshift({from:{passport:""},to:{role:ps.GUEST}}),C})},children:l("team.add")})})]}),e.jsxs(t,{className:"list",sx:{mt:-.5},children:[x.map((j,C)=>e.jsxs(t,{className:"mapping-item",sx:{display:"flex",alignItems:"center",justifyContent:"space-between",my:1},children:[e.jsxs(t,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[e.jsx(t,{sx:{flexGrow:1,flexBasis:1},children:e.jsx(M,{fullWidth:!0,size:"small","data-cy":`input-${C}-from`,placeholder:"Issuer’s Passport Name/ID *",value:j.from.passport,onChange:w=>{const{value:k}=w.target;a(L=>{const q=[...L];return q[C].from.passport=k,q})},sx:{"& .MuiInputBase-input::placeholder":{fontSize:14},"& .Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}}})}),e.jsx(t,{sx:{flexShrink:0,mx:1,width:65,height:16},children:e.jsx(Le,{})}),e.jsx(t,{sx:{flexGrow:1,flexBasis:1},children:e.jsx(M,{fullWidth:!0,size:"small",select:!0,value:j.to.role,onChange:w=>{a(k=>{const L=[...k];return L[C].to.role=w.target.value,L})},variant:"outlined",children:i.filter(w=>w.name!=="owner").map(w=>e.jsx(Z,{value:w.name,"data-cy":`passport-mapping-select-option-${w.name}`,children:e.jsx("span",{children:w.title||w.name})},w.name))})})]}),e.jsx(t,{sx:{flexShrink:0},children:e.jsx(O,{onClick:()=>{a(w=>{const k=[...w];return k.splice(C,1),k})},size:"large",children:e.jsx(ce,{})})})]},`mapping-${C}`)),!x.length&&e.jsx(t,{sx:{my:2,color:"text.secondary",fontSize:"16px"},children:e.jsx(re,{children:l("common.empty")})})]})]})})})}Ne.propTypes={onCancel:S.func.isRequired,onSuccess:S.func.isRequired,trustedPassports:S.array,data:S.object};const Ls=W.div`
91
91
  .dialog-h1 {
92
92
  font-size: 18px;
93
93
  }
@@ -99,7 +99,7 @@ import{r as b,g as _e,a as $e}from"./vendor-react-DX7tU9aY.js";import{i as qe,r
99
99
  }
100
100
  }
101
101
  }
102
- `;function pe({onCancel:c,hasPermission:s=!1}){const{api:p}=P(),{teamDid:u,trustedPassports:f}=z(),{t:i}=A(),[d,l]=b.useState(null),[r,n]=b.useState(!1),[h,m]=b.useState(!1),[g,T]=b.useState(""),x=async o=>{if(r)return;const v=f.findIndex(C=>C.issuerDid===o);v===-1&&D.error("Cannot find passports");const j=[...f];j.splice(v,1);try{n(!0),await p.configTrustedPassports({input:{teamDid:u,trustedPassports:j}}),await Y(800),n(!1),D.success(i("common.saveSuccess")),l(!1)}catch(C){n(!1),D.error(C.message)}},a=f.filter(o=>!g||o.issuerDid.toLowerCase().includes(g.toLowerCase()));return e.jsxs(W,{title:i("team.passport.trustedIssuers"),open:!0,onClose:c,fullWidth:!0,PaperProps:{style:{minHeight:"80vh"}},children:[e.jsx(Bs,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx("div",{className:"dialog-h1",children:i("team.passport.trustedPassportIssuers")}),e.jsx(Te,{sx:{mt:3},actions:e.jsxs(e.Fragment,{children:[e.jsx(je,{options:{searchPlaceholder:i("team.passport.searchIssuerDid"),searchDebounceTime:600},search:g,searchText:g,searchTextUpdate:T,searchClose:()=>T(""),onSearchOpen:()=>{}}),s&&e.jsxs(N,{variant:"contained",color:"primary","data-cy":"add-trusted-issuer",onClick:()=>m({mode:"add"}),children:[e.jsx(ye,{style:{fontSize:16,marginRight:4}}),i("team.add")]})]})}),e.jsxs("div",{className:"list",children:[a.map(o=>e.jsxs(t,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mt:"20px"},children:[e.jsxs(t,{sx:{flexShrink:0},children:[e.jsx(oe,{copyable:!1,size:16,did:ts(o.issuerDid),showDidLogo:!1}),!!o.remark&&e.jsx(t,{sx:{fontSize:12,maxWidth:"300px"},children:o.remark})]}),e.jsx(t,{sx:{color:"gray",ml:"28px",flexGrow:1},children:o.mappings&&o.mappings.length?`${o.mappings.length} ${i("team.passport.mappingRule")}`:i("team.passport.defaultRule")}),e.jsxs(t,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:[e.jsx(O,{onClick:()=>m({mode:"update",data:K(o)}),"data-cy":"edit-mapping-rule",size:"large",children:e.jsx(Ce,{})}),e.jsx(O,{"data-cy":"delete-mapping-rule",onClick:()=>l({title:i("common.delete"),description:i("common.delConfirmDescription",{data:o.issuerDid}),confirm:i("common.delConfirm"),cancel:i("common.cancel"),onConfirm:()=>x(o.issuerDid),onCancel:()=>{n(!1),l(null)}}),size:"large",children:e.jsx(ce,{})})]})]},o.issuerDid)),!f.length&&e.jsx(re,{children:i("common.empty")})]})]})}),h&&e.jsx(Ne,{mode:h.mode,data:h.data,trustedPassports:K(f),onCancel:()=>m(null),onSuccess:()=>{m(null)}}),d&&e.jsx(we,{title:d.title,description:d.description,confirm:d.confirm,cancel:d.cancel,params:d.params,onConfirm:d.onConfirm,onCancel:d.onCancel})]})}pe.propTypes={onCancel:S.func.isRequired,hasPermission:S.bool};const Ns=$(pe,"mutate_team"),zs=$(pe,"",J);function Fs(c){const{inService:s}=P();return s?e.jsx(zs,{...c}):e.jsx(Ns,{...c})}const Bs=_.div`
102
+ `;function pe({onCancel:c,hasPermission:s=!1}){const{api:p}=P(),{teamDid:u,trustedPassports:f}=z(),{t:i}=A(),[d,l]=b.useState(null),[r,n]=b.useState(!1),[h,m]=b.useState(!1),[g,T]=b.useState(""),x=async o=>{if(r)return;const v=f.findIndex(C=>C.issuerDid===o);v===-1&&D.error("Cannot find passports");const j=[...f];j.splice(v,1);try{n(!0),await p.configTrustedPassports({input:{teamDid:u,trustedPassports:j}}),await Y(800),n(!1),D.success(i("common.saveSuccess")),l(!1)}catch(C){n(!1),D.error(C.message)}},a=f.filter(o=>!g||o.issuerDid.toLowerCase().includes(g.toLowerCase()));return e.jsxs($,{title:i("team.passport.trustedIssuers"),open:!0,onClose:c,fullWidth:!0,PaperProps:{style:{minHeight:"80vh"}},children:[e.jsx(Bs,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx("div",{className:"dialog-h1",children:i("team.passport.trustedPassportIssuers")}),e.jsx(Te,{sx:{mt:3},actions:e.jsxs(e.Fragment,{children:[e.jsx(je,{options:{searchPlaceholder:i("team.passport.searchIssuerDid"),searchDebounceTime:600},search:g,searchText:g,searchTextUpdate:T,searchClose:()=>T(""),onSearchOpen:()=>{}}),s&&e.jsxs(N,{variant:"contained",color:"primary","data-cy":"add-trusted-issuer",onClick:()=>m({mode:"add"}),children:[e.jsx(ye,{style:{fontSize:16,marginRight:4}}),i("team.add")]})]})}),e.jsxs("div",{className:"list",children:[a.map(o=>e.jsxs(t,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mt:"20px"},children:[e.jsxs(t,{sx:{flexShrink:0},children:[e.jsx(oe,{copyable:!1,size:16,did:ts(o.issuerDid),showDidLogo:!1}),!!o.remark&&e.jsx(t,{sx:{fontSize:12,maxWidth:"300px"},children:o.remark})]}),e.jsx(t,{sx:{color:"gray",ml:"28px",flexGrow:1},children:o.mappings&&o.mappings.length?`${o.mappings.length} ${i("team.passport.mappingRule")}`:i("team.passport.defaultRule")}),e.jsxs(t,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:[e.jsx(O,{onClick:()=>m({mode:"update",data:K(o)}),"data-cy":"edit-mapping-rule",size:"large",children:e.jsx(Ce,{})}),e.jsx(O,{"data-cy":"delete-mapping-rule",onClick:()=>l({title:i("common.delete"),description:i("common.delConfirmDescription",{data:o.issuerDid}),confirm:i("common.delConfirm"),cancel:i("common.cancel"),onConfirm:()=>x(o.issuerDid),onCancel:()=>{n(!1),l(null)}}),size:"large",children:e.jsx(ce,{})})]})]},o.issuerDid)),!f.length&&e.jsx(re,{children:i("common.empty")})]})]})}),h&&e.jsx(Ne,{mode:h.mode,data:h.data,trustedPassports:K(f),onCancel:()=>m(null),onSuccess:()=>{m(null)}}),d&&e.jsx(we,{title:d.title,description:d.description,confirm:d.confirm,cancel:d.cancel,params:d.params,onConfirm:d.onConfirm,onCancel:d.onCancel})]})}pe.propTypes={onCancel:S.func.isRequired,hasPermission:S.bool};const Ns=_(pe,"mutate_team"),zs=_(pe,"",J);function Fs(c){const{inService:s}=P();return s?e.jsx(zs,{...c}):e.jsx(Ns,{...c})}const Bs=W.div`
103
103
  .list {
104
104
  .MuiIconButton-root {
105
105
  svg {
@@ -107,7 +107,7 @@ import{r as b,g as _e,a as $e}from"./vendor-react-DX7tU9aY.js";import{i as qe,r
107
107
  }
108
108
  }
109
109
  }
110
- `;var Es=Cs();const fe=_e(Es);function ze({onCancel:c,onSuccess:s,data:p={},trustedFactories:u=[]}){const{api:f}=P(),{roles:i,teamDid:d}=z(),{t:l}=A(),[r,n]=Ts({loading:!1,fetching:!1,fetched:[],errored:[],factoryAddress:p.factoryAddress||"",remark:p.remark||"",role:p.passport?.role||"member",ttlPolicy:p.passport?.ttlPolicy||"never",ttl:fe(+p.passport?.ttl||365*24*60*60*1e3),error:""}),h=u.findIndex(a=>a.factoryAddress===p.factoryAddress),m=async()=>{if(r.loading)return;const{factoryAddress:a,remark:o,role:v,ttlPolicy:j,ttl:C}=r,w={factoryAddress:a,remark:o,passport:{role:v,ttlPolicy:j,ttl:j==="never"?0:fe(C)}},k=[...u];h===-1?k.unshift(w):k[h]=w;try{n({loading:!0}),await f.configTrustedFactories({input:{teamDid:d,trustedFactories:k}}),await Y(800),D.success(l("common.saveSuccess")),s()}catch(L){console.error(L),D.error(te(L))}finally{n({loading:!1})}};b.useEffect(()=>{const a=r.fetched.find(v=>v.address===r.factoryAddress),o=r.errored.find(v=>v.address===r.factoryAddress);as(r.factoryAddress)&&!r.fetching&&!a&&!o&&(n({fetching:!0}),us(ms).getFactoryState({address:r.factoryAddress}).then(j=>{j.state?n({fetching:!1,fetched:[...r.fetched.filter(C=>C.address!==r.factoryAddress),j.state],remark:j.state.name}):n({fetching:!1,errored:[...r.errored.filter(C=>C.address!==r.factoryAddress),{address:r.factoryAddress}],error:l("team.passport.factory404",r)})}).catch(j=>{console.error(j),n({fetching:!1,error:te(j)})}))},[r.factoryAddress,r.fetching]);let g=r.error;const T=r.factoryAddress?r.errored.find(a=>a.address===r.factoryAddress):null;!g&&T&&(g=l("team.passport.factory404",r));const x=r.factoryAddress?r.fetched.find(a=>a.address===r.factoryAddress):null;return!g&&x&&(g=x.description),g||(g=l("team.passport.factoryAddressTip")),e.jsx(W,{title:l("team.passport.trustedFactories"),open:!0,showCloseButton:!1,PaperProps:{style:{minHeight:"80vh"}},fullWidth:!0,prepend:e.jsx(O,{onClick:c,"data-cy":"close-trusted-factory",size:"large",children:e.jsx(ge,{})}),actions:e.jsxs(e.Fragment,{children:[e.jsx(N,{onClick:c,color:"inherit",children:l("common.cancel")}),e.jsxs(N,{onClick:()=>m(),color:"primary",disabled:!r.factoryAddress||!r.remark||!r.role||r.loading||r.error||T,variant:"contained",autoFocus:!0,"data-cy":"save-trusted-factory",children:[r.loading&&e.jsx(F,{size:16}),l("common.save")]})]}),children:e.jsx(Ms,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx(M,{fullWidth:!0,error:!!r.error||!!T,"data-cy":"input-factory-address",label:l("team.passport.factoryAddress"),helperText:g,value:r.factoryAddress,onChange:a=>{n({factoryAddress:a.target.value,error:""})},slotProps:{input:{endAdornment:r.fetching?e.jsx(Ye,{position:"end",children:e.jsx(F,{size:16})}):null}}}),e.jsx(M,{style:{marginTop:32},fullWidth:!0,"data-cy":"input-factory-remark",label:l("common.remark"),value:r.remark,onChange:a=>{n({remark:a.target.value})}}),e.jsx(M,{style:{marginTop:32},fullWidth:!0,"data-cy":"input-passport-role",label:l("team.passport.role"),select:!0,value:r.role,onChange:a=>{n({role:a.target.value})},variant:"outlined",children:i.filter(a=>a.name!=="owner").map(a=>e.jsx(X,{value:a.name,"data-cy":`passport-role-select-option-${a.name}`,children:e.jsx("span",{children:a.title||a.name})},a.name))}),e.jsxs("div",{style:{marginTop:32},children:[e.jsx(Ve,{children:l("team.passport.ttl")}),e.jsxs(Xe,{color:"primary",size:"small",value:r.ttlPolicy,exclusive:!0,style:{marginTop:16},onChange:(a,o)=>n({ttlPolicy:o}),"data-cy":"input-passport-ttl-since","aria-label":"Expire Policy",children:[e.jsx(Q,{value:"never","data-cy":"input-passport-ttl-never",children:e.jsx(H,{title:l("team.passport.ttlNeverTip"),children:e.jsx(E,{children:l("team.passport.ttlNever")})})}),e.jsx(Q,{value:"mint","data-cy":"input-passport-ttl-mint",children:e.jsx(H,{title:l("team.passport.ttlMintTip"),children:e.jsx(E,{children:l("team.passport.ttlMint")})})}),e.jsx(Q,{value:"exchange","data-cy":"input-passport-ttl-exchange",children:e.jsx(H,{title:l("team.passport.ttlExchangeTip"),children:e.jsx(E,{children:l("team.passport.ttlExchange")})})})]}),r.ttlPolicy!=="never"&&e.jsxs(e.Fragment,{children:[e.jsx(Ze,{fullWidth:!0,type:"text",style:{marginTop:16},"data-cy":"input-passport-ttl",value:r.ttl,onChange:a=>{n({ttl:a.target.value})}}),e.jsx(Je,{children:l("team.passport.ttlTip")})]})]})]})})})}ze.propTypes={onCancel:S.func.isRequired,onSuccess:S.func.isRequired,trustedFactories:S.array,data:S.object};const Ms=_.div`
110
+ `;var Es=Cs();const fe=We(Es);function ze({onCancel:c,onSuccess:s,data:p={},trustedFactories:u=[]}){const{api:f}=P(),{roles:i,teamDid:d}=z(),{t:l}=A(),[r,n]=Ts({loading:!1,fetching:!1,fetched:[],errored:[],factoryAddress:p.factoryAddress||"",remark:p.remark||"",role:p.passport?.role||"member",ttlPolicy:p.passport?.ttlPolicy||"never",ttl:fe(+p.passport?.ttl||365*24*60*60*1e3),error:""}),h=u.findIndex(a=>a.factoryAddress===p.factoryAddress),m=async()=>{if(r.loading)return;const{factoryAddress:a,remark:o,role:v,ttlPolicy:j,ttl:C}=r,w={factoryAddress:a,remark:o,passport:{role:v,ttlPolicy:j,ttl:j==="never"?0:fe(C)}},k=[...u];h===-1?k.unshift(w):k[h]=w;try{n({loading:!0}),await f.configTrustedFactories({input:{teamDid:d,trustedFactories:k}}),await Y(800),D.success(l("common.saveSuccess")),s()}catch(L){console.error(L),D.error(te(L))}finally{n({loading:!1})}};b.useEffect(()=>{const a=r.fetched.find(v=>v.address===r.factoryAddress),o=r.errored.find(v=>v.address===r.factoryAddress);as(r.factoryAddress)&&!r.fetching&&!a&&!o&&(n({fetching:!0}),us(ms).getFactoryState({address:r.factoryAddress}).then(j=>{j.state?n({fetching:!1,fetched:[...r.fetched.filter(C=>C.address!==r.factoryAddress),j.state],remark:j.state.name}):n({fetching:!1,errored:[...r.errored.filter(C=>C.address!==r.factoryAddress),{address:r.factoryAddress}],error:l("team.passport.factory404",r)})}).catch(j=>{console.error(j),n({fetching:!1,error:te(j)})}))},[r.factoryAddress,r.fetching]);let g=r.error;const T=r.factoryAddress?r.errored.find(a=>a.address===r.factoryAddress):null;!g&&T&&(g=l("team.passport.factory404",r));const x=r.factoryAddress?r.fetched.find(a=>a.address===r.factoryAddress):null;return!g&&x&&(g=x.description),g||(g=l("team.passport.factoryAddressTip")),e.jsx($,{title:l("team.passport.trustedFactories"),open:!0,showCloseButton:!1,PaperProps:{style:{minHeight:"80vh"}},fullWidth:!0,prepend:e.jsx(O,{onClick:c,"data-cy":"close-trusted-factory",size:"large",children:e.jsx(ge,{})}),actions:e.jsxs(e.Fragment,{children:[e.jsx(N,{onClick:c,color:"inherit",children:l("common.cancel")}),e.jsxs(N,{onClick:()=>m(),color:"primary",disabled:!r.factoryAddress||!r.remark||!r.role||r.loading||r.error||T,variant:"contained",autoFocus:!0,"data-cy":"save-trusted-factory",children:[r.loading&&e.jsx(F,{size:16}),l("common.save")]})]}),children:e.jsx(Ms,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx(M,{fullWidth:!0,error:!!r.error||!!T,"data-cy":"input-factory-address",label:l("team.passport.factoryAddress"),helperText:g,value:r.factoryAddress,onChange:a=>{n({factoryAddress:a.target.value,error:""})},slotProps:{input:{endAdornment:r.fetching?e.jsx(Ye,{position:"end",children:e.jsx(F,{size:16})}):null}}}),e.jsx(M,{style:{marginTop:32},fullWidth:!0,"data-cy":"input-factory-remark",label:l("common.remark"),value:r.remark,onChange:a=>{n({remark:a.target.value})}}),e.jsx(M,{style:{marginTop:32},fullWidth:!0,"data-cy":"input-passport-role",label:l("team.passport.role"),select:!0,value:r.role,onChange:a=>{n({role:a.target.value})},variant:"outlined",children:i.filter(a=>a.name!=="owner").map(a=>e.jsx(Z,{value:a.name,"data-cy":`passport-role-select-option-${a.name}`,children:e.jsx("span",{children:a.title||a.name})},a.name))}),e.jsxs("div",{style:{marginTop:32},children:[e.jsx(Ve,{children:l("team.passport.ttl")}),e.jsxs(Ze,{color:"primary",size:"small",value:r.ttlPolicy,exclusive:!0,style:{marginTop:16},onChange:(a,o)=>n({ttlPolicy:o}),"data-cy":"input-passport-ttl-since","aria-label":"Expire Policy",children:[e.jsx(Q,{value:"never","data-cy":"input-passport-ttl-never",children:e.jsx(H,{title:l("team.passport.ttlNeverTip"),children:e.jsx(E,{children:l("team.passport.ttlNever")})})}),e.jsx(Q,{value:"mint","data-cy":"input-passport-ttl-mint",children:e.jsx(H,{title:l("team.passport.ttlMintTip"),children:e.jsx(E,{children:l("team.passport.ttlMint")})})}),e.jsx(Q,{value:"exchange","data-cy":"input-passport-ttl-exchange",children:e.jsx(H,{title:l("team.passport.ttlExchangeTip"),children:e.jsx(E,{children:l("team.passport.ttlExchange")})})})]}),r.ttlPolicy!=="never"&&e.jsxs(e.Fragment,{children:[e.jsx(Xe,{fullWidth:!0,type:"text",style:{marginTop:16},"data-cy":"input-passport-ttl",value:r.ttl,onChange:a=>{n({ttl:a.target.value})}}),e.jsx(Je,{children:l("team.passport.ttlTip")})]})]})]})})})}ze.propTypes={onCancel:S.func.isRequired,onSuccess:S.func.isRequired,trustedFactories:S.array,data:S.object};const Ms=W.div`
111
111
  .dialog-h1 {
112
112
  font-size: 18px;
113
113
  }
@@ -119,7 +119,7 @@ import{r as b,g as _e,a as $e}from"./vendor-react-DX7tU9aY.js";import{i as qe,r
119
119
  }
120
120
  }
121
121
  }
122
- `;function ue({onCancel:c,hasPermission:s=!1}){const{api:p}=P(),{teamDid:u,trustedFactories:f}=z(),{t:i}=A(),[d,l]=b.useState(null),[r,n]=b.useState(!1),[h,m]=b.useState(null),[g,T]=b.useState(""),x=async o=>{if(!r)try{n(!0),await p.configTrustedFactories({input:{teamDid:u,trustedFactories:f.filter(v=>v.factoryAddress!==o)}}),await Y(800),n(!1),D.success(i("common.saveSuccess")),l(null)}catch(v){n(!1),D.error(v.message)}},a=f.filter(o=>!g||o.factoryAddress.toLowerCase().includes(g.toLowerCase()));return e.jsxs(W,{title:i("team.passport.trustedFactories"),open:!0,onClose:c,fullWidth:!0,PaperProps:{style:{minHeight:"80vh"}},children:[e.jsx($s,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx("div",{className:"dialog-h1",children:i("team.passport.trustedFactoriesTip")}),e.jsx(Te,{sx:{mt:3},actions:e.jsxs(e.Fragment,{children:[e.jsx(je,{options:{searchPlaceholder:i("team.passport.searchFactoryAddress"),searchDebounceTime:600},search:g,searchText:g,searchTextUpdate:T,searchClose:()=>T(""),onSearchOpen:()=>{}}),s&&e.jsxs(N,{variant:"contained",color:"primary",size:"small","data-cy":"add-trusted-factory",onClick:()=>m({mode:"add"}),children:[e.jsx(ye,{style:{fontSize:16,marginRight:4}}),i("team.add")]})]})}),e.jsxs("div",{className:"list",children:[a.map(o=>e.jsxs(t,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mt:"20px"},children:[e.jsxs(t,{sx:{flexGrow:1},children:[e.jsx(oe,{copyable:!1,did:o.factoryAddress,size:16,showDidLogo:!1}),!!o.remark&&e.jsx(t,{sx:{fontSize:12,maxWidth:"300px"},children:o.remark})]}),e.jsx(t,{sx:{color:"gray",mr:"24px"},children:e.jsx(rs,{type:"success",children:o.passport.role})}),e.jsxs(t,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:[e.jsx(O,{onClick:()=>m({mode:"update",data:K(o)}),"data-cy":"edit-trusted-factory",size:"large",children:e.jsx(Ce,{})}),e.jsx(O,{"data-cy":"delete-trusted-factory",onClick:()=>l({title:i("common.delete"),description:i("common.delConfirmDescription",{data:o.factoryAddress}),confirm:i("common.delConfirm"),cancel:i("common.cancel"),onConfirm:()=>x(o.factoryAddress),onCancel:()=>{n(!1),l(null)}}),size:"large",children:e.jsx(ce,{})})]})]},o.factoryAddress)),!f.length&&e.jsx(re,{children:i("common.empty")})]})]})}),h&&e.jsx(ze,{data:h.data,trustedFactories:K(f),onCancel:()=>m(null),onSuccess:()=>{m(null)}}),d&&e.jsx(we,{title:d.title,description:d.description,confirm:d.confirm,cancel:d.cancel,params:d.params,onConfirm:d.onConfirm,onCancel:d.onCancel})]})}ue.propTypes={onCancel:S.func.isRequired,hasPermission:S.bool};const Os=$(ue,"mutate_team"),Ws=$(ue,"",J);function _s(c){const{inService:s}=P();return s?e.jsx(Ws,{...c}):e.jsx(Os,{...c})}const $s=_.div`
122
+ `;function ue({onCancel:c,hasPermission:s=!1}){const{api:p}=P(),{teamDid:u,trustedFactories:f}=z(),{t:i}=A(),[d,l]=b.useState(null),[r,n]=b.useState(!1),[h,m]=b.useState(null),[g,T]=b.useState(""),x=async o=>{if(!r)try{n(!0),await p.configTrustedFactories({input:{teamDid:u,trustedFactories:f.filter(v=>v.factoryAddress!==o)}}),await Y(800),n(!1),D.success(i("common.saveSuccess")),l(null)}catch(v){n(!1),D.error(v.message)}},a=f.filter(o=>!g||o.factoryAddress.toLowerCase().includes(g.toLowerCase()));return e.jsxs($,{title:i("team.passport.trustedFactories"),open:!0,onClose:c,fullWidth:!0,PaperProps:{style:{minHeight:"80vh"}},children:[e.jsx(_s,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx("div",{className:"dialog-h1",children:i("team.passport.trustedFactoriesTip")}),e.jsx(Te,{sx:{mt:3},actions:e.jsxs(e.Fragment,{children:[e.jsx(je,{options:{searchPlaceholder:i("team.passport.searchFactoryAddress"),searchDebounceTime:600},search:g,searchText:g,searchTextUpdate:T,searchClose:()=>T(""),onSearchOpen:()=>{}}),s&&e.jsxs(N,{variant:"contained",color:"primary",size:"small","data-cy":"add-trusted-factory",onClick:()=>m({mode:"add"}),children:[e.jsx(ye,{style:{fontSize:16,marginRight:4}}),i("team.add")]})]})}),e.jsxs("div",{className:"list",children:[a.map(o=>e.jsxs(t,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mt:"20px"},children:[e.jsxs(t,{sx:{flexGrow:1},children:[e.jsx(oe,{copyable:!1,did:o.factoryAddress,size:16,showDidLogo:!1}),!!o.remark&&e.jsx(t,{sx:{fontSize:12,maxWidth:"300px"},children:o.remark})]}),e.jsx(t,{sx:{color:"gray",mr:"24px"},children:e.jsx(rs,{type:"success",children:o.passport.role})}),e.jsxs(t,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:[e.jsx(O,{onClick:()=>m({mode:"update",data:K(o)}),"data-cy":"edit-trusted-factory",size:"large",children:e.jsx(Ce,{})}),e.jsx(O,{"data-cy":"delete-trusted-factory",onClick:()=>l({title:i("common.delete"),description:i("common.delConfirmDescription",{data:o.factoryAddress}),confirm:i("common.delConfirm"),cancel:i("common.cancel"),onConfirm:()=>x(o.factoryAddress),onCancel:()=>{n(!1),l(null)}}),size:"large",children:e.jsx(ce,{})})]})]},o.factoryAddress)),!f.length&&e.jsx(re,{children:i("common.empty")})]})]})}),h&&e.jsx(ze,{data:h.data,trustedFactories:K(f),onCancel:()=>m(null),onSuccess:()=>{m(null)}}),d&&e.jsx(we,{title:d.title,description:d.description,confirm:d.confirm,cancel:d.cancel,params:d.params,onConfirm:d.onConfirm,onCancel:d.onCancel})]})}ue.propTypes={onCancel:S.func.isRequired,hasPermission:S.bool};const Os=_(ue,"mutate_team"),$s=_(ue,"",J);function Ws(c){const{inService:s}=P();return s?e.jsx($s,{...c}):e.jsx(Os,{...c})}const _s=W.div`
123
123
  .list {
124
124
  .MuiIconButton-root {
125
125
  svg {
@@ -127,7 +127,7 @@ import{r as b,g as _e,a as $e}from"./vendor-react-DX7tU9aY.js";import{i as qe,r
127
127
  }
128
128
  }
129
129
  }
130
- `;function Fe({createPassportSvg:c}){const{t:s}=A(),{api:p,inService:u}=P(),{teamDid:f,refresh:i,enablePassportIssuance:d,isNodeTeam:l}=z(),[r,n]=b.useState(!1),[h,m]=b.useState(!1),[g,T]=b.useState(!1),[x,a]=b.useState(!1),[o,v]=b.useState(!1),j=async C=>{if(C.stopPropagation(),!x){a(!0);try{await p.configPassportIssuance({input:{teamDid:f,enable:!d}}),i(),await Y(800),D.success(s("common.configSuccess"))}catch(w){D.error(w.message)}finally{a(!1)}}};return e.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1,ml:1},children:[e.jsx(js,{permission:u?"":"mutate_team",role:u?J:[],children:e.jsx(U,{variant:"outlined",menuButtonProps:{"data-cy":"trusted-issuers-more"},menu:e.jsxs(e.Fragment,{children:[e.jsx(U.Item,{onClick:()=>m(!0),"data-cy":"config-trusted-issuers",children:e.jsxs(t,{children:[s("team.passport.trustedPassportIssuers"),e.jsx(t,{sx:{fontSize:12,color:"#888"},children:s("team.passport.trustedPassportIssuersTip")})]})}),e.jsx(U.Item,{onClick:()=>T(!0),"data-cy":"config-show-trusted-factories",children:e.jsxs(t,{children:[s("team.passport.configFactories"),e.jsx(t,{sx:{fontSize:12,color:"#888"},children:s("team.passport.configFactoriesTip")})]})}),e.jsx(U.Item,{"data-cy":"config-show-issue-passport",onClick:j,children:e.jsxs(t,{sx:{display:"flex",alignItems:"center"},children:[x&&e.jsx(F,{size:16,style:{marginRight:8}}),e.jsxs(t,{children:[s(d?"team.passport.disableIssuance":"team.passport.enableIssuance"),e.jsx(t,{sx:{fontSize:12,color:"#888"},children:s(d?"team.passport.disableIssuanceTip":"team.passport.enableIssuanceTip")})]})]})}),!l&&e.jsx(U.Item,{onClick:()=>n(!0),"data-cy":"config-passport-color",children:e.jsxs(t,{children:[s("team.passport.configColor"),e.jsx(t,{sx:{fontSize:12,color:"#888"},children:s("team.passport.configColorTip")})]})})]}),children:()=>e.jsx(N,{variant:"outlined",onClick:()=>{v(!0)},children:s("team.passport.view")})})}),h&&e.jsx(Fs,{onCancel:()=>m(!1)}),g&&e.jsx(_s,{onCancel:()=>T(!1)}),r&&e.jsx(Rs,{onCancel:()=>n(!1),onSuccess:()=>n(!1)}),o&&e.jsx(W,{open:!0,maxWidth:"lg",onClose:()=>v(!1),onBackdropClick:()=>v(!1),onEscapeKeyDown:()=>v(!1),title:s("team.passport.view"),children:e.jsx(ws,{createPassportSvg:c,onCancel:()=>v(!1)})})]})}Fe.propTypes={createPassportSvg:S.func.isRequired};const xe="$all",he="",Be=$e.memo(({createPassportSvg:c,passport:s,teamDid:p,inService:u})=>e.jsx(t,{sx:{display:"flex"},dangerouslySetInnerHTML:{__html:c({scope:s.scope,role:s.role,title:s.scope==="kyc"?s.name:s.title,issuer:s.issuer&&s.issuer.name,issuerDid:s.issuer&&s.issuer.id,ownerName:s.user?.fullName,ownerDid:s.user?.did,ownerAvatarUrl:s.user?.avatar?Se(s.user?.avatar,p,u):"",revoked:s.revoked,width:"36px",extra:s?.expirationDate?{key:"Exp",value:be(s.expirationDate).format("YYYY-MM-DD HH:mm:ss")}:null})}}));Be.propTypes={passport:S.object.isRequired,createPassportSvg:S.func.isRequired,teamDid:S.string.isRequired,inService:S.bool.isRequired};function qs({createPassportSvg:c}){const{api:s}=P(),{teamDid:p}=z(),{t:u,locale:f}=A(),{SYSTEM_ROLES:i}=hs(),{inService:d}=P(),[l,r]=b.useState(!1),n=`passports-${p}`,h=os(n),[m,g]=b.useState({role:xe,status:he,searchText:h.searchText||"",pageSize:h.rowsPerPage||10,page:h.page?h.page+1:1}),{data:T,loading:x}=V(async()=>(await s.getPassportRoleCounts({input:{teamDid:p}})).counts||[],{refreshDeps:[p]}),{data:a,loading:o}=V(async()=>{const y={};m.role!==xe&&(y.role=m.role),m.status&&(y.status=m.status);const I=await s.getPassportsByRole({input:{teamDid:p,query:y,paging:{page:m.page,pageSize:m.pageSize}}});return{passports:I.passports||[],total:I.paging.total}},{refreshDeps:[m.role,m.status,m.page,m.pageSize],onError:y=>D.error(y.message)}),v=y=>T?.find(R=>R.key===y)?.value||0,j=b.useMemo(()=>Object.keys(i).map(y=>({name:y,title:i[y],num:v(y)})),[T,v]),C=b.useMemo(()=>[{label:u("team.passport.role"),name:"role",options:{customBodyRender:(y,{rowIndex:I})=>{const R=a?.passports[I];return e.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(Be,{createPassportSvg:c,passport:R,teamDid:p}),e.jsx(t,{children:ne(R.title)})]})}}},{label:u("team.passport.owner"),name:"user",options:{customBodyRender:y=>ie(y,d)}},{label:u("team.passport.status"),name:"status",options:{customBodyRender:le}},{label:u("team.member.lastLogin"),name:"lastLoginAt",options:{customBodyRender:y=>ve(y,f)}},{label:u("common.address"),name:"id",options:{customBodyRender:gs}},{label:u("blocklet.overview.source"),name:"source",options:{customBodyRender:(y,{rowIndex:I})=>{const R=a?.passports[I];return R.parentDid?Z("recover"):Z(R.source)}}}],[u,f,a?.passports,p,c,d]),w=y=>{g(I=>({...I,role:y,page:1}))},k=({page:y,rowsPerPage:I,searchText:R})=>{m.pageSize!==I?g(B=>({...B,searchText:"",pageSize:I,page:1})):m.page!==y+1?g(B=>({...B,searchText:"",page:y+1})):m.searchText!==R&&g(B=>({...B,searchText:R,page:1}))},L=b.useRef(null),q=a?.passports||[],Ee=m.searchText?q.filter(y=>y.id.includes(m.searchText)||(y?.user?.fullName||"").includes(m.searchText)):q,Me={sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,onRowClick(y,{dataIndex:I},R){if(L.current?.contains(R.target)){const B=a?.passports[I];r(B)}},page:m.page-1,rowsPerPage:m.pageSize,count:a?.total||0,searchDebounceTime:600},Oe=y=>{g(I=>({...I,status:y.target.value,page:1}))},We=e.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsxs(t,{sx:{fontSize:16,fontWeight:400},children:[u("team.passport.status"),":"]}),e.jsxs(Qe,{size:"small",value:m.status,onChange:Oe,displayEmpty:!0,sx:{minWidth:120,height:36,".MuiSelect-select":{py:.5,px:1.5}},children:[e.jsx(X,{value:he,children:u("common.all")}),Object.values(fs).map(y=>e.jsx(X,{value:y,sx:{py:1},children:u(`team.passport.statusMap.${y}`)},y))]})]});return x?e.jsx(t,{sx:{py:2},children:e.jsx(G,{direction:"row",spacing:1,sx:{justifyContent:"center",alignItems:"center",position:"relative",pb:2},children:e.jsx(F,{})})}):e.jsxs(Us,{children:[e.jsxs(t,{className:"main",sx:{display:"flex",mt:0,gap:3},children:[e.jsx(t,{className:"left",children:e.jsx(t,{className:"tabs",children:j.map(y=>e.jsxs(t,{className:`tab ${m.role===y.name?"active":""}`,onClick:()=>w(y.name),children:[e.jsx("span",{className:"text",children:y.title}),e.jsx(t,{sx:{color:"text.secondary"},children:y.num})]},y.name))})}),e.jsx(t,{ref:L,className:"right",children:e.jsx(ae,{className:"main-table",verticalKeyWidth:100,locale:f,durable:n,durableKeys:["page","rowsPerPage"],data:Ee,columns:C,options:Me,loading:o,onChange:k,customButtons:[e.jsx(Fe,{createPassportSvg:c})],title:We})})]}),l&&e.jsx(Ie,{createPassportSvg:c,onCancel:()=>r(null),passport:l,onSwitchPassport:r})]})}qs.propTypes={createPassportSvg:S.func.isRequired};const Us=es(t)`
130
+ `;function Fe({createPassportSvg:c}){const{t:s}=A(),{api:p,inService:u}=P(),{teamDid:f,refresh:i,enablePassportIssuance:d,isNodeTeam:l}=z(),[r,n]=b.useState(!1),[h,m]=b.useState(!1),[g,T]=b.useState(!1),[x,a]=b.useState(!1),[o,v]=b.useState(!1),j=async C=>{if(C.stopPropagation(),!x){a(!0);try{await p.configPassportIssuance({input:{teamDid:f,enable:!d}}),i(),await Y(800),D.success(s("common.configSuccess"))}catch(w){D.error(w.message)}finally{a(!1)}}};return e.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1,ml:1},children:[e.jsx(js,{permission:u?"":"mutate_team",role:u?J:[],children:e.jsx(U,{variant:"outlined",menuButtonProps:{"data-cy":"trusted-issuers-more"},menu:e.jsxs(e.Fragment,{children:[e.jsx(U.Item,{onClick:()=>m(!0),"data-cy":"config-trusted-issuers",children:e.jsxs(t,{children:[s("team.passport.trustedPassportIssuers"),e.jsx(t,{sx:{fontSize:12,color:"#888"},children:s("team.passport.trustedPassportIssuersTip")})]})}),e.jsx(U.Item,{onClick:()=>T(!0),"data-cy":"config-show-trusted-factories",children:e.jsxs(t,{children:[s("team.passport.configFactories"),e.jsx(t,{sx:{fontSize:12,color:"#888"},children:s("team.passport.configFactoriesTip")})]})}),e.jsx(U.Item,{"data-cy":"config-show-issue-passport",onClick:j,children:e.jsxs(t,{sx:{display:"flex",alignItems:"center"},children:[x&&e.jsx(F,{size:16,style:{marginRight:8}}),e.jsxs(t,{children:[s(d?"team.passport.disableIssuance":"team.passport.enableIssuance"),e.jsx(t,{sx:{fontSize:12,color:"#888"},children:s(d?"team.passport.disableIssuanceTip":"team.passport.enableIssuanceTip")})]})]})}),!l&&e.jsx(U.Item,{onClick:()=>n(!0),"data-cy":"config-passport-color",children:e.jsxs(t,{children:[s("team.passport.configColor"),e.jsx(t,{sx:{fontSize:12,color:"#888"},children:s("team.passport.configColorTip")})]})})]}),children:()=>e.jsx(N,{variant:"outlined",onClick:()=>{v(!0)},children:s("team.passport.view")})})}),h&&e.jsx(Fs,{onCancel:()=>m(!1)}),g&&e.jsx(Ws,{onCancel:()=>T(!1)}),r&&e.jsx(Rs,{onCancel:()=>n(!1),onSuccess:()=>n(!1)}),o&&e.jsx($,{open:!0,maxWidth:"lg",onClose:()=>v(!1),onBackdropClick:()=>v(!1),onEscapeKeyDown:()=>v(!1),title:s("team.passport.view"),children:e.jsx(ws,{createPassportSvg:c,onCancel:()=>v(!1)})})]})}Fe.propTypes={createPassportSvg:S.func.isRequired};const xe="$all",he="",Be=_e.memo(({createPassportSvg:c,passport:s,teamDid:p,inService:u})=>e.jsx(t,{sx:{display:"flex"},dangerouslySetInnerHTML:{__html:c({scope:s.scope,role:s.role,title:s.scope==="kyc"?s.name:s.title,issuer:s.issuer&&s.issuer.name,issuerDid:s.issuer&&s.issuer.id,ownerName:s.user?.fullName,ownerDid:s.user?.did,ownerAvatarUrl:s.user?.avatar?Se(s.user?.avatar,p,u):"",revoked:s.revoked,width:"36px",extra:s?.expirationDate?{key:"Exp",value:be(s.expirationDate).format("YYYY-MM-DD HH:mm:ss")}:null})}}));Be.propTypes={passport:S.object.isRequired,createPassportSvg:S.func.isRequired,teamDid:S.string.isRequired,inService:S.bool.isRequired};function qs({createPassportSvg:c}){const{api:s}=P(),{teamDid:p}=z(),{t:u,locale:f}=A(),{SYSTEM_ROLES:i}=hs(),{inService:d}=P(),[l,r]=b.useState(!1),n=`passports-${p}`,h=os(n),[m,g]=b.useState({role:xe,status:he,searchText:h.searchText||"",pageSize:h.rowsPerPage||10,page:h.page?h.page+1:1}),{data:T,loading:x}=V(async()=>(await s.getPassportRoleCounts({input:{teamDid:p}})).counts||[],{refreshDeps:[p]}),{data:a,loading:o}=V(async()=>{const y={};m.role!==xe&&(y.role=m.role),m.status&&(y.status=m.status);const I=await s.getPassportsByRole({input:{teamDid:p,query:y,paging:{page:m.page,pageSize:m.pageSize}}});return{passports:I.passports||[],total:I.paging.total}},{refreshDeps:[m.role,m.status,m.page,m.pageSize],onError:y=>D.error(y.message)}),v=y=>T?.find(R=>R.key===y)?.value||0,j=b.useMemo(()=>Object.keys(i).map(y=>({name:y,title:i[y],num:v(y)})),[T,v]),C=b.useMemo(()=>[{label:u("team.passport.role"),name:"role",options:{customBodyRender:(y,{rowIndex:I})=>{const R=a?.passports[I];return e.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(Be,{createPassportSvg:c,passport:R,teamDid:p}),e.jsx(t,{children:ne(R.title)})]})}}},{label:u("team.passport.owner"),name:"user",options:{customBodyRender:y=>ie(y,d)}},{label:u("team.passport.status"),name:"status",options:{customBodyRender:le}},{label:u("team.member.lastLogin"),name:"lastLoginAt",options:{customBodyRender:y=>ve(y,f)}},{label:u("common.address"),name:"id",options:{customBodyRender:gs}},{label:u("blocklet.overview.source"),name:"source",options:{customBodyRender:(y,{rowIndex:I})=>{const R=a?.passports[I];return R.parentDid?X("recover"):X(R.source)}}}],[u,f,a?.passports,p,c,d]),w=y=>{g(I=>({...I,role:y,page:1}))},k=({page:y,rowsPerPage:I,searchText:R})=>{m.pageSize!==I?g(B=>({...B,searchText:"",pageSize:I,page:1})):m.page!==y+1?g(B=>({...B,searchText:"",page:y+1})):m.searchText!==R&&g(B=>({...B,searchText:R,page:1}))},L=b.useRef(null),q=a?.passports||[],Ee=m.searchText?q.filter(y=>y.id.includes(m.searchText)||(y?.user?.fullName||"").includes(m.searchText)):q,Me={sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,onRowClick(y,{dataIndex:I},R){if(L.current?.contains(R.target)){const B=a?.passports[I];r(B)}},page:m.page-1,rowsPerPage:m.pageSize,count:a?.total||0,searchDebounceTime:600},Oe=y=>{g(I=>({...I,status:y.target.value,page:1}))},$e=e.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsxs(t,{sx:{fontSize:16,fontWeight:400},children:[u("team.passport.status"),":"]}),e.jsxs(Qe,{size:"small",value:m.status,onChange:Oe,displayEmpty:!0,sx:{minWidth:120,height:36,".MuiSelect-select":{py:.5,px:1.5}},children:[e.jsx(Z,{value:he,children:u("common.all")}),Object.values(fs).map(y=>e.jsx(Z,{value:y,sx:{py:1},children:u(`team.passport.statusMap.${y}`)},y))]})]});return x?e.jsx(t,{sx:{py:2},children:e.jsx(G,{direction:"row",spacing:1,sx:{justifyContent:"center",alignItems:"center",position:"relative",pb:2},children:e.jsx(F,{})})}):e.jsxs(Us,{children:[e.jsxs(t,{className:"main",sx:{display:"flex",mt:0,gap:3},children:[e.jsx(t,{className:"left",children:e.jsx(t,{className:"tabs",children:j.map(y=>e.jsxs(t,{className:`tab ${m.role===y.name?"active":""}`,onClick:()=>w(y.name),children:[e.jsx("span",{className:"text",children:y.title}),e.jsx(t,{sx:{color:"text.secondary"},children:y.num})]},y.name))})}),e.jsx(t,{ref:L,className:"right",children:e.jsx(ae,{className:"main-table",verticalKeyWidth:100,locale:f,durable:n,durableKeys:["page","rowsPerPage"],data:Ee,columns:C,options:Me,loading:o,onChange:k,customButtons:[e.jsx(Fe,{createPassportSvg:c})],title:$e})})]}),l&&e.jsx(Ie,{createPassportSvg:c,onCancel:()=>r(null),passport:l,onSwitchPassport:r})]})}qs.propTypes={createPassportSvg:S.func.isRequired};const Us=es(t)`
131
131
  .main {
132
132
  .left {
133
133
  width: 256px;
@@ -1 +1 @@
1
- import{B as H,ac as Y}from"./vendor-utils-BbcnEeJI.js";import{aK as U,aL as g,aM as M,aN as N,aO as w}from"./index-yoaLEniz.js";import{e as F}from"./vendor-react-DX7tU9aY.js";var a={},$={},B;function C(){if(B)return $;B=1;var _=Object.create,r=Object.defineProperty,t=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyNames,T=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty,D=(s,f,p,c)=>{if(f&&typeof f=="object"||typeof f=="function")for(var u=y(f),d=0,S=u.length,h;d<S;d++)h=u[d],!O.call(s,h)&&h!==p&&r(s,h,{get:(P=>f[P]).bind(null,h),enumerable:!(c=t(f,h))||c.enumerable});return s},l=(s,f,p)=>(p=s!=null?_(T(s)):{},D(f||!s||!s.__esModule?r(p,"default",{value:s,enumerable:!0}):p,s));return $.__toESM=l,$}var b={},k;function q(){if(k)return b;k=1;const _=C();let r=g(),t=U;t=_.__toESM(t);const y="did:abt:",T=l=>{try{if((0,r.isHexStrict)(l))return H.from((0,r.stripHexPrefix)(l),"hex");let s=(0,r.fromBase58)(l.replace(y,""));for(;s.length<26;)s=H.concat([H.from([0]),s]);return s}catch(s){throw new Error(`Cannot convert DID string to byte array: ${s.message}`)}},O=(l,s)=>(0,t.default)((0,r.toBN)(l).toString(2),s,"0"),D=(l,s)=>{const f=l.replace(/^0x/i,"");return typeof s=="number"&&s%2===0?(0,t.default)(l,s,"0"):f.length%2===0?f:`0${f}`};return b.DID_PREFIX=y,b.toBits=O,b.toBytes=T,b.toStrictHex=D,b}var m={};const X=F(Y);var K;function V(){if(K)return m;K=1;const _=C(),r=q();let t=w(),y=g(),T=M;T=_.__toESM(T);let O=X;O=_.__toESM(O);let D=N;D=_.__toESM(D);const l={pk:"key",address:"encoding"},s={role:t.types.RoleType.ROLE_ACCOUNT,pk:t.types.KeyType.ED25519,hash:t.types.HashType.SHA3,address:t.types.EncodingType.BASE58},f={role:t.types.RoleType.ROLE_PASSKEY,pk:t.types.KeyType.PASSKEY,hash:t.types.HashType.SHA2,address:t.types.EncodingType.BASE58},p={role:t.types.RoleType.ROLE_ACCOUNT,pk:t.types.KeyType.ETHEREUM,hash:t.types.HashType.KECCAK,address:t.types.EncodingType.BASE16},c=o=>{const e=["pk","hash","address"];return(0,O.default)((0,D.default)(o,e),(0,D.default)(p,e))},u=o=>{const e=(0,y.toAddress)(o);return/^(0x)?[0-9a-f]{40}$/i.test(e)?/^(0x|0X)?[0-9a-f]{40}$/.test(e)||/^(0x|0X)?[0-9A-F]{40}$/.test(e)?!0:d(e):!1},d=o=>{const e=o.replace(/^0x/i,""),i=t.Hasher.Keccak.hash256(e.toLowerCase()).replace(/^0x/i,"");for(let n=0;n<40;n++)if(parseInt(i[n],16)>7&&e[n].toUpperCase()!==e[n]||parseInt(i[n],16)<=7&&e[n].toLowerCase()!==e[n])return!1;return!0},S=o=>{if(typeof o>"u")return"";if(!/^(0x)?[0-9a-f]{40}$/i.test(o))throw new Error(`Given address "${o}" is not a valid Ethereum address.`);const e=o.toLowerCase().replace(/^0x/i,""),i=t.Hasher.Keccak.hash256(e).replace(/^0x/i,"");let n="0x";for(let E=0;E<e.length;E++)parseInt(i[E],16)>7?n+=e[E].toUpperCase():n+=e[E];return n};function h(o={}){let e={};["default","arcblock"].includes(o)?e=s:["eth","ethereum"].includes(o)?e=p:["passkey"].includes(o)?e=f:e={...s,...o};const{role:i,pk:n,hash:E,address:R}=e;Object.keys(e).forEach(A=>{const j=(0,T.default)(`${l[A]||A}Type`);if(Object.values(t.types[j]).includes(e[A])===!1)throw new Error(`Unsupported ${A} type: ${e[A]}`)});const I={role:i,pk:n,hash:E,address:R};return c(I)===!1&&[t.types.RoleType.ROLE_NODE,t.types.RoleType.ROLE_VALIDATOR,t.types.RoleType.ROLE_TETHER,t.types.RoleType.ROLE_SWAP].includes(I.role)&&(I.hash=t.types.HashType.SHA2),I}h.toJSON=o=>Object.keys(o).reduce((e,i)=>{const n=(0,T.default)(`${l[i]||i}Type`);return e[i]=Object.keys(t.types[n])[Object.values(t.types[n]).indexOf(o[i])],e},{}),h.fromJSON=o=>Object.keys(o).reduce((e,i)=>{const n=(0,T.default)(`${l[i]||i}Type`),E=Object.keys(t.types[n]);return e[i]=Object.values(t.types[n])[E.indexOf(o[i])],e},{});const P=o=>{const e=h(o),i=`${r.toBits(e.role,6)}${r.toBits(e.pk,5)}${r.toBits(e.hash,5)}`;return r.toStrictHex((0,y.stripHexPrefix)((0,y.numberToHex)(parseInt(i,2))),4)},x=o=>{let e={};try{if(u(o))e=p;else{const i=r.toBytes(o).slice(0,2),n=r.toBits(new y.BN(r.toStrictHex(H.from(i).toString("hex")),16),16),E=n.slice(0,6),R=n.slice(6,11),I=n.slice(11,16);e={role:parseInt(E,2),pk:parseInt(R,2),hash:parseInt(I,2),address:(0,y.isHex)((0,y.toAddress)(o))?t.types.EncodingType.BASE16:t.types.EncodingType.BASE58}}return Object.keys(e).forEach(i=>{Object.values(t.types[`${(0,T.default)(l[i]||i)}Type`]).includes(e[i])===!1&&delete e[i]}),e}catch{return e}},L=o=>{const e=x(o);return Object.keys(e).reduce((i,n)=>{const E=t.types[`${(0,T.default)(l[n]||n)}Type`];return i[n]=Object.keys(E).find(R=>E[R]===e[n]),i},{})};return m.DID_TYPE_ARCBLOCK=s,m.DID_TYPE_ETHEREUM=p,m.DID_TYPE_PASSKEY=f,m.DidType=h,m.fromTypeInfo=P,m.isEthereumDid=u,m.isEthereumType=c,m.toChecksumAddress=S,m.toTypeInfo=x,m.toTypeInfoStr=L,m}var v;function z(){if(v)return a;v=1;const _=q(),r=V();let t=w(),y=g();const T=(p,c)=>{const u=r.DidType(c),d=(0,t.getSigner)(u.pk).getPublicKey(p);return O(d.indexOf("0x")===0?d:`0x${d}`,u)},O=(p,c)=>{const u=r.DidType(c);return D((0,t.getHasher)(u.hash)(p,1),u)},D=(p,c)=>{const u=r.DidType(c),d=(0,y.stripHexPrefix)(p).slice(0,40),S=(0,t.getHasher)(u.hash),h=r.fromTypeInfo(u),P=`0x${h}${d}${(0,y.stripHexPrefix)(S(`0x${h}${d}`,1)).slice(0,8)}`;return r.isEthereumType(u)?r.toChecksumAddress(`0x${p.slice(-40)}`):u.address===t.types.EncodingType.BASE58?(0,y.toBase58)(P):P},l=(p,c=t.types.RoleType.ROLE_ACCOUNT)=>{const u=Object.keys(t.types.RoleType),d=Object.values(t.types.RoleType);if(d.indexOf(c)===-1)throw new Error(`Unsupported role type ${c} when gen ddi from hash`);return D(p,r.DidType({role:t.types.RoleType[u[d.indexOf(c)]]}))},s=(p,c)=>f(p)===!1?!1:O(c,r.toTypeInfo(p))===p.replace(_.DID_PREFIX,""),f=p=>{if(!p)return!1;const c=(0,y.toAddress)(String(p)),{hash:u}=r.toTypeInfo(c);if(typeof u>"u")return!1;if(r.isEthereumDid(c))return!0;const d=(0,t.getHasher)(u),S=_.toBytes(c),h=_.toStrictHex(H.from(S.slice(0,22)).toString("hex"));return _.toStrictHex(H.from(S.slice(22,26)).toString("hex"))===(0,y.stripHexPrefix)(d(`0x${h}`,1)).slice(0,8)};return a.DID_PREFIX=_.DID_PREFIX,a.DID_TYPE_ARCBLOCK=r.DID_TYPE_ARCBLOCK,a.DID_TYPE_ETHEREUM=r.DID_TYPE_ETHEREUM,a.DID_TYPE_PASSKEY=r.DID_TYPE_PASSKEY,a.DidType=r.DidType,a.fromHash=l,a.fromPublicKey=O,a.fromPublicKeyHash=D,a.fromSecretKey=T,a.fromTypeInfo=r.fromTypeInfo,a.isEthereumDid=r.isEthereumDid,a.isEthereumType=r.isEthereumType,a.isFromPublicKey=s,a.isValid=f,a.toAddress=y.toAddress,a.toDid=y.toDid,a.toStrictHex=_.toStrictHex,a.toTypeInfo=r.toTypeInfo,a.toTypeInfoStr=r.toTypeInfoStr,a.types=t.types,a}export{X as a,z as r};
1
+ import{B as H,ac as Y}from"./vendor-utils-BbcnEeJI.js";import{aI as U,aJ as g,aK as M,aL as F,aM as w}from"./index-BJCzMYyG.js";import{e as N}from"./vendor-react-DX7tU9aY.js";var a={},$={},B;function C(){if(B)return $;B=1;var _=Object.create,r=Object.defineProperty,t=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyNames,T=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty,D=(s,f,p,c)=>{if(f&&typeof f=="object"||typeof f=="function")for(var u=y(f),d=0,O=u.length,h;d<O;d++)h=u[d],!S.call(s,h)&&h!==p&&r(s,h,{get:(I=>f[I]).bind(null,h),enumerable:!(c=t(f,h))||c.enumerable});return s},l=(s,f,p)=>(p=s!=null?_(T(s)):{},D(f||!s||!s.__esModule?r(p,"default",{value:s,enumerable:!0}):p,s));return $.__toESM=l,$}var b={},k;function q(){if(k)return b;k=1;const _=C();let r=g(),t=U;t=_.__toESM(t);const y="did:abt:",T=l=>{try{if((0,r.isHexStrict)(l))return H.from((0,r.stripHexPrefix)(l),"hex");let s=(0,r.fromBase58)(l.replace(y,""));for(;s.length<26;)s=H.concat([H.from([0]),s]);return s}catch(s){throw new Error(`Cannot convert DID string to byte array: ${s.message}`)}},S=(l,s)=>(0,t.default)((0,r.toBN)(l).toString(2),s,"0"),D=(l,s)=>{const f=l.replace(/^0x/i,"");return typeof s=="number"&&s%2===0?(0,t.default)(l,s,"0"):f.length%2===0?f:`0${f}`};return b.DID_PREFIX=y,b.toBits=S,b.toBytes=T,b.toStrictHex=D,b}var m={};const X=N(Y);var K;function V(){if(K)return m;K=1;const _=C(),r=q();let t=w(),y=g(),T=M;T=_.__toESM(T);let S=X;S=_.__toESM(S);let D=F;D=_.__toESM(D);const l={pk:"key",address:"encoding"},s={role:t.types.RoleType.ROLE_ACCOUNT,pk:t.types.KeyType.ED25519,hash:t.types.HashType.SHA3,address:t.types.EncodingType.BASE58},f={role:t.types.RoleType.ROLE_PASSKEY,pk:t.types.KeyType.PASSKEY,hash:t.types.HashType.SHA2,address:t.types.EncodingType.BASE58},p={role:t.types.RoleType.ROLE_ACCOUNT,pk:t.types.KeyType.ETHEREUM,hash:t.types.HashType.KECCAK,address:t.types.EncodingType.BASE16},c=o=>{const e=["pk","hash","address"];return(0,S.default)((0,D.default)(o,e),(0,D.default)(p,e))},u=o=>{const e=(0,y.toAddress)(o);return/^(0x)?[0-9a-f]{40}$/i.test(e)?/^(0x|0X)?[0-9a-f]{40}$/.test(e)||/^(0x|0X)?[0-9A-F]{40}$/.test(e)?!0:d(e):!1},d=o=>{const e=o.replace(/^0x/i,""),i=t.Hasher.Keccak.hash256(e.toLowerCase()).replace(/^0x/i,"");for(let n=0;n<40;n++)if(parseInt(i[n],16)>7&&e[n].toUpperCase()!==e[n]||parseInt(i[n],16)<=7&&e[n].toLowerCase()!==e[n])return!1;return!0},O=o=>{if(typeof o>"u")return"";if(!/^(0x)?[0-9a-f]{40}$/i.test(o))throw new Error(`Given address "${o}" is not a valid Ethereum address.`);const e=o.toLowerCase().replace(/^0x/i,""),i=t.Hasher.Keccak.hash256(e).replace(/^0x/i,"");let n="0x";for(let E=0;E<e.length;E++)parseInt(i[E],16)>7?n+=e[E].toUpperCase():n+=e[E];return n};function h(o={}){let e={};["default","arcblock"].includes(o)?e=s:["eth","ethereum"].includes(o)?e=p:["passkey"].includes(o)?e=f:e={...s,...o};const{role:i,pk:n,hash:E,address:R}=e;Object.keys(e).forEach(A=>{const j=(0,T.default)(`${l[A]||A}Type`);if(Object.values(t.types[j]).includes(e[A])===!1)throw new Error(`Unsupported ${A} type: ${e[A]}`)});const P={role:i,pk:n,hash:E,address:R};return c(P)===!1&&[t.types.RoleType.ROLE_NODE,t.types.RoleType.ROLE_VALIDATOR,t.types.RoleType.ROLE_TETHER,t.types.RoleType.ROLE_SWAP].includes(P.role)&&(P.hash=t.types.HashType.SHA2),P}h.toJSON=o=>Object.keys(o).reduce((e,i)=>{const n=(0,T.default)(`${l[i]||i}Type`);return e[i]=Object.keys(t.types[n])[Object.values(t.types[n]).indexOf(o[i])],e},{}),h.fromJSON=o=>Object.keys(o).reduce((e,i)=>{const n=(0,T.default)(`${l[i]||i}Type`),E=Object.keys(t.types[n]);return e[i]=Object.values(t.types[n])[E.indexOf(o[i])],e},{});const I=o=>{const e=h(o),i=`${r.toBits(e.role,6)}${r.toBits(e.pk,5)}${r.toBits(e.hash,5)}`;return r.toStrictHex((0,y.stripHexPrefix)((0,y.numberToHex)(parseInt(i,2))),4)},x=o=>{let e={};try{if(u(o))e=p;else{const i=r.toBytes(o).slice(0,2),n=r.toBits(new y.BN(r.toStrictHex(H.from(i).toString("hex")),16),16),E=n.slice(0,6),R=n.slice(6,11),P=n.slice(11,16);e={role:parseInt(E,2),pk:parseInt(R,2),hash:parseInt(P,2),address:(0,y.isHex)((0,y.toAddress)(o))?t.types.EncodingType.BASE16:t.types.EncodingType.BASE58}}return Object.keys(e).forEach(i=>{Object.values(t.types[`${(0,T.default)(l[i]||i)}Type`]).includes(e[i])===!1&&delete e[i]}),e}catch{return e}},L=o=>{const e=x(o);return Object.keys(e).reduce((i,n)=>{const E=t.types[`${(0,T.default)(l[n]||n)}Type`];return i[n]=Object.keys(E).find(R=>E[R]===e[n]),i},{})};return m.DID_TYPE_ARCBLOCK=s,m.DID_TYPE_ETHEREUM=p,m.DID_TYPE_PASSKEY=f,m.DidType=h,m.fromTypeInfo=I,m.isEthereumDid=u,m.isEthereumType=c,m.toChecksumAddress=O,m.toTypeInfo=x,m.toTypeInfoStr=L,m}var v;function z(){if(v)return a;v=1;const _=q(),r=V();let t=w(),y=g();const T=(p,c)=>{const u=r.DidType(c),d=(0,t.getSigner)(u.pk).getPublicKey(p);return S(d.indexOf("0x")===0?d:`0x${d}`,u)},S=(p,c)=>{const u=r.DidType(c);return D((0,t.getHasher)(u.hash)(p,1),u)},D=(p,c)=>{const u=r.DidType(c),d=(0,y.stripHexPrefix)(p).slice(0,40),O=(0,t.getHasher)(u.hash),h=r.fromTypeInfo(u),I=`0x${h}${d}${(0,y.stripHexPrefix)(O(`0x${h}${d}`,1)).slice(0,8)}`;return r.isEthereumType(u)?r.toChecksumAddress(`0x${p.slice(-40)}`):u.address===t.types.EncodingType.BASE58?(0,y.toBase58)(I):I},l=(p,c=t.types.RoleType.ROLE_ACCOUNT)=>{const u=Object.keys(t.types.RoleType),d=Object.values(t.types.RoleType);if(d.indexOf(c)===-1)throw new Error(`Unsupported role type ${c} when gen ddi from hash`);return D(p,r.DidType({role:t.types.RoleType[u[d.indexOf(c)]]}))},s=(p,c)=>f(p)===!1?!1:S(c,r.toTypeInfo(p))===p.replace(_.DID_PREFIX,""),f=p=>{if(!p)return!1;const c=(0,y.toAddress)(String(p)),{hash:u}=r.toTypeInfo(c);if(typeof u>"u")return!1;if(r.isEthereumDid(c))return!0;const d=(0,t.getHasher)(u),O=_.toBytes(c),h=_.toStrictHex(H.from(O.slice(0,22)).toString("hex"));return _.toStrictHex(H.from(O.slice(22,26)).toString("hex"))===(0,y.stripHexPrefix)(d(`0x${h}`,1)).slice(0,8)};return a.DID_PREFIX=_.DID_PREFIX,a.DID_TYPE_ARCBLOCK=r.DID_TYPE_ARCBLOCK,a.DID_TYPE_ETHEREUM=r.DID_TYPE_ETHEREUM,a.DID_TYPE_PASSKEY=r.DID_TYPE_PASSKEY,a.DidType=r.DidType,a.fromHash=l,a.fromPublicKey=S,a.fromPublicKeyHash=D,a.fromSecretKey=T,a.fromTypeInfo=r.fromTypeInfo,a.isEthereumDid=r.isEthereumDid,a.isEthereumType=r.isEthereumType,a.isFromPublicKey=s,a.isValid=f,a.toAddress=y.toAddress,a.toDid=y.toDid,a.toStrictHex=_.toStrictHex,a.toTypeInfo=r.toTypeInfo,a.toTypeInfoStr=r.toTypeInfoStr,a.types=t.types,a}export{X as a,z as r};
@@ -1 +1 @@
1
- import{V as te,y as _,b3 as N,b2 as de,ba as me}from"./vendor-ux-BGqHwkOM.js";import{g as fe,r as L,j as he}from"./vendor-react-DX7tU9aY.js";import{i as re,b as f,a as pe}from"./vendor-hooks-164oA5kM.js";import{j as e,al as w,A as j,bK as J,b8 as X,z as b,an as xe,e8 as ve,cY as je,aT as ie,b3 as ne,T as Q}from"./vendor-mui-core-CV-FnYH_.js";import{x as ae,G as be,z as ge}from"./vendor-utils-BbcnEeJI.js";import{u as se,C as x}from"./index.esm-C4tuRtuv.js";import{C as B}from"./isEmail-BwGDo3Ws.js";import{i as Y}from"./isURL-CpQHQuaa.js";import{r as ye}from"./isIP-BBY240SU.js";import{X as oe,V as le,av as ce,W as we}from"./index-yoaLEniz.js";import{S as v}from"./section-CZylgxjz.js";import{A as Re,a as ke,b as Te}from"./collapse-RMuUWnK3.js";import"./vendor-arcblock-Xw2zMy0D.js";import"./required-DnQpCGsD.js";var W={exports:{}},A={exports:{}},z={exports:{}},Z;function Se(){return Z||(Z=1,(function(c,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=t;function t(h){return h==null}c.exports=n.default,c.exports.default=n.default})(z,z.exports)),z.exports}var $;function Ce(){return $||($=1,(function(c,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=S;var t=R(ye()),h=R(Se());function R(m){return m&&m.__esModule?m:{default:m}}var u=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,p=/^[-+]?[0-9]+$/;function S(m,l){(0,t.default)(m),l=l||{};var d=l.allow_leading_zeroes===!1?u:p,i=!l.hasOwnProperty("min")||(0,h.default)(l.min)||m>=l.min,q=!l.hasOwnProperty("max")||(0,h.default)(l.max)||m<=l.max,I=!l.hasOwnProperty("lt")||(0,h.default)(l.lt)||m<l.lt,o=!l.hasOwnProperty("gt")||(0,h.default)(l.gt)||m>l.gt;return d.test(m)&&i&&q&&I&&o}c.exports=n.default,c.exports.default=n.default})(A,A.exports)),A.exports}var ee;function Ee(){return ee||(ee=1,(function(c,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=R;var t=h(Ce());function h(u){return u&&u.__esModule?u:{default:u}}function R(u){return(0,t.default)(u,{allow_leading_zeroes:!1,min:0,max:65535})}c.exports=n.default,c.exports.default=n.default})(W,W.exports)),W.exports}var Pe=Ee();const _e=fe(Pe),V={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function qe(){const{api:c}=oe(),{blocklet:n}=le(),{t}=te(),{confirmApi:h,confirmHolder:R}=ce(),[u,p]=L.useState(!1),S=n?.meta?.did,m=Object.assign({...V},n?.settings?.notification?.email||{}),{handleSubmit:l,control:d,formState:i,watch:q,reset:I}=se({defaultValues:ae(m,Object.keys(V))}),o=re({testReceiver:"",testReceiverError:""}),a=q("enabled"),K=f(async(r,k,P=!0)=>{try{p(!0);const{blocklet:T}=await c.configNotification({input:{did:S,notification:JSON.stringify({email:r})}}),ue=Object.assign({...V},T?.settings?.notification?.email||{});I(ue),P&&_.success(t("common.saveSuccess"))}catch(T){if(P)_.error(T.message||t("common.saveFailed"));else throw T}finally{p(!1)}}),F=f(async(r,k,P)=>{try{p(!0),i.isDirty&&await K(r,k,!1),await c.sendEmail({input:{did:S,receiver:P,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification",attachments:[{type:"link",data:{url:"https://community.arcblock.io",title:"Community",image:"https://community.arcblock.io/.well-known/service/blocklet/logo-rect-dark",utm:{campaign:"test-campaign"}}}],utm:{content:"test-email-button"}})}}),_.success(t("notification.email.testSuccess"))}catch(T){_.error(T.message||t("notification.email.testfailed"))}finally{p(!1)}}),D=f((r,k)=>{o.testReceiver=localStorage.getItem("test-receiver")||"",o.testReceiverError="",h.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(w,{sx:{width:"300px"},children:e.jsx(j,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:o.testReceiver,onChange:P=>{o.testReceiver=P.target.value},error:!!o.testReceiverError,helperText:o.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(P){const T=o.testReceiver?.trim();if(!T){o.testReceiverError=t("notification.email.receiverRequired");return}if(!B(T)){o.testReceiverError=t("notification.email.receiverInvalid");return}o.testReceiverError="",await F(r,k,T),P()},onCancel:()=>{p(!1)}})}),M=f(r=>{const k=r?.trim();return k?B(k)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),U=f(r=>{const k=r?.trim();return k?Y(k,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),s=f(r=>r?_e(r)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),C=f(r=>r?.trim()?!0:t("notification.email.userRequired")),g=f(r=>r?.trim()?!0:t("notification.email.passwordRequired")),E=f(r=>r?.trim()&&!Y(r,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),O=f(r=>r?.trim()&&!B(r)?t("notification.email.emailInvalid"):!0),y=f(()=>!0);return e.jsxs(w,{children:[e.jsxs(Ie,{component:"form",onSubmit:l(K),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(v,{title:t("notification.email.enable"),my:2.5,children:e.jsx(x,{name:"enabled",control:d,render:({field:r})=>e.jsx(J,{control:e.jsx(X,{checked:r.value,...r})})})}),e.jsx(v,{title:t("notification.email.from"),children:e.jsx(x,{name:"from",control:d,rules:{validate:a?M:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[r.name],helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.host"),children:e.jsx(x,{name:"host",control:d,rules:{validate:a?U:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",required:!0,error:!!i.errors[r.name],label:t("notification.email.host"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.port"),children:e.jsx(x,{name:"port",control:d,rules:{validate:a?s:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",required:!0,type:"number",error:!!i.errors[r.name],label:t("notification.email.port"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.user"),children:e.jsx(x,{name:"user",control:d,rules:{validate:a?C:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",required:!0,error:!!i.errors[r.name],label:t("notification.email.user"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.password"),children:e.jsx(x,{name:"password",control:d,rules:{validate:a?g:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",required:!0,type:"password",error:!!i.errors[r.name],label:t("notification.email.password"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.secure"),children:e.jsx(x,{name:"secure",control:d,rules:{validate:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(J,{control:e.jsx(X,{checked:r.value,...r,disabled:!a})})})})}),e.jsxs(Re,{children:[e.jsxs(ke,{expandIcon:e.jsx(je,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(xe,{title:t("notification.email.signatureTooltip"),children:e.jsx(ve,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(Te,{children:[e.jsx(v,{title:t("notification.email.companyName"),children:e.jsx(x,{name:"companyName",control:d,rules:{validate:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyName"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.companyLink"),children:e.jsx(x,{name:"companyLink",control:d,rules:{validate:a?E:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyLink"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.companyAddress"),children:e.jsx(x,{name:"companyAddress",control:d,rules:{validate:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyAddress"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.supportEmail"),children:e.jsx(x,{name:"supportEmail",control:d,rules:{validate:a?O:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",type:"email",error:!!i.errors[r.name],label:t("notification.email.supportEmail"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})})]})]}),e.jsxs(w,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(N,{variant:"outlined",loading:u,color:"warning",onClick:l(D),disabled:!a||u,children:t("common.runTest")}),e.jsx(N,{type:"submit",variant:"contained",loading:u,disabled:!i.isDirty||u,children:t("common.save")})]})]}),R]})}const Ie=ie(ne)``,H={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function Ke(){const{api:c}=oe(),{blocklet:n}=le(),{t}=te(),{confirmApi:h,confirmHolder:R}=ce(),[u,p]=L.useState(!1),S=n?.meta?.did,m=Object.assign({...H},n?.settings?.notification?.pushKit||{}),{handleSubmit:l,control:d,formState:i,watch:q,reset:I}=se({defaultValues:ae(m,Object.keys(H))}),o=re({testReceiver:"",testReceiverError:""}),a=q("enabled"),K=f(async(s,C,g=!0)=>{try{p(!0);const{blocklet:E}=await c.configNotification({input:{did:S,notification:JSON.stringify({pushKit:s})}}),O=Object.assign({...H},E?.settings?.notification?.pushKit||{});I(O),g&&_.success(t("common.saveSuccess"))}catch(E){if(g)_.error(E.message||t("common.saveFailed"));else throw E}finally{p(!1)}}),F=f(async(s,C)=>{try{p(!0),i.isDirty&&await K(s,C,!1);const g=(n?.configs||[]).find(y=>y.key==="BLOCKLET_APP_URL")?.value,E=be(ge(g,we,"/blocklet/logo"),{v:n?.meta?.version,t:new Date(n?.updatedAt||0).getTime()}),O={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:n?.appDid,fullName:n?.meta?.title,avatar:E}}}};await c.sendPush({input:{did:S,receiver:o.testReceiver,notification:JSON.stringify(O)}}),_.success(t("notification.pushKit.testSuccess"))}catch(g){_.error(g.message||t("notification.pushKit.testfailed"))}finally{p(!1)}}),D=f((s,C)=>{o.testReceiverError="",h.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(w,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(j,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:o.testReceiver,onChange:g=>{o.testReceiver=g.target.value},error:!!o.testReceiverError,helperText:o.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(g){if(!o.testReceiver?.trim()){o.testReceiverError=t("notification.pushKit.receiverRequired");return}o.testReceiverError="",await F(s,C),g()},onCancel:()=>{p(!1)}})}),M=f(s=>{const C=s?.trim();return C?Y(C)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),U=f(()=>!0);return e.jsxs(w,{children:[e.jsxs(Oe,{component:"form",onSubmit:l(K),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(v,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(x,{name:"enabled",control:d,render:({field:s})=>e.jsx(J,{control:e.jsx(X,{checked:s.value,...s})})})}),e.jsx(v,{title:t("notification.pushKit.endpoint"),children:e.jsx(x,{name:"endpoint",control:d,rules:{validate:a?M:U},render:({field:s})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...s,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!a})})})}),e.jsxs(v,{title:t("notification.pushKit.customOptions"),children:[e.jsx(x,{name:"did",control:d,render:({field:s})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...s,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!a})})}),e.jsx(x,{name:"pushPath",control:d,render:({field:s})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...s,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!a})})})]}),e.jsxs(w,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(N,{variant:"outlined",loading:u,color:"warning",onClick:l(D),disabled:!a||u,children:t("common.runTest")}),e.jsx(N,{type:"submit",variant:"contained",loading:u,disabled:!i.isDirty||u,children:t("common.save")})]})]}),R]})}const Oe=ie(ne)``,G=[{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"},{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Wallet"}),value:"wallet"},{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Webhooks"}),value:"webhooks"}],We=G.map(c=>c.value);function Ge(){const{t:c}=L.useContext(de),[n,t]=he(),h=n.get("type"),R=We.includes(h)?h:G[0].value,u=pe(()=>({email:e.jsx(qe,{}),pushKit:e.jsx(Ke,{}),wallet:e.jsx(Q,{variant:"body1",children:c("notification.wallet.description")}),webhooks:e.jsx(Q,{variant:"body1",children:c("notification.webhooks.description")})}),[c]),p=f(m=>{n.set("type",m),t(n,{replace:!0})}),S=L.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(w,{children:[e.jsx(me,{variant:"card",tabs:G,current:R,onChange:p}),e.jsx(w,{style:S,children:u[R]})]})}export{Ge as default};
1
+ import{V as te,y as _,b2 as N,b1 as de,b9 as me}from"./vendor-ux-hzekFYg2.js";import{g as fe,r as L,j as he}from"./vendor-react-DX7tU9aY.js";import{i as re,b as f,a as pe}from"./vendor-hooks-Bt9Vv36g.js";import{j as e,al as w,A as j,bK as J,b8 as X,z as b,an as xe,e9 as ve,cZ as je,aT as ie,b3 as ne,T as Q}from"./vendor-mui-core-D6nniiQs.js";import{x as ae,G as be,z as ge}from"./vendor-utils-BbcnEeJI.js";import{u as se,C as x}from"./index.esm-C4tuRtuv.js";import{C as B}from"./isEmail-BwGDo3Ws.js";import{i as Z}from"./isURL-CpQHQuaa.js";import{r as ye}from"./isIP-BBY240SU.js";import{X as oe,V as le,av as ce,W as we}from"./index-BJCzMYyG.js";import{S as v}from"./section-BHNJgwmP.js";import{A as Re,a as ke,b as Te}from"./collapse-CBrasNzu.js";import"./vendor-arcblock-B6JCofz3.js";import"./required-jUJP5eu8.js";var W={exports:{}},A={exports:{}},z={exports:{}},Y;function Se(){return Y||(Y=1,(function(c,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=t;function t(h){return h==null}c.exports=n.default,c.exports.default=n.default})(z,z.exports)),z.exports}var $;function Ce(){return $||($=1,(function(c,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=S;var t=R(ye()),h=R(Se());function R(m){return m&&m.__esModule?m:{default:m}}var u=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,p=/^[-+]?[0-9]+$/;function S(m,l){(0,t.default)(m),l=l||{};var d=l.allow_leading_zeroes===!1?u:p,i=!l.hasOwnProperty("min")||(0,h.default)(l.min)||m>=l.min,q=!l.hasOwnProperty("max")||(0,h.default)(l.max)||m<=l.max,I=!l.hasOwnProperty("lt")||(0,h.default)(l.lt)||m<l.lt,o=!l.hasOwnProperty("gt")||(0,h.default)(l.gt)||m>l.gt;return d.test(m)&&i&&q&&I&&o}c.exports=n.default,c.exports.default=n.default})(A,A.exports)),A.exports}var ee;function Ee(){return ee||(ee=1,(function(c,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=R;var t=h(Ce());function h(u){return u&&u.__esModule?u:{default:u}}function R(u){return(0,t.default)(u,{allow_leading_zeroes:!1,min:0,max:65535})}c.exports=n.default,c.exports.default=n.default})(W,W.exports)),W.exports}var Pe=Ee();const _e=fe(Pe),V={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function qe(){const{api:c}=oe(),{blocklet:n}=le(),{t}=te(),{confirmApi:h,confirmHolder:R}=ce(),[u,p]=L.useState(!1),S=n?.meta?.did,m=Object.assign({...V},n?.settings?.notification?.email||{}),{handleSubmit:l,control:d,formState:i,watch:q,reset:I}=se({defaultValues:ae(m,Object.keys(V))}),o=re({testReceiver:"",testReceiverError:""}),a=q("enabled"),K=f(async(r,k,P=!0)=>{try{p(!0);const{blocklet:T}=await c.configNotification({input:{did:S,notification:JSON.stringify({email:r})}}),ue=Object.assign({...V},T?.settings?.notification?.email||{});I(ue),P&&_.success(t("common.saveSuccess"))}catch(T){if(P)_.error(T.message||t("common.saveFailed"));else throw T}finally{p(!1)}}),F=f(async(r,k,P)=>{try{p(!0),i.isDirty&&await K(r,k,!1),await c.sendEmail({input:{did:S,receiver:P,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification",attachments:[{type:"link",data:{url:"https://community.arcblock.io",title:"Community",image:"https://community.arcblock.io/.well-known/service/blocklet/logo-rect-dark",utm:{campaign:"test-campaign"}}}],utm:{content:"test-email-button"}})}}),_.success(t("notification.email.testSuccess"))}catch(T){_.error(T.message||t("notification.email.testfailed"))}finally{p(!1)}}),D=f((r,k)=>{o.testReceiver=localStorage.getItem("test-receiver")||"",o.testReceiverError="",h.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(w,{sx:{width:"300px"},children:e.jsx(j,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:o.testReceiver,onChange:P=>{o.testReceiver=P.target.value},error:!!o.testReceiverError,helperText:o.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(P){const T=o.testReceiver?.trim();if(!T){o.testReceiverError=t("notification.email.receiverRequired");return}if(!B(T)){o.testReceiverError=t("notification.email.receiverInvalid");return}o.testReceiverError="",await F(r,k,T),P()},onCancel:()=>{p(!1)}})}),M=f(r=>{const k=r?.trim();return k?B(k)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),U=f(r=>{const k=r?.trim();return k?Z(k,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),s=f(r=>r?_e(r)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),C=f(r=>r?.trim()?!0:t("notification.email.userRequired")),g=f(r=>r?.trim()?!0:t("notification.email.passwordRequired")),E=f(r=>r?.trim()&&!Z(r,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),O=f(r=>r?.trim()&&!B(r)?t("notification.email.emailInvalid"):!0),y=f(()=>!0);return e.jsxs(w,{children:[e.jsxs(Ie,{component:"form",onSubmit:l(K),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(v,{title:t("notification.email.enable"),my:2.5,children:e.jsx(x,{name:"enabled",control:d,render:({field:r})=>e.jsx(J,{control:e.jsx(X,{checked:r.value,...r})})})}),e.jsx(v,{title:t("notification.email.from"),children:e.jsx(x,{name:"from",control:d,rules:{validate:a?M:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[r.name],helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.host"),children:e.jsx(x,{name:"host",control:d,rules:{validate:a?U:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",required:!0,error:!!i.errors[r.name],label:t("notification.email.host"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.port"),children:e.jsx(x,{name:"port",control:d,rules:{validate:a?s:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",required:!0,type:"number",error:!!i.errors[r.name],label:t("notification.email.port"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.user"),children:e.jsx(x,{name:"user",control:d,rules:{validate:a?C:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",required:!0,error:!!i.errors[r.name],label:t("notification.email.user"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.password"),children:e.jsx(x,{name:"password",control:d,rules:{validate:a?g:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",required:!0,type:"password",error:!!i.errors[r.name],label:t("notification.email.password"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.secure"),children:e.jsx(x,{name:"secure",control:d,rules:{validate:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(J,{control:e.jsx(X,{checked:r.value,...r,disabled:!a})})})})}),e.jsxs(Re,{children:[e.jsxs(ke,{expandIcon:e.jsx(je,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(xe,{title:t("notification.email.signatureTooltip"),children:e.jsx(ve,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(Te,{children:[e.jsx(v,{title:t("notification.email.companyName"),children:e.jsx(x,{name:"companyName",control:d,rules:{validate:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyName"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.companyLink"),children:e.jsx(x,{name:"companyLink",control:d,rules:{validate:a?E:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyLink"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.companyAddress"),children:e.jsx(x,{name:"companyAddress",control:d,rules:{validate:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyAddress"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(v,{title:t("notification.email.supportEmail"),children:e.jsx(x,{name:"supportEmail",control:d,rules:{validate:a?O:y},render:({field:r})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...r,size:"small",type:"email",error:!!i.errors[r.name],label:t("notification.email.supportEmail"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})})]})]}),e.jsxs(w,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(N,{variant:"outlined",loading:u,color:"warning",onClick:l(D),disabled:!a||u,children:t("common.runTest")}),e.jsx(N,{type:"submit",variant:"contained",loading:u,disabled:!i.isDirty||u,children:t("common.save")})]})]}),R]})}const Ie=ie(ne)``,H={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function Ke(){const{api:c}=oe(),{blocklet:n}=le(),{t}=te(),{confirmApi:h,confirmHolder:R}=ce(),[u,p]=L.useState(!1),S=n?.meta?.did,m=Object.assign({...H},n?.settings?.notification?.pushKit||{}),{handleSubmit:l,control:d,formState:i,watch:q,reset:I}=se({defaultValues:ae(m,Object.keys(H))}),o=re({testReceiver:"",testReceiverError:""}),a=q("enabled"),K=f(async(s,C,g=!0)=>{try{p(!0);const{blocklet:E}=await c.configNotification({input:{did:S,notification:JSON.stringify({pushKit:s})}}),O=Object.assign({...H},E?.settings?.notification?.pushKit||{});I(O),g&&_.success(t("common.saveSuccess"))}catch(E){if(g)_.error(E.message||t("common.saveFailed"));else throw E}finally{p(!1)}}),F=f(async(s,C)=>{try{p(!0),i.isDirty&&await K(s,C,!1);const g=(n?.configs||[]).find(y=>y.key==="BLOCKLET_APP_URL")?.value,E=be(ge(g,we,"/blocklet/logo"),{v:n?.meta?.version,t:new Date(n?.updatedAt||0).getTime()}),O={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:n?.appDid,fullName:n?.meta?.title,avatar:E}}}};await c.sendPush({input:{did:S,receiver:o.testReceiver,notification:JSON.stringify(O)}}),_.success(t("notification.pushKit.testSuccess"))}catch(g){_.error(g.message||t("notification.pushKit.testfailed"))}finally{p(!1)}}),D=f((s,C)=>{o.testReceiverError="",h.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(w,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(j,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:o.testReceiver,onChange:g=>{o.testReceiver=g.target.value},error:!!o.testReceiverError,helperText:o.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(g){if(!o.testReceiver?.trim()){o.testReceiverError=t("notification.pushKit.receiverRequired");return}o.testReceiverError="",await F(s,C),g()},onCancel:()=>{p(!1)}})}),M=f(s=>{const C=s?.trim();return C?Z(C)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),U=f(()=>!0);return e.jsxs(w,{children:[e.jsxs(Oe,{component:"form",onSubmit:l(K),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(v,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(x,{name:"enabled",control:d,render:({field:s})=>e.jsx(J,{control:e.jsx(X,{checked:s.value,...s})})})}),e.jsx(v,{title:t("notification.pushKit.endpoint"),children:e.jsx(x,{name:"endpoint",control:d,rules:{validate:a?M:U},render:({field:s})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...s,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!a})})})}),e.jsxs(v,{title:t("notification.pushKit.customOptions"),children:[e.jsx(x,{name:"did",control:d,render:({field:s})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...s,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!a})})}),e.jsx(x,{name:"pushPath",control:d,render:({field:s})=>e.jsx(b,{fullWidth:!0,children:e.jsx(j,{...s,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!a})})})]}),e.jsxs(w,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(N,{variant:"outlined",loading:u,color:"warning",onClick:l(D),disabled:!a||u,children:t("common.runTest")}),e.jsx(N,{type:"submit",variant:"contained",loading:u,disabled:!i.isDirty||u,children:t("common.save")})]})]}),R]})}const Oe=ie(ne)``,G=[{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"},{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Wallet"}),value:"wallet"},{label:e.jsx(w,{sx:{textAlign:"center",width:"100%"},children:"Webhooks"}),value:"webhooks"}],We=G.map(c=>c.value);function Ge(){const{t:c}=L.useContext(de),[n,t]=he(),h=n.get("type"),R=We.includes(h)?h:G[0].value,u=pe(()=>({email:e.jsx(qe,{}),pushKit:e.jsx(Ke,{}),wallet:e.jsx(Q,{variant:"body1",children:c("notification.wallet.description")}),webhooks:e.jsx(Q,{variant:"body1",children:c("notification.webhooks.description")})}),[c]),p=f(m=>{n.set("type",m),t(n,{replace:!0})}),S=L.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(w,{children:[e.jsx(me,{variant:"card",tabs:G,current:R,onChange:p}),e.jsx(w,{style:S,children:u[R]})]})}export{Ge as default};