@abtnode/blocklet-services 1.16.46-beta-20250704-234926-09d872ad → 1.16.46-beta-20250708-074453-e1748586

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 (267) hide show
  1. package/api/libs/image.js +10 -2
  2. package/api/routes/user.js +1 -2
  3. package/dist/assets/AdapterDayjs-X0hNNolb.js +3 -0
  4. package/dist/assets/{Community-B_rRcH4k.js → Community-CcMMU0U0.js} +1 -1
  5. package/dist/assets/{Google-if7RtO8D.js → Google-Bo2ohqwo.js} +3 -3
  6. package/dist/assets/{Holiday-DET7Gz33.js → Holiday-CQ56q1Zn.js} +1 -1
  7. package/dist/assets/{Meeting-D-dNfxru.js → Meeting-BloE6sJb.js} +1 -1
  8. package/dist/assets/{OffSick-MDwLewaS.js → OffSick-BDgahXbb.js} +1 -1
  9. package/dist/assets/{WorkingRemotely-BmHz2B2e.js → WorkingRemotely-Dy2yEuOf.js} +1 -1
  10. package/dist/assets/access-control-90k3s4Tc.js +14 -0
  11. package/dist/assets/{actions-DzwK3TZX.js → actions-DK8uxYzD.js} +1 -1
  12. package/dist/assets/{add-component-core-D76Zubeq.js → add-component-core-fR1K_s-b.js} +19 -19
  13. package/dist/assets/add-resource-C4L5iiYR.js +1 -0
  14. package/dist/assets/addon-B_9u8Uap.js +14 -0
  15. package/dist/assets/{advanced-D6zLG63b.js → advanced-B8Og-q_8.js} +3 -3
  16. package/dist/assets/api-B7LEhzE2.js +1 -0
  17. package/dist/assets/appearance-CzutBxVy.js +1 -0
  18. package/dist/assets/arrow-down.svg-ERMGqkAp.js +1 -0
  19. package/dist/assets/{audit-logs-CdG4bSHH.js → audit-logs-CeCLVKmc.js} +3 -3
  20. package/dist/assets/authorize-DZ53nGXa.js +1 -0
  21. package/dist/assets/{base-chart-CYYG4HBW.js → base-chart-DfvV1Wek.js} +1 -1
  22. package/dist/assets/base32-D5SW9slW.js +1 -0
  23. package/dist/assets/{branding-_WV1QAAs.js → branding-DqrEqckw.js} +6 -6
  24. package/dist/assets/branding-k1UuAgbL.js +40 -0
  25. package/dist/assets/bundle-avatar-DoaTu2bf.js +1 -0
  26. package/dist/assets/button-Cq26ea05.js +1 -0
  27. package/dist/assets/click-to-copy-53HtxuZ-.js +1 -0
  28. package/dist/assets/cloneDeep-C4F9EbDd.js +1 -0
  29. package/dist/assets/{collapse-hSqt1R5N.js → collapse-BWjaTK3Y.js} +1 -1
  30. package/dist/assets/complete-CTL412MW.js +39 -0
  31. package/dist/assets/{component-DKjuvHj4.js → component-Cr9ErCQn.js} +8 -8
  32. package/dist/assets/config-1BozCK2T.js +1 -0
  33. package/dist/assets/{config-CUi0elhI.js → config-CNQujUIY.js} +2 -2
  34. package/dist/assets/{config-navigation-Ha3M5G4P.js → config-navigation-DS3ENbD4.js} +7 -7
  35. package/dist/assets/config-space-BJHf-Cd6.js +1 -0
  36. package/dist/assets/confirm-Cap-op6n.js +7 -0
  37. package/dist/assets/connect--oxHn2U3.js +1 -0
  38. package/dist/assets/connect-Du7jX0Sh.js +5 -0
  39. package/dist/assets/connect-to-DFUayzYa.js +1 -0
  40. package/dist/assets/{content-layout-QCcsYBSN.js → content-layout-U_bmDcVP.js} +1 -1
  41. package/dist/assets/createClass-0H_KUZSg.js +1 -0
  42. package/dist/assets/dashboard-D5VBBuOs.js +106 -0
  43. package/dist/assets/delete-confirm-C0sSftJX.js +1 -0
  44. package/dist/assets/did-address-BbLERCPO.js +1 -0
  45. package/dist/assets/domain-action-card-YTqBPBWZ.js +28 -0
  46. package/dist/assets/domain-tDz9aJ1p.js +9 -0
  47. package/dist/assets/domains-B-tnChYf.js +1 -0
  48. package/dist/assets/{dot-BXCAJPqI.js → dot-CSvzbUXF.js} +1 -1
  49. package/dist/assets/{edit.svg-DhSbRuoX.js → edit.svg-D-deOViK.js} +1 -1
  50. package/dist/assets/email-CG37x_qj.js +18 -0
  51. package/dist/assets/{empty-spinner-Iuhp-DUy.js → empty-spinner-Bi1Cb9b7.js} +1 -1
  52. package/dist/assets/engine-BgdxJwhd.js +1 -0
  53. package/dist/assets/exchange-passport-DKVItvkK.js +1 -0
  54. package/dist/assets/{form-mylhS1ms.js → form-CGJGxKNL.js} +3 -3
  55. package/dist/assets/fuel-DVQ9RgQl.js +32 -0
  56. package/dist/assets/gen-access-key-CVqGSMOn.js +2 -0
  57. package/dist/assets/get-safe-url-DeteK1Tn.js +1 -0
  58. package/dist/assets/github-icon-CH2zo-td.js +1 -0
  59. package/dist/assets/home-CjcckRlZ.js +1 -0
  60. package/dist/assets/iframe-CjdjlDtS.js +1 -0
  61. package/dist/assets/index-1MoOycfF.js +1 -0
  62. package/dist/assets/index-B2GXn548.js +1 -0
  63. package/dist/assets/{index-CsOZO30I.js → index-BEKYMIn1.js} +2 -2
  64. package/dist/assets/index-BUiXC-M8.js +348 -0
  65. package/dist/assets/index-Bd8jbR-Z.js +1 -0
  66. package/dist/assets/{index-CJSRV-xv.js → index-BnCifgrr.js} +4 -4
  67. package/dist/assets/index-BojVbZw0.js +1 -0
  68. package/dist/assets/index-BpP1Znfh.js +1019 -0
  69. package/dist/assets/index-BqxH9RUX.js +284 -0
  70. package/dist/assets/index-BwLbaIOO.js +1 -0
  71. package/dist/assets/{index-Bvup9KK2.js → index-C-vjjw9E.js} +1 -1
  72. package/dist/assets/{index-CuVvB-Cv.js → index-CF0F1TwU.js} +1 -1
  73. package/dist/assets/index-CPh83bMS.js +55 -0
  74. package/dist/assets/{index-CxOcEJip.js → index-CXr199vi.js} +6 -6
  75. package/dist/assets/{index-troycNLC.js → index-CeSZphll.js} +12 -12
  76. package/dist/assets/index-D4YNeVBT.js +77 -0
  77. package/dist/assets/index-DRYJ0xIl.js +7 -0
  78. package/dist/assets/{index-CMf86-QO.js → index-DbIUA2zH.js} +1 -1
  79. package/dist/assets/{index-DareKNWL.js → index-Dcvh9y_X.js} +2 -2
  80. package/dist/assets/index-DmmlDdES.js +1 -0
  81. package/dist/assets/index-DnIF_NYU.js +16 -0
  82. package/dist/assets/index-DrVXX4fX.css +1 -0
  83. package/dist/assets/{index-y3-0A2va.js → index-DyFP7QxB.js} +23 -23
  84. package/dist/assets/index-M4aOFxEp.js +1 -0
  85. package/dist/assets/{index-BmzIIRpf.js → index-MGxe3V9B.js} +1 -1
  86. package/dist/assets/index-QJUPJwU5.js +29 -0
  87. package/dist/assets/index-SCzvv_RV.js +102 -0
  88. package/dist/assets/index-WQwUkHG7.js +113 -0
  89. package/dist/assets/index-azWn8MOB.js +269 -0
  90. package/dist/assets/index-m1CzDMXa.js +4 -0
  91. package/dist/assets/{index-DjNdCKSK.js → index-sx11rzaE.js} +9 -9
  92. package/dist/assets/index-v4-5jfLi.js +1 -0
  93. package/dist/assets/index-vQRat2tv.js +7 -0
  94. package/dist/assets/index-wBG-OAs3.js +1 -0
  95. package/dist/assets/{index-DQ2ZPkAL.js → index-wrdyuzbe.js} +2 -2
  96. package/dist/assets/{index-HJ9bCmon.js → index-yMf5L8qr.js} +1 -1
  97. package/dist/assets/{index.esm-CkOXP-jL.js → index.esm-BONQrRCU.js} +1 -1
  98. package/dist/assets/invitation-gz7ZaT6I.js +177 -0
  99. package/dist/assets/invite-aUuSwMvb.js +1 -0
  100. package/dist/assets/issue-passport-CvpS7DxT.js +1 -0
  101. package/dist/assets/item-CbTF-0Oa.js +1 -0
  102. package/dist/assets/landing-page-D37ZgHkj.js +1 -0
  103. package/dist/assets/{launch-result-message-Cxe_kPrP.js → launch-result-message-CDvcIXJ3.js} +1 -1
  104. package/dist/assets/{layout-DkPyTaVW.js → layout-BEzS8OOg.js} +2 -2
  105. package/dist/assets/list-BJA6szjY.js +2 -0
  106. package/dist/assets/list-BqHIXcPP.js +103 -0
  107. package/dist/assets/{list-header-CxfG7AtB.js → list-header-Bcr2R_3c.js} +1 -1
  108. package/dist/assets/localization-Lor7sJD1.js +1 -0
  109. package/dist/assets/{lock.svg-BRQnEAKL.js → lock.svg-xPuKHQ-O.js} +1 -1
  110. package/dist/assets/{log-DZVsi88y.js → log-BQUD4DCn.js} +1 -1
  111. package/dist/assets/logger-Bohy94BY.js +1 -0
  112. package/dist/assets/login-C2QfPDRA.js +1 -0
  113. package/dist/assets/login-oauth-callback-M7KZI2Od.js +1 -0
  114. package/dist/assets/{logo-uploader-X2TJccsm.js → logo-uploader-DN6GOOGh.js} +5 -5
  115. package/dist/assets/{lost-passport-BmeRKwmT.js → lost-passport-CJIQWjW5.js} +4 -4
  116. package/dist/assets/{lottie-react.esm-k2Km8DK4.js → lottie-react.esm-Bqal_rmd.js} +1 -1
  117. package/dist/assets/omit-LyexeK2n.js +1 -0
  118. package/dist/assets/open-window-DfDYFiaE.js +1 -0
  119. package/dist/assets/over-due-invoice-payment-Bd6FvSmz.js +1 -0
  120. package/dist/assets/{overview-D-oWyxxM.js → overview-DjT71Ru7.js} +3 -3
  121. package/dist/assets/{page-header-C3zFQU72.js → page-header-a5Qh5Tr1.js} +2 -2
  122. package/dist/assets/passport-item-wFQM_IPn.js +1 -0
  123. package/dist/assets/{permission-BT6A_5g7.js → permission-C8zjFCnE.js} +1 -1
  124. package/dist/assets/preferences-BfPbWKcX.js +1 -0
  125. package/dist/assets/profile-embed-C7Eh6vHi.js +1 -0
  126. package/dist/assets/publish-resource-B6a9Z8Sv.js +1 -0
  127. package/dist/assets/{question-mark-circle.svg-Dsn3tw38.js → question-mark-circle.svg-YsMacl4Q.js} +1 -1
  128. package/dist/assets/{raf-schd.esm-Cy5s98oK.js → raf-schd.esm-BZ5FB5HD.js} +1 -1
  129. package/dist/assets/{react-beautiful-dnd.esm-B7r3OKKK.js → react-beautiful-dnd.esm-Jbqi4QL3.js} +1 -1
  130. package/dist/assets/{react-stripe.esm-iz31a8Oy.js → react-stripe.esm-D_PEjY7V.js} +1 -1
  131. package/dist/assets/runtime-CPv3tqpJ.js +1 -0
  132. package/dist/assets/{sanitize-CNYhE_fv.js → sanitize-Be9_TGIg.js} +1 -1
  133. package/dist/assets/sdk-D8T5YhY1.js +1 -0
  134. package/dist/assets/{section-DG_88Iq9.js → section-76c1fWcb.js} +1 -1
  135. package/dist/assets/{security-C3JSOgkl.js → security-zyp6GX8Q.js} +4 -4
  136. package/dist/assets/{server-logo-notext.svg-BDfKF66U.js → server-logo-notext.svg-BqCXmsOm.js} +1 -1
  137. package/dist/assets/session-Ctfgia_m.js +1 -0
  138. package/dist/assets/setup-CDOoR5tS.js +30 -0
  139. package/dist/assets/{shorten-label-CMcbJgkJ.js → shorten-label-CqCkrOW-.js} +1 -1
  140. package/dist/assets/{simple-select-FEjR7w5_.js → simple-select-BtDvaDm3.js} +1 -1
  141. package/dist/assets/spaces-BaVWWOGx.js +1 -0
  142. package/dist/assets/start-ic-fIO06.js +187 -0
  143. package/dist/assets/starting-progress-DIeXw59f.js +40 -0
  144. package/dist/assets/status-DHHxfaoI.js +1 -0
  145. package/dist/assets/{step-actions-C2pOiZon.js → step-actions-Br-SRUy8.js} +1 -1
  146. package/dist/assets/studio-BoDvKSdd.js +6 -0
  147. package/dist/assets/switch-control-gGb7roLA.js +18 -0
  148. package/dist/assets/table-tips-DCJRX0td.js +1 -0
  149. package/dist/assets/traffic-D1T3F5UM.js +1 -0
  150. package/dist/assets/transfer-DJIdkLYb.js +16 -0
  151. package/dist/assets/unsubscribe-CzVwGQa2.js +1 -0
  152. package/dist/assets/{use-blocklet-logo-BEiiWhw_.js → use-blocklet-logo-CjoRB6rM.js} +6 -6
  153. package/dist/assets/{use-mobile-CbxgT1_q.js → use-mobile-BgklPLaO.js} +1 -1
  154. package/dist/assets/{use-mobile-KernkJ0t.js → use-mobile-BkNZycG6.js} +1 -1
  155. package/dist/assets/{use-server-logo-CnmK6Efi.js → use-server-logo-DZ_rNHFu.js} +1 -1
  156. package/dist/assets/useAsync-COkfundQ.js +1 -0
  157. package/dist/assets/{useAsync-sAAs4CGb.js → useAsync-fxvoN33w.js} +1 -1
  158. package/dist/assets/useLocalStorage-BrLsVuBH.js +1 -0
  159. package/dist/assets/{useSetState-BO0mlssA.js → useSetState-BWrXo9eH.js} +1 -1
  160. package/dist/assets/user-center-BTomYU5X.js +126 -0
  161. package/dist/assets/user-center-Beq7bNaq.js +77 -0
  162. package/dist/assets/user-sessions-BxCDj69X.js +1 -0
  163. package/dist/assets/util-Dp7qZZRR.js +1 -0
  164. package/dist/assets/util-SCxpGcR7.js +1 -0
  165. package/dist/assets/vendor-arcblock-Cvkavi6C.js +1419 -0
  166. package/dist/assets/vendor-hooks-CFpNP5Ql.js +7 -0
  167. package/dist/assets/{vendor-mui-core-CB7usZvs.js → vendor-mui-core-Bz-X9hX7.js} +2 -2
  168. package/dist/assets/{vendor-mui-x-Cn6DlQME.js → vendor-mui-x-Cgnunrow.js} +1 -1
  169. package/dist/assets/{vendor-react-BvXSmFbV.js → vendor-react-x2lQvn4m.js} +1 -1
  170. package/dist/assets/{vendor-utils-eI_TRB_9.js → vendor-utils-Vke2d2wu.js} +2 -2
  171. package/dist/assets/vendor-ux-D2yvD18l.js +1568 -0
  172. package/dist/assets/{vendor-ux-did-connect-C3VYvpKG.css → vendor-ux-DYcPPYq2.css} +1 -1
  173. package/dist/assets/wrap-locale-DRH6wq1d.js +1 -0
  174. package/dist/assets/zh-D9byyq6s.js +1 -0
  175. package/dist/index.html +9 -9
  176. package/dist/service-worker.js +1 -1
  177. package/package.json +33 -33
  178. package/dist/assets/AdapterDayjs-C4xA34Wo.js +0 -3
  179. package/dist/assets/access-control-DiMFm5vm.js +0 -14
  180. package/dist/assets/add-resource-QtPySaVp.js +0 -1
  181. package/dist/assets/addon-BlQzxfa9.js +0 -14
  182. package/dist/assets/api-Cux33v3g.js +0 -1
  183. package/dist/assets/appearance-ALezezqS.js +0 -1
  184. package/dist/assets/authorize-Bf6tuW6d.js +0 -1
  185. package/dist/assets/base32-ApkcljBe.js +0 -1
  186. package/dist/assets/branding-DMgflqsR.js +0 -40
  187. package/dist/assets/bundle-avatar-ZXyAO7K1.js +0 -1
  188. package/dist/assets/button-HKPEWKSE.js +0 -1
  189. package/dist/assets/click-to-copy-C9F3ippp.js +0 -1
  190. package/dist/assets/cloneDeep-D_6REFFg.js +0 -1
  191. package/dist/assets/complete-TvShCSjx.js +0 -39
  192. package/dist/assets/config-B_jSftWs.js +0 -1
  193. package/dist/assets/config-space-Bf5mw5iZ.js +0 -1
  194. package/dist/assets/confirm-ChzBz5HU.js +0 -7
  195. package/dist/assets/connect-ClCSSq0i.js +0 -5
  196. package/dist/assets/connect-DvZ8YtIj.js +0 -1
  197. package/dist/assets/connect-to-BHJ-dAXD.js +0 -1
  198. package/dist/assets/createClass-DrvVCDPe.js +0 -1
  199. package/dist/assets/dashboard-BObw3ALy.js +0 -106
  200. package/dist/assets/delete-confirm-BR2J5ZDD.js +0 -1
  201. package/dist/assets/did-address-D3Egz-BH.js +0 -1
  202. package/dist/assets/domain-DcVIImSr.js +0 -9
  203. package/dist/assets/domain-action-card-DhD_cXV_.js +0 -28
  204. package/dist/assets/domains-ou456zE4.js +0 -1
  205. package/dist/assets/email-Dl0EXVcw.js +0 -18
  206. package/dist/assets/engine-sqdrhsce.js +0 -1
  207. package/dist/assets/exchange-passport-BSJ3G8lf.js +0 -1
  208. package/dist/assets/fuel-Bd06KJQe.js +0 -32
  209. package/dist/assets/gen-access-key-m-8Jt1Hc.js +0 -2
  210. package/dist/assets/get-safe-url-BH99736U.js +0 -1
  211. package/dist/assets/home-bdgdtKT6.js +0 -1
  212. package/dist/assets/iframe-B0Sl1srb.js +0 -1
  213. package/dist/assets/index-B3QNvDDj.js +0 -746
  214. package/dist/assets/index-BZR3BNLz.js +0 -1
  215. package/dist/assets/index-BqGWM_OW.js +0 -77
  216. package/dist/assets/index-BxJtY5Kv.js +0 -284
  217. package/dist/assets/index-CFeWjGB5.js +0 -55
  218. package/dist/assets/index-CGtM1j0R.js +0 -5
  219. package/dist/assets/index-CrwOcYsE.js +0 -1
  220. package/dist/assets/index-Cx0gea65.js +0 -4
  221. package/dist/assets/index-DH-srZsa.js +0 -113
  222. package/dist/assets/index-DiZ-o7if.js +0 -1
  223. package/dist/assets/index-DrCTi6nm.css +0 -1
  224. package/dist/assets/index-fEBO3Gzc.js +0 -1
  225. package/dist/assets/index-k7k0SQbv.js +0 -1
  226. package/dist/assets/index-ks-YsRmg.js +0 -7
  227. package/dist/assets/invitation-DbN-YRUm.js +0 -177
  228. package/dist/assets/invite-CIXrj-3X.js +0 -1
  229. package/dist/assets/issue-passport-r6T68j--.js +0 -1
  230. package/dist/assets/item-Bd0ii0Us.js +0 -1
  231. package/dist/assets/list-DXrUx08c.js +0 -2
  232. package/dist/assets/list-DlvWPWYw.js +0 -103
  233. package/dist/assets/localization-Bz_iVajc.js +0 -1
  234. package/dist/assets/logger-CCGgFyYA.js +0 -1
  235. package/dist/assets/login-JGAKiqpV.js +0 -1
  236. package/dist/assets/login-oauth-callback-DqS91pc0.js +0 -1
  237. package/dist/assets/omit-D-CdbK9w.js +0 -1
  238. package/dist/assets/open-window-DcAQjlEr.js +0 -1
  239. package/dist/assets/over-due-invoice-payment-CqC6F7wx.js +0 -1
  240. package/dist/assets/passport-item-CFSqpoVC.js +0 -1
  241. package/dist/assets/preferences-Bp3snrNx.js +0 -1
  242. package/dist/assets/profile-embed-DdOuqHl9.js +0 -1
  243. package/dist/assets/publish-resource-QE-lbMIo.js +0 -1
  244. package/dist/assets/runtime-D3F-K4em.js +0 -1
  245. package/dist/assets/sdk-fQbwfdKO.js +0 -1
  246. package/dist/assets/session-CEzfQzQW.js +0 -1
  247. package/dist/assets/setup-80ncmxUI.js +0 -30
  248. package/dist/assets/spaces-BEQecBKs.js +0 -1
  249. package/dist/assets/start-CeGPz6-6.js +0 -187
  250. package/dist/assets/starting-progress-ACb9l4Xf.js +0 -40
  251. package/dist/assets/status-Ci7ywBRs.js +0 -1
  252. package/dist/assets/studio-CAziGLSY.js +0 -6
  253. package/dist/assets/switch-control-B_6jQTpz.js +0 -18
  254. package/dist/assets/table-tips-Dmnk1ZGp.js +0 -1
  255. package/dist/assets/traffic-BVI8c87H.js +0 -1
  256. package/dist/assets/transfer-BnJYdOTH.js +0 -16
  257. package/dist/assets/unsubscribe-Bt8dn_fv.js +0 -1
  258. package/dist/assets/useAsync--s_vBMXH.js +0 -1
  259. package/dist/assets/useLocalStorage-DmhYFNPM.js +0 -1
  260. package/dist/assets/user-center-DeDT-eSp.js +0 -77
  261. package/dist/assets/util-BA-_-Cnq.js +0 -1
  262. package/dist/assets/util-C7Sp_ClB.js +0 -1
  263. package/dist/assets/vendor-arcblock-B55HFGqZ.js +0 -2399
  264. package/dist/assets/vendor-hooks-BA23GwO5.js +0 -7
  265. package/dist/assets/vendor-ux-did-connect-soajAeMx.js +0 -1702
  266. package/dist/assets/wrap-locale-DXvoSw5L.js +0 -1
  267. package/dist/assets/zh-C8_JX25l.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as b,g as _e,a as ut}from"./vendor-react-BvXSmFbV.js";import{a as mt,m as re}from"./vendor-hooks-BA23GwO5.js";import{j as e,ak as g,ar as W,av as ee,p as _,au as Me,am as K,be as ft,Y as xt,T as E,a7 as ht,$ as T,G as $,M as ae,I as q,di as $e,bp as me,H as gt,D as Oe,dj as qe,dk as X,cf as We,F as He,bA as yt,bt as jt,C as vt,O as bt,V as Ct,bm as St,s as Tt}from"./vendor-mui-core-CB7usZvs.js";import{T as F,as as H,az as wt,ac as fe,$ as le,f as U,a3 as R,n as L,a5 as xe,bE as Ue,ar as Ge,bd as Dt,bY as Ie,bq as It,bD as Pt}from"./vendor-ux-did-connect-soajAeMx.js";import{D as k,n as Rt,y as Ve,U as J,G as kt,al as At,e as Ft,b as se,aN as Nt,R as Ye}from"./index-B3QNvDDj.js";import{W as he}from"./did-address-D3Egz-BH.js";import{u as M}from"./dashboard-BObw3ALy.js";import{r as ge,a as ye,b as je,c as Ke,d as ne,e as Lt,u as zt,f as Bt}from"./passport-item-CFSqpoVC.js";import{p as Ze}from"./util-C7Sp_ClB.js";import{u as Et}from"./use-mobile-KernkJ0t.js";import{A as _t,c as Mt,E as Q}from"./vendor-arcblock-B55HFGqZ.js";import{w as G,P as Je}from"./permission-BT6A_5g7.js";import{C as $t}from"./Google-if7RtO8D.js";import{M as Z,at as Ot,J as qt}from"./vendor-utils-eI_TRB_9.js";import{e as oe}from"./edit.svg-DhSbRuoX.js";import{C as ve}from"./confirm-ChzBz5HU.js";import{L as Qe}from"./list-header-CxfG7AtB.js";import{f as te}from"./index-DBs9Ljax.js";import{u as Wt}from"./useSetState-BO0mlssA.js";import{C as Ht}from"./lock.svg-BRQnEAKL.js";import"./lottie-web-4koyQiv_.js";import"./useLocalStorage-DmhYFNPM.js";import"./get-safe-url-BH99736U.js";import"./session-CEzfQzQW.js";import"./use-blocklet-logo-BEiiWhw_.js";import"./dot-BXCAJPqI.js";import"./useAsync-sAAs4CGb.js";import"./over-due-invoice-payment-CqC6F7wx.js";import"./use-mobile-CbxgT1_q.js";import"./base32-ApkcljBe.js";import"./cloneDeep-D_6REFFg.js";const ie=u=>b.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...u},b.createElement("path",{d:"M8.4375 4.3125H8.25C8.35313 4.3125 8.4375 4.22812 8.4375 4.125V4.3125H15.5625V4.125C15.5625 4.22812 15.6469 4.3125 15.75 4.3125H15.5625V6H17.25V4.125C17.25 3.29766 16.5773 2.625 15.75 2.625H8.25C7.42266 2.625 6.75 3.29766 6.75 4.125V6H8.4375V4.3125ZM20.25 6H3.75C3.33516 6 3 6.33516 3 6.75V7.5C3 7.60313 3.08437 7.6875 3.1875 7.6875H4.60312L5.18203 19.9453C5.21953 20.7445 5.88047 21.375 6.67969 21.375H17.3203C18.1219 21.375 18.7805 20.7469 18.818 19.9453L19.3969 7.6875H20.8125C20.9156 7.6875 21 7.60313 21 7.5V6.75C21 6.33516 20.6648 6 20.25 6ZM17.1398 19.6875H6.86016L6.29297 7.6875H17.707L17.1398 19.6875Z"})),Pe="info";function Xe({createPassportSvg:u,passport:o,onCancel:i,onSwitchPassport:p=()=>{}}){const{t:m}=F(),l=mt({tab:Pe}),h={info:{label:m("common.basicInfo"),value:Pe,component:()=>e.jsx(et,{passport:o,createPassportSvg:u})},logs:{label:m("common.logs"),value:"logs",component:()=>e.jsx(rt,{passport:o})},related:{label:m("team.passport.related"),value:"related",component:()=>e.jsx(at,{passport:o,onSwitchPassport:p})}},a=Object.values(h).map(({label:r,value:t})=>({label:r,value:t})).filter(r=>r.value==="related"?o.parentDid:!0),f=h[l.tab]||h.info,s=r=>{l.tab=r};return e.jsx(H,{title:m("common.passport"),onClose:i,open:!0,PaperProps:{style:{maxWidth:800,minHeight:"80vh"}},fullWidth:!0,children:e.jsxs(Ut,{children:[e.jsx(g,{className:"tabs",children:e.jsx(wt,{tabs:a,current:l.tab,onChange:s,scrollButtons:"auto"})}),e.jsx(g,{className:"body",children:e.jsx(f.component,{})})]})})}Xe.propTypes={createPassportSvg:T.func.isRequired,passport:T.object.isRequired,onCancel:T.func.isRequired,onSwitchPassport:T.func};const Ut=W(g)`
1
+ import{r as C,g as _e,a as ut}from"./vendor-react-x2lQvn4m.js";import{g as mt,k as re}from"./vendor-hooks-CFpNP5Ql.js";import{j as e,ak as g,at as W,b1 as ee,p as _,aX as Me,am as K,cy as ft,Y as xt,T as E,a7 as ht,$ as T,G as $,M as ae,I as q,cH as $e,cf as me,H as gt,D as Oe,bZ as qe,b_ as X,bv as We,F as He,bC as yt,b6 as jt,C as vt,O as Ct,V as bt,bu as St,s as Tt}from"./vendor-mui-core-Bz-X9hX7.js";import{T as F,a as H,j as wt,D as fe,A as le,H as R,n as L,C as xe,M as Ue,q as Ge,a0 as Dt,a9 as Ie,S as It,N as Pt}from"./vendor-ux-D2yvD18l.js";import{_ as k,p as Rt,ad as Ve,c as U,ax as J,Y as kt,aw as At,f as Ft,M as Nt,af as se,b4 as Lt,b5 as Ye}from"./index-BpP1Znfh.js";import{W as he}from"./did-address-BbLERCPO.js";import{u as M}from"./dashboard-D5VBBuOs.js";import{r as ge,a as ye,b as je,c as Ke,d as ne,e as Bt,u as zt,f as Et}from"./passport-item-wFQM_IPn.js";import{p as Ze}from"./util-Dp7qZZRR.js";import{u as _t}from"./use-mobile-BkNZycG6.js";import{v as Q}from"./index-DnIF_NYU.js";import{w as G,P as Je}from"./permission-C8zjFCnE.js";import{C as Mt}from"./Google-Bo2ohqwo.js";import{A as $t}from"./vendor-arcblock-Cvkavi6C.js";import{G as Z,a0 as Ot,H as qt}from"./vendor-utils-Vke2d2wu.js";import{e as oe}from"./edit.svg-D-deOViK.js";import{C as ve}from"./confirm-Cap-op6n.js";import{L as Qe}from"./list-header-Bcr2R_3c.js";import{f as te}from"./index-DBs9Ljax.js";import{u as Wt}from"./useSetState-BWrXo9eH.js";import{C as Ht}from"./lock.svg-xPuKHQ-O.js";import"./lottie-web-4koyQiv_.js";import"./useLocalStorage-BrLsVuBH.js";import"./get-safe-url-DeteK1Tn.js";import"./session-Ctfgia_m.js";import"./use-blocklet-logo-CjoRB6rM.js";import"./dot-CSvzbUXF.js";import"./useAsync-fxvoN33w.js";import"./index-BUiXC-M8.js";import"./over-due-invoice-payment-Bd6FvSmz.js";import"./use-mobile-BgklPLaO.js";import"./index-wBG-OAs3.js";import"./base32-D5SW9slW.js";import"./cloneDeep-C4F9EbDd.js";const ie=u=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...u},C.createElement("path",{d:"M8.4375 4.3125H8.25C8.35313 4.3125 8.4375 4.22812 8.4375 4.125V4.3125H15.5625V4.125C15.5625 4.22812 15.6469 4.3125 15.75 4.3125H15.5625V6H17.25V4.125C17.25 3.29766 16.5773 2.625 15.75 2.625H8.25C7.42266 2.625 6.75 3.29766 6.75 4.125V6H8.4375V4.3125ZM20.25 6H3.75C3.33516 6 3 6.33516 3 6.75V7.5C3 7.60313 3.08437 7.6875 3.1875 7.6875H4.60312L5.18203 19.9453C5.21953 20.7445 5.88047 21.375 6.67969 21.375H17.3203C18.1219 21.375 18.7805 20.7469 18.818 19.9453L19.3969 7.6875H20.8125C20.9156 7.6875 21 7.60313 21 7.5V6.75C21 6.33516 20.6648 6 20.25 6ZM17.1398 19.6875H6.86016L6.29297 7.6875H17.707L17.1398 19.6875Z"})),Pe="info";function Xe({createPassportSvg:u,passport:o,onCancel:i,onSwitchPassport:p=()=>{}}){const{t:m}=F(),l=mt({tab:Pe}),h={info:{label:m("common.basicInfo"),value:Pe,component:()=>e.jsx(et,{passport:o,createPassportSvg:u})},logs:{label:m("common.logs"),value:"logs",component:()=>e.jsx(rt,{passport:o})},related:{label:m("team.passport.related"),value:"related",component:()=>e.jsx(at,{passport:o,onSwitchPassport:p})}},a=Object.values(h).map(({label:r,value:t})=>({label:r,value:t})).filter(r=>r.value==="related"?o.parentDid:!0),f=h[l.tab]||h.info,s=r=>{l.tab=r};return e.jsx(H,{title:m("common.passport"),onClose:i,open:!0,PaperProps:{style:{maxWidth:800,minHeight:"80vh"}},fullWidth:!0,children:e.jsxs(Ut,{children:[e.jsx(g,{className:"tabs",children:e.jsx(wt,{tabs:a,current:l.tab,onChange:s,scrollButtons:"auto"})}),e.jsx(g,{className:"body",children:e.jsx(f.component,{})})]})})}Xe.propTypes={createPassportSvg:T.func.isRequired,passport:T.object.isRequired,onCancel:T.func.isRequired,onSwitchPassport:T.func};const Ut=W(g)`
2
2
  margin-top: -16px;
3
3
 
4
4
  .tabs {
@@ -9,7 +9,7 @@ import{r as b,g as _e,a as ut}from"./vendor-react-BvXSmFbV.js";import{a as mt,m
9
9
  .body {
10
10
  margin-top: 24px;
11
11
  }
12
- `;function et({createPassportSvg:u,passport:o}){const{t:i,locale:p}=F(),{teamDid:m}=M(),{inService:l}=k(),h=Et(),a=[{items:[{label:i("common.role"),content:ge(o.title)},{label:i("common.did"),content:e.jsx(he,{did:o.id})},{label:i("team.passport.status"),content:je(o.status)},{label:i("common.type"),content:e.jsx(g,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:(o.type||[]).map(s=>e.jsx(xt,{label:s,variant:"outlined",size:"small",sx:{borderRadius:1}},s))})}]}],f=[{title:i("team.passport.owner"),items:[{label:i("team.passport.owner"),content:e.jsx(g,{children:ye(o.user,l)})}]},{title:i("common.timeInfo"),items:[{label:i("team.passport.issuanceTime"),content:o.issuanceDate?e.jsx(le,{value:o.issuanceDate,type:"all",locale:p}):"-"},{label:i("team.member.lastLogin"),content:o.lastLoginAt?e.jsx(le,{value:o.lastLoginAt,type:"all",locale:p}):"-"},{label:i("common.expires"),content:o.expirationDate?e.jsx(le,{value:o.expirationDate,type:"all",locale:p}):"-"}]},{title:i("blocklet.overview.source"),items:[{label:i("blocklet.overview.source"),content:ne(o.source)}]}];return e.jsxs(Gt,{gap:3,children:[e.jsxs(g,{sx:{display:"flex",flexDirection:h?"column":"row",alignItems:h?"flex-start":"center",justifyContent:h?"center":"flex-start",width:"100%",overflow:"hidden",gap:h?2:4},children:[e.jsx(g,{sx:{display:"flex",width:"180px"},className:"passport-image",dangerouslySetInnerHTML:{__html:u({scope:o.scope,role:o.role,title:o.scope==="kyc"?o.name:o.title,issuer:o.issuer&&o.issuer.name,issuerDid:o.issuer&&o.issuer.id,ownerName:o.user?.fullName,ownerDid:o.user?.did,ownerAvatarUrl:o.user?.avatar?Ze(o.user?.avatar,m,l):"",revoked:o.revoked,extra:o?.expirationDate?{key:"Exp",value:Ve(o.expirationDate).format("YYYY-MM-DD HH:mm:ss")}:null})}}),e.jsx(g,{className:"info-area",children:a.map(s=>e.jsxs(g,{children:[s.title&&e.jsx(E,{variant:"h6",sx:{mb:2},children:s.title}),e.jsx(g,{className:"info-grid",sx:{gap:"12px !important"},children:s.items.map(r=>e.jsxs(g,{className:"info-item",children:[e.jsx(g,{className:"info-label",sx:{maxWidth:40},children:e.jsx(E,{variant:"subtitle2",color:"textSecondary",children:r.label})}),e.jsx(g,{sx:{display:"flex",flexWrap:"wrap",gap:.5,minWidth:0},children:r.content})]},r.label))})]},s.title))})]}),e.jsx(ht,{}),e.jsx(g,{className:"info-area",children:f.map(s=>e.jsxs(g,{children:[e.jsx(E,{variant:"h5",sx:{mb:1.5},children:s.title}),e.jsx(g,{className:"info-grid",children:s.items.map(r=>e.jsxs(g,{className:"info-item",children:[e.jsx(g,{className:"info-label",children:e.jsx(E,{variant:"subtitle2",color:"textSecondary",children:r.label})}),e.jsx(g,{sx:{minWidth:500},children:r.content})]},r.label))})]},s.title))})]})}et.propTypes={passport:T.object.isRequired,createPassportSvg:T.func.isRequired};const Gt=W(ee)`
12
+ `;function et({createPassportSvg:u,passport:o}){const{t:i,locale:p}=F(),{teamDid:m}=M(),{inService:l}=k(),h=_t(),a=[{items:[{label:i("common.role"),content:ge(o.title)},{label:i("common.did"),content:e.jsx(he,{did:o.id})},{label:i("team.passport.status"),content:je(o.status)},{label:i("common.type"),content:e.jsx(g,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:(o.type||[]).map(s=>e.jsx(xt,{label:s,variant:"outlined",size:"small",sx:{borderRadius:1}},s))})}]}],f=[{title:i("team.passport.owner"),items:[{label:i("team.passport.owner"),content:e.jsx(g,{children:ye(o.user,l)})}]},{title:i("common.timeInfo"),items:[{label:i("team.passport.issuanceTime"),content:o.issuanceDate?e.jsx(le,{value:o.issuanceDate,type:"all",locale:p}):"-"},{label:i("team.member.lastLogin"),content:o.lastLoginAt?e.jsx(le,{value:o.lastLoginAt,type:"all",locale:p}):"-"},{label:i("common.expires"),content:o.expirationDate?e.jsx(le,{value:o.expirationDate,type:"all",locale:p}):"-"}]},{title:i("blocklet.overview.source"),items:[{label:i("blocklet.overview.source"),content:ne(o.source)}]}];return e.jsxs(Gt,{gap:3,children:[e.jsxs(g,{sx:{display:"flex",flexDirection:h?"column":"row",alignItems:h?"flex-start":"center",justifyContent:h?"center":"flex-start",width:"100%",overflow:"hidden",gap:h?2:4},children:[e.jsx(g,{sx:{display:"flex",width:"180px"},className:"passport-image",dangerouslySetInnerHTML:{__html:u({scope:o.scope,role:o.role,title:o.scope==="kyc"?o.name:o.title,issuer:o.issuer&&o.issuer.name,issuerDid:o.issuer&&o.issuer.id,ownerName:o.user?.fullName,ownerDid:o.user?.did,ownerAvatarUrl:o.user?.avatar?Ze(o.user?.avatar,m,l):"",revoked:o.revoked,extra:o?.expirationDate?{key:"Exp",value:Ve(o.expirationDate).format("YYYY-MM-DD HH:mm:ss")}:null})}}),e.jsx(g,{className:"info-area",children:a.map(s=>e.jsxs(g,{children:[s.title&&e.jsx(E,{variant:"h6",sx:{mb:2},children:s.title}),e.jsx(g,{className:"info-grid",sx:{gap:"12px !important"},children:s.items.map(r=>e.jsxs(g,{className:"info-item",children:[e.jsx(g,{className:"info-label",sx:{maxWidth:40},children:e.jsx(E,{variant:"subtitle2",color:"textSecondary",children:r.label})}),e.jsx(g,{sx:{display:"flex",flexWrap:"wrap",gap:.5,minWidth:0},children:r.content})]},r.label))})]},s.title))})]}),e.jsx(ht,{}),e.jsx(g,{className:"info-area",children:f.map(s=>e.jsxs(g,{children:[e.jsx(E,{variant:"h5",sx:{mb:1.5},children:s.title}),e.jsx(g,{className:"info-grid",children:s.items.map(r=>e.jsxs(g,{className:"info-item",children:[e.jsx(g,{className:"info-label",children:e.jsx(E,{variant:"subtitle2",color:"textSecondary",children:r.label})}),e.jsx(g,{sx:{minWidth:500},children:r.content})]},r.label))})]},s.title))})]})}et.propTypes={passport:T.object.isRequired,createPassportSvg:T.func.isRequired};const Gt=W(ee)`
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 ut}from"./vendor-react-BvXSmFbV.js";import{a as mt,m
87
87
  margin: 0;
88
88
  }
89
89
  }
90
- `,tt=10,st=1;function rt({passport:u}){const{api:o}=k(),{teamDid:i}=M(),{t:p,locale:m}=F(),[l,h]=b.useState({pageSize:tt,page:st}),{data:a,loading:f}=re(async()=>{const y={teamDid:i,query:{passportId:u.id},paging:{page:l.page,pageSize:l.pageSize}},x=await o.getPassportLogs({input:y});return{logs:x.passportLogs||[],total:x.paging.total}},{refreshDeps:[l.page,l.pageSize],onError:y=>R.error(y.message)}),s=b.useMemo(()=>a?.logs||[],[a?.logs]),r=y=>y.action===U.PASSPORT_LOG_ACTION.APPROVE||y.action===U.PASSPORT_LOG_ACTION.REVOKE?y?.metadata?.operator?.fullName?`${p("common.operator")}: ${y?.metadata?.operator?.fullName}`:null:y.action===U.PASSPORT_LOG_ACTION.ISSUE&&y.metadata?.action===U.PASSPORT_ISSUE_ACTION.ISSUE_ON_INVITE?y?.metadata?.inviter?.fullName?`${p("common.inviter")}: ${y?.metadata?.inviter?.fullName}`:null:`passportId: ${y.passportId}`,t=b.useMemo(()=>[{label:p("common.action"),name:"action",options:{customBodyRender:(y,{rowIndex:x})=>{const d=s[x];return e.jsx(K,{title:r(d),children:`${y} ${d.metadata?.action?`(${d.metadata.action})`:""}`})}}},{label:"IP",name:"operatorIp",options:{customBodyRender:y=>e.jsx(g,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsx("span",{children:y||"-"})})}},{label:"UA",width:250,name:"operatorUa",options:{customBodyRender:(y,{rowIndex:x})=>{const d=s[x];return e.jsxs(g,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.operatorUa&&e.jsx(g,{children:Lt(d.operatorUa)}),d.operatorUa&&e.jsx(K,{title:d.operatorUa,children:e.jsx(ft,{fontSize:"small",color:"action",sx:{fontSize:16,cursor:"pointer"}})})]})}}},{label:p("common.createdAt"),name:"createdAt",options:{customBodyRender:y=>Rt(y,m)}}],[p,m,s]),n=({page:y,rowsPerPage:x})=>{l.pageSize!==x?h(d=>({...d,pageSize:x,page:1})):l.page!==y+1&&h(d=>({...d,page:y+1}))},c={sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,search:!1,page:l.page-1,rowsPerPage:l.pageSize,count:a?.total||0};return f?e.jsx(g,{sx:{py:2},children:e.jsx(ee,{direction:"row",spacing:1,sx:{position:"relative",pb:2},children:e.jsx(_,{})})}):e.jsx(g,{children:e.jsx(fe,{className:"logs-table",verticalKeyWidth:100,locale:m,data:s,columns:t,options:c,loading:f,onChange:n})})}rt.propTypes={passport:T.object.isRequired};function at({passport:u,onSwitchPassport:o}){const{api:i}=k(),{teamDid:p}=M(),{t:m,locale:l}=F(),[h,a]=b.useState({pageSize:tt,page:st}),{data:f,loading:s}=re(async()=>{const x={teamDid:p,passportId:u.parentDid,paging:{page:h.page,pageSize:h.pageSize}},d=await i.getRelatedPassports({input:x});return{passports:d.passports||[],total:d.paging.total}},{refreshDeps:[h.page,h.pageSize],onError:x=>R.error(x.message)}),r=b.useMemo(()=>f?.passports||[],[f?.passports]),t=b.useMemo(()=>[{label:m("team.passport.role"),name:"role",options:{customBodyRender:ge}},{label:m("team.passport.owner"),name:"user",options:{customBodyRender:ye}},{label:m("team.passport.status"),name:"status",options:{customBodyRender:je}},{label:m("team.member.lastLogin"),name:"lastLoginAt",options:{customBodyRender:x=>Ke(x,l)}},{label:m("blocklet.overview.source"),name:"source",options:{customBodyRender:ne}}],[m,l]),n=({page:x,rowsPerPage:d})=>{h.pageSize!==d?a(j=>({...j,pageSize:d,page:1})):h.page!==x+1&&a(j=>({...j,page:x+1}))},c=b.useRef(null),y={sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,search:!1,page:h.page-1,rowsPerPage:h.pageSize,count:f?.total||0,onRowClick(x,{dataIndex:d},j){if(c.current?.contains(j.target)){const S=r[d];o(S)}}};return s?e.jsx(g,{sx:{py:2},children:e.jsx(ee,{direction:"row",spacing:1,sx:{position:"relative",pb:2},children:e.jsx(_,{})})}):e.jsxs(ee,{spacing:1,children:[e.jsx(Me,{severity:"warning",children:m("team.passport.relatedDescription")}),e.jsx(g,{ref:c,sx:{".MuiTableRow-root":{cursor:"pointer"}},children:e.jsx(fe,{className:"related-table",verticalKeyWidth:100,locale:l,data:r.filter(x=>x.id!==u.id),columns:t,options:y,loading:s,onChange:n})})]})}at.propTypes={passport:T.object.isRequired,onSwitchPassport:T.func.isRequired};function be({onCancel:u,onSuccess:o}){const{api:i}=k(),{blocklet:p}=kt(),{t:m}=F(),[l,h]=b.useState(!1),a=(p.environments.find(n=>n.key==="BLOCKLET_PASSPORT_COLOR")||{}).value||"auto",f=a==="auto"?_t(p.appDid):a,[s,r]=b.useState(f),t=async()=>{const n=[{key:Mt.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_PASSPORT_COLOR,value:s}];try{h(!0),await i.configBlocklet({input:{did:p.meta.did,configs:n}}),o()}catch(c){R.error(c.message)}finally{h(!1)}};return e.jsx(H,{title:m("team.passport.color"),onClose:u,open:!0,fullWidth:!0,actions:e.jsxs(e.Fragment,{children:[e.jsx(L,{onClick:u,color:"inherit",children:m("common.cancel")}),e.jsxs(L,{onClick:t,color:"primary",disabled:l,variant:"contained",autoFocus:!0,"data-cy":"color-btn-confirm",children:[l&&e.jsx(_,{size:16}),m("common.save")]})]}),children:e.jsxs(g,{className:"dialog-content",sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:[e.jsx($t,{disableAlpha:!0,color:s,onChange:n=>r(n.hex)}),e.jsx("div",{style:{width:220,marginLeft:24},dangerouslySetInnerHTML:{__html:At({scope:"passport",role:"owner",title:"Owner",issuer:Ft.getDisplayName(p),issuerDid:p.appDid,ownerName:"Your Name",ownerDid:p.appDid,preferredColor:s})}})]})})}const Vt=G(be,"mutate_team"),Yt=G(be,"",J);function Kt(u){const{inService:o}=k();return o?e.jsx(Yt,{...u}):e.jsx(Vt,{...u})}be.propTypes={onCancel:T.func.isRequired,onSuccess:T.func.isRequired};var nt=function(o){return e.jsx("svg",{...o,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"})})};nt.defaultProps={width:"65",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg"};const Zt=(u,o)=>u?!o.some(i=>!i.from.passport||!i.to.role):!1;function ot({onCancel:u,onSuccess:o,data:i={},trustedPassports:p=[]}){const{api:m}=k(),{roles:l,teamDid:h}=M(),{t:a}=F(),[f,s]=b.useState(!1),[r,t]=b.useState(i.issuerDid||""),[n,c]=b.useState(i.remark||""),[y,x]=b.useState(Z(i.mappings)||[]),d=p.findIndex(S=>S.issuerDid===i.issuerDid),j=async()=>{if(f)return;const S={issuerDid:r,remark:n,mappings:y.map(C=>({...C,to:{...C.to,ttl:C.to.ttl||0}}))},w=[...p];d===-1?w.unshift(S):w[d]=S;try{s(!0),await m.configTrustedPassports({input:{teamDid:h,trustedPassports:w}}),await se(800),s(!1),R.success(a("common.saveSuccess")),o()}catch(C){s(!1),R.error(te(C))}};return e.jsx(H,{title:a("team.passport.trustedIssuers"),open:!0,showCloseButton:!1,PaperProps:{style:{minHeight:"80vh"}},fullWidth:!0,prepend:e.jsx(q,{onClick:u,"data-cy":"trusted-issuer-close",size:"large",children:e.jsx($e,{})}),actions:e.jsxs(e.Fragment,{children:[e.jsx(L,{onClick:u,color:"inherit",children:a("common.cancel")}),e.jsxs(L,{onClick:()=>j(),color:"primary",disabled:!Zt(r,y)||!n||f,variant:"contained",autoFocus:!0,"data-cy":"save-mapping",children:[f&&e.jsx(_,{size:16}),a("common.save")]})]}),children:e.jsx(Jt,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx($,{fullWidth:!0,"data-cy":"input-issuer-did",placeholder:a("team.passport.issuerDid"),value:r,onChange:S=>{t(S.target.value)}}),e.jsx($,{style:{marginTop:16},fullWidth:!0,"data-cy":"input-issuer-remark",placeholder:a("common.remark"),value:n,onChange:S=>{c(S.target.value)}}),e.jsxs(g,{sx:{mt:"30px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(g,{className:"dialog-h1",children:a("team.passport.mappingRule")}),e.jsx(g,{children:e.jsx(L,{variant:"outlined",color:"primary","data-cy":"add-mapping",onClick:()=>{x(S=>{const w=[...S];return w.unshift({from:{passport:""},to:{role:U.ROLES.GUEST}}),w})},children:a("team.add")})})]}),e.jsxs(g,{className:"list",sx:{mt:-.5},children:[y.map((S,w)=>e.jsxs(g,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",my:3},children:[e.jsxs(g,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[e.jsx(g,{sx:{flexGrow:1,flexBasis:1},children:e.jsx($,{fullWidth:!0,size:"small","data-cy":`input-${w}-from`,placeholder:"Issuer’s Passport Name/ID",value:S.from.passport,onChange:C=>{const{value:P}=C.target;x(D=>{const z=[...D];return z[w].from.passport=P,z})}})}),e.jsx(g,{sx:{flexShrink:0,mx:4},children:e.jsx(nt,{})}),e.jsx(g,{sx:{flexGrow:1,flexBasis:1},children:e.jsx($,{fullWidth:!0,size:"small",select:!0,value:S.to.role,onChange:C=>{x(P=>{const D=[...P];return D[w].to.role=C.target.value,D})},variant:"outlined",children:l.filter(C=>C.name!=="owner").map(C=>e.jsx(ae,{value:C.name,"data-cy":`passport-mapping-select-option-${C.name}`,children:e.jsx("span",{children:C.title||C.name})},C.name))})})]}),e.jsx(g,{sx:{flexShrink:0,ml:4},children:e.jsx(q,{onClick:()=>{x(C=>{const P=[...C];return P.splice(w,1),P})},size:"large",children:e.jsx(ie,{})})})]},`mapping-${w}`)),!y.length&&e.jsx(g,{sx:{my:2,color:"text.secondary",fontSize:"16px"},children:e.jsx(xe,{children:a("common.empty")})})]})]})})})}ot.propTypes={onCancel:T.func.isRequired,onSuccess:T.func.isRequired,trustedPassports:T.array,data:T.object};const Jt=W.div`
90
+ `,tt=10,st=1;function rt({passport:u}){const{api:o}=k(),{teamDid:i}=M(),{t:p,locale:m}=F(),[l,h]=C.useState({pageSize:tt,page:st}),{data:a,loading:f}=re(async()=>{const y={teamDid:i,query:{passportId:u.id},paging:{page:l.page,pageSize:l.pageSize}},x=await o.getPassportLogs({input:y});return{logs:x.passportLogs||[],total:x.paging.total}},{refreshDeps:[l.page,l.pageSize],onError:y=>R.error(y.message)}),s=C.useMemo(()=>a?.logs||[],[a?.logs]),r=y=>y.action===U.PASSPORT_LOG_ACTION.APPROVE||y.action===U.PASSPORT_LOG_ACTION.REVOKE?y?.metadata?.operator?.fullName?`${p("common.operator")}: ${y?.metadata?.operator?.fullName}`:null:y.action===U.PASSPORT_LOG_ACTION.ISSUE&&y.metadata?.action===U.PASSPORT_ISSUE_ACTION.ISSUE_ON_INVITE?y?.metadata?.inviter?.fullName?`${p("common.inviter")}: ${y?.metadata?.inviter?.fullName}`:null:`passportId: ${y.passportId}`,t=C.useMemo(()=>[{label:p("common.action"),name:"action",options:{customBodyRender:(y,{rowIndex:x})=>{const d=s[x];return e.jsx(K,{title:r(d),children:`${y} ${d.metadata?.action?`(${d.metadata.action})`:""}`})}}},{label:"IP",name:"operatorIp",options:{customBodyRender:y=>e.jsx(g,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsx("span",{children:y||"-"})})}},{label:"UA",width:250,name:"operatorUa",options:{customBodyRender:(y,{rowIndex:x})=>{const d=s[x];return e.jsxs(g,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.operatorUa&&e.jsx(g,{children:Bt(d.operatorUa)}),d.operatorUa&&e.jsx(K,{title:d.operatorUa,children:e.jsx(ft,{fontSize:"small",color:"action",sx:{fontSize:16,cursor:"pointer"}})})]})}}},{label:p("common.createdAt"),name:"createdAt",options:{customBodyRender:y=>Rt(y,m)}}],[p,m,s]),n=({page:y,rowsPerPage:x})=>{l.pageSize!==x?h(d=>({...d,pageSize:x,page:1})):l.page!==y+1&&h(d=>({...d,page:y+1}))},c={sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,search:!1,page:l.page-1,rowsPerPage:l.pageSize,count:a?.total||0};return f?e.jsx(g,{sx:{py:2},children:e.jsx(ee,{direction:"row",spacing:1,sx:{position:"relative",pb:2},children:e.jsx(_,{})})}):e.jsx(g,{children:e.jsx(fe,{className:"logs-table",verticalKeyWidth:100,locale:m,data:s,columns:t,options:c,loading:f,onChange:n})})}rt.propTypes={passport:T.object.isRequired};function at({passport:u,onSwitchPassport:o}){const{api:i}=k(),{teamDid:p}=M(),{t:m,locale:l}=F(),[h,a]=C.useState({pageSize:tt,page:st}),{data:f,loading:s}=re(async()=>{const x={teamDid:p,passportId:u.parentDid,paging:{page:h.page,pageSize:h.pageSize}},d=await i.getRelatedPassports({input:x});return{passports:d.passports||[],total:d.paging.total}},{refreshDeps:[h.page,h.pageSize],onError:x=>R.error(x.message)}),r=C.useMemo(()=>f?.passports||[],[f?.passports]),t=C.useMemo(()=>[{label:m("team.passport.role"),name:"role",options:{customBodyRender:ge}},{label:m("team.passport.owner"),name:"user",options:{customBodyRender:ye}},{label:m("team.passport.status"),name:"status",options:{customBodyRender:je}},{label:m("team.member.lastLogin"),name:"lastLoginAt",options:{customBodyRender:x=>Ke(x,l)}},{label:m("blocklet.overview.source"),name:"source",options:{customBodyRender:ne}}],[m,l]),n=({page:x,rowsPerPage:d})=>{h.pageSize!==d?a(j=>({...j,pageSize:d,page:1})):h.page!==x+1&&a(j=>({...j,page:x+1}))},c=C.useRef(null),y={sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,search:!1,page:h.page-1,rowsPerPage:h.pageSize,count:f?.total||0,onRowClick(x,{dataIndex:d},j){if(c.current?.contains(j.target)){const S=r[d];o(S)}}};return s?e.jsx(g,{sx:{py:2},children:e.jsx(ee,{direction:"row",spacing:1,sx:{position:"relative",pb:2},children:e.jsx(_,{})})}):e.jsxs(ee,{spacing:1,children:[e.jsx(Me,{severity:"warning",children:m("team.passport.relatedDescription")}),e.jsx(g,{ref:c,sx:{".MuiTableRow-root":{cursor:"pointer"}},children:e.jsx(fe,{className:"related-table",verticalKeyWidth:100,locale:l,data:r.filter(x=>x.id!==u.id),columns:t,options:y,loading:s,onChange:n})})]})}at.propTypes={passport:T.object.isRequired,onSwitchPassport:T.func.isRequired};function Ce({onCancel:u,onSuccess:o}){const{api:i}=k(),{blocklet:p}=kt(),{t:m}=F(),[l,h]=C.useState(!1),a=(p.environments.find(n=>n.key==="BLOCKLET_PASSPORT_COLOR")||{}).value||"auto",f=a==="auto"?$t(p.appDid):a,[s,r]=C.useState(f),t=async()=>{const n=[{key:Nt.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_PASSPORT_COLOR,value:s}];try{h(!0),await i.configBlocklet({input:{did:p.meta.did,configs:n}}),o()}catch(c){R.error(c.message)}finally{h(!1)}};return e.jsx(H,{title:m("team.passport.color"),onClose:u,open:!0,fullWidth:!0,actions:e.jsxs(e.Fragment,{children:[e.jsx(L,{onClick:u,color:"inherit",children:m("common.cancel")}),e.jsxs(L,{onClick:t,color:"primary",disabled:l,variant:"contained",autoFocus:!0,"data-cy":"color-btn-confirm",children:[l&&e.jsx(_,{size:16}),m("common.save")]})]}),children:e.jsxs(g,{className:"dialog-content",sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:[e.jsx(Mt,{disableAlpha:!0,color:s,onChange:n=>r(n.hex)}),e.jsx("div",{style:{width:220,marginLeft:24},dangerouslySetInnerHTML:{__html:At({scope:"passport",role:"owner",title:"Owner",issuer:Ft.getDisplayName(p),issuerDid:p.appDid,ownerName:"Your Name",ownerDid:p.appDid,preferredColor:s})}})]})})}const Vt=G(Ce,"mutate_team"),Yt=G(Ce,"",J);function Kt(u){const{inService:o}=k();return o?e.jsx(Yt,{...u}):e.jsx(Vt,{...u})}Ce.propTypes={onCancel:T.func.isRequired,onSuccess:T.func.isRequired};var nt=function(o){return e.jsx("svg",{...o,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"})})};nt.defaultProps={width:"65",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg"};const Zt=(u,o)=>u?!o.some(i=>!i.from.passport||!i.to.role):!1;function ot({onCancel:u,onSuccess:o,data:i={},trustedPassports:p=[]}){const{api:m}=k(),{roles:l,teamDid:h}=M(),{t:a}=F(),[f,s]=C.useState(!1),[r,t]=C.useState(i.issuerDid||""),[n,c]=C.useState(i.remark||""),[y,x]=C.useState(Z(i.mappings)||[]),d=p.findIndex(S=>S.issuerDid===i.issuerDid),j=async()=>{if(f)return;const S={issuerDid:r,remark:n,mappings:y.map(b=>({...b,to:{...b.to,ttl:b.to.ttl||0}}))},w=[...p];d===-1?w.unshift(S):w[d]=S;try{s(!0),await m.configTrustedPassports({input:{teamDid:h,trustedPassports:w}}),await se(800),s(!1),R.success(a("common.saveSuccess")),o()}catch(b){s(!1),R.error(te(b))}};return e.jsx(H,{title:a("team.passport.trustedIssuers"),open:!0,showCloseButton:!1,PaperProps:{style:{minHeight:"80vh"}},fullWidth:!0,prepend:e.jsx(q,{onClick:u,"data-cy":"trusted-issuer-close",size:"large",children:e.jsx($e,{})}),actions:e.jsxs(e.Fragment,{children:[e.jsx(L,{onClick:u,color:"inherit",children:a("common.cancel")}),e.jsxs(L,{onClick:()=>j(),color:"primary",disabled:!Zt(r,y)||!n||f,variant:"contained",autoFocus:!0,"data-cy":"save-mapping",children:[f&&e.jsx(_,{size:16}),a("common.save")]})]}),children:e.jsx(Jt,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx($,{fullWidth:!0,"data-cy":"input-issuer-did",placeholder:a("team.passport.issuerDid"),value:r,onChange:S=>{t(S.target.value)}}),e.jsx($,{style:{marginTop:16},fullWidth:!0,"data-cy":"input-issuer-remark",placeholder:a("common.remark"),value:n,onChange:S=>{c(S.target.value)}}),e.jsxs(g,{sx:{mt:"30px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(g,{className:"dialog-h1",children:a("team.passport.mappingRule")}),e.jsx(g,{children:e.jsx(L,{variant:"outlined",color:"primary","data-cy":"add-mapping",onClick:()=>{x(S=>{const w=[...S];return w.unshift({from:{passport:""},to:{role:U.ROLES.GUEST}}),w})},children:a("team.add")})})]}),e.jsxs(g,{className:"list",sx:{mt:-.5},children:[y.map((S,w)=>e.jsxs(g,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",my:3},children:[e.jsxs(g,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[e.jsx(g,{sx:{flexGrow:1,flexBasis:1},children:e.jsx($,{fullWidth:!0,size:"small","data-cy":`input-${w}-from`,placeholder:"Issuer’s Passport Name/ID",value:S.from.passport,onChange:b=>{const{value:P}=b.target;x(D=>{const B=[...D];return B[w].from.passport=P,B})}})}),e.jsx(g,{sx:{flexShrink:0,mx:4},children:e.jsx(nt,{})}),e.jsx(g,{sx:{flexGrow:1,flexBasis:1},children:e.jsx($,{fullWidth:!0,size:"small",select:!0,value:S.to.role,onChange:b=>{x(P=>{const D=[...P];return D[w].to.role=b.target.value,D})},variant:"outlined",children:l.filter(b=>b.name!=="owner").map(b=>e.jsx(ae,{value:b.name,"data-cy":`passport-mapping-select-option-${b.name}`,children:e.jsx("span",{children:b.title||b.name})},b.name))})})]}),e.jsx(g,{sx:{flexShrink:0,ml:4},children:e.jsx(q,{onClick:()=>{x(b=>{const P=[...b];return P.splice(w,1),P})},size:"large",children:e.jsx(ie,{})})})]},`mapping-${w}`)),!y.length&&e.jsx(g,{sx:{my:2,color:"text.secondary",fontSize:"16px"},children:e.jsx(xe,{children:a("common.empty")})})]})]})})})}ot.propTypes={onCancel:T.func.isRequired,onSuccess:T.func.isRequired,trustedPassports:T.array,data:T.object};const Jt=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 ut}from"./vendor-react-BvXSmFbV.js";import{a as mt,m
99
99
  }
100
100
  }
101
101
  }
102
- `;function Ce({onCancel:u,hasPermission:o=!1}){const{api:i}=k(),{teamDid:p,trustedPassports:m}=M(),{t:l}=F(),[h,a]=b.useState(null),[f,s]=b.useState(!1),[r,t]=b.useState(!1),[n,c]=b.useState(""),y=async d=>{if(f)return;const j=m.findIndex(w=>w.issuerDid===d);j===-1&&R.error("Cannot find passports");const S=[...m];S.splice(j,1);try{s(!0),await i.configTrustedPassports({input:{teamDid:p,trustedPassports:S}}),await se(800),s(!1),R.success(l("common.saveSuccess")),a(!1)}catch(w){s(!1),R.error(w.message)}},x=m.filter(d=>!n||d.issuerDid.toLowerCase().includes(n.toLowerCase()));return e.jsxs(H,{title:l("team.passport.trustedIssuers"),open:!0,onClose:u,fullWidth:!0,PaperProps:{style:{minHeight:"80vh"}},children:[e.jsx(ts,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx("div",{className:"dialog-h1",children:l("team.passport.trustedPassportIssuers")}),e.jsx(Qe,{sx:{mt:3},actions:e.jsxs(e.Fragment,{children:[e.jsx(Ue,{options:{searchPlaceholder:l("team.passport.searchIssuerDid"),searchDebounceTime:600},search:n,searchText:n,searchTextUpdate:c,searchClose:()=>c(""),onSearchOpen:()=>{}}),o&&e.jsxs(L,{variant:"contained",color:"primary","data-cy":"add-trusted-issuer",onClick:()=>t({mode:"add"}),children:[e.jsx(me,{style:{fontSize:16,marginRight:4}}),l("team.add")]})]})}),e.jsxs("div",{className:"list",children:[x.map(d=>e.jsxs(g,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mt:"20px"},children:[e.jsxs(g,{sx:{flexShrink:0},children:[e.jsx(he,{copyable:!1,size:16,did:Ge.toAddress(d.issuerDid),showDidLogo:!1}),!!d.remark&&e.jsx(g,{sx:{fontSize:12,maxWidth:"300px"},children:d.remark})]}),e.jsx(g,{sx:{color:"gray",ml:"28px",flexGrow:1},children:d.mappings&&d.mappings.length?`${d.mappings.length} ${l("team.passport.mappingRule")}`:l("team.passport.defaultRule")}),e.jsxs(g,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:[e.jsx(q,{onClick:()=>t({mode:"update",data:Z(d)}),"data-cy":"edit-mapping-rule",size:"large",children:e.jsx(oe,{})}),e.jsx(q,{"data-cy":"delete-mapping-rule",onClick:()=>a({title:l("common.delete"),description:l("common.delConfirmDescription",{data:d.issuerDid}),confirm:l("common.delConfirm"),cancel:l("common.cancel"),onConfirm:()=>y(d.issuerDid),onCancel:()=>{s(!1),a(null)}}),size:"large",children:e.jsx(ie,{})})]})]},d.issuerDid)),!m.length&&e.jsx(xe,{children:l("common.empty")})]})]})}),r&&e.jsx(ot,{mode:r.mode,data:r.data,trustedPassports:Z(m),onCancel:()=>t(null),onSuccess:()=>{t(null)}}),h&&e.jsx(ve,{title:h.title,description:h.description,confirm:h.confirm,cancel:h.cancel,params:h.params,onConfirm:h.onConfirm,onCancel:h.onCancel})]})}Ce.propTypes={onCancel:T.func.isRequired,hasPermission:T.bool};const Qt=G(Ce,"mutate_team"),Xt=G(Ce,"",J);function es(u){const{inService:o}=k();return o?e.jsx(Xt,{...u}):e.jsx(Qt,{...u})}const ts=W.div`
102
+ `;function be({onCancel:u,hasPermission:o=!1}){const{api:i}=k(),{teamDid:p,trustedPassports:m}=M(),{t:l}=F(),[h,a]=C.useState(null),[f,s]=C.useState(!1),[r,t]=C.useState(!1),[n,c]=C.useState(""),y=async d=>{if(f)return;const j=m.findIndex(w=>w.issuerDid===d);j===-1&&R.error("Cannot find passports");const S=[...m];S.splice(j,1);try{s(!0),await i.configTrustedPassports({input:{teamDid:p,trustedPassports:S}}),await se(800),s(!1),R.success(l("common.saveSuccess")),a(!1)}catch(w){s(!1),R.error(w.message)}},x=m.filter(d=>!n||d.issuerDid.toLowerCase().includes(n.toLowerCase()));return e.jsxs(H,{title:l("team.passport.trustedIssuers"),open:!0,onClose:u,fullWidth:!0,PaperProps:{style:{minHeight:"80vh"}},children:[e.jsx(ts,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx("div",{className:"dialog-h1",children:l("team.passport.trustedPassportIssuers")}),e.jsx(Qe,{sx:{mt:3},actions:e.jsxs(e.Fragment,{children:[e.jsx(Ue,{options:{searchPlaceholder:l("team.passport.searchIssuerDid"),searchDebounceTime:600},search:n,searchText:n,searchTextUpdate:c,searchClose:()=>c(""),onSearchOpen:()=>{}}),o&&e.jsxs(L,{variant:"contained",color:"primary","data-cy":"add-trusted-issuer",onClick:()=>t({mode:"add"}),children:[e.jsx(me,{style:{fontSize:16,marginRight:4}}),l("team.add")]})]})}),e.jsxs("div",{className:"list",children:[x.map(d=>e.jsxs(g,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mt:"20px"},children:[e.jsxs(g,{sx:{flexShrink:0},children:[e.jsx(he,{copyable:!1,size:16,did:Ge.toAddress(d.issuerDid),showDidLogo:!1}),!!d.remark&&e.jsx(g,{sx:{fontSize:12,maxWidth:"300px"},children:d.remark})]}),e.jsx(g,{sx:{color:"gray",ml:"28px",flexGrow:1},children:d.mappings&&d.mappings.length?`${d.mappings.length} ${l("team.passport.mappingRule")}`:l("team.passport.defaultRule")}),e.jsxs(g,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:[e.jsx(q,{onClick:()=>t({mode:"update",data:Z(d)}),"data-cy":"edit-mapping-rule",size:"large",children:e.jsx(oe,{})}),e.jsx(q,{"data-cy":"delete-mapping-rule",onClick:()=>a({title:l("common.delete"),description:l("common.delConfirmDescription",{data:d.issuerDid}),confirm:l("common.delConfirm"),cancel:l("common.cancel"),onConfirm:()=>y(d.issuerDid),onCancel:()=>{s(!1),a(null)}}),size:"large",children:e.jsx(ie,{})})]})]},d.issuerDid)),!m.length&&e.jsx(xe,{children:l("common.empty")})]})]})}),r&&e.jsx(ot,{mode:r.mode,data:r.data,trustedPassports:Z(m),onCancel:()=>t(null),onSuccess:()=>{t(null)}}),h&&e.jsx(ve,{title:h.title,description:h.description,confirm:h.confirm,cancel:h.cancel,params:h.params,onConfirm:h.onConfirm,onCancel:h.onCancel})]})}be.propTypes={onCancel:T.func.isRequired,hasPermission:T.bool};const Qt=G(be,"mutate_team"),Xt=G(be,"",J);function es(u){const{inService:o}=k();return o?e.jsx(Xt,{...u}):e.jsx(Qt,{...u})}const ts=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 ut}from"./vendor-react-BvXSmFbV.js";import{a as mt,m
107
107
  }
108
108
  }
109
109
  }
110
- `;var ss=Ot();const Re=_e(ss);function it({onCancel:u,onSuccess:o,data:i={},trustedFactories:p=[]}){const{api:m}=k(),{roles:l,teamDid:h}=M(),{t:a}=F(),[f,s]=Wt({loading:!1,fetching:!1,fetched:[],errored:[],factoryAddress:i.factoryAddress||"",remark:i.remark||"",role:i.passport?.role||"member",ttlPolicy:i.passport?.ttlPolicy||"never",ttl:Re(+i.passport?.ttl||365*24*60*60*1e3),error:""}),r=p.findIndex(x=>x.factoryAddress===i.factoryAddress),t=async()=>{if(f.loading)return;const{factoryAddress:x,remark:d,role:j,ttlPolicy:S,ttl:w}=f,C={factoryAddress:x,remark:d,passport:{role:j,ttlPolicy:S,ttl:S==="never"?0:Re(w)}},P=[...p];r===-1?P.unshift(C):P[r]=C;try{s({loading:!0}),await m.configTrustedFactories({input:{teamDid:h,trustedFactories:P}}),await se(800),R.success(a("common.saveSuccess")),o()}catch(D){console.error(D),R.error(te(D))}finally{s({loading:!1})}};b.useEffect(()=>{const x=f.fetched.find(j=>j.address===f.factoryAddress),d=f.errored.find(j=>j.address===f.factoryAddress);Ge.isValid(f.factoryAddress)&&!f.fetching&&!x&&!d&&(s({fetching:!0}),Nt(U.MAIN_CHAIN_ENDPOINT).getFactoryState({address:f.factoryAddress}).then(S=>{S.state?s({fetching:!1,fetched:[...f.fetched.filter(w=>w.address!==f.factoryAddress),S.state],remark:S.state.name}):s({fetching:!1,errored:[...f.errored.filter(w=>w.address!==f.factoryAddress),{address:f.factoryAddress}],error:a("team.passport.factory404",f)})}).catch(S=>{console.error(S),s({fetching:!1,error:te(S)})}))},[f.factoryAddress,f.fetching]);let n=f.error;const c=f.factoryAddress?f.errored.find(x=>x.address===f.factoryAddress):null;!n&&c&&(n=a("team.passport.factory404",f));const y=f.factoryAddress?f.fetched.find(x=>x.address===f.factoryAddress):null;return!n&&y&&(n=y.description),n||(n=a("team.passport.factoryAddressTip")),e.jsx(H,{title:a("team.passport.trustedFactories"),open:!0,showCloseButton:!1,PaperProps:{style:{minHeight:"80vh"}},fullWidth:!0,prepend:e.jsx(q,{onClick:u,"data-cy":"close-trusted-factory",size:"large",children:e.jsx($e,{})}),actions:e.jsxs(e.Fragment,{children:[e.jsx(L,{onClick:u,color:"inherit",children:a("common.cancel")}),e.jsxs(L,{onClick:()=>t(),color:"primary",disabled:!f.factoryAddress||!f.remark||!f.role||f.loading||f.error||c,variant:"contained",autoFocus:!0,"data-cy":"save-trusted-factory",children:[f.loading&&e.jsx(_,{size:16}),a("common.save")]})]}),children:e.jsx(rs,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx($,{fullWidth:!0,error:!!f.error||!!c,"data-cy":"input-factory-address",label:a("team.passport.factoryAddress"),helperText:n,value:f.factoryAddress,onChange:x=>{s({factoryAddress:x.target.value,error:""})},slotProps:{input:{endAdornment:f.fetching?e.jsx(gt,{position:"end",children:e.jsx(_,{size:16})}):null}}}),e.jsx($,{style:{marginTop:32},fullWidth:!0,"data-cy":"input-factory-remark",label:a("common.remark"),value:f.remark,onChange:x=>{s({remark:x.target.value})}}),e.jsx($,{style:{marginTop:32},fullWidth:!0,"data-cy":"input-passport-role",label:a("team.passport.role"),select:!0,value:f.role,onChange:x=>{s({role:x.target.value})},variant:"outlined",children:l.filter(x=>x.name!=="owner").map(x=>e.jsx(ae,{value:x.name,"data-cy":`passport-role-select-option-${x.name}`,children:e.jsx("span",{children:x.title||x.name})},x.name))}),e.jsxs("div",{style:{marginTop:32},children:[e.jsx(Oe,{children:a("team.passport.ttl")}),e.jsxs(qe,{color:"primary",size:"small",value:f.ttlPolicy,exclusive:!0,style:{marginTop:16},onChange:(x,d)=>s({ttlPolicy:d}),"data-cy":"input-passport-ttl-since","aria-label":"Expire Policy",children:[e.jsx(X,{value:"never","data-cy":"input-passport-ttl-never",children:e.jsx(K,{title:a("team.passport.ttlNeverTip"),children:e.jsx(E,{children:a("team.passport.ttlNever")})})}),e.jsx(X,{value:"mint","data-cy":"input-passport-ttl-mint",children:e.jsx(K,{title:a("team.passport.ttlMintTip"),children:e.jsx(E,{children:a("team.passport.ttlMint")})})}),e.jsx(X,{value:"exchange","data-cy":"input-passport-ttl-exchange",children:e.jsx(K,{title:a("team.passport.ttlExchangeTip"),children:e.jsx(E,{children:a("team.passport.ttlExchange")})})})]}),f.ttlPolicy!=="never"&&e.jsxs(e.Fragment,{children:[e.jsx(We,{fullWidth:!0,type:"text",style:{marginTop:16},"data-cy":"input-passport-ttl",value:f.ttl,onChange:x=>{s({ttl:x.target.value})}}),e.jsx(He,{children:a("team.passport.ttlTip")})]})]})]})})})}it.propTypes={onCancel:T.func.isRequired,onSuccess:T.func.isRequired,trustedFactories:T.array,data:T.object};const rs=W.div`
110
+ `;var ss=Ot();const Re=_e(ss);function it({onCancel:u,onSuccess:o,data:i={},trustedFactories:p=[]}){const{api:m}=k(),{roles:l,teamDid:h}=M(),{t:a}=F(),[f,s]=Wt({loading:!1,fetching:!1,fetched:[],errored:[],factoryAddress:i.factoryAddress||"",remark:i.remark||"",role:i.passport?.role||"member",ttlPolicy:i.passport?.ttlPolicy||"never",ttl:Re(+i.passport?.ttl||365*24*60*60*1e3),error:""}),r=p.findIndex(x=>x.factoryAddress===i.factoryAddress),t=async()=>{if(f.loading)return;const{factoryAddress:x,remark:d,role:j,ttlPolicy:S,ttl:w}=f,b={factoryAddress:x,remark:d,passport:{role:j,ttlPolicy:S,ttl:S==="never"?0:Re(w)}},P=[...p];r===-1?P.unshift(b):P[r]=b;try{s({loading:!0}),await m.configTrustedFactories({input:{teamDid:h,trustedFactories:P}}),await se(800),R.success(a("common.saveSuccess")),o()}catch(D){console.error(D),R.error(te(D))}finally{s({loading:!1})}};C.useEffect(()=>{const x=f.fetched.find(j=>j.address===f.factoryAddress),d=f.errored.find(j=>j.address===f.factoryAddress);Ge.isValid(f.factoryAddress)&&!f.fetching&&!x&&!d&&(s({fetching:!0}),Lt(U.MAIN_CHAIN_ENDPOINT).getFactoryState({address:f.factoryAddress}).then(S=>{S.state?s({fetching:!1,fetched:[...f.fetched.filter(w=>w.address!==f.factoryAddress),S.state],remark:S.state.name}):s({fetching:!1,errored:[...f.errored.filter(w=>w.address!==f.factoryAddress),{address:f.factoryAddress}],error:a("team.passport.factory404",f)})}).catch(S=>{console.error(S),s({fetching:!1,error:te(S)})}))},[f.factoryAddress,f.fetching]);let n=f.error;const c=f.factoryAddress?f.errored.find(x=>x.address===f.factoryAddress):null;!n&&c&&(n=a("team.passport.factory404",f));const y=f.factoryAddress?f.fetched.find(x=>x.address===f.factoryAddress):null;return!n&&y&&(n=y.description),n||(n=a("team.passport.factoryAddressTip")),e.jsx(H,{title:a("team.passport.trustedFactories"),open:!0,showCloseButton:!1,PaperProps:{style:{minHeight:"80vh"}},fullWidth:!0,prepend:e.jsx(q,{onClick:u,"data-cy":"close-trusted-factory",size:"large",children:e.jsx($e,{})}),actions:e.jsxs(e.Fragment,{children:[e.jsx(L,{onClick:u,color:"inherit",children:a("common.cancel")}),e.jsxs(L,{onClick:()=>t(),color:"primary",disabled:!f.factoryAddress||!f.remark||!f.role||f.loading||f.error||c,variant:"contained",autoFocus:!0,"data-cy":"save-trusted-factory",children:[f.loading&&e.jsx(_,{size:16}),a("common.save")]})]}),children:e.jsx(rs,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx($,{fullWidth:!0,error:!!f.error||!!c,"data-cy":"input-factory-address",label:a("team.passport.factoryAddress"),helperText:n,value:f.factoryAddress,onChange:x=>{s({factoryAddress:x.target.value,error:""})},slotProps:{input:{endAdornment:f.fetching?e.jsx(gt,{position:"end",children:e.jsx(_,{size:16})}):null}}}),e.jsx($,{style:{marginTop:32},fullWidth:!0,"data-cy":"input-factory-remark",label:a("common.remark"),value:f.remark,onChange:x=>{s({remark:x.target.value})}}),e.jsx($,{style:{marginTop:32},fullWidth:!0,"data-cy":"input-passport-role",label:a("team.passport.role"),select:!0,value:f.role,onChange:x=>{s({role:x.target.value})},variant:"outlined",children:l.filter(x=>x.name!=="owner").map(x=>e.jsx(ae,{value:x.name,"data-cy":`passport-role-select-option-${x.name}`,children:e.jsx("span",{children:x.title||x.name})},x.name))}),e.jsxs("div",{style:{marginTop:32},children:[e.jsx(Oe,{children:a("team.passport.ttl")}),e.jsxs(qe,{color:"primary",size:"small",value:f.ttlPolicy,exclusive:!0,style:{marginTop:16},onChange:(x,d)=>s({ttlPolicy:d}),"data-cy":"input-passport-ttl-since","aria-label":"Expire Policy",children:[e.jsx(X,{value:"never","data-cy":"input-passport-ttl-never",children:e.jsx(K,{title:a("team.passport.ttlNeverTip"),children:e.jsx(E,{children:a("team.passport.ttlNever")})})}),e.jsx(X,{value:"mint","data-cy":"input-passport-ttl-mint",children:e.jsx(K,{title:a("team.passport.ttlMintTip"),children:e.jsx(E,{children:a("team.passport.ttlMint")})})}),e.jsx(X,{value:"exchange","data-cy":"input-passport-ttl-exchange",children:e.jsx(K,{title:a("team.passport.ttlExchangeTip"),children:e.jsx(E,{children:a("team.passport.ttlExchange")})})})]}),f.ttlPolicy!=="never"&&e.jsxs(e.Fragment,{children:[e.jsx(We,{fullWidth:!0,type:"text",style:{marginTop:16},"data-cy":"input-passport-ttl",value:f.ttl,onChange:x=>{s({ttl:x.target.value})}}),e.jsx(He,{children:a("team.passport.ttlTip")})]})]})]})})})}it.propTypes={onCancel:T.func.isRequired,onSuccess:T.func.isRequired,trustedFactories:T.array,data:T.object};const rs=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 ut}from"./vendor-react-BvXSmFbV.js";import{a as mt,m
119
119
  }
120
120
  }
121
121
  }
122
- `;function Se({onCancel:u,hasPermission:o=!1}){const{api:i}=k(),{teamDid:p,trustedFactories:m}=M(),{t:l}=F(),[h,a]=b.useState(null),[f,s]=b.useState(!1),[r,t]=b.useState(null),[n,c]=b.useState(""),y=async d=>{if(!f)try{s(!0),await i.configTrustedFactories({input:{teamDid:p,trustedFactories:m.filter(j=>j.factoryAddress!==d)}}),await se(800),s(!1),R.success(l("common.saveSuccess")),a(null)}catch(j){s(!1),R.error(j.message)}},x=m.filter(d=>!n||d.factoryAddress.toLowerCase().includes(n.toLowerCase()));return e.jsxs(H,{title:l("team.passport.trustedFactories"),open:!0,onClose:u,fullWidth:!0,PaperProps:{style:{minHeight:"80vh"}},children:[e.jsx(is,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx("div",{className:"dialog-h1",children:l("team.passport.trustedFactoriesTip")}),e.jsx(Qe,{sx:{mt:3},actions:e.jsxs(e.Fragment,{children:[e.jsx(Ue,{options:{searchPlaceholder:l("team.passport.searchFactoryAddress"),searchDebounceTime:600},search:n,searchText:n,searchTextUpdate:c,searchClose:()=>c(""),onSearchOpen:()=>{}}),o&&e.jsxs(L,{variant:"contained",color:"primary",size:"small","data-cy":"add-trusted-factory",onClick:()=>t({mode:"add"}),children:[e.jsx(me,{style:{fontSize:16,marginRight:4}}),l("team.add")]})]})}),e.jsxs("div",{className:"list",children:[x.map(d=>e.jsxs(g,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mt:"20px"},children:[e.jsxs(g,{sx:{flexGrow:1},children:[e.jsx(he,{copyable:!1,did:d.factoryAddress,size:16,showDidLogo:!1}),!!d.remark&&e.jsx(g,{sx:{fontSize:12,maxWidth:"300px"},children:d.remark})]}),e.jsx(g,{sx:{color:"gray",mr:"24px"},children:e.jsx(Dt,{type:"success",children:d.passport.role})}),e.jsxs(g,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:[e.jsx(q,{onClick:()=>t({mode:"update",data:Z(d)}),"data-cy":"edit-trusted-factory",size:"large",children:e.jsx(oe,{})}),e.jsx(q,{"data-cy":"delete-trusted-factory",onClick:()=>a({title:l("common.delete"),description:l("common.delConfirmDescription",{data:d.factoryAddress}),confirm:l("common.delConfirm"),cancel:l("common.cancel"),onConfirm:()=>y(d.factoryAddress),onCancel:()=>{s(!1),a(null)}}),size:"large",children:e.jsx(ie,{})})]})]},d.factoryAddress)),!m.length&&e.jsx(xe,{children:l("common.empty")})]})]})}),r&&e.jsx(it,{data:r.data,trustedFactories:Z(m),onCancel:()=>t(null),onSuccess:()=>{t(null)}}),h&&e.jsx(ve,{title:h.title,description:h.description,confirm:h.confirm,cancel:h.cancel,params:h.params,onConfirm:h.onConfirm,onCancel:h.onCancel})]})}Se.propTypes={onCancel:T.func.isRequired,hasPermission:T.bool};const as=G(Se,"mutate_team"),ns=G(Se,"",J);function os(u){const{inService:o}=k();return o?e.jsx(ns,{...u}):e.jsx(as,{...u})}const is=W.div`
122
+ `;function Se({onCancel:u,hasPermission:o=!1}){const{api:i}=k(),{teamDid:p,trustedFactories:m}=M(),{t:l}=F(),[h,a]=C.useState(null),[f,s]=C.useState(!1),[r,t]=C.useState(null),[n,c]=C.useState(""),y=async d=>{if(!f)try{s(!0),await i.configTrustedFactories({input:{teamDid:p,trustedFactories:m.filter(j=>j.factoryAddress!==d)}}),await se(800),s(!1),R.success(l("common.saveSuccess")),a(null)}catch(j){s(!1),R.error(j.message)}},x=m.filter(d=>!n||d.factoryAddress.toLowerCase().includes(n.toLowerCase()));return e.jsxs(H,{title:l("team.passport.trustedFactories"),open:!0,onClose:u,fullWidth:!0,PaperProps:{style:{minHeight:"80vh"}},children:[e.jsx(is,{children:e.jsxs("div",{className:"dialog-content",children:[e.jsx("div",{className:"dialog-h1",children:l("team.passport.trustedFactoriesTip")}),e.jsx(Qe,{sx:{mt:3},actions:e.jsxs(e.Fragment,{children:[e.jsx(Ue,{options:{searchPlaceholder:l("team.passport.searchFactoryAddress"),searchDebounceTime:600},search:n,searchText:n,searchTextUpdate:c,searchClose:()=>c(""),onSearchOpen:()=>{}}),o&&e.jsxs(L,{variant:"contained",color:"primary",size:"small","data-cy":"add-trusted-factory",onClick:()=>t({mode:"add"}),children:[e.jsx(me,{style:{fontSize:16,marginRight:4}}),l("team.add")]})]})}),e.jsxs("div",{className:"list",children:[x.map(d=>e.jsxs(g,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mt:"20px"},children:[e.jsxs(g,{sx:{flexGrow:1},children:[e.jsx(he,{copyable:!1,did:d.factoryAddress,size:16,showDidLogo:!1}),!!d.remark&&e.jsx(g,{sx:{fontSize:12,maxWidth:"300px"},children:d.remark})]}),e.jsx(g,{sx:{color:"gray",mr:"24px"},children:e.jsx(Dt,{type:"success",children:d.passport.role})}),e.jsxs(g,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:[e.jsx(q,{onClick:()=>t({mode:"update",data:Z(d)}),"data-cy":"edit-trusted-factory",size:"large",children:e.jsx(oe,{})}),e.jsx(q,{"data-cy":"delete-trusted-factory",onClick:()=>a({title:l("common.delete"),description:l("common.delConfirmDescription",{data:d.factoryAddress}),confirm:l("common.delConfirm"),cancel:l("common.cancel"),onConfirm:()=>y(d.factoryAddress),onCancel:()=>{s(!1),a(null)}}),size:"large",children:e.jsx(ie,{})})]})]},d.factoryAddress)),!m.length&&e.jsx(xe,{children:l("common.empty")})]})]})}),r&&e.jsx(it,{data:r.data,trustedFactories:Z(m),onCancel:()=>t(null),onSuccess:()=>{t(null)}}),h&&e.jsx(ve,{title:h.title,description:h.description,confirm:h.confirm,cancel:h.cancel,params:h.params,onConfirm:h.onConfirm,onCancel:h.onCancel})]})}Se.propTypes={onCancel:T.func.isRequired,hasPermission:T.bool};const as=G(Se,"mutate_team"),ns=G(Se,"",J);function os(u){const{inService:o}=k();return o?e.jsx(ns,{...u}):e.jsx(as,{...u})}const is=W.div`
123
123
  .list {
124
124
  .MuiIconButton-root {
125
125
  svg {
@@ -132,7 +132,7 @@ import{r as b,g as _e,a as ut}from"./vendor-react-BvXSmFbV.js";import{a as mt,m
132
132
  *
133
133
  * @author Feross Aboukhadijeh <https://feross.org>
134
134
  * @license MIT
135
- */var ue,Ne;function cs(){if(Ne)return ue;Ne=1,ue=function(i){return i!=null&&(u(i)||o(i)||!!i._isBuffer)};function u(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function o(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&u(i.slice(0,0))}return ue}var Le;function ds(){return Le||(Le=1,function(){var u=ls(),o=Fe().utf8,i=cs(),p=Fe().bin,m=function(l,h){l.constructor==String?h&&h.encoding==="binary"?l=p.stringToBytes(l):l=o.stringToBytes(l):i(l)?l=Array.prototype.slice.call(l,0):!Array.isArray(l)&&l.constructor!==Uint8Array&&(l=l.toString());for(var a=u.bytesToWords(l),f=l.length*8,s=1732584193,r=-271733879,t=-1732584194,n=271733878,c=0;c<a.length;c++)a[c]=(a[c]<<8|a[c]>>>24)&16711935|(a[c]<<24|a[c]>>>8)&4278255360;a[f>>>5]|=128<<f%32,a[(f+64>>>9<<4)+14]=f;for(var y=m._ff,x=m._gg,d=m._hh,j=m._ii,c=0;c<a.length;c+=16){var S=s,w=r,C=t,P=n;s=y(s,r,t,n,a[c+0],7,-680876936),n=y(n,s,r,t,a[c+1],12,-389564586),t=y(t,n,s,r,a[c+2],17,606105819),r=y(r,t,n,s,a[c+3],22,-1044525330),s=y(s,r,t,n,a[c+4],7,-176418897),n=y(n,s,r,t,a[c+5],12,1200080426),t=y(t,n,s,r,a[c+6],17,-1473231341),r=y(r,t,n,s,a[c+7],22,-45705983),s=y(s,r,t,n,a[c+8],7,1770035416),n=y(n,s,r,t,a[c+9],12,-1958414417),t=y(t,n,s,r,a[c+10],17,-42063),r=y(r,t,n,s,a[c+11],22,-1990404162),s=y(s,r,t,n,a[c+12],7,1804603682),n=y(n,s,r,t,a[c+13],12,-40341101),t=y(t,n,s,r,a[c+14],17,-1502002290),r=y(r,t,n,s,a[c+15],22,1236535329),s=x(s,r,t,n,a[c+1],5,-165796510),n=x(n,s,r,t,a[c+6],9,-1069501632),t=x(t,n,s,r,a[c+11],14,643717713),r=x(r,t,n,s,a[c+0],20,-373897302),s=x(s,r,t,n,a[c+5],5,-701558691),n=x(n,s,r,t,a[c+10],9,38016083),t=x(t,n,s,r,a[c+15],14,-660478335),r=x(r,t,n,s,a[c+4],20,-405537848),s=x(s,r,t,n,a[c+9],5,568446438),n=x(n,s,r,t,a[c+14],9,-1019803690),t=x(t,n,s,r,a[c+3],14,-187363961),r=x(r,t,n,s,a[c+8],20,1163531501),s=x(s,r,t,n,a[c+13],5,-1444681467),n=x(n,s,r,t,a[c+2],9,-51403784),t=x(t,n,s,r,a[c+7],14,1735328473),r=x(r,t,n,s,a[c+12],20,-1926607734),s=d(s,r,t,n,a[c+5],4,-378558),n=d(n,s,r,t,a[c+8],11,-2022574463),t=d(t,n,s,r,a[c+11],16,1839030562),r=d(r,t,n,s,a[c+14],23,-35309556),s=d(s,r,t,n,a[c+1],4,-1530992060),n=d(n,s,r,t,a[c+4],11,1272893353),t=d(t,n,s,r,a[c+7],16,-155497632),r=d(r,t,n,s,a[c+10],23,-1094730640),s=d(s,r,t,n,a[c+13],4,681279174),n=d(n,s,r,t,a[c+0],11,-358537222),t=d(t,n,s,r,a[c+3],16,-722521979),r=d(r,t,n,s,a[c+6],23,76029189),s=d(s,r,t,n,a[c+9],4,-640364487),n=d(n,s,r,t,a[c+12],11,-421815835),t=d(t,n,s,r,a[c+15],16,530742520),r=d(r,t,n,s,a[c+2],23,-995338651),s=j(s,r,t,n,a[c+0],6,-198630844),n=j(n,s,r,t,a[c+7],10,1126891415),t=j(t,n,s,r,a[c+14],15,-1416354905),r=j(r,t,n,s,a[c+5],21,-57434055),s=j(s,r,t,n,a[c+12],6,1700485571),n=j(n,s,r,t,a[c+3],10,-1894986606),t=j(t,n,s,r,a[c+10],15,-1051523),r=j(r,t,n,s,a[c+1],21,-2054922799),s=j(s,r,t,n,a[c+8],6,1873313359),n=j(n,s,r,t,a[c+15],10,-30611744),t=j(t,n,s,r,a[c+6],15,-1560198380),r=j(r,t,n,s,a[c+13],21,1309151649),s=j(s,r,t,n,a[c+4],6,-145523070),n=j(n,s,r,t,a[c+11],10,-1120210379),t=j(t,n,s,r,a[c+2],15,718787259),r=j(r,t,n,s,a[c+9],21,-343485551),s=s+S>>>0,r=r+w>>>0,t=t+C>>>0,n=n+P>>>0}return u.endian([s,r,t,n])};m._ff=function(l,h,a,f,s,r,t){var n=l+(h&a|~h&f)+(s>>>0)+t;return(n<<r|n>>>32-r)+h},m._gg=function(l,h,a,f,s,r,t){var n=l+(h&f|a&~f)+(s>>>0)+t;return(n<<r|n>>>32-r)+h},m._hh=function(l,h,a,f,s,r,t){var n=l+(h^a^f)+(s>>>0)+t;return(n<<r|n>>>32-r)+h},m._ii=function(l,h,a,f,s,r,t){var n=l+(a^(h|~f))+(s>>>0)+t;return(n<<r|n>>>32-r)+h},m._blocksize=16,m._digestsize=16,ce.exports=function(l,h){if(l==null)throw new Error("Illegal argument "+l);var a=u.wordsToBytes(m(l,h));return h&&h.asBytes?a:h&&h.asString?p.bytesToString(a):u.bytesToHex(a)}}()),ce.exports}var ps=ds();const us=_e(ps);function Te({teamDid:u,onCancel:o,onSuccess:i,onError:p=()=>{},mode:m="create",item:l={}}){const{api:h}=k(),[a,f]=b.useState(!1),[s,r]=b.useState(""),{t}=F(),[n,c]=b.useState(l.title||""),[y,x]=b.useState(l.description||""),[d,j]=b.useState(l?.extra?.display||"builtin"),[S,w]=b.useState(l?.extra?.types?l.extra.types.join(","):""),C=async()=>{const D=n.trim();if(!D){r(t("team.passport.error.titleEmpty"));return}if(D.length>64){r(t("team.passport.error.titleTooLong",{length:64}));return}const z=y.replace(/\n/g," ");if(!z){r(t("team.passport.error.descriptionEmpty"));return}const V=m==="create"?us(D):l.name;r(null),f(!0);try{if(m==="create"){const B={teamDid:u,name:V,title:D,description:z};d==="custom"&&(B.extra=JSON.stringify({display:"custom",types:S.split(",")})),await h.createRole({input:B})}else{const B={teamDid:u,role:{name:V,title:D,description:z}};await h.updateRole({input:B})}i()}catch(B){const Y=te(B);r(Y),p(B)}finally{f(!1)}},P=e.jsxs("div",{children:[m==="update"&&e.jsx(E,{component:"div",style:{paddingTop:16},children:e.jsx($,{label:"ID",autoComplete:"off",variant:"outlined",name:"url","data-cy":"mutate-role-input-name",fullWidth:!0,autoFocus:!0,value:l.name,disabled:!0})}),e.jsx(E,{component:"div",style:{marginTop:16},children:e.jsx($,{label:t("common.title"),autoComplete:"off",variant:"outlined",name:"title","data-cy":"mutate-role-input-title",fullWidth:!0,autoFocus:!0,value:n,onChange:D=>{r(null),c(D.target.value)},disabled:m==="update"||a,helperText:t("team.passport.create.titleTip")})}),e.jsx(E,{component:"div",style:{marginTop:16,marginBottom:16},children:e.jsx($,{label:t("common.description"),autoComplete:"off",variant:"outlined",name:"description","data-cy":"mutate-role-input-description",fullWidth:!0,autoFocus:!0,value:y,onChange:D=>{r(null),x(D.target.value)},disabled:a,multiline:!0,rows:3})}),m==="create"&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx(Oe,{children:t("common.display")}),e.jsxs(qe,{color:"primary",size:"small",value:d,exclusive:!0,style:{marginTop:16},disabled:a,onChange:(D,z)=>j(z),"data-cy":"input-role-display",children:[e.jsx(X,{value:"builtin","data-cy":"input-role-display-builtin",children:e.jsx(E,{children:t("team.passport.displayBuiltin")})}),e.jsx(X,{value:"custom","data-cy":"input-role-display-custom",children:e.jsx(E,{children:t("team.passport.displayCustom")})})]}),d==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx(We,{fullWidth:!0,type:"text",style:{marginTop:16},"data-cy":"input-role-types",value:S,disabled:a,onChange:D=>{w(D.target.value)}}),e.jsx(He,{children:t("team.passport.typesTip")})]})]})]});return e.jsxs(H,{title:m==="create"?t("team.passport.create.title"):"",fullWidth:!0,open:!0,onClose:o,showCloseButton:!1,actions:e.jsxs(e.Fragment,{children:[e.jsx(L,{onClick:o,color:"inherit",children:t("common.cancel")}),e.jsxs(L,{"data-cy":"mutate-role-confirm",onClick:C,color:"primary",disabled:a,variant:"contained",autoFocus:!0,children:[a&&e.jsx(_,{size:16}),t(m==="create"?"common.create":"common.update")]})]}),children:[e.jsx(yt,{component:"div",children:P}),!!s&&e.jsx(Me,{severity:"error",variant:"icon",style:{width:"100%",margin:0},children:s})]})}Te.propTypes={teamDid:T.string.isRequired,onCancel:T.func.isRequired,onSuccess:T.func.isRequired,onError:T.func,mode:T.oneOf(["create","update"]),item:T.object};function we({onCancel:u,onSuccess:o,onDelete:i,roleName:p,hasPermission:m=!1}){const{api:l}=k(),{roles:h,permissions:a,teamDid:f,refresh:s,isNodeTeam:r}=M(),{t}=F(),[n,c]=b.useState([]),[y,x]=b.useState(!1),[d,j]=b.useState(null),[S,w]=b.useState(!1),C=Z(h.find(A=>A.name===p)),P=Ye(p),D=async A=>{if(!S)try{w(!0),await l.deleteRole({input:{teamDid:f,name:A}}),i()}catch(v){R.error(v.message)}finally{w(!1),j(null)}},z=async(A,v)=>{const N=(await l.getPermissionsByRole({input:{teamDid:A,role:{name:v}}})).permissions||[],O=a.map(De=>({...De,bind:N.some(pt=>pt.name===De.name)}));c(O)},V=async()=>{w(!0);const A=n.filter(v=>v.bind).map(v=>v.name);try{await l.updatePermissionsForRole({input:{teamDid:f,roleName:C.name,grantNames:A}}),R.success(t("common.saveSuccess")),o()}catch(v){R.error(te(v))}finally{w(!1)}};b.useEffect(()=>{f&&p&&z(f,p)},[f,p]);const B=r||!m;let Y=null;return r&&(Y=e.jsxs("div",{className:"bind",children:[e.jsx("div",{className:"title",children:t("common.permission")}),e.jsx("div",{className:"list",children:n.filter(A=>B?A.bind:!0).map(A=>e.jsx("div",{className:"item",children:e.jsx(jt,{control:e.jsx(vt,{disabled:B,checked:A.bind,onChange:()=>{c(v=>v.map(I=>(I.name===A.name&&(I.bind=!I.bind),I)))},name:A.name}),label:A.description})}))})]})),e.jsxs(H,{title:t("common.passport"),onClose:u,open:!0,fullWidth:!0,toolbar:m&&!P&&e.jsxs(e.Fragment,{children:[e.jsx(q,{onClick:()=>x(C),"data-cy":`edit-passport-${C.name}`,size:"large",children:e.jsx(oe,{fill:"#bfbfbf"})}),e.jsx(q,{onClick:()=>j({title:t("team.passport.delete.title"),description:t("team.passport.delete.description",{name:C.title}),confirm:t("common.delConfirm"),cancel:t("common.cancel"),onConfirm:()=>{D(C.name)},onCancel:()=>{w(!1),j(null)}}),"data-cy":`delete-passport-${C.name}`,size:"large",children:e.jsx(ie,{"data-cy":"close-passport-dialog",fill:"#bfbfbf"})})]}),actions:r&&!B&&e.jsxs(e.Fragment,{children:[e.jsx(L,{onClick:u,color:"inherit",children:t("common.cancel")}),e.jsxs(L,{onClick:V,color:"primary",disabled:S||!C,variant:"contained",autoFocus:!0,"data-cy":"bind-permission-btn-confirm",children:[S&&e.jsx(_,{size:16}),t("common.save")]})]}),children:[e.jsxs(hs,{children:[!C&&e.jsx(gs,{children:e.jsx(_,{})}),C&&e.jsxs("div",{className:"dialog-content",children:[e.jsxs("div",{className:"header",children:[e.jsx("div",{className:"title",children:C.title}),e.jsx("div",{className:"description",style:{marginTop:r?16:48},children:C.description})]}),Y]})]}),y&&e.jsx(Te,{teamDid:f,onCancel:()=>x(null),onSuccess:()=>{x(null),s()},mode:"update",roleName:y.name,item:y}),d&&e.jsx(ve,{title:d.title,description:d.description,confirm:d.confirm,cancel:d.cancel,params:d.params,onConfirm:d.onConfirm,onCancel:d.onCancel})]})}const ms=G(we,"mutate_team"),fs=G(we,"",J);function xs(u){const{inService:o}=k();return o?e.jsx(fs,{...u}):e.jsx(ms,{...u})}we.propTypes={roleName:T.string.isRequired,onCancel:T.func.isRequired,onSuccess:T.func.isRequired,onDelete:T.func.isRequired,hasPermission:T.bool};const hs=W.div`
135
+ */var ue,Ne;function cs(){if(Ne)return ue;Ne=1,ue=function(i){return i!=null&&(u(i)||o(i)||!!i._isBuffer)};function u(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function o(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&u(i.slice(0,0))}return ue}var Le;function ds(){return Le||(Le=1,function(){var u=ls(),o=Fe().utf8,i=cs(),p=Fe().bin,m=function(l,h){l.constructor==String?h&&h.encoding==="binary"?l=p.stringToBytes(l):l=o.stringToBytes(l):i(l)?l=Array.prototype.slice.call(l,0):!Array.isArray(l)&&l.constructor!==Uint8Array&&(l=l.toString());for(var a=u.bytesToWords(l),f=l.length*8,s=1732584193,r=-271733879,t=-1732584194,n=271733878,c=0;c<a.length;c++)a[c]=(a[c]<<8|a[c]>>>24)&16711935|(a[c]<<24|a[c]>>>8)&4278255360;a[f>>>5]|=128<<f%32,a[(f+64>>>9<<4)+14]=f;for(var y=m._ff,x=m._gg,d=m._hh,j=m._ii,c=0;c<a.length;c+=16){var S=s,w=r,b=t,P=n;s=y(s,r,t,n,a[c+0],7,-680876936),n=y(n,s,r,t,a[c+1],12,-389564586),t=y(t,n,s,r,a[c+2],17,606105819),r=y(r,t,n,s,a[c+3],22,-1044525330),s=y(s,r,t,n,a[c+4],7,-176418897),n=y(n,s,r,t,a[c+5],12,1200080426),t=y(t,n,s,r,a[c+6],17,-1473231341),r=y(r,t,n,s,a[c+7],22,-45705983),s=y(s,r,t,n,a[c+8],7,1770035416),n=y(n,s,r,t,a[c+9],12,-1958414417),t=y(t,n,s,r,a[c+10],17,-42063),r=y(r,t,n,s,a[c+11],22,-1990404162),s=y(s,r,t,n,a[c+12],7,1804603682),n=y(n,s,r,t,a[c+13],12,-40341101),t=y(t,n,s,r,a[c+14],17,-1502002290),r=y(r,t,n,s,a[c+15],22,1236535329),s=x(s,r,t,n,a[c+1],5,-165796510),n=x(n,s,r,t,a[c+6],9,-1069501632),t=x(t,n,s,r,a[c+11],14,643717713),r=x(r,t,n,s,a[c+0],20,-373897302),s=x(s,r,t,n,a[c+5],5,-701558691),n=x(n,s,r,t,a[c+10],9,38016083),t=x(t,n,s,r,a[c+15],14,-660478335),r=x(r,t,n,s,a[c+4],20,-405537848),s=x(s,r,t,n,a[c+9],5,568446438),n=x(n,s,r,t,a[c+14],9,-1019803690),t=x(t,n,s,r,a[c+3],14,-187363961),r=x(r,t,n,s,a[c+8],20,1163531501),s=x(s,r,t,n,a[c+13],5,-1444681467),n=x(n,s,r,t,a[c+2],9,-51403784),t=x(t,n,s,r,a[c+7],14,1735328473),r=x(r,t,n,s,a[c+12],20,-1926607734),s=d(s,r,t,n,a[c+5],4,-378558),n=d(n,s,r,t,a[c+8],11,-2022574463),t=d(t,n,s,r,a[c+11],16,1839030562),r=d(r,t,n,s,a[c+14],23,-35309556),s=d(s,r,t,n,a[c+1],4,-1530992060),n=d(n,s,r,t,a[c+4],11,1272893353),t=d(t,n,s,r,a[c+7],16,-155497632),r=d(r,t,n,s,a[c+10],23,-1094730640),s=d(s,r,t,n,a[c+13],4,681279174),n=d(n,s,r,t,a[c+0],11,-358537222),t=d(t,n,s,r,a[c+3],16,-722521979),r=d(r,t,n,s,a[c+6],23,76029189),s=d(s,r,t,n,a[c+9],4,-640364487),n=d(n,s,r,t,a[c+12],11,-421815835),t=d(t,n,s,r,a[c+15],16,530742520),r=d(r,t,n,s,a[c+2],23,-995338651),s=j(s,r,t,n,a[c+0],6,-198630844),n=j(n,s,r,t,a[c+7],10,1126891415),t=j(t,n,s,r,a[c+14],15,-1416354905),r=j(r,t,n,s,a[c+5],21,-57434055),s=j(s,r,t,n,a[c+12],6,1700485571),n=j(n,s,r,t,a[c+3],10,-1894986606),t=j(t,n,s,r,a[c+10],15,-1051523),r=j(r,t,n,s,a[c+1],21,-2054922799),s=j(s,r,t,n,a[c+8],6,1873313359),n=j(n,s,r,t,a[c+15],10,-30611744),t=j(t,n,s,r,a[c+6],15,-1560198380),r=j(r,t,n,s,a[c+13],21,1309151649),s=j(s,r,t,n,a[c+4],6,-145523070),n=j(n,s,r,t,a[c+11],10,-1120210379),t=j(t,n,s,r,a[c+2],15,718787259),r=j(r,t,n,s,a[c+9],21,-343485551),s=s+S>>>0,r=r+w>>>0,t=t+b>>>0,n=n+P>>>0}return u.endian([s,r,t,n])};m._ff=function(l,h,a,f,s,r,t){var n=l+(h&a|~h&f)+(s>>>0)+t;return(n<<r|n>>>32-r)+h},m._gg=function(l,h,a,f,s,r,t){var n=l+(h&f|a&~f)+(s>>>0)+t;return(n<<r|n>>>32-r)+h},m._hh=function(l,h,a,f,s,r,t){var n=l+(h^a^f)+(s>>>0)+t;return(n<<r|n>>>32-r)+h},m._ii=function(l,h,a,f,s,r,t){var n=l+(a^(h|~f))+(s>>>0)+t;return(n<<r|n>>>32-r)+h},m._blocksize=16,m._digestsize=16,ce.exports=function(l,h){if(l==null)throw new Error("Illegal argument "+l);var a=u.wordsToBytes(m(l,h));return h&&h.asBytes?a:h&&h.asString?p.bytesToString(a):u.bytesToHex(a)}}()),ce.exports}var ps=ds();const us=_e(ps);function Te({teamDid:u,onCancel:o,onSuccess:i,onError:p=()=>{},mode:m="create",item:l={}}){const{api:h}=k(),[a,f]=C.useState(!1),[s,r]=C.useState(""),{t}=F(),[n,c]=C.useState(l.title||""),[y,x]=C.useState(l.description||""),[d,j]=C.useState(l?.extra?.display||"builtin"),[S,w]=C.useState(l?.extra?.types?l.extra.types.join(","):""),b=async()=>{const D=n.trim();if(!D){r(t("team.passport.error.titleEmpty"));return}if(D.length>64){r(t("team.passport.error.titleTooLong",{length:64}));return}const B=y.replace(/\n/g," ");if(!B){r(t("team.passport.error.descriptionEmpty"));return}const V=m==="create"?us(D):l.name;r(null),f(!0);try{if(m==="create"){const z={teamDid:u,name:V,title:D,description:B};d==="custom"&&(z.extra=JSON.stringify({display:"custom",types:S.split(",")})),await h.createRole({input:z})}else{const z={teamDid:u,role:{name:V,title:D,description:B}};await h.updateRole({input:z})}i()}catch(z){const Y=te(z);r(Y),p(z)}finally{f(!1)}},P=e.jsxs("div",{children:[m==="update"&&e.jsx(E,{component:"div",style:{paddingTop:16},children:e.jsx($,{label:"ID",autoComplete:"off",variant:"outlined",name:"url","data-cy":"mutate-role-input-name",fullWidth:!0,autoFocus:!0,value:l.name,disabled:!0})}),e.jsx(E,{component:"div",style:{marginTop:16},children:e.jsx($,{label:t("common.title"),autoComplete:"off",variant:"outlined",name:"title","data-cy":"mutate-role-input-title",fullWidth:!0,autoFocus:!0,value:n,onChange:D=>{r(null),c(D.target.value)},disabled:m==="update"||a,helperText:t("team.passport.create.titleTip")})}),e.jsx(E,{component:"div",style:{marginTop:16,marginBottom:16},children:e.jsx($,{label:t("common.description"),autoComplete:"off",variant:"outlined",name:"description","data-cy":"mutate-role-input-description",fullWidth:!0,autoFocus:!0,value:y,onChange:D=>{r(null),x(D.target.value)},disabled:a,multiline:!0,rows:3})}),m==="create"&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx(Oe,{children:t("common.display")}),e.jsxs(qe,{color:"primary",size:"small",value:d,exclusive:!0,style:{marginTop:16},disabled:a,onChange:(D,B)=>j(B),"data-cy":"input-role-display",children:[e.jsx(X,{value:"builtin","data-cy":"input-role-display-builtin",children:e.jsx(E,{children:t("team.passport.displayBuiltin")})}),e.jsx(X,{value:"custom","data-cy":"input-role-display-custom",children:e.jsx(E,{children:t("team.passport.displayCustom")})})]}),d==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx(We,{fullWidth:!0,type:"text",style:{marginTop:16},"data-cy":"input-role-types",value:S,disabled:a,onChange:D=>{w(D.target.value)}}),e.jsx(He,{children:t("team.passport.typesTip")})]})]})]});return e.jsxs(H,{title:m==="create"?t("team.passport.create.title"):"",fullWidth:!0,open:!0,onClose:o,showCloseButton:!1,actions:e.jsxs(e.Fragment,{children:[e.jsx(L,{onClick:o,color:"inherit",children:t("common.cancel")}),e.jsxs(L,{"data-cy":"mutate-role-confirm",onClick:b,color:"primary",disabled:a,variant:"contained",autoFocus:!0,children:[a&&e.jsx(_,{size:16}),t(m==="create"?"common.create":"common.update")]})]}),children:[e.jsx(yt,{component:"div",children:P}),!!s&&e.jsx(Me,{severity:"error",variant:"icon",style:{width:"100%",margin:0},children:s})]})}Te.propTypes={teamDid:T.string.isRequired,onCancel:T.func.isRequired,onSuccess:T.func.isRequired,onError:T.func,mode:T.oneOf(["create","update"]),item:T.object};function we({onCancel:u,onSuccess:o,onDelete:i,roleName:p,hasPermission:m=!1}){const{api:l}=k(),{roles:h,permissions:a,teamDid:f,refresh:s,isNodeTeam:r}=M(),{t}=F(),[n,c]=C.useState([]),[y,x]=C.useState(!1),[d,j]=C.useState(null),[S,w]=C.useState(!1),b=Z(h.find(A=>A.name===p)),P=Ye(p),D=async A=>{if(!S)try{w(!0),await l.deleteRole({input:{teamDid:f,name:A}}),i()}catch(v){R.error(v.message)}finally{w(!1),j(null)}},B=async(A,v)=>{const N=(await l.getPermissionsByRole({input:{teamDid:A,role:{name:v}}})).permissions||[],O=a.map(De=>({...De,bind:N.some(pt=>pt.name===De.name)}));c(O)},V=async()=>{w(!0);const A=n.filter(v=>v.bind).map(v=>v.name);try{await l.updatePermissionsForRole({input:{teamDid:f,roleName:b.name,grantNames:A}}),R.success(t("common.saveSuccess")),o()}catch(v){R.error(te(v))}finally{w(!1)}};C.useEffect(()=>{f&&p&&B(f,p)},[f,p]);const z=r||!m;let Y=null;return r&&(Y=e.jsxs("div",{className:"bind",children:[e.jsx("div",{className:"title",children:t("common.permission")}),e.jsx("div",{className:"list",children:n.filter(A=>z?A.bind:!0).map(A=>e.jsx("div",{className:"item",children:e.jsx(jt,{control:e.jsx(vt,{disabled:z,checked:A.bind,onChange:()=>{c(v=>v.map(I=>(I.name===A.name&&(I.bind=!I.bind),I)))},name:A.name}),label:A.description})}))})]})),e.jsxs(H,{title:t("common.passport"),onClose:u,open:!0,fullWidth:!0,toolbar:m&&!P&&e.jsxs(e.Fragment,{children:[e.jsx(q,{onClick:()=>x(b),"data-cy":`edit-passport-${b.name}`,size:"large",children:e.jsx(oe,{fill:"#bfbfbf"})}),e.jsx(q,{onClick:()=>j({title:t("team.passport.delete.title"),description:t("team.passport.delete.description",{name:b.title}),confirm:t("common.delConfirm"),cancel:t("common.cancel"),onConfirm:()=>{D(b.name)},onCancel:()=>{w(!1),j(null)}}),"data-cy":`delete-passport-${b.name}`,size:"large",children:e.jsx(ie,{"data-cy":"close-passport-dialog",fill:"#bfbfbf"})})]}),actions:r&&!z&&e.jsxs(e.Fragment,{children:[e.jsx(L,{onClick:u,color:"inherit",children:t("common.cancel")}),e.jsxs(L,{onClick:V,color:"primary",disabled:S||!b,variant:"contained",autoFocus:!0,"data-cy":"bind-permission-btn-confirm",children:[S&&e.jsx(_,{size:16}),t("common.save")]})]}),children:[e.jsxs(hs,{children:[!b&&e.jsx(gs,{children:e.jsx(_,{})}),b&&e.jsxs("div",{className:"dialog-content",children:[e.jsxs("div",{className:"header",children:[e.jsx("div",{className:"title",children:b.title}),e.jsx("div",{className:"description",style:{marginTop:r?16:48},children:b.description})]}),Y]})]}),y&&e.jsx(Te,{teamDid:f,onCancel:()=>x(null),onSuccess:()=>{x(null),s()},mode:"update",roleName:y.name,item:y}),d&&e.jsx(ve,{title:d.title,description:d.description,confirm:d.confirm,cancel:d.cancel,params:d.params,onConfirm:d.onConfirm,onCancel:d.onCancel})]})}const ms=G(we,"mutate_team"),fs=G(we,"",J);function xs(u){const{inService:o}=k();return o?e.jsx(fs,{...u}):e.jsx(ms,{...u})}we.propTypes={roleName:T.string.isRequired,onCancel:T.func.isRequired,onSuccess:T.func.isRequired,onDelete:T.func.isRequired,hasPermission:T.bool};const hs=W.div`
136
136
  .header {
137
137
  .title {
138
138
  font-weight: 400;
@@ -181,7 +181,7 @@ import{r as b,g as _e,a as ut}from"./vendor-react-BvXSmFbV.js";import{a as mt,m
181
181
  justify-content: center;
182
182
  align-items: center;
183
183
  height: 200px;
184
- `,ze=b.memo(({field:u,value:o,copyable:i})=>{const{local:p}=F();return o?e.jsxs(g,{onClick:m=>m.stopPropagation(),sx:{display:"flex",alignItems:"center",gap:1},children:[u?e.jsxs(Ie,{variant:"subtitle1",color:"textSecondary",sx:{width:50,textAlign:"right"},children:[u,":"]}):null,e.jsx(Ie,{variant:"body1",children:e.jsxs(g,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(K,{title:o,children:e.jsx("span",{className:"value-ellipsis",children:o})}),i?e.jsx(It,{content:qt(o),locale:p,style:{marginLeft:"4px",color:"#999",fontSize:"0.8em",verticalAlign:"bottom"}}):null]})})]}):null});function lt({createPassportSvg:u}){const{inService:o}=k(),{roles:i,teamIssuerDid:p,teamName:m,refresh:l,passportColor:h,teamDid:a,isNodeTeam:f}=M(),{t:s}=F(),[r,t]=b.useState(!1),[n,c]=b.useState(!1),y=bt(d=>d.breakpoints.down("md")),x=b.useCallback(d=>d&&!U.ROLES[d.toUpperCase()],[]);return e.jsxs(ys,{sx:{mt:0},children:[e.jsx(g,{sx:{display:"flex",justifyContent:"flex-end"},children:!f&&e.jsxs(Ct,{variant:"contained",edge:"end",color:"primary","data-cy":"create-role",onClick:()=>t(!0),children:[e.jsx(me,{style:{fontSize:16,marginRight:4}}),s("team.passport.create.title")]})}),e.jsx(g,{className:"list",children:i.map(d=>e.jsxs(g,{"data-cy":`passport-${d.name}`,className:"item",onClick:()=>c(d),sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(g,{sx:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{width:150},dangerouslySetInnerHTML:{__html:u({title:d.title,issuer:m,issuerDid:p,ownerName:"Your Name",ownerDid:p,preferredColor:h,width:"150px"})}}),e.jsxs(g,{className:"title",sx:{ml:3},children:[e.jsx(ze,{value:d.title}),x(d.name)?e.jsx(ze,{value:d.name,copyable:!0}):null]})]}),!y&&e.jsx(g,{className:"description",children:d.description}),e.jsx(Je,{permission:o?"":"mutate_team",role:o?J:[],children:e.jsx("div",{className:"action",children:Ye(d.name)?e.jsx(Ht,{}):e.jsx(oe,{})})})]},d.name))}),n&&e.jsx(xs,{onCancel:()=>c(!1),onSuccess:()=>{c(!1),l()},onDelete:()=>{c(!1),l()},mode:"update",roleName:n.name,item:n}),r&&e.jsx(Te,{teamDid:a,onCancel:()=>t(!1),onSuccess:()=>{t(!1),l()}})]})}const ys=W(g)`
184
+ `,Be=C.memo(({field:u,value:o,copyable:i})=>{const{local:p}=F();return o?e.jsxs(g,{onClick:m=>m.stopPropagation(),sx:{display:"flex",alignItems:"center",gap:1},children:[u?e.jsxs(Ie,{variant:"subtitle1",color:"textSecondary",sx:{width:50,textAlign:"right"},children:[u,":"]}):null,e.jsx(Ie,{variant:"body1",children:e.jsxs(g,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(K,{title:o,children:e.jsx("span",{className:"value-ellipsis",children:o})}),i?e.jsx(It,{content:qt(o),locale:p,style:{marginLeft:"4px",color:"#999",fontSize:"0.8em",verticalAlign:"bottom"}}):null]})})]}):null});function lt({createPassportSvg:u}){const{inService:o}=k(),{roles:i,teamIssuerDid:p,teamName:m,refresh:l,passportColor:h,teamDid:a,isNodeTeam:f}=M(),{t:s}=F(),[r,t]=C.useState(!1),[n,c]=C.useState(!1),y=Ct(d=>d.breakpoints.down("md")),x=C.useCallback(d=>d&&!U.ROLES[d.toUpperCase()],[]);return e.jsxs(ys,{sx:{mt:0},children:[e.jsx(g,{sx:{display:"flex",justifyContent:"flex-end"},children:!f&&e.jsxs(bt,{variant:"contained",edge:"end",color:"primary","data-cy":"create-role",onClick:()=>t(!0),children:[e.jsx(me,{style:{fontSize:16,marginRight:4}}),s("team.passport.create.title")]})}),e.jsx(g,{className:"list",children:i.map(d=>e.jsxs(g,{"data-cy":`passport-${d.name}`,className:"item",onClick:()=>c(d),sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(g,{sx:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{width:150},dangerouslySetInnerHTML:{__html:u({title:d.title,issuer:m,issuerDid:p,ownerName:"Your Name",ownerDid:p,preferredColor:h,width:"150px"})}}),e.jsxs(g,{className:"title",sx:{ml:3},children:[e.jsx(Be,{value:d.title}),x(d.name)?e.jsx(Be,{value:d.name,copyable:!0}):null]})]}),!y&&e.jsx(g,{className:"description",children:d.description}),e.jsx(Je,{permission:o?"":"mutate_team",role:o?J:[],children:e.jsx("div",{className:"action",children:Ye(d.name)?e.jsx(Ht,{}):e.jsx(oe,{})})})]},d.name))}),n&&e.jsx(xs,{onCancel:()=>c(!1),onSuccess:()=>{c(!1),l()},onDelete:()=>{c(!1),l()},mode:"update",roleName:n.name,item:n}),r&&e.jsx(Te,{teamDid:a,onCancel:()=>t(!1),onSuccess:()=>{t(!1),l()}})]})}const ys=W(g)`
185
185
  .list {
186
186
  .item {
187
187
  padding: 12px;
@@ -219,7 +219,7 @@ import{r as b,g as _e,a as ut}from"./vendor-react-BvXSmFbV.js";import{a as mt,m
219
219
  fill: ${({theme:u})=>u.palette.text.secondary};
220
220
  }
221
221
  }
222
- `;lt.propTypes={createPassportSvg:T.func.isRequired};function ct({createPassportSvg:u}){const{t:o}=F(),{api:i,inService:p}=k(),{teamDid:m,refresh:l,enablePassportIssuance:h,isNodeTeam:a}=M(),[f,s]=b.useState(!1),[r,t]=b.useState(!1),[n,c]=b.useState(!1),[y,x]=b.useState(!1),[d,j]=b.useState(!1),S=async w=>{if(w.stopPropagation(),!y){x(!0);try{await i.configPassportIssuance({input:{teamDid:m,enable:!h}}),l(),await se(800),R.success(o("common.configSuccess"))}catch(C){R.error(C.message)}finally{x(!1)}}};return e.jsxs(g,{sx:{display:"flex",alignItems:"center",gap:1,ml:1},children:[e.jsx(Je,{permission:p?"":"mutate_team",role:p?J:[],children:e.jsx(Q,{variant:"outlined",menuButtonProps:{"data-cy":"trusted-issuers-more"},menu:e.jsxs(e.Fragment,{children:[e.jsx(Q.Item,{onClick:()=>t(!0),"data-cy":"config-trusted-issuers",children:e.jsxs(g,{children:[o("team.passport.trustedPassportIssuers"),e.jsx(g,{sx:{fontSize:12,color:"#888"},children:o("team.passport.trustedPassportIssuersTip")})]})}),e.jsx(Q.Item,{onClick:()=>c(!0),"data-cy":"config-show-trusted-factories",children:e.jsxs(g,{children:[o("team.passport.configFactories"),e.jsx(g,{sx:{fontSize:12,color:"#888"},children:o("team.passport.configFactoriesTip")})]})}),e.jsx(Q.Item,{"data-cy":"config-show-issue-passport",onClick:S,children:e.jsxs(g,{sx:{display:"flex",alignItems:"center"},children:[y&&e.jsx(_,{size:16,style:{marginRight:8}}),e.jsxs(g,{children:[o(h?"team.passport.disableIssuance":"team.passport.enableIssuance"),e.jsx(g,{sx:{fontSize:12,color:"#888"},children:o(h?"team.passport.disableIssuanceTip":"team.passport.enableIssuanceTip")})]})]})}),!a&&e.jsx(Q.Item,{onClick:()=>s(!0),"data-cy":"config-passport-color",children:e.jsxs(g,{children:[o("team.passport.configColor"),e.jsx(g,{sx:{fontSize:12,color:"#888"},children:o("team.passport.configColorTip")})]})})]}),children:()=>e.jsx(L,{variant:"outlined",onClick:()=>{j(!0)},children:o("team.passport.view")})})}),r&&e.jsx(es,{onCancel:()=>t(!1)}),n&&e.jsx(os,{onCancel:()=>c(!1)}),f&&e.jsx(Kt,{onCancel:()=>s(!1),onSuccess:()=>s(!1)}),d&&e.jsx(H,{open:!0,maxWidth:"lg",onClose:()=>j(!1),onBackdropClick:()=>j(!1),onEscapeKeyDown:()=>j(!1),title:o("team.passport.view"),children:e.jsx(lt,{createPassportSvg:u,onCancel:()=>j(!1)})})]})}ct.propTypes={createPassportSvg:T.func.isRequired};const Be="$all",Ee="",dt=ut.memo(({createPassportSvg:u,passport:o,teamDid:i,inService:p})=>e.jsx(g,{sx:{display:"flex"},dangerouslySetInnerHTML:{__html:u({scope:o.scope,role:o.role,title:o.scope==="kyc"?o.name:o.title,issuer:o.issuer&&o.issuer.name,issuerDid:o.issuer&&o.issuer.id,ownerName:o.user?.fullName,ownerDid:o.user?.did,ownerAvatarUrl:o.user?.avatar?Ze(o.user?.avatar,i,p):"",revoked:o.revoked,width:"36px",extra:o?.expirationDate?{key:"Exp",value:Ve(o.expirationDate).format("YYYY-MM-DD HH:mm:ss")}:null})}}));dt.propTypes={passport:T.object.isRequired,createPassportSvg:T.func.isRequired,teamDid:T.string.isRequired,inService:T.bool.isRequired};function js({createPassportSvg:u}){const{api:o}=k(),{teamDid:i}=M(),{t:p,locale:m}=F(),{SYSTEM_ROLES:l}=zt(),{inService:h}=k(),[a,f]=b.useState(!1),s=`passports-${i}`,r=Pt(s),[t,n]=b.useState({role:Be,status:Ee,searchText:r.searchText||"",pageSize:r.rowsPerPage||10,page:r.page?r.page+1:1}),{data:c,loading:y}=re(async()=>(await o.getPassportRoleCounts({input:{teamDid:i}})).counts||[],{refreshDeps:[i]}),{data:x,loading:d}=re(async()=>{const v={};t.role!==Be&&(v.role=t.role),t.status&&(v.status=t.status);const I=await o.getPassportsByRole({input:{teamDid:i,query:v,paging:{page:t.page,pageSize:t.pageSize}}});return{passports:I.passports||[],total:I.paging.total}},{refreshDeps:[t.role,t.status,t.page,t.pageSize],onError:v=>R.error(v.message)}),j=v=>c?.find(N=>N.key===v)?.value||0,S=b.useMemo(()=>Object.keys(l).map(v=>({name:v,title:l[v],num:j(v)})),[c,j]),w=b.useMemo(()=>[{label:p("team.passport.role"),name:"role",options:{customBodyRender:(v,{rowIndex:I})=>{const N=x?.passports[I];return e.jsxs(g,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(dt,{createPassportSvg:u,passport:N,teamDid:i}),e.jsx(g,{children:ge(N.title)})]})}}},{label:p("team.passport.owner"),name:"user",options:{customBodyRender:v=>ye(v,h)}},{label:p("team.passport.status"),name:"status",options:{customBodyRender:je}},{label:p("team.member.lastLogin"),name:"lastLoginAt",options:{customBodyRender:v=>Ke(v,m)}},{label:p("common.address"),name:"id",options:{customBodyRender:Bt}},{label:p("blocklet.overview.source"),name:"source",options:{customBodyRender:(v,{rowIndex:I})=>{const N=x?.passports[I];return N.parentDid?ne("recover"):ne(N.source)}}}],[p,m,x?.passports,i,u,h]),C=v=>{n(I=>({...I,role:v,page:1}))},P=({page:v,rowsPerPage:I,searchText:N})=>{t.pageSize!==I?n(O=>({...O,searchText:"",pageSize:I,page:1})):t.page!==v+1?n(O=>({...O,searchText:"",page:v+1})):t.searchText!==N&&n(O=>({...O,searchText:N,page:1}))},D=b.useRef(null),z=x?.passports||[],V=t.searchText?z.filter(v=>v.id.includes(t.searchText)||(v?.user?.fullName||"").includes(t.searchText)):z,B={sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,onRowClick(v,{dataIndex:I},N){if(D.current?.contains(N.target)){const O=x?.passports[I];f(O)}},page:t.page-1,rowsPerPage:t.pageSize,count:x?.total||0,searchDebounceTime:600},Y=v=>{n(I=>({...I,status:v.target.value,page:1}))},A=e.jsxs(g,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsxs(g,{sx:{fontSize:16,fontWeight:400},children:[p("team.passport.status"),":"]}),e.jsxs(St,{size:"small",value:t.status,onChange:Y,displayEmpty:!0,sx:{minWidth:120,height:36,".MuiSelect-select":{py:.5,px:1.5}},children:[e.jsx(ae,{value:Ee,children:p("common.all")}),Object.values(U.PASSPORT_STATUS).map(v=>e.jsx(ae,{value:v,sx:{py:1},children:p(`team.passport.statusMap.${v}`)},v))]})]});return y?e.jsx(g,{sx:{py:2},children:e.jsx(ee,{direction:"row",spacing:1,sx:{justifyContent:"center",alignItems:"center",position:"relative",pb:2},children:e.jsx(_,{})})}):e.jsxs(vs,{children:[e.jsxs(g,{className:"main",sx:{display:"flex",mt:0,gap:3},children:[e.jsx(g,{className:"left",children:e.jsx(g,{className:"tabs",children:S.map(v=>e.jsxs(g,{className:`tab ${t.role===v.name?"active":""}`,onClick:()=>C(v.name),children:[e.jsx("span",{className:"text",children:v.title}),e.jsx(g,{sx:{color:"text.secondary"},children:v.num})]},v.name))})}),e.jsx(g,{ref:D,className:"right",children:e.jsx(fe,{className:"main-table",verticalKeyWidth:100,locale:m,durable:s,durableKeys:["page","rowsPerPage"],data:V,columns:w,options:B,loading:d,onChange:P,customButtons:[e.jsx(ct,{createPassportSvg:u})],title:A})})]}),a&&e.jsx(Xe,{createPassportSvg:u,onCancel:()=>f(null),passport:a,onSwitchPassport:f})]})}js.propTypes={createPassportSvg:T.func.isRequired};const vs=Tt(g)`
222
+ `;lt.propTypes={createPassportSvg:T.func.isRequired};function ct({createPassportSvg:u}){const{t:o}=F(),{api:i,inService:p}=k(),{teamDid:m,refresh:l,enablePassportIssuance:h,isNodeTeam:a}=M(),[f,s]=C.useState(!1),[r,t]=C.useState(!1),[n,c]=C.useState(!1),[y,x]=C.useState(!1),[d,j]=C.useState(!1),S=async w=>{if(w.stopPropagation(),!y){x(!0);try{await i.configPassportIssuance({input:{teamDid:m,enable:!h}}),l(),await se(800),R.success(o("common.configSuccess"))}catch(b){R.error(b.message)}finally{x(!1)}}};return e.jsxs(g,{sx:{display:"flex",alignItems:"center",gap:1,ml:1},children:[e.jsx(Je,{permission:p?"":"mutate_team",role:p?J:[],children:e.jsx(Q,{variant:"outlined",menuButtonProps:{"data-cy":"trusted-issuers-more"},menu:e.jsxs(e.Fragment,{children:[e.jsx(Q.Item,{onClick:()=>t(!0),"data-cy":"config-trusted-issuers",children:e.jsxs(g,{children:[o("team.passport.trustedPassportIssuers"),e.jsx(g,{sx:{fontSize:12,color:"#888"},children:o("team.passport.trustedPassportIssuersTip")})]})}),e.jsx(Q.Item,{onClick:()=>c(!0),"data-cy":"config-show-trusted-factories",children:e.jsxs(g,{children:[o("team.passport.configFactories"),e.jsx(g,{sx:{fontSize:12,color:"#888"},children:o("team.passport.configFactoriesTip")})]})}),e.jsx(Q.Item,{"data-cy":"config-show-issue-passport",onClick:S,children:e.jsxs(g,{sx:{display:"flex",alignItems:"center"},children:[y&&e.jsx(_,{size:16,style:{marginRight:8}}),e.jsxs(g,{children:[o(h?"team.passport.disableIssuance":"team.passport.enableIssuance"),e.jsx(g,{sx:{fontSize:12,color:"#888"},children:o(h?"team.passport.disableIssuanceTip":"team.passport.enableIssuanceTip")})]})]})}),!a&&e.jsx(Q.Item,{onClick:()=>s(!0),"data-cy":"config-passport-color",children:e.jsxs(g,{children:[o("team.passport.configColor"),e.jsx(g,{sx:{fontSize:12,color:"#888"},children:o("team.passport.configColorTip")})]})})]}),children:()=>e.jsx(L,{variant:"outlined",onClick:()=>{j(!0)},children:o("team.passport.view")})})}),r&&e.jsx(es,{onCancel:()=>t(!1)}),n&&e.jsx(os,{onCancel:()=>c(!1)}),f&&e.jsx(Kt,{onCancel:()=>s(!1),onSuccess:()=>s(!1)}),d&&e.jsx(H,{open:!0,maxWidth:"lg",onClose:()=>j(!1),onBackdropClick:()=>j(!1),onEscapeKeyDown:()=>j(!1),title:o("team.passport.view"),children:e.jsx(lt,{createPassportSvg:u,onCancel:()=>j(!1)})})]})}ct.propTypes={createPassportSvg:T.func.isRequired};const ze="$all",Ee="",dt=ut.memo(({createPassportSvg:u,passport:o,teamDid:i,inService:p})=>e.jsx(g,{sx:{display:"flex"},dangerouslySetInnerHTML:{__html:u({scope:o.scope,role:o.role,title:o.scope==="kyc"?o.name:o.title,issuer:o.issuer&&o.issuer.name,issuerDid:o.issuer&&o.issuer.id,ownerName:o.user?.fullName,ownerDid:o.user?.did,ownerAvatarUrl:o.user?.avatar?Ze(o.user?.avatar,i,p):"",revoked:o.revoked,width:"36px",extra:o?.expirationDate?{key:"Exp",value:Ve(o.expirationDate).format("YYYY-MM-DD HH:mm:ss")}:null})}}));dt.propTypes={passport:T.object.isRequired,createPassportSvg:T.func.isRequired,teamDid:T.string.isRequired,inService:T.bool.isRequired};function js({createPassportSvg:u}){const{api:o}=k(),{teamDid:i}=M(),{t:p,locale:m}=F(),{SYSTEM_ROLES:l}=zt(),{inService:h}=k(),[a,f]=C.useState(!1),s=`passports-${i}`,r=Pt(s),[t,n]=C.useState({role:ze,status:Ee,searchText:r.searchText||"",pageSize:r.rowsPerPage||10,page:r.page?r.page+1:1}),{data:c,loading:y}=re(async()=>(await o.getPassportRoleCounts({input:{teamDid:i}})).counts||[],{refreshDeps:[i]}),{data:x,loading:d}=re(async()=>{const v={};t.role!==ze&&(v.role=t.role),t.status&&(v.status=t.status);const I=await o.getPassportsByRole({input:{teamDid:i,query:v,paging:{page:t.page,pageSize:t.pageSize}}});return{passports:I.passports||[],total:I.paging.total}},{refreshDeps:[t.role,t.status,t.page,t.pageSize],onError:v=>R.error(v.message)}),j=v=>c?.find(N=>N.key===v)?.value||0,S=C.useMemo(()=>Object.keys(l).map(v=>({name:v,title:l[v],num:j(v)})),[c,j]),w=C.useMemo(()=>[{label:p("team.passport.role"),name:"role",options:{customBodyRender:(v,{rowIndex:I})=>{const N=x?.passports[I];return e.jsxs(g,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(dt,{createPassportSvg:u,passport:N,teamDid:i}),e.jsx(g,{children:ge(N.title)})]})}}},{label:p("team.passport.owner"),name:"user",options:{customBodyRender:v=>ye(v,h)}},{label:p("team.passport.status"),name:"status",options:{customBodyRender:je}},{label:p("team.member.lastLogin"),name:"lastLoginAt",options:{customBodyRender:v=>Ke(v,m)}},{label:p("common.address"),name:"id",options:{customBodyRender:Et}},{label:p("blocklet.overview.source"),name:"source",options:{customBodyRender:(v,{rowIndex:I})=>{const N=x?.passports[I];return N.parentDid?ne("recover"):ne(N.source)}}}],[p,m,x?.passports,i,u,h]),b=v=>{n(I=>({...I,role:v,page:1}))},P=({page:v,rowsPerPage:I,searchText:N})=>{t.pageSize!==I?n(O=>({...O,searchText:"",pageSize:I,page:1})):t.page!==v+1?n(O=>({...O,searchText:"",page:v+1})):t.searchText!==N&&n(O=>({...O,searchText:N,page:1}))},D=C.useRef(null),B=x?.passports||[],V=t.searchText?B.filter(v=>v.id.includes(t.searchText)||(v?.user?.fullName||"").includes(t.searchText)):B,z={sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,onRowClick(v,{dataIndex:I},N){if(D.current?.contains(N.target)){const O=x?.passports[I];f(O)}},page:t.page-1,rowsPerPage:t.pageSize,count:x?.total||0,searchDebounceTime:600},Y=v=>{n(I=>({...I,status:v.target.value,page:1}))},A=e.jsxs(g,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsxs(g,{sx:{fontSize:16,fontWeight:400},children:[p("team.passport.status"),":"]}),e.jsxs(St,{size:"small",value:t.status,onChange:Y,displayEmpty:!0,sx:{minWidth:120,height:36,".MuiSelect-select":{py:.5,px:1.5}},children:[e.jsx(ae,{value:Ee,children:p("common.all")}),Object.values(U.PASSPORT_STATUS).map(v=>e.jsx(ae,{value:v,sx:{py:1},children:p(`team.passport.statusMap.${v}`)},v))]})]});return y?e.jsx(g,{sx:{py:2},children:e.jsx(ee,{direction:"row",spacing:1,sx:{justifyContent:"center",alignItems:"center",position:"relative",pb:2},children:e.jsx(_,{})})}):e.jsxs(vs,{children:[e.jsxs(g,{className:"main",sx:{display:"flex",mt:0,gap:3},children:[e.jsx(g,{className:"left",children:e.jsx(g,{className:"tabs",children:S.map(v=>e.jsxs(g,{className:`tab ${t.role===v.name?"active":""}`,onClick:()=>b(v.name),children:[e.jsx("span",{className:"text",children:v.title}),e.jsx(g,{sx:{color:"text.secondary"},children:v.num})]},v.name))})}),e.jsx(g,{ref:D,className:"right",children:e.jsx(fe,{className:"main-table",verticalKeyWidth:100,locale:m,durable:s,durableKeys:["page","rowsPerPage"],data:V,columns:w,options:z,loading:d,onChange:P,customButtons:[e.jsx(ct,{createPassportSvg:u})],title:A})})]}),a&&e.jsx(Xe,{createPassportSvg:u,onCancel:()=>f(null),passport:a,onSwitchPassport:f})]})}js.propTypes={createPassportSvg:T.func.isRequired};const vs=Tt(g)`
223
223
  .main {
224
224
  .left {
225
225
  width: 256px;
@@ -0,0 +1 @@
1
+ import{j as t,ak as s,T as n,$ as i}from"./vendor-mui-core-Bz-X9hX7.js";import{T as f}from"./vendor-ux-D2yvD18l.js";import{L as g,r as k}from"./vendor-react-x2lQvn4m.js";import"./index-BpP1Znfh.js";import"./vendor-utils-Vke2d2wu.js";import"./vendor-hooks-CFpNP5Ql.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-Cvkavi6C.js";const l=(e,o)=>[e,...Array.isArray(o)?o:[o]],a=(e=2)=>({overflow:"hidden",textOverflow:"ellipsis",wordBreak:"break-word",display:"-webkit-box",WebkitLineClamp:e,WebkitBoxOrient:"vertical"});function p({sx:e={},...o}){const r=l({display:"flex",flexWrap:"wrap",mx:-1},e);return t.jsx(s,{sx:r,...o})}p.propTypes={sx:i.object};function w({icon:e}){const[o,r]=k.useState(!1);return!e||o?null:typeof e=="string"?t.jsx(s,{component:"img",src:e,alt:"",sx:{width:1,height:1},onError:()=>r(!0)}):e}w.propTypes={icon:i.oneOfType([i.string,i.node]).isRequired};function b({title:e,desc:o,extra:r,cover:c,icon:d,to:x,sx:h}){const m=l({position:"relative",flexBasis:{xs:"100%",sm:"50%",md:"33.33%",lg:"25%"},maxWidth:{xs:"100%",sm:"50%",md:"33.33%",lg:"25%"},mb:{xs:2,md:6},px:1},h);return t.jsx(s,{sx:m,children:t.jsx(s,{component:g,to:x,target:"_blank",sx:{display:"flex",flexDirection:"column",gap:1,height:1,pt:0,color:"inherit",textDecoration:"none",borderRadius:1,cursor:"pointer"},children:t.jsxs(s,{children:[t.jsxs(s,{sx:{position:"relative"},children:[c,d&&t.jsx(s,{sx:{position:"absolute",top:44,left:16,zIndex:1,width:56,height:56},children:t.jsx(w,{icon:d})})]}),t.jsx(n,{sx:{mt:1,fontSize:"1.25rem",fontWeight:600,...a()},children:e}),o&&t.jsx(n,{variant:"body2",sx:{my:1,...a(),color:"text.secondary"},children:o}),r]})})})}b.propTypes={title:i.string.isRequired,desc:i.string.isRequired,extra:i.node.isRequired,cover:i.string.isRequired,icon:i.string.isRequired,to:i.string.isRequired,sx:i.object.isRequired};const j="/.well-known/service/static/assets/doc-board-bg-DWZHV9Ng.png";function u({board:e,sx:o,...r}){return t.jsx(b,{date:e.createdAt,sx:o,to:e.link,title:e.title,desc:e.desc,cover:t.jsx(s,{sx:{position:"relative",paddingTop:`${9/16*100}%`,border:1,borderColor:"divider",borderRadius:1,overflow:"hidden"},children:t.jsx(s,{component:"img",src:j,alt:"",sx:{position:"absolute",top:0,left:0,width:1,filter:c=>c.palette.mode==="dark"?"brightness(0.28) contrast(1.1)":"none"}})}),icon:e.icon,...r})}u.propTypes={board:i.object.isRequired,sx:i.object.isRequired};function $(){const{locale:e}=f(),o=[{id:"1",title:"Blocklet Platform",desc:"Guide to understand and build on our blocklet platform",icon:"https://www.arcblock.io/favicon.ico",link:`https://www.arcblock.io/docs/blocklet-developer/${e}/getting-started`},{id:"2",title:"Create Blocklet",desc:"Build blocklet with just one command line.",icon:"https://www.arcblock.io/favicon.ico",link:`https://www.arcblock.io/docs/createblocklet/${e}/quick-start`},{id:"3",title:"Blocklet Launcher",desc:"Streamlining Blocklet Launching.",icon:"https://www.arcblock.io/docs/uploads/5a4f4716bc8061532a535fe816a9169c.png",link:`https://www.arcblock.io/docs/launcher/${e}/launcher-welcome`},{id:"4",title:"DID Spaces",desc:"Digital Spaces for Decentralized Identity (DID)",icon:"https://www.arcblock.io/docs/uploads/3a8b142d7c940c57eced71eddba2ff19.png",link:`https://www.arcblock.io/docs/did-spaces/${e}/did-spaces-getting-started`},{id:"5",title:"DID Wallet",desc:"DID Wallet Support docs",icon:"https://www.arcblock.io/docs/uploads/59ddb28f405ee670428e5fe1ff12d104.png",link:`https://www.arcblock.io/docs/did-wallet/${e}/get-started`},{id:"6",title:"DID Names",desc:"Naming Service based on NFT and verifiable credentials",icon:"https://www.didnames.io/favicon.ico?imageFilter=resize&w=32",link:`https://www.arcblock.io/docs/did-domain/${e}/did-domain-faq`},{id:"7",title:"Blockchain",desc:"The ledger for ArcBlock ecosystem",icon:"https://www.arcblock.io/docs/uploads/4a20c152faae0f104ed0815ff3b8b48b.png",link:`https://www.arcblock.io/docs/blockchain/${e}/blockchain-how-to-guides`},{id:"8",title:"DID Connect",desc:"The open protocol and development kit for connecting users and dapps",icon:"https://www.arcblock.io/docs/uploads/d189118f89b56e9d5b03ad5a0212a4ab.png",link:`https://www.arcblock.io/docs/did-connect/${e}/developer-guides`}];return t.jsx(p,{children:o.map(r=>t.jsx(u,{board:r},r.id))})}export{$ as default};
@@ -0,0 +1,7 @@
1
+ import{T as M,H as q,I as N,k as V,C as ve,D as Ce,N as Se}from"./vendor-ux-D2yvD18l.js";import{q as Te,k as le,s as Ie}from"./vendor-hooks-CFpNP5Ql.js";import{r as E,a as ae}from"./vendor-react-x2lQvn4m.js";import{j as e,a1 as Re,bB as We,a3 as ze,ak as p,G as se,T as C,p as F,aX as te,W as De,V as H,b6 as ne,am as A,bt as _,C as J,Z as Q,X as Z,b4 as Oe,Y as L,I as B,cl as $e,bc as Ae,q as Pe,F as qe,$ as t,b1 as R,a7 as ce,bY as ee,cp as Le,aO as Me,aP as Be,cq as Fe,cr as He,cs as Ne,s as oe,aU as Ue,aj as _e,O as Ye,ct as Ke,aZ as Ve,cg as Je,c9 as Xe,cf as Ge}from"./vendor-mui-core-Bz-X9hX7.js";import{g as de,a as pe,l as ue}from"./index-wBG-OAs3.js";import{_ as Y,c as xe,ad as Qe,Y as Ze,aY as X}from"./index-BpP1Znfh.js";import{u as K}from"./dashboard-D5VBBuOs.js";import{u as et}from"./use-mobile-BkNZycG6.js";import{u as tt,C as G}from"./index.esm-BONQrRCU.js";import{C as he,a as me,J as ot}from"./vendor-utils-Vke2d2wu.js";import{C as st}from"./confirm-Cap-op6n.js";import{A as nt}from"./actions-DK8uxYzD.js";import{T as ie}from"./table-tips-DCJRX0td.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-Cvkavi6C.js";import"./useLocalStorage-BrLsVuBH.js";import"./index-DBs9Ljax.js";import"./get-safe-url-DeteK1Tn.js";import"./session-Ctfgia_m.js";import"./use-blocklet-logo-CjoRB6rM.js";import"./dot-CSvzbUXF.js";import"./useAsync-fxvoN33w.js";import"./useSetState-BWrXo9eH.js";import"./index-BUiXC-M8.js";import"./over-due-invoice-payment-Bd6FvSmz.js";import"./use-mobile-BgklPLaO.js";const it=i=>{const[u,c]=E.useState(null),[b,r]=E.useState(!0),[w,x]=E.useState(null),j=window.blocklet?.appUrl,l=E.useMemo(()=>{const g={};return u&&(u.sources.forEach(y=>{g[y.did]={source:y,events:[],count:0}}),u.events.forEach(y=>{g[y.source]&&(g[y.source].events.push(y),g[y.source].count+=1)})),g},[u]),f=async()=>{try{if(r(!0),!j)return;const y=await(await fetch(he(j,xe.WELLKNOWN_SERVICE_PATH_PREFIX,"/openevent.json"))).json();c(y),x(null)}catch(g){x(g instanceof Error?g:new Error(String(g)))}finally{r(!1)}};return E.useEffect(()=>{f()},[j]),{openEvent:u,setOpenEvent:c,eventsBySource:l,loading:b,error:w,loadData:f}};function ge({eventsBySource:i,selectedEvents:u,setSelectedEvents:c,error:b=null}){const{t:r}=M(),[w,x]=E.useState({}),j=E.useMemo(()=>{const n={};return Object.entries(i).forEach(([a,{events:m}])=>{const v=m.filter(S=>u[`${S.type}-${S.source}`]).length;n[a]=v}),n},[i,u]),l=E.useMemo(()=>Object.values(j).reduce((n,a)=>n+a,0),[j]),f=E.useMemo(()=>Object.values(i).reduce((n,{events:a})=>n+a.length,0),[i]),g=(n,a)=>{a.stopPropagation(),x({...w,[n]:!w[n]})},y=n=>{const a=`${n.type}-${n.source}`;c(m=>({...m,[a]:!m[a]}))},z=(n,a)=>{const m={};n.forEach(v=>{const S=`${v.type}-${v.source}`;m[S]=!a}),c(v=>({...v,...m}))},T=n=>{const a={};Object.values(i).forEach(({events:m})=>{m.forEach(v=>{const S=`${v.type}-${v.source}`;a[S]=n.target.checked})}),c(a)};return e.jsxs(p,{sx:{width:"100%"},children:[e.jsxs(p,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ne,{control:e.jsx(J,{onChange:T,checked:l>0&&l===f}),label:e.jsxs(p,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[r("webhookEndpoint.selectAllEvents"),e.jsx(p,{sx:{display:"flex",alignItems:"center"},children:e.jsx(A,{title:r("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(_,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),l>0&&e.jsx(C,{variant:"body2",color:"primary",sx:{ml:"auto"},children:r("webhookEndpoint.selectedEventsCount",{count:l})})]}),e.jsx(p,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(Q,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:"4px"},children:Object.entries(i).map(([n,{source:a,events:m,count:v}],S)=>{const D=j[n]>0,I=j[n]===m.length&&m.length>0,O=w[n];return e.jsxs(ae.Fragment,{children:[e.jsx(Z,{sx:{borderBottom:({palette:o})=>S<Object.keys(i).length-1?`1px solid ${o.divider}`:"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(p,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:o=>{o.target.closest(".MuiFormControlLabel-root")||g(n,o)},children:[e.jsx(p,{sx:{display:"flex",alignItems:"center"},children:m.length>0&&e.jsx(ne,{control:e.jsx(J,{checked:I,indeterminate:D&&!I,onChange:o=>{o.stopPropagation(),z(m,I)}}),label:e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[a.logo&&e.jsx(Oe,{src:a.logo,sx:{width:24,height:24}}),e.jsx(p,{children:a.title||n}),D&&e.jsx(L,{label:r("webhookEndpoint.selectedCount",{count:j[n]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:o=>`${o.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(p,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(C,{variant:"body2",sx:{color:"text.secondary",mr:1},children:r("webhookEndpoint.eventsCount",{count:v})}),m.length>0&&e.jsx(B,{size:"small",edge:"end",children:O?e.jsx($e,{}):e.jsx(Ae,{})})]})]})}),m.length>0&&e.jsx(Pe,{in:O,timeout:"auto",unmountOnExit:!0,children:e.jsx(Q,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:m.map(o=>{const d=`${o.type}-${o.source}`,s=!!u[d];return e.jsx(Z,{dense:!0,sx:{py:.75},onClick:()=>y(o),children:e.jsxs(p,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(J,{checked:s,sx:{mr:1}}),e.jsxs(p,{children:[e.jsx(C,{variant:"body1",sx:{cursor:"pointer",color:"text.primary"},children:o.type}),e.jsx(C,{variant:"caption",sx:{color:"text.secondary",display:"block",cursor:"pointer"},children:o.description})]})]})},d)})})})]},n)})})}),b&&e.jsx(qe,{error:!0,sx:{mt:1},children:b})]})}ge.propTypes={eventsBySource:t.objectOf(t.shape({source:t.shape({did:t.string.isRequired,title:t.string,description:t.string,version:t.string,logo:t.string}).isRequired,events:t.arrayOf(t.shape({type:t.string.isRequired,description:t.string.isRequired,source:t.string.isRequired})).isRequired,count:t.number.isRequired})).isRequired,selectedEvents:t.objectOf(t.bool).isRequired,setSelectedEvents:t.func.isRequired,error:t.string};function fe({id:i=null,url:u="",description:c="",enabledEvents:b=[],onSubmit:r,onClose:w=()=>{}}){const{t:x}=M(),[j,l]=E.useState({}),{teamDid:f}=K(),{api:g}=Y(),{loading:y,error:z,eventsBySource:T}=it(),{control:n,handleSubmit:a,formState:{errors:m},reset:v,setValue:S,trigger:D}=tt({defaultValues:{url:"",description:""}});E.useEffect(()=>{const o=Object.values(j).some(d=>d);S("selectedEvents",o?"valid":""),D("selectedEvents")},[j,S,D]);const I=()=>{l({}),v(),w()},O=async o=>{const d=Object.keys(j).filter(h=>j[h]),s={url:o.url,description:o.description,enabledEvents:d.map(h=>{const[k,W]=h.split("-");return!k||!W?null:{type:k,source:W}}).filter(Boolean)};try{if(i){const h=await g.updateWebhookEndpoint({input:{teamDid:f,id:i,data:s}});q.success(`${x("webhookEndpoint.updateWebhook")} ${x("webhookEndpoint.success")}`),r(h)}else{const h=await g.createWebhookEndpoint({input:{teamDid:f,input:s}});q.success(`${x("webhookEndpoint.createWebhook")} ${x("webhookEndpoint.success")}`),r(h)}}catch(h){q.error(h?.message)}I()};return E.useEffect(()=>{v({url:u,description:c}),l(b.reduce((o,d)=>(o[`${d.type}-${d.source}`]=!0,o),{}))},[v,l,u,c,b]),e.jsx(Re,{open:!0,onClose:I,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:a(O),children:[e.jsx(We,{children:x(i?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(ze,{children:e.jsxs(p,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(G,{name:"url",control:n,rules:{required:x("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:x("webhookEndpoint.validation.urlInvalid")}},render:({field:o})=>e.jsx(se,{...o,label:x("webhookEndpoint.url.label"),fullWidth:!0,error:!!m.url,helperText:m.url?.message})}),e.jsx(G,{name:"description",control:n,rules:{required:x("webhookEndpoint.validation.descriptionRequired")},render:({field:o})=>e.jsx(se,{...o,label:x("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!m.description,helperText:m.description?.message})}),e.jsx(G,{name:"selectedEvents",control:n,rules:{required:x("webhookEndpoint.validation.eventRequired")},render:({field:o})=>e.jsx("input",{type:"hidden",...o})}),!y&&T&&Object.keys(T).length>0&&e.jsx(ge,{eventsBySource:T,selectedEvents:j,setSelectedEvents:l,error:m.selectedEvents?.message}),!y&&(!T||Object.keys(T).length===0)&&e.jsx(C,{sx:{color:"text.secondary"},children:x("webhookEndpoint.noAvailableEvents")}),y&&e.jsx(p,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(F,{size:20})}),z&&e.jsx(te,{severity:"error",children:x("webhookEndpoint.loadingError",{message:z?.message})})]})}),e.jsxs(De,{sx:{p:"8px 24px 24px"},children:[e.jsx(H,{onClick:I,children:x("common.cancel")}),e.jsx(H,{type:"submit",variant:"contained",color:"primary",children:x(i?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}fe.propTypes={onSubmit:t.func.isRequired,id:t.string,url:t.string,description:t.string,enabledEvents:t.arrayOf(t.shape({type:t.string.isRequired,source:t.string.isRequired})),onClose:t.func};function be(i){switch(i){case"enabled":return"success";case"disabled":default:return"default"}}const rt=(i="en")=>i==="tw"?"zh":i;function U(i,u="YYYY-MM-DD HH:mm:ss",c="en"){return i?Qe(i).locale(rt(c)).format(u):"-"}function lt(i){return typeof i=="number"?!1:me(i)}function at(i){return i>=200&&i<300}function $({value:i,label:u,tip:c="",divider:b=!1}){const r=lt(i);return e.jsxs(e.Fragment,{children:[e.jsxs(R,{direction:"column",alignItems:"flex-start",children:[e.jsxs(C,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[u,!!c&&e.jsx(A,{title:c,children:e.jsx(_,{fontSize:"small"})})]}),e.jsx(C,{component:"div",variant:"body1",color:r?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:r?"-":i})]}),b&&e.jsx(ce,{orientation:"vertical",flexItem:!0})]})}$.propTypes={label:t.oneOfType([t.string,t.node]).isRequired,value:t.oneOfType([t.string,t.node]).isRequired,tip:t.oneOfType([t.string,t.node]),divider:t.bool};function je({title:i,children:u=null,mb:c=1.5,mt:b=1.5}){return e.jsxs(R,{className:"section-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,mb:c,mt:b,pb:1},children:[e.jsx(C,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:i}),u]})}je.propTypes={title:t.oneOfType([t.string,t.node]).isRequired,children:t.node,mb:t.number,mt:t.number};const ct={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},dt=i=>{const u={};return i.forEach(c=>{const b=new Date(c.createdAt).toLocaleDateString();u[b]||(u[b]=[]),u[b]?.push(c)}),u};function ye({eventId:i="",webhookEndpointId:u="",event:c=null}){const{api:b,ws:{useSubscription:r}}=Y(),{t:w}=M(),{teamDid:x}=K(),{blocklet:j}=Ze(),{data:l,loadMore:f,loadingMore:g,loading:y,mutate:z}=Te(s=>{const k=s?Math.ceil(s.list.length/15)+1:1;return b.getWebhookAttempts({input:{teamDid:x,input:{eventId:i,webhookId:u},paging:{page:k,pageSize:15}}})},{reloadDeps:[i,u]}),T=l?.list||[],[n,a]=E.useState(null),[m,v]=E.useState(!1),S=dt(T);if(E.useEffect(()=>{!n&&l?.list.length&&a(l.list[0])},[l?.list.length,n]),r(xe.EVENTS.WEBHOOK_ATTEMPT,s=>{z(h=>{if(h.list.find(W=>W.id===s.id)){const W=h.list.map(P=>P.id===s.id?{...P,...s}:P);return{...h,list:W}}return s.endpoint=h.list[0]?.endpoint,s.event=h.list[0]?.event,{...h,list:[s,...h.list]}})},[]),y)return e.jsx(F,{});const D=l&&l.list.length<l.paging.total,I=async()=>{n&&(v(!0),await b.retryWebhookAttempt({input:{teamDid:x,eventId:n.event.id,webhookId:u,attemptId:n.id}}).finally(()=>{setTimeout(()=>{v(!1)},1e3)}))},O=s=>{if(s.responseBody&&s.responseBody?.sessionId&&s.responseBody?.projectId&&s.responseBody?.agentId){const h=j?.site?.domainAliases[0]?.value,k=(j.children||[]).find(P=>P?.meta?.name==="ai-studio"),W=ot(he(`https://${h}`,k?.mountPoint||"","projects",s.responseBody.projectId,"logs/main"),{sessionId:s.responseBody.sessionId,agentId:s.responseBody.agentId});return e.jsx(B,{sx:{fontSize:20},onClick:()=>window.open(W,"_blank"),children:e.jsx(p,{component:N,icon:X})})}return null},o=s=>s.status==="pending"?e.jsx(Fe,{color:"warning"}):at(s.responseStatus)?e.jsx(He,{color:"success"}):e.jsx(Ne,{color:"error"}),d=n?.triggeredFrom&&(l?.list||[]).find(s=>s.id===n.triggeredFrom);return e.jsxs(pt,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ee,{size:{xs:12,md:4},sx:{height:1},children:me(Object.keys(S))?e.jsx(C,{sx:{color:"text.secondary"},children:w("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(S).map(([s,h])=>e.jsxs(ae.Fragment,{children:[e.jsx(Le,{sx:{p:0},children:s}),h.map(k=>e.jsxs(Z,{sx:{cursor:"pointer",px:1},onClick:()=>a(k),selected:n&&n?.id===k?.id,secondaryAction:e.jsx(C,{sx:{color:"text.secondary"},children:U(k.createdAt,"HH:mm:ss")}),children:[e.jsx(Me,{sx:{minWidth:0,mr:1.5},children:o(k)}),e.jsx(Be,{primary:e.jsx(C,{sx:{color:"text.primary"},children:k.event.type})})]},k.id))]},s))}),D&&e.jsx(p,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1},children:e.jsx(H,{variant:"text",type:"button",color:"inherit",onClick:f,disabled:g,sx:{color:s=>s.palette.text.disabled},children:w(g?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ee,{size:{xs:12,md:8},sx:{height:1},children:[n&&e.jsxs(R,{direction:"column",spacing:2,sx:{height:1,overflow:"auto",pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(p,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"h4",children:w(`common.${n.status}`)}),e.jsx(p,{children:O(n)})]}),e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[d&&e.jsx(A,{placement:"left",title:e.jsxs(R,{onClick:()=>a(d),sx:{gap:1,cursor:"pointer",".did-address-text":{color:"common.white"}},children:[e.jsx(de,{showDid:!0,did:n.triggeredBy,cardType:ue.Detailed,infoType:pe.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(ce,{}),e.jsxs(p,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(C,{variant:"body2",sx:{color:"primary.main"},children:w("webhookEndpoint.triggeredFrom")}),e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"body2",children:n.id}),e.jsx(B,{onClick:()=>a(d),children:e.jsx(p,{component:N,icon:X,sx:{fontSize:16,color:"common.white"}})})]})]})]}),slotProps:{tooltip:{sx:{maxWidth:400}}},children:e.jsx(B,{onClick:()=>a(d),children:e.jsx(p,{component:N,icon:X,sx:{fontSize:16}})})}),e.jsxs(H,{variant:"outlined",color:"primary",size:"small",onClick:I,disabled:m,children:[e.jsx(p,{component:N,icon:ct,sx:{fontSize:16,animation:m?"spin 1s linear infinite":"none",mr:.5}}),w("notification.resend")]})]})]}),e.jsxs(p,{children:[e.jsxs(C,{variant:"h6",children:[w("webhookEndpoint.response")," (",n.responseStatus,")"]}),e.jsx(V,{language:"json",children:JSON.stringify(n.responseBody,null,2)})]}),e.jsxs(p,{children:[e.jsx(R,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(C,{variant:"h6",children:w("webhookEndpoint.request")})}),e.jsx(V,{language:"json",sx:{margin:0},children:JSON.stringify(n.event,null,2)})]})]}),l?.list.length===0&&c&&e.jsxs(p,{children:[e.jsx(R,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(C,{variant:"h6",children:w("webhookEndpoint.eventData")})}),e.jsx(V,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}ye.propTypes={eventId:t.string,webhookEndpointId:t.string,event:t.shape({type:t.string,data:t.object,request:t.object,requestInfo:t.object})};const pt=oe(ee)`
2
+ @keyframes spin {
3
+ to {
4
+ transform: rotate(360deg);
5
+ }
6
+ }
7
+ `;function we({id:i,onClose:u}){const{t:c}=M(),{api:b}=Y(),{teamDid:r}=K(),{loading:w,error:x,data:j}=le(()=>b.getWebhookEndpoint({input:{teamDid:r,id:i}})),l=j?.data;return x?e.jsx(te,{severity:"error",children:x.message}):w||!l?e.jsx(p,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1},children:e.jsx(F,{})}):e.jsxs(ut,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(p,{children:[e.jsxs(R,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsx(R,{sx:{flex:1,width:0},children:e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"h5",sx:{fontWeight:600,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:l.description}),e.jsx(A,{title:l.url,children:e.jsx(_,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(R,{direction:"row",sx:{alignItems:"center"},children:e.jsx(B,{edge:"end",color:"inherit",onClick:u,children:e.jsx(_e,{})})})]}),e.jsx(p,{sx:{mt:2},children:e.jsxs(R,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},sx:{justifyContent:"flex-start",flexWrap:"wrap",pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx($,{label:c("common.status"),value:e.jsx(L,{size:"small",variant:"filled",label:l.status,color:be(l.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx($,{label:c("webhookEndpoint.listen"),value:e.jsx(A,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:l.enabledEvents.map(f=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:f?.type},f))}),children:e.jsx(L,{size:"small",variant:"filled",label:c("webhookEndpoint.eventsCount",{count:l.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx($,{label:c("webhookEndpoint.version"),value:l.apiVersion,divider:!0}),e.jsx($,{label:c("common.createdAt"),value:U(l.createdAt),divider:!0}),e.jsx($,{label:c("common.updatedAt"),value:U(l.updatedAt),divider:!0}),e.jsx($,{label:c("common.createdBy"),value:e.jsx(A,{arrow:!0,title:l.createUser?.did,children:e.jsx(L,{size:"small",variant:"filled",label:l.createUser?.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx($,{label:c("common.updatedBy"),value:e.jsx(A,{arrow:!0,title:l.updateUser?.did,children:e.jsx(L,{size:"small",variant:"filled",label:l.updateUser?.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(R,{className:"section",sx:{flex:1,height:0,overflow:"hidden"},children:[e.jsx(je,{title:c("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(R,{sx:{height:0,flex:1,overflow:"hidden"},children:e.jsx(ye,{webhookEndpointId:l.id})})]})]})}we.propTypes={id:t.string.isRequired,onClose:t.func.isRequired};const ut=oe(R)``;function ke({open:i,onClose:u,id:c}){return e.jsx(Ue,{anchor:"right",open:i,onClose:u,slotProps:{paper:{sx:{width:"90vw",maxWidth:"1200px"}}},children:e.jsx(p,{sx:{height:"100vh",p:3},children:e.jsx(we,{id:c,onClose:u})})})}ke.propTypes={open:t.bool.isRequired,onClose:t.func.isRequired,id:t.string.isRequired};function re(){return null}function Ee({options:i={},columns:u=[],toolbar:c=!0,footer:b=!0,hasRowLink:r=!1,emptyNodeText:w="",durable:x="",durableKeys:j=[],data:l=[],loading:f=!1,...g}){const{locale:y}=M(),z=Ye(a=>a.breakpoints.down("md")),T={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:z?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},n={};return c||(n.TableToolbar=re),b||(n.TableFooter=re),e.jsx(xt,{locale:y,options:{...T,...i},columns:(u||[]).map(a=>(a.options=a.options||{},a.options.filter=a.options.filter||!1,a.options.sort=a.options.sort||!1,a)),emptyNode:e.jsx(ve,{children:w}),...g,durable:x,durableKeys:j,data:l,loading:f,components:n,hasRowLink:r,isMobile:z})}Ee.propTypes={options:t.object,columns:t.array,toolbar:t.bool,footer:t.bool,hasRowLink:t.bool,emptyNodeText:t.node,durable:t.string,durableKeys:t.array,data:t.array,loading:t.bool,onChange:t.func,title:t.node,components:t.object};const xt=oe(Ce)``,ht=E.memo(Ee);function Ft(){const{teamDid:i}=K(),u=et(),c=`webhook-endpoints-${i}`,b=Se(c),{t:r,locale:w}=M(),{api:x}=Y(),[j,l]=E.useState(""),[f,g]=E.useState({webhookDetail:{open:!1,id:null},createEdit:{open:!1,id:null,url:"",description:"",enabledEvents:[]},deleteConfirm:null}),[y,z]=Ie(c,{defaultValue:{pageSize:b.rowsPerPage||20,page:b.page?b.page+1:1}}),{loading:T,error:n,data:a,refresh:m}=le(()=>x.getWebhookEndpoints({input:{teamDid:i,paging:{page:y.page,pageSize:y.pageSize}}}));E.useEffect(()=>{m()},[y,m]);const v=E.useCallback(async(o,d)=>{try{await x.updateWebhookEndpoint({input:{teamDid:i,id:o.id,data:{status:d?"disabled":"enabled"}}}),m(),q.success(`${r(d?"webhookEndpoint.disable":"webhookEndpoint.enable")}${r("webhookEndpoint.success")}`)}catch(s){q.error(s?.message)}},[x,i,m,r]),S=E.useCallback(async o=>{try{await x.deleteWebhookEndpoint({input:{teamDid:i,id:o}}),m(),g(d=>({...d,deleteConfirm:null})),q.success(`${r("common.delete")}${r("webhookEndpoint.success")}`)}catch(d){q.error(d?.message)}},[x,i,m,r]),D=(o,d)=>{let s=o.page+1;const h=o.searchText||"";if(h!==j){l(h);return}if(d==="changePage"||d==="changeRowsPerPage"){d!=="changePage"&&(s=1);const k={page:s,pageSize:o.rowsPerPage};l(""),z(k)}};if(n)return e.jsx(te,{severity:"error",children:n.message});if(T||!a)return e.jsx(p,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1,height:500},children:e.jsx(F,{})});const I=(a?.list||[]).filter(o=>{if(!j)return!0;const d=j.toLowerCase();return o.description.toLowerCase().includes(d)||o.url.toLowerCase().includes(d)}),O=[{label:"URL",name:"url",options:{customBodyRenderLite:(o,d)=>{const s=I[d];return e.jsxs(p,{sx:{display:"flex",alignItems:"center",cursor:"pointer",gap:.5},children:[e.jsx(C,{variant:"body2",children:s.description}),e.jsx(p,{sx:{display:"flex"},onClick:h=>{h.stopPropagation()},children:e.jsx(A,{title:s.url,children:e.jsx(_,{sx:{fontSize:"15px",marginTop:"1px"}})})})]})}}},{label:"Events",name:"events",options:{customBodyRenderLite:(o,d)=>{const s=I[d];return e.jsx(p,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:s.enabledEvents.map(h=>e.jsx(L,{size:"small",variant:"filled",label:h.type,sx:{borderRadius:"4px",textTransform:"capitalize"}},`${s.source}-${h.type}`))})}}},{label:r("common.status"),name:"status",options:{customBodyRenderLite:(o,d)=>{const s=I[d];return e.jsx(L,{size:"small",variant:"filled",label:r(`webhookEndpoint.${s?.status}`),color:be(s?.status),sx:{borderRadius:"4px",textTransform:"capitalize"}},`status-${s.status}`)}}},{label:r("common.createdAt"),name:"createdAt",minWidth:200,options:{customBodyRender:o=>U(o)}},{label:r("common.createdBy"),name:"createUser",width:100,options:{customBodyRender:o=>o?e.jsx(de,{showDid:!0,did:o?.did,cardType:ue.Detailed,infoType:pe.Minimal,sx:{border:0,padding:0}}):"-"}},{label:r("common.actions"),name:"actions",width:100,align:"center",verticalKeyAlign:"center",options:{customBodyRenderLite:(o,d)=>{const s=I[d],h=s?.status==="enabled";return e.jsx(nt,{actions:[{icon:h?e.jsx(Ke,{}):e.jsx(Ve,{}),text:r(h?"webhookEndpoint.disable":"webhookEndpoint.enable"),onClick:k=>{k.stopPropagation(),v(s,h)}},{icon:e.jsx(Je,{}),text:r("common.edit"),onClick:k=>{k.stopPropagation(),g(W=>({...W,createEdit:{open:!0,id:s.id,url:s.url,description:s.description,enabledEvents:s.enabledEvents}}))}},{icon:e.jsx(Xe,{}),text:r("common.delete"),onClick:k=>{k.stopPropagation(),g(W=>({...W,deleteConfirm:{title:r("webhookEndpoint.deleteWebhook.title"),description:r("webhookEndpoint.deleteWebhook.description"),confirm:r("common.confirm"),cancel:r("common.cancel"),onConfirm:()=>S(s.id),onCancel:()=>g(P=>({...P,deleteConfirm:null}))}}))}}]})}}}];return e.jsxs(p,{sx:{".custom-toobar-btns":{gap:"8px"},".custom-toobar-title .custom-toobar-title-inner>span":{display:"flex",alignItems:"center","white-space":"inherit",height:"100%"}},children:[u?e.jsx(ie,{title:r("webhookEndpoint.listTitle"),tooltipTitle:r("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${w}/webhook`}):null,e.jsx(ht,{durable:c,durableKeys:["page","rowsPerPage"],data:I,columns:O,options:{count:a.count,page:y.page-1,rowsPerPage:y.pageSize,viewColumns:!1,onRowClick:(o,{dataIndex:d})=>{const s=a.list[d];g(h=>({...h,webhookDetail:{open:!0,id:s.id}}))}},loading:T,onChange:D,emptyNodeText:e.jsx(R,{sx:{gap:1},children:r("webhookEndpoint.noWebhooksAdded")}),title:u?null:e.jsx(ie,{title:r("webhookEndpoint.listTitle"),tooltipTitle:r("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${w}/webhook`}),customButtons:[e.jsxs(H,{sx:{color:"common.white"},edge:"end",variant:"contained",color:"primary",onClick:()=>g(o=>({...o,createEdit:{...o.createEdit,open:!0}})),className:"rule-action",children:[T?e.jsx(F,{size:16}):e.jsx(Ge,{style:{fontSize:16}}),r("common.create")]},"add")]}),f.webhookDetail.open&&e.jsx(ke,{open:!0,onClose:()=>g(o=>({...o,webhookDetail:{open:!1,id:null}})),id:f.webhookDetail.id}),f.createEdit.open&&e.jsx(fe,{onSubmit:m,...f.createEdit,onClose:()=>g(o=>({...o,createEdit:{id:null,url:"",description:"",enabledEvents:[],open:!1}}))}),f.deleteConfirm&&e.jsx(st,{title:f.deleteConfirm.title,description:f.deleteConfirm.description,confirm:f.deleteConfirm.confirm,cancel:f.deleteConfirm.cancel,params:f.deleteConfirm.params,onConfirm:f.deleteConfirm.onConfirm,onCancel:f.deleteConfirm.onCancel})]})}export{Ft as default};
@@ -0,0 +1 @@
1
+ import{j as a,T as y,ak as p,J as C,S as j}from"./vendor-mui-core-Bz-X9hX7.js";import{r as c}from"./vendor-react-x2lQvn4m.js";import{aG as f,aH as S,aI as b,aJ as T,aK as w,aL as D}from"./index-BpP1Znfh.js";import{o as m,$ as N}from"./vendor-ux-D2yvD18l.js";var i=(r=>(r.AvatarOnly="AvatarOnly",r.Detailed="Detailed",r))(i||{}),l=(r=>(r.NameOnly="NameOnly",r.Minimal="Minimal",r.Basic="Basic",r))(l||{});function P(r){const{user:e,infoType:o,avatarSize:s=48,shouldShowHoverCard:d=!1,renderCardContent:n,...t}=r;return o===l.NameOnly?a.jsx(f,{user:e,avatarSize:s,shouldShowHoverCard:!1,renderCardContent:n,tooltipTitle:e.fullName||e.email||e.did,...t}):a.jsx(f,{user:e,avatarSize:s,shouldShowHoverCard:d,renderCardContent:n,...t})}function O(r){const{user:e,avatarSize:o=48,onAvatarClick:s}=r;return a.jsxs(a.Fragment,{children:[S(e,o,r.avatarProps,s),a.jsx(y,{variant:"body1",children:e.fullName||e.email||e.did})]})}function R({...r}){const{user:e,avatarSize:o=40,renderCustomContent:s,infoType:d=l.Minimal,renderFields:n,popupRenderFields:t,...u}=r;return a.jsxs(p,{sx:{display:"flex",flexDirection:"column",width:"100%",flex:1,height:"100%"},children:[a.jsx(b,{user:e,avatarSize:o,...u}),d===l.Basic&&a.jsx(T,{user:e,renderFields:n}),a.jsx(p,{className:"user-card__footer",children:s&&a.jsx(p,{sx:{mt:1.5},children:s()})})]})}function h({...r}){const{infoType:e=l.Minimal}=r;switch(e){case l.NameOnly:return a.jsx(O,{...r});default:return a.jsx(R,{...r})}}function g({children:r,sx:e={}}){const o=C();return a.jsx(p,{sx:m({p:2,backgroundColor:o.palette.background.paper,border:"1px solid",borderColor:"divider",borderRadius:1,maxWidth:500,minWidth:320,display:"flex"},e||null),children:r})}function z({children:r,cardType:e=i.Detailed,variant:o="box",containerRef:s=void 0,sx:d={}}){const n={minWidth:320,p:2,borderRadius:1,...e===i.Detailed?{border:"1px solid",borderColor:"divider"}:{}};return o==="paper"?a.jsx(j,{ref:s,elevation:0,sx:n,children:r}):a.jsx(p,{ref:s,sx:m(n,{display:"flex",alignItems:e===i.AvatarOnly?"center":"flex-start",gap:2},d||null),children:r})}function B(r){const{cardType:e=i.Detailed,showHoverCard:o}=r,s=o!==void 0?o:e===i.AvatarOnly,d=c.useRef(null),[n,t]=c.useState(()=>r.user||null);if(c.useEffect(()=>{let x=!0;return r.user?t(r.user):r.did&&w(r.did)&&!r.user&&D(r.did).then(v=>{x&&t(v||{fullName:"Anonymous",did:r.did,avatar:""})}),()=>{x=!1}},[r.did,r.user]),!n)return a.jsx(N,{did:r.did,size:r.avatarSize,...r.avatarProps});const u=()=>a.jsx(g,{sx:r.popupSx,children:a.jsx(h,{...r,shouldShowHoverCard:!1,user:n,avatarProps:r.popupAvatarProps,shortenLabelProps:r.popupShortenLabelProps||r.shortenLabelProps,renderFields:r.popupRenderFields,renderName:r.popupRenderName,infoType:r.popupInfoType||r.infoType,didProps:r.popupDidProps||r.didProps,showDid:r.popupShowDid||r.showDid})});return e===i.AvatarOnly?a.jsx(P,{...r,shouldShowHoverCard:s,renderCardContent:u,user:n}):a.jsx(z,{containerRef:d,cardType:e,sx:r.sx,children:a.jsx(h,{...r,shouldShowHoverCard:s,renderCardContent:u,user:n})})}export{l as a,B as g,i as l};
@@ -1,5 +1,5 @@
1
- import{j as e,$ as u,p as A,T as j,ar as Ne,J as _e,dD as V,ao as X,dE as We,ak as S,av as G,az as Ge,s as xe,dF as be,be as Ke,am as ge,bB as Fe,M as F,a_ as Y,ce as Ye,a$ as $,V as $e,b7 as qe,aD as He,dG as Qe,dH as Je,dI as Ve,bU as Xe,aC as he}from"./vendor-mui-core-CB7usZvs.js";import{m as Ze,j as ke,b as ue}from"./vendor-hooks-BA23GwO5.js";import{r as h,j as et}from"./vendor-react-BvXSmFbV.js";import{c as M,w as tt,I as st,J as nt,D as ot,K as le,v as at}from"./vendor-arcblock-B55HFGqZ.js";import{a3 as B,T as E,bb as rt,f as I,bd as q,ac as it,bA as ct,n as de,au as lt,z as je,az as dt}from"./vendor-ux-did-connect-soajAeMx.js";import{G as O,D as N,y as D,ab as pt,an as ut,aO as mt}from"./index-B3QNvDDj.js";import{u as ft}from"./use-mobile-KernkJ0t.js";import{a as H,d as Ce,a4 as xt,e as gt,z as we,D as me}from"./vendor-utils-eI_TRB_9.js";import"./api-Cux33v3g.js";import{u as Be,C as ht,D as St,a as yt}from"./connect-to-BHJ-dAXD.js";import{b as bt,c as kt,d as jt,i as Ct,e as fe,f as wt,h as Bt,j as Dt}from"./spaces-BEQecBKs.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Et}from"./index-CuVvB-Cv.js";import{E as Tt}from"./index-CMf86-QO.js";import{g as Se}from"./get-safe-url-BH99736U.js";import{S as It}from"./switch-control-B_6jQTpz.js";import{C as Rt,u as Pt}from"./config-space-Bf5mw5iZ.js";import{L as ye}from"./list-header-CxfG7AtB.js";import"./lottie-web-4koyQiv_.js";async function vt({blockletDid:t,nodeApi:o,spaceGateways:a}){let s=!1;const i=await Promise.all(a.map(async n=>{let{name:r}=n;const l=await bt(n.endpoint);return!H(l)&&l!==r&&(r=l,s=!0),{...n,name:r}}));return s&&await Promise.all(i.filter(n=>n.did).map(n=>o.updateBlockletSpaceGateway({input:{did:t,where:{did:n.did},spaceGateway:{...n}}}))),i}function zt({refresh:t}={}){const{blocklet:o}=O(),a=o?.meta?.did,{api:s}=N();return Ze(async()=>{if(!a)return[];const{spaceGateways:i}=await s.getBlockletSpaceGateways({input:{did:a}});return await vt({blockletDid:a,nodeApi:s,spaceGateways:i})??[]},{refreshDeps:[a,t],onError(i){i?.message?.includes("not logged")?console.warn(i):(console.error(i),B.error(Q(i)))}})}function De({deps:t,setLoading:o,backupDate:a}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=O(),[i,n]=h.useState([]),{api:r}=N(),[l,d]=h.useMemo(()=>a?[D(a).startOf("day").toISOString(),D(a).endOf("day").toISOString()]:[D().startOf("year").toISOString(),D().endOf("day").toISOString()],[a]),c=Ce(async()=>{try{if(o(!0),!s){n([]);return}const{backups:m}=await r.getBlockletBackups({input:{did:s.meta.did,startTime:l,endTime:d}});n(m??[])}catch(m){console.error(m),B.error(Q(m))}finally{o(!1)}},1e3);return ke(async()=>{c()},[s?.meta?.did].concat(t)),{backups:i}}function At({appDid:t}){const{backups:o}=De(),[a,s]=h.useState({message:"",progress:0,completed:!1}),i=N(),{ws:{useSubscription:n}}=i;return n(M.BlockletEvents.backupProgress,r=>{t===r?.appDid&&s(()=>({...r}))},[t]),h.useEffect(()=>{if(o?.length&&xt(o[0]?.status)){const[r]=o;s(()=>({message:r.message,progress:r.progress,completed:r.progress>=100}))}},[o]),a}function Ot({deps:t=[],setLoading:o=()=>{}}={}){const{blocklet:a}=O(),[s,i]=h.useState([]),{api:n}=N(),r=h.useCallback(Ce(async()=>{if(!n||!a?.meta?.did){i([]);return}try{o(!0);const l=D(),d=l.subtract(1,"year"),{summary:c}=await n.getBlockletBackupSummary({input:{did:a.meta.did,startTime:d.toISOString(),endTime:l.toISOString()}});i(Array.isArray(c)?c:[])}catch(l){console.error("Failed to fetch backup summary:",l),B.error(Q(l)),i([])}finally{o(!1)}},1e3),[]);return ke(async()=>(await r(),()=>{r.cancel()}),[a?.meta?.did].concat(t)),{backupSummary:s}}const Ee=h.createContext({}),{Provider:Ut,Consumer:fs}=Ee;function Te({children:t}){const{t:o}=E(),{api:a}=N(),{blocklet:s}=O(),[i,n]=h.useState(null),[r,l]=h.useState(!1),{data:d,loading:c,mutate:m}=zt({refresh:r}),g=gt(d),f=At({appDid:s?.appDid}),p=h.useMemo(()=>kt(s?.environments),[s?.environments]),[k,w]=h.useState(!1),[y,b]=h.useState(!1),{backups:Z}=De({deps:[y,i],setLoading:w,backupDate:i}),[ee,te]=h.useState(!1),{backupSummary:se}=Ot({deps:[ee]}),[_,L]=h.useState(d?.find(x=>x.endpoint===p)),T=s?.settings?.autoBackup,P=()=>{l(x=>!x)},ne=()=>{te(x=>!x)},oe=()=>{b(x=>!x)},K=async x=>{await a.updateAutoBackup({input:{did:s.meta.did,autoBackup:x}})},J=async()=>{await a.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(x,z)=>{try{m(R=>{const v=[...R];return v.push({...x,loading:!0}),v}),await a.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:x}}),p!==z&&await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:z}]}}),L(x),P(),B.success(o("storage.spaces.connectedWithName",{name:x?.name??"DID Spaces"}))}catch(R){throw console.error(R),m(v=>[...v].filter(W=>W.did!==x.did)),R}},re=async x=>{x&&(x.endpoint===p&&(await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),T?.enabled&&await K({enabled:!1})),await a.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:x?.did}}),m(z=>{const R=[...z];return R.splice(R.indexOf(x),1),R}),L(x),P())},ie=async x=>{await Promise.all([a.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:x.did},spaceGateway:x}}),p!==x.endpoint&&a.configBlocklet({input:{did:[s.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:x.endpoint}]}})]),B.success(o("storage.spaces.connectedWithName",{name:x?.name??"DID Spaces"})),P()},C=x=>x?.endpoint===p;return e.jsx(Ut,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:P,spaceGatewaysLoading:c,spaceGatewaysFirstLoading:g,spaceGatewayIsSelected:C,updateAutoBackup:K,abortBlockletBackup:J,backupEndpoint:p,backupProgress:f,backups:Z,backupSummary:se,refreshBackupSummary:ne,refreshBackups:oe,setBackupDate:n,backupsLoading:k,autoBackup:T},children:t})}Te.propTypes={children:u.any.isRequired};function U(){return h.useContext(Ee)}function Ie({...t}){const{blocklet:o}=O(),{info:a}=N(),{t:s}=E(),i=Be({blocklet:o}),n=pt(a),{spaceGateways:r,addSpaceGateway:l}=U(),d={checkFn:we.create({baseURL:me(window.location.origin,ut())}).get,webWalletUrl:n,extraParams:{appPid:o.appPid,appDid:i.appDid,appName:i.appName,appDescription:i.appDescription,appUrl:i.appUrl,referrer:i.referrer,scopes:i.scopes,nodeDid:a.did}},c=async({endpoint:g,name:f,did:p})=>{const k=await jt(g);if(!await Ct(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(r.some(b=>b.endpoint===g)){B.error(s("storage.spaces.gateway.add.duplicate",{name:f}));return}await l({name:f,did:p,url:k,endpoint:g},g)},m=async({spaceGateway:g})=>{try{await c(g)}catch(f){console.error(f),B.error(Q(f))}};return e.jsx(tt,{...t,connectScope:"app",options:d,onSuccess:m})}function Re({...t}){const{t:o}=h.useContext(rt),{blocklet:a,loadingDiskInfo:s,actions:i}=O();if(h.useEffect(()=>{i?.refreshBlocklet({showError:!1,attachDiskInfo:!0})},[]),a.diskInfo){const n=(d,c,m)=>e.jsxs(j,{children:[d," ",e.jsx("strong",{children:c?mt(c):"empty"})]}),r=a.environments.reduce((d,c)=>(d[c.key]=c.value,d),{}),l=[{key:"appDir",name:o("blocklet.diskInfo.appDir"),value:n(r.BLOCKLET_APP_DIR,a.diskInfo.app)},{key:"dataDir",name:o("blocklet.diskInfo.dataDir"),value:n(r.BLOCKLET_DATA_DIR,a.diskInfo.data)},{key:"logDir",name:o("blocklet.diskInfo.logDir"),value:n(r.BLOCKLET_LOG_DIR,a.diskInfo.log)},{key:"cacheDir",name:o("blocklet.diskInfo.cacheDir"),value:n(r.BLOCKLET_CACHE_DIR,a.diskInfo.cache)}];return e.jsx(Lt,{component:"div",...t,children:l.map(d=>e.jsx(Et,{valueComponent:"div",nameWidth:120,name:d.name,children:d.value},d.key))})}return s?e.jsx(A,{}):e.jsx(j,{children:o("blocklet.diskInfo.empty")})}const Lt=Ne(j)``;function Pe(){const{t}=E(),{setBackupDate:o,backupSummary:a}=U(),s=st({key:"lg"}),i=h.useRef(null),n=_e(),r=h.useCallback(c=>{o(c)},[o]),l=h.useMemo(()=>{const c=D().add(1,"day"),m=D().subtract(11,"month").startOf("month"),g=new Map(a.map(p=>[p.date,{date:p.date,successCount:p.successCount,errorCount:p.errorCount}])),f=[];for(let p=m.clone();D(p).isBefore(c);p=p.add(1,"day")){const k=p.format("YYYY-MM-DD");f.push(g.get(k)||{date:k,successCount:0,errorCount:0})}return f},[a]),d=h.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:y,errorCount:b}=l[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${y}</div>`,`<div>${t("common.failed")}: ${b}</div>`].join(`
2
- `)},backgroundColor:n.palette.background.paper,borderColor:n.palette.divider,textStyle:{color:n.palette.text.primary,fontSize:14},extraCssText:`box-shadow: ${n.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:n.palette.grey[200]},{min:1,max:3,color:X[300]},{min:3,max:6,color:X[400]},{min:6,max:9,color:X[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:X[600]}],orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:12,textStyle:{color:n.palette.text.secondary,fontSize:12}},calendar:{top:30,left:50,right:10,bottom:4,cellSize:[8,8],splitLine:{show:!1},itemStyle:{borderWidth:2,borderColor:n.palette.background.default,color:n.palette.background.default},dayLabel:{show:!0,firstDay:0,nameMap:["","Mon","","Wed","","Fri",""],position:"start",margin:4,fontSize:10,color:n.palette.text.primary,fontWeight:"400",width:20},monthLabel:{show:!0,nameMap:"cn",align:"left",color:n.palette.text.primary,fontWeight:"400",fontSize:12,position:"start",margin:4,width:30,padding:[0,2]},yearLabel:{show:!1},range:[D().subtract(11,"month").startOf("month").format("YYYY-MM-DD"),D().endOf("month").format("YYYY-MM-DD")],orient:"horizontal"},series:{type:"heatmap",coordinateSystem:"calendar",data:l.map(k=>[k.date,k.errorCount?-k.errorCount:k.successCount]),label:{show:!1},itemStyle:{borderWidth:2,borderColor:n.palette.background.default,borderRadius:4},emphasis:{itemStyle:{borderWidth:2,borderColor:We[200],color:"inherit"}}}}),[l,t,n]);return e.jsxs(e.Fragment,{children:[e.jsx(S,{ref:i,sx:{maxWidth:"1280px",border:"1px solid",borderColor:"divider",padding:"8px",overflowX:"auto"},children:e.jsx(S,{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:c=>{c.componentType==="series"&&c.data&&r(c.data[0])}}})})}),e.jsx(S,{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(S,{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(S,{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(S,{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 Mt=xe(({className:t,...o})=>e.jsx(ge,{...o,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function ve({status:t,message:o="",createdAt:a}){const{t:s}=E(),i=t===I.BACKUPS.STATUS.PROGRESS&&D().diff(a,"hours")>=I.BACKUPS.TIMEOUT_HOURS,n=i&&s("common.timeoutError"),r=t===I.BACKUPS.STATUS.PROGRESS&&!i,l=t===I.BACKUPS.STATUS.SUCCEEDED&&!i;return r?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(A,{sx:{marginRight:"4px"},size:"12px"}),s("common.progress")]}):l?e.jsx(q,{type:"success",children:s("common.succeeded")}):e.jsxs(S,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"error",children:s("common.failed")}),e.jsx(ge,{style:{display:"flex",alignItems:"center",flexShrink:0},title:o||n,children:e.jsx(be,{children:e.jsx(Fe,{style:{width:"24px",height:"24px"},color:"error"})})})]})}ve.propTypes={status:u.string.isRequired,message:u.string,createdAt:u.string.isRequired};function ze({metadata:t={}}){const{t:o}=E();if(H(t))return e.jsx(q,{type:"success",children:o("common.succeeded")});const a=t.count||0,s=t.size||0,i=nt(s,{iec:!0}),n=e.jsxs(S,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:[e.jsxs(j,{variant:"body2",children:[o("common.fileCount"),": ",a]}),e.jsxs(j,{variant:"body2",children:[o("common.fileSize"),": ",i]})]});return e.jsxs(S,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"success",children:o("common.succeeded")}),e.jsx(Mt,{title:n,style:{display:"flex",alignItems:"center",flexShrink:0},placement:"left",children:e.jsx(be,{children:e.jsx(Ke,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}ze.propTypes={metadata:u.object};function Ae(){const{t,locale:o}=E(),{spaceGateways:a,backups:s,backupsLoading:i}=U(),n=h.useMemo(()=>[{label:"DID Space",name:"target",options:{customBodyRenderLite:l=>{const{targetUrl:d,targetName:c,status:m,createdAt:g}=s[l],f=m===I.BACKUPS.STATUS.PROGRESS&&D().diff(g,"hours")>=I.BACKUPS.TIMEOUT_HOURS,p=m===I.BACKUPS.STATUS.SUCCEEDED&&!f,k=c||a.find(w=>d?.includes(fe(w?.endpoint)))?.name||"Unknown DID Space";return p?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:l=>{const d=t(l===0?"common.auto":"common.manual");return e.jsx(q,{children:d})}}},{label:t("common.startTime"),name:"createdAt",options:{customBodyRender:l=>D(l).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.endTime"),name:"updatedAt",options:{customBodyRender:l=>H(l)?"":D(l).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:l=>{const d=s?.[l]??{},{status:c,message:m,createdAt:g,metadata:f}=d,p=c===I.BACKUPS.STATUS.PROGRESS&&D().diff(g,"hours")>=I.BACKUPS.TIMEOUT_HOURS,k=c===I.BACKUPS.STATUS.PROGRESS&&!p,w=c===I.BACKUPS.STATUS.SUCCEEDED&&!p;return k?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(A,{sx:{marginRight:"4px"},size:"12px"}),t("common.progress")]}):w?e.jsx(ze,{metadata:f}):e.jsx(ve,{status:c,message:m,createdAt:g})}}}],[s,a,t]),r=h.useMemo(()=>!s?.length,[s]);return e.jsx(e.Fragment,{children:r?e.jsx(S,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px",color:"#9397A1",marginTop:"16px",marginBottom:"24px"},children:t("storage.spaces.record.emptyData")}):e.jsx(it,{title:"",loading:i,data:s,columns:n,emptyNode:t("storage.spaces.record.emptyData",o),options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}})})}function Nt(){const{t}=E();return e.jsxs(S,{children:[e.jsxs(S,{sx:{display:"flex",gap:3,flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(S,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",minWidth:240},children:[e.jsx(ot,{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(S,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(S,{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(Pe,{})]})]}),e.jsx(Ae,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2,mt:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function Oe({spaceGateway:t,onConfirm:o=()=>{},onCancel:a=()=>{}}){const{t:s}=E(),[i,n]=h.useState(!1),[r,l]=h.useState(!1),d=(g,f)=>{g?.preventDefault(),g?.stopPropagation(),n(f)},c=async g=>{try{g?.stopPropagation(),l(!0),await o?.(t),n(!1)}catch(f){console.error(f),B.error(`${s("storage.space.gateway.delete.failed")}: ${Q(f)}`)}finally{n(!1),l(!1)}},m=g=>{d(g,!1),a?.(g)};return e.jsxs(e.Fragment,{children:[e.jsxs(F,{color:"red",onClick:g=>d(g,!0),children:[e.jsx(Y,{style:{minWidth:24,color:"red"},children:e.jsx(Ye,{fontSize:"small"})}),e.jsx($,{style:{color:"red"},children:s("common.disconnect")})]}),e.jsx(ct,{title:s("storage.spaces.gateway.delete.title"),open:i,confirmButton:{text:s("common.confirm"),props:{size:"small",variant:"contained",color:"error",loading:r}},cancelButton:{text:s("common.cancel"),props:{size:"small",variant:"outlined",disabled:r}},onConfirm:c,onCancel:m,children:e.jsx(j,{sx:{wordWrap:"break-word"},children:s("storage.spaces.gateway.delete.descForBackup",{name:`${t?.name}`})})})]})}Oe.propTypes={spaceGateway:u.shape({name:u.string.isRequired,url:u.string.isRequired,protected:u.bool}).isRequired,onConfirm:u.func,onCancel:u.func};function Ue({spaceGateway:t,selected:o,onDelete:a=()=>{},onConnect:s=()=>{},enableSwitchToSpace:i=!0,backupInProgress:n=!1,...r}){const{abortBlockletBackup:l}=U(),[d,c]=h.useState(null),{t:m}=E(),[g,f]=h.useState(!1),p=(y,b)=>{y.stopPropagation(),y.preventDefault(),c(b&&y.currentTarget)},k=async y=>{try{f(!0),p(y,!1),await s(t)}catch(b){console.error(b),B.error(b.message)}finally{f(!1)}},w=async y=>{try{f(!0),p(y,!1),await l()}catch(b){console.error(b),B.error(b.message)}finally{f(!1)}};return e.jsxs(e.Fragment,{children:[g||t?.loading?e.jsx(A,{sx:{ml:1},size:"24px"}):e.jsx($e,{"aria-label":"more","aria-controls":"actions-menu","aria-haspopup":"true","data-cy":"trigger-blocklet-actions",variant:"outlined",size:"small",onClick:y=>p(y,!0),...r,children:e.jsx(qe,{})}),e.jsxs(He,{id:"simple-menu",anchorEl:d,keepMounted:!0,open:!!d,onClose:y=>p(y,!1),children:[e.jsxs(F,{onClick:y=>{p(y,!1),window.open(Se(t.endpoint?wt(t.endpoint):t.url,{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Qe,{fontSize:"small"})}),e.jsx($,{children:m("common.open")})]}),e.jsxs(F,{onClick:y=>{p(y,!1),window.open(Se(Bt(t.endpoint),{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Je,{fontSize:"small"})}),e.jsx($,{children:m("storage.spaces.strategy.viewBackupFiles")})]}),!o&&i&&e.jsxs(F,{onClick:k,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Ve,{fontSize:"small"})}),e.jsx($,{children:m("storage.spaces.connect.switchToSpace")})]}),n&&e.jsxs(F,{onClick:w,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Xe,{fontSize:"small"})}),e.jsx($,{children:m("storage.spaces.connect.abortBlockletBackup")})]}),!n&&e.jsx(Oe,{spaceGateway:t,onConfirm:async()=>{c(null),await a?.(t)},onCancel:()=>c(null)})]})]})}Ue.propTypes={spaceGateway:u.shape({name:u.string.isRequired,url:u.string.isRequired,protected:u.bool,endpoint:u.string.isRequired,loading:u.bool}).isRequired,selected:u.bool.isRequired,enableSwitchToSpace:u.bool,onDelete:u.func,onConnect:u.func,backupInProgress:u.bool};const _t=xe(({className:t,...o})=>e.jsx(ge,{...o,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Le({spaceGateway:t,spaceStatus:o,selected:a,onConnected:s=()=>{},onDeleted:i=()=>{},onBackedUp:n=()=>{}}){const{t:r,locale:l}=E(),{blocklet:d}=O(),{api:c,info:{did:m}}=N(),{appDid:g,appName:f,appDescription:p,scopes:k,appUrl:w,referrer:y}=Be({blocklet:d}),{backupProgress:b,updateSpaceGateway:Z,deleteSpaceGateway:ee,refreshBackupSummary:te,refreshBackups:se}=U(),[_,L]=h.useState(!1),[T,P]=h.useState({open:!1,action:"one-click-authorization",checkTimeout:1e3*300,messages:{title:r("storage.spaces.authorize.title",{appName:f},l),scan:r("storage.spaces.authorize.scan",{appName:f},l),confirm:"",success:e.jsx(j,{gutterBottom:!0,children:r("storage.spaces.authorize.success")})},onClose:()=>{P(C=>({...C,open:!1}))}}),ne=a&&!_&&o===le.DISCONNECTED,oe=a&&!_&&!t.loading&&o===le.CONNECTED,K=a&&_&&o===le.CONNECTED&&b?.progress>=0,J=async()=>{try{if(await Dt(t?.endpoint)){await c.configBlocklet({input:{did:[d.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:t.endpoint}]}}),B.success(r("storage.spaces.connect.switchToSpaceSucceeded",{name:t.name?`(${t.name})`:""})),s?.(null,t);return}}catch(C){console.error(C),s?.(C,t);return}P(C=>({...C,open:!0,prefix:me(t.url,"space/api/did"),baseUrl:new URL(t.url).origin,checkFn:we.create({baseURL:me(t.url,"space")}).get,extraParams:{appDid:g,appName:f,appDescription:p,scopes:k,appUrl:w,referrer:y,nodeDid:m,spaceDid:t.did}}))},ae=async(C,x)=>{const z=x(C.endpoint),R=fe(z),v=C.space?x(C.space):{};if(t.did&&R!==t.did){P(Me=>({...Me,open:!1}));const W=r("storage.spaces.gateway.switch.failedForMismatchSpace",{name:v?.name?v.name:""});B.error(W),s?.(new Error(W),t);return}const ce={...t,name:v.name??"DID Space",did:v.did??fe(z),endpoint:z};await Z(ce),P(W=>({...W,open:!1})),s?.(null,ce)},re=async()=>{try{if(_)return;L(!0),await c.backupBlocklet({input:{appDid:d.appDid,to:"spaces"}})}catch(C){console.error(C),B.error(C.message),n?.(C,t)}finally{L(!0)}},ie=async()=>{try{await ee(t),B.success(r("storage.spaces.gateway.delete.succeeded",{name:t.name?`(${t.name})`:""})),i?.(null,t)}catch(C){console.error(C),i?.(C,t)}};return h.useEffect(()=>{b?.completed?(a&&(b?.progress===100?(B.success(r("storage.spaces.backupSuccessfully")),n?.(null,t)):b.message&&n?.(new Error(b?.message),t),b.progress=0,b.message=""),L(!1),setTimeout(()=>{te(),se()},1e3)):b.progress&&L(!0)},[b]),e.jsxs(e.Fragment,{children:[e.jsxs(S,{sx:{display:"flex",alignItems:"center",".action-btn":{borderRadius:1,marginLeft:1}},children:[oe&&e.jsx(de,{className:"action-btn",variant:"outlined",size:"small",onClick:re,children:r("storage.spaces.strategy.backupNow")}),ne&&e.jsx(de,{className:"action-btn",variant:"outlined",size:"small",onClick:J,children:r("storage.spaces.disconnected.reconnectNow")}),K&&e.jsx(_t,{title:b?.message&&e.jsx(S,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:e.jsx(j,{variant:"body2",children:b.message})}),children:e.jsxs(de,{className:"action-btn",variant:"outlined",size:"small",sx:{minWidth:70},children:[e.jsx(A,{variant:"determinate",value:b?.progress,size:14,sx:{mr:1}}),b?.progress,"%"]})}),e.jsx(lt,{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:l},"get-endpoint")]}),e.jsx(Ue,{sx:{minWidth:32,padding:"2px 4px",ml:1},spaceGateway:t,selected:a,onDelete:ie,onConnect:J,enableSwitchToSpace:b?.completed||H(b?.message),backupInProgress:K})]})}Le.propTypes={spaceGateway:u.shape({did:u.string.isRequired,name:u.string.isRequired,url:u.string.isRequired,endpoint:u.string.isRequired,protected:u.bool,loading:u.bool}).isRequired,spaceStatus:u.string.isRequired,selected:u.bool.isRequired,onConnected:u.func,onDeleted:u.func,onBackedUp:u.func};function Wt({...t}){const{t:o}=E();return e.jsxs(S,{...t,children:[e.jsx(S,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:o("storage.spaces.backup.records")})}),e.jsx(Pe,{}),e.jsx(Ae,{})]})}function Gt({...t}){const{t:o}=E(),{autoBackup:a,updateAutoBackup:s}=U(),i=async()=>{try{const n=!a?.enabled;await s({enabled:n}),B.success(o(n?"storage.spaces.autoBackup.enabled":"storage.spaces.autoBackup.disabled"))}catch(n){B.error(n.message)}};return e.jsx(It,{checked:!!a?.enabled,onChange:i,name:"enableWelcomePage",labelProps:{label:e.jsx(j,{sx:{marginRight:"8px"},children:e.jsx("span",{children:o("storage.spaces.autoBackup.title")})})},style:{...t.style}})}function Kt(){const{t}=E(),{spaceGateways:o,spaceGatewaysLoading:a,spaceGatewayIsSelected:s}=U(),i=a&&!o?.length,n=({spaceGateway:r,spaceStatus:l,selected:d,refresh:c})=>e.jsx(Le,{spaceGateway:r,spaceStatus:l,selected:d,onConnected:()=>c(),onBackedUp:m=>m&&c()});return e.jsxs(S,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(S,{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(S,{sx:{mt:2},children:i?e.jsx(S,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(A,{})}):e.jsx(he,{container:!0,spacing:2,children:e.jsx(e.Fragment,{children:o.map(r=>e.jsx(he,{size:{xs:12,md:6},children:e.jsx(at,{endpoint:r.endpoint,selected:s(r),action:n},r.endpoint)},r.endpoint))})})}),e.jsx(Wt,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function Ft(){const{spaceGatewaysFirstLoading:t,spaceGateways:o}=U();return t?e.jsx(je,{relative:"parent",children:e.jsx(A,{})}):H(o)?e.jsx(Nt,{}):e.jsx(Kt,{})}function Yt(){return e.jsx(Te,{children:e.jsx(Ft,{})})}function $t(){const{spaceGateway:t,settingStorageEndpoint:o,updateSpaceGateway:a,hasStorageEndpoint:s,loading:i,storageEndpoint:n}=Pt(),r=ue(()=>({display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"16px"}));return i?e.jsx(je,{relative:"parent",children:e.jsx(A,{})}):e.jsxs(S,{sx:{maxWidth:"md",position:"relative"},children:[s?e.jsx(ht,{spaceGateway:t,settingStorageEndpoint:o}):e.jsx(St,{}),e.jsx(S,{sx:r,children:e.jsx(yt,{onConnect:a,storageEndpoint:n})})]})}function qt(){const{t}=E();return e.jsxs(Rt,{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 Ht({navOrientation:t="vertical",...o}){const{t:a,locale:s}=E(),{blocklet:i}=O(),n=ft({key:"md"}),[r,l]=et(),d=r.get("tab")||"backup",c=n?"horizontal":t,m=ue(()=>{const w=[{label:a("common.backup"),value:"backup"}],y=i?.capabilities?.didSpace;return(y===M.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED||y===M.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP)&&w.push({label:a("common.storage"),value:"storage"}),w},[s,c]),f=ue(()=>({backup:e.jsx(Yt,{}),storage:e.jsx(qt,{})}))[d],p=w=>{l(y=>(w==="backup"?y.delete("tab"):y.set("tab",w),y))};if(m.length<=1)return e.jsx(pe,{children:f});const k=e.jsx(dt,{tabs:m,current:d,orientation:c,onChange:p,sx:[{borderRight:1,height:"100%",borderColor:"divider"},c==="horizontal"&&{borderRight:0}]});if(c==="vertical")return e.jsx(S,{...o,children:e.jsxs(G,{direction:{md:"column",lg:"row"},sx:{gap:2},children:[e.jsx(S,{sx:{flexShrink:0},children:e.jsx(ye,{left:k})}),e.jsx(S,{sx:{flexGrow:1,minWidth:0},children:e.jsx(pe,{sx:{mt:1},children:f})})]})});if(c==="horizontal")return e.jsxs(S,{...o,children:[e.jsx(ye,{left:k}),e.jsx(pe,{sx:{mt:2},children:f})]})}Ht.propTypes={navOrientation:u.oneOf(["vertical","horizontal"])};const pe=xe(S)`
1
+ import{j as e,$ as u,p as O,T as j,at as Ne,J as _e,cI as V,ao as X,cJ as We,ak as S,b1 as K,a$ as Ke,s as xe,cK as be,cy as Ge,am as ge,cu as Fe,M as F,aO as Y,bR as Ye,aP as $,V as $e,bl as qe,aR as He,cL as Qe,cM as Je,cN as Ve,cO as Xe,bY as he}from"./vendor-mui-core-Bz-X9hX7.js";import{k as Ze,j as ke,f as ue}from"./vendor-hooks-CFpNP5Ql.js";import{r as h,u as et}from"./vendor-react-x2lQvn4m.js";import{Y as z,_ as N,ad as D,M,aC as tt,aD as st,au as nt,c as I,$ as ot}from"./index-BpP1Znfh.js";import{H as B,T as E,b as at,a0 as q,D as rt,J as it,n as le,j as ct}from"./vendor-ux-D2yvD18l.js";import{u as lt}from"./use-mobile-BkNZycG6.js";import{a as H,d as je,a1 as dt,e as pt,D as Ce,C as me}from"./vendor-utils-Vke2d2wu.js";import{o as we}from"./vendor-arcblock-Cvkavi6C.js";import{b as ut,u as mt,D as ft,c as de,a as xt}from"./index-QJUPJwU5.js";import"./index-DnIF_NYU.js";import"./index-BojVbZw0.js";import"./api-B7LEhzE2.js";import{u as Be,C as gt,D as ht,a as St}from"./connect-to-DFUayzYa.js";import{b as yt,c as bt,d as kt,i as jt,e as fe,f as Ct,h as wt,j as Bt}from"./spaces-BaVWWOGx.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-CF0F1TwU.js";import{E as Et}from"./index-DbIUA2zH.js";import{x as Tt}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-DeteK1Tn.js";import{S as It}from"./switch-control-gGb7roLA.js";import{C as Rt,u as Pt}from"./config-space-BJHf-Cd6.js";import{L as ye}from"./list-header-Bcr2R_3c.js";import"./lottie-web-4koyQiv_.js";import"./index-BwLbaIOO.js";async function At({blockletDid:t,nodeApi:o,spaceGateways:a}){let s=!1;const i=await Promise.all(a.map(async n=>{let{name:r}=n;const l=await yt(n.endpoint);return!H(l)&&l!==r&&(r=l,s=!0),{...n,name:r}}));return s&&await Promise.all(i.filter(n=>n.did).map(n=>o.updateBlockletSpaceGateway({input:{did:t,where:{did:n.did},spaceGateway:{...n}}}))),i}function vt({refresh:t}={}){const{blocklet:o}=z(),a=o?.meta?.did,{api:s}=N();return Ze(async()=>{if(!a)return[];const{spaceGateways:i}=await s.getBlockletSpaceGateways({input:{did:a}});return await At({blockletDid:a,nodeApi:s,spaceGateways:i})??[]},{refreshDeps:[a,t],onError(i){i?.message?.includes("not logged")?console.warn(i):(console.error(i),B.error(Q(i)))}})}function De({deps:t,setLoading:o,backupDate:a}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=z(),[i,n]=h.useState([]),{api:r}=N(),[l,d]=h.useMemo(()=>a?[D(a).startOf("day").toISOString(),D(a).endOf("day").toISOString()]:[D().startOf("year").toISOString(),D().endOf("day").toISOString()],[a]),c=je(async()=>{try{if(o(!0),!s){n([]);return}const{backups:m}=await r.getBlockletBackups({input:{did:s.meta.did,startTime:l,endTime:d}});n(m??[])}catch(m){console.error(m),B.error(Q(m))}finally{o(!1)}},1e3);return ke(async()=>{c()},[s?.meta?.did].concat(t)),{backups:i}}function Ot({appDid:t}){const{backups:o}=De(),[a,s]=h.useState({message:"",progress:0,completed:!1}),i=N(),{ws:{useSubscription:n}}=i;return n(M.BlockletEvents.backupProgress,r=>{t===r?.appDid&&s(()=>({...r}))},[t]),h.useEffect(()=>{if(o?.length&&dt(o[0]?.status)){const[r]=o;s(()=>({message:r.message,progress:r.progress,completed:r.progress>=100}))}},[o]),a}function zt({deps:t=[],setLoading:o=()=>{}}={}){const{blocklet:a}=z(),[s,i]=h.useState([]),{api:n}=N(),r=h.useCallback(je(async()=>{if(!n||!a?.meta?.did){i([]);return}try{o(!0);const l=D(),d=l.subtract(1,"year"),{summary:c}=await n.getBlockletBackupSummary({input:{did:a.meta.did,startTime:d.toISOString(),endTime:l.toISOString()}});i(Array.isArray(c)?c:[])}catch(l){console.error("Failed to fetch backup summary:",l),B.error(Q(l)),i([])}finally{o(!1)}},1e3),[]);return ke(async()=>(await r(),()=>{r.cancel()}),[a?.meta?.did].concat(t)),{backupSummary:s}}const Ee=h.createContext({}),{Provider:Lt,Consumer:ys}=Ee;function Te({children:t}){const{t:o}=E(),{api:a}=N(),{blocklet:s}=z(),[i,n]=h.useState(null),[r,l]=h.useState(!1),{data:d,loading:c,mutate:m}=vt({refresh:r}),g=pt(d),f=Ot({appDid:s?.appDid}),p=h.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=h.useState(!1),[y,b]=h.useState(!1),{backups:Z}=De({deps:[y,i],setLoading:w,backupDate:i}),[ee,te]=h.useState(!1),{backupSummary:se}=zt({deps:[ee]}),[_,U]=h.useState(d?.find(x=>x.endpoint===p)),T=s?.settings?.autoBackup,P=()=>{l(x=>!x)},ne=()=>{te(x=>!x)},oe=()=>{b(x=>!x)},G=async x=>{await a.updateAutoBackup({input:{did:s.meta.did,autoBackup:x}})},J=async()=>{await a.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(x,v)=>{try{m(R=>{const A=[...R];return A.push({...x,loading:!0}),A}),await a.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:x}}),p!==v&&await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:v}]}}),U(x),P(),B.success(o("storage.spaces.connectedWithName",{name:x?.name??"DID Spaces"}))}catch(R){throw console.error(R),m(A=>[...A].filter(W=>W.did!==x.did)),R}},re=async x=>{x&&(x.endpoint===p&&(await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),T?.enabled&&await G({enabled:!1})),await a.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:x?.did}}),m(v=>{const R=[...v];return R.splice(R.indexOf(x),1),R}),U(x),P())},ie=async x=>{await Promise.all([a.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:x.did},spaceGateway:x}}),p!==x.endpoint&&a.configBlocklet({input:{did:[s.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:x.endpoint}]}})]),B.success(o("storage.spaces.connectedWithName",{name:x?.name??"DID Spaces"})),P()},C=x=>x?.endpoint===p;return e.jsx(Lt,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:P,spaceGatewaysLoading:c,spaceGatewaysFirstLoading:g,spaceGatewayIsSelected:C,updateAutoBackup:G,abortBlockletBackup:J,backupEndpoint:p,backupProgress:f,backups:Z,backupSummary:se,refreshBackupSummary:ne,refreshBackups:oe,setBackupDate:n,backupsLoading:k,autoBackup:T},children:t})}Te.propTypes={children:u.any.isRequired};function L(){return h.useContext(Ee)}function Ie({...t}){const{blocklet:o}=z(),{info:a}=N(),{t:s}=E(),i=Be({blocklet:o}),n=tt(a),{spaceGateways:r,addSpaceGateway:l}=L(),d={checkFn:Ce.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:n,extraParams:{appPid:o.appPid,appDid:i.appDid,appName:i.appName,appDescription:i.appDescription,appUrl:i.appUrl,referrer:i.referrer,scopes:i.scopes,nodeDid:a.did}},c=async({endpoint:g,name:f,did:p})=>{const k=await kt(g);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(r.some(b=>b.endpoint===g)){B.error(s("storage.spaces.gateway.add.duplicate",{name:f}));return}await l({name:f,did:p,url:k,endpoint:g},g)},m=async({spaceGateway:g})=>{try{await c(g)}catch(f){console.error(f),B.error(Q(f))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:m})}function Re({...t}){const{t:o}=h.useContext(at),{blocklet:a,loadingDiskInfo:s,actions:i}=z();if(h.useEffect(()=>{i?.refreshBlocklet({showError:!1,attachDiskInfo:!0})},[]),a.diskInfo){const n=(d,c,m)=>e.jsxs(j,{children:[d," ",e.jsx("strong",{children:c?nt(c):"empty"})]}),r=a.environments.reduce((d,c)=>(d[c.key]=c.value,d),{}),l=[{key:"appDir",name:o("blocklet.diskInfo.appDir"),value:n(r.BLOCKLET_APP_DIR,a.diskInfo.app)},{key:"dataDir",name:o("blocklet.diskInfo.dataDir"),value:n(r.BLOCKLET_DATA_DIR,a.diskInfo.data)},{key:"logDir",name:o("blocklet.diskInfo.logDir"),value:n(r.BLOCKLET_LOG_DIR,a.diskInfo.log)},{key:"cacheDir",name:o("blocklet.diskInfo.cacheDir"),value:n(r.BLOCKLET_CACHE_DIR,a.diskInfo.cache)}];return e.jsx(Ut,{component:"div",...t,children:l.map(d=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:d.name,children:d.value},d.key))})}return s?e.jsx(O,{}):e.jsx(j,{children:o("blocklet.diskInfo.empty")})}const Ut=Ne(j)``;function Pe(){const{t}=E(),{setBackupDate:o,backupSummary:a}=L(),s=mt({key:"lg"}),i=h.useRef(null),n=_e(),r=h.useCallback(c=>{o(c)},[o]),l=h.useMemo(()=>{const c=D().add(1,"day"),m=D().subtract(11,"month").startOf("month"),g=new Map(a.map(p=>[p.date,{date:p.date,successCount:p.successCount,errorCount:p.errorCount}])),f=[];for(let p=m.clone();D(p).isBefore(c);p=p.add(1,"day")){const k=p.format("YYYY-MM-DD");f.push(g.get(k)||{date:k,successCount:0,errorCount:0})}return f},[a]),d=h.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:y,errorCount:b}=l[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${y}</div>`,`<div>${t("common.failed")}: ${b}</div>`].join(`
2
+ `)},backgroundColor:n.palette.background.paper,borderColor:n.palette.divider,textStyle:{color:n.palette.text.primary,fontSize:14},extraCssText:`box-shadow: ${n.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:n.palette.grey[200]},{min:1,max:3,color:X[300]},{min:3,max:6,color:X[400]},{min:6,max:9,color:X[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:X[600]}],orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:12,textStyle:{color:n.palette.text.secondary,fontSize:12}},calendar:{top:30,left:50,right:10,bottom:4,cellSize:[8,8],splitLine:{show:!1},itemStyle:{borderWidth:2,borderColor:n.palette.background.default,color:n.palette.background.default},dayLabel:{show:!0,firstDay:0,nameMap:["","Mon","","Wed","","Fri",""],position:"start",margin:4,fontSize:10,color:n.palette.text.primary,fontWeight:"400",width:20},monthLabel:{show:!0,nameMap:"cn",align:"left",color:n.palette.text.primary,fontWeight:"400",fontSize:12,position:"start",margin:4,width:30,padding:[0,2]},yearLabel:{show:!1},range:[D().subtract(11,"month").startOf("month").format("YYYY-MM-DD"),D().endOf("month").format("YYYY-MM-DD")],orient:"horizontal"},series:{type:"heatmap",coordinateSystem:"calendar",data:l.map(k=>[k.date,k.errorCount?-k.errorCount:k.successCount]),label:{show:!1},itemStyle:{borderWidth:2,borderColor:n.palette.background.default,borderRadius:4},emphasis:{itemStyle:{borderWidth:2,borderColor:We[200],color:"inherit"}}}}),[l,t,n]);return e.jsxs(e.Fragment,{children:[e.jsx(S,{ref:i,sx:{maxWidth:"1280px",border:"1px solid",borderColor:"divider",padding:"8px",overflowX:"auto"},children:e.jsx(S,{sx:{width:"1200px",height:"180px",position:"relative"},children:e.jsx(Et,{option:d,style:{height:"100%",width:"100%"},notMerge:!0,lazyUpdate:!1,opts:{renderer:"canvas"},onEvents:{click:c=>{c.componentType==="series"&&c.data&&r(c.data[0])}}})})}),e.jsx(S,{sx:{display:"flex",justifyContent:"flex-end",mt:1,mr:s?2:5,mb:2},children:e.jsxs(K,{direction:s?"column":"row",spacing:s?2:1,sx:{width:"100%",justifyContent:"flex-start",alignItems:s?"flex-start":"center"},children:[e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(S,{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(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(S,{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(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(S,{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 Mt=xe(({className:t,...o})=>e.jsx(ge,{...o,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Ae({status:t,message:o="",createdAt:a}){const{t:s}=E(),i=t===I.BACKUPS.STATUS.PROGRESS&&D().diff(a,"hours")>=I.BACKUPS.TIMEOUT_HOURS,n=i&&s("common.timeoutError"),r=t===I.BACKUPS.STATUS.PROGRESS&&!i,l=t===I.BACKUPS.STATUS.SUCCEEDED&&!i;return r?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(O,{sx:{marginRight:"4px"},size:"12px"}),s("common.progress")]}):l?e.jsx(q,{type:"success",children:s("common.succeeded")}):e.jsxs(S,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"error",children:s("common.failed")}),e.jsx(ge,{style:{display:"flex",alignItems:"center",flexShrink:0},title:o||n,children:e.jsx(be,{children:e.jsx(Fe,{style:{width:"24px",height:"24px"},color:"error"})})})]})}Ae.propTypes={status:u.string.isRequired,message:u.string,createdAt:u.string.isRequired};function ve({metadata:t={}}){const{t:o}=E();if(H(t))return e.jsx(q,{type:"success",children:o("common.succeeded")});const a=t.count||0,s=t.size||0,i=Tt(s,{iec:!0}),n=e.jsxs(S,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:[e.jsxs(j,{variant:"body2",children:[o("common.fileCount"),": ",a]}),e.jsxs(j,{variant:"body2",children:[o("common.fileSize"),": ",i]})]});return e.jsxs(S,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"success",children:o("common.succeeded")}),e.jsx(Mt,{title:n,style:{display:"flex",alignItems:"center",flexShrink:0},placement:"left",children:e.jsx(be,{children:e.jsx(Ge,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}ve.propTypes={metadata:u.object};function Oe(){const{t,locale:o}=E(),{spaceGateways:a,backups:s,backupsLoading:i}=L(),n=h.useMemo(()=>[{label:"DID Space",name:"target",options:{customBodyRenderLite:l=>{const{targetUrl:d,targetName:c,status:m,createdAt:g}=s[l],f=m===I.BACKUPS.STATUS.PROGRESS&&D().diff(g,"hours")>=I.BACKUPS.TIMEOUT_HOURS,p=m===I.BACKUPS.STATUS.SUCCEEDED&&!f,k=c||a.find(w=>d?.includes(fe(w?.endpoint)))?.name||"Unknown DID Space";return p?e.jsx(Ke,{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:l=>{const d=t(l===0?"common.auto":"common.manual");return e.jsx(q,{children:d})}}},{label:t("common.startTime"),name:"createdAt",options:{customBodyRender:l=>D(l).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.endTime"),name:"updatedAt",options:{customBodyRender:l=>H(l)?"":D(l).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:l=>{const d=s?.[l]??{},{status:c,message:m,createdAt:g,metadata:f}=d,p=c===I.BACKUPS.STATUS.PROGRESS&&D().diff(g,"hours")>=I.BACKUPS.TIMEOUT_HOURS,k=c===I.BACKUPS.STATUS.PROGRESS&&!p,w=c===I.BACKUPS.STATUS.SUCCEEDED&&!p;return k?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(O,{sx:{marginRight:"4px"},size:"12px"}),t("common.progress")]}):w?e.jsx(ve,{metadata:f}):e.jsx(Ae,{status:c,message:m,createdAt:g})}}}],[s,a,t]),r=h.useMemo(()=>!s?.length,[s]);return e.jsx(e.Fragment,{children:r?e.jsx(S,{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:i,data:s,columns:n,emptyNode:t("storage.spaces.record.emptyData",o),options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}})})}function Nt(){const{t}=E();return e.jsxs(S,{children:[e.jsxs(S,{sx:{display:"flex",gap:3,flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(S,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",minWidth:240},children:[e.jsx(ft,{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(S,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(S,{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(Pe,{})]})]}),e.jsx(Oe,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2,mt:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function ze({spaceGateway:t,onConfirm:o=()=>{},onCancel:a=()=>{}}){const{t:s}=E(),[i,n]=h.useState(!1),[r,l]=h.useState(!1),d=(g,f)=>{g?.preventDefault(),g?.stopPropagation(),n(f)},c=async g=>{try{g?.stopPropagation(),l(!0),await o?.(t),n(!1)}catch(f){console.error(f),B.error(`${s("storage.space.gateway.delete.failed")}: ${Q(f)}`)}finally{n(!1),l(!1)}},m=g=>{d(g,!1),a?.(g)};return e.jsxs(e.Fragment,{children:[e.jsxs(F,{color:"red",onClick:g=>d(g,!0),children:[e.jsx(Y,{style:{minWidth:24,color:"red"},children:e.jsx(Ye,{fontSize:"small"})}),e.jsx($,{style:{color:"red"},children:s("common.disconnect")})]}),e.jsx(it,{title:s("storage.spaces.gateway.delete.title"),open:i,confirmButton:{text:s("common.confirm"),props:{size:"small",variant:"contained",color:"error",loading:r}},cancelButton:{text:s("common.cancel"),props:{size:"small",variant:"outlined",disabled:r}},onConfirm:c,onCancel:m,children:e.jsx(j,{sx:{wordWrap:"break-word"},children:s("storage.spaces.gateway.delete.descForBackup",{name:`${t?.name}`})})})]})}ze.propTypes={spaceGateway:u.shape({name:u.string.isRequired,url:u.string.isRequired,protected:u.bool}).isRequired,onConfirm:u.func,onCancel:u.func};function Le({spaceGateway:t,selected:o,onDelete:a=()=>{},onConnect:s=()=>{},enableSwitchToSpace:i=!0,backupInProgress:n=!1,...r}){const{abortBlockletBackup:l}=L(),[d,c]=h.useState(null),{t:m}=E(),[g,f]=h.useState(!1),p=(y,b)=>{y.stopPropagation(),y.preventDefault(),c(b&&y.currentTarget)},k=async y=>{try{f(!0),p(y,!1),await s(t)}catch(b){console.error(b),B.error(b.message)}finally{f(!1)}},w=async y=>{try{f(!0),p(y,!1),await l()}catch(b){console.error(b),B.error(b.message)}finally{f(!1)}};return e.jsxs(e.Fragment,{children:[g||t?.loading?e.jsx(O,{sx:{ml:1},size:"24px"}):e.jsx($e,{"aria-label":"more","aria-controls":"actions-menu","aria-haspopup":"true","data-cy":"trigger-blocklet-actions",variant:"outlined",size:"small",onClick:y=>p(y,!0),...r,children:e.jsx(qe,{})}),e.jsxs(He,{id:"simple-menu",anchorEl:d,keepMounted:!0,open:!!d,onClose:y=>p(y,!1),children:[e.jsxs(F,{onClick:y=>{p(y,!1),window.open(Se(t.endpoint?Ct(t.endpoint):t.url,{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Qe,{fontSize:"small"})}),e.jsx($,{children:m("common.open")})]}),e.jsxs(F,{onClick:y=>{p(y,!1),window.open(Se(wt(t.endpoint),{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Je,{fontSize:"small"})}),e.jsx($,{children:m("storage.spaces.strategy.viewBackupFiles")})]}),!o&&i&&e.jsxs(F,{onClick:k,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Ve,{fontSize:"small"})}),e.jsx($,{children:m("storage.spaces.connect.switchToSpace")})]}),n&&e.jsxs(F,{onClick:w,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Xe,{fontSize:"small"})}),e.jsx($,{children:m("storage.spaces.connect.abortBlockletBackup")})]}),!n&&e.jsx(ze,{spaceGateway:t,onConfirm:async()=>{c(null),await a?.(t)},onCancel:()=>c(null)})]})]})}Le.propTypes={spaceGateway:u.shape({name:u.string.isRequired,url:u.string.isRequired,protected:u.bool,endpoint:u.string.isRequired,loading:u.bool}).isRequired,selected:u.bool.isRequired,enableSwitchToSpace:u.bool,onDelete:u.func,onConnect:u.func,backupInProgress:u.bool};const _t=xe(({className:t,...o})=>e.jsx(ge,{...o,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:o,selected:a,onConnected:s=()=>{},onDeleted:i=()=>{},onBackedUp:n=()=>{}}){const{t:r,locale:l}=E(),{blocklet:d}=z(),{api:c,info:{did:m}}=N(),{appDid:g,appName:f,appDescription:p,scopes:k,appUrl:w,referrer:y}=Be({blocklet:d}),{backupProgress:b,updateSpaceGateway:Z,deleteSpaceGateway:ee,refreshBackupSummary:te,refreshBackups:se}=L(),[_,U]=h.useState(!1),[T,P]=h.useState({open:!1,action:"one-click-authorization",checkTimeout:1e3*300,messages:{title:r("storage.spaces.authorize.title",{appName:f},l),scan:r("storage.spaces.authorize.scan",{appName:f},l),confirm:"",success:e.jsx(j,{gutterBottom:!0,children:r("storage.spaces.authorize.success")})},onClose:()=>{P(C=>({...C,open:!1}))}}),ne=a&&!_&&o===de.DISCONNECTED,oe=a&&!_&&!t.loading&&o===de.CONNECTED,G=a&&_&&o===de.CONNECTED&&b?.progress>=0,J=async()=>{try{if(await Bt(t?.endpoint)){await c.configBlocklet({input:{did:[d.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:t.endpoint}]}}),B.success(r("storage.spaces.connect.switchToSpaceSucceeded",{name:t.name?`(${t.name})`:""})),s?.(null,t);return}}catch(C){console.error(C),s?.(C,t);return}P(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:g,appName:f,appDescription:p,scopes:k,appUrl:w,referrer:y,nodeDid:m,spaceDid:t.did}}))},ae=async(C,x)=>{const v=x(C.endpoint),R=fe(v),A=C.space?x(C.space):{};if(t.did&&R!==t.did){P(Me=>({...Me,open:!1}));const W=r("storage.spaces.gateway.switch.failedForMismatchSpace",{name:A?.name?A.name:""});B.error(W),s?.(new Error(W),t);return}const ce={...t,name:A.name??"DID Space",did:A.did??fe(v),endpoint:v};await Z(ce),P(W=>({...W,open:!1})),s?.(null,ce)},re=async()=>{try{if(_)return;U(!0),await c.backupBlocklet({input:{appDid:d.appDid,to:"spaces"}})}catch(C){console.error(C),B.error(C.message),n?.(C,t)}finally{U(!0)}},ie=async()=>{try{await ee(t),B.success(r("storage.spaces.gateway.delete.succeeded",{name:t.name?`(${t.name})`:""})),i?.(null,t)}catch(C){console.error(C),i?.(C,t)}};return h.useEffect(()=>{b?.completed?(a&&(b?.progress===100?(B.success(r("storage.spaces.backupSuccessfully")),n?.(null,t)):b.message&&n?.(new Error(b?.message),t),b.progress=0,b.message=""),U(!1),setTimeout(()=>{te(),se()},1e3)):b.progress&&U(!0)},[b]),e.jsxs(e.Fragment,{children:[e.jsxs(S,{sx:{display:"flex",alignItems:"center",".action-btn":{borderRadius:1,marginLeft:1}},children:[oe&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:re,children:r("storage.spaces.strategy.backupNow")}),ne&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:J,children:r("storage.spaces.disconnected.reconnectNow")}),G&&e.jsx(_t,{title:b?.message&&e.jsx(S,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:e.jsx(j,{variant:"body2",children:b.message})}),children:e.jsxs(le,{className:"action-btn",variant:"outlined",size:"small",sx:{minWidth:70},children:[e.jsx(O,{variant:"determinate",value:b?.progress,size:14,sx:{mr:1}}),b?.progress,"%"]})}),e.jsx(ot,{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:l},"get-endpoint")]}),e.jsx(Le,{sx:{minWidth:32,padding:"2px 4px",ml:1},spaceGateway:t,selected:a,onDelete:ie,onConnect:J,enableSwitchToSpace:b?.completed||H(b?.message),backupInProgress:G})]})}Ue.propTypes={spaceGateway:u.shape({did:u.string.isRequired,name:u.string.isRequired,url:u.string.isRequired,endpoint:u.string.isRequired,protected:u.bool,loading:u.bool}).isRequired,spaceStatus:u.string.isRequired,selected:u.bool.isRequired,onConnected:u.func,onDeleted:u.func,onBackedUp:u.func};function Wt({...t}){const{t:o}=E();return e.jsxs(S,{...t,children:[e.jsx(S,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:o("storage.spaces.backup.records")})}),e.jsx(Pe,{}),e.jsx(Oe,{})]})}function Kt({...t}){const{t:o}=E(),{autoBackup:a,updateAutoBackup:s}=L(),i=async()=>{try{const n=!a?.enabled;await s({enabled:n}),B.success(o(n?"storage.spaces.autoBackup.enabled":"storage.spaces.autoBackup.disabled"))}catch(n){B.error(n.message)}};return e.jsx(It,{checked:!!a?.enabled,onChange:i,name:"enableWelcomePage",labelProps:{label:e.jsx(j,{sx:{marginRight:"8px"},children:e.jsx("span",{children:o("storage.spaces.autoBackup.title")})})},style:{...t.style}})}function Gt(){const{t}=E(),{spaceGateways:o,spaceGatewaysLoading:a,spaceGatewayIsSelected:s}=L(),i=a&&!o?.length,n=({spaceGateway:r,spaceStatus:l,selected:d,refresh:c})=>e.jsx(Ue,{spaceGateway:r,spaceStatus:l,selected:d,onConnected:()=>c(),onBackedUp:m=>m&&c()});return e.jsxs(S,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(S,{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(Kt,{}),e.jsx(Ie,{})]}),e.jsx(S,{sx:{mt:2},children:i?e.jsx(S,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(O,{})}):e.jsx(he,{container:!0,spacing:2,children:e.jsx(e.Fragment,{children:o.map(r=>e.jsx(he,{size:{xs:12,md:6},children:e.jsx(xt,{endpoint:r.endpoint,selected:s(r),action:n},r.endpoint)},r.endpoint))})})}),e.jsx(Wt,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function Ft(){const{spaceGatewaysFirstLoading:t,spaceGateways:o}=L();return t?e.jsx(we,{relative:"parent",children:e.jsx(O,{})}):H(o)?e.jsx(Nt,{}):e.jsx(Gt,{})}function Yt(){return e.jsx(Te,{children:e.jsx(Ft,{})})}function $t(){const{spaceGateway:t,settingStorageEndpoint:o,updateSpaceGateway:a,hasStorageEndpoint:s,loading:i,storageEndpoint:n}=Pt(),r=ue(()=>({display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"16px"}));return i?e.jsx(we,{relative:"parent",children:e.jsx(O,{})}):e.jsxs(S,{sx:{maxWidth:"md",position:"relative"},children:[s?e.jsx(gt,{spaceGateway:t,settingStorageEndpoint:o}):e.jsx(ht,{}),e.jsx(S,{sx:r,children:e.jsx(St,{onConnect:a,storageEndpoint:n})})]})}function qt(){const{t}=E();return e.jsxs(Rt,{children:[e.jsxs(K,{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 Ht({navOrientation:t="vertical",...o}){const{t:a,locale:s}=E(),{blocklet:i}=z(),n=lt({key:"md"}),[r,l]=et(),d=r.get("tab")||"backup",c=n?"horizontal":t,m=ue(()=>{const w=[{label:a("common.backup"),value:"backup"}],y=i?.capabilities?.didSpace;return(y===M.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED||y===M.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP)&&w.push({label:a("common.storage"),value:"storage"}),w},[s,c]),f=ue(()=>({backup:e.jsx(Yt,{}),storage:e.jsx(qt,{})}))[d],p=w=>{l(y=>(w==="backup"?y.delete("tab"):y.set("tab",w),y))};if(m.length<=1)return e.jsx(pe,{children:f});const k=e.jsx(ct,{tabs:m,current:d,orientation:c,onChange:p,sx:[{borderRight:1,height:"100%",borderColor:"divider"},c==="horizontal"&&{borderRight:0}]});if(c==="vertical")return e.jsx(S,{...o,children:e.jsxs(K,{direction:{md:"column",lg:"row"},sx:{gap:2},children:[e.jsx(S,{sx:{flexShrink:0},children:e.jsx(ye,{left:k})}),e.jsx(S,{sx:{flexGrow:1,minWidth:0},children:e.jsx(pe,{sx:{mt:1},children:f})})]})});if(c==="horizontal")return e.jsxs(S,{...o,children:[e.jsx(ye,{left:k}),e.jsx(pe,{sx:{mt:2},children:f})]})}Ht.propTypes={navOrientation:u.oneOf(["vertical","horizontal"])};const pe=xe(S)`
3
3
  position: relative;
4
4
  min-height: 66vh;
5
5
  overflow: hidden;
@@ -1 +1 @@
1
- import{d as A,v as R,p as w,e as p}from"./index-DareKNWL.js";const O=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,x=/^[a-zA-Z]:\\/;function N(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return x.test(e)?!1:O.test(e)}const _=["http","https"],z=["nofollow"],L={};function T(e){const r=e||L,g=r.protocols||_,u=A(r.test);return function(h){R(h,"element",function(t,y,E){if(t.tagName==="a"&&typeof t.properties.href=="string"&&u(t,y,E)){const o=t.properties.href;if(N(o)?g.includes(o.slice(0,o.indexOf(":"))):o.startsWith("//")){const n=s(r.content,t),c=n&&!Array.isArray(n)?[n]:n,i=s(r.rel,t)||z,a=typeof i=="string"?w(i):i,f=s(r.target,t),l=s(r.properties,t);if(l&&Object.assign(t.properties,p(l)),a.length>0&&(t.properties.rel=[...a]),f&&(t.properties.target=f),c){const m=s(r.contentProperties,t)||{};t.children.push({type:"element",tagName:"span",properties:p(m),children:p(c)})}}}})}}function s(e,r){return typeof e=="function"?e(r):e}export{T as r};
1
+ import{c as A,v as R,p as w,s as p}from"./index-Dcvh9y_X.js";const O=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,x=/^[a-zA-Z]:\\/;function N(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return x.test(e)?!1:O.test(e)}const _=["http","https"],z=["nofollow"],L={};function T(e){const r=e||L,g=r.protocols||_,u=A(r.test);return function(h){R(h,"element",function(t,y,E){if(t.tagName==="a"&&typeof t.properties.href=="string"&&u(t,y,E)){const o=t.properties.href;if(N(o)?g.includes(o.slice(0,o.indexOf(":"))):o.startsWith("//")){const n=s(r.content,t),c=n&&!Array.isArray(n)?[n]:n,i=s(r.rel,t)||z,a=typeof i=="string"?w(i):i,f=s(r.target,t),l=s(r.properties,t);if(l&&Object.assign(t.properties,p(l)),a.length>0&&(t.properties.rel=[...a]),f&&(t.properties.target=f),c){const m=s(r.contentProperties,t)||{};t.children.push({type:"element",tagName:"span",properties:p(m),children:p(c)})}}}})}}function s(e,r){return typeof e=="function"?e(r):e}export{T as r};