@abtnode/blocklet-services 1.17.3-beta-20251126-121502-d0926972 → 1.17.3-beta-20251127-063055-94957209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/api/services/auth/connect/gen-access-key.js +1 -0
  2. package/api/services/auth/connect/verify-destroy.js +32 -31
  3. package/api/services/auth/connect/verify-elevated.js +1 -0
  4. package/dist/assets/{AdapterDayjs-B2uxdBcK.js → AdapterDayjs-DlsssqYa.js} +1 -1
  5. package/dist/assets/{Google-mmkrFmA4.js → Google-D0eQfUdH.js} +1 -1
  6. package/dist/assets/{access-control-BsrYt8sR.js → access-control-Danf5ySk.js} +1 -1
  7. package/dist/assets/{actions-BQZmpgjH.js → actions-DHp-gk7h.js} +1 -1
  8. package/dist/assets/{add-component-core-DdA5-pKs.js → add-component-core-Daobxf3I.js} +1 -1
  9. package/dist/assets/{add-resource-BwJJ0aia.js → add-resource-C2oX_-Zz.js} +1 -1
  10. package/dist/assets/{addon-DMnO8VZk.js → addon-Be4T3QjT.js} +1 -1
  11. package/dist/assets/{advanced-D4bpKYrU.js → advanced-kv_eujfj.js} +1 -1
  12. package/dist/assets/{aigne-BKYy4lDi.js → aigne-vYtZdhdi.js} +1 -1
  13. package/dist/assets/{appearance-CoZeiSDb.js → appearance-D_x7BGc3.js} +1 -1
  14. package/dist/assets/{arrow-down.svg-arX2hS9A.js → arrow-down.svg-OnWcVrr5.js} +1 -1
  15. package/dist/assets/{audit-logs-Tol8dkkk.js → audit-logs-BnoJxxOA.js} +1 -1
  16. package/dist/assets/{authorize-Bma44S9y.js → authorize-CEopc1Jx.js} +1 -1
  17. package/dist/assets/{base-chart-Gh7OtL-d.js → base-chart-Cn6zWpXN.js} +1 -1
  18. package/dist/assets/{base32-HmSqZ9zU.js → base32-DmEq36OL.js} +1 -1
  19. package/dist/assets/{bind-account-BHZb-y1l.js → bind-account-CNpaY2P8.js} +1 -1
  20. package/dist/assets/{branding-CnmWjFbu.js → branding-B4_lA6sS.js} +1 -1
  21. package/dist/assets/{branding-Fj3LseIw.js → branding-DQ5FtHfK.js} +1 -1
  22. package/dist/assets/branding-DW4NsL1y.js +1 -0
  23. package/dist/assets/{bundle-avatar-CeDsDt5-.js → bundle-avatar-mI1l0Wbs.js} +1 -1
  24. package/dist/assets/button-CX931aAr.js +1 -0
  25. package/dist/assets/{click-to-copy-COEss4SB.js → click-to-copy-Cq4W-wkJ.js} +1 -1
  26. package/dist/assets/{collapse-BlkBpbz3.js → collapse-DL7FXe7i.js} +1 -1
  27. package/dist/assets/{complete-DetpIm2X.js → complete-CoMp3K_K.js} +1 -1
  28. package/dist/assets/{component-Br_A0gxQ.js → component-DqnOhVec.js} +2 -2
  29. package/dist/assets/{config-DaTqZM7S.js → config-BNoxsDyj.js} +1 -1
  30. package/dist/assets/{config-BZ68qemi.js → config-DIElb3ko.js} +6 -6
  31. package/dist/assets/{config-hHQ1dQ0r.js → config-l8EZr5wV.js} +1 -1
  32. package/dist/assets/{config-navigation-CIiX_S1E.js → config-navigation-CvEqeTCm.js} +2 -2
  33. package/dist/assets/{config-space-DcxPvrsQ.js → config-space-D-JrZNQP.js} +1 -1
  34. package/dist/assets/{confirm-CQifLVQz.js → confirm-7CqzZykT.js} +1 -1
  35. package/dist/assets/{connect-BYne4RoU.js → connect-CL9-wlU7.js} +1 -1
  36. package/dist/assets/{connect-DCXdY6aM.js → connect-HC_-YXp4.js} +1 -1
  37. package/dist/assets/{connect-to-Dp0mJeqn.js → connect-to-DNIdRfZG.js} +1 -1
  38. package/dist/assets/{content-layout-CpbYUNJ8.js → content-layout-dv29oUBd.js} +1 -1
  39. package/dist/assets/{create-passport-svg-hAgKE5uX.js → create-passport-svg-CESSejlW.js} +1 -1
  40. package/dist/assets/{createClass-D1NoiqdO.js → createClass-bIxJZr1p.js} +1 -1
  41. package/dist/assets/{dashboard-PCrwcW_N.js → dashboard-D4m3zfEM.js} +2 -2
  42. package/dist/assets/{delete-confirm-DP77Lldw.js → delete-confirm-D1LtCumr.js} +1 -1
  43. package/dist/assets/{did-address-CLsSdiw3.js → did-address-gjwvc_rF.js} +1 -1
  44. package/dist/assets/{domain-DptzkTFQ.js → domain-BSIx6Jyu.js} +1 -1
  45. package/dist/assets/{domain-action-card-DmLVoK6X.js → domain-action-card-uJMlNbM4.js} +1 -1
  46. package/dist/assets/domains-DPyPBivZ.js +1 -0
  47. package/dist/assets/{email-zUlL8Ooc.js → email-ua9HtNUU.js} +1 -1
  48. package/dist/assets/{empty-spinner-DiVQXbse.js → empty-spinner-v7NQTJhv.js} +1 -1
  49. package/dist/assets/engine-cCWGwlN6.js +1 -0
  50. package/dist/assets/{exchange-passport-4jMKVLBc.js → exchange-passport-ClnnHBna.js} +1 -1
  51. package/dist/assets/{form-BhkklUts.js → form-DswlznpT.js} +1 -1
  52. package/dist/assets/{form-text-input-BFhD3mCK.js → form-text-input-BdG6b7xY.js} +1 -1
  53. package/dist/assets/{form-wrapper-B9XdbV9a.js → form-wrapper-D4szSlOw.js} +1 -1
  54. package/dist/assets/{fuel-_LHEMXNX.js → fuel-whr3Ilmj.js} +1 -1
  55. package/dist/assets/{gen-access-key-Cuu-iyxE.js → gen-access-key-DAhMUU-d.js} +1 -1
  56. package/dist/assets/{gen-simple-access-key-ud5DXiqY.js → gen-simple-access-key-DS0CA98s.js} +1 -1
  57. package/dist/assets/get-safe-url-DFrG9umg.js +1 -0
  58. package/dist/assets/{home-D-jA_4Lm.js → home-Co102dWk.js} +1 -1
  59. package/dist/assets/{iframe-DwMwGxmX.js → iframe-COJHAFfh.js} +1 -1
  60. package/dist/assets/{index-B1hEtoFm.js → index-AgA4sW48.js} +1 -1
  61. package/dist/assets/{index-xERuGIw0.js → index-B7aKP8pi.js} +4 -4
  62. package/dist/assets/{index-Cvr1OSm0.js → index-BKN6q696.js} +1 -1
  63. package/dist/assets/{index-D_l_jjH3.js → index-BNDeY87F.js} +1 -1
  64. package/dist/assets/{index-auhzedGi.js → index-BbKEZuXu.js} +1 -1
  65. package/dist/assets/{index-CozzYt0Z.js → index-BbXRGcZW.js} +1 -1
  66. package/dist/assets/{index-kzb9GjyJ.js → index-BgHe98gK.js} +1 -1
  67. package/dist/assets/{index-BcssdfWc.js → index-BxqQFCR8.js} +1 -1
  68. package/dist/assets/{index-s6v6fZUe.js → index-C0q0zQTI.js} +1 -1
  69. package/dist/assets/{index-B3nY7xOz.js → index-C9kZHU28.js} +3 -3
  70. package/dist/assets/{index-CR-yimk0.js → index-CCVrpeOq.js} +1 -1
  71. package/dist/assets/{index-ClXqfbDZ.js → index-CEz-byBA.js} +1 -1
  72. package/dist/assets/{index-CoJqP_N2.js → index-CIxFbeb7.js} +1 -1
  73. package/dist/assets/{index-BWgjTPxl.js → index-CcXTlGtY.js} +1 -1
  74. package/dist/assets/{index-C3PPGtfI.js → index-ClXbSPXF.js} +2 -2
  75. package/dist/assets/{index-ByEQy1Lz.js → index-CqjGrKtg.js} +1 -1
  76. package/dist/assets/{index-Dr1AOLd_.js → index-CzmL_Hvj.js} +1 -1
  77. package/dist/assets/{index-KzZiqY9D.js → index-D1fu_Ebn.js} +6 -6
  78. package/dist/assets/{index-B65qJcbt.js → index-DIDsL1O1.js} +1 -1
  79. package/dist/assets/{index-DxlME7t_.js → index-DJFOLfX2.js} +1 -1
  80. package/dist/assets/{index-BNBVWXSX.js → index-DMxyBvNb.js} +2 -2
  81. package/dist/assets/{index-BQyVf1E3.js → index-DgXRGMR4.js} +1 -1
  82. package/dist/assets/{index-D45cjNSM.js → index-DmGYWcz-.js} +1 -1
  83. package/dist/assets/{index-DDNvzM4M.js → index-Dspz6jcA.js} +1 -1
  84. package/dist/assets/{index-DjE2GQIM.js → index-DwhuhEAl.js} +1 -1
  85. package/dist/assets/index-KEP7l6E2.js +124 -0
  86. package/dist/assets/{index-Cpsil-_J.js → index-Np46kKLW.js} +1 -1
  87. package/dist/assets/{index-D0XVz0dc.js → index-XWTmneBy.js} +1 -1
  88. package/dist/assets/{index-N6YyFqDu.js → index-ZUT_Qafk.js} +1 -1
  89. package/dist/assets/{index-kD1YmpMU.js → index-cUf5_jCs.js} +2 -2
  90. package/dist/assets/{index-BLT40lDy.js → index-it0t1NhB.js} +1 -1
  91. package/dist/assets/{index-BO3UQZPi.js → index-uV0wgve2.js} +1 -1
  92. package/dist/assets/{invitation-gK2vIEsH.js → invitation-C_tg_ETR.js} +1 -1
  93. package/dist/assets/{invitations-lfws_T2N.js → invitations-DfUvBLlf.js} +1 -1
  94. package/dist/assets/{invite-CGloPprm.js → invite-nGN9Oyh4.js} +1 -1
  95. package/dist/assets/{isURL-CDvz38EO.js → isURL-C5WG5wCh.js} +1 -1
  96. package/dist/assets/{issue-passport-Dl3X8TTW.js → issue-passport-D9X0hPuR.js} +1 -1
  97. package/dist/assets/{item-CTQ1F-Dd.js → item-CLLsRigr.js} +1 -1
  98. package/dist/assets/{landing-page-DKcKat1r.js → landing-page-BCWLCQCC.js} +1 -1
  99. package/dist/assets/{launch-result-message--rgseiAA.js → launch-result-message-cNLFIi7R.js} +1 -1
  100. package/dist/assets/{layout-D1wjW1Oy.js → layout-C7kocIsT.js} +1 -1
  101. package/dist/assets/{list-DPsX8TMn.js → list-CTOAY-ou.js} +3 -3
  102. package/dist/assets/{list-MeDKce8j.js → list-CoA75USb.js} +1 -1
  103. package/dist/assets/{list-header-DOS7AnGs.js → list-header-C3sqYJbQ.js} +1 -1
  104. package/dist/assets/localization-B-Y1B8LC.js +1 -0
  105. package/dist/assets/{log-B9KcwZD3.js → log-By5AyjAO.js} +1 -1
  106. package/dist/assets/logger-d9jkFx-x.js +1 -0
  107. package/dist/assets/{login-Cbb7F6Mu.js → login-DthiGxzS.js} +1 -1
  108. package/dist/assets/{login-oauth-callback-f64z-iJf.js → login-oauth-callback-1zhw-LOq.js} +1 -1
  109. package/dist/assets/{logo-uploader-D6c2iUqg.js → logo-uploader-BrImw7s9.js} +1 -1
  110. package/dist/assets/{lost-passport-CSoln1QB.js → lost-passport-BB122NeD.js} +1 -1
  111. package/dist/assets/{observability-D1A-1uvj.js → observability-BtYD0ieN.js} +1 -1
  112. package/dist/assets/{open-window-7JDNMA9V.js → open-window-DVvGcPv8.js} +1 -1
  113. package/dist/assets/{over-due-invoice-payment-CljuJ4kk.js → over-due-invoice-payment-BDO7_XVI.js} +1 -1
  114. package/dist/assets/{overview-CI-TDe1L.js → overview-DAMKF9mI.js} +2 -2
  115. package/dist/assets/{page-header-Dh_UA7fa.js → page-header-DbMN84ZK.js} +1 -1
  116. package/dist/assets/{passport-0dxK_pTH.js → passport-UxiDT8mW.js} +1 -1
  117. package/dist/assets/{passport-item-DwumTPQv.js → passport-item-B2H7GQg8.js} +1 -1
  118. package/dist/assets/{permission-Blt9Onuq.js → permission-D6_WOpI3.js} +1 -1
  119. package/dist/assets/{playground-kZ9J2CEx.js → playground-NSs9sx7X.js} +1 -1
  120. package/dist/assets/preferences-DexmqT2T.js +1 -0
  121. package/dist/assets/profile-embed-z9JSgirN.js +1 -0
  122. package/dist/assets/{publish-resource-Adc4901F.js → publish-resource-TLVbUo-x.js} +1 -1
  123. package/dist/assets/{react-beautiful-dnd.esm-CbCp5m8Z.js → react-beautiful-dnd.esm-CK4sWF8a.js} +1 -1
  124. package/dist/assets/{react-stripe.esm-C8Keba5n.js → react-stripe.esm-DtEXX2jp.js} +1 -1
  125. package/dist/assets/{required-CgSsIuqu.js → required-Cwbcx6Cg.js} +1 -1
  126. package/dist/assets/{runtime-OGDYw4nO.js → runtime-CnztHx23.js} +1 -1
  127. package/dist/assets/sdk-CLOiRS-Q.js +1 -0
  128. package/dist/assets/{section-tQK-hwwW.js → section-Bq6cqwD2.js} +1 -1
  129. package/dist/assets/{security-DEVrQWpZ.js → security-4cho6HAg.js} +1 -1
  130. package/dist/assets/{session-CAj-TcUY.js → session-4l80Me2P.js} +1 -1
  131. package/dist/assets/{setup-BT6-74rK.js → setup-BtaOnq1y.js} +1 -1
  132. package/dist/assets/{shorten-label-JstixX67.js → shorten-label-BugTCYOF.js} +1 -1
  133. package/dist/assets/{simple-select-_qsehgaA.js → simple-select-BueAriVl.js} +1 -1
  134. package/dist/assets/{spaces-B6flHcN-.js → spaces-iftz1eYH.js} +1 -1
  135. package/dist/assets/{start-BMKAy5mb.js → start-AVZVc08V.js} +1 -1
  136. package/dist/assets/{starting-progress-SNgrsu02.js → starting-progress-KDLYjvJ9.js} +1 -1
  137. package/dist/assets/{status-GY7lihPg.js → status-DfnitO-x.js} +1 -1
  138. package/dist/assets/{step-actions-BcFE8m2n.js → step-actions-CFyLVUSC.js} +1 -1
  139. package/dist/assets/{studio-BkTwhFSX.js → studio-CuikMk9t.js} +1 -1
  140. package/dist/assets/{switch-control-DVE8MCqI.js → switch-control-tVHoI5QM.js} +1 -1
  141. package/dist/assets/{table-tips-DMkRZoRQ.js → table-tips-AK8Y4Q8i.js} +1 -1
  142. package/dist/assets/{team-DANl8A6y.js → team-CsIX00_k.js} +1 -1
  143. package/dist/assets/{traffic-D_pUHfvx.js → traffic-hGNEG2UT.js} +1 -1
  144. package/dist/assets/{transfer-3jaJ_59b.js → transfer-dv44R-B9.js} +1 -1
  145. package/dist/assets/{unsubscribe-zGPKbsNi.js → unsubscribe-B_7KhKwO.js} +1 -1
  146. package/dist/assets/{use-app-logo-mH-ZWGvv.js → use-app-logo-BebTliBo.js} +1 -1
  147. package/dist/assets/{use-mobile-BdZU3Qy2.js → use-mobile-CbzGNuhc.js} +1 -1
  148. package/dist/assets/{use-mobile-nqweJXIG.js → use-mobile-D-631edY.js} +1 -1
  149. package/dist/assets/{use-server-logo-YhCrW0Nr.js → use-server-logo-BqPWSS3F.js} +1 -1
  150. package/dist/assets/{use-window-close-B1fcc1UV.js → use-window-close-Tv5rDlUk.js} +1 -1
  151. package/dist/assets/{useAsyncRetry-DhVFzdPo.js → useAsyncRetry-D33rBUak.js} +1 -1
  152. package/dist/assets/{useLocalStorage-BCYIznDQ.js → useLocalStorage-CNRBVDFF.js} +1 -1
  153. package/dist/assets/{user-center-gH0CVETg.js → user-center-xqAXQ-SZ.js} +2 -2
  154. package/dist/assets/{user-follower-DYsXrJ7n.js → user-follower-Dv6JnrUr.js} +1 -1
  155. package/dist/assets/{util-BN6NLUU2.js → util-Cd42TaWI.js} +1 -1
  156. package/dist/assets/{util-wCHwyw_F.js → util-DzML57Qs.js} +1 -1
  157. package/dist/assets/{vendor-arcblock-BRRIrPlW.js → vendor-arcblock-D5spFpjt.js} +1 -1
  158. package/dist/assets/{vendor-mui-core-B62p29u8.js → vendor-mui-core-Et2SVbGP.js} +1 -1
  159. package/dist/assets/{vendor-mui-x-vSVDqxyB.js → vendor-mui-x-BIXAJqK8.js} +1 -1
  160. package/dist/assets/{vendor-ux-k_TkMNDV.js → vendor-ux-Y094QNTK.js} +1 -1
  161. package/dist/assets/{wait-connect-Df9uvB6x.js → wait-connect-5-eiabIl.js} +1 -1
  162. package/dist/assets/{wizard-GCfJ08HB.js → wizard-_JfH9fOz.js} +1 -1
  163. package/dist/assets/{wizard-components-D_w2hIhz.js → wizard-components-C_0333Fa.js} +1 -1
  164. package/dist/assets/wrap-locale-DFgLH2rd.js +1 -0
  165. package/dist/assets/{zh-QBR-GmxX.js → zh-Czp7XVra.js} +1 -1
  166. package/dist/index.html +1 -1
  167. package/dist/service-worker.js +1 -1
  168. package/package.json +23 -23
  169. package/dist/assets/branding-DhsDum88.js +0 -1
  170. package/dist/assets/button-M1tE0EM6.js +0 -1
  171. package/dist/assets/domains-Cj55weM5.js +0 -1
  172. package/dist/assets/engine-Br5kqWzP.js +0 -1
  173. package/dist/assets/get-safe-url-baxNHkAA.js +0 -1
  174. package/dist/assets/index-DBBPnrYI.js +0 -124
  175. package/dist/assets/localization-CASCfNj1.js +0 -1
  176. package/dist/assets/logger-6-51jSsQ.js +0 -1
  177. package/dist/assets/preferences-OylPiHSa.js +0 -1
  178. package/dist/assets/profile-embed-CCdzwTKi.js +0 -1
  179. package/dist/assets/sdk-CxQIQdbk.js +0 -1
  180. package/dist/assets/wrap-locale-Dgf6KVHX.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as e,W as u,a6 as z,T as j,at as _e,D as We,cH as J,ao as V,cI as Ke,ak as h,b1 as K,a$ as Ge,s as fe,cJ as be,co as Fe,am as ge,cq as Ye,M as F,aO as Y,bX as $e,aP as $,Q as qe,be as He,aR as Qe,cK as Xe,cL as Je,cM as Ve,cN as Ze,c2 as he}from"./vendor-mui-core-B62p29u8.js";import{k as ke,j as je,a as ue}from"./vendor-hooks-BeI8hpF9.js";import{r as b,u as et}from"./vendor-react-CUXIiAnY.js";import{ac as O,_ as L,a1 as E,Y as N,aR as tt,aS as st,aJ as nt,c as T,v as ot}from"./index-xERuGIw0.js";import{H as B,V as D,s as at,a2 as q,x as rt,a4 as it,n as le,A as ct}from"./vendor-ux-k_TkMNDV.js";import{u as lt}from"./use-mobile-nqweJXIG.js";import{a as H,d as Ce,a0 as dt,c as pt,D as we,C as me}from"./vendor-utils-DZwtp8ph.js";import{o as Be}from"./vendor-arcblock-BRRIrPlW.js";import{b as ut,u as mt,D as xt,c as de,a as ft}from"./index-Dr1AOLd_.js";import"./index-B1hEtoFm.js";import"./index-BojVbZw0.js";import"./api-C1vNuLNj.js";import{u as De,C as gt,D as ht,a as St}from"./connect-to-Dp0mJeqn.js";import{b as yt,c as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Bt}from"./spaces-B6flHcN-.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-D0XVz0dc.js";import{E as Et}from"./index-DYMBrhSA.js";import{x as It}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-baxNHkAA.js";import{S as Tt}from"./switch-control-DVE8MCqI.js";import{C as Rt,u as Pt}from"./config-space-DcxPvrsQ.js";import{L as ye}from"./list-header-DOS7AnGs.js";import"./lottie-web-4koyQiv_.js";import"./index-Cvr1OSm0.js";async function At({blockletDid:t,nodeApi:n,spaceGateways:o}){let s=!1;const r=await Promise.all(o.map(async a=>{let{name:c}=a;const i=await yt(a.endpoint);return!H(i)&&i!==c&&(c=i,s=!0),{...a,name:c}}));return s&&await Promise.all(r.filter(a=>a.did).map(a=>n.updateBlockletSpaceGateway({input:{did:t,where:{did:a.did},spaceGateway:{...a}}}))),r}function vt({refresh:t}={}){const{blocklet:n}=O(),o=n?.meta?.did,{api:s}=L();return ke(async()=>{if(!o)return[];const{spaceGateways:r}=await s.getBlockletSpaceGateways({input:{did:o}});return await At({blockletDid:o,nodeApi:s,spaceGateways:r})??[]},{refreshDeps:[o,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),B.error(Q(r)))}})}function Ee({deps:t,setLoading:n,backupDate:o}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=O(),[r,a]=b.useState([]),{api:c}=L(),[i,d]=b.useMemo(()=>o?[E(o).startOf("day").toISOString(),E(o).endOf("day").toISOString()]:[E().startOf("year").toISOString(),E().endOf("day").toISOString()],[o]),l=Ce(async()=>{try{if(n(!0),!s){a([]);return}const{backups:x}=await c.getBlockletBackups({input:{did:s.meta.did,startTime:i,endTime:d}});a(x??[])}catch(x){console.error(x),B.error(Q(x))}finally{n(!1)}},1e3);return je(async()=>{l()},[s?.meta?.did].concat(t)),{backups:r}}function zt({appDid:t}){const{backups:n}=Ee(),[o,s]=b.useState({message:"",progress:0,completed:!1}),r=L(),{ws:{useSubscription:a}}=r;return a(N.BlockletEvents.backupProgress,c=>{t===c?.appDid&&s(()=>({...c}))},[t]),b.useEffect(()=>{if(n?.length&&dt(n[0]?.status)){const[c]=n;s(()=>({message:c.message,progress:c.progress,completed:c.progress>=100}))}},[n]),o}function Ot({deps:t=[],setLoading:n=()=>{}}={}){const{blocklet:o}=O(),[s,r]=b.useState([]),{api:a}=L(),c=b.useCallback(Ce(async()=>{if(!a||!o?.meta?.did){r([]);return}try{n(!0);const i=E(),d=i.subtract(1,"year"),{summary:l}=await a.getBlockletBackupSummary({input:{did:o.meta.did,startTime:d.toISOString(),endTime:i.toISOString()}});r(Array.isArray(l)?l:[])}catch(i){console.error("Failed to fetch backup summary:",i),B.error(Q(i)),r([])}finally{n(!1)}},1e3),[]);return je(async()=>(await c(),()=>{c.cancel()}),[o?.meta?.did].concat(t)),{backupSummary:s}}const Ie=b.createContext({}),{Provider:Lt,Consumer:bs}=Ie;function Te({children:t}){const{t:n}=D(),{api:o}=L(),{blocklet:s}=O(),[r,a]=b.useState(null),[c,i]=b.useState(!1),{data:d,loading:l,mutate:x}=vt({refresh:c}),g=pt(d),m=zt({appDid:s?.appDid}),p=b.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=b.useState(!1),[S,y]=b.useState(0),{backups:Z}=Ee({deps:[S,r],setLoading:w,backupDate:r}),[ee,te]=b.useState(0),{backupSummary:se}=Ot({deps:[ee]}),[_,M]=b.useState(d?.find(f=>f.endpoint===p)),I=s?.settings?.autoBackup,P=()=>{i(f=>!f)},ne=()=>{te(f=>f+1)},oe=()=>{y(f=>f+1)},G=async f=>{await o.updateAutoBackup({input:{did:s.meta.did,autoBackup:f}})},X=async()=>{await o.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(f,v)=>{try{x(R=>{const A=[...R];return A.push({...f,loading:!0}),A}),await o.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:f}}),p!==v&&await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:v}]}}),M(f),P(),B.success(n("storage.spaces.connectedWithName",{name:f?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(A=>[...A].filter(W=>W.did!==f.did)),R}},re=async f=>{f&&(f.endpoint===p&&(await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),I?.enabled&&await G({enabled:!1})),await o.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:f?.did}}),x(v=>{const R=[...v];return R.splice(R.indexOf(f),1),R}),M(f),P())},ie=async f=>{await Promise.all([o.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:f.did},spaceGateway:f}}),p!==f.endpoint&&o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:f.endpoint}]}})]),B.success(n("storage.spaces.connectedWithName",{name:f?.name??"DID Spaces"})),P()},C=f=>f?.endpoint===p;return e.jsx(Lt,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:P,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:g,spaceGatewayIsSelected:C,updateAutoBackup:G,abortBlockletBackup:X,backupEndpoint:p,backupProgress:m,backups:Z,backupSummary:se,refreshBackupSummary:ne,refreshBackups:oe,setBackupDate:a,backupsLoading:k,autoBackup:I},children:t})}Te.propTypes={children:u.any.isRequired};function U(){return b.useContext(Ie)}function Re({...t}){const{blocklet:n}=O(),{info:o}=L(),{t:s}=D(),r=De({blocklet:n}),a=tt(o),{spaceGateways:c,addSpaceGateway:i}=U(),d={checkFn:we.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:a,extraParams:{appPid:n.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:o.did}},l=async({endpoint:g,name:m,did:p})=>{const k=await kt(g);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(c.some(y=>y.endpoint===g)){B.error(s("storage.spaces.gateway.add.duplicate",{name:m}));return}await i({name:m,did:p,url:k,endpoint:g},g)},x=async({spaceGateway:g})=>{try{await l(g)}catch(m){console.error(m),B.error(Q(m))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:x})}function Ut(){const{api:t}=L(),{blocklet:n}=O(),{data:o,loading:s}=ke(()=>t.getBlocklet({input:{did:n?.meta?.did,attachDiskInfo:!0,attachRuntimeInfo:!0}}),{ready:!!n?.meta?.did,refreshDeps:[n?.meta?.did]});return{blocklet:o?.blocklet??null,loading:s}}function Pe({...t}){const{t:n}=b.useContext(at),{blocklet:o,loading:s}=Ut();if(o?.diskInfo){const r=(i,d,l)=>e.jsxs(j,{children:[i," ",e.jsx("strong",{children:d?nt(d):"empty"})]}),a=o.environments.reduce((i,d)=>(i[d.key]=d.value,i),{}),c=[{key:"appDir",name:n("blocklet.diskInfo.appDir"),value:r(a.BLOCKLET_APP_DIR,o.diskInfo.app)},{key:"dataDir",name:n("blocklet.diskInfo.dataDir"),value:r(a.BLOCKLET_DATA_DIR,o.diskInfo.data)},{key:"logDir",name:n("blocklet.diskInfo.logDir"),value:r(a.BLOCKLET_LOG_DIR,o.diskInfo.log)},{key:"cacheDir",name:n("blocklet.diskInfo.cacheDir"),value:r(a.BLOCKLET_CACHE_DIR,o.diskInfo.cache)}];return e.jsx(Mt,{component:"div",...t,children:c.map(i=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:i.name,children:i.value},i.key))})}return s?e.jsx(z,{}):e.jsx(j,{children:n("blocklet.diskInfo.empty")})}const Mt=_e(j)``;function Ae(){const{t}=D(),{setBackupDate:n,backupSummary:o}=U(),s=mt({key:"lg"}),r=b.useRef(null),a=We(),c=b.useCallback(l=>{n(l)},[n]),i=b.useMemo(()=>{const l=E().add(1,"day"),x=l.subtract(1,"year"),g=new Map(o.map(p=>[p.date,{date:p.date,successCount:p.successCount,errorCount:p.errorCount}])),m=[];for(let p=x.clone();E(p).isBefore(l);p=p.add(1,"day")){const k=p.format("YYYY-MM-DD");m.push(g.get(k)||{date:k,successCount:0,errorCount:0})}return m},[o]),d=b.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:S,errorCount:y}=i[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${y}</div>`].join(`
1
+ import{j as e,W as u,a6 as z,T as j,at as _e,D as We,cI as J,ao as V,cJ as Ke,ak as h,b1 as K,a$ as Ge,s as fe,cK as be,cp as Fe,am as ge,cr as Ye,M as F,aO as Y,bX as $e,aP as $,Q as qe,be as He,aR as Qe,cL as Xe,cM as Je,cN as Ve,cO as Ze,c2 as he}from"./vendor-mui-core-Et2SVbGP.js";import{k as ke,j as je,a as ue}from"./vendor-hooks-BeI8hpF9.js";import{r as b,u as et}from"./vendor-react-CUXIiAnY.js";import{ac as O,_ as L,a1 as E,Y as N,aR as tt,aS as st,aJ as nt,c as T,v as ot}from"./index-B7aKP8pi.js";import{H as B,V as D,s as at,a2 as q,x as rt,a4 as it,n as le,A as ct}from"./vendor-ux-Y094QNTK.js";import{u as lt}from"./use-mobile-D-631edY.js";import{a as H,d as Ce,a0 as dt,c as pt,D as we,C as me}from"./vendor-utils-DZwtp8ph.js";import{o as Be}from"./vendor-arcblock-D5spFpjt.js";import{b as ut,u as mt,D as xt,c as de,a as ft}from"./index-CzmL_Hvj.js";import"./index-AgA4sW48.js";import"./index-BojVbZw0.js";import"./api-C1vNuLNj.js";import{u as De,C as gt,D as ht,a as St}from"./connect-to-DNIdRfZG.js";import{b as yt,c as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Bt}from"./spaces-iftz1eYH.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-XWTmneBy.js";import{E as Et}from"./index-DYMBrhSA.js";import{x as It}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-DFrG9umg.js";import{S as Tt}from"./switch-control-tVHoI5QM.js";import{C as Rt,u as Pt}from"./config-space-D-JrZNQP.js";import{L as ye}from"./list-header-C3sqYJbQ.js";import"./lottie-web-4koyQiv_.js";import"./index-BKN6q696.js";async function At({blockletDid:t,nodeApi:n,spaceGateways:o}){let s=!1;const r=await Promise.all(o.map(async a=>{let{name:c}=a;const i=await yt(a.endpoint);return!H(i)&&i!==c&&(c=i,s=!0),{...a,name:c}}));return s&&await Promise.all(r.filter(a=>a.did).map(a=>n.updateBlockletSpaceGateway({input:{did:t,where:{did:a.did},spaceGateway:{...a}}}))),r}function vt({refresh:t}={}){const{blocklet:n}=O(),o=n?.meta?.did,{api:s}=L();return ke(async()=>{if(!o)return[];const{spaceGateways:r}=await s.getBlockletSpaceGateways({input:{did:o}});return await At({blockletDid:o,nodeApi:s,spaceGateways:r})??[]},{refreshDeps:[o,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),B.error(Q(r)))}})}function Ee({deps:t,setLoading:n,backupDate:o}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=O(),[r,a]=b.useState([]),{api:c}=L(),[i,d]=b.useMemo(()=>o?[E(o).startOf("day").toISOString(),E(o).endOf("day").toISOString()]:[E().startOf("year").toISOString(),E().endOf("day").toISOString()],[o]),l=Ce(async()=>{try{if(n(!0),!s){a([]);return}const{backups:x}=await c.getBlockletBackups({input:{did:s.meta.did,startTime:i,endTime:d}});a(x??[])}catch(x){console.error(x),B.error(Q(x))}finally{n(!1)}},1e3);return je(async()=>{l()},[s?.meta?.did].concat(t)),{backups:r}}function zt({appDid:t}){const{backups:n}=Ee(),[o,s]=b.useState({message:"",progress:0,completed:!1}),r=L(),{ws:{useSubscription:a}}=r;return a(N.BlockletEvents.backupProgress,c=>{t===c?.appDid&&s(()=>({...c}))},[t]),b.useEffect(()=>{if(n?.length&&dt(n[0]?.status)){const[c]=n;s(()=>({message:c.message,progress:c.progress,completed:c.progress>=100}))}},[n]),o}function Ot({deps:t=[],setLoading:n=()=>{}}={}){const{blocklet:o}=O(),[s,r]=b.useState([]),{api:a}=L(),c=b.useCallback(Ce(async()=>{if(!a||!o?.meta?.did){r([]);return}try{n(!0);const i=E(),d=i.subtract(1,"year"),{summary:l}=await a.getBlockletBackupSummary({input:{did:o.meta.did,startTime:d.toISOString(),endTime:i.toISOString()}});r(Array.isArray(l)?l:[])}catch(i){console.error("Failed to fetch backup summary:",i),B.error(Q(i)),r([])}finally{n(!1)}},1e3),[]);return je(async()=>(await c(),()=>{c.cancel()}),[o?.meta?.did].concat(t)),{backupSummary:s}}const Ie=b.createContext({}),{Provider:Lt,Consumer:bs}=Ie;function Te({children:t}){const{t:n}=D(),{api:o}=L(),{blocklet:s}=O(),[r,a]=b.useState(null),[c,i]=b.useState(!1),{data:d,loading:l,mutate:x}=vt({refresh:c}),g=pt(d),m=zt({appDid:s?.appDid}),p=b.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=b.useState(!1),[S,y]=b.useState(0),{backups:Z}=Ee({deps:[S,r],setLoading:w,backupDate:r}),[ee,te]=b.useState(0),{backupSummary:se}=Ot({deps:[ee]}),[_,M]=b.useState(d?.find(f=>f.endpoint===p)),I=s?.settings?.autoBackup,P=()=>{i(f=>!f)},ne=()=>{te(f=>f+1)},oe=()=>{y(f=>f+1)},G=async f=>{await o.updateAutoBackup({input:{did:s.meta.did,autoBackup:f}})},X=async()=>{await o.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(f,v)=>{try{x(R=>{const A=[...R];return A.push({...f,loading:!0}),A}),await o.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:f}}),p!==v&&await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:v}]}}),M(f),P(),B.success(n("storage.spaces.connectedWithName",{name:f?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(A=>[...A].filter(W=>W.did!==f.did)),R}},re=async f=>{f&&(f.endpoint===p&&(await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),I?.enabled&&await G({enabled:!1})),await o.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:f?.did}}),x(v=>{const R=[...v];return R.splice(R.indexOf(f),1),R}),M(f),P())},ie=async f=>{await Promise.all([o.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:f.did},spaceGateway:f}}),p!==f.endpoint&&o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:f.endpoint}]}})]),B.success(n("storage.spaces.connectedWithName",{name:f?.name??"DID Spaces"})),P()},C=f=>f?.endpoint===p;return e.jsx(Lt,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:P,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:g,spaceGatewayIsSelected:C,updateAutoBackup:G,abortBlockletBackup:X,backupEndpoint:p,backupProgress:m,backups:Z,backupSummary:se,refreshBackupSummary:ne,refreshBackups:oe,setBackupDate:a,backupsLoading:k,autoBackup:I},children:t})}Te.propTypes={children:u.any.isRequired};function U(){return b.useContext(Ie)}function Re({...t}){const{blocklet:n}=O(),{info:o}=L(),{t:s}=D(),r=De({blocklet:n}),a=tt(o),{spaceGateways:c,addSpaceGateway:i}=U(),d={checkFn:we.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:a,extraParams:{appPid:n.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:o.did}},l=async({endpoint:g,name:m,did:p})=>{const k=await kt(g);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(c.some(y=>y.endpoint===g)){B.error(s("storage.spaces.gateway.add.duplicate",{name:m}));return}await i({name:m,did:p,url:k,endpoint:g},g)},x=async({spaceGateway:g})=>{try{await l(g)}catch(m){console.error(m),B.error(Q(m))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:x})}function Ut(){const{api:t}=L(),{blocklet:n}=O(),{data:o,loading:s}=ke(()=>t.getBlocklet({input:{did:n?.meta?.did,attachDiskInfo:!0,attachRuntimeInfo:!0}}),{ready:!!n?.meta?.did,refreshDeps:[n?.meta?.did]});return{blocklet:o?.blocklet??null,loading:s}}function Pe({...t}){const{t:n}=b.useContext(at),{blocklet:o,loading:s}=Ut();if(o?.diskInfo){const r=(i,d,l)=>e.jsxs(j,{children:[i," ",e.jsx("strong",{children:d?nt(d):"empty"})]}),a=o.environments.reduce((i,d)=>(i[d.key]=d.value,i),{}),c=[{key:"appDir",name:n("blocklet.diskInfo.appDir"),value:r(a.BLOCKLET_APP_DIR,o.diskInfo.app)},{key:"dataDir",name:n("blocklet.diskInfo.dataDir"),value:r(a.BLOCKLET_DATA_DIR,o.diskInfo.data)},{key:"logDir",name:n("blocklet.diskInfo.logDir"),value:r(a.BLOCKLET_LOG_DIR,o.diskInfo.log)},{key:"cacheDir",name:n("blocklet.diskInfo.cacheDir"),value:r(a.BLOCKLET_CACHE_DIR,o.diskInfo.cache)}];return e.jsx(Mt,{component:"div",...t,children:c.map(i=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:i.name,children:i.value},i.key))})}return s?e.jsx(z,{}):e.jsx(j,{children:n("blocklet.diskInfo.empty")})}const Mt=_e(j)``;function Ae(){const{t}=D(),{setBackupDate:n,backupSummary:o}=U(),s=mt({key:"lg"}),r=b.useRef(null),a=We(),c=b.useCallback(l=>{n(l)},[n]),i=b.useMemo(()=>{const l=E().add(1,"day"),x=l.subtract(1,"year"),g=new Map(o.map(p=>[p.date,{date:p.date,successCount:p.successCount,errorCount:p.errorCount}])),m=[];for(let p=x.clone();E(p).isBefore(l);p=p.add(1,"day")){const k=p.format("YYYY-MM-DD");m.push(g.get(k)||{date:k,successCount:0,errorCount:0})}return m},[o]),d=b.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:S,errorCount:y}=i[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${y}</div>`].join(`
2
2
  `)},backgroundColor:a.palette.background.paper,borderColor:a.palette.divider,textStyle:{color:a.palette.text.primary,fontSize:14},extraCssText:`box-shadow: ${a.shadows[2]}; border-radius: 4px;`,padding:[8,10]},visualMap:{show:!1,min:-12,max:12,pieces:[{min:Number.MIN_SAFE_INTEGER,max:-9,color:J[600]},{min:-9,max:-6,color:J[500]},{min:-6,max:-3,color:J[400]},{min:-3,max:-1,color:J[300]},{min:0,max:0,color:a.palette.grey[200]},{min:1,max:3,color:V[300]},{min:3,max:6,color:V[400]},{min:6,max:9,color:V[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:V[600]}],orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:12,textStyle:{color:a.palette.text.secondary,fontSize:12}},calendar:{top:30,left:50,right:10,bottom:4,cellSize:[8,8],splitLine:{show:!1},itemStyle:{borderWidth:2,borderColor:a.palette.background.default,color:a.palette.background.default},dayLabel:{show:!0,firstDay:0,nameMap:["","Mon","","Wed","","Fri",""],position:"start",margin:4,fontSize:10,color:a.palette.text.primary,fontWeight:"400",width:20},monthLabel:{show:!0,nameMap:"cn",align:"left",color:a.palette.text.primary,fontWeight:"400",fontSize:12,position:"start",margin:4,width:30,padding:[0,2]},yearLabel:{show:!1},range:[E().subtract(11,"month").startOf("month").format("YYYY-MM-DD"),E().endOf("month").format("YYYY-MM-DD")],orient:"horizontal"},series:{type:"heatmap",coordinateSystem:"calendar",data:i.map(k=>[k.date,k.errorCount?-k.errorCount:k.successCount]),label:{show:!1},itemStyle:{borderWidth:2,borderColor:a.palette.background.default,borderRadius:4},emphasis:{itemStyle:{borderWidth:2,borderColor:Ke[200],color:"inherit"}}}}),[i,t,a]);return e.jsxs(e.Fragment,{children:[e.jsx(h,{ref:r,sx:{maxWidth:"1280px",border:"1px solid",borderColor:"divider",padding:"8px",overflowX:"auto"},children:e.jsx(h,{sx:{width:"1200px",height:"180px",position:"relative"},children:e.jsx(Et,{option:d,style:{height:"100%",width:"100%"},notMerge:!0,lazyUpdate:!1,opts:{renderer:"canvas"},onEvents:{click:l=>{l.componentType==="series"&&l.data&&c(l.data[0])}}})})}),e.jsx(h,{sx:{display:"flex",justifyContent:"flex-end",mt:1,mr:s?2:5,mb:2},children:e.jsxs(K,{direction:s?"column":"row",spacing:s?2:1,sx:{width:"100%",justifyContent:"flex-start",alignItems:s?"flex-start":"center"},children:[e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #8B5000 0%, #A36200 33%, #C17700 66%, #E29000 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.failed")})]}),e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,bgcolor:"grey.200",border:"1px solid",borderColor:"grey.200"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.without")})]}),e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #9be9a8 0%, #40c463 33%, #30a14e 66%, #216e39 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.succeeded")})]})]})})]})}const Nt=fe(({className:t,...n})=>e.jsx(ge,{...n,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function ve({status:t,message:n="",createdAt:o}){const{t:s}=D(),r=t===T.BACKUPS.STATUS.PROGRESS&&E().diff(o,"hours")>=T.BACKUPS.TIMEOUT_HOURS,a=r&&s("common.timeoutError"),c=t===T.BACKUPS.STATUS.PROGRESS&&!r,i=t===T.BACKUPS.STATUS.SUCCEEDED&&!r;return c?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(z,{sx:{marginRight:"4px"},size:"12px"}),s("common.progress")]}):i?e.jsx(q,{type:"success",children:s("common.succeeded")}):e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"error",children:s("common.failed")}),e.jsx(ge,{style:{display:"flex",alignItems:"center",flexShrink:0},title:n||a,children:e.jsx(be,{children:e.jsx(Ye,{style:{width:"24px",height:"24px"},color:"error"})})})]})}ve.propTypes={status:u.string.isRequired,message:u.string,createdAt:u.string.isRequired};function ze({metadata:t={}}){const{t:n}=D();if(H(t))return e.jsx(q,{type:"success",children:n("common.succeeded")});const o=t.count||0,s=t.size||0,r=It(s,{iec:!0}),a=e.jsxs(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:[e.jsxs(j,{variant:"body2",children:[n("common.fileCount"),": ",o]}),e.jsxs(j,{variant:"body2",children:[n("common.fileSize"),": ",r]})]});return e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"success",children:n("common.succeeded")}),e.jsx(Nt,{title:a,style:{display:"flex",alignItems:"center",flexShrink:0},placement:"left",children:e.jsx(be,{children:e.jsx(Fe,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}ze.propTypes={metadata:u.object};function Oe(){const{t,locale:n}=D(),{spaceGateways:o,backups:s,backupsLoading:r}=U(),a=b.useMemo(()=>[{label:"DID Space",name:"target",options:{customBodyRenderLite:i=>{const{targetUrl:d,targetName:l,status:x,createdAt:g}=s[i],m=x===T.BACKUPS.STATUS.PROGRESS&&E().diff(g,"hours")>=T.BACKUPS.TIMEOUT_HOURS,p=x===T.BACKUPS.STATUS.SUCCEEDED&&!m,k=l||o.find(w=>d?.includes(xe(w?.endpoint)))?.name||"Unknown DID Space";return p?e.jsx(Ge,{href:d,target:"_blank",sx:{fontSize:"16px"},children:k}):e.jsx(j,{variant:"body1",sx:{fontSize:"16px"},children:k})}}},{label:t("common.strategy"),name:"strategy",options:{customBodyRender:i=>{const d=t(i===0?"common.auto":"common.manual");return e.jsx(q,{children:d})}}},{label:t("common.startTime"),name:"createdAt",options:{customBodyRender:i=>E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.endTime"),name:"updatedAt",options:{customBodyRender:i=>H(i)?"":E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:i=>{const d=s?.[i]??{},{status:l,message:x,createdAt:g,metadata:m}=d,p=l===T.BACKUPS.STATUS.PROGRESS&&E().diff(g,"hours")>=T.BACKUPS.TIMEOUT_HOURS,k=l===T.BACKUPS.STATUS.PROGRESS&&!p,w=l===T.BACKUPS.STATUS.SUCCEEDED&&!p;return k?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(z,{sx:{marginRight:"4px"},size:"12px"}),t("common.progress")]}):w?e.jsx(ze,{metadata:m}):e.jsx(ve,{status:l,message:x,createdAt:g})}}}],[s,o,t]),c=b.useMemo(()=>!s?.length,[s]);return e.jsx(e.Fragment,{children:c?e.jsx(h,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px",color:"#9397A1",marginTop:"16px",marginBottom:"24px"},children:t("storage.spaces.record.emptyData")}):e.jsx(rt,{title:"",loading:r,data:s,columns:a,emptyNode:t("storage.spaces.record.emptyData",n),options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}})})}function _t(){const{t}=D();return e.jsxs(h,{children:[e.jsxs(h,{sx:{display:"flex",gap:3,flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",minWidth:240},children:[e.jsx(xt,{style:{cursor:"pointer",width:"150px",height:"100%",maxHeight:160}}),e.jsx(j,{sx:{my:2,textAlign:"center",color:"text.secondary"},children:t("storage.spaces.connect.provider")}),e.jsx(Re,{})]}),e.jsxs(h,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.spaces.backup.records")})}),e.jsx(Ae,{})]})]}),e.jsx(Oe,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2,mt:2},children:t("common.dataStorage")}),e.jsx(Pe,{})]})}function Le({spaceGateway:t,onConfirm:n=()=>{},onCancel:o=()=>{}}){const{t:s}=D(),[r,a]=b.useState(!1),[c,i]=b.useState(!1),d=(g,m)=>{g?.preventDefault(),g?.stopPropagation(),a(m)},l=async g=>{try{g?.stopPropagation(),i(!0),await n?.(t),a(!1)}catch(m){console.error(m),B.error(`${s("storage.space.gateway.delete.failed")}: ${Q(m)}`)}finally{a(!1),i(!1)}},x=g=>{d(g,!1),o?.(g)};return e.jsxs(e.Fragment,{children:[e.jsxs(F,{color:"red",onClick:g=>d(g,!0),children:[e.jsx(Y,{style:{minWidth:24,color:"red"},children:e.jsx($e,{fontSize:"small"})}),e.jsx($,{style:{color:"red"},children:s("common.disconnect")})]}),e.jsx(it,{title:s("storage.spaces.gateway.delete.title"),open:r,confirmButton:{text:s("common.confirm"),props:{size:"small",variant:"contained",color:"error",loading:c}},cancelButton:{text:s("common.cancel"),props:{size:"small",variant:"outlined",disabled:c}},onConfirm:l,onCancel:x,children:e.jsx(j,{sx:{wordWrap:"break-word"},children:s("storage.spaces.gateway.delete.descForBackup",{name:`${t?.name}`})})})]})}Le.propTypes={spaceGateway:u.shape({name:u.string.isRequired,url:u.string.isRequired,protected:u.bool}).isRequired,onConfirm:u.func,onCancel:u.func};function Ue({spaceGateway:t,selected:n,onDelete:o=()=>{},onConnect:s=()=>{},enableSwitchToSpace:r=!0,backupInProgress:a=!1,...c}){const{abortBlockletBackup:i}=U(),[d,l]=b.useState(null),{t:x}=D(),[g,m]=b.useState(!1),p=(S,y)=>{S.stopPropagation(),S.preventDefault(),l(y&&S.currentTarget)},k=async S=>{try{m(!0),p(S,!1),await s(t)}catch(y){console.error(y),B.error(y.message)}finally{m(!1)}},w=async S=>{try{m(!0),p(S,!1),await i()}catch(y){console.error(y),B.error(y.message)}finally{m(!1)}};return e.jsxs(e.Fragment,{children:[g||t?.loading?e.jsx(z,{sx:{ml:1},size:"24px"}):e.jsx(qe,{"aria-label":"more","aria-controls":"actions-menu","aria-haspopup":"true","data-cy":"trigger-blocklet-actions",variant:"outlined",size:"small",onClick:S=>p(S,!0),...c,children:e.jsx(He,{})}),e.jsxs(Qe,{id:"simple-menu",anchorEl:d,keepMounted:!0,open:!!d,onClose:S=>p(S,!1),children:[e.jsxs(F,{onClick:S=>{p(S,!1),window.open(Se(t.endpoint?Ct(t.endpoint):t.url,{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Xe,{fontSize:"small"})}),e.jsx($,{children:x("common.open")})]}),e.jsxs(F,{onClick:S=>{p(S,!1),window.open(Se(wt(t.endpoint),{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Je,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.strategy.viewBackupFiles")})]}),!n&&r&&e.jsxs(F,{onClick:k,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Ve,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.connect.switchToSpace")})]}),a&&e.jsxs(F,{onClick:w,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Ze,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.connect.abortBlockletBackup")})]}),!a&&e.jsx(Le,{spaceGateway:t,onConfirm:async()=>{l(null),await o?.(t)},onCancel:()=>l(null)})]})]})}Ue.propTypes={spaceGateway:u.shape({name:u.string.isRequired,url:u.string.isRequired,protected:u.bool,endpoint:u.string.isRequired,loading:u.bool}).isRequired,selected:u.bool.isRequired,enableSwitchToSpace:u.bool,onDelete:u.func,onConnect:u.func,backupInProgress:u.bool};const Wt=fe(({className:t,...n})=>e.jsx(ge,{...n,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Me({spaceGateway:t,spaceStatus:n,selected:o,onConnected:s=()=>{},onDeleted:r=()=>{},onBackedUp:a=()=>{}}){const{t:c,locale:i}=D(),{blocklet:d}=O(),{api:l,info:{did:x}}=L(),{appDid:g,appName:m,appDescription:p,scopes:k,appUrl:w,referrer:S}=De({blocklet:d}),{backupProgress:y,updateSpaceGateway:Z,deleteSpaceGateway:ee,refreshBackupSummary:te,refreshBackups:se}=U(),[_,M]=b.useState(!1),[I,P]=b.useState({open:!1,action:"one-click-authorization",checkTimeout:1e3*300,messages:{title:c("storage.spaces.authorize.title",{appName:m},i),scan:c("storage.spaces.authorize.scan",{appName:m},i),confirm:"",success:e.jsx(j,{gutterBottom:!0,children:c("storage.spaces.authorize.success")})},onClose:()=>{P(C=>({...C,open:!1}))}}),ne=o&&!_&&n===de.DISCONNECTED,oe=o&&!_&&!t.loading&&n===de.CONNECTED,G=o&&_&&n===de.CONNECTED&&y?.progress>=0,X=async()=>{try{if(await Bt(t?.endpoint)){await l.configBlocklet({input:{did:[d.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:t.endpoint}]}}),B.success(c("storage.spaces.connect.switchToSpaceSucceeded",{name:t.name?`(${t.name})`:""})),s?.(null,t);return}}catch(C){console.error(C),s?.(C,t);return}P(C=>({...C,open:!0,prefix:me(t.url,"space/api/did"),baseUrl:new URL(t.url).origin,checkFn:we.create({baseURL:me(t.url,"space")}).get,extraParams:{appDid:g,appName:m,appDescription:p,scopes:k,appUrl:w,referrer:S,nodeDid:x,spaceDid:t.did}}))},ae=async(C,f)=>{const v=f(C.endpoint),R=xe(v),A=C.space?f(C.space):{};if(t.did&&R!==t.did){P(Ne=>({...Ne,open:!1}));const W=c("storage.spaces.gateway.switch.failedForMismatchSpace",{name:A?.name?A.name:""});B.error(W),s?.(new Error(W),t);return}const ce={...t,name:A.name??"DID Space",did:A.did??xe(v),endpoint:v};await Z(ce),P(W=>({...W,open:!1})),s?.(null,ce)},re=async()=>{try{if(_)return;M(!0),await l.backupBlocklet({input:{appDid:d.appDid,to:"spaces"}})}catch(C){console.error(C),B.error(C.message),a?.(C,t)}finally{M(!0)}},ie=async()=>{try{await ee(t),B.success(c("storage.spaces.gateway.delete.succeeded",{name:t.name?`(${t.name})`:""})),r?.(null,t)}catch(C){console.error(C),r?.(C,t)}};return b.useEffect(()=>{y?.completed?(o&&(y?.progress===100?(B.success(c("storage.spaces.backupSuccessfully")),a?.(null,t)):y.message&&a?.(new Error(y?.message),t),y.progress=0,y.message=""),M(!1),te(),se()):y.progress&&M(!0)},[y]),e.jsxs(e.Fragment,{children:[e.jsxs(h,{sx:{display:"flex",alignItems:"center",".action-btn":{borderRadius:1,marginLeft:1}},children:[oe&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:re,children:c("storage.spaces.strategy.backupNow")}),ne&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:X,children:c("storage.spaces.disconnected.reconnectNow")}),G&&e.jsx(Wt,{title:y?.message&&e.jsx(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:e.jsx(j,{variant:"body2",children:y.message})}),children:e.jsxs(le,{className:"action-btn",variant:"outlined",size:"small",sx:{minWidth:70},children:[e.jsx(z,{variant:"determinate",value:y?.progress,size:14,sx:{mr:1}}),y?.progress,"%"]})}),e.jsx(ot,{forceConnected:!1,saveConnect:!1,prefix:I.prefix,open:I.open,popup:!0,action:I.action,baseUrl:I.baseUrl,checkFn:I.checkFn,onSuccess:ae,onClose:I.onClose,checkTimeout:I.checkTimeout,extraParams:I.extraParams,messages:I.messages,locale:i},"get-endpoint")]}),e.jsx(Ue,{sx:{minWidth:32,padding:"2px 4px",ml:1},spaceGateway:t,selected:o,onDelete:ie,onConnect:X,enableSwitchToSpace:y?.completed||H(y?.message),backupInProgress:G})]})}Me.propTypes={spaceGateway:u.shape({did:u.string.isRequired,name:u.string.isRequired,url:u.string.isRequired,endpoint:u.string.isRequired,protected:u.bool,loading:u.bool}).isRequired,spaceStatus:u.string.isRequired,selected:u.bool.isRequired,onConnected:u.func,onDeleted:u.func,onBackedUp:u.func};function Kt({...t}){const{t:n}=D();return e.jsxs(h,{...t,children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:n("storage.spaces.backup.records")})}),e.jsx(Ae,{}),e.jsx(Oe,{})]})}function Gt({...t}){const{t:n}=D(),{autoBackup:o,updateAutoBackup:s}=U(),r=async()=>{try{const a=!o?.enabled;await s({enabled:a}),B.success(n(a?"storage.spaces.autoBackup.enabled":"storage.spaces.autoBackup.disabled"))}catch(a){B.error(a.message)}};return e.jsx(Tt,{checked:!!o?.enabled,onChange:r,name:"enableWelcomePage",labelProps:{label:e.jsx(j,{sx:{marginRight:"8px"},children:e.jsx("span",{children:n("storage.spaces.autoBackup.title")})})},style:{...t.style}})}function Ft(){const{t}=D(),{spaceGateways:n,spaceGatewaysLoading:o,spaceGatewayIsSelected:s}=U(),r=o&&!n?.length,a=({spaceGateway:c,spaceStatus:i,selected:d,refresh:l})=>e.jsx(Me,{spaceGateway:c,spaceStatus:i,selected:d,onConnected:()=>l(),onBackedUp:x=>x&&l()});return e.jsxs(h,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},gap:{xs:1,md:2},justifyContent:{xs:"center",md:"flex-start"},alignItems:{xs:"flex-start",md:"center"}},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",flexGrow:1},children:t("storage.spaces.connected.title")}),e.jsx(Gt,{}),e.jsx(Re,{})]}),e.jsx(h,{sx:{mt:2},children:r?e.jsx(h,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(z,{})}):e.jsx(he,{container:!0,spacing:2,children:e.jsx(e.Fragment,{children:n.map(c=>e.jsx(he,{size:{xs:12,md:6},children:e.jsx(ft,{endpoint:c.endpoint,selected:s(c),action:a},c.endpoint)},c.endpoint))})})}),e.jsx(Kt,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2},children:t("common.dataStorage")}),e.jsx(Pe,{})]})}function Yt(){const{spaceGatewaysFirstLoading:t,spaceGateways:n}=U();return t?e.jsx(Be,{relative:"parent",children:e.jsx(z,{})}):H(n)?e.jsx(_t,{}):e.jsx(Ft,{})}function $t(){return e.jsx(Te,{children:e.jsx(Yt,{})})}function qt(){const{spaceGateway:t,settingStorageEndpoint:n,updateSpaceGateway:o,hasStorageEndpoint:s,loading:r,storageEndpoint:a}=Pt(),c=ue(()=>({display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"16px"}));return r?e.jsx(Be,{relative:"parent",children:e.jsx(z,{})}):e.jsxs(h,{sx:{maxWidth:"md",position:"relative"},children:[s?e.jsx(gt,{spaceGateway:t,settingStorageEndpoint:n}):e.jsx(ht,{}),e.jsx(h,{sx:c,children:e.jsx(St,{onConnect:o,storageEndpoint:a})})]})}function Ht(){const{t}=D();return e.jsxs(Rt,{children:[e.jsxs(K,{spacing:1,sx:{marginBottom:2},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.appLevel.title")}),e.jsx(j,{sx:{color:"text.secondary"},children:t("storage.appLevel.description")})]}),e.jsx(qt,{})]})}function Qt({navOrientation:t="vertical",...n}){const{t:o,locale:s}=D(),{blocklet:r}=O(),a=lt({key:"md"}),[c,i]=et(),d=c.get("tab")||"backup",l=a?"horizontal":t,x=ue(()=>{const w=[{label:o("common.backup"),value:"backup"}],S=r?.capabilities?.didSpace;return(S===N.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED||S===N.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP)&&w.push({label:o("common.storage"),value:"storage"}),w},[s,l]),m=ue(()=>({backup:e.jsx($t,{}),storage:e.jsx(Ht,{})}))[d],p=w=>{i(S=>(w==="backup"?S.delete("tab"):S.set("tab",w),S))};if(x.length<=1)return e.jsx(pe,{children:m});const k=e.jsx(ct,{tabs:x,current:d,orientation:l,onChange:p,sx:[{borderRight:1,height:"100%",borderColor:"divider"},l==="horizontal"&&{borderRight:0}]});if(l==="vertical")return e.jsx(h,{...n,children:e.jsxs(K,{direction:{md:"column",lg:"row"},sx:{gap:2},children:[e.jsx(h,{sx:{flexShrink:0},children:e.jsx(ye,{left:k})}),e.jsx(h,{sx:{flexGrow:1,minWidth:0},children:e.jsx(pe,{sx:{mt:1},children:m})})]})});if(l==="horizontal")return e.jsxs(h,{...n,children:[e.jsx(ye,{left:k}),e.jsx(pe,{sx:{mt:2},children:m})]})}Qt.propTypes={navOrientation:u.oneOf(["vertical","horizontal"])};const pe=fe(h)`
3
3
  position: relative;
4
4
  min-height: 66vh;
@@ -0,0 +1,124 @@
1
+ import{j as e,y as ht,bc as ye,M as ne,ak as x,Q as G,W as p,J as ve,c1 as xt,I as D,aN as gt,T as A,aj as mt,b5 as Pe,P as Ie,b6 as Te,a5 as Re,z as Ue,A as Fe,cj as bt,bh as yt,U as Me,cS as vt,cT as wt,at as Z,cU as jt,a6 as V,n as oe,D as Ct,cV as kt,ar as Ae,b1 as we,cW as St,aX as Pt,a$ as It,cX as Tt}from"./vendor-mui-core-Et2SVbGP.js";import{r as y,a as Rt,u as Mt,j as At}from"./vendor-react-CUXIiAnY.js";import{t as _e,Z as Et,a4 as zt,R as Ee,D as Lt,C as se,n as H,A as Wt}from"./vendor-utils-DZwtp8ph.js";import{a as Dt,G as Bt,bi as $t,c as je,Z as Ot,bj as Nt,aA as qe,X as le,bf as Ut,bk as Ft,a9 as _t,aa as qt,bl as Ht}from"./index-B7aKP8pi.js";import{a as R,h as Gt,k as ce,g as Q,b as M,j as Kt}from"./vendor-hooks-BeI8hpF9.js";import{l as He}from"./arrow-down.svg-OnWcVrr5.js";import{s as Ce,a3 as z,V as L,ay as Vt,z as Ge,az as Yt,H as O,aA as Zt,aB as Qt,aC as ze,v as Xt,n as Ke,p as ke,aD as Jt,aE as T,Q as er,P as tr,$ as rr,aF as nr,aG as or,o as Ve}from"./vendor-ux-Y094QNTK.js";import{N as sr}from"./list-CTOAY-ou.js";import{d as ir}from"./search-4YYphs0l.js";import{B as Le}from"./bundle-avatar-mI1l0Wbs.js";import{h as We,T as ar}from"./team-CsIX00_k.js";import{b as lr,d as cr,a as dr,c as ur,e as pr,f as fr,h as hr,$ as xr}from"./user-center-xqAXQ-SZ.js";import{T as De,O as gr}from"./index-ClXbSPXF.js";import{c as mr}from"./passport-UxiDT8mW.js";import{N as Ye,U as Ze}from"./index-CIxFbeb7.js";import{u as de}from"./use-mobile-CbzGNuhc.js";import br from"./index-uV0wgve2.js";import{U as yr,a as vr}from"./user-follower-Dv6JnrUr.js";import{f as Y}from"./index-DBs9Ljax.js";import{u as me}from"./index-BKN6q696.js";import wr from"./index-D1fu_Ebn.js";import{o as jr}from"./vendor-arcblock-D5spFpjt.js";import{c as Cr,b as ie,a as kr,S as Sr}from"./index-CzmL_Hvj.js";import"./index-AgA4sW48.js";import"./index-BojVbZw0.js";import"./lottie-web-4koyQiv_.js";import"./server-logo-notext.svg-DHxZ1bRk.js";import"./util-Cd42TaWI.js";import"./base32-DmEq36OL.js";import"./session-4l80Me2P.js";import"./isURL-C5WG5wCh.js";import"./use-app-logo-BebTliBo.js";import"./index-CCVrpeOq.js";import"./revoke.svg-CuiCGfVW.js";import"./use-mobile-D-631edY.js";import"./actions-DHp-gk7h.js";import"./index-XWTmneBy.js";import"./form-text-input-BdG6b7xY.js";import"./required-Cwbcx6Cg.js";import"./form-wrapper-D4szSlOw.js";import"./edit.svg-Dz9cVo7r.js";import"./lock.svg-BPCZ0CT3.js";import"./index-C0q0zQTI.js";import"./permission-D6_WOpI3.js";import"./confirm-7CqzZykT.js";import"./click-to-copy-Cq4W-wkJ.js";import"./invitations-DfUvBLlf.js";import"./create-passport-svg-CESSejlW.js";import"./api-C1vNuLNj.js";import"./table-tips-AK8Y4Q8i.js";import"./ua-parser-DP5omx3I.js";import"./sdk-CLOiRS-Q.js";import"./passport-item-B2H7GQg8.js";import"./did-address-gjwvc_rF.js";import"./index-DgXRGMR4.js";import"./vendor-mui-x-BIXAJqK8.js";import"./AdapterDayjs-DlsssqYa.js";import"./delete-confirm-D1LtCumr.js";import"./index-DRYJ0xIl.js";function Pr(){let t=new Map;function i({root:s,rootMargin:n,threshold:o}){let f=t.get(s);f||(f=new Map,t.set(s,f));let a=JSON.stringify({rootMargin:n,threshold:o}),d=f.get(a);if(!d){let r=new Map;d={observer:new IntersectionObserver(h=>{h.forEach(b=>{r.get(b.target)?.(b)})},{root:s,rootMargin:n,threshold:o}),entryCallbacks:r},f.set(a,d)}return{observe:(r,h)=>{d.entryCallbacks.set(r,h),d.observer.observe(r)},unobserve:r=>{d.entryCallbacks.delete(r),d.observer.unobserve(r)}}}return{getObserver:i}}var Ir="0px",Tr=[0],Rr=Pr();function Mr(t){let i=t?.rootMargin??Ir,s=t?.threshold??Tr,n=y.useRef(null),o=y.useRef(null),f=y.useRef(null),[a,d]=y.useState(),r=y.useCallback(()=>{let j=n.current;if(!j){d(void 0);return}let v=Rr.getObserver({root:o.current,rootMargin:i,threshold:s});v.observe(j,l=>{d(l)}),f.current=v},[i,s]),h=y.useCallback(()=>{let j=f.current,v=n.current;v&&j?.unobserve(v),f.current=null},[]),b=y.useCallback(j=>{h(),n.current=j,r()},[r,h]),u=y.useCallback(j=>{h(),o.current=j,r()},[r,h]);return[b,{entry:a,rootRef:u}]}var Ar=Mr;function Er(t){let[i,s]=Ar(t),n=!!s.entry?.isIntersecting,[o,f]=y.useState(n);return n&&!o&&f(!0),[i,{...s,isVisible:n,wasEverVisible:o}]}var zr=Er,Lr=100;function Wr({loading:t,hasNextPage:i,onLoadMore:s,rootMargin:n,disabled:o,delayInMs:f=Lr}){let a=y.useRef(s),[d,{rootRef:r,isVisible:h}]=zr({rootMargin:n});y.useEffect(()=>{a.current=s},[s]);let b=!o&&!t&&h&&i;return y.useEffect(()=>{if(b){let u=setTimeout(()=>{a.current()},f);return()=>{clearTimeout(u)}}},[b,f]),[d,{rootRef:r}]}var Dr=Wr;const ge={info:"#3B82F6",success:"#10B981",warning:"#F59E0B",error:"#EF4444"};ae.propTypes={severity:p.oneOf(["info","success","warning","error",""]).isRequired,size:p.number};function ae({severity:t,size:i=8}){return ge[t]?e.jsx(x,{component:"span",sx:{display:"inline-block",width:i,height:i,borderRadius:"50%",backgroundColor:ge[t]||ge.info}}):null}Qe.propTypes={theme:p.string,type:p.oneOf(["button","line","select"]),onSelectType:p.func,extra:p.node,loading:p.bool,currentTab:p.oneOf(["info","success","warning","error",""])};function Qe({theme:t="dark",type:i="button",onSelectType:s,extra:n=void 0,currentTab:o="",loading:f=!1,...a}){const{t:d}=y.useContext(Ce),r=[{label:d("notification.allSeverity"),value:""},{label:d("notification.severityType.info"),value:"info"},{label:d("notification.severityType.success"),value:"success"},{label:d("notification.severityType.warning"),value:"warning"},{label:d("notification.severityType.error"),value:"error"}],h=g=>{(g!==o||!f)&&s(g)},b=y.useMemo(()=>{const g={width:"100%",bgcolor:t==="dark"?"#F9FAFB":"",overflowY:"auto",paddingTop:i==="select"?"0":"5px",whiteSpace:"nowrap",borderRadius:0,display:"flex",justifyContent:"space-between",alignItems:"flex-end",flexWrap:"wrap",gap:"8px"};return i==="line"?Object.assign(g,{}):g},[i,t]),u=(g,k,I)=>e.jsx(G,{disabled:f,onClick:()=>h(g.value),className:`profile-button ${k?"active":""}`,...a,children:g.label},g.value||I),j=(g,k,I)=>e.jsx(G,{variant:"text",disabled:f,onClick:()=>h(g.value),className:`profile-line-button ${k?"active":""}`,...a,children:g.label},g.value||I),v=()=>r?.map((g,k)=>{const I=o===g?.value;return i==="line"?e.jsx(y.Fragment,{children:j(g,I,k)},g.value||k):e.jsx(y.Fragment,{children:u(g,I,k)},g.value||k)}),l=g=>{const{value:k}=g.target;h(k==="all"?"":k)};return i==="select"?e.jsx(ht,{sx:{maxWidth:300},children:e.jsx(ye,{value:o||"all",onChange:l,size:"small",label:"Severity",IconComponent:g=>e.jsx(He,{...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(ne,{value:g.value||"all",children:e.jsxs(x,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(ae,{severity:g.value}),g.label]})},g.value||k))})}):e.jsxs(x,{className:"severity-tabs",sx:b,children:[e.jsx(x,{sx:{...i==="line"?{flex:1,borderBottom:"1px solid",borderColor:"grey.200"}:{display:"flex",gap:"24px"}},children:v()}),n]})}Xe.propTypes={paging:p.objectOf(p.any).isRequired,loading:p.bool.isRequired,onChange:p.func.isRequired};function Xe({loading:t,paging:i,onChange:s}){const{t:n}=y.useContext(Ce),o=ve(r=>r.breakpoints.down("md"));if(i.pageCount<=0||o)return null;const f=(r,h)=>{s({page:h+1})},a=r=>{const h=Number(r.target.value);s({page:1,pageSize:h})},d=i.page-1<=0?0:i.page-1;return e.jsx(x,{className:"notification-pagination",sx:{mt:2,display:"flex",justifyContent:"flex-end"},children:e.jsx(xt,{component:"div",disabled:t,count:i.total,page:d,rowsPerPageOptions:[10,20,50,100],labelRowsPerPage:n("pagination.rowsPerPage"),labelDisplayedRows:({from:r,to:h,count:b})=>`${r}–${h} / ${b!==-1?b:`${n()}more than ${h}`}`,rowsPerPage:i.pageSize,onPageChange:f,onRowsPerPageChange:a})})}const Br=y.memo(Xe),$r={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"/>'},Be=6,$e={"& .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}},Or={border:"1px solid",borderColor:"divider",borderRadius:1,overflow:"hidden",backgroundColor:"background.paper",backgroundImage:"none",transition:"all 0.2s ease-in-out"},Oe=()=>({...Or,width:"calc(50% - 8px)"});Je.propTypes={loading:p.bool,type:p.oneOf(["server","service"]),onFilterChange:p.func,blockletMap:p.object,filterType:p.oneOf(["component","entity"]),selectedId:p.array,severity:p.array,enableMarkAllAsRead:p.bool,unReadCount:p.number,onReadFilterChange:p.func,currentReadFilter:p.string};function Je({onFilterChange:t=()=>{},loading:i=!1,type:s="service",blockletMap:n={},filterType:o="component",selectedId:f=[],severity:a=[],enableMarkAllAsRead:d=!0,unReadCount:r=0,onReadFilterChange:h=()=>{},currentReadFilter:b="all"}){const{t:u}=y.useContext(Ce),[j,v]=y.useState(null),l=!!j,[g,k]=y.useState(f),[I,W]=y.useState(a),[m,C]=y.useState(!1),[S,_]=y.useState(""),[B,N]=y.useState([]);y.useEffect(()=>{k(f),W(a)},[f,a]);const U=[{label:u("notification.filterType.all"),value:"all"},{label:u("notification.filterType.unread"),value:"unread"}],X=c=>{(c!==b||!i)&&h(c)},K=[{label:u("notification.severityType.info"),value:"info"},{label:u("notification.severityType.success"),value:"success"},{label:u("notification.severityType.warning"),value:"warning"},{label:u("notification.severityType.error"),value:"error"}],J=c=>{v(c.currentTarget),_(""),C(!1)},pe=()=>{v(null)},ee=c=>{const w=g.includes(c)?g.filter(P=>P!==c):[...g,c];k(w),t({id:w,severity:I})},te=c=>{const w=I.includes(c)?I.filter(P=>P!==c):[...I,c];W(w),t({severity:w,id:g})},fe=c=>{_(c.target.value)},he=()=>{C(!m)},q=Rt.useMemo(()=>{if(!n.size)return[];const c=[];return o==="component"&&c.push({label:u("notification.system"),id:"system"}),Array.from(n).forEach(([,w])=>{const P=w.did||w.meta?.did,E=w.title||w.meta?.title||"",$=w.appPid||w.appDid;(o==="component"&&$!==P||o==="entity"&&$===P)&&c.push({label:E,id:P,blocklet:w,ancestors:w.ancestors})}),c},[n,o,u]);y.useEffect(()=>{if(S.trim()==="")N(q);else{const c=S.toLowerCase(),w=q.filter(P=>P.label.toLowerCase().includes(c));N(w)}},[S,q]);const xe=S.trim()!==""||m?B:B.slice(0,Be);return e.jsxs(x,{children:[e.jsxs(x,{sx:{display:"flex",justifyContent:d?"space-between":"flex-end",alignItems:"flex-start",flexWrap:"wrap",gap:1},children:[d&&e.jsx(x,{sx:{display:"flex",gap:1.5},children:U.map(c=>e.jsxs(G,{disabled:i,onClick:()=>X(c.value),className:`profile-button ${b===c.value?"active":""}`,sx:{...s==="service"&&b===c.value?{color:"secondary.main"}:{},color:"red",fontWeight:b===c.value?"bold":"normal"},children:[c.label,c.value==="unread"&&r>0&&` (${r})`]},c.value))}),e.jsxs(x,{sx:{display:"flex",justifyContent:"flex-end",gap:2},children:[e.jsx(D,{size:"small",onClick:J,disabled:i,sx:{minWidth:"auto",borderRadius:1,border:"1px solid",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:e.jsx(z,{icon:$r,hFlip:!0})}),e.jsx(gt,{open:l,anchorEl:j,onClose:pe,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(x,{children:[e.jsxs(x,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,height:"28px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:u("notification.severity")}),e.jsx(x,{sx:{minWidth:"60px",display:"flex",justifyContent:"flex-end"},children:(g.length>0||I.length>0)&&e.jsx(G,{size:"small",onClick:()=>{k([]),W([]),t({severity:[],id:[]})},startIcon:e.jsx(mt,{fontSize:"small"}),sx:{color:"text.secondary",textTransform:"none",minWidth:"auto","&:hover":{backgroundColor:"transparent"},"& .MuiButton-startIcon":{marginRight:"2px"}},children:u("notification.clear")})})]}),e.jsx(x,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(Pe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:2,flex:1},children:K.map(c=>e.jsx(Ie,{elevation:0,sx:Oe(I.includes(c.value)),children:e.jsx(Te,{sx:{margin:0,padding:.5,width:"100%","& .MuiFormControlLabel-label":{display:"flex",alignItems:"center",gap:1,fontSize:"0.875rem"},...$e},control:e.jsx(Re,{checked:I.includes(c.value),onChange:()=>te(c.value),disabled:i,size:"small"}),label:e.jsxs(x,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:.5},children:[e.jsx(ae,{severity:c.value}),c.label]})})},c.value))})}),e.jsxs(x,{sx:{mb:2},children:[e.jsxs(x,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,mb:1.5},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold",width:"calc(100% - 36px)"},children:u("notification.from")}),e.jsx(x,{sx:{display:"flex",alignItems:"center",width:"calc(100% - 36px)"},children:e.jsx(Ue,{size:"small",placeholder:"search",value:S,onChange:fe,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(Fe,{position:"start",sx:{marginRight:"2px"},children:e.jsx(z,{icon:ir})})}}})})]}),e.jsx(Pe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:2},children:xe.map(c=>e.jsx(Ie,{elevation:0,sx:Oe(g.includes(c.id)),children:e.jsx(Te,{sx:{margin:0,padding:.5,width:"100%","& .MuiFormControlLabel-label":{fontSize:"0.875rem",width:"calc(100% - 36px)"},...$e},control:e.jsx(Re,{checked:g.includes(c.id),onChange:()=>ee(c.id),disabled:i,size:"small"}),label:e.jsxs(x,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:.5,minWidth:0,width:"100%"},children:[c.blocklet&&e.jsx(Le,{size:20,blocklet:c.blocklet,ancestors:c.ancestors,style:{borderRadius:4,flexShrink:0}}),e.jsx(A,{noWrap:!0,variant:"body2",component:"span",title:c.label,sx:{flex:1,overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:c.label})]})})},c.id))}),B.length>Be&&S.trim()===""&&e.jsx(G,{fullWidth:!0,size:"small",onClick:he,sx:{mt:1},endIcon:m?e.jsx(bt,{}):e.jsx(yt,{})})]})]})})]})]}),g.length>0||I.length>0?e.jsxs(x,{className:"notification-filter-content",sx:{display:"flex",flexWrap:"wrap",gap:1,mt:2},children:[I.map(c=>{const w=K.find(P=>P.value===c);return e.jsx(Me,{label:e.jsxs(x,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(ae,{severity:c}),w?w.label:c]}),onDelete:()=>te(c),size:"small",variant:"outlined",sx:{borderRadius:2,color:"text.secondary",borderColor:"divider","& .MuiChip-label":{display:"flex",alignItems:"center"}}},`severity-${c}`)}),g.map(c=>{const w=q.find(P=>P.id===c);return e.jsx(Me,{label:e.jsxs(x,{sx:{display:"flex",alignItems:"center",gap:.5},children:[w?.blocklet&&e.jsx(Le,{size:16,blocklet:w.blocklet,ancestors:w.ancestors,style:{borderRadius:4,flexShrink:0}}),w?w.label:c]}),variant:"outlined",onDelete:()=>ee(c),size:"small",sx:{borderRadius:2,color:"text.secondary",borderColor:"divider","& .MuiChip-label":{display:"flex",alignItems:"center"}}},`component-${c}`)})]}):null]})}const Nr=Z(jt)`
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 Ur(){const[t,i]=y.useState(!1);y.useEffect(()=>{const n=_e(()=>{i(window.pageYOffset>300)},200);return window.addEventListener("scroll",n),n(),()=>window.removeEventListener("scroll",n)},[]);const s=()=>{try{"scrollTo"in window?window.scrollTo({top:0,behavior:"smooth"}):window.scrollTo(0,0)}catch{window.scrollTo(0,0)}};return e.jsx(vt,{in:t,children:e.jsx(Nr,{color:"primary",size:"small","aria-label":"scroll back to top",onClick:s,children:e.jsx(wt,{})})})}const Fr=Z.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})=>oe(t.palette.primary.main,.1)};
36
+ border: 1px solid ${({theme:t})=>oe(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
+ `;et.propTypes={blocklets:p.array,context:p.object,pagination:p.bool,inDialog:p.bool,filterType:p.oneOf(["component","entity"]),toViewAll:p.func,type:p.oneOf(["server","service"])};function et({blocklets:t=[],context:i,pagination:s=!0,inDialog:n=!1,filterType:o="component",toViewAll:f=()=>{},type:a="service"}){const{data:d,paging:r,refresh:h,loading:b,params:u,onReadNotification:j,componentDids:v,filterUnReadCount:l,initial:g}=i,k=c=>{h({...u,severity:c&&typeof c=="string"?[c]:c||[],paging:{...u.paging,page:1}})},[I]=Mt(),W=R(()=>I.get("id"),[I]),m=ve(c=>c.breakpoints.down("md")),[C,S]=y.useState(0),[_,B]=y.useState(!1),N=y.useMemo(()=>u.read===!1?"unread":"all",[u.read]),U=R(()=>_e(c=>{if(b)return;const w=d.length,P=d.filter($=>!We($)).length;let E={...u,append:!0,paging:{...u.paging,...c,currentPage:(r.currentPage||0)+1}};N==="unread"&&P<w&&c.page>u.paging.page&&(E={...u,append:!0,paging:{...u.paging,...c,page:u.paging.page||1,currentPage:(r.currentPage||0)+1}}),h(E)},500),[d,u,N,r,b,h]);Gt(()=>{g&&typeof g=="function"&&g()}),y.useEffect(()=>{(!r.currentPage||r.currentPage===1)&&S(r.total)},[r.total,r.currentPage]),y.useEffect(()=>{setTimeout(()=>{const c=document.getElementById(W);c&&c.scrollIntoView({behavior:"smooth",block:"center"}),B(!0)},100),setTimeout(()=>{B(!1)},3e3)},[W]);const X=R(()=>d?.length>0&&d.length<C,[d,C]),K=y.useCallback(c=>{const{blocklet:w={}}=window,P=[w?.did,...(w?.ancestors||[]).map(E=>E)];return v?.includes(c)||P.findIndex(E=>E===c)>-1},[v]),J=y.useMemo(()=>{const c=new Map;return t.length&&t.forEach(w=>{const P=w?.did||w.meta?.did;P&&!c.has(P)&&(w.ancestors=[],c.set(P,w),w?.alsoKnownAs?.length>0&&w.alsoKnownAs.forEach(E=>{c.has(E)||c.set(E,w)})),w?.children?.length>0&&w.children.forEach(E=>{const $=E?.did||E.meta?.did;$&&!c.has($)&&K($)&&(E.ancestors=[w],c.set($,E))})}),c},[t,K]),pe=y.useCallback(()=>{b||U({page:r.page+1})},[r.page,b,U]),[ee]=Dr({loading:b,hasNextPage:X,onLoadMore:pe}),te=c=>{!c||We(c)||j(c.id).then(()=>{n&&f()})},fe=({severity:c,id:w})=>{if(b)return;let P={};o==="component"?P={entityId:[],componentDid:w}:o==="entity"&&(P={componentDid:[],entityId:w}),h({...u,severity:c,...P,paging:{...u.paging,page:1}})},he=c=>{if(b)return;let w={...u,paging:{...u.paging,page:1}};c==="unread"?(w.read=!1,w.paging.currentPage=1):w=Et(w,"read"),h(w)},q=R(()=>o==="component"?Array.isArray(u.componentDid)?u.componentDid:[]:o==="entity"?Array.isArray(u.entityId)?u.entityId:[]:[],[u,o]),xe=R(()=>(Array.isArray(u.severity)?u.severity:[])[0]||"",[u.severity]);return e.jsxs(Fr,{inDialog:!!n,children:[n?e.jsx(Qe,{currentTab:xe,type:"line",theme:"light",onSelectType:k}):e.jsx(Je,{loading:b,blockletMap:J,unReadCount:l,filterType:o,type:a,selectedId:q,onFilterChange:fe,severity:u.severity,onReadFilterChange:he,currentReadFilter:N}),!m&&b?e.jsx(x,{sx:{display:"flex",width:"100%",minHeight:400,justifyContent:"center",alignItems:"center"},children:e.jsx(V,{})}):e.jsx(sr,{data:d,blockletMap:J,onReadNotification:te,onReadBatch:j,inDialog:n,highlightId:W,highlight:!n&&_,type:a}),s&&!m?e.jsx(Br,{loading:b,paging:r,onChange:U}):null,s&&m&&(b||X)?e.jsx(x,{ref:ee,sx:{display:"flex",width:"100%",minHeight:100,justifyContent:"center",alignItems:"center"},children:e.jsx(V,{})}):null,!n&&m?e.jsx(Ur,{}):null]})}const _r=y.memo(et),F=new $t;function ue(t){const{userDid:i=""}={},{session:s}=Dt(),n=R(()=>{if(i)return i;const r=window.location.href,h=zt(r);return h?.did?Array.isArray(h.did)?h.did[0]:h.did:s?.user?.did},[s?.user?.did,i]),o=R(()=>s.user,[s]),f=R(()=>o?n===o?.did:!1,[n,o?.did]),a=ce(async()=>{if(await Bt(()=>s?.initialized),f)return s.user;if(n)return F.user.getUserPublicInfo({did:n})},{refreshDeps:[n,f,s?.initialized,o]}),d=R(()=>o?.passports?.some(r=>r.role===je.ROLES.OWNER),[o]);return{currentDid:n,session:s,isMyself:f,user:o,viewUser:a.data,isOwner:d}}function tt({user:t,...i}){const{t:s}=L(),n=Ct(),o=R(()=>{const d=(t?.passports||[]).map(r=>({...r,revoked:r.status===Vt.REVOKED}));return d.sort((r,h)=>r.revoked===h.revoked?0:r.revoked?1:-1),Ee(d.filter(r=>!r.display),"role").concat(Ee(d.filter(r=>r.display),"display.content"))},[t?.passports]),f=R(()=>o?.find(d=>d.name===t.role),[o,t?.role]),a=n.palette.primary.main;return o.length===0?e.jsx(x,{children:e.jsx(Ge,{children:s("userCenter.noPassport")})}):e.jsx(x,{...i,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,...i.sx},children:o.map(d=>e.jsx(lr,{passport:d,user:t,color:window.blocklet.passportColor,createPassportSvg:mr,title:f&&f.role===d.role?s("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:f&&f.role===d.role?`0px 2px 4px 0px ${a}, 0px 1px 2px -1px ${a}, 0px 0px 0px 1px ${a} !important`:"unset"},".passport-item__body":{marginLeft:"0 !important"}}},d.id))})}tt.propTypes={user:p.object.isRequired};function qr({visible:t,onClose:i,nft:s}){return!t||!s?null:e.jsx(Hr,{children:e.jsx(kt,{open:t,onClose:i,children:e.jsx(Gr,{onClick:i,children:e.jsx(Ye,{data:Ze(s),address:s.address,inset:!0})})})})}const Hr=Z.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
+ `,Gr=Z.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
+ `,Kr=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:oe(t.palette.background.paper,.9),color:"text.primary","&:hover":{backgroundColor:oe(t.palette.background.paper,1)}}}),Vr={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"}},Ne="https://main.abtnetwork.io/explorer";function rt({user:t}){const{t:i,locale:s}=L(),n=de(),[o,f]=y.useState({visible:!1,nft:null}),[a,d]=y.useState({anchorEl:null,props:null}),r=m=>{const C=se(Ne,"assets",m);window.open(C,"_blank")},h=(m,C)=>{let S="";typeof C.data?.value=="string"?S=JSON.parse(C.data?.value)?.domain:S=C.data?.value?.domain,d({anchorEl:m,props:{title:S?`Hey, I just won an NFT at the ${S} event!`:"Hey, I just won an NFT!",url:se(Ne,"assets",C.address)}})},b=m=>{f({visible:!0,nft:m})},u=Q({page:1,size:20}),j=ce(async(m=u)=>(await Lt.get(`${je.WELLKNOWN_SERVICE_PATH_PREFIX}/ocap/listAssets`,{params:{ownerAddress:t.did,...m}})).data,{ready:t?.did&&u,defaultParams:[u],refreshDeps:[t?.did,u]}),{loading:v,data:l}=j,g=l?.page??{cursor:0,next:!1,total:0},k=(m,C)=>{u.page=C,j.run(u)},I=M(m=>[e.jsx(D,{size:"small",className:"mask-item",onClick:C=>{C.stopPropagation(),r(m.address)},children:e.jsx(z,{icon:"tabler:link",fontSize:18})},"link"),e.jsx(D,{size:"small",onClick:C=>{C.stopPropagation(),h(C.currentTarget,m)},className:"mask-item",children:e.jsx(z,{icon:"tabler:share-2",fontSize:18})},"share"),e.jsx(D,{size:"small",onClick:C=>{C.stopPropagation(),b(m)},className:"mask-item",children:e.jsx(z,{icon:"tabler:eye",fontSize:18})},"view")]),W=R(()=>{if(v){const m=["skeleton-1","skeleton-2","skeleton-3","skeleton-4","skeleton-5"].map(C=>e.jsx(Ae,{variant:"rectangular",width:"15%",height:166,sx:{borderRadius:1,flexShrink:0}},C));return e.jsxs(x,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx(Ae,{width:"20%"}),e.jsx(x,{sx:{display:"flex",flexDirection:"row",gap:2,flexWrap:"nowrap"},children:m})]})}return e.jsxs(e.Fragment,{children:[e.jsx(A,{sx:{color:"grey.A700",fontWeight:600,mb:2.5},children:i("userCenter.common.nft")}),l?.assets?.length===0&&!v&&e.jsx(x,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%"},children:e.jsx(Ge,{children:i("userCenter.common.noNFT")})}),e.jsx(x,{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:l?.assets?.map(m=>e.jsxs(x,{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",...n?{}:{"&:hover .mask":{opacity:1}}},children:[e.jsx(Ye,{data:Ze(m),address:m.address,inset:!0,imageFilter:{imageFilter:"resize",w:"500",f:"webp"}}),n?e.jsx(x,{className:"footer-mask",sx:Vr,children:I(m)}):e.jsx(x,{className:"mask",sx:Kr,children:e.jsx(we,{direction:"row",spacing:1,children:I(m)})})]},m.address))}),g.next||u.page>1?e.jsx(St,{sx:{display:"flex",justifyContent:"center",mt:2},page:u.page,onChange:k,count:Math.ceil(g.total/u.size),size:"small"}):null,e.jsx(qr,{visible:o.visible&&!!o.nft,nft:o.nft,onClose:()=>{f({visible:!1,nft:null})}}),e.jsx(Yt,{locale:s,anchorEl:a.anchorEl,onClose:()=>{d({anchorEl:null,props:null})},sharedProps:a.props||{title:"",url:""}})]})},[v,g,u.page,u.size,k,a,o]);return e.jsx(x,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1,p:2,mb:5},children:W})}rt.propTypes={user:p.object.isRequired};function Yr(){const{t}=L(),{user:i,isMyself:s,viewUser:n}=ue();return e.jsxs(x,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[s?e.jsxs(x,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1.5,p:2},children:[e.jsx(A,{sx:{color:"text.primary",fontWeight:600,mb:2.5},children:t("userCenter.passport")}),e.jsx(tt,{user:i})]}):null,e.jsx(rt,{user:s?i:n})]})}const Zr=[{name:"English",code:"en"},{name:"中文",code:"zh"}];function nt({user:t,onSave:i}){const{t:s,changeLocale:n}=L(),o=Q({locale:t.locale,loading:!1}),f=M(async a=>{try{const{value:d}=a.target;o.loading=!0,await F.user.saveProfile({locale:d}),await i("profile"),n(d),o.locale=d}catch(d){O.error(Y(d))}finally{o.loading=!1}});return e.jsxs(x,{sx:{gap:1,display:"grid",alignItems:"center",gridTemplateColumns:{xs:"1fr",sm:"max-content 1fr"}},children:[e.jsx(x,{children:s("userCenter.commonSetting.locale")}),e.jsx(x,{children:e.jsx(ye,{value:o.locale,onChange:f,size:"small",IconComponent:a=>e.jsx(He,{...a,width:20,height:20}),sx:{minWidth:200,"&:hover":{"fieldset.MuiOutlinedInput-notchedOutline":{borderColor:"divider"}},fieldset:{borderColor:"divider"}},children:(window.blocklet.languages||Zr).map(a=>e.jsx(ne,{value:a.code,children:a.name},a.code))})})]})}nt.propTypes={user:p.shape({locale:p.string}).isRequired,onSave:p.func.isRequired};function be({onTest:t=H,onDelete:i=H,onSave:s=H,onCancel:n=H,type:o="slack",url:f="",edit:a=!1}){const{t:d}=L(),r=Q({type:o||"slack",url:f||"",edit:a??!1,error:"",loading:!1}),h=M(()=>r.url?Ot(r.url)?(r.error="",!0):(r.error=d("common.invalid"),!1):(r.error=d("common.required"),!1)),b=M(()=>{r.edit=!1,r.url=f||"",r.type=o||"slack",r.error="",r.loading=!1,n()}),u=M(async l=>{r.loading=!0,await t(l),r.loading=!1}),j=M(l=>()=>{h()&&l({type:r.type,url:r.url})}),v=R(()=>r.error?e.jsx(A,{component:"span",color:"error",children:r.error}):r.edit?r.loading?e.jsx(V,{size:16}):e.jsx(D,{size:"small",onClick:j(u),sx:{mr:-1},children:e.jsx(z,{icon:cr})}):null,[r.error,r.edit,r.loading]);return e.jsxs(x,{sx:{display:"flex",gap:1.5,width:"100%",alignItems:{xs:"flex-start",md:"center"},flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(ye,{sx:{borderRadius:1,"&.Mui-disabled":{backgroundColor:"grey.50"}},disabled:!r.edit||r.loading,size:"small",value:r.type,onChange:l=>{r.type=l.target.value},children:[e.jsx(ne,{value:"api",children:d("userCenter.webhook.url")}),e.jsx(ne,{value:"slack",children:d("userCenter.webhook.slack")})]}),e.jsxs(x,{sx:{display:"flex",alignItems:"center",gap:.5,width:"100%"},children:[e.jsx(Ue,{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:l=>{r.url=l.target.value,h()},error:!!r.error,slotProps:{input:{endAdornment:e.jsx(Fe,{position:"end",children:v})}}}),e.jsx(x,{sx:{display:"flex",gap:.5},children:r.edit?e.jsxs(e.Fragment,{children:[e.jsx(D,{color:"success",onClick:j((...l)=>{s(...l),r.edit=!1}),sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(z,{icon:Zt})}),e.jsx(D,{color:"error",onClick:b,sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(z,{icon:Qt})})]}):e.jsxs(e.Fragment,{children:[e.jsx(D,{onClick:()=>{r.edit=!0},sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(z,{icon:dr})}),e.jsx(D,{color:"error",onClick:()=>{i({type:r.type,url:r.url})},sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(z,{icon:ur})})]})})]})]})}be.propTypes={onTest:p.func,onDelete:p.func,onSave:p.func,onCancel:p.func,type:p.oneOf(["api","slack"]),url:p.string,edit:p.bool};function re({title:t=void 0,description:i=void 0,value:s,onChange:n,isMobile:o}){const f=M(a=>{a.stopPropagation()});return e.jsxs(x,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(me,{checked:s,size:"small",onChange:n}),e.jsxs(A,{component:"div",onClick:f,sx:{color:"text.primary",fontSize:14,display:"flex",flexWrap:o?"wrap":"nowrap",columnGap:1,flex:1,whiteSpace:o?"normal":"nowrap"},children:[t,i]})]})}re.propTypes={title:p.string,description:p.node,value:p.bool.isRequired,onChange:p.func.isRequired,isMobile:p.bool.isRequired};function ot({user:t,isMobile:i}){const{t:s}=L(),n=Q({showAdd:!1}),o=ce(async()=>await F.user.getUserNotificationConfig(),{refreshDeps:[t],loadingDelay:300}),f=R(()=>({wallet:!0,email:!0,phone:!1,push:!0,...o?.data?.notifications||{}}),[o?.data?.notifications]),a=R(()=>o?.data?.webhooks||[],[o?.data?.webhooks]),d=M(async v=>{try{await F.user.saveUserNotificationConfig(v),O.success(s("userCenter.saveSuccess")),o.run()}catch(l){O.error(Y(l))}}),r=M(async(v,l)=>{await d({notifications:{[v]:l}})}),h=async v=>{try{await F.user.testNotificationWebhook(v),O.success(s("userCenter.webhookTested"))}catch(l){O.error(Y(l))}},b=M(async v=>{await d({webhooks:a.filter((l,g)=>g!==v)})}),u=M(async(v,l)=>{await d({webhooks:a.map((g,k)=>k===v?l:g)})}),j=M(async v=>{await d({webhooks:[...a,v]}),n.showAdd=!1});return o.error?e.jsx(Pt,{severity:"error",children:o.error.message}):o.loading||!o.data?e.jsx(x,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px"},children:e.jsx(V,{})}):e.jsxs(x,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsxs(x,{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(re,{value:f.wallet,isMobile:i,title:s("userCenter.walletNotification"),onChange:v=>r("wallet",v.target.checked),description:ze(t)&&e.jsx(Xt,{did:ze(t),showQrcode:!1,showAvatar:!i,copyable:!0,compact:!0,responsive:!0,startChars:i?2:6})}),e.jsx(re,{value:f.email,isMobile:i,onChange:v=>r("email",v.target.checked),title:s("userCenter.emailNotification"),description:t?.email&&e.jsx(A,{component:"span",sx:{color:"text.secondary",fontSize:13},children:t?.email})}),e.jsx(re,{isMobile:i,value:f.push,title:s("userCenter.pushNotification"),onChange:v=>r("push",v.target.checked)})]}),e.jsxs(we,{spacing:1.5,useFlexGap:!0,direction:"column",sx:{alignItems:"start"},children:[a.map((v,l)=>e.jsx(be,{onTest:h,onDelete:()=>b(l),onSave:(...g)=>u(l,...g),type:v.type,url:v.url,edit:!1},`${l}_${v.url}`)),n.showAdd&&e.jsx(be,{onTest:h,onCancel:()=>{n.showAdd=!1},onSave:(...v)=>j(...v),edit:!0},"add"),e.jsx(Ke,{variant:"outlined",size:"small",sx:{color:"text.primary",borderColor:"divider","&:hover":{borderColor:"divider"},py:.5,borderRadius:1},startIcon:e.jsx(z,{icon:pr}),onClick:()=>{n.showAdd=!0},children:s("userCenter.addWebhook")})]})]})}ot.propTypes={user:p.object.isRequired,isMobile:p.bool.isRequired};function st({item:t}){const i=ke(),{blocklet:s}=Nt(),{confirmApi:n,confirmHolder:o}=qe(),f=Q({loading:!1}),{t:a}=L(),{session:d}=y.use(le),{bindOAuth:r,unbindOAuth:h,setBaseUrl:b,baseUrl:u}=d.useOAuth(),{disconnectPasskey:j,setTargetAppPid:v}=d.usePasskey(),l=R(()=>Jt[t?.provider]||"unknown",[t?.provider]),g=M(m=>m?._bind?m.provider===T.WALLET&&m.did?a("userCenter.thirdPartyLogin.walletAccountCantRemove"):m.provider===T.PASSKEY&&i.arcSphere?a("userCenter.thirdPartyLogin.dontSupportRemoveinArcSphere"):m._mainProvider&&i.arcSphere?a("userCenter.thirdPartyLogin.mainProviderCantRemove"):"":""),k=M(async()=>{if(t?.provider===T.PASSKEY){await new Promise((m,C)=>{n.open({title:a("userCenter.thirdPartyLogin.disconnectPasskey",{name:l}),content:a("userCenter.thirdPartyLogin.disconnectPasskeyDescription",{name:l}),confirmButtonText:a("common.confirm"),confirmButtonProps:{color:"error"},cancelButtonText:a("common.cancel"),onConfirm(S){j({session:d,connectedAccount:t}).then(m).catch(C),S()},onCancel:m})});return}try{f.loading=!0,await new Promise((m,C)=>{if(t?._bind)n.open({title:a("userCenter.thirdPartyLogin.confirmUnbind",{name:l}),content:a("userCenter.thirdPartyLogin.confirmUnbindDescription",{name:l}),confirmButtonText:a("common.confirm"),confirmButtonProps:{color:"error"},cancelButtonText:a("common.cancel"),onConfirm(S){h({session:d,connectedAccount:{...Wt(t,["did","pk"]),showProvider:t.provider,provider:t._rawProvider}}).then(m).catch(C),S()},onCancel:m});else if(t.provider===T.WALLET)n.open({title:a("userCenter.thirdPartyLogin.confirmBindWallet",{name:l}),content:a("userCenter.thirdPartyLogin.confirmBindWalletDescription",{name:l}),confirmButtonText:a("common.confirm"),confirmButtonProps:{color:"primary"},cancelButtonText:a("common.cancel"),onConfirm:S=>{d.bindWallet({onSuccess:m,onCancel:C}),S()},onCancel:m});else{const S=u,_=window?.blocklet;let B="/";const N=er(_),U=tr(_);N&&U?.appPid&&d?.user?.sourceAppPid&&(B=U.appUrl),b(B),v(s?.appPid),r({session:d,oauthItem:{...t,provider:t._rawProvider}}).then(m).catch(C).finally(()=>{b(S),v()})}})}catch(m){console.error(`Failed to ${t?._bind?"unbind":"bind"} oauth account`,m)}finally{f.loading=!1}}),I=M(m=>m.provider===T.WALLET&&m.did?a("userCenter.thirdPartyLogin.walletAccount"):m._mainProvider?a("userCenter.thirdPartyLogin.mainAccount"):m?._bind?a("userCenter.thirdPartyLogin.disconnect"):a("userCenter.thirdPartyLogin.connect")),W=M(m=>m.provider===T.WALLET&&m.did||m.provider===T.PASSKEY&&(i.arcSphere||i.wallet)?!0:!!t._mainProvider,[i.arcSphere]);return e.jsxs(e.Fragment,{children:[e.jsxs(x,{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(Ut,{provider:t?.provider,sx:{width:"1em",height:"1em",flexShrink:0,fontSize:16}}),e.jsx(x,{sx:{flex:1,display:{xs:t.userInfo?.email||t.did?"none":"block",sm:"block"}},children:l}),t.userInfo?.email||t.did?e.jsxs(x,{sx:{display:"flex",alignItems:"center",gap:.5,overflow:"hidden"},children:[e.jsx(x,{sx:{flex:1,textOverflow:"ellipsis",overflow:"hidden",lineHeight:"normal"},children:t.userInfo?.email||t.did}),t.userInfo?.name?e.jsx(De,{title:e.jsxs(x,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(rr,{size:36,variant:"circle",shape:"circle",src:t.userInfo?.picture,did:t.did}),e.jsxs(x,{children:[e.jsx(A,{sx:{whiteSpace:"normal",wordBreak:"break-all",fontSize:"0.9rem"},children:t.userInfo?.name}),e.jsx(A,{sx:{whiteSpace:"normal",wordBreak:"break-all",fontSize:"0.9rem"},children:t.userInfo?.email})]})]}),children:e.jsx(x,{component:z,icon:Ft,sx:{color:"text.secondary",fontSize:16,cursor:"pointer",flexShrink:0}})}):null]}):null]}),e.jsx(De,{title:g(t),placement:"auto",children:e.jsx(x,{children:e.jsx(Ke,{variant:"outlined",size:"small",sx:m=>{const C=m.palette.error.main,S=m.palette.primary.main;return{color:t?._bind?C:S,borderColor:t?._bind?C:S,backgroundColor:"background.default","&:hover":{borderColor:t?._bind?C:S,backgroundColor:"action.hover"},py:.5,borderRadius:1,fontWeight:500,whiteSpace:"nowrap"}},fullWidth:!0,startIcon:f.loading?null:e.jsx(z,{icon:fr}),onClick:k,disabled:W(t),loading:f.loading,children:I(t)})})}),o]})}st.propTypes={item:p.shape({provider:p.string,did:p.string,pk:p.string,userInfo:p.object,id:p.string,_bind:p.bool,_rawProvider:p.string,_mainProvider:p.bool}).isRequired};function it({user:t}){const{session:i}=y.use(le),[s,n]=y.useState({}),{getOAuthConfigs:o}=i.useOAuth(),f=ke();Kt(async()=>{const r=await o({sourceAppPid:t?.sourceAppPid});n(r)},[t?.sourceAppPid]);const a=R(()=>{const r=Object.keys(s).map(h=>({...s[h],provider:h})).filter(h=>h.enabled);return[{provider:T.WALLET,order:-1},...r,{provider:T.PASSKEY,order:1/0}]},[s]),d=R(()=>{const r=nr(t);let h=!1,b="",u=or(t);const j=r.find(l=>l.provider===T.AUTH0);return j&&(j.id.startsWith("google-oauth2|")&&(r.some(l=>l.provider==="google")||(h=!0,b=T.GOOGLE,u===T.AUTH0&&(u=T.GOOGLE))),j.id.startsWith("appleid|")&&(r.some(l=>l.provider===T.APPLE)||(h=!0,b=T.APPLE,u===T.AUTH0&&(u=T.APPLE))),j.id.startsWith("github|")&&(r.some(l=>l.provider===T.GITHUB)||(h=!0,b=T.GITHUB,u===T.AUTH0&&(u=T.GITHUB)))),a.map(l=>{if(l.provider===T.AUTH0&&h)return null;const g=h&&l.provider===b?r.find(k=>k.provider===T.AUTH0):r.find(k=>k.provider===l.provider);return g?{...l,provider:l.provider,did:g.did,pk:g.pk,userInfo:g.userInfo,_bind:!0,_rawProvider:g.provider,_mainProvider:l.provider===u}:{...l,provider:l.provider,_rawProvider:l.provider,_mainProvider:l.provider===u}}).filter(l=>!(!l||l.provider===T.PASSKEY&&!l.did)).sort((l,g)=>l._mainProvider?-1:l?.order!==void 0&&g?.order!==void 0?l.order-g.order:l?.order!==void 0?-1:1)},[t?.connectedAccounts,a]);return e.jsxs(x,{sx:{gap:1,display:"grid",gridTemplateColumns:"1fr min-content"},children:[d.map(r=>e.jsx(st,{item:r},r?.provider)),f.wallet||f.arcSphere?null:e.jsx(_t,{behavior:"only-new",action:"connect",createMode:"connect",createButtonText:"Add New Passkey",onSuccess:H,onError:H,dense:!0,sx:{px:1.5,py:1,gap:.75}})]})}it.propTypes={user:p.object.isRequired};function at({configList:t,onSave:i}){const[s,n]=y.useState(t),{t:o}=L(),f=M(async(a,d)=>{try{const r=await F.user.saveUserPrivacyConfig({[a]:typeof d=="string"?d:!d});n(s.map(h=>({...h,value:r?.[h.key]??h.value}))),O.success(o("userCenter.saveSuccess")),i("privacy")}catch(r){O.error(Y(r))}});return y.useEffect(()=>{n(t)},[t]),e.jsx(x,{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:s.map(a=>{if(a.isPrivate)return null;const d=!a.value||["all","follower-only"].includes(a.value);return e.jsxs(x,{children:[e.jsx(me,{checked:d,labelProps:{label:e.jsx(A,{sx:{color:"text.primary",fontSize:14,display:"flex",flexFlow:"wrap",columnGap:1,flex:1},children:o("userCenter.toPublic",{name:a.name})})},size:"small",onChange:r=>{const{checked:h}=r.target;a.followersOnly?f(a.key,h?"all":"private"):f(a.key,h)}},a.key),a.followersOnly&&d&&e.jsx(x,{sx:{pl:3,pt:1},children:e.jsx(me,{checked:a.value==="follower-only",labelProps:{label:e.jsx(A,{sx:{color:"text.primary",fontSize:14,display:"flex",flexFlow:"wrap",columnGap:1,flex:1},children:o("team.userFollowers.followersOnly")})},size:"small",onChange:r=>{const{checked:h}=r.target;f(a.key,h?"follower-only":"all")}})})]})})})}at.propTypes={configList:p.arrayOf(p.shape({key:p.string.isRequired,name:p.string.isRequired,value:p.bool.isRequired,isPrivate:p.bool})).isRequired,onSave:p.func.isRequired};function lt({onDestroySelf:t=void 0}){const{confirmHolder:i}=qe(),{t:s}=L(),{session:n}=y.use(le),o=M(async()=>{if(!t||typeof t!="function")return;const f=n.withSecondaryAuth(t,{extraParams:{removeUserDid:n?.user?.did,input:{user:{did:n?.user?.did},teamDid:window?.blocklet?.did}},operation:"destroySelf"});try{await f(),n.logout()}catch(a){O.error(a?.message||s("userCenter.destroyMyself.error"))}});return e.jsxs(e.Fragment,{children:[e.jsx(x,{children:e.jsxs(x,{sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"space-between",flexWrap:"wrap"},children:[e.jsxs(x,{children:[e.jsx(A,{variant:"h6",sx:{fontSize:"0.875rem !important",fontWeight:"bold"},children:s("userCenter.dangerZone.deleteAccount")}),e.jsx(A,{variant:"caption",sx:{color:"text.secondary"},children:s("userCenter.dangerZone.deleteAccountDescription")})]}),e.jsx(G,{variant:"contained",color:"error",size:"small",onClick:o,children:s("userCenter.dangerZone.delete")})]})}),i]})}lt.propTypes={onDestroySelf:p.func};function Qr(){const t=de({key:"md"}),i=ve(o=>o.breakpoints.down("lg")),s={display:"flex",justifyContent:"flex-end",flexWrap:"wrap",textAlign:"right","&.expired-at > div":{maxWidth:160,justifyContent:"flex-end",flexWrap:"wrap"}},n=R(()=>Ve({},t?s:{}),[t]);return e.jsx(x,{id:"user-center-access-key-setting",sx:{maxWidth:t?"unset":i?"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:o=>`${o.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(wr,{isSelf:!0,columnSx:n})})}function ct({onDestroySelf:t=void 0,userCenterTabs:i=[]}){const{t:s}=L(),{user:n,session:o,isMyself:f,isOwner:a}=ue(),r=ke().arcSphere,h=de({key:"md"}),b=ce(async()=>n&&f?await F.user.getUserPrivacyConfig({did:n.did}):null,{refreshDeps:[n,f],loadingDelay:300}),u=R(()=>i.map(l=>({key:l.value,name:l.label,value:l.protected,isPrivate:l.isPrivate,followersOnly:l.followersOnly})),[i]),j=M(async l=>l==="privacy"?(await b.runAsync(),b.data):(l==="profile"&&await o.refresh(),null));y.useEffect(()=>{const l=window.location.hash.slice(1);l&&document.getElementById(l)?.scrollIntoView({behavior:"smooth"})},[]);const v=R(()=>[r?void 0:{label:s("userCenter.commonSetting.title"),value:"common",content:e.jsx(nt,{user:n,onSave:j})},{label:s("userCenter.notificationManagement"),value:"notification",content:e.jsx(ot,{user:n,isMobile:h})},{label:s("userCenter.thirdPartyLogin.title"),value:"thirdPartyLogin",content:e.jsx(it,{user:n})},{label:s("common.accessKeys"),value:"accessKeys",content:e.jsx(Qr,{isSelf:!0})},{label:s("common.mcpServers"),value:"mcpServers",content:e.jsx(br,{})},{label:s("userCenter.privacyManagement"),value:"privacy",content:e.jsx(at,{configList:u,onSave:j})},{label:s("userCenter.sessionManagement"),value:"session",content:e.jsx(yr,{user:n,showUser:!1,getUserSessions:l=>F.userSession.getMyLoginSessions({},l)})},!a&&t&&typeof t=="function"?{label:s("userCenter.dangerZone.title"),value:"dangerZone",content:e.jsx(lt,{onDestroySelf:t}),sx:{borderColor:"error.main"}}:null].filter(Boolean),[n,u,h,a,t]);return f?e.jsx(x,{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(l=>l?e.jsxs(x,{id:l.value,sx:Ve({border:"1px solid",borderColor:"divider",borderRadius:1,p:2,"&:last-child":{mb:5}},l.sx),children:[e.jsx(A,{sx:{color:"text.primary",fontWeight:600},children:l.label}),e.jsx(x,{sx:{mt:2.5},children:l.content})]},l.value):null)}):null}ct.propTypes={onDestroySelf:p.func,userCenterTabs:p.array};const dt=y.createContext({}),{Provider:Xr,Consumer:fo}=dt;function ut({children:t}){const[i]=y.useState(!1),{session:s}=y.use(le),{user:n}=s,[o,f]=y.useState(),a=y.useMemo(()=>n?.didSpace?.endpoint,[n?.didSpace]);y.useEffect(()=>{f(n?.didSpace)},[n?.didSpace]);const d=async()=>{f(void 0)},r=u=>{},h=async u=>{f(u),await r(u.endpoint)},b=!!(a&&o);return e.jsx(Xr,{value:{loading:i,spaceGateway:o,session:s,deleteSpaceGateway:d,updateSpaceGateway:h,storageEndpoint:a,settingStorageEndpoint:r,hasStorageEndpoint:b},children:t})}function Se(){return y.use(dt)}ut.propTypes={children:p.node.isRequired};function Jr(t){const i=t.replace(/\/api\/space\/.+/,""),n=t.replace(/\/$/,"").split("/").at(-4);return se(i,"space",n)}function pt({session:t,spaceGateway:i,spaceStatus:s,refresh:n}){return e.jsxs(we,{direction:"row",spacing:1,children:[s===Cr.DISCONNECTED&&e.jsx(ie,{reconnect:!0,variant:"outlined",session:t,spaceDid:t.user?.didSpace?.did,spaceGatewayUrl:t.user?.didSpace?.url,connectScope:"user",onSuccess:async()=>{await n()},onError:o=>{console.error(o),O.error(Y(o))}}),e.jsx(D,{size:"small",LinkComponent:It,href:Jr(i.endpoint),target:"_blank",children:e.jsx(Tt,{})})]})}pt.propTypes={session:p.object.isRequired,spaceGateway:p.object.isRequired,spaceStatus:p.string.isRequired,refresh:p.func.isRequired};function ft({spaceGateway:t=void 0}){const{t:i}=L(),{updateSpaceGateway:s,session:n}=Se(),o=de(),f=({spaceGateway:a})=>s(a);return e.jsxs(x,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(x,{sx:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[e.jsx(A,{sx:{fontSize:"16px",fontWeight:"bold"},children:i("userCenter.storage.spaces.connected.title")}),!o&&e.jsx(ie,{connectScope:"user",connectText:i("userCenter.storage.spaces.connected.switch"),session:n,onSuccess:f})]}),e.jsx(x,{children:t&&e.jsx(kr,{endpoint:t.endpoint,deps:[t],selected:!0,footer:!0,action:a=>e.jsx(pt,{session:n,...a})},t.endpoint)}),o&&e.jsx(x,{sx:{display:"flex",alignItems:"center",justifyContent:"center",marginTop:2},children:e.jsx(ie,{connectScope:"user",connectText:i("userCenter.storage.spaces.connected.switch"),session:n,onSuccess:f})})]})}ft.propTypes={spaceGateway:p.object};function en(){const{t}=L(),{updateSpaceGateway:i,session:s}=Se(),n=({spaceGateway:o})=>i(o);return e.jsxs(x,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(A,{sx:{fontSize:"16px",fontWeight:"bold"},children:t("userCenter.storage.spaces.connect.providerForStorage")}),e.jsx(Sr,{viewBox:"0 0 228 258",style:{width:"156px",height:"156px",margin:"16px 0"}}),e.jsx(x,{children:e.jsx(ie,{session:s,onSuccess:n})})]})}function tn(){const{spaceGateway:t,hasStorageEndpoint:i,loading:s}=Se(),{isMyself:n}=ue();return n?s?e.jsx(jr,{relative:"parent",children:e.jsx(V,{})}):e.jsx(nn,{children:e.jsx(x,{sx:{maxWidth:"720px"},children:i?e.jsx(ft,{spaceGateway:t}):e.jsx(en,{})})}):null}function rn(){return e.jsx(ut,{children:e.jsx(tn,{})})}const nn=Z(x)`
122
+ height: 100%;
123
+ overflow-y: auto;
124
+ `;function on(){const{user:t,isMyself:i,viewUser:s}=ue(),{followed:n}=hr();return e.jsx(x,{children:e.jsx(vr,{teamDid:window?.blocklet?.did||"",user:i?t:s,showInvitees:i,followed:n})})}function sn({tab:t=""}){const{api:i}=qt(),s=y.useRef(null),n=At(),o=t||n.tab,a=new URLSearchParams(window.location.search).get("embed")||window.sessionStorage?.getItem("embed"),d=Ht(),r=R(()=>({...window.blocklet,meta:{did:window.blocklet.did,name:window.blocklet.did},children:window?.blocklet?.componentMountPoints.map(b=>({...b,meta:{...b,did:b.did,name:b.name||b.title||"",logo:"logo.png"}}))})),h=async b=>{const{input:u,sessionId:j}=b;try{await i.destroySelf({input:{...u,sessionId:j}})}catch(v){console.error("destroy myself error",v)}};return e.jsx(ar,{mode:"user-center",children:e.jsxs(xr,{ref:s,embed:a==="1",currentTab:o?se(je.WELLKNOWN_SERVICE_PATH_PREFIX,"user",o):"",disableAutoRedirect:o==="settings",children:[o==="notifications"?e.jsx(_r,{blocklets:[r],context:d}):null,o==="nfts"?e.jsx(Yr,{}):null,o==="settings"?e.jsx(ct,{onDestroySelf:h}):null,o==="did-spaces"?e.jsx(rn,{}):null,o==="user-followers"?e.jsx(on,{}):null,o==="orgs"?e.jsx(gr,{id:n.id||""}):null]})})}sn.propTypes={tab:p.string};export{sn as default};