@abtnode/blocklet-services 1.16.49-beta-20250819-084933-3bcbd851 → 1.16.49-beta-20250822-070545-6d3344cc

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 (245) hide show
  1. package/api/libs/connect/session.js +4 -4
  2. package/api/routes/env.js +0 -1
  3. package/api/services/analytics/index.js +8 -5
  4. package/api/services/auth/connect/connect-to-did-spaces-for-user.js +5 -5
  5. package/api/services/auth/connect/migrate-app-to-struct-v2.js +1 -1
  6. package/api/state/profile.js +1 -1
  7. package/api/util/blocklet-utils.js +2 -2
  8. package/dist/assets/{AdapterDayjs-DQyL5DVQ.js → AdapterDayjs-VDBijwaM.js} +1 -1
  9. package/dist/assets/{Google-C3EYOLRU.js → Google-Sm1AunGv.js} +1 -1
  10. package/dist/assets/{access-control-CuUB1GoU.js → access-control-VF0jIUag.js} +1 -1
  11. package/dist/assets/{actions-DnpJX6lQ.js → actions-Bf4UKTeu.js} +1 -1
  12. package/dist/assets/{add-component-core-JXDWXmkX.js → add-component-core-DPxKUwJB.js} +7 -7
  13. package/dist/assets/add-resource-DuOqQFR-.js +1 -0
  14. package/dist/assets/{addon-D99FdIJX.js → addon-CosTdlat.js} +1 -1
  15. package/dist/assets/{advanced-CGlqr3Vl.js → advanced-B9TR0x_M.js} +2 -2
  16. package/dist/assets/{aigne-DceTN7Rt.js → aigne-C7JPp9u1.js} +1 -1
  17. package/dist/assets/api-IUmhrtIY.js +1 -0
  18. package/dist/assets/{appearance-fnwZybsp.js → appearance-Byekpih2.js} +1 -1
  19. package/dist/assets/{ar-B5ZCU4Ws.js → ar-fE5SSTrt.js} +1 -1
  20. package/dist/assets/{arrow-down.svg-BcoTeNyX.js → arrow-down.svg-lBR1lfm2.js} +1 -1
  21. package/dist/assets/{audit-logs-Dzq32Y_L.js → audit-logs-BTyQcfWp.js} +2 -2
  22. package/dist/assets/authorize-BbCQomqp.js +1 -0
  23. package/dist/assets/{base-chart-CBzZ3RX9.js → base-chart-DZz4r8-E.js} +1 -1
  24. package/dist/assets/base32-D7JDMggs.js +1 -0
  25. package/dist/assets/bind-account-B-fdpRuH.js +1 -0
  26. package/dist/assets/{branding-BgclUoWJ.js → branding-Bp4tsvug.js} +5 -5
  27. package/dist/assets/branding-CXO5C9Lb.js +1 -0
  28. package/dist/assets/{branding-g04aJopG.js → branding-DKOBu_eV.js} +2 -2
  29. package/dist/assets/{bundle-avatar-VT8FLC3N.js → bundle-avatar-FLzOZWlh.js} +1 -1
  30. package/dist/assets/button-DEDR-8Tu.js +1 -0
  31. package/dist/assets/{click-to-copy-LMYjlbUz.js → click-to-copy-CVpUD4ji.js} +1 -1
  32. package/dist/assets/{cloneDeep-KmDjD-jP.js → cloneDeep-DqaMBldf.js} +1 -1
  33. package/dist/assets/{collapse-XWrflTSv.js → collapse-C-BNkgS6.js} +1 -1
  34. package/dist/assets/{complete-BnL-RLHX.js → complete-CnjLDP7N.js} +2 -2
  35. package/dist/assets/{component-B20Ffd5t.js → component-Dogt0tzj.js} +3 -3
  36. package/dist/assets/{config-DRsQLuMp.js → config-B5Y8LOpp.js} +3 -3
  37. package/dist/assets/{config-BV0yp1Ym.js → config-BxiVjVAu.js} +1 -1
  38. package/dist/assets/{config-CJHA8pSh.js → config-gL555Qh4.js} +2 -2
  39. package/dist/assets/{config-navigation-CR3DV4xf.js → config-navigation-CveewaP3.js} +11 -11
  40. package/dist/assets/{config-space-BzTYceTE.js → config-space-h6V3UKMc.js} +1 -1
  41. package/dist/assets/confirm-C9tgdTJT.js +7 -0
  42. package/dist/assets/{connect-Dvl9nMFJ.js → connect-CYT-S8fi.js} +1 -1
  43. package/dist/assets/{connect-BaSUwW0G.js → connect-Cx2VNYgu.js} +1 -1
  44. package/dist/assets/connect-to-DiEQlFbF.js +1 -0
  45. package/dist/assets/{content-layout-yAb710pQ.js → content-layout-DoBqUAz1.js} +1 -1
  46. package/dist/assets/createClass-D9kGlylC.js +1 -0
  47. package/dist/assets/{dashboard-CuNuXf3l.js → dashboard-D1d9MQbs.js} +6 -6
  48. package/dist/assets/{de-Bt2QRaGQ.js → de-Byq6SyWJ.js} +1 -1
  49. package/dist/assets/{delete-confirm-DTjAa9xG.js → delete-confirm-XVeEePxy.js} +1 -1
  50. package/dist/assets/{did-address-CY4nLJqm.js → did-address-CcsL3-Qm.js} +1 -1
  51. package/dist/assets/{domain-C8-oT2Wp.js → domain-CV6OAKYE.js} +1 -1
  52. package/dist/assets/domain-action-card-BXYZu_pS.js +28 -0
  53. package/dist/assets/domains-DrF1lJas.js +1 -0
  54. package/dist/assets/{email-BXcDoVMA.js → email-CniDyVLQ.js} +3 -3
  55. package/dist/assets/{empty-spinner-CvzdEO93.js → empty-spinner-BMVhld2Z.js} +1 -1
  56. package/dist/assets/engine-hsJUTQxh.js +1 -0
  57. package/dist/assets/{es-RcHRYKIM.js → es-Q8J1CCMS.js} +1 -1
  58. package/dist/assets/{exchange-passport-BJ2cvp1M.js → exchange-passport-BnNDAYeY.js} +1 -1
  59. package/dist/assets/{form-Df41zlMi.js → form-BndJ7ZnS.js} +2 -2
  60. package/dist/assets/{form-text-input-DHhw6HI1.js → form-text-input-DJPCEDjA.js} +1 -1
  61. package/dist/assets/{form-wrapper-DihET07L.js → form-wrapper-CHYdE4By.js} +1 -1
  62. package/dist/assets/{fr-CQKeqjRX.js → fr-8njRrvuV.js} +1 -1
  63. package/dist/assets/{fuel-D_lR2dCI.js → fuel-BTh7B67H.js} +1 -1
  64. package/dist/assets/gen-access-key-CbaepD9-.js +1 -0
  65. package/dist/assets/gen-simple-access-key-mJK0zx1B.js +1 -0
  66. package/dist/assets/get-safe-url-Bpq2IOGY.js +1 -0
  67. package/dist/assets/hdkey-BpKJbkt5.js +62 -0
  68. package/dist/assets/hi-JUTdfcRr.js +5 -0
  69. package/dist/assets/{home-YcebrtVr.js → home-BwLLSjzW.js} +1 -1
  70. package/dist/assets/{id-B2v2gNB3.js → id-CrtgRPeX.js} +1 -1
  71. package/dist/assets/iframe-CbjzikLk.js +1 -0
  72. package/dist/assets/index-0VNYJQln.js +271 -0
  73. package/dist/assets/{index-COzISRvj.js → index-B5t6TkeL.js} +9 -9
  74. package/dist/assets/{index-Pzk7QDI_.js → index-B9sHaKla.js} +1 -1
  75. package/dist/assets/{index-I45i29I1.js → index-BFQdM_lT.js} +1 -1
  76. package/dist/assets/index-BH6jQqKY.js +55 -0
  77. package/dist/assets/{index-C2CNlq3a.js → index-BIfpX-Mq.js} +1 -1
  78. package/dist/assets/index-BKiTWpo1.js +6 -0
  79. package/dist/assets/{index-DtDUB9t6.js → index-BY2dcTa4.js} +1 -1
  80. package/dist/assets/{index-yRvJst1p.js → index-Bk02VaQE.js} +10 -10
  81. package/dist/assets/index-BtHQU9Nx.js +30 -0
  82. package/dist/assets/{index-BbOvyzfE.js → index-BtkFo6d6.js} +1 -1
  83. package/dist/assets/{index-BusluHY3.js → index-BxU3q403.js} +12 -12
  84. package/dist/assets/{index-CV12n3b0.js → index-Bzij4iIk.js} +1 -1
  85. package/dist/assets/{index-DYgvuymH.js → index-C-DpXzH8.js} +1 -1
  86. package/dist/assets/index-C4e0bu4c.js +124 -0
  87. package/dist/assets/{index-Bx4IaUHc.js → index-Ca4b_pCt.js} +6 -6
  88. package/dist/assets/{index-Bv7qQ-8a.js → index-Cd2DJL-w.js} +1 -1
  89. package/dist/assets/index-CjfYhb8W.js +1 -0
  90. package/dist/assets/index-CuQBOJqN.js +1022 -0
  91. package/dist/assets/index-DEu06Btv.js +1 -0
  92. package/dist/assets/index-DQmcrxe_.js +1 -0
  93. package/dist/assets/{index-DHaiY3PI.js → index-DT3k66ox.js} +1 -1
  94. package/dist/assets/{index-BNm1HXpF.js → index-DzSOofQf.js} +11 -11
  95. package/dist/assets/{index-CX5AEYFR.js → index-DzqNo2lD.js} +1 -1
  96. package/dist/assets/index-JixySlIT.js +7 -0
  97. package/dist/assets/{index-DeQPqRmy.js → index-SbRD4xbu.js} +2 -2
  98. package/dist/assets/{index-D4wH7CER.js → index-ew1if2W6.js} +6 -6
  99. package/dist/assets/index-hXRVhE3g.js +113 -0
  100. package/dist/assets/{index-DQ3_Wuxe.js → index-pAv7g5o_.js} +1 -1
  101. package/dist/assets/{index-Q_U4JZ73.js → index-yi4PlkyH.js} +1 -1
  102. package/dist/assets/{invitation-Cic0zA9s.js → invitation-CsvJMPo7.js} +3 -3
  103. package/dist/assets/{invite-EVcEzrIF.js → invite-DEEX5t_7.js} +1 -1
  104. package/dist/assets/{isURL-BZcSl4qG.js → isURL-Cuto2_sB.js} +2 -2
  105. package/dist/assets/{issue-passport-B3O3mNxG.js → issue-passport-BuT9-mlQ.js} +1 -1
  106. package/dist/assets/{item-BJ_EimT6.js → item-CEYjCEHD.js} +1 -1
  107. package/dist/assets/{ja-BweNHYYv.js → ja-BDFhRccP.js} +1 -1
  108. package/dist/assets/{ko-BrUV9qyv.js → ko-Dde62QRb.js} +1 -1
  109. package/dist/assets/landing-page-CbZO5p-X.js +1 -0
  110. package/dist/assets/{launch-result-message-CFuQ3Maq.js → launch-result-message-BhJWVXUs.js} +1 -1
  111. package/dist/assets/{layout-DTue3JyF.js → layout-BOMMbsdq.js} +1 -1
  112. package/dist/assets/list-CIIZmkmF.js +4 -0
  113. package/dist/assets/list-CcfeNfGu.js +103 -0
  114. package/dist/assets/{list-header-bAafK8zK.js → list-header-BQx81X9X.js} +1 -1
  115. package/dist/assets/localization-DNJagVoT.js +1 -0
  116. package/dist/assets/{log-DiR01oV7.js → log-CHaoSWXc.js} +1 -1
  117. package/dist/assets/logger-yrkSQn8c.js +1 -0
  118. package/dist/assets/login-C0FSm4ep.js +1 -0
  119. package/dist/assets/{login-oauth-callback-D2Bc3xAH.js → login-oauth-callback-DJxlMwXZ.js} +1 -1
  120. package/dist/assets/{logo-uploader-BayOewpo.js → logo-uploader-C0ihL7E6.js} +2 -2
  121. package/dist/assets/{lost-passport-flvvhlNS.js → lost-passport-BoAvHfI_.js} +2 -2
  122. package/dist/assets/{observability-DUV9CYIA.js → observability-F2NkCkza.js} +1 -1
  123. package/dist/assets/{omit-DdJriebF.js → omit-BM-5z5qE.js} +1 -1
  124. package/dist/assets/{open-window-Cj2XU2ZE.js → open-window-BNY_OfK6.js} +1 -1
  125. package/dist/assets/{over-due-invoice-payment-DveCusKe.js → over-due-invoice-payment-DXbfRbJ6.js} +1 -1
  126. package/dist/assets/{overview-BCygf-5_.js → overview-DpF1loGs.js} +2 -2
  127. package/dist/assets/{page-header-BtdOLX8d.js → page-header-CSMnIoYZ.js} +1 -1
  128. package/dist/assets/passport-item-VXkf3FVk.js +1 -0
  129. package/dist/assets/{permission-BPBzp1tm.js → permission-DeQz9qFD.js} +1 -1
  130. package/dist/assets/{playground-Doy13-fN.js → playground-CTvnZW2L.js} +1 -1
  131. package/dist/assets/preferences-C7TivEto.js +1 -0
  132. package/dist/assets/profile-embed-Dzt59MHT.js +1 -0
  133. package/dist/assets/pt-C4nfuExm.js +5 -0
  134. package/dist/assets/publish-resource-BSY6p0as.js +1 -0
  135. package/dist/assets/{react-beautiful-dnd.esm-DR1a-vn2.js → react-beautiful-dnd.esm-CYy644iX.js} +1 -1
  136. package/dist/assets/{react-stripe.esm-DJ2wjb7C.js → react-stripe.esm-CLg1-THR.js} +1 -1
  137. package/dist/assets/{required-2qxcR9JF.js → required-CobBjKC9.js} +1 -1
  138. package/dist/assets/ru-B4GtNlEa.js +5 -0
  139. package/dist/assets/runtime-B01d8fEk.js +1 -0
  140. package/dist/assets/{sanitize-t-NsAK4g.js → sanitize-NVxeYIWy.js} +1 -1
  141. package/dist/assets/sdk-ZTxfQBV1.js +1 -0
  142. package/dist/assets/{section-D4T7FV6C.js → section-Dq8SB7lh.js} +1 -1
  143. package/dist/assets/{security-BAcM8QUq.js → security-sVehajDA.js} +3 -3
  144. package/dist/assets/session-Bk6ebojT.js +1 -0
  145. package/dist/assets/{setup-Cs_D4O1K.js → setup-B9yaqoQM.js} +1 -1
  146. package/dist/assets/{shorten-label-BfHH-3ih.js → shorten-label-BHlFrl9P.js} +1 -1
  147. package/dist/assets/{simple-select-DIgPQFb4.js → simple-select-rm53gQ69.js} +1 -1
  148. package/dist/assets/{spaces-CU7Gi53i.js → spaces-HwfT17d7.js} +1 -1
  149. package/dist/assets/{start-Ds4Of13F.js → start-4J_Dh_zH.js} +1 -1
  150. package/dist/assets/{starting-progress-BTMrLOch.js → starting-progress-mgdXXqlr.js} +1 -1
  151. package/dist/assets/status-B1AV3yPH.js +1 -0
  152. package/dist/assets/{step-actions-DDyCXELh.js → step-actions-YjxSTbIE.js} +1 -1
  153. package/dist/assets/{studio-CYLOXolI.js → studio-Cx6j_6QU.js} +1 -1
  154. package/dist/assets/{switch-control-CAUrltdD.js → switch-control-BR8H_fdm.js} +1 -1
  155. package/dist/assets/{table-tips-BNjmTVFL.js → table-tips-BP283GGZ.js} +1 -1
  156. package/dist/assets/team-Dl23XmaY.js +146 -0
  157. package/dist/assets/th-BkShd6jD.js +5 -0
  158. package/dist/assets/traffic-O-wVx65-.js +1 -0
  159. package/dist/assets/{transfer-2ba_g--R.js → transfer-gEq9B27K.js} +1 -1
  160. package/dist/assets/{unsubscribe-B0KWDak0.js → unsubscribe-vpGsla5T.js} +1 -1
  161. package/dist/assets/{use-app-logo-pyV6ZPrc.js → use-app-logo-7cjs_pn8.js} +1 -1
  162. package/dist/assets/{use-mobile-BcHeqFSk.js → use-mobile-C_DcJ5SZ.js} +1 -1
  163. package/dist/assets/{use-mobile-BmKySh5X.js → use-mobile-DM4d_PLd.js} +1 -1
  164. package/dist/assets/{use-server-logo-CFQEMdB-.js → use-server-logo-Cxah39TH.js} +1 -1
  165. package/dist/assets/{use-window-close-PwuafSt8.js → use-window-close-DpgRKaaP.js} +1 -1
  166. package/dist/assets/{useAsync-BrjQTmBf.js → useAsync-BrMo9m7W.js} +1 -1
  167. package/dist/assets/{useAsync-C0iFIKqR.js → useAsync-CsYRBczg.js} +1 -1
  168. package/dist/assets/{useAsyncRetry-BmdG-NgH.js → useAsyncRetry-D4-sRZN-.js} +1 -1
  169. package/dist/assets/useLocalStorage-DqhgzGNT.js +1 -0
  170. package/dist/assets/user-center-DtJ32yjF.js +126 -0
  171. package/dist/assets/user-sessions-CFxn5EHL.js +1 -0
  172. package/dist/assets/{util-Dceeaiqy.js → util-Ca2jlZN4.js} +1 -1
  173. package/dist/assets/{util-BW0qhGTg.js → util-o8U4JIlX.js} +1 -1
  174. package/dist/assets/{vendor-arcblock-D_Dm09bZ.js → vendor-arcblock-B7AoUs4o.js} +139 -138
  175. package/dist/assets/{vendor-hooks-9cd36rYd.js → vendor-hooks-BRXKH6Nb.js} +1 -1
  176. package/dist/assets/{vendor-mui-core-DV92LEhm.js → vendor-mui-core-B7zoO8f5.js} +1 -1
  177. package/dist/assets/{vendor-mui-x-8McV6Pkb.js → vendor-mui-x-Qph0dQcg.js} +1 -1
  178. package/dist/assets/vendor-utils-DtY42AM-.js +213 -0
  179. package/dist/assets/{vendor-ux-C9Q7otQi.js → vendor-ux-B7q8W4Pg.js} +11 -11
  180. package/dist/assets/vi-C1PSP5SP.js +5 -0
  181. package/dist/assets/{wait-connect-CZLL86-A.js → wait-connect-DPAxcgcf.js} +1 -1
  182. package/dist/assets/{wizard-B45wL4-0.js → wizard-072KuoFQ.js} +1 -1
  183. package/dist/assets/{wizard-components-DtebwiYw.js → wizard-components-Dx5C9E35.js} +3 -3
  184. package/dist/assets/wrap-locale-BQM6_LkP.js +1 -0
  185. package/dist/assets/{zh-DBSThusI.js → zh-C_fDhC3R.js} +1 -1
  186. package/dist/assets/{zh-BaEjqGHy.js → zh-gAK37O_Y.js} +2 -2
  187. package/dist/assets/{zh-tw-xcyHbP3V.js → zh-tw-BGfyObps.js} +2 -2
  188. package/dist/index.html +6 -6
  189. package/dist/service-worker.js +1 -1
  190. package/package.json +33 -33
  191. package/dist/assets/add-resource-DfcJCfFx.js +0 -1
  192. package/dist/assets/api-ZbpPN5Q9.js +0 -1
  193. package/dist/assets/authorize-Cp-IEkvY.js +0 -1
  194. package/dist/assets/base32-rvunYmjt.js +0 -1
  195. package/dist/assets/bind-account-DWpWB9oY.js +0 -1
  196. package/dist/assets/branding-C1Ia1UuG.js +0 -1
  197. package/dist/assets/button-DTxgdpBB.js +0 -1
  198. package/dist/assets/confirm-DTV46cI2.js +0 -7
  199. package/dist/assets/connect-to-DqRnkSJR.js +0 -1
  200. package/dist/assets/createClass-BMZZ4tvt.js +0 -1
  201. package/dist/assets/domain-action-card-CEOtRquC.js +0 -28
  202. package/dist/assets/domains-UcvU4SNI.js +0 -1
  203. package/dist/assets/engine-D80vWtQO.js +0 -1
  204. package/dist/assets/gen-access-key-CceVm9CK.js +0 -1
  205. package/dist/assets/gen-simple-access-key-DBtfSm_M.js +0 -1
  206. package/dist/assets/get-safe-url-C-ga6boD.js +0 -1
  207. package/dist/assets/hi-C3FQ6j4Z.js +0 -5
  208. package/dist/assets/iframe-yWzH7Y70.js +0 -1
  209. package/dist/assets/index-9RuhtmiE.js +0 -7
  210. package/dist/assets/index-B8oq6zxb.js +0 -1
  211. package/dist/assets/index-BPLFlpyZ.js +0 -1
  212. package/dist/assets/index-Bpx_SHfH.js +0 -124
  213. package/dist/assets/index-BwWh6qt0.js +0 -113
  214. package/dist/assets/index-CBuBVmWe.js +0 -1020
  215. package/dist/assets/index-CJ69vsWG.js +0 -271
  216. package/dist/assets/index-DMpO3u1o.js +0 -29
  217. package/dist/assets/index-DTwsbX7O.js +0 -55
  218. package/dist/assets/index-Dib9OV0s.js +0 -6
  219. package/dist/assets/index-GUfN0pBe.js +0 -62
  220. package/dist/assets/index-OkiS9ggb.js +0 -1
  221. package/dist/assets/landing-page-CEwZuo6C.js +0 -1
  222. package/dist/assets/list-DFvUHI6u.js +0 -103
  223. package/dist/assets/list-DKV7bt8d.js +0 -2
  224. package/dist/assets/localization-BAcpaWtp.js +0 -1
  225. package/dist/assets/logger-__gJZTBC.js +0 -1
  226. package/dist/assets/login-DcV8dmSg.js +0 -1
  227. package/dist/assets/passport-item-Bej8KfmX.js +0 -1
  228. package/dist/assets/preferences-f1ltD9jG.js +0 -1
  229. package/dist/assets/profile-embed-DKKNp824.js +0 -1
  230. package/dist/assets/pt-DopXhOk4.js +0 -5
  231. package/dist/assets/publish-resource-Ce_uMtZk.js +0 -1
  232. package/dist/assets/ru-pXOMfITZ.js +0 -5
  233. package/dist/assets/runtime-EaR7CQWh.js +0 -1
  234. package/dist/assets/sdk-D0Pm334j.js +0 -1
  235. package/dist/assets/session-DW40g2df.js +0 -1
  236. package/dist/assets/status-D4MGFqcv.js +0 -1
  237. package/dist/assets/team-C8yfeoct.js +0 -146
  238. package/dist/assets/th-Dt7avnjd.js +0 -5
  239. package/dist/assets/traffic-BjVQYor-.js +0 -1
  240. package/dist/assets/useLocalStorage-BRaJWH_j.js +0 -1
  241. package/dist/assets/user-center-V4qQZYhM.js +0 -126
  242. package/dist/assets/user-sessions-DYh09QrL.js +0 -1
  243. package/dist/assets/vendor-utils-CddrUZ58.js +0 -213
  244. package/dist/assets/vi-BbB_zl6_.js +0 -5
  245. package/dist/assets/wrap-locale-FkxlVw29.js +0 -1
@@ -1,7 +0,0 @@
1
- import{T as M,H as q,J as N,k as Y,I as ve,L as Ce,Z as Se}from"./vendor-ux-C9Q7otQi.js";import{s as Te,k as le,t as Ie}from"./vendor-hooks-9cd36rYd.js";import{r as E,a as ae}from"./vendor-react-Dvs43sk9.js";import{j as e,Y as Re,bB as We,$ as ze,ak as p,z as ne,T as C,a6 as F,aX as te,R as De,Q as H,b6 as se,am as P,bd as _,a5 as J,V as Z,S as G,b4 as Oe,U as L,I as B,cm as Ae,bf as Pe,a7 as $e,F as qe,W as t,b1 as R,a3 as ce,c1 as ee,cn as Le,aO as Me,aP as Be,co as Fe,cp as He,cq as Ne,s as oe,aU as Ue,aj as _e,J as Ke,cr as Ve,aZ as Ye,cg as Je,c9 as Qe,cf as Xe}from"./vendor-mui-core-DV92LEhm.js";import{B as de,a as pe,l as ue}from"./index-CX5AEYFR.js";import{Y as K,c as xe,an as Ze,a7 as Ge,b5 as Q}from"./index-CBuBVmWe.js";import{u as V}from"./team-C8yfeoct.js";import{u as et}from"./use-mobile-BcHeqFSk.js";import{u as tt,C as X}from"./index.esm-JPZAjt0x.js";import{C as he,a as me,J as ot}from"./vendor-utils-CddrUZ58.js";import{C as nt}from"./confirm-DTV46cI2.js";import{A as st}from"./actions-DnpJX6lQ.js";import{T as ie}from"./table-tips-BNjmTVFL.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-D_Dm09bZ.js";import"./session-DW40g2df.js";import"./isURL-BZcSl4qG.js";import"./use-app-logo-pyV6ZPrc.js";import"./index-DBs9Ljax.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 s={};return Object.entries(i).forEach(([a,{events:m}])=>{const v=m.filter(S=>u[`${S.type}-${S.source}`]).length;s[a]=v}),s},[i,u]),l=E.useMemo(()=>Object.values(j).reduce((s,a)=>s+a,0),[j]),f=E.useMemo(()=>Object.values(i).reduce((s,{events:a})=>s+a.length,0),[i]),g=(s,a)=>{a.stopPropagation(),x({...w,[s]:!w[s]})},y=s=>{const a=`${s.type}-${s.source}`;c(m=>({...m,[a]:!m[a]}))},z=(s,a)=>{const m={};s.forEach(v=>{const S=`${v.type}-${v.source}`;m[S]=!a}),c(v=>({...v,...m}))},T=s=>{const a={};Object.values(i).forEach(({events:m})=>{m.forEach(v=>{const S=`${v.type}-${v.source}`;a[S]=s.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(se,{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(P,{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(Z,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:"4px"},children:Object.entries(i).map(([s,{source:a,events:m,count:v}],S)=>{const D=j[s]>0,I=j[s]===m.length&&m.length>0,O=w[s];return e.jsxs(ae.Fragment,{children:[e.jsx(G,{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(s,o)},children:[e.jsx(p,{sx:{display:"flex",alignItems:"center"},children:m.length>0&&e.jsx(se,{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||s}),D&&e.jsx(L,{label:r("webhookEndpoint.selectedCount",{count:j[s]}),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(Ae,{}):e.jsx(Pe,{})})]})]})}),m.length>0&&e.jsx($e,{in:O,timeout:"auto",unmountOnExit:!0,children:e.jsx(Z,{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}`,n=!!u[d];return e.jsx(G,{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:n,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)})})})]},s)})})}),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}=V(),{api:g}=K(),{loading:y,error:z,eventsBySource:T}=it(),{control:s,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]),n={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:n}});q.success(`${x("webhookEndpoint.updateWebhook")} ${x("webhookEndpoint.success")}`),r(h)}else{const h=await g.createWebhookEndpoint({input:{teamDid:f,input:n}});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(X,{name:"url",control:s,rules:{required:x("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:x("webhookEndpoint.validation.urlInvalid")}},render:({field:o})=>e.jsx(ne,{...o,label:x("webhookEndpoint.url.label"),fullWidth:!0,error:!!m.url,helperText:m.url?.message})}),e.jsx(X,{name:"description",control:s,rules:{required:x("webhookEndpoint.validation.descriptionRequired")},render:({field:o})=>e.jsx(ne,{...o,label:x("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!m.description,helperText:m.description?.message})}),e.jsx(X,{name:"selectedEvents",control:s,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?Ze(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 A({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(P,{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})]})}A.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}}=K(),{t:w}=M(),{teamDid:x}=V(),{blocklet:j}=Ge(),{data:l,loadMore:f,loadingMore:g,loading:y,mutate:z}=Te(n=>{const k=n?Math.ceil(n.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||[],[s,a]=E.useState(null),[m,v]=E.useState(!1),S=dt(T);if(E.useEffect(()=>{!s&&l?.list.length&&a(l.list[0])},[l?.list.length,s]),r(xe.EVENTS.WEBHOOK_ATTEMPT,n=>{z(h=>{if(h.list.find(W=>W.id===n.id)){const W=h.list.map($=>$.id===n.id?{...$,...n}:$);return{...h,list:W}}return n.endpoint=h.list[0]?.endpoint,n.event=h.list[0]?.event,{...h,list:[n,...h.list]}})},[]),y)return e.jsx(F,{});const D=l&&l.list.length<l.paging.total,I=async()=>{s&&(v(!0),await b.retryWebhookAttempt({input:{teamDid:x,eventId:s.event.id,webhookId:u,attemptId:s.id}}).finally(()=>{setTimeout(()=>{v(!1)},1e3)}))},O=n=>{if(n.responseBody&&n.responseBody?.sessionId&&n.responseBody?.projectId&&n.responseBody?.agentId){const h=j?.site?.domainAliases[0]?.value,k=(j.children||[]).find($=>$?.meta?.name==="ai-studio"),W=ot(he(`https://${h}`,k?.mountPoint||"","projects",n.responseBody.projectId,"logs/main"),{sessionId:n.responseBody.sessionId,agentId:n.responseBody.agentId});return e.jsx(B,{sx:{fontSize:20},onClick:()=>window.open(W,"_blank"),children:e.jsx(p,{component:N,icon:Q})})}return null},o=n=>n.status==="pending"?e.jsx(Fe,{color:"warning"}):at(n.responseStatus)?e.jsx(He,{color:"success"}):e.jsx(Ne,{color:"error"}),d=s?.triggeredFrom&&(l?.list||[]).find(n=>n.id===s.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(Z,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(S).map(([n,h])=>e.jsxs(ae.Fragment,{children:[e.jsx(Le,{sx:{p:0},children:n}),h.map(k=>e.jsxs(G,{sx:{cursor:"pointer",px:1},onClick:()=>a(k),selected:s&&s?.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))]},n))}),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:n=>n.palette.text.disabled},children:w(g?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ee,{size:{xs:12,md:8},sx:{height:1},children:[s&&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.${s.status}`)}),e.jsx(p,{children:O(s)})]}),e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[d&&e.jsx(P,{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:s.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:s.id}),e.jsx(B,{onClick:()=>a(d),children:e.jsx(p,{component:N,icon:Q,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:Q,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")," (",s.responseStatus,")"]}),e.jsx(Y,{language:"json",children:JSON.stringify(s.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(Y,{language:"json",sx:{margin:0},children:JSON.stringify(s.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(Y,{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}=K(),{teamDid:r}=V(),{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(P,{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(A,{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(A,{label:c("webhookEndpoint.listen"),value:e.jsx(P,{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(A,{label:c("webhookEndpoint.version"),value:l.apiVersion,divider:!0}),e.jsx(A,{label:c("common.createdAt"),value:U(l.createdAt),divider:!0}),e.jsx(A,{label:c("common.updatedAt"),value:U(l.updatedAt),divider:!0}),e.jsx(A,{label:c("common.createdBy"),value:e.jsx(P,{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(A,{label:c("common.updatedBy"),value:e.jsx(P,{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=Ke(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},s={};return c||(s.TableToolbar=re),b||(s.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:s,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 At(){const{teamDid:i}=V(),u=et(),c=`webhook-endpoints-${i}`,b=Se(c),{t:r,locale:w}=M(),{api:x}=K(),[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:s,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(n){q.error(n?.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 n=o.page+1;const h=o.searchText||"";if(h!==j){l(h);return}if(d==="changePage"||d==="changeRowsPerPage"){d!=="changePage"&&(n=1);const k={page:n,pageSize:o.rowsPerPage};l(""),z(k)}};if(s)return e.jsx(te,{severity:"error",children:s.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 n=I[d];return e.jsxs(p,{sx:{display:"flex",alignItems:"center",cursor:"pointer",gap:.5},children:[e.jsx(C,{variant:"body2",children:n.description}),e.jsx(p,{sx:{display:"flex"},onClick:h=>{h.stopPropagation()},children:e.jsx(P,{title:n.url,children:e.jsx(_,{sx:{fontSize:"15px",marginTop:"1px"}})})})]})}}},{label:"Events",name:"events",options:{customBodyRenderLite:(o,d)=>{const n=I[d];return e.jsx(p,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:n.enabledEvents.map(h=>e.jsx(L,{size:"small",variant:"filled",label:h.type,sx:{borderRadius:"4px",textTransform:"capitalize"}},`${n.source}-${h.type}`))})}}},{label:r("common.status"),name:"status",options:{customBodyRenderLite:(o,d)=>{const n=I[d];return e.jsx(L,{size:"small",variant:"filled",label:r(`webhookEndpoint.${n?.status}`),color:be(n?.status),sx:{borderRadius:"4px",textTransform:"capitalize"}},`status-${n.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 n=I[d],h=n?.status==="enabled";return e.jsx(st,{actions:[{icon:h?e.jsx(Ve,{}):e.jsx(Ye,{}),text:r(h?"webhookEndpoint.disable":"webhookEndpoint.enable"),onClick:k=>{k.stopPropagation(),v(n,h)}},{icon:e.jsx(Je,{}),text:r("common.edit"),onClick:k=>{k.stopPropagation(),g(W=>({...W,createEdit:{open:!0,id:n.id,url:n.url,description:n.description,enabledEvents:n.enabledEvents}}))}},{icon:e.jsx(Qe,{}),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(n.id),onCancel:()=>g($=>({...$,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 n=a.list[d];g(h=>({...h,webhookDetail:{open:!0,id:n.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(Xe,{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(nt,{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{At as default};
@@ -1 +0,0 @@
1
- import{j as t,at as r}from"./vendor-mui-core-DV92LEhm.js";import{r as s}from"./vendor-react-Dvs43sk9.js";import{c as a}from"./vendor-ux-C9Q7otQi.js";import{t as n}from"./index-CBuBVmWe.js";import"./vendor-utils-CddrUZ58.js";import"./vendor-hooks-9cd36rYd.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-D_Dm09bZ.js";function l(){const{t:o}=s.useContext(a);return t.jsx(i,{style:{paddingTop:"25vh"},children:t.jsx(n,{status:"404",description:o("noMatch.desc"),style:{backgroundColor:"transparent"}})})}const i=r.main``;export{l as default};
@@ -1 +0,0 @@
1
- import{r as l}from"./vendor-react-Dvs43sk9.js";import{T as C,$ as E,j as M,k as P}from"./vendor-ux-C9Q7otQi.js";import{k as y}from"./vendor-hooks-9cd36rYd.js";import{j as e,ak as s,a6 as $,aX as k,b1 as W,y as L,x as _,bb as B,M as z,T as A,a$ as D,I as K,bc as N,Q as F,W as U}from"./vendor-mui-core-DV92LEhm.js";import{c as S,Y as w}from"./index-CBuBVmWe.js";import{a as q}from"./api-ZbpPN5Q9.js";import{T as V}from"./table-tips-BNjmTVFL.js";import{u as G}from"./team-C8yfeoct.js";import{u as H}from"./session-DW40g2df.js";import"./vendor-utils-CddrUZ58.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-D_Dm09bZ.js";import"./use-mobile-BcHeqFSk.js";import"./isURL-BZcSl4qG.js";import"./use-app-logo-pyV6ZPrc.js";function T({endpoint:i}){const[t,a]=l.useState("mcp-link"),x=w(),{api:h}=w(),{teamDid:m}=G(),{t:c,locale:p}=C(),{session:r}=H(),{data:u,run:o,loading:g}=y(()=>{const f={owner:S.SERVER_ROLES.ADMIN}[r?.user?.role]||r?.user?.role;return h.createAccessKey({input:{teamDid:m,passport:f,authType:"simple",remark:"Generated by MCP Servers"}})},{manual:!0}),{imgPrefix:n}=x,j=l.useMemo(()=>[{icon:e.jsx(s,{sx:{width:20,height:20},children:"🔗"}),value:"mcp-link",label:"MCP Link"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/claude.webp`,alt:"Claude",sx:{width:20,height:20}}),value:"claude",label:"Claude"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/cursor.png`,alt:"Cursor",sx:{width:20,height:20}}),value:"cursor",label:"Cursor"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/cline.png`,alt:"Cline",sx:{width:20,height:20}}),value:"cline",label:"Cline"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/roocline.png`,alt:"Roo Cline",sx:{width:20,height:20}}),value:"roo-cline",label:"Roo Cline"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/windsurf.png`,alt:"Windsurf",sx:{width:20,height:20}}),value:"windsurf",label:"Windsurf"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/witsy.png`,alt:"Witsy",sx:{width:20,height:20}}),value:"witsy",label:"Witsy"}],[n]),v=j.find(d=>d.value===t),b=l.useMemo(()=>u?.data?.accessKeySecret,[u]),R=l.useMemo(()=>!b&&t!=="mcp-link",[b,t]),I=d=>{const f=`npx @blocklet/install-mcp@latest i ${i} --client ${d} --streamableHTTP --oauth2Bearer ${b}`;switch(d){case"cursor":case"claude":case"cline":case"roo-cline":case"windsurf":case"witsy":return f;case"mcp-link":default:return i}};return e.jsxs(s,{className:"mcp-servers-container",children:[e.jsx(M,{tabs:j,current:t,onChange:a,scrollButtons:"auto",iconPosition:"start"}),e.jsxs(s,{children:[e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(A,{component:"span",variant:"h6",sx:{fontWeight:"bold",my:2},children:t==="mcp-link"?v?.label:`${v?.label} ${c("installCommand")}`}),t!=="mcp-link"&&e.jsx(D,{href:`https://www.arcblock.io/docs/blocklet-developer/${p}/mcp-${t}`,target:"_blank",rel:"noopener noreferrer",children:e.jsx(K,{size:"small",children:e.jsx(N,{fontSize:"small"})})})]}),e.jsxs(s,{className:"mcp-servers-codeblock",sx:{position:"relative","& pre":{borderRadius:1},"& .codeblock__inner":{overflow:"auto !important",borderRadius:1}},children:[e.jsx(P,{code:I(t),language:"shell",style:{margin:0}}),R&&e.jsx(s,{sx:{position:"absolute",top:0,right:0,left:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"action.active",backdropFilter:"blur(3px)",WebkitBackdropFilter:"blur(3px)",zIndex:1},children:g?e.jsx($,{}):e.jsx(F,{variant:"contained",color:"primary",onClick:o,size:"small",children:`${c("common.generate")} ${c("command")}`})})]})]})]})}T.propTypes={endpoint:U.string.isRequired};function ce(){const[i,t]=l.useState(null),{t:a,locale:x}=C(),h=`${window?.blocklet?.appUrl}${S.WELLKNOWN_SERVICE_PATH_PREFIX}/mcp/servers`,{data:m,loading:c,error:p}=y(()=>Promise.all([q.get(h)])),r=l.useMemo(()=>m?.[0]?.data?.servers||[],[m]);l.useEffect(()=>{r?.length&&t(r.find(o=>o.did===window?.blocklet?.did)||r[0])},[r]);const u=o=>{const g=o.target.value;t(r.find(n=>n.did===g))};return c?e.jsx(s,{children:e.jsx($,{})}):p?e.jsx(k,{color:"error",children:p?.message}):r?.length?e.jsxs(W,{sx:{gap:2,maxWidth:1200},children:[e.jsx(V,{title:a("mcp.listTitle"),tooltipTitle:a("mcp.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${x}/mcp-server`}),e.jsxs(L,{fullWidth:!0,children:[e.jsx(_,{id:"server-select-label",children:a("mcp.available")}),e.jsx(B,{labelId:"server-select-label",value:i?.did||"",label:a("mcp.available"),onChange:u,children:r.map(o=>e.jsx(z,{value:o.did,children:e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(E,{variant:"rounded",shape:"square",did:o.did,src:o.logo,size:20}),e.jsx(s,{sx:{fontSize:14},children:o.name})]})},o.did))})]}),i&&e.jsx(T,{endpoint:i.endpoint})]}):e.jsx(k,{color:"warning",children:a("mcp.noServer")})}export{ce as default};
@@ -1,124 +0,0 @@
1
- import{j as e,y as St,bb as Se,M as ae,ak as f,Q as _,W as u,J as xe,c0 as kt,I as O,aN as Pt,T as I,aj as Rt,b5 as Ee,P as Le,b6 as Q,a5 as Be,z as Ve,A as Ye,cm as It,bf as Tt,U as je,d8 as At,d9 as Mt,at as ee,da as zt,a6 as Y,n as le,D as Et,db as Lt,ar as We,b1 as ke,dc as Bt,aX as Wt,am as X,bp as Dt,bq as ye,a$ as Nt,cV as Ot}from"./vendor-mui-core-DV92LEhm.js";import{r as y,a as $t,u as Ft,j as Ut}from"./vendor-react-Dvs43sk9.js";import{t as Ze,Z as qt,a7 as _t,R as De,D as Ht,C as ce,n as V,A as Gt}from"./vendor-utils-CddrUZ58.js";import{a as Kt,G as Vt,br as Yt,c as Pe,d as Zt,X as Qt,bs as Xt,aR as Re,V as fe,bc as Jt,bt as er,a4 as tr,aT as rr,a5 as nr,bu as or}from"./index-CBuBVmWe.js";import{a as T,h as Qe,k as te,g as H,b as E,j as sr}from"./vendor-hooks-9cd36rYd.js";import{l as Xe}from"./arrow-down.svg-BcoTeNyX.js";import{c as Ie,J as N,T as D,av as ir,I as Je,aw as ar,H as q,ax as lr,ay as cr,az as Ne,f as dr,n as et,e as Te,aA as ur,aB as M,y as pr,x as xr,$ as tt,aC as fr,aD as hr,K as gr,o as de,C as Oe,L as mr}from"./vendor-ux-C9Q7otQi.js";import{N as br}from"./list-DFvUHI6u.js";import{d as yr}from"./search-4YYphs0l.js";import{B as $e}from"./bundle-avatar-VT8FLC3N.js";import{h as Fe,T as vr}from"./team-C8yfeoct.js";import{b as wr,d as jr,a as Cr,c as Sr,e as kr,f as Pr,B as Rr}from"./user-center-V4qQZYhM.js";import{N as rt,U as nt}from"./index-DQ3_Wuxe.js";import{u as re}from"./use-mobile-BmKySh5X.js";import Ir from"./index-BPLFlpyZ.js";import{f as J}from"./index-DBs9Ljax.js";import{u as ot}from"./index-BbOvyzfE.js";import{U as ve}from"./user-sessions-DYh09QrL.js";import Tr from"./index-D4wH7CER.js";import{o as Ar}from"./vendor-arcblock-D_Dm09bZ.js";import{c as Mr,b as ue,a as zr,S as Er}from"./index-DMpO3u1o.js";import"./index-DYgvuymH.js";import"./index-BojVbZw0.js";import"./lottie-web-4koyQiv_.js";import"./server-logo-notext.svg-CKQB0tIp.js";import"./index-CX5AEYFR.js";import"./util-Dceeaiqy.js";import"./base32-rvunYmjt.js";import"./session-DW40g2df.js";import"./isURL-BZcSl4qG.js";import"./use-app-logo-pyV6ZPrc.js";import"./index-Bx4IaUHc.js";import"./api-ZbpPN5Q9.js";import"./table-tips-BNjmTVFL.js";import"./use-mobile-BcHeqFSk.js";import"./passport-item-Bej8KfmX.js";import"./did-address-CY4nLJqm.js";import"./index-Bv7qQ-8a.js";import"./vendor-mui-x-8McV6Pkb.js";import"./AdapterDayjs-DQyL5DVQ.js";import"./confirm-DTV46cI2.js";import"./click-to-copy-LMYjlbUz.js";import"./delete-confirm-DTjAa9xG.js";import"./permission-BPBzp1tm.js";import"./actions-DnpJX6lQ.js";import"./index-DRYJ0xIl.js";function Lr(){let t=new Map;function s({root:o,rootMargin:n,threshold:l}){let i=t.get(o);i||(i=new Map,t.set(o,i));let c=JSON.stringify({rootMargin:n,threshold:l}),p=i.get(c);if(!p){let r=new Map;p={observer:new IntersectionObserver(x=>{x.forEach(m=>{r.get(m.target)?.(m)})},{root:o,rootMargin:n,threshold:l}),entryCallbacks:r},i.set(c,p)}return{observe:(r,x)=>{p.entryCallbacks.set(r,x),p.observer.observe(r)},unobserve:r=>{p.entryCallbacks.delete(r),p.observer.unobserve(r)}}}return{getObserver:s}}var Br="0px",Wr=[0],Dr=Lr();function Nr(t){let s=t?.rootMargin??Br,o=t?.threshold??Wr,n=y.useRef(null),l=y.useRef(null),i=y.useRef(null),[c,p]=y.useState(),r=y.useCallback(()=>{let C=n.current;if(!C){p(void 0);return}let v=Dr.getObserver({root:l.current,rootMargin:s,threshold:o});v.observe(C,a=>{p(a)}),i.current=v},[s,o]),x=y.useCallback(()=>{let C=i.current,v=n.current;v&&C?.unobserve(v),i.current=null},[]),m=y.useCallback(C=>{x(),n.current=C,r()},[r,x]),h=y.useCallback(C=>{x(),l.current=C,r()},[r,x]);return[m,{entry:c,rootRef:h}]}var Or=Nr;function $r(t){let[s,o]=Or(t),n=!!o.entry?.isIntersecting,[l,i]=y.useState(n);return n&&!l&&i(!0),[s,{...o,isVisible:n,wasEverVisible:l}]}var Fr=$r,Ur=100;function qr({loading:t,hasNextPage:s,onLoadMore:o,rootMargin:n,disabled:l,delayInMs:i=Ur}){let c=y.useRef(o),[p,{rootRef:r,isVisible:x}]=Fr({rootMargin:n});y.useEffect(()=>{c.current=o},[o]);let m=!l&&!t&&x&&s;return y.useEffect(()=>{if(m){let h=setTimeout(()=>{c.current()},i);return()=>{clearTimeout(h)}}},[m,i]),[p,{rootRef:r}]}var _r=qr;const we={info:"#3B82F6",success:"#10B981",warning:"#F59E0B",error:"#EF4444"};pe.propTypes={severity:u.oneOf(["info","success","warning","error",""]).isRequired,size:u.number};function pe({severity:t,size:s=8}){return we[t]?e.jsx(f,{component:"span",sx:{display:"inline-block",width:s,height:s,borderRadius:"50%",backgroundColor:we[t]||we.info}}):null}st.propTypes={theme:u.string,type:u.oneOf(["button","line","select"]),onSelectType:u.func,extra:u.node,loading:u.bool,currentTab:u.oneOf(["info","success","warning","error",""])};function st({theme:t="dark",type:s="button",onSelectType:o,extra:n=void 0,currentTab:l="",loading:i=!1,...c}){const{t:p}=y.useContext(Ie),r=[{label:p("notification.allSeverity"),value:""},{label:p("notification.severityType.info"),value:"info"},{label:p("notification.severityType.success"),value:"success"},{label:p("notification.severityType.warning"),value:"warning"},{label:p("notification.severityType.error"),value:"error"}],x=g=>{(g!==l||!i)&&o(g)},m=y.useMemo(()=>{const g={width:"100%",bgcolor:t==="dark"?"#F9FAFB":"",overflowY:"auto",paddingTop:s==="select"?"0":"5px",whiteSpace:"nowrap",borderRadius:0,display:"flex",justifyContent:"space-between",alignItems:"flex-end",flexWrap:"wrap",gap:"8px"};return s==="line"?Object.assign(g,{}):g},[s,t]),h=(g,k,R)=>e.jsx(_,{disabled:i,onClick:()=>x(g.value),className:`profile-button ${k?"active":""}`,...c,children:g.label},g.value||R),C=(g,k,R)=>e.jsx(_,{variant:"text",disabled:i,onClick:()=>x(g.value),className:`profile-line-button ${k?"active":""}`,...c,children:g.label},g.value||R),v=()=>r?.map((g,k)=>{const R=l===g?.value;return s==="line"?e.jsx(y.Fragment,{children:C(g,R,k)},g.value||k):e.jsx(y.Fragment,{children:h(g,R,k)},g.value||k)}),a=g=>{const{value:k}=g.target;x(k==="all"?"":k)};return s==="select"?e.jsx(St,{sx:{maxWidth:300},children:e.jsx(Se,{value:l||"all",onChange:a,size:"small",label:"Severity",IconComponent:g=>e.jsx(Xe,{...g,width:20,height:20}),MenuProps:{autoFocus:!1,PaperProps:{style:{maxHeight:400,overflowY:"auto",borderRadius:"8px",boxShadow:"0px 6px 24px rgba(0, 0, 0, 0.15)"}}},variant:"outlined",sx:{fieldset:{border:"none"}},children:r.map((g,k)=>e.jsx(ae,{value:g.value||"all",children:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(pe,{severity:g.value}),g.label]})},g.value||k))})}):e.jsxs(f,{className:"severity-tabs",sx:m,children:[e.jsx(f,{sx:{...s==="line"?{flex:1,borderBottom:"1px solid",borderColor:"grey.200"}:{display:"flex",gap:"24px"}},children:v()}),n]})}it.propTypes={paging:u.objectOf(u.any).isRequired,loading:u.bool.isRequired,onChange:u.func.isRequired};function it({loading:t,paging:s,onChange:o}){const{t:n}=y.useContext(Ie),l=xe(r=>r.breakpoints.down("md"));if(s.pageCount<=0||l)return null;const i=(r,x)=>{o({page:x+1})},c=r=>{const x=Number(r.target.value);o({page:1,pageSize:x})},p=s.page-1<=0?0:s.page-1;return e.jsx(f,{className:"notification-pagination",sx:{mt:2,display:"flex",justifyContent:"flex-end"},children:e.jsx(kt,{component:"div",disabled:t,count:s.total,page:p,rowsPerPageOptions:[10,20,50,100],labelRowsPerPage:n("pagination.rowsPerPage"),labelDisplayedRows:({from:r,to:x,count:m})=>`${r}–${x} / ${m!==-1?m:`${n()}more than ${x}`}`,rowsPerPage:s.pageSize,onPageChange:i,onRowsPerPageChange:c})})}const Hr=y.memo(it),Gr={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4h16v2.172a2 2 0 0 1-.586 1.414L15 12v7l-6 2v-8.5L4.52 7.572A2 2 0 0 1 4 6.227V4z"/>'},Ue=6,qe={"& .MuiCheckbox-root":{padding:"4px"},"& .MuiCheckbox-root .MuiSvgIcon-root":{fontSize:"1.35rem"},"& .MuiCheckbox-root:not(.Mui-checked)":{color:"divider"},"& .MuiCheckbox-root.Mui-checked":{color:"primary.main"},"& .MuiCheckbox-root .css-i4bv87-MuiSvgIcon-root":{width:"1.1em",height:"1.1em"},"& .MuiCheckbox-root svg":{stroke:"divider",strokeWidth:.7}},Kr={border:"1px solid",borderColor:"divider",borderRadius:1,overflow:"hidden",backgroundColor:"background.paper",backgroundImage:"none",transition:"all 0.2s ease-in-out"},_e=()=>({...Kr,width:"calc(50% - 8px)"});at.propTypes={loading:u.bool,type:u.oneOf(["server","service"]),onFilterChange:u.func,blockletMap:u.object,filterType:u.oneOf(["component","entity"]),selectedId:u.array,severity:u.array,enableMarkAllAsRead:u.bool,unReadCount:u.number,onReadFilterChange:u.func,currentReadFilter:u.string};function at({onFilterChange:t=()=>{},loading:s=!1,type:o="service",blockletMap:n={},filterType:l="component",selectedId:i=[],severity:c=[],enableMarkAllAsRead:p=!0,unReadCount:r=0,onReadFilterChange:x=()=>{},currentReadFilter:m="all"}){const{t:h}=y.useContext(Ie),[C,v]=y.useState(null),a=!!C,[g,k]=y.useState(i),[R,P]=y.useState(c),[b,z]=y.useState(!1),[L,F]=y.useState(""),[j,S]=y.useState([]);y.useEffect(()=>{k(i),P(c)},[i,c]);const B=[{label:h("notification.filterType.all"),value:"all"},{label:h("notification.filterType.unread"),value:"unread"}],G=d=>{(d!==m||!s)&&x(d)},Z=[{label:h("notification.severityType.info"),value:"info"},{label:h("notification.severityType.success"),value:"success"},{label:h("notification.severityType.warning"),value:"warning"},{label:h("notification.severityType.error"),value:"error"}],ne=d=>{v(d.currentTarget),F(""),z(!1)},he=()=>{v(null)},oe=d=>{const w=g.includes(d)?g.filter(A=>A!==d):[...g,d];k(w),t({id:w,severity:R})},se=d=>{const w=R.includes(d)?R.filter(A=>A!==d):[...R,d];P(w),t({severity:w,id:g})},ge=d=>{F(d.target.value)},me=()=>{z(!b)},K=$t.useMemo(()=>{if(!n.size)return[];const d=[];return l==="component"&&d.push({label:h("notification.system"),id:"system"}),Array.from(n).forEach(([,w])=>{const A=w.did||w.meta?.did,W=w.title||w.meta?.title||"",U=w.appPid||w.appDid;(l==="component"&&U!==A||l==="entity"&&U===A)&&d.push({label:W,id:A,blocklet:w,ancestors:w.ancestors})}),d},[n,l,h]);y.useEffect(()=>{if(L.trim()==="")S(K);else{const d=L.toLowerCase(),w=K.filter(A=>A.label.toLowerCase().includes(d));S(w)}},[L,K]);const be=L.trim()!==""||b?j:j.slice(0,Ue);return e.jsxs(f,{children:[e.jsxs(f,{sx:{display:"flex",justifyContent:p?"space-between":"flex-end",alignItems:"flex-start",flexWrap:"wrap",gap:1},children:[p&&e.jsx(f,{sx:{display:"flex",gap:1.5},children:B.map(d=>e.jsxs(_,{disabled:s,onClick:()=>G(d.value),className:`profile-button ${m===d.value?"active":""}`,sx:{...o==="service"&&m===d.value?{color:"secondary.main"}:{},color:"red",fontWeight:m===d.value?"bold":"normal"},children:[d.label,d.value==="unread"&&r>0&&` (${r})`]},d.value))}),e.jsxs(f,{sx:{display:"flex",justifyContent:"flex-end",gap:2},children:[e.jsx(O,{size:"small",onClick:ne,disabled:s,sx:{minWidth:"auto",borderRadius:1,border:"1px solid",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:e.jsx(N,{icon:Gr,hFlip:!0})}),e.jsx(Pt,{open:a,anchorEl:C,onClose:he,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{p:3,width:450,maxHeight:500,overflowY:"auto",backgroundColor:"background.paper",backgroundImage:"none",borderRadius:1,boxShadow:"0px 6px 24px rgba(0, 0, 0, 0.15)"}}},children:e.jsxs(f,{children:[e.jsxs(f,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,height:"28px"},children:[e.jsx(I,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("notification.severity")}),e.jsx(f,{sx:{minWidth:"60px",display:"flex",justifyContent:"flex-end"},children:(g.length>0||R.length>0)&&e.jsx(_,{size:"small",onClick:()=>{k([]),P([]),t({severity:[],id:[]})},startIcon:e.jsx(Rt,{fontSize:"small"}),sx:{color:"text.secondary",textTransform:"none",minWidth:"auto","&:hover":{backgroundColor:"transparent"},"& .MuiButton-startIcon":{marginRight:"2px"}},children:h("notification.clear")})})]}),e.jsx(f,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(Ee,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:2,flex:1},children:Z.map(d=>e.jsx(Le,{elevation:0,sx:_e(R.includes(d.value)),children:e.jsx(Q,{sx:{margin:0,padding:.5,width:"100%","& .MuiFormControlLabel-label":{display:"flex",alignItems:"center",gap:1,fontSize:"0.875rem"},...qe},control:e.jsx(Be,{checked:R.includes(d.value),onChange:()=>se(d.value),disabled:s,size:"small"}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:.5},children:[e.jsx(pe,{severity:d.value}),d.label]})})},d.value))})}),e.jsxs(f,{sx:{mb:2},children:[e.jsxs(f,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,mb:1.5},children:[e.jsx(I,{variant:"subtitle1",sx:{fontWeight:"bold",width:"calc(100% - 36px)"},children:h("notification.from")}),e.jsx(f,{sx:{display:"flex",alignItems:"center",width:"calc(100% - 36px)"},children:e.jsx(Ve,{size:"small",placeholder:"search",value:L,onChange:ge,sx:{width:"100%","& .MuiOutlinedInput-input":{padding:"6px 4px 6px 0"},".MuiOutlinedInput-root":{"&:hover":{fieldset:{borderColor:"divider"}},"&.Mui-focused":{fieldset:{borderColor:"divider"}}},fieldset:{borderColor:"divider"}},slotProps:{input:{size:"small",startAdornment:e.jsx(Ye,{position:"start",sx:{marginRight:"2px"},children:e.jsx(N,{icon:yr})})}}})})]}),e.jsx(Ee,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:2},children:be.map(d=>e.jsx(Le,{elevation:0,sx:_e(g.includes(d.id)),children:e.jsx(Q,{sx:{margin:0,padding:.5,width:"100%","& .MuiFormControlLabel-label":{fontSize:"0.875rem",width:"calc(100% - 36px)"},...qe},control:e.jsx(Be,{checked:g.includes(d.id),onChange:()=>oe(d.id),disabled:s,size:"small"}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:.5,minWidth:0,width:"100%"},children:[d.blocklet&&e.jsx($e,{size:20,blocklet:d.blocklet,ancestors:d.ancestors,style:{borderRadius:4,flexShrink:0}}),e.jsx(I,{noWrap:!0,variant:"body2",component:"span",title:d.label,sx:{flex:1,overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:d.label})]})})},d.id))}),j.length>Ue&&L.trim()===""&&e.jsx(_,{fullWidth:!0,size:"small",onClick:me,sx:{mt:1},endIcon:b?e.jsx(It,{}):e.jsx(Tt,{})})]})]})})]})]}),g.length>0||R.length>0?e.jsxs(f,{className:"notification-filter-content",sx:{display:"flex",flexWrap:"wrap",gap:1,mt:2},children:[R.map(d=>{const w=Z.find(A=>A.value===d);return e.jsx(je,{label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(pe,{severity:d}),w?w.label:d]}),onDelete:()=>se(d),size:"small",variant:"outlined",sx:{borderRadius:2,color:"text.secondary",borderColor:"divider","& .MuiChip-label":{display:"flex",alignItems:"center"}}},`severity-${d}`)}),g.map(d=>{const w=K.find(A=>A.id===d);return e.jsx(je,{label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:.5},children:[w?.blocklet&&e.jsx($e,{size:16,blocklet:w.blocklet,ancestors:w.ancestors,style:{borderRadius:4,flexShrink:0}}),w?w.label:d]}),variant:"outlined",onDelete:()=>oe(d),size:"small",sx:{borderRadius:2,color:"text.secondary",borderColor:"divider","& .MuiChip-label":{display:"flex",alignItems:"center"}}},`component-${d}`)})]}):null]})}const Vr=ee(zt)`
2
- position: fixed;
3
- bottom: 20px;
4
- right: 20px;
5
- z-index: 1000;
6
- @media (max-width: 600px) {
7
- bottom: 16px;
8
- right: 16px;
9
- transform: scale(0.9);
10
- }
11
- `;function Yr(){const[t,s]=y.useState(!1);y.useEffect(()=>{const n=Ze(()=>{s(window.pageYOffset>300)},200);return window.addEventListener("scroll",n),n(),()=>window.removeEventListener("scroll",n)},[]);const o=()=>{try{"scrollTo"in window?window.scrollTo({top:0,behavior:"smooth"}):window.scrollTo(0,0)}catch{window.scrollTo(0,0)}};return e.jsx(At,{in:t,children:e.jsx(Vr,{color:"primary",size:"small","aria-label":"scroll back to top",onClick:o,children:e.jsx(Mt,{})})})}const Zr=ee.div`
12
- display: flex;
13
- flex-direction: column;
14
- gap: ${t=>t.inDialog?0:"24px"};
15
- .MuiContainer-root {
16
- padding-right: 0;
17
- }
18
-
19
- .profile-button.MuiButtonBase-root {
20
- border-radius: 9999px;
21
- margin-right: 2px;
22
- padding: 5px 12px;
23
- line-height: 22px;
24
- font-size: 13px;
25
- border: 1px solid transparent;
26
- background-color: ${({theme:t})=>t.palette.background.default};
27
- color: ${({theme:t})=>t.palette.text.primary};
28
- font-weight: 400;
29
- border: 1px solid ${({theme:t})=>t.palette.divider} !important;
30
- }
31
- .profile-button.active.MuiButtonBase-root,
32
- .profile-button.active.MuiButtonBase-root:hover {
33
- color: ${({theme:t})=>t.palette.primary.main};
34
- font-weight: 600;
35
- background-color: ${({theme:t})=>le(t.palette.primary.main,.1)};
36
- border: 1px solid ${({theme:t})=>le(t.palette.primary.main,.24)} !important;
37
- }
38
-
39
- .profile-button.MuiButtonBase-root:hover {
40
- background-color: rgba(0, 0, 0, 0.04);
41
- }
42
-
43
- .profile-line-button.MuiButtonBase-root {
44
- margin-right: 2px;
45
- color: ${({theme:t})=>t.palette.text.secondary};
46
- padding: 5px 12px;
47
- line-height: 22px;
48
- font-size: 13px;
49
- border: none !important;
50
- border-radius: 0;
51
- }
52
-
53
- .profile-line-button.active.MuiButtonBase-root {
54
- color: ${({theme:t})=>t.palette.text.primary};
55
- border-bottom: 1px solid ${({theme:t})=>t.palette.text.primary} !important;
56
- }
57
-
58
- .profile-button.MuiButtonBase-root:last-of-type,
59
- .profile-line-button.MuiButtonBase-root {
60
- margin-right: 0;
61
- }
62
-
63
- .profile-line-button.MuiButtonBase-root:hover {
64
- color: ${({theme:t})=>t.palette.text.primary};
65
- background-color: unset;
66
- }
67
-
68
- * {
69
- scrollbar-width: none; /* Firefox */
70
- -ms-overflow-style: none; /* IE and Edge */
71
- }
72
-
73
- *::-webkit-scrollbar {
74
- display: none; /* Chrome, Safari and Opera */
75
- }
76
- `;lt.propTypes={blocklets:u.array,context:u.object,pagination:u.bool,inDialog:u.bool,filterType:u.oneOf(["component","entity"]),toViewAll:u.func,type:u.oneOf(["server","service"])};function lt({blocklets:t=[],context:s,pagination:o=!0,inDialog:n=!1,filterType:l="component",toViewAll:i=()=>{},type:c="service"}){const{data:p,paging:r,refresh:x,loading:m,params:h,onReadNotification:C,componentDids:v,filterUnReadCount:a,initial:g}=s,k=d=>{x({...h,severity:d&&typeof d=="string"?[d]:d||[],paging:{...h.paging,page:1}})},[R]=Ft(),P=T(()=>R.get("id"),[R]),b=xe(d=>d.breakpoints.down("md")),[z,L]=y.useState(0),[F,j]=y.useState(!1),S=y.useMemo(()=>h.read===!1?"unread":"all",[h.read]),B=T(()=>Ze(d=>{if(m)return;const w=p.length,A=p.filter(U=>!Fe(U)).length;let W={...h,append:!0,paging:{...h.paging,...d,currentPage:(r.currentPage||0)+1}};S==="unread"&&A<w&&d.page>h.paging.page&&(W={...h,append:!0,paging:{...h.paging,...d,page:h.paging.page||1,currentPage:(r.currentPage||0)+1}}),x(W)},500),[p,h,S,r,m,x]);Qe(()=>{g&&typeof g=="function"&&g()}),y.useEffect(()=>{(!r.currentPage||r.currentPage===1)&&L(r.total)},[r.total,r.currentPage]),y.useEffect(()=>{setTimeout(()=>{const d=document.getElementById(P);d&&d.scrollIntoView({behavior:"smooth",block:"center"}),j(!0)},100),setTimeout(()=>{j(!1)},3e3)},[P]);const G=T(()=>p?.length>0&&p.length<z,[p,z]),Z=y.useCallback(d=>{const{blocklet:w={}}=window,A=[w?.did,...(w?.ancestors||[]).map(W=>W)];return v?.includes(d)||A.findIndex(W=>W===d)>-1},[v]),ne=y.useMemo(()=>{const d=new Map;return t.length&&t.forEach(w=>{const A=w?.did||w.meta?.did;A&&!d.has(A)&&(w.ancestors=[],d.set(A,w),w?.alsoKnownAs?.length>0&&w.alsoKnownAs.forEach(W=>{d.has(W)||d.set(W,w)})),w?.children?.length>0&&w.children.forEach(W=>{const U=W?.did||W.meta?.did;U&&!d.has(U)&&Z(U)&&(W.ancestors=[w],d.set(U,W))})}),d},[t,Z]),he=y.useCallback(()=>{m||B({page:r.page+1})},[r.page,m,B]),[oe]=_r({loading:m,hasNextPage:G,onLoadMore:he}),se=d=>{!d||Fe(d)||C(d.id).then(()=>{n&&i()})},ge=({severity:d,id:w})=>{if(m)return;let A={};l==="component"?A={entityId:[],componentDid:w}:l==="entity"&&(A={componentDid:[],entityId:w}),x({...h,severity:d,...A,paging:{...h.paging,page:1}})},me=d=>{if(m)return;let w={...h,paging:{...h.paging,page:1}};d==="unread"?(w.read=!1,w.paging.currentPage=1):w=qt(w,"read"),x(w)},K=T(()=>l==="component"?Array.isArray(h.componentDid)?h.componentDid:[]:l==="entity"?Array.isArray(h.entityId)?h.entityId:[]:[],[h,l]),be=T(()=>(Array.isArray(h.severity)?h.severity:[])[0]||"",[h.severity]);return e.jsxs(Zr,{inDialog:!!n,children:[n?e.jsx(st,{currentTab:be,type:"line",theme:"light",onSelectType:k}):e.jsx(at,{loading:m,blockletMap:ne,unReadCount:a,filterType:l,type:c,selectedId:K,onFilterChange:ge,severity:h.severity,onReadFilterChange:me,currentReadFilter:S}),!b&&m?e.jsx(f,{sx:{display:"flex",width:"100%",minHeight:400,justifyContent:"center",alignItems:"center"},children:e.jsx(Y,{})}):e.jsx(br,{data:p,blockletMap:ne,onReadNotification:se,onReadBatch:C,inDialog:n,highlightId:P,highlight:!n&&F,type:c}),o&&!b?e.jsx(Hr,{loading:m,paging:r,onChange:B}):null,o&&b&&(m||G)?e.jsx(f,{ref:oe,sx:{display:"flex",width:"100%",minHeight:100,justifyContent:"center",alignItems:"center"},children:e.jsx(Y,{})}):null,!n&&b?e.jsx(Yr,{}):null]})}const Qr=y.memo(lt),$=new Yt;function Ae(t){const{userDid:s=""}={},{session:o}=Kt(),n=T(()=>{if(s)return s;const r=window.location.href,x=_t(r);return x?.did?Array.isArray(x.did)?x.did[0]:x.did:o?.user?.did},[o?.user?.did,s]),l=T(()=>o.user,[o]),i=T(()=>l?n===l?.did:!1,[n,l?.did]),c=te(async()=>{if(await Vt(()=>o?.initialized),i)return o.user;if(n)return $.user.getUserPublicInfo({did:n})},{refreshDeps:[n,i,o?.initialized,l]}),p=T(()=>l.passports?.some(r=>r.role===Pe.ROLES.OWNER),[l]);return{currentDid:n,session:o,isMyself:i,user:l,viewUser:c.data,isOwner:p}}function ct({user:t,...s}){const{t:o}=D(),n=Et(),l=T(()=>{const p=(t?.passports||[]).map(r=>({...r,revoked:r.status===ir.REVOKED}));return p.sort((r,x)=>r.revoked===x.revoked?0:r.revoked?1:-1),De(p.filter(r=>!r.display),"role").concat(De(p.filter(r=>r.display),"display.content"))},[t?.passports]),i=T(()=>l?.find(p=>p.name===t.role),[l,t?.role]),c=n.palette.primary.main;return l.length===0?e.jsx(f,{children:e.jsx(Je,{children:o("userCenter.noPassport")})}):e.jsx(f,{...s,sx:{display:"grid",justifyItems:"start",gridTemplateColumns:{xs:"repeat(2, 1fr)",sm:"repeat(2, 1fr)",md:"repeat(3, 1fr)",lg:"repeat(5, 1fr)"},gap:2.5,...s.sx},children:l.map(p=>e.jsx(wr,{passport:p,user:t,color:window.blocklet.passportColor,createPassportSvg:Zt,title:i&&i.role===p.role?o("userCenter.currentPassport"):"",sx:{flexDirection:"column",alignItems:"center",gap:1,".passport-item__display":{width:166,height:166,borderRadius:1,px:2,display:"flex",justifyContent:"center",backgroundColor:"grey.50",boxShadow:i&&i.role===p.role?`0px 2px 4px 0px ${c}, 0px 1px 2px -1px ${c}, 0px 0px 0px 1px ${c} !important`:"unset"},".passport-item__body":{marginLeft:"0 !important"}}},p.id))})}ct.propTypes={user:u.object.isRequired};function Xr({visible:t,onClose:s,nft:o}){return!t||!o?null:e.jsx(Jr,{children:e.jsx(Lt,{open:t,onClose:s,children:e.jsx(en,{onClick:s,children:e.jsx(rt,{data:nt(o),address:o.address,inset:!0})})})})}const Jr=ee.div`
77
- position: relative;
78
- width: 100%;
79
- height: 100%;
80
- cursor: pointer;
81
-
82
- &:hover {
83
- .mask {
84
- opacity: 1;
85
- }
86
- }
87
-
88
- .mask {
89
- position: absolute;
90
- top: 0;
91
- left: 0;
92
- display: flex;
93
- align-items: center;
94
- justify-content: center;
95
- width: 100%;
96
- height: 100%;
97
- background: rgba(0, 0, 0, 0.6);
98
- opacity: 0;
99
- transition: opacity 0.2s;
100
- }
101
- `,en=ee.div`
102
- display: flex;
103
- justify-content: center;
104
- align-items: center;
105
- height: 100vh;
106
- width: 100vw;
107
-
108
- img,
109
- object {
110
- max-width: 90vw;
111
- max-height: 75vh;
112
- }
113
-
114
- .nft-display--inset {
115
- > .MuiBox-root,
116
- .nft-display__loading {
117
- width: 75vmin;
118
- height: 75vmin;
119
- }
120
- }
121
- `,tn=t=>({position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.6)",opacity:0,transition:"opacity 0.3s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1,"& .mask-item":{backgroundColor:le(t.palette.background.paper,.9),color:"text.primary","&:hover":{backgroundColor:le(t.palette.background.paper,1)}}}),rn={position:"absolute",bottom:0,left:0,right:0,height:24,backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",gap:1,zIndex:1,"& .mask-item":{width:20,height:20,color:"white"}},He="https://main.abtnetwork.io/explorer";function dt({user:t}){const{t:s}=D(),o=re(),[n,l]=y.useState({visible:!1,nft:null}),[i,c]=y.useState({anchorEl:null,props:null}),p=P=>{const b=ce(He,"assets",P);window.open(b,"_blank")},r=(P,b)=>{let z="";typeof b.data?.value=="string"?z=JSON.parse(b.data?.value)?.domain:z=b.data?.value?.domain,c({anchorEl:P,props:{title:z?`Hey, I just won an NFT at the ${z} event!`:"Hey, I just won an NFT!",url:ce(He,"assets",b.address)}})},x=P=>{l({visible:!0,nft:P})},m=H({page:1,size:20}),h=te(async(P=m)=>(await Ht.get(`${Pe.WELLKNOWN_SERVICE_PATH_PREFIX}/ocap/listAssets`,{params:{ownerAddress:t.did,...P}})).data,{ready:t?.did&&m,defaultParams:[m],refreshDeps:[t?.did,m]}),{loading:C,data:v}=h,a=v?.page??{cursor:0,next:!1,total:0},g=(P,b)=>{m.page=b,h.run(m)},k=E(P=>[e.jsx(O,{size:"small",className:"mask-item",onClick:b=>{b.stopPropagation(),p(P.address)},children:e.jsx(N,{icon:"tabler:link",fontSize:18})},"link"),e.jsx(O,{size:"small",onClick:b=>{b.stopPropagation(),r(b.currentTarget,P)},className:"mask-item",children:e.jsx(N,{icon:"tabler:share-2",fontSize:18})},"share"),e.jsx(O,{size:"small",onClick:b=>{b.stopPropagation(),x(P)},className:"mask-item",children:e.jsx(N,{icon:"tabler:eye",fontSize:18})},"view")]),R=T(()=>{if(C){const P=["skeleton-1","skeleton-2","skeleton-3","skeleton-4","skeleton-5"].map(b=>e.jsx(We,{variant:"rectangular",width:"15%",height:166,sx:{borderRadius:1,flexShrink:0}},b));return e.jsxs(f,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx(We,{width:"20%"}),e.jsx(f,{sx:{display:"flex",flexDirection:"row",gap:2,flexWrap:"nowrap"},children:P})]})}return e.jsxs(e.Fragment,{children:[e.jsx(I,{sx:{color:"grey.A700",fontWeight:600,mb:2.5},children:s("userCenter.common.nft")}),v?.assets?.length===0&&!C&&e.jsx(f,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%"},children:e.jsx(Je,{children:s("userCenter.common.noNFT")})}),e.jsx(f,{className:"nft-list-wrapper",sx:{display:"grid",justifyItems:"start",gridTemplateColumns:{xs:"repeat(2, 1fr)",sm:"repeat(3, 1fr)",md:"repeat(3, 1fr)",lg:"repeat(5, 1fr)"},gap:2.5},children:v?.assets?.map(P=>e.jsxs(f,{sx:{flexShrink:0,width:{xs:120,sm:120,md:120,lg:166},height:{xs:120,sm:120,md:120,lg:166},position:"relative",borderRadius:1,overflow:"hidden",cursor:"pointer",...o?{}:{"&:hover .mask":{opacity:1}}},children:[e.jsx(rt,{data:nt(P),address:P.address,inset:!0,imageFilter:{imageFilter:"resize",w:"500",f:"webp"}}),o?e.jsx(f,{className:"footer-mask",sx:rn,children:k(P)}):e.jsx(f,{className:"mask",sx:tn,children:e.jsx(ke,{direction:"row",spacing:1,children:k(P)})})]},P.address))}),a.next||m.page>1?e.jsx(Bt,{sx:{display:"flex",justifyContent:"center",mt:2},page:m.page,onChange:g,count:Math.ceil(a.total/m.size),size:"small"}):null,e.jsx(Xr,{visible:n.visible&&!!n.nft,nft:n.nft,onClose:()=>{l({visible:!1,nft:null})}}),e.jsx(ar,{anchorEl:i.anchorEl,onClose:()=>{c({anchorEl:null,props:null})},sharedProps:i.props||{title:"",url:""}})]})},[C,a,m.page,m.size,g,i,n]);return e.jsx(f,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1,p:2,mb:5},children:R})}dt.propTypes={user:u.object.isRequired};function nn(){const{t}=D(),{user:s,isMyself:o,viewUser:n}=Ae();return e.jsxs(f,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[o?e.jsxs(f,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1.5,p:2},children:[e.jsx(I,{sx:{color:"text.primary",fontWeight:600,mb:2.5},children:t("userCenter.passport")}),e.jsx(ct,{user:s})]}):null,e.jsx(dt,{user:o?s:n})]})}const on=[{name:"English",code:"en"},{name:"中文",code:"zh"}];function ut({user:t,onSave:s}){const{t:o,changeLocale:n}=D(),l=H({locale:t.locale,loading:!1}),i=E(async c=>{try{const{value:p}=c.target;l.loading=!0,await $.user.saveProfile({locale:p}),await s("profile"),n(p),l.locale=p}catch(p){q.error(J(p))}finally{l.loading=!1}});return e.jsxs(f,{sx:{gap:1,display:"grid",alignItems:"center",gridTemplateColumns:{xs:"1fr",sm:"max-content 1fr"}},children:[e.jsx(f,{children:o("userCenter.commonSetting.locale")}),e.jsx(f,{children:e.jsx(Se,{value:l.locale,onChange:i,size:"small",IconComponent:c=>e.jsx(Xe,{...c,width:20,height:20}),sx:{minWidth:200,"&:hover":{"fieldset.MuiOutlinedInput-notchedOutline":{borderColor:"divider"}},fieldset:{borderColor:"divider"}},children:(window.blocklet.languages||on).map(c=>e.jsx(ae,{value:c.code,children:c.name},c.code))})})]})}ut.propTypes={user:u.shape({locale:u.string}).isRequired,onSave:u.func.isRequired};function Ce({onTest:t=V,onDelete:s=V,onSave:o=V,onCancel:n=V,type:l="slack",url:i="",edit:c=!1}){const{t:p}=D(),r=H({type:l||"slack",url:i||"",edit:c??!1,error:"",loading:!1}),x=E(()=>r.url?Qt(r.url)?(r.error="",!0):(r.error=p("common.invalid"),!1):(r.error=p("common.required"),!1)),m=E(()=>{r.edit=!1,r.url=i||"",r.type=l||"slack",r.error="",r.loading=!1,n()}),h=E(async a=>{r.loading=!0,await t(a),r.loading=!1}),C=E(a=>()=>{x()&&a({type:r.type,url:r.url})}),v=T(()=>r.error?e.jsx(I,{component:"span",color:"error",children:r.error}):r.edit?r.loading?e.jsx(Y,{size:16}):e.jsx(O,{size:"small",onClick:C(h),sx:{mr:-1},children:e.jsx(N,{icon:jr})}):null,[r.error,r.edit,r.loading]);return e.jsxs(f,{sx:{display:"flex",gap:1.5,width:"100%",alignItems:{xs:"flex-start",md:"center"},flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(Se,{sx:{borderRadius:1,"&.Mui-disabled":{backgroundColor:"grey.50"}},disabled:!r.edit||r.loading,size:"small",value:r.type,onChange:a=>{r.type=a.target.value},children:[e.jsx(ae,{value:"api",children:p("userCenter.webhook.url")}),e.jsx(ae,{value:"slack",children:p("userCenter.webhook.slack")})]}),e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:.5,width:"100%"},children:[e.jsx(Ve,{sx:{flex:1,".MuiInputBase-root":{borderRadius:1,"&.Mui-disabled":{backgroundColor:"grey.50"}}},disabled:!r.edit||r.loading,fullWidth:!0,size:"small",required:!0,value:r.url,onChange:a=>{r.url=a.target.value,x()},error:!!r.error,slotProps:{input:{endAdornment:e.jsx(Ye,{position:"end",children:v})}}}),e.jsx(f,{sx:{display:"flex",gap:.5},children:r.edit?e.jsxs(e.Fragment,{children:[e.jsx(O,{color:"success",onClick:C((...a)=>{o(...a),r.edit=!1}),sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(N,{icon:lr})}),e.jsx(O,{color:"error",onClick:m,sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(N,{icon:cr})})]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{onClick:()=>{r.edit=!0},sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(N,{icon:Cr})}),e.jsx(O,{color:"error",onClick:()=>{s({type:r.type,url:r.url})},sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(N,{icon:Sr})})]})})]})]})}Ce.propTypes={onTest:u.func,onDelete:u.func,onSave:u.func,onCancel:u.func,type:u.oneOf(["api","slack"]),url:u.string,edit:u.bool};function ie({title:t=void 0,description:s=void 0,value:o,onChange:n,isMobile:l}){const i=E(c=>{c.stopPropagation()});return e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(ot,{checked:o,size:"small",onChange:n}),e.jsxs(I,{component:"div",onClick:i,sx:{color:"text.primary",fontSize:14,display:"flex",flexWrap:l?"wrap":"nowrap",columnGap:1,flex:1,whiteSpace:l?"normal":"nowrap"},children:[t,s]})]})}ie.propTypes={title:u.string,description:u.node,value:u.bool.isRequired,onChange:u.func.isRequired,isMobile:u.bool.isRequired};function pt({user:t,isMobile:s}){const{t:o}=D(),n=H({showAdd:!1}),l=te(async()=>await $.user.getUserNotificationConfig(),{refreshDeps:[t],loadingDelay:300}),i=T(()=>({wallet:!0,email:!0,phone:!1,push:!0,...l?.data?.notifications||{}}),[l?.data?.notifications]),c=T(()=>l?.data?.webhooks||[],[l?.data?.webhooks]),p=E(async v=>{try{await $.user.saveUserNotificationConfig(v),q.success(o("userCenter.saveSuccess")),l.run()}catch(a){q.error(J(a))}}),r=E(async(v,a)=>{await p({notifications:{[v]:a}})}),x=async v=>{try{await $.user.testNotificationWebhook(v),q.success(o("userCenter.webhookTested"))}catch(a){q.error(J(a))}},m=E(async v=>{await p({webhooks:c.filter((a,g)=>g!==v)})}),h=E(async(v,a)=>{await p({webhooks:c.map((g,k)=>k===v?a:g)})}),C=E(async v=>{await p({webhooks:[...c,v]}),n.showAdd=!1});return l.error?e.jsx(Wt,{severity:"error",children:l.error.message}):l.loading||!l.data?e.jsx(f,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px"},children:e.jsx(Y,{})}):e.jsxs(f,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsxs(f,{sx:{display:"flex",flexDirection:"column",gap:1,alignItems:"start",".MuiFormControlLabel-root":{gap:1,m:0,flexDirection:{xs:"row-reverse",md:"row"},width:{xs:"100%",md:"unset"}},".MuiSwitch-track":{borderRadius:"100vw"},".MuiSwitch-thumb":{borderRadius:"100%"},".MuiSwitch-root.MuiSwitch-sizeSmall":{height:"20px",width:"36px",".MuiSwitch-thumb":{width:"16px",height:"16px"}}},children:[e.jsx(ie,{value:i.wallet,isMobile:s,title:o("userCenter.walletNotification"),onChange:v=>r("wallet",v.target.checked),description:Ne(t)&&e.jsx(dr,{did:Ne(t),showQrcode:!1,showAvatar:!s,copyable:!0,compact:!0,responsive:!0,startChars:s?2:6})}),e.jsx(ie,{value:i.email,isMobile:s,onChange:v=>r("email",v.target.checked),title:o("userCenter.emailNotification"),description:t?.email&&e.jsx(I,{component:"span",sx:{color:"text.secondary",fontSize:13},children:t?.email})}),e.jsx(ie,{isMobile:s,value:i.push,title:o("userCenter.pushNotification"),onChange:v=>r("push",v.target.checked)})]}),e.jsxs(ke,{spacing:1.5,useFlexGap:!0,direction:"column",sx:{alignItems:"start"},children:[c.map((v,a)=>e.jsx(Ce,{onTest:x,onDelete:()=>m(a),onSave:(...g)=>h(a,...g),type:v.type,url:v.url,edit:!1},`${a}_${v.url}`)),n.showAdd&&e.jsx(Ce,{onTest:x,onCancel:()=>{n.showAdd=!1},onSave:(...v)=>C(...v),edit:!0},"add"),e.jsx(et,{variant:"outlined",size:"small",sx:{color:"text.primary",borderColor:"divider","&:hover":{borderColor:"divider"},py:.5,borderRadius:1},startIcon:e.jsx(N,{icon:kr}),onClick:()=>{n.showAdd=!0},children:o("userCenter.addWebhook")})]})]})}pt.propTypes={user:u.object.isRequired,isMobile:u.bool.isRequired};function xt({item:t}){const s=Te(),{blocklet:o}=Xt(),{confirmApi:n,confirmHolder:l}=Re(),i=H({loading:!1}),{t:c}=D(),{session:p}=y.use(fe),{bindOAuth:r,unbindOAuth:x,setBaseUrl:m,baseUrl:h}=p.useOAuth(),{disconnectPasskey:C,setTargetAppPid:v}=p.usePasskey(),a=T(()=>ur[t?.provider]||"unknown",[t?.provider]),g=E(async()=>{if(t?.provider===M.PASSKEY){await new Promise((b,z)=>{n.open({title:c("userCenter.thirdPartyLogin.disconnectPasskey",{name:a}),content:c("userCenter.thirdPartyLogin.disconnectPasskeyDescription",{name:a}),confirmButtonText:c("common.confirm"),confirmButtonProps:{color:"error"},cancelButtonText:c("common.cancel"),onConfirm(L){C({session:p,connectedAccount:t}).then(b).catch(z),L()},onCancel:b})});return}try{i.loading=!0,await new Promise((b,z)=>{if(t?._bind)n.open({title:c("userCenter.thirdPartyLogin.confirmUnbind",{name:a}),content:c("userCenter.thirdPartyLogin.confirmUnbindDescription",{name:a}),confirmButtonText:c("common.confirm"),confirmButtonProps:{color:"error"},cancelButtonText:c("common.confirm"),onConfirm(L){x({session:p,connectedAccount:{...Gt(t,["did","pk"]),showProvider:t.provider,provider:t._rawProvider}}).then(b).catch(z),L()},onCancel:b});else if(t.provider===M.WALLET)p.bindWallet({onSuccess:b,onCancel:z});else{const L=h,F=window?.blocklet;let j="/";const S=pr(F),B=xr(F);S&&B?.appPid&&p?.user?.sourceAppPid&&(j=B.appUrl),m(j),v(o?.appPid),r({session:p,oauthItem:{...t,provider:t._rawProvider}}).then(b).catch(z).finally(()=>{m(L),v()})}})}catch(b){console.error(`Failed to ${t?._bind?"unbind":"bind"} oauth account`,b)}finally{i.loading=!1}}),k=E(b=>b.provider===M.WALLET&&b.did?c("userCenter.thirdPartyLogin.walletAccount"):b._mainProvider?c("userCenter.thirdPartyLogin.mainAccount"):b?._bind?c("userCenter.thirdPartyLogin.disconnect"):c("userCenter.thirdPartyLogin.connect")),R=E(b=>b.provider===M.WALLET&&b.did?c("userCenter.thirdPartyLogin.walletAccountCantRemove"):b.provider===M.PASSKEY?c("userCenter.thirdPartyLogin.dontSupportRemoveinArcSphere"):b._mainProvider?c("userCenter.thirdPartyLogin.mainProviderCantRemove"):""),P=E(b=>b.provider===M.WALLET&&b.did||b.provider===M.PASSKEY&&(s.arcSphere||s.wallet)?!0:!!t._mainProvider,[s.arcSphere]);return e.jsxs(e.Fragment,{children:[e.jsxs(f,{sx:{borderRadius:1,border:"1px solid",borderColor:"divider",backgroundColor:"grey.50",display:"flex",alignItems:"center",py:1,px:1.5,gap:.75,fontSize:"14px",lineHeight:1,overflow:"hidden"},children:[e.jsx(Jt,{provider:t?.provider,sx:{width:"1em",height:"1em",flexShrink:0,fontSize:16,filter:({palette:b})=>t?.provider===M.GITHUB&&b.mode==="dark"?"invert(1)":"none"}}),e.jsx(f,{sx:{flex:1,display:{xs:t.userInfo?.email||t.did?"none":"block",sm:"block"}},children:a}),t.userInfo?.email||t.did?e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:.5,overflow:"hidden"},children:[e.jsx(f,{sx:{flex:1,textOverflow:"ellipsis",overflow:"hidden",lineHeight:"normal"},children:t.userInfo?.email||t.did}),t.userInfo?.name?e.jsx(X,{title:e.jsx(e.Fragment,{children:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(tt,{size:36,variant:"circle",shape:"circle",src:t.userInfo?.picture,did:t.did}),e.jsxs(f,{children:[e.jsx(I,{sx:{whiteSpace:"normal",wordBreak:"break-all",fontSize:"0.9rem"},children:t.userInfo?.name}),e.jsx(I,{sx:{whiteSpace:"normal",wordBreak:"break-all",fontSize:"0.9rem"},children:t.userInfo?.email})]})]})}),children:e.jsx(f,{component:N,icon:er,sx:{color:"text.secondary",fontSize:16,cursor:"pointer",flexShrink:0}})}):null]}):null]}),e.jsx(X,{title:R(t),placement:"auto",children:e.jsx(f,{children:e.jsx(et,{variant:"outlined",size:"small",sx:b=>{const z=b.palette.error.main,L=b.palette.primary.main;return{color:t?._bind?z:L,borderColor:t?._bind?z:L,backgroundColor:"background.default","&:hover":{borderColor:t?._bind?z:L,backgroundColor:"action.hover"},py:.5,borderRadius:1,fontWeight:500,whiteSpace:"nowrap"}},fullWidth:!0,startIcon:i.loading?null:e.jsx(N,{icon:Pr}),onClick:g,disabled:P(t),loading:i.loading,children:k(t)})})}),l]})}xt.propTypes={item:u.shape({provider:u.string,did:u.string,pk:u.string,userInfo:u.object,id:u.string,_bind:u.bool,_rawProvider:u.string,_mainProvider:u.bool}).isRequired};function ft({user:t}){const{session:s}=y.use(fe),[o,n]=y.useState({}),{getOAuthConfigs:l}=s.useOAuth(),i=Te();sr(async()=>{const r=await l({sourceAppPid:t?.sourceAppPid});n(r)},[t?.sourceAppPid]);const c=T(()=>{const r=Object.keys(o).map(x=>({...o[x],provider:x})).filter(x=>x.enabled);return[{provider:M.WALLET,order:-1},...r,{provider:M.PASSKEY,order:1/0}]},[o]),p=T(()=>{const r=fr(t);let x=!1,m="",h=hr(t);const C=r.find(a=>a.provider===M.AUTH0);return C&&(C.id.startsWith("google-oauth2|")&&(r.some(a=>a.provider==="google")||(x=!0,m=M.GOOGLE,h===M.AUTH0&&(h=M.GOOGLE))),C.id.startsWith("appleid|")&&(r.some(a=>a.provider===M.APPLE)||(x=!0,m=M.APPLE,h===M.AUTH0&&(h=M.APPLE))),C.id.startsWith("github|")&&(r.some(a=>a.provider===M.GITHUB)||(x=!0,m=M.GITHUB,h===M.AUTH0&&(h=M.GITHUB)))),c.map(a=>{if(a.provider===M.AUTH0&&x)return null;const g=x&&a.provider===m?r.find(k=>k.provider===M.AUTH0):r.find(k=>k.provider===a.provider);return g?{...a,provider:a.provider,did:g.did,pk:g.pk,userInfo:g.userInfo,_bind:!0,_rawProvider:g.provider,_mainProvider:a.provider===h}:{...a,provider:a.provider,_rawProvider:a.provider,_mainProvider:a.provider===h}}).filter(a=>!(!a||a.provider===M.PASSKEY&&!a.did)).sort((a,g)=>a._mainProvider?-1:a?.order!==void 0&&g?.order!==void 0?a.order-g.order:a?.order!==void 0?-1:1)},[t?.connectedAccounts,c]);return e.jsxs(f,{sx:{gap:1,display:"grid",gridTemplateColumns:"1fr min-content"},children:[p.map(r=>e.jsx(xt,{item:r},r?.provider)),i.wallet||i.arcSphere?null:e.jsx(tr,{behavior:"only-new",action:"connect",createMode:"connect",createButtonText:"Add New Passkey",onSuccess:V,onError:V,dense:!0,sx:{px:1.5,py:1,gap:.75}})]})}ft.propTypes={user:u.object.isRequired};function ht({configList:t,onSave:s}){const[o,n]=y.useState(t),{t:l}=D(),i=E(async(c,p)=>{try{const r=await $.user.saveUserPrivacyConfig({[c]:!p});n(o.map(x=>({...x,value:r?.[x.key]??x.value}))),q.success(l("userCenter.saveSuccess")),s("privacy")}catch(r){q.error(J(r))}});return y.useEffect(()=>{n(t)},[t]),e.jsx(f,{sx:{display:"flex",flexDirection:"column",gap:1,alignItems:"start",".MuiFormControlLabel-root":{gap:1,m:0,flexDirection:{xs:"row-reverse",md:"row"},width:{xs:"100%",md:"unset"}},".MuiSwitch-track":{borderRadius:"100vw"},".MuiSwitch-thumb":{borderRadius:"100%"},".MuiSwitch-root.MuiSwitch-sizeSmall":{height:"20px",width:"36px",".MuiSwitch-thumb":{width:"16px",height:"16px"}}},children:o.map(c=>c.isPrivate?null:e.jsx(ot,{checked:!c.value,labelProps:{label:e.jsx(I,{sx:{color:"text.primary",fontSize:14,display:"flex",flexFlow:"wrap",columnGap:1,flex:1},children:l("userCenter.toPublic",{name:c.name})})},size:"small",onChange:p=>i(c.key,p.target.checked)},c.key))})}ht.propTypes={configList:u.arrayOf(u.shape({key:u.string.isRequired,name:u.string.isRequired,value:u.bool.isRequired,isPrivate:u.bool})).isRequired,onSave:u.func.isRequired};function gt({user:t,sessionUser:s}){const o=T(()=>(t?.passports||[])?.find(n=>n.name===s.role),[t?.passports,s?.role]);return e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(tt,{size:40,variant:"circle",shape:"circle",src:s.avatar,did:s.did,sx:{flexShrink:0}}),e.jsxs(f,{sx:{flex:1,overflow:"hidden"},children:[e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(X,{title:s.fullName,children:e.jsx(I,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1},children:s.fullName})}),e.jsx(je,{label:o?.title||o?.name||"Guest",size:"small",variant:"outlined",sx:{flexShrink:0,fontWeight:"bold",fontSize:"12px",color:"text.primary",borderColor:"grey.300",backgroundColor:"transparent",textTransform:"capitalize",pr:.5,pl:0,height:"auto"}})]}),e.jsx(X,{title:s.email,children:e.jsx(I,{variant:"body2",color:"grey",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.email})})]})]})}gt.propTypes={user:u.object.isRequired,sessionUser:u.shape({role:u.string,avatar:u.string,did:u.string,fullName:u.string,email:u.string}).isRequired};const sn=()=>Promise.resolve(""),Ge=t=>new ve(t,{browser:[[/(ArcWallet)\/([\w\.]+)/i],[ve.BROWSER.NAME,ve.BROWSER.VERSION]]}).getResult(),Ke={display:"flex",justifyContent:"flex-end",textAlign:"right"},an=new rr({concurrency:1}),Me=y.memo(({userSession:t,isMobile:s=!1})=>{const o=H({loading:!0,ipRegion:""}),{t:n}=D();return y.useEffect(()=>{an.add(async()=>{try{o.ipRegion=await sn(t.lastLoginIp)}finally{o.loading=!1}})},[o,t.lastLoginIp]),e.jsx(f,{...s&&{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1,flexWrap:"wrap"},children:o.ipRegion?e.jsxs(e.Fragment,{children:[e.jsx(I,{variant:"body2",children:o.ipRegion}),e.jsx(I,{variant:"body2",color:"grey",children:t.lastLoginIp||n("userCenter.unknown")})]}):e.jsxs(e.Fragment,{children:[e.jsx(I,{children:t.lastLoginIp||n("userCenter.unknown")}),o.loading?e.jsx(I,{variant:"body2",color:"grey",sx:{textAlign:"center"},children:e.jsx(Y,{size:12,color:"inherit"})}):null]})})});Me.propTypes={userSession:u.object.isRequired,isMobile:u.bool};Me.defaultProps={isMobile:!1};function mt({user:t,showAction:s=!0,showUser:o=!0,getUserSessions:n,showOffline:l=!1}){const i=H({status:"online",page:1,pageSize:10}),c=H({online:0,expired:0,offline:0}),p=gr(),{t:r}=D(),x=re({key:"md"}),m=xe(j=>j.breakpoints.down("lg")),{confirmApi:h,confirmHolder:C}=Re(),v=E(async()=>{const j=await n({page:i.page,pageSize:i.pageSize,status:i.status}),S=j?.paging?.total||0;return c[i.status]=S,{total:S,list:j?.list||[]}});Qe(async()=>{const j=await n({page:1,pageSize:1,status:"expired"});c.expired=j?.paging?.total||0;const S=await n({page:1,pageSize:1,status:"offline"});c.offline=S?.paging?.total||0});const a=te(v,{refreshDeps:[i.status,i.page,i.pageSize]}),g=T(()=>a.data?.list||[],[a.data?.list]),k=T(()=>{const{status:j}=i;return j==="online"?c[j]<=1:c[j]===0},[g,p]),R=T(()=>de({},x?Ke:{}),[x]),P=E(({visitorId:j})=>{h.open({title:r("userCenter.logoutThisSession"),content:r("userCenter.logoutThisSessionConfirm"),confirmButtonText:r("userCenter.confirm"),confirmButtonProps:{color:"error"},cancelButtonText:r("userCenter.cancel"),onConfirm:async()=>{await $.user.logout({visitorId:j,includeFederated:!0});const{page:S=0}=i,{list:B=[]}=a.data||{},G=B.length||0;S>1&&G===1&&(i.page=Math.max(S-1,1)),a.refresh(),h.close()}})}),b=E(()=>{h.open({title:r("userCenter.logoutAllSession",{type:r(i.status)}),content:r("userCenter.logoutAllSessionConfirm",{type:r(i.status)}),confirmButtonText:r("userCenter.confirm"),confirmButtonProps:{color:"error"},cancelButtonText:r("userCenter.cancel"),onConfirm:async()=>{await $.user.logout({status:i.status,visitorId:p,includeFederated:!0}),i.page=1,a.refresh(),h.close()}})}),z=[];s&&z.push(e.jsx(X,{title:r("userCenter.logoutAllTips",{type:r(i.status)}),children:e.jsx(_,{sx:{ml:.5},size:"small",variant:"contained",color:"error",onClick:b,disabled:k,children:r("userCenter.logoutAll",{type:r(i.status)})})},"logoutAll"));const L=T(()=>({search:!1,sort:!1,download:!1,filter:!1,print:!1,expandableRowsOnClick:!1,searchDebounceTime:600,page:i.page-1,rowsPerPage:i.pageSize,count:a.data?.total||0}),[a.data?.total,i.page,i.pageSize]),F=[{label:r("userCenter.platform"),name:"platform",options:{customBodyRenderLite:j=>{const S=g[j],B=Ge(S?.ua);return e.jsx(f,{sx:R,children:[B.os?.name,B.os?.version].filter(Boolean).join("/")||r("userCenter.unknown")})}}},{label:r("userCenter.deviceType"),name:"deviceType",options:{customBodyRenderLite:j=>{const S=g[j],B=Ge(S?.ua);return e.jsx(f,{sx:R,children:[B.browser?.name,B.browser?.version].filter(Boolean).join("/")||r("userCenter.unknown")})}}},{label:r("userCenter.walletOS"),name:"walletOS",options:{customBodyRenderLite:j=>{const S=g[j];return e.jsx(f,{sx:R,children:S.extra?.walletOS||r("userCenter.unknown")})}}},o&&{label:r("userCenter.user"),name:"user",options:{customBodyRenderLite:j=>{const S=g[j];return e.jsx(f,{sx:de({minWidth:150,maxWidth:250},x?Ke:{}),children:e.jsx(gt,{sessionUser:S.user,user:t})})}}},{label:r("userCenter.createdAt"),name:"createdAt",options:{customBodyRenderLite:j=>{const S=g[j];return e.jsx(f,{sx:R,children:S.createdAt?e.jsx(Oe,{value:S.createdAt,relativeRange:3*86400*1e3}):r("userCenter.unknown")})}}},!l&&{label:r("userCenter.updatedAt"),name:"updatedAt",options:{customBodyRenderLite:j=>{const S=g[j];return e.jsx(f,{sx:R,children:S.status==="expired"?r("userCenter.expired"):e.jsx(Oe,{value:S.updatedAt,relativeRange:3*86400*1e3})})}}},{label:r("userCenter.lastLoginIp"),name:"lastLoginIp",options:{customBodyRenderLite:j=>{const S=g[j];return e.jsx(Me,{userSession:S,isMobile:x})}}},s&&{label:r("userCenter.actions"),name:"actions",options:{customBodyRenderLite:j=>{const S=g[j];return e.jsx(f,{sx:R,children:e.jsx(_,{sx:{whiteSpace:"nowrap",fontSize:"12px !important",lineHeight:"1.25",px:1},disabled:p===S.visitorId,variant:"outlined",size:"small",color:"error",onClick:()=>P({visitorId:S.visitorId}),children:S.status==="expired"?r("userCenter.remove"):p===S.visitorId?r("userCenter.currentSession"):r("userCenter.logout")})})}}}].filter(Boolean);return e.jsxs(f,{className:"pc-user-sessions",sx:{maxWidth:x?"unset":m?"calc(100vw - 300px)":"100%",...x&&{".pc-user-sessions-table > div:nth-child(2)":{border:"1px solid",borderColor:"divider",borderRadius:1}},".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableRow-root":{border:"unset","&:nth-child(even)":{backgroundColor:"grey.50","&:hover":{backgroundColor:j=>`${j.palette.grey[50]} !important`}}},".MuiTableRow-hover":{"&:hover":{backgroundColor:"inherit !important"}},".MuiTableCell-root":{paddingRight:"8px",paddingLeft:"8px",color:"text.secondary",...x&&{padding:"8px !important","&:first-child":{paddingTop:"20px!important"},"&:last-child":{paddingBottom:"20px!important"}}}},children:[C,e.jsx(mr,{count:a.data?.total||0,data:g,columns:F,customButtons:z,options:L,loading:a.loading,className:"pc-user-sessions-table",title:e.jsxs(Dt,{row:!0,sx:{lineHeight:1,ml:1},onChange:j=>{i.status=j.target.value},children:[e.jsx(Q,{value:"online",control:e.jsx(ye,{size:"small",sx:{lineHeight:1,fontSize:0},checked:i.status==="online"}),label:e.jsxs(I,{sx:{display:"flex",alignItems:"center"},children:[r("userCenter.online"),e.jsxs(I,{component:"span",sx:{ml:.5,color:"text.secondary"},children:["(",c.online,")"]})]})}),e.jsx(Q,{value:"expired",control:e.jsx(ye,{size:"small",sx:{lineHeight:1,fontSize:0},checked:i.status==="expired"}),label:e.jsxs(I,{sx:{display:"flex",alignItems:"center"},children:[r("userCenter.expired"),e.jsxs(I,{component:"span",sx:{ml:.5,color:"text.secondary"},children:["(",c.expired,")"]})]})}),l?e.jsx(Q,{value:"offline",control:e.jsx(ye,{size:"small",sx:{lineHeight:1,fontSize:0},checked:i.status==="offline"}),label:e.jsxs(I,{sx:{display:"flex",alignItems:"center"},children:[r("userCenter.offline"),e.jsxs(I,{component:"span",sx:{ml:.5,color:"text.secondary"},children:["(",c.offline,")"]})]})}):null]}),onChange:j=>{i.page=j.page+1,i.pageSize=j.rowsPerPage}})]})}mt.propTypes={user:u.object.isRequired,showAction:u.bool,showUser:u.bool,showOffline:u.bool,getUserSessions:u.func.isRequired};function bt({onDestroySelf:t=void 0}){const{confirmHolder:s}=Re(),{t:o}=D(),{session:n}=y.use(fe),l=E(async()=>{if(!t||typeof t!="function")return;const i=n.withSecondaryAuth(t,{extraParams:{removeUserDid:n?.user?.did,input:{user:{did:n?.user?.did},teamDid:window?.blocklet?.did}},operation:"destroySelf"});try{await i(),n.logout()}catch(c){q.error(c?.message||o("userCenter.destroyMyself.error"))}});return e.jsxs(e.Fragment,{children:[e.jsx(f,{children:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"space-between",flexWrap:"wrap"},children:[e.jsxs(f,{children:[e.jsx(I,{variant:"h6",sx:{fontSize:"0.875rem !important",fontWeight:"bold"},children:o("userCenter.dangerZone.deleteAccount")}),e.jsx(I,{variant:"caption",sx:{color:"text.secondary"},children:o("userCenter.dangerZone.deleteAccountDescription")})]}),e.jsx(_,{variant:"contained",color:"error",size:"small",onClick:l,children:o("userCenter.dangerZone.delete")})]})}),s]})}bt.propTypes={onDestroySelf:u.func};function ln(){const t=re({key:"md"}),s=xe(l=>l.breakpoints.down("lg")),o={display:"flex",justifyContent:"flex-end",flexWrap:"wrap",textAlign:"right","&.expired-at > div":{maxWidth:160,justifyContent:"flex-end",flexWrap:"wrap"}},n=T(()=>de({},t?o:{}),[t]);return e.jsx(f,{id:"user-center-access-key-setting",sx:{maxWidth:t?"unset":s?"calc(100vw - 300px)":"100%",...t&&{".pc-access-key-table > div:nth-child(2)":{border:"1px solid",borderColor:"divider",borderRadius:1}},".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableRow-root":{border:"unset","&:nth-child(even)":{backgroundColor:"grey.50","&:hover":{backgroundColor:l=>`${l.palette.grey[50]} !important`}}},".MuiTableRow-hover":{"&:hover":{backgroundColor:"inherit !important"}},".MuiTableCell-root":{paddingRight:"8px",paddingLeft:"8px",color:"text.secondary",...t&&{padding:"8px !important","&:first-child":{paddingTop:"20px!important"},"&:last-child":{paddingBottom:"20px!important"}}}},children:e.jsx(Tr,{isSelf:!0,columnSx:n})})}function yt({onDestroySelf:t=void 0,userCenterTabs:s=[]}){const{t:o}=D(),{user:n,session:l,isMyself:i,isOwner:c}=Ae(),r=Te().arcSphere,x=re({key:"md"}),m=te(async()=>n&&i?await $.user.getUserPrivacyConfig({did:n.did}):null,{refreshDeps:[n,i],loadingDelay:300}),h=T(()=>s.map(a=>({key:a.value,name:a.label,value:a.protected,isPrivate:a.isPrivate})),[s]),C=E(async a=>a==="privacy"?(await m.runAsync(),m.data):(a==="profile"&&await l.refresh(),null));y.useEffect(()=>{const a=window.location.hash.slice(1);a&&document.getElementById(a)?.scrollIntoView({behavior:"smooth"})},[]);const v=T(()=>[r?void 0:{label:o("userCenter.commonSetting.title"),value:"common",content:e.jsx(ut,{user:n,onSave:C})},{label:o("userCenter.notificationManagement"),value:"notification",content:e.jsx(pt,{user:n,isMobile:x})},{label:o("userCenter.thirdPartyLogin.title"),value:"thirdPartyLogin",content:e.jsx(ft,{user:n})},{label:o("common.accessKeys"),value:"accessKeys",content:e.jsx(ln,{isSelf:!0})},{label:o("common.mcpServers"),value:"mcpServers",content:e.jsx(Ir,{})},{label:o("userCenter.privacyManagement"),value:"privacy",content:e.jsx(ht,{configList:h,onSave:C})},{label:o("userCenter.sessionManagement"),value:"session",content:e.jsx(mt,{user:n,showUser:!1,getUserSessions:a=>$.userSession.getMyLoginSessions({},a)})},!c&&t&&typeof t=="function"?{label:o("userCenter.dangerZone.title"),value:"dangerZone",content:e.jsx(bt,{onDestroySelf:t}),sx:{borderColor:"error.main"}}:null].filter(Boolean),[n,h,x,c,t]);return i?e.jsx(f,{className:"user-center-settings",sx:{display:"flex",flexDirection:"column",gap:2.5,minWidth:{md:500},"@media (min-width: 1200px) and (max-width: 1260px)":{maxWidth:750},"@media (min-width: 1100px) and (max-width: 1199px)":{maxWidth:650},"@media (min-width: 1000px) and (max-width: 1099px)":{maxWidth:600},"@media (max-width: 1049px)":{maxWidth:"100%"}},children:v.map(a=>a?e.jsxs(f,{id:a.value,sx:de({border:"1px solid",borderColor:"divider",borderRadius:1,p:2,"&:last-child":{mb:5}},a.sx),children:[e.jsx(I,{sx:{color:"text.primary",fontWeight:600},children:a.label}),e.jsx(f,{sx:{mt:2.5},children:a.content})]},a.value):null)}):null}yt.propTypes={onDestroySelf:u.func,userCenterTabs:u.array};const vt=y.createContext({}),{Provider:cn,Consumer:ao}=vt;function wt({children:t}){const[s]=y.useState(!1),{session:o}=y.use(fe),{user:n}=o,[l,i]=y.useState(),c=y.useMemo(()=>n?.didSpace?.endpoint,[n?.didSpace]);y.useEffect(()=>{i(n?.didSpace)},[n?.didSpace]);const p=async()=>{i(void 0)},r=h=>{},x=async h=>{i(h),await r(h.endpoint)},m=!!(c&&l);return e.jsx(cn,{value:{loading:s,spaceGateway:l,session:o,deleteSpaceGateway:p,updateSpaceGateway:x,storageEndpoint:c,settingStorageEndpoint:r,hasStorageEndpoint:m},children:t})}function ze(){return y.use(vt)}wt.propTypes={children:u.node.isRequired};function dn(t){const s=t.replace(/\/api\/space\/.+/,""),n=t.replace(/\/$/,"").split("/").at(-4);return ce(s,"space",n)}function jt({session:t,spaceGateway:s,spaceStatus:o,refresh:n}){return e.jsxs(ke,{direction:"row",spacing:1,children:[o===Mr.DISCONNECTED&&e.jsx(ue,{reconnect:!0,variant:"outlined",session:t,spaceDid:t.user?.didSpace?.did,spaceGatewayUrl:t.user?.didSpace?.url,connectScope:"user",onSuccess:async()=>{await n()},onError:l=>{console.error(l),q.error(J(l))}}),e.jsx(O,{size:"small",LinkComponent:Nt,href:dn(s.endpoint),target:"_blank",children:e.jsx(Ot,{})})]})}jt.propTypes={session:u.object.isRequired,spaceGateway:u.object.isRequired,spaceStatus:u.string.isRequired,refresh:u.func.isRequired};function Ct({spaceGateway:t=void 0}){const{t:s}=D(),{updateSpaceGateway:o,session:n}=ze(),l=re(),i=({spaceGateway:c})=>o(c);return e.jsxs(f,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(f,{sx:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[e.jsx(I,{sx:{fontSize:"16px",fontWeight:"bold"},children:s("userCenter.storage.spaces.connected.title")}),!l&&e.jsx(ue,{connectScope:"user",connectText:s("userCenter.storage.spaces.connected.switch"),session:n,onSuccess:i})]}),e.jsx(f,{children:t&&e.jsx(zr,{endpoint:t.endpoint,deps:[t],selected:!0,footer:!0,action:c=>e.jsx(jt,{session:n,...c})},t.endpoint)}),l&&e.jsx(f,{sx:{display:"flex",alignItems:"center",justifyContent:"center",marginTop:2},children:e.jsx(ue,{connectScope:"user",connectText:s("userCenter.storage.spaces.connected.switch"),session:n,onSuccess:i})})]})}Ct.propTypes={spaceGateway:u.object};function un(){const{t}=D(),{updateSpaceGateway:s,session:o}=ze(),n=({spaceGateway:l})=>s(l);return e.jsxs(f,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(I,{sx:{fontSize:"16px",fontWeight:"bold"},children:t("userCenter.storage.spaces.connect.providerForStorage")}),e.jsx(Er,{viewBox:"0 0 228 258",style:{width:"156px",height:"156px",margin:"16px 0"}}),e.jsx(f,{children:e.jsx(ue,{session:o,onSuccess:n})})]})}function pn(){const{spaceGateway:t,hasStorageEndpoint:s,loading:o}=ze(),{isMyself:n}=Ae();return n?o?e.jsx(Ar,{relative:"parent",children:e.jsx(Y,{})}):e.jsx(fn,{children:e.jsx(f,{sx:{maxWidth:"720px"},children:s?e.jsx(Ct,{spaceGateway:t}):e.jsx(un,{})})}):null}function xn(){return e.jsx(wt,{children:e.jsx(pn,{})})}const fn=ee(f)`
122
- height: 100%;
123
- overflow-y: auto;
124
- `;function lo(){const{api:t}=nr(),s=y.useRef(null),n=Ut().tab,i=new URLSearchParams(window.location.search).get("embed")||window.sessionStorage?.getItem("embed"),c=or(),p=T(()=>({...window.blocklet,meta:{did:window.blocklet.did,name:window.blocklet.did},children:window?.blocklet?.componentMountPoints.map(x=>({...x,meta:{...x,did:x.did,name:x.name||x.title||"",logo:"logo.png"}}))})),r=async x=>{const{input:m,sessionId:h}=x;try{await t.destroySelf({input:{...m,sessionId:h}})}catch(C){console.error("destroy myself error",C)}};return e.jsx(vr,{children:e.jsxs(Rr,{ref:s,embed:i==="1",currentTab:n?ce(Pe.WELLKNOWN_SERVICE_PATH_PREFIX,"user",n):"",disableAutoRedirect:n==="settings",children:[n==="notifications"?e.jsx(Qr,{blocklets:[p],context:c}):null,n==="nfts"?e.jsx(nn,{}):null,n==="settings"?e.jsx(yt,{onDestroySelf:r}):null,n==="did-spaces"?e.jsx(xn,{}):null]})})}export{lo as default};
@@ -1,113 +0,0 @@
1
- import{g as Wt,r as v}from"./vendor-react-Dvs43sk9.js";import{j as e,ak as y,z as Q,b6 as me,be as Ke,y as V,am as ut,d1 as Bt,bm as Kt,at as ae,b1 as mt,W as h,T as ee,U as Ye,d2 as pt,b5 as qe,a5 as Me,Q as Fe,d3 as Ge,aN as Ue,a6 as ft,D as ht,d4 as qt,ad as xt,d5 as Mt,d6 as Ut,c1 as st,n as Ht,x as $t,bb as Vt,M as it,cz as Yt,I as Gt,d7 as Jt}from"./vendor-mui-core-DV92LEhm.js";import{A as gt,J as Xt,C as Qt,e as le,F as Zt,a4 as je}from"./vendor-utils-CddrUZ58.js";import{T as te,H as M,n as ce,c as en,j as bt,a2 as tn,at as nn,m as jt,$ as vt,L as yt,au as Oe,b as St,C as sn,Z as an}from"./vendor-ux-C9Q7otQi.js";import{aC as rn,Y as Je,a7 as Ct,aR as Rt,K as _e,c as _,an as Z,p as on,aL as at}from"./index-CBuBVmWe.js";import{g as ye,b as $,a as se}from"./vendor-hooks-9cd36rYd.js";import{u as wt,C as J}from"./index.esm-JPZAjt0x.js";import{i as He}from"./isURL-BZcSl4qG.js";import{S as X}from"./section-D4T7FV6C.js";import{A as ln,a as cn,b as dn}from"./collapse-XWrflTSv.js";import{S as Se}from"./shorten-label-BfHH-3ih.js";import{v as Tt}from"./index-CV12n3b0.js";import{R as Nt,A as un,S as mn,a as pn,B as fn}from"./list-DFvUHI6u.js";import{j as hn,c as xn,N as gn}from"./team-C8yfeoct.js";import{W as bn}from"./did-address-CY4nLJqm.js";import{p as It}from"./util-Dceeaiqy.js";import{D as jn,g as vn}from"./traffic-BjVQYor-.js";import{B as Et}from"./bundle-avatar-VT8FLC3N.js";import{u as yn}from"./use-mobile-BcHeqFSk.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-D_Dm09bZ.js";import"./required-2qxcR9JF.js";import"./server-logo-notext.svg-CKQB0tIp.js";import"./index-CX5AEYFR.js";import"./session-DW40g2df.js";import"./use-app-logo-pyV6ZPrc.js";import"./base32-rvunYmjt.js";import"./useAsyncRetry-BmdG-NgH.js";import"./useAsync-BrjQTmBf.js";import"./iframe-yWzH7Y70.js";import"./index-OkiS9ggb.js";import"./index-DBs9Ljax.js";import"./base-chart-CBzZ3RX9.js";import"./index-DHaiY3PI.js";import"./vendor-mui-x-8McV6Pkb.js";import"./AdapterDayjs-DQyL5DVQ.js";var Te={exports:{}},Ne={exports:{}},Ie={exports:{}},rt;function Sn(){return rt||(rt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=t;function t(r){return r==null}n.exports=s.default,n.exports.default=s.default}(Ie,Ie.exports)),Ie.exports}var ot;function Cn(){return ot||(ot=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=u;var t=o(rn()),r=o(Sn());function o(p){return p&&p.__esModule?p:{default:p}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,b=/^[-+]?[0-9]+$/;function u(p,i){(0,t.default)(p),i=i||{};var N=i.allow_leading_zeroes===!1?l:b,I=!i.hasOwnProperty("min")||(0,r.default)(i.min)||p>=i.min,S=!i.hasOwnProperty("max")||(0,r.default)(i.max)||p<=i.max,j=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||p<i.lt,E=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||p>i.gt;return N.test(p)&&I&&S&&j&&E}n.exports=s.default,n.exports.default=s.default}(Ne,Ne.exports)),Ne.exports}var lt;function Rn(){return lt||(lt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=o;var t=r(Cn());function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,t.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=s.default,n.exports.default=s.default}(Te,Te.exports)),Te.exports}var wn=Rn();const Tn=Wt(wn),ze={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Nn(){const{api:n}=Je(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=Rt(),l=s?.meta?.did,b=Object.assign({...ze},s?.settings?.notification?.email||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=wt({defaultValues:gt(b,Object.keys(ze))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(a,T,k=!0)=>{try{const{blocklet:D}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),re=Object.assign({...ze},D?.settings?.notification?.email||{});I(re),k&&M.success(t("oauth.saveSuccess"))}catch(D){if(k)M.error(D.message||t("oauth.saveFailed"));else throw D}}),Y=$(async(a,T,k)=>{try{i.isDirty&&await E(a,T,!1),await n.sendEmail({input:{did:l,receiver:k,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),M.success(t("notification.email.testSuccess"))}catch(D){M.error(D.message||t("notification.email.testfailed"))}}),z=$((a,T)=>{S.testReceiver="",S.testReceiverError="",r.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(y,{sx:{width:"300px"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:S.testReceiver,onChange:k=>{S.testReceiver=k.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(k){const D=S.testReceiver?.trim();if(!D){S.testReceiverError=t("notification.email.receiverRequired");return}if(!_e(D)){S.testReceiverError=t("notification.email.receiverInvalid");return}S.testReceiverError="",await Y(a,T,D),k()}})}),F=$(a=>{const T=a?.trim();return T?_e(T)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),B=$(a=>{const T=a?.trim();return T?He(T,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),R=$(a=>a?Tn(a)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),K=$(a=>a?.trim()?!0:t("notification.email.userRequired")),q=$(a=>a?.trim()?!0:t("notification.email.passwordRequired")),f=$(a=>a?.trim()&&!He(a,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),w=$(a=>a?.trim()&&!_e(a)?t("notification.email.emailInvalid"):!0),C=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(In,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.email.enable"),my:2.5,children:e.jsx(J,{name:"enabled",control:p,render:({field:a})=>e.jsx(me,{control:e.jsx(Ke,{checked:a.value,...a})})})}),e.jsx(X,{title:t("notification.email.from"),children:e.jsx(J,{name:"from",control:p,rules:{validate:j?F:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[a.name],helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.host"),children:e.jsx(J,{name:"host",control:p,rules:{validate:j?B:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.host"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.port"),children:e.jsx(J,{name:"port",control:p,rules:{validate:j?R:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:t("notification.email.port"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.user"),children:e.jsx(J,{name:"user",control:p,rules:{validate:j?K:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.user"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.password"),children:e.jsx(J,{name:"password",control:p,rules:{validate:j?q:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:t("notification.email.password"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.secure"),children:e.jsx(J,{name:"secure",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(me,{control:e.jsx(Ke,{checked:a.value,...a,disabled:!j})})})})}),e.jsxs(ln,{children:[e.jsxs(cn,{expandIcon:e.jsx(Kt,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(ut,{title:t("notification.email.signatureTooltip"),children:e.jsx(Bt,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(dn,{children:[e.jsx(X,{title:t("notification.email.companyName"),children:e.jsx(J,{name:"companyName",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyName"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyLink"),children:e.jsx(J,{name:"companyLink",control:p,rules:{validate:j?f:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyLink"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyAddress"),children:e.jsx(J,{name:"companyAddress",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyAddress"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.supportEmail"),children:e.jsx(J,{name:"supportEmail",control:p,rules:{validate:j?w:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:t("notification.email.supportEmail"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})})]})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const In=ae(mt)``,We={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function En(){const{api:n}=Je(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=Rt(),l=s?.meta?.did,b=Object.assign({...We},s?.settings?.notification?.pushKit||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=wt({defaultValues:gt(b,Object.keys(We))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(R,K,q=!0)=>{try{const{blocklet:f}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:R})}}),w=Object.assign({...We},f?.settings?.notification?.pushKit||{});I(w),q&&M.success(t("oauth.saveSuccess"))}catch(f){if(q)M.error(f.message||t("oauth.saveFailed"));else throw f}}),Y=$(async(R,K)=>{try{i.isDirty&&await E(R,K,!1);const q=(s?.configs||[]).find(C=>C.key==="BLOCKLET_APP_URL")?.value,f=Xt(Qt(q,_.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),w={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:f}}}};await n.sendPush({input:{did:l,receiver:S.testReceiver,notification:JSON.stringify(w)}}),M.success(t("notification.pushKit.testSuccess"))}catch(q){M.error(q.message||t("notification.pushKit.testfailed"))}}),z=$((R,K)=>{S.testReceiverError="",r.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(y,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:S.testReceiver,onChange:q=>{S.testReceiver=q.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(q){if(!S.testReceiver?.trim()){S.testReceiverError=t("notification.pushKit.receiverRequired");return}S.testReceiverError="",await Y(R,K),q()}})}),F=$(R=>{const K=R?.trim();return K?He(K)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),B=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(An,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(J,{name:"enabled",control:p,render:({field:R})=>e.jsx(me,{control:e.jsx(Ke,{checked:R.value,...R})})})}),e.jsx(X,{title:t("notification.pushKit.endpoint"),children:e.jsx(J,{name:"endpoint",control:p,rules:{validate:j?F:B},render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})})}),e.jsxs(X,{title:t("notification.pushKit.customOptions"),children:[e.jsx(J,{name:"did",control:p,render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})}),e.jsx(J,{name:"pushPath",control:p,render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const An=ae(mt)``,ct=[{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function On(){const[n,s]=v.useState(ct[0].value),{locale:t}=v.useContext(en),r=se(()=>({email:e.jsx(Nn,{}),pushKit:e.jsx(En,{})}),[t]),o=v.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(y,{children:[e.jsx(bt,{tabs:ct,current:n,onChange:s}),e.jsx(y,{style:o,children:r[n]})]})}const At=v.createContext({}),{Provider:kn,Consumer:Ws}=At;function Dn({children:n,blocklet:s=""}){const{api:t,inService:r,ws:{useSubscription:o}}=Je(),[l,b]=v.useState([]),[u,p]=v.useState({total:0,pageSize:20,pageCount:0,page:1}),i=se(()=>s.meta?.did,[s]),[N,I]=v.useState([]),[S,j]=v.useState({}),E=se(()=>l.length?new Set(l.map(f=>f.id)):new Set,[l]),Y=async({page:f=1,pageSize:w=20,...C}={})=>{if(!i)return[];try{const a={paging:{page:f,pageSize:w},...C,teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0},{dids:T,...k}=a;let D="";T&&T.includes("system")&&(D="system");const re=T?T.filter(pe=>pe!=="system"):[],ue={...k,source:D,componentDids:re},oe=await t.getNotificationSendLog({input:ue});return j(ue),b(oe.list),p(oe.paging),oe.list}catch(a){return M.error(a.message),[]}},z=async()=>{const f=await t.getNotificationComponents({input:{teamDid:i}});I(f.componentDids)},F=v.useCallback(f=>{const w=s.children.find(C=>C.meta?.did===f);if(w)return w.ancestors=[s],w},[s]),B=async({notificationId:f,receivers:w,channels:C,...a})=>{await t.resendNotification({input:{teamDid:i,notificationId:f,receivers:w,channels:C.map(T=>T==="wallet"?_.NOTIFICATION_SEND_CHANNEL.WALLET:T==="pushKit"?_.NOTIFICATION_SEND_CHANNEL.PUSH:T),...a}})},R=v.useCallback(async f=>(await t.getUser({input:{teamDid:i,user:{did:f}}})).user,[t,i]),K=v.useCallback(async({page:f=1,pageSize:w=20,...C}={})=>{try{const a={paging:{page:f,pageSize:w},...C,userName:C.searchText||"",teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0};return await t.getReceivers({input:a})}catch(a){throw M.error(a.message),a}},[t,i]);v.useEffect(()=>{i&&z()},[i]),o(_.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,f=>{E.has(f.notificationId)&&Y(S)},[E,S]),o(_.EVENTS.NOTIFICATION_BLOCKLET_CREATE,f=>{E.has(f.id)||Y(S)},[E,S]);const q={fetch:Y,data:l,paging:u,blocklet:s,getComponent:F,resendNotification:B,getUser:R,componentDids:N,getReceivers:K,inService:r,teamDid:i};return e.jsx(kn,{value:{notificationRecords:q},children:n})}function Xe(){const{notificationRecords:n}=v.useContext(At);return n}Ce.propTypes={severity:h.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ln={info:"primary",success:"success",error:"error",warning:"warning"};function Ce({severity:n="info"}){return e.jsx(tn,{type:Ln[n],children:n})}const Pn=(n,s,t="")=>{if(!t||!s)return"";switch(t){case _.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return t}};function Ot(n,s,t={}){const{status:r,updatedAt:o,reason:l="",channel:b="wallet"}=t,u=o?n("notification.sendStatus.sentTime",{date:on(o,s)}):"",p=Pn(n,b,l);return r===_.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:u,reason:p}:r===_.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:u}:{status:"pending",title:n("notification.sendStatus.pending"),reason:p,sentTime:u}}const $e={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ve=["wallet","pushKit","email"],dt=["info","success","error","warning"],kt=n=>{const{settings:s}=n;return s?.notification?.email?.enabled},Dt=n=>{const{settings:s}=n;return s?.notification?.pushKit?.enabled},Fn=(n,s)=>{const t=le(s,"extra.notifications.email",!0);return{available:kt(n),enabled:t}},_n=(n,s)=>{const t=le(s,"extra.notifications.push",!0);return{available:Dt(n),enabled:t}},zn=n=>({enabled:le(n,"extra.notifications.wallet",!0)}),Wn=n=>({enabled:le(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(s=>{setTimeout(()=>{s()},n*1e3)}),Bn=(n,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:n("notification.sendStatus.reason.available",{channel:s}),fail:n("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:[],Ae=(n=[])=>{const s=Z().startOf("day");return n.filter(t=>Z(t.sendAt).isSame(s,"day")).length},Kn=(n,s="")=>{if(s&&Ve.includes(s)){const l=`${s}SendRecord`,b=le(n,l,[]);return Ae(b)}const t=le(n,"webhook",{}),r=Object.keys(t??{})??[];if(s&&r.includes(s)){const l=t[s]??[];return Ae(l)}const o={};return Ve.forEach(l=>{const b=`${l}SendRecord`,u=le(n,b,[]),p=Ae(u);o[l]=p}),r.length>0&&r.forEach(l=>{const b=t[l]??[],u=Ae(b);o[l]=u}),o},ke=(n,s,t)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[t].splice(s,1),n},De=(n,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(n):!1},qn=n=>{switch(n){case _.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case _.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case _.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case _.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:s=!0,showTitle:t=!1,children:r=null}){const{status:o,title:l="",sentTime:b="",reason:u=""}=n,p=[l,u].filter(Boolean).join(", ");return e.jsx(ut,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:p}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(y,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(y,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:$e[o]}}),e.jsx(y,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:$e[o]}})]}),e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:t?l:r})]})})}de.propTypes={config:h.object.isRequired,enableTooltip:h.bool,showTitle:h.bool,children:h.node};Le.propTypes={list:h.array.isRequired,label:h.string.isRequired,onDelete:h.func};function Le({list:n,label:s,onDelete:t=()=>{}}){const{t:r,locale:o}=te();return e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),n.map(l=>{const b=Ot(r,o,{status:l});return e.jsx(Ye,{size:"small",label:e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(de,{config:b,enableTooltip:!1,children:b.title})}),onDelete:u=>t(u,l)},l)})]})}Qe.propTypes={filterList:h.array.isRequired,onChange:h.func.isRequired,index:h.number.isRequired,column:h.object.isRequired,filterValues:h.array.isRequired,label:h.string.isRequired,renderLabel:h.func.isRequired};function Qe({filterList:n,onChange:s,index:t,column:r,filterValues:o,label:l,renderLabel:b}){return e.jsxs(V,{className:"filter-container",children:[e.jsx(pt,{component:"legend",children:l}),e.jsx(qe,{row:!0,children:o.map(u=>e.jsx(me,{control:e.jsx(Me,{checked:n[t].indexOf(u.value??u)>-1,onChange:p=>{const i=[...n];p.target.checked?i[t]=[...i[t],u.value??u]:i[t]=i[t].filter(N=>N!==(u.value??u)),s(i[t],t,r)},name:u.value??u}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(u)})},u.value??u))})]})}function Be(n){return e.jsx(Qe,{...n,renderLabel:s=>e.jsx(de,{enableTooltip:!1,config:{status:s.status},children:s.label})})}xe.propTypes={status:h.number.isRequired,updatedAt:h.string.isRequired,reason:h.string,channel:h.string,onResend:h.func};function xe({status:n,updatedAt:s,reason:t="",channel:r="wallet",onResend:o}){const{t:l,locale:b}=te(),u=Ot(l,b,{status:n,updatedAt:s,reason:t,channel:r});return e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(de,{config:u,showTitle:!0}),u.status!=="success"&&e.jsx(Fe,{className:"resend-btn",size:"small",startIcon:e.jsx(Ge,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}Ze.propTypes={value:h.array.isRequired,onChange:h.func};function Ze({value:n,onChange:s}){const{locale:t}=te(),r=Z().toDate(),[o,l]=v.useState(null),b=v.useCallback(i=>{l(o?null:i.currentTarget)},[o]),u=!!o,p=v.useCallback(i=>{if(!i.startDate||!i.endDate){M.error("Please select a date range");return}if(Z(i.startDate).isAfter(i.endDate)||!Z(i.startDate).isValid()||!Z(i.endDate).isValid()){M.error("Invalid date range");return}s([i.startDate,i.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(ee,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Fe,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[at(n[0],t)," - ",at(n[1],t)]})}),e.jsx(Ue,{open:u,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(jn,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:b,definedRanges:vn(r),onChange:p})})]})}et.propTypes={itemComponent:h.elementType.isRequired};function et({itemComponent:n,...s}){const{t}=te();return!s?.filterList?.filter(o=>o.length).length?null:e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:t("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(nn.TableFilterList,{...s,ItemComponent:n})})]})}function tt({label:n,onDelete:s,canDelete:t=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let l=!0;return t&&typeof t=="function"&&(l=t({label:n,...r})),e.jsx(Ye,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}tt.propTypes={label:h.string.isRequired,onDelete:h.func,canDelete:h.func};const Mn=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];Pt.propTypes={loading:h.bool,onCancel:h.func,onConfirm:h.func};function Pt({loading:n=!1,onCancel:s=()=>{},onConfirm:t=()=>{}}){const{t:r}=te(),[o,l]=v.useState(Mn),[b,u]=v.useState(!0),p=(N,I)=>{I.checked=N.target.checked;const S=o.map(j=>({...j,checked:j.value===I.value?I.checked:j.checked}));l(S)},i=N=>{N.stopPropagation(),t({channels:o.filter(I=>I.checked).map(I=>I.value),isResendFailedOnly:b})};return e.jsxs(y,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ee,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(y,{className:"choose-channel",children:e.jsxs(V,{component:"fieldset",variant:"standard",children:[e.jsx(pt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(qe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(N=>e.jsx(me,{control:e.jsx(Me,{checked:N.checked,onChange:I=>p(I,N),name:N.value}),label:N.label},N.value))})]})}),e.jsx(y,{className:"resend-config-footer",children:e.jsx(qe,{children:e.jsx(me,{control:e.jsx(Me,{checked:b,onChange:N=>u(N.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(y,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Fe,{onClick:N=>{N.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Fe,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(ft,{size:16}),r("common.confirm")]})]})]})}Ft.propTypes={notificationId:h.string.isRequired,handleResend:h.func,resending:h.bool};function Ft({notificationId:n,handleResend:s,resending:t=!1}){const{t:r,locale:o}=te(),l=ht(),b=v.useMemo(()=>jt(l,Lt()),[l]),{getReceivers:u,inService:p,teamDid:i,getUser:N,blocklet:I}=Xe(),[S,j]=v.useState(!1),[E,Y]=v.useState([]),z=ye({anchorEl:null,position:null}),F=ye({anchorEl:null,position:null}),[B,R]=v.useState(null),[K,q]=v.useState({total:0,pageSize:10,pageCount:0,page:1}),[f,w]=v.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),[C,a]=v.useState([]),T=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],k=async()=>{if(!S&&n)try{j(!0);const c=await u({notificationId:n,...f}),d=c.list.map(m=>({...m,receiverUser:{...m.receiverUser,avatar:It(m.receiverUser.avatar,i,p)}}));Y(d),q(c.paging),j(!1)}catch(c){M.error(c.message),j(!1)}};v.useEffect(()=>{k()},[f]);const D=c=>{c.stopPropagation();const d=c.currentTarget;F.anchorEl=d;const m=d.getBoundingClientRect();F.position={top:m.top+window.scrollY,left:m.left+window.scrollX}},re=c=>c.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(ce,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Ge,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:D,children:r("notification.resend")})}):null,ue={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:K.page-1,rowsPerPage:K.pageSize,count:K.total,searchText:f.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:C,onRowSelectionChange:(c,d)=>{a(d.map(m=>m.dataIndex))},customToolbarSelect:re},oe=({page:c,rowsPerPage:d,searchText:m,filterList:O})=>{const[,U=[],ne=[],G=[]]=O;f.pageSize!==d?w(H=>({...H,pageSize:d,page:1})):f.page!==c+1?w(H=>({...H,page:c+1})):f.searchText!==m?w(H=>({...H,searchText:m,page:1})):je(U,f.walletSendStatus)?je(ne,f.pushKitSendStatus)?je(G,f.emailSendStatus)||w(H=>({...H,emailSendStatus:G,page:1})):w(H=>({...H,pushKitSendStatus:ne,page:1})):w(H=>({...H,walletSendStatus:U,page:1}))},pe=v.useCallback(async(c,d)=>{if(!d)return!1;const m=await N(d);return m?c==="wallet"?zn(m):c==="email"?Fn(I,m):c==="pushKit"?_n(I,m):c==="webhook"?Wn(m):!0:!1},[N,I]),Re=v.useCallback(c=>Bn(r,c),[r]),fe=()=>{z.anchorEl=null,z.position=null,R(null)},he=()=>{F.anchorEl=null,F.position=null},g=async(c,d,m=!0,O="")=>{if(!(!d.length||!c.length))try{s(c,d,m,O),F.anchorEl||(await Ee(.5),fe())}catch(U){console.error("handleResend error",{error:U})}},x=async({channels:c,isResendFailedOnly:d})=>{const m=C.map(O=>E[O].receiver);await g(c,m,d),await Ee(.5),he(),a([])},A=async(c,d=[],m=!0)=>{try{await g(["webhook"],[c.receiver],m,d)}catch(O){M.error(O.response?O.response.statusText:O.message)}},L=async(c,d,m,O=[],U=!0)=>{if(c.stopPropagation(),Kn(d,m)>=4){M.warning(r("notification.resendLimit"));return}if(!Ve.includes(m)){await A(d,O,U);return}if(c){const G=c.currentTarget,H=G.getBoundingClientRect();z.anchorEl=G,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}R({channel:m});try{const G=await pe(m,d.receiver);await Ee(1),R({channel:m,result:G}),(typeof G=="boolean"&&G||Zt(G)&&Object.values(G).every(H=>!!H))&&(await s([m],[d.receiver],U),F.anchorEl||(await Ee(.5),fe()))}catch(G){M.error(G.message)}},W=c=>{w(d=>({...d,dateRange:c,page:1}))},P=(c,d,m,O)=>{c.stopPropagation();const U=m.filter(ne=>ne!==d);w(ne=>({...ne,[O]:U,page:1}))},ie=se(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:c=>{const{receiverUser:d,receiver:m}=E[c];return d?e.jsxs(y,{"data-cy":`member-name-${d.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(vt,{src:`${d.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:m,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Se,{children:d.fullName})]},m):e.jsx(bn,{size:14,responsive:!1,compact:!0,copyable:!1,did:m})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:f.walletSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Wallet",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[1].options.filterList,"walletSendStatus")}}),update:ke},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,O)=>e.jsx(Be,{label:"Wallet",filterList:c,onChange:d,index:m,column:O,filterValues:T})},customBodyRenderLite:c=>{const{walletSendStatus:d,walletSendAt:m,walletSendFailedReason:O}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:O,channel:"wallet",onResend:U=>L(U,E[c],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{pushKitSendStatus:d,pushKitSendAt:m,pushKitSendFailedReason:O}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:O,channel:"pushkit",onResend:U=>L(U,E[c],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:f.pushKitSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Push Kit",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[2].options.filterList,"pushKitSendStatus")}}),update:ke},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,O)=>e.jsx(Be,{label:"Push Kit",filterList:c,onChange:d,index:m,column:O,filterValues:T})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{emailSendStatus:d,emailSendAt:m,emailSendFailedReason:O}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:O,channel:"email",onResend:U=>L(U,E[c],"email",[],!1)})},filter:!0,filterType:"custom",filterList:f.emailSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Email",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[3].options.filterList,"emailSendStatus")}}),update:ke},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,O)=>e.jsx(Be,{label:"Email",filterList:c,onChange:d,index:m,column:O,filterValues:T})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{webhook:d}=E[c];if(!d)return null;const m=Object.entries(d)[0];if(!m)return null;const[O,U]=m,ne=U[0];return e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(y,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(Se,{maxLength:30,children:O},O),e.jsx(xe,{status:ne.status,updatedAt:ne.sendAt,reason:ne.failedReason,channel:"webhook",onResend:G=>L(G,E[c],"webhook",[O],!1)})]},O)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:c=>{const{createdAt:d}=E[c];return e.jsx(Nt,{value:d,locale:o,shouldUpdate:!0})}}}],[E,o,f,r]),we=[e.jsx(Ze,{value:f.dateRange,onChange:W},"date-picker"),e.jsx(ce,{variant:"contained",size:"small",color:"primary",loading:S,startIcon:e.jsx(qt,{}),onClick:()=>k(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(y,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(Hn,{children:e.jsxs(xt,{theme:b,children:[e.jsx(yt,{className:"receivers-table",locale:o,loading:S,columns:ie,data:E,onChange:oe,options:ue,customButtons:we,components:{TableFilterList:c=>e.jsx(et,{...c,itemComponent:d=>e.jsx(tt,{...d,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Ue,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:fe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs($n,{children:[e.jsxs(ee,{variant:"body1",component:"div",className:"check-title",children:[B?.channel," Checking"]}),e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Re(B?.channel).map(c=>{const{type:d,pass:m,fail:O}=c;return!B?.result||B?.result?.[d]?e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:B?.result?.[d]?Oe.success.main:"inherit"},children:[B?.result?e.jsx(Mt,{}):e.jsx(ft,{size:12,sx:{color:Oe.primary.main}}),e.jsx("span",{children:m})]},d):e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:Oe.error.main},children:[e.jsx(Ut,{}),e.jsx("span",{children:O})]},d)})})]})}),F.anchorEl&&e.jsx(Ue,{open:!!F.anchorEl,anchorReference:"anchorPosition",anchorPosition:F.position,onClose:he,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Pt,{loading:t,onCancel:he,onConfirm:x})})]})})})}const Un=v.memo(Ft),Hn=ae.div`
2
- td.MuiTableCell-footer {
3
- border: none !important;
4
- }
5
- .sent-status-cell {
6
- .resend-btn {
7
- display: none;
8
- }
9
- &:hover {
10
- .resend-btn {
11
- display: flex;
12
- }
13
- }
14
- }
15
- `,$n=ae.div`
16
- padding: 8px 16px;
17
- .check-title {
18
- font-weight: 500;
19
- margin-bottom: 8px;
20
- &::first-letter {
21
- text-transform: uppercase;
22
- }
23
- }
24
- .check-item {
25
- svg {
26
- font-size: 16px;
27
- }
28
- font-size: 12px;
29
- }
30
- `,ve=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:n;function Vn(n){const{wallet:s,push:t,email:r,webhook:o}=n;return[{name:"Wallet",value:e.jsx(ge,{item:s})},{name:"Push",value:e.jsx(ge,{item:t})},{name:"Email",value:e.jsx(ge,{item:r})},...o.total>0?[{name:"Webhook",value:e.jsx(ge,{item:o,isWebhook:!0})}]:[]]}function Yn(n,s,t){const{wallet:r,push:o,email:l,webhook:b}=n;return[{name:"Wallet",value:e.jsx(be,{loading:t,channel:_.NOTIFICATION_SEND_CHANNEL.WALLET,item:r,onResend:s})},{name:"Push",value:e.jsx(be,{loading:t,channel:_.NOTIFICATION_SEND_CHANNEL.PUSH,item:o,onResend:s})},{name:"Email",value:e.jsx(be,{loading:t,channel:_.NOTIFICATION_SEND_CHANNEL.EMAIL,item:l,onResend:s})},...b.total>0?[{name:"Webhook",value:e.jsx(be,{loading:t,channel:_.NOTIFICATION_SEND_CHANNEL.WEBHOOK,item:b,isWebhook:!0,onResend:s})}]:[]]}nt.propTypes={statistics:h.object.isRequired,onResend:h.func,mode:h.oneOf(["simple","detail"]),resending:h.bool};ge.propTypes={item:h.object.isRequired,isWebhook:h.bool};function ge({item:n,isWebhook:s=!1}){const{t}=te(),r=s?n.success.length:n.success,o=n.total,l=r===o?"success":"failed";return e.jsx(y,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:2},children:e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsxs(de,{config:{status:l},enableTooltip:!1,children:[ve(r)," / ",ve(o)," ",t("notification.sendStatus.success")]})})})}be.propTypes={item:h.object.isRequired,isWebhook:h.bool,channel:h.string,onResend:h.func,loading:h.bool};function be({channel:n=_.NOTIFICATION_SEND_CHANNEL.WALLET,item:s,isWebhook:t=!1,onResend:r=()=>{},loading:o=!1}){const{t:l}=te(),{success:b,failed:u,pending:p}=s,i=qn(n),N=t?b.length:b,I=t?u.length:u,S=t?p.length:p,j=async F=>{F.stopPropagation();const B=t?[...new Set([...b,...u].map(R=>R))]:[];await r([n],[],!0,B)},E=N+I,Y=E>0?N/E*100:0,z=E>0?I/E*100:0;return e.jsxs(Gn,{successRatio:Y,failedRatio:z,children:[e.jsxs(ee,{variant:"h6",children:[i," (",s.total,")"]}),e.jsxs(ee,{variant:"body1",sx:{mb:2},children:[e.jsx("span",{style:{color:$e.success,fontWeight:600,fontSize:24},children:ve(N)}),e.jsx("small",{style:{paddingLeft:4},children:l("notification.sendStatus.success")})]}),e.jsxs(y,{className:"unsent-area",children:[e.jsxs(y,{children:[e.jsxs(de,{config:{status:"failed"},enableTooltip:!1,children:[ve(I)," ",l("notification.sendStatus.failed")]}),e.jsxs(de,{config:{status:"pending"},enableTooltip:!1,children:[ve(S)," ",l("notification.sendStatus.pending")]})]}),I>0&&e.jsx(y,{className:"resend-btn",children:e.jsx(ce,{size:"small",color:"primary",loading:o,variant:"contained",startIcon:e.jsx(Ge,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:j,children:l("notification.resend")})})]})]})}function nt({statistics:n,mode:s="simple",onResend:t=()=>{},resending:r=!1}){const o=se(()=>s==="simple"?Vn(n):Yn(n,t,r),[n,s]);return s==="simple"?e.jsx("div",{children:o.map(l=>e.jsx(Tt,{style:{alignItems:"flex-start",marginBottom:s==="simple"?0:16},valueComponent:"div",nameWidth:100,name:l.name,children:l.value},l.name))}):e.jsx(st,{container:!0,spacing:2,children:o.map(l=>e.jsx(st,{size:{md:4,sm:6,xs:12},children:l.value},l.name))})}const Gn=ae(y)`
31
- display: flex;
32
- flex-direction: column;
33
- align-items: flex-start;
34
- padding: 16px;
35
- border-radius: 8px;
36
- background: ${({successRatio:n,failedRatio:s,theme:t})=>n===0&&s===0?t.palette.grey[300]:`linear-gradient(to right, ${Ht(t.palette.success.light,.4)} ${n}%, ${t.palette.grey[100]} ${n}%)`};
37
- transition: 'background 0.5s ease';
38
- cursor: pointer;
39
- .unsent-area {
40
- width: 100%;
41
- position: relative;
42
- .resend-btn {
43
- position: absolute;
44
- right: 0;
45
- bottom: 0;
46
- }
47
- }
48
- `;_t.propTypes={notification:h.object.isRequired,onCancel:h.func,blocklet:h.object.isRequired,tab:h.string};function _t({notification:n,onCancel:s=()=>{},blocklet:t,tab:r="info"}){const{t:o,locale:l}=te(),{getComponent:b,resendNotification:u}=Xe(),[p,i]=v.useState(!1),N=se(()=>b(n.componentDid)||t,[t,n.componentDid]),I=ye({tab:r||"info"}),S=v.useCallback(async(f,w,C=!0,a=[])=>{if(!f.length||!n.id)return;const T=w.length>0?w:n?.receivers?.map(D=>D.receiver);if(!T.length)return;let k=[...f];if(k.includes(_.NOTIFICATION_SEND_CHANNEL.PUSH)&&!Dt(t)&&(M.warning(o("notification.sendStatus.reason.unavailable",{channel:"Push Kit"})),k=k.filter(D=>D!==_.NOTIFICATION_SEND_CHANNEL.PUSH)),k.includes(_.NOTIFICATION_SEND_CHANNEL.EMAIL)&&!kt(t)&&(M.warning(o("notification.sendStatus.reason.unavailable",{channel:"Email"})),k=k.filter(D=>D!==_.NOTIFICATION_SEND_CHANNEL.EMAIL)),!!k.length)try{i(!0),await u({notificationId:n.id,receivers:T,channels:k,resendFailedOnly:C,...k.includes("webhook")&&a.length?{webhookUrls:a}:{}}),M.success("Message has been sent!")}catch(D){console.error("handleResend error",{error:D}),M.error(D.response?D.response.statusText:D.message)}finally{i(!1)}},[t,n.id,n?.receivers,u,o]),j=se(()=>hn(n),[n]),E=se(()=>xn(n),[n]),Y=se(()=>j?n?.actorInfo:[],[n]),z=se(()=>t?.did||t?.meta?.did||"",[t]);function F(){return[{name:o("notification.from"),value:j&&E?e.jsx(un,{actors:Y,teamDid:z,size:32,showName:!0}):e.jsx(mn,{size:32,blocklet:N,showName:!0,hideDot:!0})},{name:o("notification.notificationTitle"),value:e.jsx(Se,{maxLength:50,children:n.title})},{name:o("notification.body"),value:j?e.jsx(pn,{notification:n,blocklet:t}):e.jsx(gn,{notification:n,rows:0})},{name:o("notification.severity"),value:e.jsx(Ce,{severity:n.severity})},{name:o("notification.createdAt"),value:e.jsx(sn,{value:n.createdAt,locale:l,shouldUpdate:!0,type:"all"})}].map(w=>e.jsx(Tt,{style:{alignItems:"flex-start"},valueComponent:"div",nameWidth:120,name:w.name,children:w.value},w.name))}const B={info:{label:o("common.basicInfo"),value:"info",component:F},receivers:{label:o("notification.receiver"),value:"receivers"},statistics:{label:o("notification.statistics"),value:"statistics"}},R=Object.values(B).map(({label:f,value:w})=>({label:f,value:w})),K=B[I.tab]||B.info,q=f=>{I.tab=f};return e.jsx(St,{title:o("notification.notificationDetails"),fullWidth:!0,maxWidth:"lg",onClose:()=>{I.tab="info",s()},open:!0,actionsPosition:"left",sx:{".ux-dialog_header":{paddingBottom:0},".MuiDialogContent-root":{paddingTop:0}},children:e.jsxs(Xn,{children:[e.jsx(y,{className:"tabs",sx:{mx:3},children:e.jsx(bt,{tabs:R,current:I.tab,onChange:q,scrollButtons:"auto"})}),e.jsxs("div",{className:"body",children:[I.tab==="receivers"&&e.jsx(Un,{notificationId:n.id,resending:p,handleResend:S}),I.tab==="statistics"&&e.jsx(nt,{statistics:n.statistics,mode:"detail",resending:p,onResend:S}),I.tab==="info"&&e.jsx(K.component,{})]})]})})}const Jn=v.memo(_t),Xn=ae.div`
49
- & > .notification-row {
50
- padding: 0;
51
- }
52
-
53
- .tabs {
54
- margin: 0;
55
- }
56
- .body {
57
- margin-top: 16px;
58
- }
59
-
60
- .channel-item {
61
- display: flex;
62
- padding: 4px;
63
- justify-content: flex-start;
64
- align-items: center;
65
- gap: 8px;
66
- > p {
67
- font-size: 15px;
68
- }
69
- .resend-btn {
70
- svg {
71
- font-size: 16px;
72
- }
73
- display: flex;
74
- align-items: center;
75
- font-size: 12px;
76
- cursor: pointer;
77
- &.disabled {
78
- cursor: not-allowed;
79
- color: ${Oe.text.disabled};
80
- }
81
- }
82
- }
83
- `;Pe.propTypes={blocklet:h.object,label:h.string};const Qn=ae.div`
84
- display: flex;
85
- justify-items: flex-start;
86
- align-items: center;
87
- gap: 8px;
88
- .name {
89
- display: block;
90
- max-width: 260px;
91
- white-space: nowrap;
92
- overflow: hidden;
93
- text-overflow: ellipsis;
94
- }
95
- `;function Pe({blocklet:n=null,label:s=""}){return e.jsx(Qn,{children:n?e.jsxs(e.Fragment,{children:[e.jsx(Et,{size:24,blocklet:n,ancestors:n.ancestors}),e.jsx("span",{className:"name",children:n.title||n.meta?.title})]}):e.jsx("span",{className:"name",children:s})})}zt.propTypes={list:h.array.isRequired,label:h.string.isRequired,onDelete:h.func};function zt({list:n,label:s,onDelete:t=()=>{}}){return e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),n.map(r=>e.jsx(Ye,{size:"small",label:e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(Ce,{severity:r})}),onDelete:o=>t(o,r)},r))]})}function Zn(n){return e.jsx(Qe,{...n,renderLabel:s=>e.jsx(Ce,{severity:s})})}function es({customTableButtons:n}){const{t:s,locale:t}=te(),r=ht(),o=v.useMemo(()=>jt(r,Lt()),[r]),[l,b]=v.useState(!1),{data:u,paging:p,blocklet:i,fetch:N,getComponent:I,componentDids:S,inService:j,teamDid:E}=Xe(),Y=v.useRef(null),[z,F]=v.useState(null),[B,R]=v.useState("info"),K=yn(),[q,f]=v.useState(!1),w=`notification-records-${i.meta?.did}`,C=an(w),[a,T]=v.useState({pageSize:C.rowsPerPage||10,page:C.page?C.page+1:1,dids:C.dids||[],dateRange:C.dateRange||[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),k=se(()=>{if(!i.children||!i.children.length)return[];const g=[];return i.children.forEach(x=>{const A=x.did||x.meta?.did;S.includes(A)&&(x.ancestors=[i],g.push(x))}),g},[S,i]),D=async g=>{try{b(!0),await N(g),b(!1)}finally{b(!1)}};v.useEffect(()=>{D(a)},[a]),v.useEffect(()=>{const g=u.find(x=>x.id===z?.id);z&&g&&F({...g})},[u]);const re=(g,x,A,L)=>{g.stopPropagation();const W=A.filter(P=>P!==x);T(P=>({...P,[L]:W,page:1}))},ue=({page:g,rowsPerPage:x,filterList:A})=>{const[L=[],,,,W=[]]=A;a.pageSize!==x?T(P=>({...P,pageSize:x,page:1})):a.page!==g+1?T(P=>({...P,page:g+1})):je(a.dids,L)?je(a.severities,W)||T(P=>({...P,severities:W,page:1})):T(P=>({...P,dids:L,page:1}))},oe=v.useCallback(()=>{F(null),R("info")},[]),pe=v.useCallback(()=>{N(a)},[N,a]),Re=[{label:s("notification.from"),name:"sender",width:400,options:{filter:!0,filterType:"custom",customFilterListOptions:{render:g=>g.map((x,A)=>{if(x==="system")return e.jsx("span",{children:s("notification.system")},`system-${A}`);const L=k.find(W=>(W.did||W.meta?.did)===x);return e.jsx(Pe,{blocklet:L,label:L?.title||L?.meta?.title},x)}),update:(g,x,A)=>(g[A].splice(x,1),g)},filterOptions:{names:k,logic:(g,x)=>x.length?!x.includes(g):!1,display:(g,x,A,L)=>e.jsxs(V,{style:{width:"380px"},children:[e.jsx($t,{id:"demo-simple-select-label",style:{background:"#ffffff"},children:"Sender"}),e.jsxs(Vt,{multiple:!0,value:g[A],renderValue:W=>e.jsx(y,{style:{overflow:"hidden",textOverflow:"ellipsis"},sx:{display:"flex",gap:1,alignItems:"center"},children:W.map(P=>{if(P==="system")return e.jsx("span",{children:s("notification.system")},P);const ie=k.find(we=>(we.did||we.meta?.did)===P);return e.jsx(Pe,{blocklet:ie,label:ie?.title||ie?.meta?.title},P)})}),onChange:W=>{g[A]=W.target.value,x(g[A],A,L)},children:[e.jsx(it,{value:"system",children:s("notification.system")}),k.map(W=>{const P=W.did||W.meta?.did;return e.jsx(it,{value:P,children:e.jsx(Pe,{blocklet:W,label:W.title||W.meta?.title})},P)})]})]})},customBodyRenderLite:g=>{const x=u[g],A=I(x.componentDid);return e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[A?e.jsx(Et,{size:32,blocklet:A,ancestors:A.ancestors??[]}):e.jsx(fn,{blocklet:i,size:32}),e.jsx(Se,{maxLength:50,children:A?.meta?.title||i?.meta?.title})]})}}},{label:s("notification.receiver"),name:"receivers",width:300,options:{filter:!1,customBodyRenderLite:g=>{const x=u[g],{receivers:A}=x;return e.jsx(Yt,{total:A.length,renderSurplus:L=>L<100?e.jsxs("span",{children:["+",L]}):e.jsx("span",{children:"99+"}),max:3,sx:{justifyContent:"flex-end",height:"32px",".MuiAvatar-root":{width:"32px",height:"32px",fontSize:"12px",border:0,zIndex:2}},onClick:L=>{L.stopPropagation(),F(x),R("receivers")},children:A.map(L=>{const{receiverUser:W}=L,P=It(W.avatar,E,j);return e.jsx(vt,{alt:W.fullName,src:`${P}?imageFilter=resize&w=48&h=48`,size:32,did:L.receiver,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}},L.receiver)})})}}},{label:s("notification.statistics"),name:"statistics",width:400,options:{filter:!1,customBodyRenderLite:g=>{const x=u[g];return e.jsx(y,{onClick:A=>{A.stopPropagation(),F(x),R("statistics")},children:e.jsx(nt,{statistics:x.statistics})})}}},{label:s("notification.notificationPreview"),name:"data",options:{filter:!1,customBodyRenderLite:g=>{const x=u[g];return e.jsx(Se,{maxLength:50,children:x.title})}}},{label:s("notification.severity"),name:"severity",width:200,options:{setCellProps:()=>({className:"severity-cell"}),customBodyRenderLite:g=>{const x=u[g];return e.jsx(Ce,{severity:x.severity})},filter:!0,filterType:"custom",filterList:a.severities??[],customFilterListOptions:{render:g=>e.jsx(zt,{list:g,label:s("notification.severity"),onDelete:(x,A)=>{x.stopPropagation(),re(x,A,Re[4].options.filterList,"severities")}}),update:ke},filterOptions:{names:dt,fullWidth:!0,logic:De,display:(g,x,A,L)=>e.jsx(Zn,{label:s("notification.severity"),filterList:g,onChange:x,index:A,column:L,filterValues:dt})}}},{label:s("common.createdAt"),name:"createdAt",width:300,options:{filter:!1,customBodyRenderLite:g=>{const{createdAt:x}=u[g];return e.jsx(Nt,{value:x,locale:t,shouldUpdate:!0})}}}],fe=g=>{T(x=>({...x,dateRange:g,page:1}))},he=[e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(Gt,{onClick:()=>f(!0),sx:{p:K?0:void 0},children:e.jsx(Jt,{})},"settings"),K?e.jsx(ee,{children:s("common.setting")}):null]}),...n||[]];return e.jsxs(y,{ref:Y,sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:[e.jsx(ts,{children:e.jsx(xt,{theme:o,children:e.jsx(yt,{className:"main-table",verticalKeyWidth:100,loading:l,locale:t,columns:Re,data:u,durable:w,onChange:ue,options:{sort:!1,download:!1,print:!1,search:!1,expandableRowsOnClick:!0,page:p.page-1,rowsPerPage:p.pageSize,count:p.total,...C,onRowClick:(g,{dataIndex:x})=>{F(u[x])}},customPreButtons:[e.jsx(Ze,{value:a.dateRange,onChange:fe})],customButtons:he,components:{TableFilterList:g=>e.jsx(et,{...g,itemComponent:x=>e.jsx(tt,{...x,canDelete:A=>A?.columnNames?.[A?.index||0]?.name==="sender"})})}})})}),z&&e.jsx(Jn,{refresh:pe,onCancel:oe,notification:z,blocklet:i,tab:B}),e.jsx(St,{title:`${s("common.notification")} ${s("common.setting")}`,fullWidth:!0,maxWidth:"md",open:q,onClose:()=>f(!1),PaperProps:{style:{minHeight:"500px"}},children:e.jsx(y,{sx:{mt:"-16px",overflowY:"hidden"},children:e.jsx(On,{})})})]})}const ts=ae.div`
96
- td.MuiTableCell-footer {
97
- border: none !important;
98
- }
99
- .sent-status-cell {
100
- .resend-btn {
101
- display: none;
102
- }
103
- &:hover {
104
- .resend-btn {
105
- display: flex;
106
- }
107
- }
108
- }
109
-
110
- .custom-toobar-btns {
111
- gap: 4px;
112
- }
113
- `;ns.propTypes={blocklet:h.object.isRequired,customTableButtons:h.array};function ns({blocklet:n={},customTableButtons:s=[]}){return e.jsx(Dn,{blocklet:n,children:e.jsx(es,{customTableButtons:s})})}export{ns as default};