@abtnode/blocklet-services 1.16.46-beta-20250709-071942-1f57b2b8 → 1.16.46-beta-20250709-120742-e445a508

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 (163) hide show
  1. package/dist/assets/{AdapterDayjs-BeqEJUig.js → AdapterDayjs-DiKE7R2w.js} +1 -1
  2. package/dist/assets/{Google-C8DG_mDp.js → Google-YsG2REYU.js} +1 -1
  3. package/dist/assets/{access-control-X_NlM1AQ.js → access-control-CMbWBbA-.js} +1 -1
  4. package/dist/assets/{actions-DK8uxYzD.js → actions-CXdeSIgp.js} +1 -1
  5. package/dist/assets/{add-component-core-BNm8Sohm.js → add-component-core-C_-47aWH.js} +1 -1
  6. package/dist/assets/{add-resource-DbjUjkxV.js → add-resource-CF3PYVap.js} +1 -1
  7. package/dist/assets/{addon-BkZEzLfU.js → addon-BU6EtMS1.js} +1 -1
  8. package/dist/assets/{advanced-Bmq6xQB4.js → advanced-BsXG5Uen.js} +1 -1
  9. package/dist/assets/{appearance-CI7tP4v7.js → appearance-DnQKeY3-.js} +1 -1
  10. package/dist/assets/{arrow-down.svg-DR5noAvr.js → arrow-down.svg-CaNNzVmj.js} +1 -1
  11. package/dist/assets/{audit-logs-Bbodpxwp.js → audit-logs-BdTL3Ee_.js} +1 -1
  12. package/dist/assets/{authorize-osbNauSJ.js → authorize-D3GrNEeY.js} +1 -1
  13. package/dist/assets/{base-chart-BGpAbSkc.js → base-chart-D2xQQY8-.js} +1 -1
  14. package/dist/assets/{base32-vvndof6f.js → base32-6sm6N7JR.js} +1 -1
  15. package/dist/assets/{branding-QpFA5gHx.js → branding-DU4A47RN.js} +1 -1
  16. package/dist/assets/{branding-9qaGpptV.js → branding-xOC7tV88.js} +2 -2
  17. package/dist/assets/{bundle-avatar-D1U8n6sJ.js → bundle-avatar-mX0oF7zo.js} +1 -1
  18. package/dist/assets/button-DEodgJFI.js +1 -0
  19. package/dist/assets/{click-to-copy-B6s5Z4cq.js → click-to-copy-DlFJrA7H.js} +1 -1
  20. package/dist/assets/{collapse-BWjaTK3Y.js → collapse-BqoeNHou.js} +1 -1
  21. package/dist/assets/{complete-B3LQtNHp.js → complete-DyNDIJOz.js} +1 -1
  22. package/dist/assets/{component-CyoK1wFU.js → component-DTQzu9Ux.js} +3 -3
  23. package/dist/assets/{config-BgvCY9yW.js → config-CLS5JN-Q.js} +1 -1
  24. package/dist/assets/{config-Bl2vLfGW.js → config-DlVTbC3O.js} +1 -1
  25. package/dist/assets/{config-navigation-DcBcxC77.js → config-navigation-beAE71Co.js} +3 -3
  26. package/dist/assets/{config-space-D2PSYekl.js → config-space-p8dvh7nV.js} +1 -1
  27. package/dist/assets/{confirm-DAb9dboO.js → confirm-CCJkd_GP.js} +1 -1
  28. package/dist/assets/{connect-geHS1TpW.js → connect-Bscwq6pz.js} +1 -1
  29. package/dist/assets/{connect-Ca67d-kp.js → connect-CRMI4vhC.js} +1 -1
  30. package/dist/assets/{connect-to-2xYBexsb.js → connect-to-DK_UHSXd.js} +1 -1
  31. package/dist/assets/{content-layout-U_bmDcVP.js → content-layout-BFy-gp0u.js} +1 -1
  32. package/dist/assets/{createClass-geNigj02.js → createClass-BKrX8gDd.js} +1 -1
  33. package/dist/assets/{dashboard-DUhl5uLq.js → dashboard-EECTIwDT.js} +3 -3
  34. package/dist/assets/{delete-confirm-DxvPCnQ2.js → delete-confirm-OwSiQs5a.js} +1 -1
  35. package/dist/assets/{did-address-COwwd6H0.js → did-address-BdvYNOBf.js} +1 -1
  36. package/dist/assets/{domain-DsyzZKaj.js → domain-Bqb4STve.js} +1 -1
  37. package/dist/assets/{domain-action-card-BHqkche3.js → domain-action-card-78ZAvOXg.js} +1 -1
  38. package/dist/assets/domains-Cc33cE6l.js +1 -0
  39. package/dist/assets/{dot-DLj9aDwC.js → dot-DWse_kXZ.js} +1 -1
  40. package/dist/assets/{email-ClGSUpWT.js → email-CW26NZg4.js} +1 -1
  41. package/dist/assets/{empty-spinner-Bi1Cb9b7.js → empty-spinner-CpvmEmwT.js} +1 -1
  42. package/dist/assets/engine-CcVO7RNx.js +1 -0
  43. package/dist/assets/{exchange-passport-BUGi1VBV.js → exchange-passport-ARTNldc_.js} +1 -1
  44. package/dist/assets/{form-zxAQYYnY.js → form-C7DadyRx.js} +1 -1
  45. package/dist/assets/{fuel-BID4hifo.js → fuel-CdmuLJ5m.js} +1 -1
  46. package/dist/assets/{gen-access-key-BTM6ukrq.js → gen-access-key-DmGPdafH.js} +1 -1
  47. package/dist/assets/get-safe-url-CFJ4a0MT.js +1 -0
  48. package/dist/assets/{home-B_RkpQaJ.js → home-DSXcBmq0.js} +1 -1
  49. package/dist/assets/{iframe-CubIsy36.js → iframe-CTQOWc1h.js} +1 -1
  50. package/dist/assets/{index-yMf5L8qr.js → index-BSmqpzfQ.js} +1 -1
  51. package/dist/assets/{index-C9VaBr_O.js → index-Bk5yhzGt.js} +1 -1
  52. package/dist/assets/{index-_X8imDSe.js → index-BuCfItTx.js} +3 -3
  53. package/dist/assets/{index-C7l3rSL2.js → index-C410XMZO.js} +1 -1
  54. package/dist/assets/{index-BsTbYUnM.js → index-C7Lof57D.js} +1 -1
  55. package/dist/assets/{index-Dtcv_nT6.js → index-CHgWkvhM.js} +4 -4
  56. package/dist/assets/{index-CrE4cEyN.js → index-CSfHWUfI.js} +1 -1
  57. package/dist/assets/{index-CuOPtgTg.js → index-ClQB4tO4.js} +1 -1
  58. package/dist/assets/{index-Cs4ZeTTW.js → index-ClY8OPfZ.js} +1 -1
  59. package/dist/assets/{index-XuUrUf8b.js → index-CnZyhA37.js} +1 -1
  60. package/dist/assets/{index-D-Q3LAn6.js → index-Cs_Iwqc6.js} +1 -1
  61. package/dist/assets/{index-Ds6nmMCe.js → index-CzlSSzt5.js} +1 -1
  62. package/dist/assets/{index-CpryIQED.js → index-DHPu60AO.js} +1 -1
  63. package/dist/assets/{index-BXjxtue_.js → index-DJhjl40G.js} +1 -1
  64. package/dist/assets/{index-ZnnRM00W.js → index-DKdSMDX6.js} +1 -1
  65. package/dist/assets/{index-SJzJLNlA.js → index-DMKmqbPb.js} +1 -1
  66. package/dist/assets/{index-TG8FK0pk.js → index-DO3jlY1J.js} +1 -1
  67. package/dist/assets/{index-Bst-lasJ.js → index-DRCXfYI5.js} +1 -1
  68. package/dist/assets/{index-C0PfwuMR.js → index-DYWITQqN.js} +1 -1
  69. package/dist/assets/{index-D3YocLxi.js → index-DaWCw-fb.js} +1 -1
  70. package/dist/assets/{index-Bzd_F7Ms.js → index-DhbrYLsW.js} +1 -1
  71. package/dist/assets/{index-45FYp8zC.js → index-DjGGLSgp.js} +1 -1
  72. package/dist/assets/{index-Dcvh9y_X.js → index-E_Fpmc4w.js} +1 -1
  73. package/dist/assets/{index-BUEUadKA.js → index-Kcu6d0fi.js} +4 -4
  74. package/dist/assets/index-MvpWBcrT.js +1 -0
  75. package/dist/assets/{index-BVAv5IrJ.js → index-S9T-sBWO.js} +6 -6
  76. package/dist/assets/{index-BiGUf0JP.js → index-VGO-dEle.js} +1 -1
  77. package/dist/assets/{index-Wo9AdN6Y.js → index-biihuQJV.js} +1 -1
  78. package/dist/assets/{index-C-yjHI_C.js → index-kQLw_ftN.js} +1 -1
  79. package/dist/assets/{index-AI8jHnw9.js → index-n70kyMPo.js} +1 -1
  80. package/dist/assets/{index-Dk6JQKfz.js → index-waZfnNlB.js} +1 -1
  81. package/dist/assets/{invitation-fbTXYMgC.js → invitation-S4WXAiey.js} +1 -1
  82. package/dist/assets/invite-COY7brfc.js +1 -0
  83. package/dist/assets/{issue-passport-b9pA_OcP.js → issue-passport-BSa2KdpC.js} +1 -1
  84. package/dist/assets/{item-c7_gTBTX.js → item-C-9-K-dS.js} +1 -1
  85. package/dist/assets/{landing-page-CPsYV1SX.js → landing-page-C3ZqUsaQ.js} +1 -1
  86. package/dist/assets/{launch-result-message-CDvcIXJ3.js → launch-result-message-gmDOMo-e.js} +1 -1
  87. package/dist/assets/{layout-DkHZoXcQ.js → layout-CFnEKAtz.js} +1 -1
  88. package/dist/assets/{list-kq8swRwp.js → list-B7ZF5Ul0.js} +1 -1
  89. package/dist/assets/{list-BOhlf5Oo.js → list-Dvw6k9Fn.js} +2 -2
  90. package/dist/assets/{list-header-Bcr2R_3c.js → list-header-DZoSW08k.js} +1 -1
  91. package/dist/assets/localization-B4hOUoCq.js +1 -0
  92. package/dist/assets/{log-CZOcHiO-.js → log-CQyBD4pJ.js} +1 -1
  93. package/dist/assets/logger-BD3QOXfW.js +1 -0
  94. package/dist/assets/{login-oauth-callback-BN9Asi_d.js → login-oauth-callback-BXAgY8t2.js} +1 -1
  95. package/dist/assets/{login-CMyDCkH6.js → login-yfGJSAJb.js} +1 -1
  96. package/dist/assets/{logo-uploader-BeGnMM3a.js → logo-uploader-DL_O0r92.js} +3 -3
  97. package/dist/assets/{lost-passport--Rxl4BIv.js → lost-passport-BeFjTnh-.js} +1 -1
  98. package/dist/assets/{open-window-DmgdhkjX.js → open-window-PnHF0kAn.js} +1 -1
  99. package/dist/assets/{over-due-invoice-payment-azmcP3Sx.js → over-due-invoice-payment-COY8cvLu.js} +1 -1
  100. package/dist/assets/{overview-Chm9UqJe.js → overview-Cd-vxOiy.js} +1 -1
  101. package/dist/assets/{page-header-a5Qh5Tr1.js → page-header-CiDBkMEP.js} +1 -1
  102. package/dist/assets/{passport-item-Byi-8gTO.js → passport-item-DelVKtIt.js} +1 -1
  103. package/dist/assets/{permission-tBQugdD0.js → permission-B4gBENoO.js} +1 -1
  104. package/dist/assets/preferences-CjO06ZIQ.js +1 -0
  105. package/dist/assets/profile-embed-BitC6ZoS.js +1 -0
  106. package/dist/assets/publish-resource-Ck5quuGX.js +1 -0
  107. package/dist/assets/{react-beautiful-dnd.esm-rTL6rgJs.js → react-beautiful-dnd.esm-Cjgywj65.js} +1 -1
  108. package/dist/assets/{react-stripe.esm-D_PEjY7V.js → react-stripe.esm-BRjejkg6.js} +1 -1
  109. package/dist/assets/{runtime-qJ1PldRM.js → runtime-B-Viq2us.js} +1 -1
  110. package/dist/assets/sdk-Bg2mtU3m.js +1 -0
  111. package/dist/assets/{section-76c1fWcb.js → section-iFIMehPS.js} +1 -1
  112. package/dist/assets/{security-m1Vf67My.js → security-J0LBanar.js} +1 -1
  113. package/dist/assets/{session-CFTmeC0_.js → session-CD-6TrlW.js} +1 -1
  114. package/dist/assets/{setup-w1nCUnw5.js → setup-CpWZbzzi.js} +3 -3
  115. package/dist/assets/{shorten-label-CqCkrOW-.js → shorten-label-OzRq4VRH.js} +1 -1
  116. package/dist/assets/{simple-select-BtDvaDm3.js → simple-select-CywFjRfu.js} +1 -1
  117. package/dist/assets/{spaces--oE74hBj.js → spaces-Jt4I6QVN.js} +1 -1
  118. package/dist/assets/{start-DQqIgvdd.js → start-DFxA6tPZ.js} +1 -1
  119. package/dist/assets/starting-progress-ONT_Uhnp.js +40 -0
  120. package/dist/assets/{status-Bj5PpxMp.js → status-B2xgYwSq.js} +1 -1
  121. package/dist/assets/{step-actions-BZsA_oSN.js → step-actions-BnfP6cxN.js} +1 -1
  122. package/dist/assets/{studio-CRXYSEnV.js → studio-CiSsKpFb.js} +1 -1
  123. package/dist/assets/{switch-control-Cd3QShYo.js → switch-control-C9XSb8cW.js} +1 -1
  124. package/dist/assets/{table-tips-CMqGfw3-.js → table-tips-sgNXbhRZ.js} +1 -1
  125. package/dist/assets/{traffic-PJIhaYTG.js → traffic-C0Ugjtml.js} +1 -1
  126. package/dist/assets/{transfer-B9hKmCer.js → transfer-BrnC_C-u.js} +1 -1
  127. package/dist/assets/{unsubscribe-By-fRglQ.js → unsubscribe-Df9woQco.js} +1 -1
  128. package/dist/assets/{use-blocklet-logo-CudOf_wh.js → use-blocklet-logo-B1g1jSm8.js} +1 -1
  129. package/dist/assets/{use-mobile-BgklPLaO.js → use-mobile-B8-JPkft.js} +1 -1
  130. package/dist/assets/{use-mobile-BkNZycG6.js → use-mobile-DpkDXDwi.js} +1 -1
  131. package/dist/assets/{use-server-logo-DZ_rNHFu.js → use-server-logo-BrWB7X_I.js} +1 -1
  132. package/dist/assets/{useAsync-Ct43XAf7.js → useAsync-C8Ma6muj.js} +1 -1
  133. package/dist/assets/{useAsync-CaAq0Gts.js → useAsync-D7pjCBig.js} +1 -1
  134. package/dist/assets/{useLocalStorage-C30Mdv9U.js → useLocalStorage-DHCQcCRn.js} +1 -1
  135. package/dist/assets/{user-center-coYNhbvf.js → user-center-Dicuqlij.js} +3 -3
  136. package/dist/assets/{user-center-CxUqWFNC.js → user-center-lZ9ifkcH.js} +3 -3
  137. package/dist/assets/{user-sessions-C5THsvtE.js → user-sessions-DmuUfMxJ.js} +1 -1
  138. package/dist/assets/{util-Ba52lfC5.js → util-BTNHVX94.js} +1 -1
  139. package/dist/assets/{util-DakLk8kj.js → util-Doke8P4Y.js} +1 -1
  140. package/dist/assets/{vendor-arcblock-DKbvje4v.js → vendor-arcblock-BndcJjQO.js} +1 -1
  141. package/dist/assets/{vendor-hooks-CwHgeAuk.js → vendor-hooks-zCCbpt45.js} +1 -1
  142. package/dist/assets/{vendor-mui-core-Bz-X9hX7.js → vendor-mui-core-p6jGoroc.js} +1 -1
  143. package/dist/assets/{vendor-mui-x-Cgnunrow.js → vendor-mui-x-CkcHHKbJ.js} +1 -1
  144. package/dist/assets/vendor-ux-TkkDR0Gn.js +1568 -0
  145. package/dist/assets/{wrap-locale-ChQwQuJk.js → wrap-locale-CfJqsNLW.js} +1 -1
  146. package/dist/assets/{zh-Bg0MRqOX.js → zh-DJzU8mmk.js} +1 -1
  147. package/dist/index.html +5 -5
  148. package/dist/service-worker.js +1 -1
  149. package/package.json +31 -31
  150. package/dist/assets/button-n_0p8lJU.js +0 -1
  151. package/dist/assets/domains-JuDH24L8.js +0 -1
  152. package/dist/assets/engine-CR4ymPVp.js +0 -1
  153. package/dist/assets/get-safe-url-BK7rZ--W.js +0 -1
  154. package/dist/assets/index-C_rFfbiq.js +0 -1
  155. package/dist/assets/invite-D1p1pcY6.js +0 -1
  156. package/dist/assets/localization-CZzoT5xp.js +0 -1
  157. package/dist/assets/logger-69zTMQoL.js +0 -1
  158. package/dist/assets/preferences-DI-hndOF.js +0 -1
  159. package/dist/assets/profile-embed-hoDmZwiP.js +0 -1
  160. package/dist/assets/publish-resource-CEjwTzjC.js +0 -1
  161. package/dist/assets/sdk-Dl0rUz88.js +0 -1
  162. package/dist/assets/starting-progress-Bq_gQVhf.js +0 -40
  163. package/dist/assets/vendor-ux-BArADSzA.js +0 -1568
@@ -1,4 +1,4 @@
1
- import{j as a,J as I,T as _,ch as L,V as M,ci as q,aV as J,ak as h,cj as K,aU as Q,av as B,o as V,bV as X,ck as Y}from"./vendor-mui-core-Bz-X9hX7.js";import{r as d,k as C,L as z,n as Z,o as ee}from"./vendor-react-x2lQvn4m.js";import{H as A,aF as ae}from"./index-BVAv5IrJ.js";import{b as te}from"./vendor-hooks-CwHgeAuk.js";import{F as ie,m,V as E,W as S}from"./vendor-ux-BArADSzA.js";import{z as re}from"./vendor-arcblock-DKbvje4v.js";const U=d.createContext(null),oe=e=>{const i=d.use(U);return d.useLayoutEffect(()=>{},[]),i};function se({children:e=void 0,...i}){const[t,r]=d.useState({inFullPage:!1,showToggleButton:!1,headerVisibleInFullPage:!0,footerVisibleInFullPage:!1,sidebarVisibleInFullPage:!1}),s=()=>{r(o=>({...o,inFullPage:!o.inFullPage}))},l=d.useMemo(()=>({...t,headerVisible:!t.inFullPage||t.headerVisibleInFullPage,footerVisible:!t.inFullPage||t.footerVisibleInFullPage,sidebarVisible:!t.inFullPage||t.sidebarVisibleInFullPage,toggleFullPage:s,configure:o=>r(n=>({...n,...o}))}),[t]);return a.jsx(U,{value:l,...i,children:e})}function le({name:e,size:i=36,alt:t="",color:r="#000000",prefix:s="/images",showBadge:l=!1,style:o={},...n}){const c=`${s}/${e}-${r.replace(/^#/,"")}.png`;return a.jsxs(ne,{style:{width:i,height:i},children:[a.jsx(ie,{width:i,height:i,alt:t||e,src:c,style:Object.assign({width:i},o),...n}),l&&a.jsx("i",{className:"badge-point"})]})}const ne=m("div")`
1
+ import{j as a,J as I,T as _,ch as L,V as M,ci as q,aV as J,ak as h,cj as K,aU as Q,av as B,o as V,bV as X,ck as Y}from"./vendor-mui-core-p6jGoroc.js";import{r as d,k as C,L as z,n as Z,o as ee}from"./vendor-react-x2lQvn4m.js";import{H as A,aF as ae}from"./index-S9T-sBWO.js";import{e as te}from"./vendor-hooks-zCCbpt45.js";import{F as ie,m,V as E,W as S}from"./vendor-ux-TkkDR0Gn.js";import{z as re}from"./vendor-arcblock-BndcJjQO.js";const U=d.createContext(null),oe=e=>{const i=d.use(U);return d.useLayoutEffect(()=>{},[]),i};function se({children:e=void 0,...i}){const[t,r]=d.useState({inFullPage:!1,showToggleButton:!1,headerVisibleInFullPage:!0,footerVisibleInFullPage:!1,sidebarVisibleInFullPage:!1}),s=()=>{r(o=>({...o,inFullPage:!o.inFullPage}))},l=d.useMemo(()=>({...t,headerVisible:!t.inFullPage||t.headerVisibleInFullPage,footerVisible:!t.inFullPage||t.footerVisibleInFullPage,sidebarVisible:!t.inFullPage||t.sidebarVisibleInFullPage,toggleFullPage:s,configure:o=>r(n=>({...n,...o}))}),[t]);return a.jsx(U,{value:l,...i,children:e})}function le({name:e,size:i=36,alt:t="",color:r="#000000",prefix:s="/images",showBadge:l=!1,style:o={},...n}){const c=`${s}/${e}-${r.replace(/^#/,"")}.png`;return a.jsxs(ne,{style:{width:i,height:i},children:[a.jsx(ie,{width:i,height:i,alt:t||e,src:c,style:Object.assign({width:i},o),...n}),l&&a.jsx("i",{className:"badge-point"})]})}const ne=m("div")`
2
2
  position: relative;
3
3
  .badge-point {
4
4
  position: absolute;
@@ -1,4 +1,4 @@
1
- import{r as u}from"./vendor-react-x2lQvn4m.js";import{$ as o,j as e,ak as j,aN as L,G as A,at as K,bi as B,I as P,p as M,bH as W,aj as X,b$ as $}from"./vendor-mui-core-Bz-X9hX7.js";import{C as G}from"./Google-C8DG_mDp.js";import{b as H}from"./vendor-ux-BArADSzA.js";import{aw as U,f as Y}from"./index-BVAv5IrJ.js";import{A as J}from"./vendor-arcblock-DKbvje4v.js";import{F as Q,R as Z,L as v}from"./logo-uploader-BeGnMM3a.js";import{A as ee,a as ne,b as te}from"./collapse-BWjaTK3Y.js";const S={description:o.string,editing:o.bool,onChange:o.func,required:o.bool,value:o.any,componentProps:o.object,render:o.func,renderFormItem:o.func};function T({editing:n,value:s,onChange:l}){const[i,c]=u.useState(!1),m=u.useRef(),f=u.useRef(s);u.useEffect(()=>{let a=null;return n&&(a=setTimeout(()=>{c(!0)},50)),()=>{clearTimeout(a)}},[n]);const h=a=>{f.current=a,l(a)},b=()=>{c(!1),l(f.current)},y=e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[s,s!=="auto"&&e.jsx("div",{style:{marginLeft:4,backgroundColor:s,width:"1em",height:"1em",borderRadius:"0.2em"}})]})}),p=e.jsxs(j,{onKeyDown:b,sx:{display:"flex",flexGrow:1,alignItems:"center",height:"40px"},children:[e.jsx(j,{onClick:()=>c(!0),sx:{display:"flex",alignItems:"center"},children:e.jsx("div",{ref:m,style:{flexShrink:0,marginLeft:"8px",backgroundColor:s,width:"32px",height:"32px",boxSizing:"border-box",borderRadius:"8px",border:"1px solid #eee",cursor:s==="auto"?"default":"pointer"}})}),e.jsx(L,{open:i,anchorEl:m.current,onClose:()=>c(!1),anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(G,{color:s,onChange:a=>h(a.hex)})})]});return n?p:y}T.propTypes=S;function D({editing:n,description:s,value:l,onChange:i,componentProps:c={},...m}){const{placeholder:f}=c,h=u.useRef(l),{t:b}=u.useContext(H),y=a=>{a.key==="Enter"&&i(h.current,"confirm")},p=a=>{h.current=a,i(a)};return n?e.jsx(A,{style:{flex:1},fullWidth:!0,value:l,onChange:a=>{a.persist(),p(a.target.value)},autoFocus:!0,size:"small",variant:"outlined",placeholder:s||f,onKeyDown:y,...m}):e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:l||e.jsx("span",{className:"placeholder",children:b("common.requiredInputPlaceholder",{name:s||f})})})}D.propTypes=S;function O({editing:n,value:s,onChange:l,componentProps:i,...c}){const{blocklet:m}=i,f=s==="auto"?J(m.appDid):s;return e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{width:96,marginRight:12},dangerouslySetInnerHTML:{__html:U({title:"Owner",issuer:Y.getDisplayName(m),issuerDid:m.appDid,ownerName:"Your Name",ownerDid:m.appDid,preferredColor:s||"auto"})}}),e.jsx(T,{...c,editing:n,value:n?f:s,onChange:l,componentProps:i})]})}O.propTypes={...S,componentProps:o.shape({blocklet:o.object.isRequired}).isRequired};const re=$`
1
+ import{r as u}from"./vendor-react-x2lQvn4m.js";import{$ as o,j as e,ak as j,aN as L,G as A,at as K,bi as B,I as P,p as M,bH as W,aj as X,b$ as $}from"./vendor-mui-core-p6jGoroc.js";import{C as G}from"./Google-YsG2REYU.js";import{b as H}from"./vendor-ux-TkkDR0Gn.js";import{aw as U,f as Y}from"./index-S9T-sBWO.js";import{A as J}from"./vendor-arcblock-BndcJjQO.js";import{F as Q,R as Z,L as v}from"./logo-uploader-DL_O0r92.js";import{A as ee,a as ne,b as te}from"./collapse-BqoeNHou.js";const S={description:o.string,editing:o.bool,onChange:o.func,required:o.bool,value:o.any,componentProps:o.object,render:o.func,renderFormItem:o.func};function T({editing:n,value:s,onChange:l}){const[i,c]=u.useState(!1),m=u.useRef(),f=u.useRef(s);u.useEffect(()=>{let a=null;return n&&(a=setTimeout(()=>{c(!0)},50)),()=>{clearTimeout(a)}},[n]);const h=a=>{f.current=a,l(a)},b=()=>{c(!1),l(f.current)},y=e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[s,s!=="auto"&&e.jsx("div",{style:{marginLeft:4,backgroundColor:s,width:"1em",height:"1em",borderRadius:"0.2em"}})]})}),p=e.jsxs(j,{onKeyDown:b,sx:{display:"flex",flexGrow:1,alignItems:"center",height:"40px"},children:[e.jsx(j,{onClick:()=>c(!0),sx:{display:"flex",alignItems:"center"},children:e.jsx("div",{ref:m,style:{flexShrink:0,marginLeft:"8px",backgroundColor:s,width:"32px",height:"32px",boxSizing:"border-box",borderRadius:"8px",border:"1px solid #eee",cursor:s==="auto"?"default":"pointer"}})}),e.jsx(L,{open:i,anchorEl:m.current,onClose:()=>c(!1),anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(G,{color:s,onChange:a=>h(a.hex)})})]});return n?p:y}T.propTypes=S;function D({editing:n,description:s,value:l,onChange:i,componentProps:c={},...m}){const{placeholder:f}=c,h=u.useRef(l),{t:b}=u.useContext(H),y=a=>{a.key==="Enter"&&i(h.current,"confirm")},p=a=>{h.current=a,i(a)};return n?e.jsx(A,{style:{flex:1},fullWidth:!0,value:l,onChange:a=>{a.persist(),p(a.target.value)},autoFocus:!0,size:"small",variant:"outlined",placeholder:s||f,onKeyDown:y,...m}):e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:l||e.jsx("span",{className:"placeholder",children:b("common.requiredInputPlaceholder",{name:s||f})})})}D.propTypes=S;function O({editing:n,value:s,onChange:l,componentProps:i,...c}){const{blocklet:m}=i,f=s==="auto"?J(m.appDid):s;return e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{width:96,marginRight:12},dangerouslySetInnerHTML:{__html:U({title:"Owner",issuer:Y.getDisplayName(m),issuerDid:m.appDid,ownerName:"Your Name",ownerDid:m.appDid,preferredColor:s||"auto"})}}),e.jsx(T,{...c,editing:n,value:n?f:s,onChange:l,componentProps:i})]})}O.propTypes={...S,componentProps:o.shape({blocklet:o.object.isRequired}).isRequired};const re=$`
2
2
  0%, 100% {
3
3
  transform: scale(1) translateX(0);
4
4
  }
@@ -1,4 +1,4 @@
1
- import{g as Bt,r as v}from"./vendor-react-x2lQvn4m.js";import{j as e,ak as y,G as Q,b6 as me,bb as qe,E as V,am as ut,d3 as Wt,bi as qt,at as ae,b1 as mt,$ as h,T as ee,Y as Ye,d4 as pt,b5 as Ke,C as Me,V as Fe,d5 as Ge,aN as Ue,p as ft,J as ht,a8 as xt,d6 as Kt,ac as gt,d7 as Mt,d8 as Ut,bY as st,n as Ht,D as $t,bu as Vt,M as it,cB as Yt,I as Gt,d9 as Jt}from"./vendor-mui-core-Bz-X9hX7.js";import{A as bt,J as Xt,C as Qt,e as le,F as Zt,a4 as je}from"./vendor-utils-CtD44yV-.js";import{T as te,H as M,n as ce,b as en,j as jt,a0 as tn,as as nn,$ as vt,D as yt,at as ke,a as St,A as sn,N as an}from"./vendor-ux-BArADSzA.js";import{bj as rn,_ as Je,Y as Ct,aN as Rt,F as _e,c as _,ad as Z,p as on,aE as at}from"./index-BVAv5IrJ.js";import{g as ye,a as $,f as se}from"./vendor-hooks-CwHgeAuk.js";import{u as wt,C as J}from"./index.esm-BONQrRCU.js";import{o as He,j as ln,d as cn,N as dn}from"./use-blocklet-logo-CudOf_wh.js";import{S as X}from"./section-76c1fWcb.js";import{A as un,a as mn,b as pn}from"./collapse-BWjaTK3Y.js";import{S as Se}from"./shorten-label-CqCkrOW-.js";import{v as Tt}from"./index-BiGUf0JP.js";import{R as Nt,A as fn,S as hn,a as xn,B as gn}from"./list-kq8swRwp.js";import{W as bn}from"./did-address-COwwd6H0.js";import{p as It}from"./util-DakLk8kj.js";import{D as jn,g as vn}from"./traffic-PJIhaYTG.js";import{B as Et}from"./bundle-avatar-D1U8n6sJ.js";import{u as yn}from"./use-mobile-BkNZycG6.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DKbvje4v.js";import"./session-CFTmeC0_.js";import"./server-logo-notext.svg-BqCXmsOm.js";import"./index-ZnnRM00W.js";import"./base32-vvndof6f.js";import"./dot-DLj9aDwC.js";import"./useAsync-Ct43XAf7.js";import"./iframe-CubIsy36.js";import"./index-BsTbYUnM.js";import"./index-DBs9Ljax.js";import"./base-chart-BGpAbSkc.js";import"./index-Wo9AdN6Y.js";import"./vendor-mui-x-Cgnunrow.js";import"./AdapterDayjs-BeqEJUig.js";var Te={exports:{}},Ne={exports:{}},Ie={exports:{}},rt;function Sn(){return rt||(rt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=t;function t(r){return r==null}n.exports=s.default,n.exports.default=s.default}(Ie,Ie.exports)),Ie.exports}var ot;function Cn(){return ot||(ot=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=u;var t=o(rn()),r=o(Sn());function o(p){return p&&p.__esModule?p:{default:p}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,b=/^[-+]?[0-9]+$/;function u(p,i){(0,t.default)(p),i=i||{};var N=i.allow_leading_zeroes===!1?l:b,I=!i.hasOwnProperty("min")||(0,r.default)(i.min)||p>=i.min,S=!i.hasOwnProperty("max")||(0,r.default)(i.max)||p<=i.max,j=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||p<i.lt,E=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||p>i.gt;return N.test(p)&&I&&S&&j&&E}n.exports=s.default,n.exports.default=s.default}(Ne,Ne.exports)),Ne.exports}var lt;function Rn(){return lt||(lt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=o;var t=r(Cn());function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,t.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=s.default,n.exports.default=s.default}(Te,Te.exports)),Te.exports}var wn=Rn();const Tn=Bt(wn),ze={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Nn(){const{api:n}=Je(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=Rt(),l=s?.meta?.did,b=Object.assign({...ze},s?.settings?.notification?.email||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=wt({defaultValues:bt(b,Object.keys(ze))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(a,T,O=!0)=>{try{const{blocklet:D}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),re=Object.assign({...ze},D?.settings?.notification?.email||{});I(re),O&&M.success(t("oauth.saveSuccess"))}catch(D){if(O)M.error(D.message||t("oauth.saveFailed"));else throw D}}),Y=$(async(a,T,O)=>{try{i.isDirty&&await E(a,T,!1),await n.sendEmail({input:{did:l,receiver:O,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),M.success(t("notification.email.testSuccess"))}catch(D){M.error(D.message||t("notification.email.testfailed"))}}),z=$((a,T)=>{S.testReceiver="",S.testReceiverError="",r.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(y,{sx:{width:"300px"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:S.testReceiver,onChange:O=>{S.testReceiver=O.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(O){const D=S.testReceiver?.trim();if(!D){S.testReceiverError=t("notification.email.receiverRequired");return}if(!_e(D)){S.testReceiverError=t("notification.email.receiverInvalid");return}S.testReceiverError="",await Y(a,T,D),O()}})}),F=$(a=>{const T=a?.trim();return T?_e(T)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),W=$(a=>{const T=a?.trim();return T?He(T,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),R=$(a=>a?Tn(a)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),q=$(a=>a?.trim()?!0:t("notification.email.userRequired")),K=$(a=>a?.trim()?!0:t("notification.email.passwordRequired")),f=$(a=>a?.trim()&&!He(a,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),w=$(a=>a?.trim()&&!_e(a)?t("notification.email.emailInvalid"):!0),C=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(In,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.email.enable"),my:2.5,children:e.jsx(J,{name:"enabled",control:p,render:({field:a})=>e.jsx(me,{control:e.jsx(qe,{checked:a.value,...a})})})}),e.jsx(X,{title:t("notification.email.from"),children:e.jsx(J,{name:"from",control:p,rules:{validate:j?F:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[a.name],helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.host"),children:e.jsx(J,{name:"host",control:p,rules:{validate:j?W:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.host"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.port"),children:e.jsx(J,{name:"port",control:p,rules:{validate:j?R:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:t("notification.email.port"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.user"),children:e.jsx(J,{name:"user",control:p,rules:{validate:j?q:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.user"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.password"),children:e.jsx(J,{name:"password",control:p,rules:{validate:j?K:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:t("notification.email.password"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.secure"),children:e.jsx(J,{name:"secure",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(me,{control:e.jsx(qe,{checked:a.value,...a,disabled:!j})})})})}),e.jsxs(un,{children:[e.jsxs(mn,{expandIcon:e.jsx(qt,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(ut,{title:t("notification.email.signatureTooltip"),children:e.jsx(Wt,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(pn,{children:[e.jsx(X,{title:t("notification.email.companyName"),children:e.jsx(J,{name:"companyName",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyName"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyLink"),children:e.jsx(J,{name:"companyLink",control:p,rules:{validate:j?f:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyLink"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyAddress"),children:e.jsx(J,{name:"companyAddress",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyAddress"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.supportEmail"),children:e.jsx(J,{name:"supportEmail",control:p,rules:{validate:j?w:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:t("notification.email.supportEmail"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})})]})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const In=ae(mt)``,Be={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function En(){const{api:n}=Je(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=Rt(),l=s?.meta?.did,b=Object.assign({...Be},s?.settings?.notification?.pushKit||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=wt({defaultValues:bt(b,Object.keys(Be))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(R,q,K=!0)=>{try{const{blocklet:f}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:R})}}),w=Object.assign({...Be},f?.settings?.notification?.pushKit||{});I(w),K&&M.success(t("oauth.saveSuccess"))}catch(f){if(K)M.error(f.message||t("oauth.saveFailed"));else throw f}}),Y=$(async(R,q)=>{try{i.isDirty&&await E(R,q,!1);const K=(s?.configs||[]).find(C=>C.key==="BLOCKLET_APP_URL")?.value,f=Xt(Qt(K,_.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),w={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:f}}}};await n.sendPush({input:{did:l,receiver:S.testReceiver,notification:JSON.stringify(w)}}),M.success(t("notification.pushKit.testSuccess"))}catch(K){M.error(K.message||t("notification.pushKit.testfailed"))}}),z=$((R,q)=>{S.testReceiverError="",r.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(y,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:S.testReceiver,onChange:K=>{S.testReceiver=K.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(K){if(!S.testReceiver?.trim()){S.testReceiverError=t("notification.pushKit.receiverRequired");return}S.testReceiverError="",await Y(R,q),K()}})}),F=$(R=>{const q=R?.trim();return q?He(q)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),W=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(An,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(J,{name:"enabled",control:p,render:({field:R})=>e.jsx(me,{control:e.jsx(qe,{checked:R.value,...R})})})}),e.jsx(X,{title:t("notification.pushKit.endpoint"),children:e.jsx(J,{name:"endpoint",control:p,rules:{validate:j?F:W},render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})})}),e.jsxs(X,{title:t("notification.pushKit.customOptions"),children:[e.jsx(J,{name:"did",control:p,render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})}),e.jsx(J,{name:"pushPath",control:p,render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const An=ae(mt)``,ct=[{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function kn(){const[n,s]=v.useState(ct[0].value),{locale:t}=v.useContext(en),r=se(()=>({email:e.jsx(Nn,{}),pushKit:e.jsx(En,{})}),[t]),o=v.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(y,{children:[e.jsx(jt,{tabs:ct,current:n,onChange:s}),e.jsx(y,{style:o,children:r[n]})]})}const At=v.createContext({}),{Provider:On,Consumer:Fs}=At;function Dn({children:n,blocklet:s=""}){const{api:t,inService:r,ws:{useSubscription:o}}=Je(),[l,b]=v.useState([]),[u,p]=v.useState({total:0,pageSize:20,pageCount:0,page:1}),i=se(()=>s.meta?.did,[s]),[N,I]=v.useState([]),[S,j]=v.useState({}),E=se(()=>l.length?new Set(l.map(f=>f.id)):new Set,[l]),Y=async({page:f=1,pageSize:w=20,...C}={})=>{if(!i)return[];try{const a={paging:{page:f,pageSize:w},...C,teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0},{dids:T,...O}=a;let D="";T&&T.includes("system")&&(D="system");const re=T?T.filter(pe=>pe!=="system"):[],ue={...O,source:D,componentDids:re},oe=await t.getNotificationSendLog({input:ue});return j(ue),b(oe.list),p(oe.paging),oe.list}catch(a){return M.error(a.message),[]}},z=async()=>{const f=await t.getNotificationComponents({input:{teamDid:i}});I(f.componentDids)},F=v.useCallback(f=>{const w=s.children.find(C=>C.meta?.did===f);if(w)return w.ancestors=[s],w},[s]),W=async({notificationId:f,receivers:w,channels:C,...a})=>{await t.resendNotification({input:{teamDid:i,notificationId:f,receivers:w,channels:C.map(T=>T==="wallet"?_.NOTIFICATION_SEND_CHANNEL.WALLET:T==="pushKit"?_.NOTIFICATION_SEND_CHANNEL.PUSH:T),...a}})},R=v.useCallback(async f=>(await t.getUser({input:{teamDid:i,user:{did:f}}})).user,[t,i]),q=v.useCallback(async({page:f=1,pageSize:w=20,...C}={})=>{try{const a={paging:{page:f,pageSize:w},...C,userName:C.searchText||"",teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0};return await t.getReceivers({input:a})}catch(a){throw M.error(a.message),a}},[t,i]);v.useEffect(()=>{i&&z()},[i]),o(_.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,f=>{E.has(f.notificationId)&&Y(S)},[E,S]),o(_.EVENTS.NOTIFICATION_BLOCKLET_CREATE,f=>{E.has(f.id)||Y(S)},[E,S]);const K={fetch:Y,data:l,paging:u,blocklet:s,getComponent:F,resendNotification:W,getUser:R,componentDids:N,getReceivers:q,inService:r,teamDid:i};return e.jsx(On,{value:{notificationRecords:K},children:n})}function Xe(){const{notificationRecords:n}=v.useContext(At);return n}Ce.propTypes={severity:h.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ln={info:"primary",success:"success",error:"error",warning:"warning"};function Ce({severity:n="info"}){return e.jsx(tn,{type:Ln[n],children:n})}const Pn=(n,s,t="")=>{if(!t||!s)return"";switch(t){case _.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return t}};function kt(n,s,t={}){const{status:r,updatedAt:o,reason:l="",channel:b="wallet"}=t,u=o?n("notification.sendStatus.sentTime",{date:on(o,s)}):"",p=Pn(n,b,l);return r===_.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:u,reason:p}:r===_.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:u}:{status:"pending",title:n("notification.sendStatus.pending"),reason:p,sentTime:u}}const $e={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ve=["wallet","pushKit","email"],dt=["info","success","error","warning"],Ot=n=>{const{settings:s}=n;return s?.notification?.email?.enabled},Dt=n=>{const{settings:s}=n;return s?.notification?.pushKit?.enabled},Fn=(n,s)=>{const t=le(s,"extra.notifications.email",!0);return{available:Ot(n),enabled:t}},_n=(n,s)=>{const t=le(s,"extra.notifications.push",!0);return{available:Dt(n),enabled:t}},zn=n=>({enabled:le(n,"extra.notifications.wallet",!0)}),Bn=n=>({enabled:le(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(s=>{setTimeout(()=>{s()},n*1e3)}),Wn=(n,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:n("notification.sendStatus.reason.available",{channel:s}),fail:n("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:[],Ae=(n=[])=>{const s=Z().startOf("day");return n.filter(t=>Z(t.sendAt).isSame(s,"day")).length},qn=(n,s="")=>{if(s&&Ve.includes(s)){const l=`${s}SendRecord`,b=le(n,l,[]);return Ae(b)}const t=le(n,"webhook",{}),r=Object.keys(t??{})??[];if(s&&r.includes(s)){const l=t[s]??[];return Ae(l)}const o={};return Ve.forEach(l=>{const b=`${l}SendRecord`,u=le(n,b,[]),p=Ae(u);o[l]=p}),r.length>0&&r.forEach(l=>{const b=t[l]??[],u=Ae(b);o[l]=u}),o},Oe=(n,s,t)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[t].splice(s,1),n},De=(n,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(n):!1},Kn=n=>{switch(n){case _.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case _.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case _.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case _.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:s=!0,showTitle:t=!1,children:r=null}){const{status:o,title:l="",sentTime:b="",reason:u=""}=n,p=[l,u].filter(Boolean).join(", ");return e.jsx(ut,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:p}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(y,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(y,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:$e[o]}}),e.jsx(y,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:$e[o]}})]}),e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:t?l:r})]})})}de.propTypes={config:h.object.isRequired,enableTooltip:h.bool,showTitle:h.bool,children:h.node};Le.propTypes={list:h.array.isRequired,label:h.string.isRequired,onDelete:h.func};function Le({list:n,label:s,onDelete:t=()=>{}}){const{t:r,locale:o}=te();return e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),n.map(l=>{const b=kt(r,o,{status:l});return e.jsx(Ye,{size:"small",label:e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(de,{config:b,enableTooltip:!1,children:b.title})}),onDelete:u=>t(u,l)},l)})]})}Qe.propTypes={filterList:h.array.isRequired,onChange:h.func.isRequired,index:h.number.isRequired,column:h.object.isRequired,filterValues:h.array.isRequired,label:h.string.isRequired,renderLabel:h.func.isRequired};function Qe({filterList:n,onChange:s,index:t,column:r,filterValues:o,label:l,renderLabel:b}){return e.jsxs(V,{className:"filter-container",children:[e.jsx(pt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(u=>e.jsx(me,{control:e.jsx(Me,{checked:n[t].indexOf(u.value??u)>-1,onChange:p=>{const i=[...n];p.target.checked?i[t]=[...i[t],u.value??u]:i[t]=i[t].filter(N=>N!==(u.value??u)),s(i[t],t,r)},name:u.value??u}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(u)})},u.value??u))})]})}function We(n){return e.jsx(Qe,{...n,renderLabel:s=>e.jsx(de,{enableTooltip:!1,config:{status:s.status},children:s.label})})}xe.propTypes={status:h.number.isRequired,updatedAt:h.string.isRequired,reason:h.string,channel:h.string,onResend:h.func};function xe({status:n,updatedAt:s,reason:t="",channel:r="wallet",onResend:o}){const{t:l,locale:b}=te(),u=kt(l,b,{status:n,updatedAt:s,reason:t,channel:r});return e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(de,{config:u,showTitle:!0}),u.status!=="success"&&e.jsx(Fe,{className:"resend-btn",size:"small",startIcon:e.jsx(Ge,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}Ze.propTypes={value:h.array.isRequired,onChange:h.func};function Ze({value:n,onChange:s}){const{locale:t}=te(),r=Z().toDate(),[o,l]=v.useState(null),b=v.useCallback(i=>{l(o?null:i.currentTarget)},[o]),u=!!o,p=v.useCallback(i=>{if(!i.startDate||!i.endDate){M.error("Please select a date range");return}if(Z(i.startDate).isAfter(i.endDate)||!Z(i.startDate).isValid()||!Z(i.endDate).isValid()){M.error("Invalid date range");return}s([i.startDate,i.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(ee,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Fe,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[at(n[0],t)," - ",at(n[1],t)]})}),e.jsx(Ue,{open:u,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(jn,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:b,definedRanges:vn(r),onChange:p})})]})}et.propTypes={itemComponent:h.elementType.isRequired};function et({itemComponent:n,...s}){const{t}=te();return!s?.filterList?.filter(o=>o.length).length?null:e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:t("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(nn.TableFilterList,{...s,ItemComponent:n})})]})}function tt({label:n,onDelete:s,canDelete:t=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let l=!0;return t&&typeof t=="function"&&(l=t({label:n,...r})),e.jsx(Ye,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}tt.propTypes={label:h.string.isRequired,onDelete:h.func,canDelete:h.func};const Mn=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];Pt.propTypes={loading:h.bool,onCancel:h.func,onConfirm:h.func};function Pt({loading:n=!1,onCancel:s=()=>{},onConfirm:t=()=>{}}){const{t:r}=te(),[o,l]=v.useState(Mn),[b,u]=v.useState(!0),p=(N,I)=>{I.checked=N.target.checked;const S=o.map(j=>({...j,checked:j.value===I.value?I.checked:j.checked}));l(S)},i=N=>{N.stopPropagation(),t({channels:o.filter(I=>I.checked).map(I=>I.value),isResendFailedOnly:b})};return e.jsxs(y,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ee,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(y,{className:"choose-channel",children:e.jsxs(V,{component:"fieldset",variant:"standard",children:[e.jsx(pt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(N=>e.jsx(me,{control:e.jsx(Me,{checked:N.checked,onChange:I=>p(I,N),name:N.value}),label:N.label},N.value))})]})}),e.jsx(y,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(me,{control:e.jsx(Me,{checked:b,onChange:N=>u(N.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(y,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Fe,{onClick:N=>{N.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Fe,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(ft,{size:16}),r("common.confirm")]})]})]})}Ft.propTypes={notificationId:h.string.isRequired,handleResend:h.func,resending:h.bool};function Ft({notificationId:n,handleResend:s,resending:t=!1}){const{t:r,locale:o}=te(),l=ht(),b=v.useMemo(()=>xt(l,Lt()),[l]),{getReceivers:u,inService:p,teamDid:i,getUser:N,blocklet:I}=Xe(),[S,j]=v.useState(!1),[E,Y]=v.useState([]),z=ye({anchorEl:null,position:null}),F=ye({anchorEl:null,position:null}),[W,R]=v.useState(null),[q,K]=v.useState({total:0,pageSize:10,pageCount:0,page:1}),[f,w]=v.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),[C,a]=v.useState([]),T=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],O=async()=>{if(!S&&n)try{j(!0);const c=await u({notificationId:n,...f}),d=c.list.map(m=>({...m,receiverUser:{...m.receiverUser,avatar:It(m.receiverUser.avatar,i,p)}}));Y(d),K(c.paging),j(!1)}catch(c){M.error(c.message),j(!1)}};v.useEffect(()=>{O()},[f]);const D=c=>{c.stopPropagation();const d=c.currentTarget;F.anchorEl=d;const m=d.getBoundingClientRect();F.position={top:m.top+window.scrollY,left:m.left+window.scrollX}},re=c=>c.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(ce,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Ge,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:D,children:r("notification.resend")})}):null,ue={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:q.page-1,rowsPerPage:q.pageSize,count:q.total,searchText:f.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:C,onRowSelectionChange:(c,d)=>{a(d.map(m=>m.dataIndex))},customToolbarSelect:re},oe=({page:c,rowsPerPage:d,searchText:m,filterList:k})=>{const[,U=[],ne=[],G=[]]=k;f.pageSize!==d?w(H=>({...H,pageSize:d,page:1})):f.page!==c+1?w(H=>({...H,page:c+1})):f.searchText!==m?w(H=>({...H,searchText:m,page:1})):je(U,f.walletSendStatus)?je(ne,f.pushKitSendStatus)?je(G,f.emailSendStatus)||w(H=>({...H,emailSendStatus:G,page:1})):w(H=>({...H,pushKitSendStatus:ne,page:1})):w(H=>({...H,walletSendStatus:U,page:1}))},pe=v.useCallback(async(c,d)=>{if(!d)return!1;const m=await N(d);return m?c==="wallet"?zn(m):c==="email"?Fn(I,m):c==="pushKit"?_n(I,m):c==="webhook"?Bn(m):!0:!1},[N,I]),Re=v.useCallback(c=>Wn(r,c),[r]),fe=()=>{z.anchorEl=null,z.position=null,R(null)},he=()=>{F.anchorEl=null,F.position=null},g=async(c,d,m=!0,k="")=>{if(!(!d.length||!c.length))try{s(c,d,m,k),F.anchorEl||(await Ee(.5),fe())}catch(U){console.error("handleResend error",{error:U})}},x=async({channels:c,isResendFailedOnly:d})=>{const m=C.map(k=>E[k].receiver);await g(c,m,d),await Ee(.5),he(),a([])},A=async(c,d=[],m=!0)=>{try{await g(["webhook"],[c.receiver],m,d)}catch(k){M.error(k.response?k.response.statusText:k.message)}},L=async(c,d,m,k=[],U=!0)=>{if(c.stopPropagation(),qn(d,m)>=4){M.warning(r("notification.resendLimit"));return}if(!Ve.includes(m)){await A(d,k,U);return}if(c){const G=c.currentTarget,H=G.getBoundingClientRect();z.anchorEl=G,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}R({channel:m});try{const G=await pe(m,d.receiver);await Ee(1),R({channel:m,result:G}),(typeof G=="boolean"&&G||Zt(G)&&Object.values(G).every(H=>!!H))&&(await s([m],[d.receiver],U),F.anchorEl||(await Ee(.5),fe()))}catch(G){M.error(G.message)}},B=c=>{w(d=>({...d,dateRange:c,page:1}))},P=(c,d,m,k)=>{c.stopPropagation();const U=m.filter(ne=>ne!==d);w(ne=>({...ne,[k]:U,page:1}))},ie=se(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:c=>{const{receiverUser:d,receiver:m}=E[c];return d?e.jsxs(y,{"data-cy":`member-name-${d.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(vt,{src:`${d.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:m,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Se,{children:d.fullName})]},m):e.jsx(bn,{size:14,responsive:!1,compact:!0,copyable:!1,did:m})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:f.walletSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Wallet",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[1].options.filterList,"walletSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,k)=>e.jsx(We,{label:"Wallet",filterList:c,onChange:d,index:m,column:k,filterValues:T})},customBodyRenderLite:c=>{const{walletSendStatus:d,walletSendAt:m,walletSendFailedReason:k}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:k,channel:"wallet",onResend:U=>L(U,E[c],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{pushKitSendStatus:d,pushKitSendAt:m,pushKitSendFailedReason:k}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:k,channel:"pushkit",onResend:U=>L(U,E[c],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:f.pushKitSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Push Kit",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[2].options.filterList,"pushKitSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,k)=>e.jsx(We,{label:"Push Kit",filterList:c,onChange:d,index:m,column:k,filterValues:T})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{emailSendStatus:d,emailSendAt:m,emailSendFailedReason:k}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:k,channel:"email",onResend:U=>L(U,E[c],"email",[],!1)})},filter:!0,filterType:"custom",filterList:f.emailSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Email",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[3].options.filterList,"emailSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,k)=>e.jsx(We,{label:"Email",filterList:c,onChange:d,index:m,column:k,filterValues:T})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{webhook:d}=E[c];if(!d)return null;const m=Object.entries(d)[0];if(!m)return null;const[k,U]=m,ne=U[0];return e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(y,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(Se,{maxLength:30,children:k},k),e.jsx(xe,{status:ne.status,updatedAt:ne.sendAt,reason:ne.failedReason,channel:"webhook",onResend:G=>L(G,E[c],"webhook",[k],!1)})]},k)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:c=>{const{createdAt:d}=E[c];return e.jsx(Nt,{value:d,locale:o,shouldUpdate:!0})}}}],[E,o,f,r]),we=[e.jsx(Ze,{value:f.dateRange,onChange:B},"date-picker"),e.jsx(ce,{variant:"contained",size:"small",color:"primary",loading:S,startIcon:e.jsx(Kt,{}),onClick:()=>O(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(y,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(Hn,{children:e.jsxs(gt,{theme:b,children:[e.jsx(yt,{className:"receivers-table",locale:o,loading:S,columns:ie,data:E,onChange:oe,options:ue,customButtons:we,components:{TableFilterList:c=>e.jsx(et,{...c,itemComponent:d=>e.jsx(tt,{...d,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Ue,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:fe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs($n,{children:[e.jsxs(ee,{variant:"body1",component:"div",className:"check-title",children:[W?.channel," Checking"]}),e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Re(W?.channel).map(c=>{const{type:d,pass:m,fail:k}=c;return!W?.result||W?.result?.[d]?e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:W?.result?.[d]?ke.success.main:"inherit"},children:[W?.result?e.jsx(Mt,{}):e.jsx(ft,{size:12,sx:{color:ke.primary.main}}),e.jsx("span",{children:m})]},d):e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:ke.error.main},children:[e.jsx(Ut,{}),e.jsx("span",{children:k})]},d)})})]})}),F.anchorEl&&e.jsx(Ue,{open:!!F.anchorEl,anchorReference:"anchorPosition",anchorPosition:F.position,onClose:he,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Pt,{loading:t,onCancel:he,onConfirm:x})})]})})})}const Un=v.memo(Ft),Hn=ae.div`
1
+ import{g as Bt,r as v}from"./vendor-react-x2lQvn4m.js";import{j as e,ak as y,G as Q,b6 as me,bb as qe,E as V,am as ut,d3 as Wt,bi as qt,at as ae,b1 as mt,$ as h,T as ee,Y as Ye,d4 as pt,b5 as Ke,C as Me,V as Fe,d5 as Ge,aN as Ue,p as ft,J as ht,a8 as xt,d6 as Kt,ad as gt,d7 as Mt,d8 as Ut,bY as st,n as Ht,D as $t,bu as Vt,M as it,cB as Yt,I as Gt,d9 as Jt}from"./vendor-mui-core-p6jGoroc.js";import{A as bt,J as Xt,C as Qt,e as le,F as Zt,a4 as je}from"./vendor-utils-CtD44yV-.js";import{T as te,H as M,n as ce,b as en,j as jt,a0 as tn,as as nn,$ as vt,D as yt,at as ke,a as St,A as sn,N as an}from"./vendor-ux-TkkDR0Gn.js";import{bj as rn,_ as Je,Y as Ct,aN as Rt,F as _e,c as _,ad as Z,p as on,aE as at}from"./index-S9T-sBWO.js";import{g as ye,b as $,a as se}from"./vendor-hooks-zCCbpt45.js";import{u as wt,C as J}from"./index.esm-BONQrRCU.js";import{o as He,j as ln,d as cn,N as dn}from"./use-blocklet-logo-B1g1jSm8.js";import{S as X}from"./section-iFIMehPS.js";import{A as un,a as mn,b as pn}from"./collapse-BqoeNHou.js";import{S as Se}from"./shorten-label-OzRq4VRH.js";import{v as Tt}from"./index-VGO-dEle.js";import{R as Nt,A as fn,S as hn,a as xn,B as gn}from"./list-B7ZF5Ul0.js";import{W as bn}from"./did-address-BdvYNOBf.js";import{p as It}from"./util-Doke8P4Y.js";import{D as jn,g as vn}from"./traffic-C0Ugjtml.js";import{B as Et}from"./bundle-avatar-mX0oF7zo.js";import{u as yn}from"./use-mobile-B8-JPkft.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BndcJjQO.js";import"./session-CD-6TrlW.js";import"./server-logo-notext.svg-BqCXmsOm.js";import"./index-DKdSMDX6.js";import"./base32-6sm6N7JR.js";import"./dot-DWse_kXZ.js";import"./useAsync-C8Ma6muj.js";import"./iframe-CTQOWc1h.js";import"./index-C7Lof57D.js";import"./index-DBs9Ljax.js";import"./base-chart-D2xQQY8-.js";import"./index-biihuQJV.js";import"./vendor-mui-x-CkcHHKbJ.js";import"./AdapterDayjs-DiKE7R2w.js";var Te={exports:{}},Ne={exports:{}},Ie={exports:{}},rt;function Sn(){return rt||(rt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=t;function t(r){return r==null}n.exports=s.default,n.exports.default=s.default}(Ie,Ie.exports)),Ie.exports}var ot;function Cn(){return ot||(ot=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=u;var t=o(rn()),r=o(Sn());function o(p){return p&&p.__esModule?p:{default:p}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,b=/^[-+]?[0-9]+$/;function u(p,i){(0,t.default)(p),i=i||{};var N=i.allow_leading_zeroes===!1?l:b,I=!i.hasOwnProperty("min")||(0,r.default)(i.min)||p>=i.min,S=!i.hasOwnProperty("max")||(0,r.default)(i.max)||p<=i.max,j=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||p<i.lt,E=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||p>i.gt;return N.test(p)&&I&&S&&j&&E}n.exports=s.default,n.exports.default=s.default}(Ne,Ne.exports)),Ne.exports}var lt;function Rn(){return lt||(lt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=o;var t=r(Cn());function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,t.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=s.default,n.exports.default=s.default}(Te,Te.exports)),Te.exports}var wn=Rn();const Tn=Bt(wn),ze={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Nn(){const{api:n}=Je(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=Rt(),l=s?.meta?.did,b=Object.assign({...ze},s?.settings?.notification?.email||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=wt({defaultValues:bt(b,Object.keys(ze))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(a,T,O=!0)=>{try{const{blocklet:D}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),re=Object.assign({...ze},D?.settings?.notification?.email||{});I(re),O&&M.success(t("oauth.saveSuccess"))}catch(D){if(O)M.error(D.message||t("oauth.saveFailed"));else throw D}}),Y=$(async(a,T,O)=>{try{i.isDirty&&await E(a,T,!1),await n.sendEmail({input:{did:l,receiver:O,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),M.success(t("notification.email.testSuccess"))}catch(D){M.error(D.message||t("notification.email.testfailed"))}}),z=$((a,T)=>{S.testReceiver="",S.testReceiverError="",r.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(y,{sx:{width:"300px"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:S.testReceiver,onChange:O=>{S.testReceiver=O.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(O){const D=S.testReceiver?.trim();if(!D){S.testReceiverError=t("notification.email.receiverRequired");return}if(!_e(D)){S.testReceiverError=t("notification.email.receiverInvalid");return}S.testReceiverError="",await Y(a,T,D),O()}})}),F=$(a=>{const T=a?.trim();return T?_e(T)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),W=$(a=>{const T=a?.trim();return T?He(T,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),R=$(a=>a?Tn(a)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),q=$(a=>a?.trim()?!0:t("notification.email.userRequired")),K=$(a=>a?.trim()?!0:t("notification.email.passwordRequired")),f=$(a=>a?.trim()&&!He(a,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),w=$(a=>a?.trim()&&!_e(a)?t("notification.email.emailInvalid"):!0),C=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(In,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.email.enable"),my:2.5,children:e.jsx(J,{name:"enabled",control:p,render:({field:a})=>e.jsx(me,{control:e.jsx(qe,{checked:a.value,...a})})})}),e.jsx(X,{title:t("notification.email.from"),children:e.jsx(J,{name:"from",control:p,rules:{validate:j?F:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[a.name],helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.host"),children:e.jsx(J,{name:"host",control:p,rules:{validate:j?W:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.host"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.port"),children:e.jsx(J,{name:"port",control:p,rules:{validate:j?R:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:t("notification.email.port"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.user"),children:e.jsx(J,{name:"user",control:p,rules:{validate:j?q:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.user"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.password"),children:e.jsx(J,{name:"password",control:p,rules:{validate:j?K:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:t("notification.email.password"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.secure"),children:e.jsx(J,{name:"secure",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(me,{control:e.jsx(qe,{checked:a.value,...a,disabled:!j})})})})}),e.jsxs(un,{children:[e.jsxs(mn,{expandIcon:e.jsx(qt,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(ut,{title:t("notification.email.signatureTooltip"),children:e.jsx(Wt,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(pn,{children:[e.jsx(X,{title:t("notification.email.companyName"),children:e.jsx(J,{name:"companyName",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyName"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyLink"),children:e.jsx(J,{name:"companyLink",control:p,rules:{validate:j?f:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyLink"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyAddress"),children:e.jsx(J,{name:"companyAddress",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyAddress"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.supportEmail"),children:e.jsx(J,{name:"supportEmail",control:p,rules:{validate:j?w:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:t("notification.email.supportEmail"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})})]})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const In=ae(mt)``,Be={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function En(){const{api:n}=Je(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=Rt(),l=s?.meta?.did,b=Object.assign({...Be},s?.settings?.notification?.pushKit||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=wt({defaultValues:bt(b,Object.keys(Be))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(R,q,K=!0)=>{try{const{blocklet:f}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:R})}}),w=Object.assign({...Be},f?.settings?.notification?.pushKit||{});I(w),K&&M.success(t("oauth.saveSuccess"))}catch(f){if(K)M.error(f.message||t("oauth.saveFailed"));else throw f}}),Y=$(async(R,q)=>{try{i.isDirty&&await E(R,q,!1);const K=(s?.configs||[]).find(C=>C.key==="BLOCKLET_APP_URL")?.value,f=Xt(Qt(K,_.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),w={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:f}}}};await n.sendPush({input:{did:l,receiver:S.testReceiver,notification:JSON.stringify(w)}}),M.success(t("notification.pushKit.testSuccess"))}catch(K){M.error(K.message||t("notification.pushKit.testfailed"))}}),z=$((R,q)=>{S.testReceiverError="",r.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(y,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:S.testReceiver,onChange:K=>{S.testReceiver=K.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(K){if(!S.testReceiver?.trim()){S.testReceiverError=t("notification.pushKit.receiverRequired");return}S.testReceiverError="",await Y(R,q),K()}})}),F=$(R=>{const q=R?.trim();return q?He(q)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),W=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(An,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(J,{name:"enabled",control:p,render:({field:R})=>e.jsx(me,{control:e.jsx(qe,{checked:R.value,...R})})})}),e.jsx(X,{title:t("notification.pushKit.endpoint"),children:e.jsx(J,{name:"endpoint",control:p,rules:{validate:j?F:W},render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})})}),e.jsxs(X,{title:t("notification.pushKit.customOptions"),children:[e.jsx(J,{name:"did",control:p,render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})}),e.jsx(J,{name:"pushPath",control:p,render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const An=ae(mt)``,ct=[{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function kn(){const[n,s]=v.useState(ct[0].value),{locale:t}=v.useContext(en),r=se(()=>({email:e.jsx(Nn,{}),pushKit:e.jsx(En,{})}),[t]),o=v.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(y,{children:[e.jsx(jt,{tabs:ct,current:n,onChange:s}),e.jsx(y,{style:o,children:r[n]})]})}const At=v.createContext({}),{Provider:On,Consumer:Fs}=At;function Dn({children:n,blocklet:s=""}){const{api:t,inService:r,ws:{useSubscription:o}}=Je(),[l,b]=v.useState([]),[u,p]=v.useState({total:0,pageSize:20,pageCount:0,page:1}),i=se(()=>s.meta?.did,[s]),[N,I]=v.useState([]),[S,j]=v.useState({}),E=se(()=>l.length?new Set(l.map(f=>f.id)):new Set,[l]),Y=async({page:f=1,pageSize:w=20,...C}={})=>{if(!i)return[];try{const a={paging:{page:f,pageSize:w},...C,teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0},{dids:T,...O}=a;let D="";T&&T.includes("system")&&(D="system");const re=T?T.filter(pe=>pe!=="system"):[],ue={...O,source:D,componentDids:re},oe=await t.getNotificationSendLog({input:ue});return j(ue),b(oe.list),p(oe.paging),oe.list}catch(a){return M.error(a.message),[]}},z=async()=>{const f=await t.getNotificationComponents({input:{teamDid:i}});I(f.componentDids)},F=v.useCallback(f=>{const w=s.children.find(C=>C.meta?.did===f);if(w)return w.ancestors=[s],w},[s]),W=async({notificationId:f,receivers:w,channels:C,...a})=>{await t.resendNotification({input:{teamDid:i,notificationId:f,receivers:w,channels:C.map(T=>T==="wallet"?_.NOTIFICATION_SEND_CHANNEL.WALLET:T==="pushKit"?_.NOTIFICATION_SEND_CHANNEL.PUSH:T),...a}})},R=v.useCallback(async f=>(await t.getUser({input:{teamDid:i,user:{did:f}}})).user,[t,i]),q=v.useCallback(async({page:f=1,pageSize:w=20,...C}={})=>{try{const a={paging:{page:f,pageSize:w},...C,userName:C.searchText||"",teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0};return await t.getReceivers({input:a})}catch(a){throw M.error(a.message),a}},[t,i]);v.useEffect(()=>{i&&z()},[i]),o(_.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,f=>{E.has(f.notificationId)&&Y(S)},[E,S]),o(_.EVENTS.NOTIFICATION_BLOCKLET_CREATE,f=>{E.has(f.id)||Y(S)},[E,S]);const K={fetch:Y,data:l,paging:u,blocklet:s,getComponent:F,resendNotification:W,getUser:R,componentDids:N,getReceivers:q,inService:r,teamDid:i};return e.jsx(On,{value:{notificationRecords:K},children:n})}function Xe(){const{notificationRecords:n}=v.useContext(At);return n}Ce.propTypes={severity:h.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ln={info:"primary",success:"success",error:"error",warning:"warning"};function Ce({severity:n="info"}){return e.jsx(tn,{type:Ln[n],children:n})}const Pn=(n,s,t="")=>{if(!t||!s)return"";switch(t){case _.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return t}};function kt(n,s,t={}){const{status:r,updatedAt:o,reason:l="",channel:b="wallet"}=t,u=o?n("notification.sendStatus.sentTime",{date:on(o,s)}):"",p=Pn(n,b,l);return r===_.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:u,reason:p}:r===_.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:u}:{status:"pending",title:n("notification.sendStatus.pending"),reason:p,sentTime:u}}const $e={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ve=["wallet","pushKit","email"],dt=["info","success","error","warning"],Ot=n=>{const{settings:s}=n;return s?.notification?.email?.enabled},Dt=n=>{const{settings:s}=n;return s?.notification?.pushKit?.enabled},Fn=(n,s)=>{const t=le(s,"extra.notifications.email",!0);return{available:Ot(n),enabled:t}},_n=(n,s)=>{const t=le(s,"extra.notifications.push",!0);return{available:Dt(n),enabled:t}},zn=n=>({enabled:le(n,"extra.notifications.wallet",!0)}),Bn=n=>({enabled:le(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(s=>{setTimeout(()=>{s()},n*1e3)}),Wn=(n,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:n("notification.sendStatus.reason.available",{channel:s}),fail:n("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:[],Ae=(n=[])=>{const s=Z().startOf("day");return n.filter(t=>Z(t.sendAt).isSame(s,"day")).length},qn=(n,s="")=>{if(s&&Ve.includes(s)){const l=`${s}SendRecord`,b=le(n,l,[]);return Ae(b)}const t=le(n,"webhook",{}),r=Object.keys(t??{})??[];if(s&&r.includes(s)){const l=t[s]??[];return Ae(l)}const o={};return Ve.forEach(l=>{const b=`${l}SendRecord`,u=le(n,b,[]),p=Ae(u);o[l]=p}),r.length>0&&r.forEach(l=>{const b=t[l]??[],u=Ae(b);o[l]=u}),o},Oe=(n,s,t)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[t].splice(s,1),n},De=(n,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(n):!1},Kn=n=>{switch(n){case _.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case _.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case _.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case _.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:s=!0,showTitle:t=!1,children:r=null}){const{status:o,title:l="",sentTime:b="",reason:u=""}=n,p=[l,u].filter(Boolean).join(", ");return e.jsx(ut,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:p}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(y,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(y,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:$e[o]}}),e.jsx(y,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:$e[o]}})]}),e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:t?l:r})]})})}de.propTypes={config:h.object.isRequired,enableTooltip:h.bool,showTitle:h.bool,children:h.node};Le.propTypes={list:h.array.isRequired,label:h.string.isRequired,onDelete:h.func};function Le({list:n,label:s,onDelete:t=()=>{}}){const{t:r,locale:o}=te();return e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),n.map(l=>{const b=kt(r,o,{status:l});return e.jsx(Ye,{size:"small",label:e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(de,{config:b,enableTooltip:!1,children:b.title})}),onDelete:u=>t(u,l)},l)})]})}Qe.propTypes={filterList:h.array.isRequired,onChange:h.func.isRequired,index:h.number.isRequired,column:h.object.isRequired,filterValues:h.array.isRequired,label:h.string.isRequired,renderLabel:h.func.isRequired};function Qe({filterList:n,onChange:s,index:t,column:r,filterValues:o,label:l,renderLabel:b}){return e.jsxs(V,{className:"filter-container",children:[e.jsx(pt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(u=>e.jsx(me,{control:e.jsx(Me,{checked:n[t].indexOf(u.value??u)>-1,onChange:p=>{const i=[...n];p.target.checked?i[t]=[...i[t],u.value??u]:i[t]=i[t].filter(N=>N!==(u.value??u)),s(i[t],t,r)},name:u.value??u}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(u)})},u.value??u))})]})}function We(n){return e.jsx(Qe,{...n,renderLabel:s=>e.jsx(de,{enableTooltip:!1,config:{status:s.status},children:s.label})})}xe.propTypes={status:h.number.isRequired,updatedAt:h.string.isRequired,reason:h.string,channel:h.string,onResend:h.func};function xe({status:n,updatedAt:s,reason:t="",channel:r="wallet",onResend:o}){const{t:l,locale:b}=te(),u=kt(l,b,{status:n,updatedAt:s,reason:t,channel:r});return e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(de,{config:u,showTitle:!0}),u.status!=="success"&&e.jsx(Fe,{className:"resend-btn",size:"small",startIcon:e.jsx(Ge,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}Ze.propTypes={value:h.array.isRequired,onChange:h.func};function Ze({value:n,onChange:s}){const{locale:t}=te(),r=Z().toDate(),[o,l]=v.useState(null),b=v.useCallback(i=>{l(o?null:i.currentTarget)},[o]),u=!!o,p=v.useCallback(i=>{if(!i.startDate||!i.endDate){M.error("Please select a date range");return}if(Z(i.startDate).isAfter(i.endDate)||!Z(i.startDate).isValid()||!Z(i.endDate).isValid()){M.error("Invalid date range");return}s([i.startDate,i.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(ee,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Fe,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[at(n[0],t)," - ",at(n[1],t)]})}),e.jsx(Ue,{open:u,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(jn,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:b,definedRanges:vn(r),onChange:p})})]})}et.propTypes={itemComponent:h.elementType.isRequired};function et({itemComponent:n,...s}){const{t}=te();return!s?.filterList?.filter(o=>o.length).length?null:e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:t("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(nn.TableFilterList,{...s,ItemComponent:n})})]})}function tt({label:n,onDelete:s,canDelete:t=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let l=!0;return t&&typeof t=="function"&&(l=t({label:n,...r})),e.jsx(Ye,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}tt.propTypes={label:h.string.isRequired,onDelete:h.func,canDelete:h.func};const Mn=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];Pt.propTypes={loading:h.bool,onCancel:h.func,onConfirm:h.func};function Pt({loading:n=!1,onCancel:s=()=>{},onConfirm:t=()=>{}}){const{t:r}=te(),[o,l]=v.useState(Mn),[b,u]=v.useState(!0),p=(N,I)=>{I.checked=N.target.checked;const S=o.map(j=>({...j,checked:j.value===I.value?I.checked:j.checked}));l(S)},i=N=>{N.stopPropagation(),t({channels:o.filter(I=>I.checked).map(I=>I.value),isResendFailedOnly:b})};return e.jsxs(y,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ee,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(y,{className:"choose-channel",children:e.jsxs(V,{component:"fieldset",variant:"standard",children:[e.jsx(pt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(N=>e.jsx(me,{control:e.jsx(Me,{checked:N.checked,onChange:I=>p(I,N),name:N.value}),label:N.label},N.value))})]})}),e.jsx(y,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(me,{control:e.jsx(Me,{checked:b,onChange:N=>u(N.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(y,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Fe,{onClick:N=>{N.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Fe,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(ft,{size:16}),r("common.confirm")]})]})]})}Ft.propTypes={notificationId:h.string.isRequired,handleResend:h.func,resending:h.bool};function Ft({notificationId:n,handleResend:s,resending:t=!1}){const{t:r,locale:o}=te(),l=ht(),b=v.useMemo(()=>xt(l,Lt()),[l]),{getReceivers:u,inService:p,teamDid:i,getUser:N,blocklet:I}=Xe(),[S,j]=v.useState(!1),[E,Y]=v.useState([]),z=ye({anchorEl:null,position:null}),F=ye({anchorEl:null,position:null}),[W,R]=v.useState(null),[q,K]=v.useState({total:0,pageSize:10,pageCount:0,page:1}),[f,w]=v.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),[C,a]=v.useState([]),T=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],O=async()=>{if(!S&&n)try{j(!0);const c=await u({notificationId:n,...f}),d=c.list.map(m=>({...m,receiverUser:{...m.receiverUser,avatar:It(m.receiverUser.avatar,i,p)}}));Y(d),K(c.paging),j(!1)}catch(c){M.error(c.message),j(!1)}};v.useEffect(()=>{O()},[f]);const D=c=>{c.stopPropagation();const d=c.currentTarget;F.anchorEl=d;const m=d.getBoundingClientRect();F.position={top:m.top+window.scrollY,left:m.left+window.scrollX}},re=c=>c.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(ce,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Ge,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:D,children:r("notification.resend")})}):null,ue={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:q.page-1,rowsPerPage:q.pageSize,count:q.total,searchText:f.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:C,onRowSelectionChange:(c,d)=>{a(d.map(m=>m.dataIndex))},customToolbarSelect:re},oe=({page:c,rowsPerPage:d,searchText:m,filterList:k})=>{const[,U=[],ne=[],G=[]]=k;f.pageSize!==d?w(H=>({...H,pageSize:d,page:1})):f.page!==c+1?w(H=>({...H,page:c+1})):f.searchText!==m?w(H=>({...H,searchText:m,page:1})):je(U,f.walletSendStatus)?je(ne,f.pushKitSendStatus)?je(G,f.emailSendStatus)||w(H=>({...H,emailSendStatus:G,page:1})):w(H=>({...H,pushKitSendStatus:ne,page:1})):w(H=>({...H,walletSendStatus:U,page:1}))},pe=v.useCallback(async(c,d)=>{if(!d)return!1;const m=await N(d);return m?c==="wallet"?zn(m):c==="email"?Fn(I,m):c==="pushKit"?_n(I,m):c==="webhook"?Bn(m):!0:!1},[N,I]),Re=v.useCallback(c=>Wn(r,c),[r]),fe=()=>{z.anchorEl=null,z.position=null,R(null)},he=()=>{F.anchorEl=null,F.position=null},g=async(c,d,m=!0,k="")=>{if(!(!d.length||!c.length))try{s(c,d,m,k),F.anchorEl||(await Ee(.5),fe())}catch(U){console.error("handleResend error",{error:U})}},x=async({channels:c,isResendFailedOnly:d})=>{const m=C.map(k=>E[k].receiver);await g(c,m,d),await Ee(.5),he(),a([])},A=async(c,d=[],m=!0)=>{try{await g(["webhook"],[c.receiver],m,d)}catch(k){M.error(k.response?k.response.statusText:k.message)}},L=async(c,d,m,k=[],U=!0)=>{if(c.stopPropagation(),qn(d,m)>=4){M.warning(r("notification.resendLimit"));return}if(!Ve.includes(m)){await A(d,k,U);return}if(c){const G=c.currentTarget,H=G.getBoundingClientRect();z.anchorEl=G,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}R({channel:m});try{const G=await pe(m,d.receiver);await Ee(1),R({channel:m,result:G}),(typeof G=="boolean"&&G||Zt(G)&&Object.values(G).every(H=>!!H))&&(await s([m],[d.receiver],U),F.anchorEl||(await Ee(.5),fe()))}catch(G){M.error(G.message)}},B=c=>{w(d=>({...d,dateRange:c,page:1}))},P=(c,d,m,k)=>{c.stopPropagation();const U=m.filter(ne=>ne!==d);w(ne=>({...ne,[k]:U,page:1}))},ie=se(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:c=>{const{receiverUser:d,receiver:m}=E[c];return d?e.jsxs(y,{"data-cy":`member-name-${d.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(vt,{src:`${d.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:m,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Se,{children:d.fullName})]},m):e.jsx(bn,{size:14,responsive:!1,compact:!0,copyable:!1,did:m})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:f.walletSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Wallet",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[1].options.filterList,"walletSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,k)=>e.jsx(We,{label:"Wallet",filterList:c,onChange:d,index:m,column:k,filterValues:T})},customBodyRenderLite:c=>{const{walletSendStatus:d,walletSendAt:m,walletSendFailedReason:k}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:k,channel:"wallet",onResend:U=>L(U,E[c],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{pushKitSendStatus:d,pushKitSendAt:m,pushKitSendFailedReason:k}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:k,channel:"pushkit",onResend:U=>L(U,E[c],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:f.pushKitSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Push Kit",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[2].options.filterList,"pushKitSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,k)=>e.jsx(We,{label:"Push Kit",filterList:c,onChange:d,index:m,column:k,filterValues:T})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{emailSendStatus:d,emailSendAt:m,emailSendFailedReason:k}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:k,channel:"email",onResend:U=>L(U,E[c],"email",[],!1)})},filter:!0,filterType:"custom",filterList:f.emailSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Email",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[3].options.filterList,"emailSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,k)=>e.jsx(We,{label:"Email",filterList:c,onChange:d,index:m,column:k,filterValues:T})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{webhook:d}=E[c];if(!d)return null;const m=Object.entries(d)[0];if(!m)return null;const[k,U]=m,ne=U[0];return e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(y,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(Se,{maxLength:30,children:k},k),e.jsx(xe,{status:ne.status,updatedAt:ne.sendAt,reason:ne.failedReason,channel:"webhook",onResend:G=>L(G,E[c],"webhook",[k],!1)})]},k)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:c=>{const{createdAt:d}=E[c];return e.jsx(Nt,{value:d,locale:o,shouldUpdate:!0})}}}],[E,o,f,r]),we=[e.jsx(Ze,{value:f.dateRange,onChange:B},"date-picker"),e.jsx(ce,{variant:"contained",size:"small",color:"primary",loading:S,startIcon:e.jsx(Kt,{}),onClick:()=>O(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(y,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(Hn,{children:e.jsxs(gt,{theme:b,children:[e.jsx(yt,{className:"receivers-table",locale:o,loading:S,columns:ie,data:E,onChange:oe,options:ue,customButtons:we,components:{TableFilterList:c=>e.jsx(et,{...c,itemComponent:d=>e.jsx(tt,{...d,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Ue,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:fe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs($n,{children:[e.jsxs(ee,{variant:"body1",component:"div",className:"check-title",children:[W?.channel," Checking"]}),e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Re(W?.channel).map(c=>{const{type:d,pass:m,fail:k}=c;return!W?.result||W?.result?.[d]?e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:W?.result?.[d]?ke.success.main:"inherit"},children:[W?.result?e.jsx(Mt,{}):e.jsx(ft,{size:12,sx:{color:ke.primary.main}}),e.jsx("span",{children:m})]},d):e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:ke.error.main},children:[e.jsx(Ut,{}),e.jsx("span",{children:k})]},d)})})]})}),F.anchorEl&&e.jsx(Ue,{open:!!F.anchorEl,anchorReference:"anchorPosition",anchorPosition:F.position,onClose:he,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Pt,{loading:t,onCancel:he,onConfirm:x})})]})})})}const Un=v.memo(Ft),Hn=ae.div`
2
2
  td.MuiTableCell-footer {
3
3
  border: none !important;
4
4
  }
@@ -1,4 +1,4 @@
1
- import{M as m,j as e,V as c,bc as B,S as C,ai as E,v as I,bd as v,U as z}from"./vendor-mui-core-Bz-X9hX7.js";import{r as o}from"./vendor-react-x2lQvn4m.js";import{n as A}from"./vendor-utils-CtD44yV-.js";import{m as p}from"./vendor-ux-BArADSzA.js";function L({...r}){const{size:d="medium",color:i="primary",menu:a=[],children:s=null,variant:u="contained",onClick:x=A,menuButtonProps:f={},...h}=r,[j,l]=o.useState(!1),n=o.useRef(null),g=Array.isArray(a)?a.map((t,b)=>o.isValidElement(t)?t:o.createElement(m,{...t,key:b})):a,M=()=>{l(t=>!t)},y=t=>{n.current&&n.current.contains(t.target)||l(!1)},k=t=>{t.target.closest(".MuiMenuItem-root")&&l(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(P,{variant:u,size:d,color:i,ref:n,...h,children:[typeof s=="function"?s():e.jsx(c,{onClick:x,color:i,children:s}),e.jsx(c,{onClick:M,color:i,...f,"aria-label":"more functions",children:e.jsx(B,{})})]}),e.jsx(w,{open:j,anchorEl:n.current,placement:"bottom-end",disablePortal:!1,children:e.jsx(C,{children:e.jsx(E,{onClickAway:y,children:e.jsx(I,{onClick:k,children:g})})})})]})}L.Item=m;const P=p(v)`
1
+ import{M as m,j as e,V as c,bc as B,S as C,ai as E,v as I,bd as v,U as z}from"./vendor-mui-core-p6jGoroc.js";import{r as o}from"./vendor-react-x2lQvn4m.js";import{n as A}from"./vendor-utils-CtD44yV-.js";import{m as p}from"./vendor-ux-TkkDR0Gn.js";function L({...r}){const{size:d="medium",color:i="primary",menu:a=[],children:s=null,variant:u="contained",onClick:x=A,menuButtonProps:f={},...h}=r,[j,l]=o.useState(!1),n=o.useRef(null),g=Array.isArray(a)?a.map((t,b)=>o.isValidElement(t)?t:o.createElement(m,{...t,key:b})):a,M=()=>{l(t=>!t)},y=t=>{n.current&&n.current.contains(t.target)||l(!1)},k=t=>{t.target.closest(".MuiMenuItem-root")&&l(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(P,{variant:u,size:d,color:i,ref:n,...h,children:[typeof s=="function"?s():e.jsx(c,{onClick:x,color:i,children:s}),e.jsx(c,{onClick:M,color:i,...f,"aria-label":"more functions",children:e.jsx(B,{})})]}),e.jsx(w,{open:j,anchorEl:n.current,placement:"bottom-end",disablePortal:!1,children:e.jsx(C,{children:e.jsx(E,{onClickAway:y,children:e.jsx(I,{onClick:k,children:g})})})})]})}L.Item=m;const P=p(v)`
2
2
  > .MuiButtonBase-root:last-of-type {
3
3
  min-width: 2em;
4
4
  padding-left: 0;
@@ -1 +1 @@
1
- import{r as h}from"./vendor-react-x2lQvn4m.js";import{j as a,E as x,F as j,$ as e,G as S,M,ak as b}from"./vendor-mui-core-Bz-X9hX7.js";import{ad as s}from"./index-BVAv5IrJ.js";import{T as v}from"./vendor-ux-BArADSzA.js";import{l as w}from"./arrow-down.svg-DR5noAvr.js";import{f as H}from"./vendor-hooks-CwHgeAuk.js";import{L as _,D as E}from"./vendor-mui-x-Cgnunrow.js";import{A}from"./AdapterDayjs-BeqEJUig.js";function Y({value:r=null,onChange:i,error:l=!1,helperText:u="",label:t="",timezone:n=""}){const f=n?s().tz(n):s(),p=H(()=>{let m=s();return r&&(m=n?s(r).tz(n):s(r)),m.format("YYYY-MM-DD[T]HH:mm")},[r,n]),D=m=>{const T=n?s(m).tz(n).format("YYYY-MM-DD HH:mm:00"):s(m).format("YYYY-MM-DD HH:mm:00");i(new Date(T))};return a.jsx(_,{dateAdapter:A,children:a.jsxs(x,{fullWidth:!0,error:l,children:[a.jsx(E,{label:t,minDateTime:f,value:s(p),onChange:D,slotProps:{textField:{error:l,helperText:l?u:""}},format:"YYYY-MM-DD HH:mm"}),u&&a.jsx(j,{children:u})]})})}Y.propTypes={value:e.oneOfType([e.string,e.instanceOf(Date)]),onChange:e.func.isRequired,error:e.bool,helperText:e.string,label:e.string,timezone:e.string};function C(r){return a.jsx(w,{...r,width:20,height:20})}const c={MINUTES_30:30*60*1e3,HOUR_1:60*60*1e3,HOURS_3:3*60*60*1e3,DAY_1:24*60*60*1e3,DAYS_7:7*24*60*60*1e3,DAYS_30:30*24*60*60*1e3};function y({placeholder:r="",value:i="",onChange:l,timezone:u=""}){const{t}=v(),[n,f]=h.useState(i||""),[p,D]=h.useState(null),m=h.useMemo(()=>[{value:new Date(Date.now()+c.MINUTES_30),label:`30 ${t("common.minutes")}`},{value:new Date(Date.now()+c.HOUR_1),label:`1 ${t("common.hour")}`},{value:new Date(Date.now()+c.HOURS_3),label:`3 ${t("common.hours")}`},{value:new Date(Date.now()+c.DAY_1),label:`1 ${t("common.day")}`},{value:new Date(Date.now()+c.DAYS_7),label:`7 ${t("common.days")}`},{value:new Date(Date.now()+c.DAYS_30),label:`30 ${t("common.days")}`},{value:"custom",label:t("common.custom")}],[t]),T=o=>{if(f(o),o==="custom"){const d=s().toDate();D(d),l(d)}else l(o)},g=o=>{D(o),l(o)};return h.useEffect(()=>{i&&(m.find(d=>s(d.value).isSame(i))||(f("custom"),D(i)))},[]),a.jsxs(a.Fragment,{children:[a.jsx(x,{fullWidth:!0,children:a.jsx(S,{select:!0,value:n,label:r||t("team.passport.passportExpireTime"),onChange:o=>T(o.target.value),variant:"outlined",slotProps:{select:{IconComponent:C}},children:m.map(o=>a.jsx(M,{value:o.value,children:o.label},o.value))})}),n==="custom"&&a.jsx(b,{children:a.jsx(Y,{value:p,onChange:g,label:t("team.passport.customExpireTime"),timezone:u,error:!p,helperText:p?void 0:t("team.passport.customExpireTime")})})]})}y.propTypes={value:e.oneOfType([e.string,e.instanceOf(Date)]),onChange:e.func.isRequired,timezone:e.string,placeholder:e.string};export{y as T};
1
+ import{r as h}from"./vendor-react-x2lQvn4m.js";import{j as a,E as x,F as j,$ as e,G as S,M,ak as b}from"./vendor-mui-core-p6jGoroc.js";import{ad as s}from"./index-S9T-sBWO.js";import{T as v}from"./vendor-ux-TkkDR0Gn.js";import{l as w}from"./arrow-down.svg-CaNNzVmj.js";import{a as H}from"./vendor-hooks-zCCbpt45.js";import{L as _,D as E}from"./vendor-mui-x-CkcHHKbJ.js";import{A}from"./AdapterDayjs-DiKE7R2w.js";function Y({value:r=null,onChange:i,error:l=!1,helperText:u="",label:t="",timezone:n=""}){const f=n?s().tz(n):s(),p=H(()=>{let m=s();return r&&(m=n?s(r).tz(n):s(r)),m.format("YYYY-MM-DD[T]HH:mm")},[r,n]),D=m=>{const T=n?s(m).tz(n).format("YYYY-MM-DD HH:mm:00"):s(m).format("YYYY-MM-DD HH:mm:00");i(new Date(T))};return a.jsx(_,{dateAdapter:A,children:a.jsxs(x,{fullWidth:!0,error:l,children:[a.jsx(E,{label:t,minDateTime:f,value:s(p),onChange:D,slotProps:{textField:{error:l,helperText:l?u:""}},format:"YYYY-MM-DD HH:mm"}),u&&a.jsx(j,{children:u})]})})}Y.propTypes={value:e.oneOfType([e.string,e.instanceOf(Date)]),onChange:e.func.isRequired,error:e.bool,helperText:e.string,label:e.string,timezone:e.string};function C(r){return a.jsx(w,{...r,width:20,height:20})}const c={MINUTES_30:30*60*1e3,HOUR_1:60*60*1e3,HOURS_3:3*60*60*1e3,DAY_1:24*60*60*1e3,DAYS_7:7*24*60*60*1e3,DAYS_30:30*24*60*60*1e3};function y({placeholder:r="",value:i="",onChange:l,timezone:u=""}){const{t}=v(),[n,f]=h.useState(i||""),[p,D]=h.useState(null),m=h.useMemo(()=>[{value:new Date(Date.now()+c.MINUTES_30),label:`30 ${t("common.minutes")}`},{value:new Date(Date.now()+c.HOUR_1),label:`1 ${t("common.hour")}`},{value:new Date(Date.now()+c.HOURS_3),label:`3 ${t("common.hours")}`},{value:new Date(Date.now()+c.DAY_1),label:`1 ${t("common.day")}`},{value:new Date(Date.now()+c.DAYS_7),label:`7 ${t("common.days")}`},{value:new Date(Date.now()+c.DAYS_30),label:`30 ${t("common.days")}`},{value:"custom",label:t("common.custom")}],[t]),T=o=>{if(f(o),o==="custom"){const d=s().toDate();D(d),l(d)}else l(o)},g=o=>{D(o),l(o)};return h.useEffect(()=>{i&&(m.find(d=>s(d.value).isSame(i))||(f("custom"),D(i)))},[]),a.jsxs(a.Fragment,{children:[a.jsx(x,{fullWidth:!0,children:a.jsx(S,{select:!0,value:n,label:r||t("team.passport.passportExpireTime"),onChange:o=>T(o.target.value),variant:"outlined",slotProps:{select:{IconComponent:C}},children:m.map(o=>a.jsx(M,{value:o.value,children:o.label},o.value))})}),n==="custom"&&a.jsx(b,{children:a.jsx(Y,{value:p,onChange:g,label:t("team.passport.customExpireTime"),timezone:u,error:!p,helperText:p?void 0:t("team.passport.customExpireTime")})})]})}y.propTypes={value:e.oneOfType([e.string,e.instanceOf(Date)]),onChange:e.func.isRequired,timezone:e.string,placeholder:e.string};export{y as T};
@@ -1 +1 @@
1
- import{j as a,T as y,ak as p,J as C,S as j}from"./vendor-mui-core-Bz-X9hX7.js";import{r as c}from"./vendor-react-x2lQvn4m.js";import{aG as f,aH as S,aI as b,aJ as T,aK as w,aL as D}from"./index-BVAv5IrJ.js";import{o as m,$ as N}from"./vendor-ux-BArADSzA.js";var i=(r=>(r.AvatarOnly="AvatarOnly",r.Detailed="Detailed",r))(i||{}),l=(r=>(r.NameOnly="NameOnly",r.Minimal="Minimal",r.Basic="Basic",r))(l||{});function P(r){const{user:e,infoType:o,avatarSize:s=48,shouldShowHoverCard:d=!1,renderCardContent:n,...t}=r;return o===l.NameOnly?a.jsx(f,{user:e,avatarSize:s,shouldShowHoverCard:!1,renderCardContent:n,tooltipTitle:e.fullName||e.email||e.did,...t}):a.jsx(f,{user:e,avatarSize:s,shouldShowHoverCard:d,renderCardContent:n,...t})}function O(r){const{user:e,avatarSize:o=48,onAvatarClick:s}=r;return a.jsxs(a.Fragment,{children:[S(e,o,r.avatarProps,s),a.jsx(y,{variant:"body1",children:e.fullName||e.email||e.did})]})}function R({...r}){const{user:e,avatarSize:o=40,renderCustomContent:s,infoType:d=l.Minimal,renderFields:n,popupRenderFields:t,...u}=r;return a.jsxs(p,{sx:{display:"flex",flexDirection:"column",width:"100%",flex:1,height:"100%"},children:[a.jsx(b,{user:e,avatarSize:o,...u}),d===l.Basic&&a.jsx(T,{user:e,renderFields:n}),a.jsx(p,{className:"user-card__footer",children:s&&a.jsx(p,{sx:{mt:1.5},children:s()})})]})}function h({...r}){const{infoType:e=l.Minimal}=r;switch(e){case l.NameOnly:return a.jsx(O,{...r});default:return a.jsx(R,{...r})}}function g({children:r,sx:e={}}){const o=C();return a.jsx(p,{sx:m({p:2,backgroundColor:o.palette.background.paper,border:"1px solid",borderColor:"divider",borderRadius:1,maxWidth:500,minWidth:320,display:"flex"},e||null),children:r})}function z({children:r,cardType:e=i.Detailed,variant:o="box",containerRef:s=void 0,sx:d={}}){const n={minWidth:320,p:2,borderRadius:1,...e===i.Detailed?{border:"1px solid",borderColor:"divider"}:{}};return o==="paper"?a.jsx(j,{ref:s,elevation:0,sx:n,children:r}):a.jsx(p,{ref:s,sx:m(n,{display:"flex",alignItems:e===i.AvatarOnly?"center":"flex-start",gap:2},d||null),children:r})}function B(r){const{cardType:e=i.Detailed,showHoverCard:o}=r,s=o!==void 0?o:e===i.AvatarOnly,d=c.useRef(null),[n,t]=c.useState(()=>r.user||null);if(c.useEffect(()=>{let x=!0;return r.user?t(r.user):r.did&&w(r.did)&&!r.user&&D(r.did).then(v=>{x&&t(v||{fullName:"Anonymous",did:r.did,avatar:""})}),()=>{x=!1}},[r.did,r.user]),!n)return a.jsx(N,{did:r.did,size:r.avatarSize,...r.avatarProps});const u=()=>a.jsx(g,{sx:r.popupSx,children:a.jsx(h,{...r,shouldShowHoverCard:!1,user:n,avatarProps:r.popupAvatarProps,shortenLabelProps:r.popupShortenLabelProps||r.shortenLabelProps,renderFields:r.popupRenderFields,renderName:r.popupRenderName,infoType:r.popupInfoType||r.infoType,didProps:r.popupDidProps||r.didProps,showDid:r.popupShowDid||r.showDid})});return e===i.AvatarOnly?a.jsx(P,{...r,shouldShowHoverCard:s,renderCardContent:u,user:n}):a.jsx(z,{containerRef:d,cardType:e,sx:r.sx,children:a.jsx(h,{...r,shouldShowHoverCard:s,renderCardContent:u,user:n})})}export{l as a,B as g,i as l};
1
+ import{j as a,T as y,ak as p,J as C,S as j}from"./vendor-mui-core-p6jGoroc.js";import{r as c}from"./vendor-react-x2lQvn4m.js";import{aG as f,aH as S,aI as b,aJ as T,aK as w,aL as D}from"./index-S9T-sBWO.js";import{o as m,$ as N}from"./vendor-ux-TkkDR0Gn.js";var i=(r=>(r.AvatarOnly="AvatarOnly",r.Detailed="Detailed",r))(i||{}),l=(r=>(r.NameOnly="NameOnly",r.Minimal="Minimal",r.Basic="Basic",r))(l||{});function P(r){const{user:e,infoType:o,avatarSize:s=48,shouldShowHoverCard:d=!1,renderCardContent:n,...t}=r;return o===l.NameOnly?a.jsx(f,{user:e,avatarSize:s,shouldShowHoverCard:!1,renderCardContent:n,tooltipTitle:e.fullName||e.email||e.did,...t}):a.jsx(f,{user:e,avatarSize:s,shouldShowHoverCard:d,renderCardContent:n,...t})}function O(r){const{user:e,avatarSize:o=48,onAvatarClick:s}=r;return a.jsxs(a.Fragment,{children:[S(e,o,r.avatarProps,s),a.jsx(y,{variant:"body1",children:e.fullName||e.email||e.did})]})}function R({...r}){const{user:e,avatarSize:o=40,renderCustomContent:s,infoType:d=l.Minimal,renderFields:n,popupRenderFields:t,...u}=r;return a.jsxs(p,{sx:{display:"flex",flexDirection:"column",width:"100%",flex:1,height:"100%"},children:[a.jsx(b,{user:e,avatarSize:o,...u}),d===l.Basic&&a.jsx(T,{user:e,renderFields:n}),a.jsx(p,{className:"user-card__footer",children:s&&a.jsx(p,{sx:{mt:1.5},children:s()})})]})}function h({...r}){const{infoType:e=l.Minimal}=r;switch(e){case l.NameOnly:return a.jsx(O,{...r});default:return a.jsx(R,{...r})}}function g({children:r,sx:e={}}){const o=C();return a.jsx(p,{sx:m({p:2,backgroundColor:o.palette.background.paper,border:"1px solid",borderColor:"divider",borderRadius:1,maxWidth:500,minWidth:320,display:"flex"},e||null),children:r})}function z({children:r,cardType:e=i.Detailed,variant:o="box",containerRef:s=void 0,sx:d={}}){const n={minWidth:320,p:2,borderRadius:1,...e===i.Detailed?{border:"1px solid",borderColor:"divider"}:{}};return o==="paper"?a.jsx(j,{ref:s,elevation:0,sx:n,children:r}):a.jsx(p,{ref:s,sx:m(n,{display:"flex",alignItems:e===i.AvatarOnly?"center":"flex-start",gap:2},d||null),children:r})}function B(r){const{cardType:e=i.Detailed,showHoverCard:o}=r,s=o!==void 0?o:e===i.AvatarOnly,d=c.useRef(null),[n,t]=c.useState(()=>r.user||null);if(c.useEffect(()=>{let x=!0;return r.user?t(r.user):r.did&&w(r.did)&&!r.user&&D(r.did).then(v=>{x&&t(v||{fullName:"Anonymous",did:r.did,avatar:""})}),()=>{x=!1}},[r.did,r.user]),!n)return a.jsx(N,{did:r.did,size:r.avatarSize,...r.avatarProps});const u=()=>a.jsx(g,{sx:r.popupSx,children:a.jsx(h,{...r,shouldShowHoverCard:!1,user:n,avatarProps:r.popupAvatarProps,shortenLabelProps:r.popupShortenLabelProps||r.shortenLabelProps,renderFields:r.popupRenderFields,renderName:r.popupRenderName,infoType:r.popupInfoType||r.infoType,didProps:r.popupDidProps||r.didProps,showDid:r.popupShowDid||r.showDid})});return e===i.AvatarOnly?a.jsx(P,{...r,shouldShowHoverCard:s,renderCardContent:u,user:n}):a.jsx(z,{containerRef:d,cardType:e,sx:r.sx,children:a.jsx(h,{...r,shouldShowHoverCard:s,renderCardContent:u,user:n})})}export{l as a,B as g,i as l};
@@ -1,4 +1,4 @@
1
- import{j as e,$ as u,p as O,T as j,at as Ne,J as _e,cI as V,ao as X,cJ as We,ak as S,b1 as K,a$ as Ke,s as xe,cK as be,cy as Ge,am as ge,cu as Fe,M as F,aO as Y,bR as Ye,aP as $,V as $e,bl as qe,aR as He,cL as Qe,cM as Je,cN as Ve,cO as Xe,bY as he}from"./vendor-mui-core-Bz-X9hX7.js";import{k as Ze,j as ke,f as ue}from"./vendor-hooks-CwHgeAuk.js";import{r as h,u as et}from"./vendor-react-x2lQvn4m.js";import{Y as z,_ as N,ad as D,M,aC as tt,aD as st,au as nt,c as I,$ as ot}from"./index-BVAv5IrJ.js";import{H as B,T as E,b as at,a0 as q,D as rt,J as it,n as le,j as ct}from"./vendor-ux-BArADSzA.js";import{u as lt}from"./use-mobile-BkNZycG6.js";import{a as H,d as je,a1 as dt,c as pt,D as Ce,C as me}from"./vendor-utils-CtD44yV-.js";import{o as we}from"./vendor-arcblock-DKbvje4v.js";import{b as ut,u as mt,D as ft,c as de,a as xt}from"./index-45FYp8zC.js";import"./index-CpryIQED.js";import"./index-BojVbZw0.js";import"./api-CpYSt0CS.js";import{u as Be,C as gt,D as ht,a as St}from"./connect-to-2xYBexsb.js";import{b as yt,c as bt,d as kt,i as jt,e as fe,f as Ct,h as wt,j as Bt}from"./spaces--oE74hBj.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-BiGUf0JP.js";import{E as Et}from"./index-Wo9AdN6Y.js";import{x as Tt}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-BK7rZ--W.js";import{S as It}from"./switch-control-Cd3QShYo.js";import{C as Rt,u as Pt}from"./config-space-D2PSYekl.js";import{L as ye}from"./list-header-Bcr2R_3c.js";import"./lottie-web-4koyQiv_.js";import"./index-CuOPtgTg.js";async function At({blockletDid:t,nodeApi:o,spaceGateways:a}){let s=!1;const i=await Promise.all(a.map(async n=>{let{name:r}=n;const l=await yt(n.endpoint);return!H(l)&&l!==r&&(r=l,s=!0),{...n,name:r}}));return s&&await Promise.all(i.filter(n=>n.did).map(n=>o.updateBlockletSpaceGateway({input:{did:t,where:{did:n.did},spaceGateway:{...n}}}))),i}function vt({refresh:t}={}){const{blocklet:o}=z(),a=o?.meta?.did,{api:s}=N();return Ze(async()=>{if(!a)return[];const{spaceGateways:i}=await s.getBlockletSpaceGateways({input:{did:a}});return await At({blockletDid:a,nodeApi:s,spaceGateways:i})??[]},{refreshDeps:[a,t],onError(i){i?.message?.includes("not logged")?console.warn(i):(console.error(i),B.error(Q(i)))}})}function De({deps:t,setLoading:o,backupDate:a}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=z(),[i,n]=h.useState([]),{api:r}=N(),[l,d]=h.useMemo(()=>a?[D(a).startOf("day").toISOString(),D(a).endOf("day").toISOString()]:[D().startOf("year").toISOString(),D().endOf("day").toISOString()],[a]),c=je(async()=>{try{if(o(!0),!s){n([]);return}const{backups:m}=await r.getBlockletBackups({input:{did:s.meta.did,startTime:l,endTime:d}});n(m??[])}catch(m){console.error(m),B.error(Q(m))}finally{o(!1)}},1e3);return ke(async()=>{c()},[s?.meta?.did].concat(t)),{backups:i}}function Ot({appDid:t}){const{backups:o}=De(),[a,s]=h.useState({message:"",progress:0,completed:!1}),i=N(),{ws:{useSubscription:n}}=i;return n(M.BlockletEvents.backupProgress,r=>{t===r?.appDid&&s(()=>({...r}))},[t]),h.useEffect(()=>{if(o?.length&&dt(o[0]?.status)){const[r]=o;s(()=>({message:r.message,progress:r.progress,completed:r.progress>=100}))}},[o]),a}function zt({deps:t=[],setLoading:o=()=>{}}={}){const{blocklet:a}=z(),[s,i]=h.useState([]),{api:n}=N(),r=h.useCallback(je(async()=>{if(!n||!a?.meta?.did){i([]);return}try{o(!0);const l=D(),d=l.subtract(1,"year"),{summary:c}=await n.getBlockletBackupSummary({input:{did:a.meta.did,startTime:d.toISOString(),endTime:l.toISOString()}});i(Array.isArray(c)?c:[])}catch(l){console.error("Failed to fetch backup summary:",l),B.error(Q(l)),i([])}finally{o(!1)}},1e3),[]);return ke(async()=>(await r(),()=>{r.cancel()}),[a?.meta?.did].concat(t)),{backupSummary:s}}const Ee=h.createContext({}),{Provider:Lt,Consumer:ys}=Ee;function Te({children:t}){const{t:o}=E(),{api:a}=N(),{blocklet:s}=z(),[i,n]=h.useState(null),[r,l]=h.useState(!1),{data:d,loading:c,mutate:m}=vt({refresh:r}),g=pt(d),f=Ot({appDid:s?.appDid}),p=h.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=h.useState(!1),[y,b]=h.useState(!1),{backups:Z}=De({deps:[y,i],setLoading:w,backupDate:i}),[ee,te]=h.useState(!1),{backupSummary:se}=zt({deps:[ee]}),[_,U]=h.useState(d?.find(x=>x.endpoint===p)),T=s?.settings?.autoBackup,P=()=>{l(x=>!x)},ne=()=>{te(x=>!x)},oe=()=>{b(x=>!x)},G=async x=>{await a.updateAutoBackup({input:{did:s.meta.did,autoBackup:x}})},J=async()=>{await a.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(x,v)=>{try{m(R=>{const A=[...R];return A.push({...x,loading:!0}),A}),await a.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:x}}),p!==v&&await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:v}]}}),U(x),P(),B.success(o("storage.spaces.connectedWithName",{name:x?.name??"DID Spaces"}))}catch(R){throw console.error(R),m(A=>[...A].filter(W=>W.did!==x.did)),R}},re=async x=>{x&&(x.endpoint===p&&(await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),T?.enabled&&await G({enabled:!1})),await a.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:x?.did}}),m(v=>{const R=[...v];return R.splice(R.indexOf(x),1),R}),U(x),P())},ie=async x=>{await Promise.all([a.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:x.did},spaceGateway:x}}),p!==x.endpoint&&a.configBlocklet({input:{did:[s.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:x.endpoint}]}})]),B.success(o("storage.spaces.connectedWithName",{name:x?.name??"DID Spaces"})),P()},C=x=>x?.endpoint===p;return e.jsx(Lt,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:P,spaceGatewaysLoading:c,spaceGatewaysFirstLoading:g,spaceGatewayIsSelected:C,updateAutoBackup:G,abortBlockletBackup:J,backupEndpoint:p,backupProgress:f,backups:Z,backupSummary:se,refreshBackupSummary:ne,refreshBackups:oe,setBackupDate:n,backupsLoading:k,autoBackup:T},children:t})}Te.propTypes={children:u.any.isRequired};function L(){return h.useContext(Ee)}function Ie({...t}){const{blocklet:o}=z(),{info:a}=N(),{t:s}=E(),i=Be({blocklet:o}),n=tt(a),{spaceGateways:r,addSpaceGateway:l}=L(),d={checkFn:Ce.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:n,extraParams:{appPid:o.appPid,appDid:i.appDid,appName:i.appName,appDescription:i.appDescription,appUrl:i.appUrl,referrer:i.referrer,scopes:i.scopes,nodeDid:a.did}},c=async({endpoint:g,name:f,did:p})=>{const k=await kt(g);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(r.some(b=>b.endpoint===g)){B.error(s("storage.spaces.gateway.add.duplicate",{name:f}));return}await l({name:f,did:p,url:k,endpoint:g},g)},m=async({spaceGateway:g})=>{try{await c(g)}catch(f){console.error(f),B.error(Q(f))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:m})}function Re({...t}){const{t:o}=h.useContext(at),{blocklet:a,loadingDiskInfo:s,actions:i}=z();if(h.useEffect(()=>{i?.refreshBlocklet({showError:!1,attachDiskInfo:!0})},[]),a.diskInfo){const n=(d,c,m)=>e.jsxs(j,{children:[d," ",e.jsx("strong",{children:c?nt(c):"empty"})]}),r=a.environments.reduce((d,c)=>(d[c.key]=c.value,d),{}),l=[{key:"appDir",name:o("blocklet.diskInfo.appDir"),value:n(r.BLOCKLET_APP_DIR,a.diskInfo.app)},{key:"dataDir",name:o("blocklet.diskInfo.dataDir"),value:n(r.BLOCKLET_DATA_DIR,a.diskInfo.data)},{key:"logDir",name:o("blocklet.diskInfo.logDir"),value:n(r.BLOCKLET_LOG_DIR,a.diskInfo.log)},{key:"cacheDir",name:o("blocklet.diskInfo.cacheDir"),value:n(r.BLOCKLET_CACHE_DIR,a.diskInfo.cache)}];return e.jsx(Ut,{component:"div",...t,children:l.map(d=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:d.name,children:d.value},d.key))})}return s?e.jsx(O,{}):e.jsx(j,{children:o("blocklet.diskInfo.empty")})}const Ut=Ne(j)``;function Pe(){const{t}=E(),{setBackupDate:o,backupSummary:a}=L(),s=mt({key:"lg"}),i=h.useRef(null),n=_e(),r=h.useCallback(c=>{o(c)},[o]),l=h.useMemo(()=>{const c=D().add(1,"day"),m=D().subtract(11,"month").startOf("month"),g=new Map(a.map(p=>[p.date,{date:p.date,successCount:p.successCount,errorCount:p.errorCount}])),f=[];for(let p=m.clone();D(p).isBefore(c);p=p.add(1,"day")){const k=p.format("YYYY-MM-DD");f.push(g.get(k)||{date:k,successCount:0,errorCount:0})}return f},[a]),d=h.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:y,errorCount:b}=l[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${y}</div>`,`<div>${t("common.failed")}: ${b}</div>`].join(`
1
+ import{j as e,$ as u,p as O,T as j,at as Ne,J as _e,cI as V,ao as X,cJ as We,ak as S,b1 as K,a$ as Ke,s as xe,cK as be,cy as Ge,am as ge,cu as Fe,M as F,aO as Y,bR as Ye,aP as $,V as $e,bl as qe,aR as He,cL as Qe,cM as Je,cN as Ve,cO as Xe,bY as he}from"./vendor-mui-core-p6jGoroc.js";import{k as Ze,j as ke,a as ue}from"./vendor-hooks-zCCbpt45.js";import{r as h,u as et}from"./vendor-react-x2lQvn4m.js";import{Y as z,_ as N,ad as D,M,aC as tt,aD as st,au as nt,c as I,$ as ot}from"./index-S9T-sBWO.js";import{H as B,T as E,b as at,a0 as q,D as rt,J as it,n as le,j as ct}from"./vendor-ux-TkkDR0Gn.js";import{u as lt}from"./use-mobile-B8-JPkft.js";import{a as H,d as je,a1 as dt,c as pt,D as Ce,C as me}from"./vendor-utils-CtD44yV-.js";import{o as we}from"./vendor-arcblock-BndcJjQO.js";import{b as ut,u as mt,D as ft,c as de,a as xt}from"./index-DjGGLSgp.js";import"./index-DHPu60AO.js";import"./index-BojVbZw0.js";import"./api-CpYSt0CS.js";import{u as Be,C as gt,D as ht,a as St}from"./connect-to-DK_UHSXd.js";import{b as yt,c as bt,d as kt,i as jt,e as fe,f as Ct,h as wt,j as Bt}from"./spaces-Jt4I6QVN.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-VGO-dEle.js";import{E as Et}from"./index-biihuQJV.js";import{x as Tt}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-CFJ4a0MT.js";import{S as It}from"./switch-control-C9XSb8cW.js";import{C as Rt,u as Pt}from"./config-space-p8dvh7nV.js";import{L as ye}from"./list-header-DZoSW08k.js";import"./lottie-web-4koyQiv_.js";import"./index-ClQB4tO4.js";async function At({blockletDid:t,nodeApi:o,spaceGateways:a}){let s=!1;const i=await Promise.all(a.map(async n=>{let{name:r}=n;const l=await yt(n.endpoint);return!H(l)&&l!==r&&(r=l,s=!0),{...n,name:r}}));return s&&await Promise.all(i.filter(n=>n.did).map(n=>o.updateBlockletSpaceGateway({input:{did:t,where:{did:n.did},spaceGateway:{...n}}}))),i}function vt({refresh:t}={}){const{blocklet:o}=z(),a=o?.meta?.did,{api:s}=N();return Ze(async()=>{if(!a)return[];const{spaceGateways:i}=await s.getBlockletSpaceGateways({input:{did:a}});return await At({blockletDid:a,nodeApi:s,spaceGateways:i})??[]},{refreshDeps:[a,t],onError(i){i?.message?.includes("not logged")?console.warn(i):(console.error(i),B.error(Q(i)))}})}function De({deps:t,setLoading:o,backupDate:a}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=z(),[i,n]=h.useState([]),{api:r}=N(),[l,d]=h.useMemo(()=>a?[D(a).startOf("day").toISOString(),D(a).endOf("day").toISOString()]:[D().startOf("year").toISOString(),D().endOf("day").toISOString()],[a]),c=je(async()=>{try{if(o(!0),!s){n([]);return}const{backups:m}=await r.getBlockletBackups({input:{did:s.meta.did,startTime:l,endTime:d}});n(m??[])}catch(m){console.error(m),B.error(Q(m))}finally{o(!1)}},1e3);return ke(async()=>{c()},[s?.meta?.did].concat(t)),{backups:i}}function Ot({appDid:t}){const{backups:o}=De(),[a,s]=h.useState({message:"",progress:0,completed:!1}),i=N(),{ws:{useSubscription:n}}=i;return n(M.BlockletEvents.backupProgress,r=>{t===r?.appDid&&s(()=>({...r}))},[t]),h.useEffect(()=>{if(o?.length&&dt(o[0]?.status)){const[r]=o;s(()=>({message:r.message,progress:r.progress,completed:r.progress>=100}))}},[o]),a}function zt({deps:t=[],setLoading:o=()=>{}}={}){const{blocklet:a}=z(),[s,i]=h.useState([]),{api:n}=N(),r=h.useCallback(je(async()=>{if(!n||!a?.meta?.did){i([]);return}try{o(!0);const l=D(),d=l.subtract(1,"year"),{summary:c}=await n.getBlockletBackupSummary({input:{did:a.meta.did,startTime:d.toISOString(),endTime:l.toISOString()}});i(Array.isArray(c)?c:[])}catch(l){console.error("Failed to fetch backup summary:",l),B.error(Q(l)),i([])}finally{o(!1)}},1e3),[]);return ke(async()=>(await r(),()=>{r.cancel()}),[a?.meta?.did].concat(t)),{backupSummary:s}}const Ee=h.createContext({}),{Provider:Lt,Consumer:ys}=Ee;function Te({children:t}){const{t:o}=E(),{api:a}=N(),{blocklet:s}=z(),[i,n]=h.useState(null),[r,l]=h.useState(!1),{data:d,loading:c,mutate:m}=vt({refresh:r}),g=pt(d),f=Ot({appDid:s?.appDid}),p=h.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=h.useState(!1),[y,b]=h.useState(!1),{backups:Z}=De({deps:[y,i],setLoading:w,backupDate:i}),[ee,te]=h.useState(!1),{backupSummary:se}=zt({deps:[ee]}),[_,U]=h.useState(d?.find(x=>x.endpoint===p)),T=s?.settings?.autoBackup,P=()=>{l(x=>!x)},ne=()=>{te(x=>!x)},oe=()=>{b(x=>!x)},G=async x=>{await a.updateAutoBackup({input:{did:s.meta.did,autoBackup:x}})},J=async()=>{await a.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(x,v)=>{try{m(R=>{const A=[...R];return A.push({...x,loading:!0}),A}),await a.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:x}}),p!==v&&await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:v}]}}),U(x),P(),B.success(o("storage.spaces.connectedWithName",{name:x?.name??"DID Spaces"}))}catch(R){throw console.error(R),m(A=>[...A].filter(W=>W.did!==x.did)),R}},re=async x=>{x&&(x.endpoint===p&&(await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),T?.enabled&&await G({enabled:!1})),await a.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:x?.did}}),m(v=>{const R=[...v];return R.splice(R.indexOf(x),1),R}),U(x),P())},ie=async x=>{await Promise.all([a.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:x.did},spaceGateway:x}}),p!==x.endpoint&&a.configBlocklet({input:{did:[s.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:x.endpoint}]}})]),B.success(o("storage.spaces.connectedWithName",{name:x?.name??"DID Spaces"})),P()},C=x=>x?.endpoint===p;return e.jsx(Lt,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:P,spaceGatewaysLoading:c,spaceGatewaysFirstLoading:g,spaceGatewayIsSelected:C,updateAutoBackup:G,abortBlockletBackup:J,backupEndpoint:p,backupProgress:f,backups:Z,backupSummary:se,refreshBackupSummary:ne,refreshBackups:oe,setBackupDate:n,backupsLoading:k,autoBackup:T},children:t})}Te.propTypes={children:u.any.isRequired};function L(){return h.useContext(Ee)}function Ie({...t}){const{blocklet:o}=z(),{info:a}=N(),{t:s}=E(),i=Be({blocklet:o}),n=tt(a),{spaceGateways:r,addSpaceGateway:l}=L(),d={checkFn:Ce.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:n,extraParams:{appPid:o.appPid,appDid:i.appDid,appName:i.appName,appDescription:i.appDescription,appUrl:i.appUrl,referrer:i.referrer,scopes:i.scopes,nodeDid:a.did}},c=async({endpoint:g,name:f,did:p})=>{const k=await kt(g);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(r.some(b=>b.endpoint===g)){B.error(s("storage.spaces.gateway.add.duplicate",{name:f}));return}await l({name:f,did:p,url:k,endpoint:g},g)},m=async({spaceGateway:g})=>{try{await c(g)}catch(f){console.error(f),B.error(Q(f))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:m})}function Re({...t}){const{t:o}=h.useContext(at),{blocklet:a,loadingDiskInfo:s,actions:i}=z();if(h.useEffect(()=>{i?.refreshBlocklet({showError:!1,attachDiskInfo:!0})},[]),a.diskInfo){const n=(d,c,m)=>e.jsxs(j,{children:[d," ",e.jsx("strong",{children:c?nt(c):"empty"})]}),r=a.environments.reduce((d,c)=>(d[c.key]=c.value,d),{}),l=[{key:"appDir",name:o("blocklet.diskInfo.appDir"),value:n(r.BLOCKLET_APP_DIR,a.diskInfo.app)},{key:"dataDir",name:o("blocklet.diskInfo.dataDir"),value:n(r.BLOCKLET_DATA_DIR,a.diskInfo.data)},{key:"logDir",name:o("blocklet.diskInfo.logDir"),value:n(r.BLOCKLET_LOG_DIR,a.diskInfo.log)},{key:"cacheDir",name:o("blocklet.diskInfo.cacheDir"),value:n(r.BLOCKLET_CACHE_DIR,a.diskInfo.cache)}];return e.jsx(Ut,{component:"div",...t,children:l.map(d=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:d.name,children:d.value},d.key))})}return s?e.jsx(O,{}):e.jsx(j,{children:o("blocklet.diskInfo.empty")})}const Ut=Ne(j)``;function Pe(){const{t}=E(),{setBackupDate:o,backupSummary:a}=L(),s=mt({key:"lg"}),i=h.useRef(null),n=_e(),r=h.useCallback(c=>{o(c)},[o]),l=h.useMemo(()=>{const c=D().add(1,"day"),m=D().subtract(11,"month").startOf("month"),g=new Map(a.map(p=>[p.date,{date:p.date,successCount:p.successCount,errorCount:p.errorCount}])),f=[];for(let p=m.clone();D(p).isBefore(c);p=p.add(1,"day")){const k=p.format("YYYY-MM-DD");f.push(g.get(k)||{date:k,successCount:0,errorCount:0})}return f},[a]),d=h.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:y,errorCount:b}=l[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${y}</div>`,`<div>${t("common.failed")}: ${b}</div>`].join(`
2
2
  `)},backgroundColor:n.palette.background.paper,borderColor:n.palette.divider,textStyle:{color:n.palette.text.primary,fontSize:14},extraCssText:`box-shadow: ${n.shadows[2]}; border-radius: 4px;`,padding:[8,10]},visualMap:{show:!1,min:-12,max:12,pieces:[{min:Number.MIN_SAFE_INTEGER,max:-9,color:V[600]},{min:-9,max:-6,color:V[500]},{min:-6,max:-3,color:V[400]},{min:-3,max:-1,color:V[300]},{min:0,max:0,color:n.palette.grey[200]},{min:1,max:3,color:X[300]},{min:3,max:6,color:X[400]},{min:6,max:9,color:X[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:X[600]}],orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:12,textStyle:{color:n.palette.text.secondary,fontSize:12}},calendar:{top:30,left:50,right:10,bottom:4,cellSize:[8,8],splitLine:{show:!1},itemStyle:{borderWidth:2,borderColor:n.palette.background.default,color:n.palette.background.default},dayLabel:{show:!0,firstDay:0,nameMap:["","Mon","","Wed","","Fri",""],position:"start",margin:4,fontSize:10,color:n.palette.text.primary,fontWeight:"400",width:20},monthLabel:{show:!0,nameMap:"cn",align:"left",color:n.palette.text.primary,fontWeight:"400",fontSize:12,position:"start",margin:4,width:30,padding:[0,2]},yearLabel:{show:!1},range:[D().subtract(11,"month").startOf("month").format("YYYY-MM-DD"),D().endOf("month").format("YYYY-MM-DD")],orient:"horizontal"},series:{type:"heatmap",coordinateSystem:"calendar",data:l.map(k=>[k.date,k.errorCount?-k.errorCount:k.successCount]),label:{show:!1},itemStyle:{borderWidth:2,borderColor:n.palette.background.default,borderRadius:4},emphasis:{itemStyle:{borderWidth:2,borderColor:We[200],color:"inherit"}}}}),[l,t,n]);return e.jsxs(e.Fragment,{children:[e.jsx(S,{ref:i,sx:{maxWidth:"1280px",border:"1px solid",borderColor:"divider",padding:"8px",overflowX:"auto"},children:e.jsx(S,{sx:{width:"1200px",height:"180px",position:"relative"},children:e.jsx(Et,{option:d,style:{height:"100%",width:"100%"},notMerge:!0,lazyUpdate:!1,opts:{renderer:"canvas"},onEvents:{click:c=>{c.componentType==="series"&&c.data&&r(c.data[0])}}})})}),e.jsx(S,{sx:{display:"flex",justifyContent:"flex-end",mt:1,mr:s?2:5,mb:2},children:e.jsxs(K,{direction:s?"column":"row",spacing:s?2:1,sx:{width:"100%",justifyContent:"flex-start",alignItems:s?"flex-start":"center"},children:[e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(S,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #8B5000 0%, #A36200 33%, #C17700 66%, #E29000 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.failed")})]}),e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(S,{sx:{width:32,height:12,borderRadius:.5,bgcolor:"grey.200",border:"1px solid",borderColor:"grey.200"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.without")})]}),e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(S,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #9be9a8 0%, #40c463 33%, #30a14e 66%, #216e39 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.succeeded")})]})]})})]})}const Mt=xe(({className:t,...o})=>e.jsx(ge,{...o,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Ae({status:t,message:o="",createdAt:a}){const{t:s}=E(),i=t===I.BACKUPS.STATUS.PROGRESS&&D().diff(a,"hours")>=I.BACKUPS.TIMEOUT_HOURS,n=i&&s("common.timeoutError"),r=t===I.BACKUPS.STATUS.PROGRESS&&!i,l=t===I.BACKUPS.STATUS.SUCCEEDED&&!i;return r?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(O,{sx:{marginRight:"4px"},size:"12px"}),s("common.progress")]}):l?e.jsx(q,{type:"success",children:s("common.succeeded")}):e.jsxs(S,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"error",children:s("common.failed")}),e.jsx(ge,{style:{display:"flex",alignItems:"center",flexShrink:0},title:o||n,children:e.jsx(be,{children:e.jsx(Fe,{style:{width:"24px",height:"24px"},color:"error"})})})]})}Ae.propTypes={status:u.string.isRequired,message:u.string,createdAt:u.string.isRequired};function ve({metadata:t={}}){const{t:o}=E();if(H(t))return e.jsx(q,{type:"success",children:o("common.succeeded")});const a=t.count||0,s=t.size||0,i=Tt(s,{iec:!0}),n=e.jsxs(S,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:[e.jsxs(j,{variant:"body2",children:[o("common.fileCount"),": ",a]}),e.jsxs(j,{variant:"body2",children:[o("common.fileSize"),": ",i]})]});return e.jsxs(S,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"success",children:o("common.succeeded")}),e.jsx(Mt,{title:n,style:{display:"flex",alignItems:"center",flexShrink:0},placement:"left",children:e.jsx(be,{children:e.jsx(Ge,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}ve.propTypes={metadata:u.object};function Oe(){const{t,locale:o}=E(),{spaceGateways:a,backups:s,backupsLoading:i}=L(),n=h.useMemo(()=>[{label:"DID Space",name:"target",options:{customBodyRenderLite:l=>{const{targetUrl:d,targetName:c,status:m,createdAt:g}=s[l],f=m===I.BACKUPS.STATUS.PROGRESS&&D().diff(g,"hours")>=I.BACKUPS.TIMEOUT_HOURS,p=m===I.BACKUPS.STATUS.SUCCEEDED&&!f,k=c||a.find(w=>d?.includes(fe(w?.endpoint)))?.name||"Unknown DID Space";return p?e.jsx(Ke,{href:d,target:"_blank",sx:{fontSize:"16px"},children:k}):e.jsx(j,{variant:"body1",sx:{fontSize:"16px"},children:k})}}},{label:t("common.strategy"),name:"strategy",options:{customBodyRender:l=>{const d=t(l===0?"common.auto":"common.manual");return e.jsx(q,{children:d})}}},{label:t("common.startTime"),name:"createdAt",options:{customBodyRender:l=>D(l).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.endTime"),name:"updatedAt",options:{customBodyRender:l=>H(l)?"":D(l).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:l=>{const d=s?.[l]??{},{status:c,message:m,createdAt:g,metadata:f}=d,p=c===I.BACKUPS.STATUS.PROGRESS&&D().diff(g,"hours")>=I.BACKUPS.TIMEOUT_HOURS,k=c===I.BACKUPS.STATUS.PROGRESS&&!p,w=c===I.BACKUPS.STATUS.SUCCEEDED&&!p;return k?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(O,{sx:{marginRight:"4px"},size:"12px"}),t("common.progress")]}):w?e.jsx(ve,{metadata:f}):e.jsx(Ae,{status:c,message:m,createdAt:g})}}}],[s,a,t]),r=h.useMemo(()=>!s?.length,[s]);return e.jsx(e.Fragment,{children:r?e.jsx(S,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px",color:"#9397A1",marginTop:"16px",marginBottom:"24px"},children:t("storage.spaces.record.emptyData")}):e.jsx(rt,{title:"",loading:i,data:s,columns:n,emptyNode:t("storage.spaces.record.emptyData",o),options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}})})}function Nt(){const{t}=E();return e.jsxs(S,{children:[e.jsxs(S,{sx:{display:"flex",gap:3,flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(S,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",minWidth:240},children:[e.jsx(ft,{style:{cursor:"pointer",width:"150px",height:"100%",maxHeight:160}}),e.jsx(j,{sx:{my:2,textAlign:"center",color:"text.secondary"},children:t("storage.spaces.connect.provider")}),e.jsx(Ie,{})]}),e.jsxs(S,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(S,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.spaces.backup.records")})}),e.jsx(Pe,{})]})]}),e.jsx(Oe,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2,mt:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function ze({spaceGateway:t,onConfirm:o=()=>{},onCancel:a=()=>{}}){const{t:s}=E(),[i,n]=h.useState(!1),[r,l]=h.useState(!1),d=(g,f)=>{g?.preventDefault(),g?.stopPropagation(),n(f)},c=async g=>{try{g?.stopPropagation(),l(!0),await o?.(t),n(!1)}catch(f){console.error(f),B.error(`${s("storage.space.gateway.delete.failed")}: ${Q(f)}`)}finally{n(!1),l(!1)}},m=g=>{d(g,!1),a?.(g)};return e.jsxs(e.Fragment,{children:[e.jsxs(F,{color:"red",onClick:g=>d(g,!0),children:[e.jsx(Y,{style:{minWidth:24,color:"red"},children:e.jsx(Ye,{fontSize:"small"})}),e.jsx($,{style:{color:"red"},children:s("common.disconnect")})]}),e.jsx(it,{title:s("storage.spaces.gateway.delete.title"),open:i,confirmButton:{text:s("common.confirm"),props:{size:"small",variant:"contained",color:"error",loading:r}},cancelButton:{text:s("common.cancel"),props:{size:"small",variant:"outlined",disabled:r}},onConfirm:c,onCancel:m,children:e.jsx(j,{sx:{wordWrap:"break-word"},children:s("storage.spaces.gateway.delete.descForBackup",{name:`${t?.name}`})})})]})}ze.propTypes={spaceGateway:u.shape({name:u.string.isRequired,url:u.string.isRequired,protected:u.bool}).isRequired,onConfirm:u.func,onCancel:u.func};function Le({spaceGateway:t,selected:o,onDelete:a=()=>{},onConnect:s=()=>{},enableSwitchToSpace:i=!0,backupInProgress:n=!1,...r}){const{abortBlockletBackup:l}=L(),[d,c]=h.useState(null),{t:m}=E(),[g,f]=h.useState(!1),p=(y,b)=>{y.stopPropagation(),y.preventDefault(),c(b&&y.currentTarget)},k=async y=>{try{f(!0),p(y,!1),await s(t)}catch(b){console.error(b),B.error(b.message)}finally{f(!1)}},w=async y=>{try{f(!0),p(y,!1),await l()}catch(b){console.error(b),B.error(b.message)}finally{f(!1)}};return e.jsxs(e.Fragment,{children:[g||t?.loading?e.jsx(O,{sx:{ml:1},size:"24px"}):e.jsx($e,{"aria-label":"more","aria-controls":"actions-menu","aria-haspopup":"true","data-cy":"trigger-blocklet-actions",variant:"outlined",size:"small",onClick:y=>p(y,!0),...r,children:e.jsx(qe,{})}),e.jsxs(He,{id:"simple-menu",anchorEl:d,keepMounted:!0,open:!!d,onClose:y=>p(y,!1),children:[e.jsxs(F,{onClick:y=>{p(y,!1),window.open(Se(t.endpoint?Ct(t.endpoint):t.url,{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Qe,{fontSize:"small"})}),e.jsx($,{children:m("common.open")})]}),e.jsxs(F,{onClick:y=>{p(y,!1),window.open(Se(wt(t.endpoint),{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Je,{fontSize:"small"})}),e.jsx($,{children:m("storage.spaces.strategy.viewBackupFiles")})]}),!o&&i&&e.jsxs(F,{onClick:k,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Ve,{fontSize:"small"})}),e.jsx($,{children:m("storage.spaces.connect.switchToSpace")})]}),n&&e.jsxs(F,{onClick:w,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Xe,{fontSize:"small"})}),e.jsx($,{children:m("storage.spaces.connect.abortBlockletBackup")})]}),!n&&e.jsx(ze,{spaceGateway:t,onConfirm:async()=>{c(null),await a?.(t)},onCancel:()=>c(null)})]})]})}Le.propTypes={spaceGateway:u.shape({name:u.string.isRequired,url:u.string.isRequired,protected:u.bool,endpoint:u.string.isRequired,loading:u.bool}).isRequired,selected:u.bool.isRequired,enableSwitchToSpace:u.bool,onDelete:u.func,onConnect:u.func,backupInProgress:u.bool};const _t=xe(({className:t,...o})=>e.jsx(ge,{...o,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Ue({spaceGateway:t,spaceStatus:o,selected:a,onConnected:s=()=>{},onDeleted:i=()=>{},onBackedUp:n=()=>{}}){const{t:r,locale:l}=E(),{blocklet:d}=z(),{api:c,info:{did:m}}=N(),{appDid:g,appName:f,appDescription:p,scopes:k,appUrl:w,referrer:y}=Be({blocklet:d}),{backupProgress:b,updateSpaceGateway:Z,deleteSpaceGateway:ee,refreshBackupSummary:te,refreshBackups:se}=L(),[_,U]=h.useState(!1),[T,P]=h.useState({open:!1,action:"one-click-authorization",checkTimeout:1e3*300,messages:{title:r("storage.spaces.authorize.title",{appName:f},l),scan:r("storage.spaces.authorize.scan",{appName:f},l),confirm:"",success:e.jsx(j,{gutterBottom:!0,children:r("storage.spaces.authorize.success")})},onClose:()=>{P(C=>({...C,open:!1}))}}),ne=a&&!_&&o===de.DISCONNECTED,oe=a&&!_&&!t.loading&&o===de.CONNECTED,G=a&&_&&o===de.CONNECTED&&b?.progress>=0,J=async()=>{try{if(await Bt(t?.endpoint)){await c.configBlocklet({input:{did:[d.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:t.endpoint}]}}),B.success(r("storage.spaces.connect.switchToSpaceSucceeded",{name:t.name?`(${t.name})`:""})),s?.(null,t);return}}catch(C){console.error(C),s?.(C,t);return}P(C=>({...C,open:!0,prefix:me(t.url,"space/api/did"),baseUrl:new URL(t.url).origin,checkFn:Ce.create({baseURL:me(t.url,"space")}).get,extraParams:{appDid:g,appName:f,appDescription:p,scopes:k,appUrl:w,referrer:y,nodeDid:m,spaceDid:t.did}}))},ae=async(C,x)=>{const v=x(C.endpoint),R=fe(v),A=C.space?x(C.space):{};if(t.did&&R!==t.did){P(Me=>({...Me,open:!1}));const W=r("storage.spaces.gateway.switch.failedForMismatchSpace",{name:A?.name?A.name:""});B.error(W),s?.(new Error(W),t);return}const ce={...t,name:A.name??"DID Space",did:A.did??fe(v),endpoint:v};await Z(ce),P(W=>({...W,open:!1})),s?.(null,ce)},re=async()=>{try{if(_)return;U(!0),await c.backupBlocklet({input:{appDid:d.appDid,to:"spaces"}})}catch(C){console.error(C),B.error(C.message),n?.(C,t)}finally{U(!0)}},ie=async()=>{try{await ee(t),B.success(r("storage.spaces.gateway.delete.succeeded",{name:t.name?`(${t.name})`:""})),i?.(null,t)}catch(C){console.error(C),i?.(C,t)}};return h.useEffect(()=>{b?.completed?(a&&(b?.progress===100?(B.success(r("storage.spaces.backupSuccessfully")),n?.(null,t)):b.message&&n?.(new Error(b?.message),t),b.progress=0,b.message=""),U(!1),setTimeout(()=>{te(),se()},1e3)):b.progress&&U(!0)},[b]),e.jsxs(e.Fragment,{children:[e.jsxs(S,{sx:{display:"flex",alignItems:"center",".action-btn":{borderRadius:1,marginLeft:1}},children:[oe&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:re,children:r("storage.spaces.strategy.backupNow")}),ne&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:J,children:r("storage.spaces.disconnected.reconnectNow")}),G&&e.jsx(_t,{title:b?.message&&e.jsx(S,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:e.jsx(j,{variant:"body2",children:b.message})}),children:e.jsxs(le,{className:"action-btn",variant:"outlined",size:"small",sx:{minWidth:70},children:[e.jsx(O,{variant:"determinate",value:b?.progress,size:14,sx:{mr:1}}),b?.progress,"%"]})}),e.jsx(ot,{forceConnected:!1,saveConnect:!1,prefix:T.prefix,open:T.open,popup:!0,action:T.action,baseUrl:T.baseUrl,checkFn:T.checkFn,onSuccess:ae,onClose:T.onClose,checkTimeout:T.checkTimeout,extraParams:T.extraParams,messages:T.messages,locale:l},"get-endpoint")]}),e.jsx(Le,{sx:{minWidth:32,padding:"2px 4px",ml:1},spaceGateway:t,selected:a,onDelete:ie,onConnect:J,enableSwitchToSpace:b?.completed||H(b?.message),backupInProgress:G})]})}Ue.propTypes={spaceGateway:u.shape({did:u.string.isRequired,name:u.string.isRequired,url:u.string.isRequired,endpoint:u.string.isRequired,protected:u.bool,loading:u.bool}).isRequired,spaceStatus:u.string.isRequired,selected:u.bool.isRequired,onConnected:u.func,onDeleted:u.func,onBackedUp:u.func};function Wt({...t}){const{t:o}=E();return e.jsxs(S,{...t,children:[e.jsx(S,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:o("storage.spaces.backup.records")})}),e.jsx(Pe,{}),e.jsx(Oe,{})]})}function Kt({...t}){const{t:o}=E(),{autoBackup:a,updateAutoBackup:s}=L(),i=async()=>{try{const n=!a?.enabled;await s({enabled:n}),B.success(o(n?"storage.spaces.autoBackup.enabled":"storage.spaces.autoBackup.disabled"))}catch(n){B.error(n.message)}};return e.jsx(It,{checked:!!a?.enabled,onChange:i,name:"enableWelcomePage",labelProps:{label:e.jsx(j,{sx:{marginRight:"8px"},children:e.jsx("span",{children:o("storage.spaces.autoBackup.title")})})},style:{...t.style}})}function Gt(){const{t}=E(),{spaceGateways:o,spaceGatewaysLoading:a,spaceGatewayIsSelected:s}=L(),i=a&&!o?.length,n=({spaceGateway:r,spaceStatus:l,selected:d,refresh:c})=>e.jsx(Ue,{spaceGateway:r,spaceStatus:l,selected:d,onConnected:()=>c(),onBackedUp:m=>m&&c()});return e.jsxs(S,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(S,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},gap:{xs:1,md:2},justifyContent:{xs:"center",md:"flex-start"},alignItems:{xs:"flex-start",md:"center"}},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",flexGrow:1},children:t("storage.spaces.connected.title")}),e.jsx(Kt,{}),e.jsx(Ie,{})]}),e.jsx(S,{sx:{mt:2},children:i?e.jsx(S,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(O,{})}):e.jsx(he,{container:!0,spacing:2,children:e.jsx(e.Fragment,{children:o.map(r=>e.jsx(he,{size:{xs:12,md:6},children:e.jsx(xt,{endpoint:r.endpoint,selected:s(r),action:n},r.endpoint)},r.endpoint))})})}),e.jsx(Wt,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function Ft(){const{spaceGatewaysFirstLoading:t,spaceGateways:o}=L();return t?e.jsx(we,{relative:"parent",children:e.jsx(O,{})}):H(o)?e.jsx(Nt,{}):e.jsx(Gt,{})}function Yt(){return e.jsx(Te,{children:e.jsx(Ft,{})})}function $t(){const{spaceGateway:t,settingStorageEndpoint:o,updateSpaceGateway:a,hasStorageEndpoint:s,loading:i,storageEndpoint:n}=Pt(),r=ue(()=>({display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"16px"}));return i?e.jsx(we,{relative:"parent",children:e.jsx(O,{})}):e.jsxs(S,{sx:{maxWidth:"md",position:"relative"},children:[s?e.jsx(gt,{spaceGateway:t,settingStorageEndpoint:o}):e.jsx(ht,{}),e.jsx(S,{sx:r,children:e.jsx(St,{onConnect:a,storageEndpoint:n})})]})}function qt(){const{t}=E();return e.jsxs(Rt,{children:[e.jsxs(K,{spacing:1,sx:{marginBottom:2},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.appLevel.title")}),e.jsx(j,{sx:{color:"text.secondary"},children:t("storage.appLevel.description")})]}),e.jsx($t,{})]})}function Ht({navOrientation:t="vertical",...o}){const{t:a,locale:s}=E(),{blocklet:i}=z(),n=lt({key:"md"}),[r,l]=et(),d=r.get("tab")||"backup",c=n?"horizontal":t,m=ue(()=>{const w=[{label:a("common.backup"),value:"backup"}],y=i?.capabilities?.didSpace;return(y===M.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED||y===M.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP)&&w.push({label:a("common.storage"),value:"storage"}),w},[s,c]),f=ue(()=>({backup:e.jsx(Yt,{}),storage:e.jsx(qt,{})}))[d],p=w=>{l(y=>(w==="backup"?y.delete("tab"):y.set("tab",w),y))};if(m.length<=1)return e.jsx(pe,{children:f});const k=e.jsx(ct,{tabs:m,current:d,orientation:c,onChange:p,sx:[{borderRight:1,height:"100%",borderColor:"divider"},c==="horizontal"&&{borderRight:0}]});if(c==="vertical")return e.jsx(S,{...o,children:e.jsxs(K,{direction:{md:"column",lg:"row"},sx:{gap:2},children:[e.jsx(S,{sx:{flexShrink:0},children:e.jsx(ye,{left:k})}),e.jsx(S,{sx:{flexGrow:1,minWidth:0},children:e.jsx(pe,{sx:{mt:1},children:f})})]})});if(c==="horizontal")return e.jsxs(S,{...o,children:[e.jsx(ye,{left:k}),e.jsx(pe,{sx:{mt:2},children:f})]})}Ht.propTypes={navOrientation:u.oneOf(["vertical","horizontal"])};const pe=xe(S)`
3
3
  position: relative;
4
4
  min-height: 66vh;