@abtnode/blocklet-services 1.16.44-beta-20250526-130644-5e05dc90 → 1.16.44-beta-20250528-003415-7a5e5d90

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 (161) hide show
  1. package/api/services/auth/index.js +4 -0
  2. package/dist/assets/{AdapterDayjs-Bs_Q9JXL.js → AdapterDayjs-gCvKcGfu.js} +1 -1
  3. package/dist/assets/{ArrowDropDown-DUn14Acv.js → ArrowDropDown-D32FY-Mt.js} +1 -1
  4. package/dist/assets/{CheckCircle-DsdIIzds.js → CheckCircle-BBSSDlcc.js} +1 -1
  5. package/dist/assets/{ChevronLeft-BXDIS6AE.js → ChevronLeft-CF24ouxR.js} +1 -1
  6. package/dist/assets/{ChevronRight-BfSAowju.js → ChevronRight-DA9t_C-l.js} +1 -1
  7. package/dist/assets/{DeleteOutline-lCPjjhKz.js → DeleteOutline-CzIOFoFP.js} +1 -1
  8. package/dist/assets/{Done-BoNuG9Iy.js → Done-MQdb8YLa.js} +1 -1
  9. package/dist/assets/{Download-4NCgy4QK.js → Download-IxxF4Ujs.js} +1 -1
  10. package/dist/assets/{Edit-BqpcPg9o.js → Edit-DSht16TX.js} +1 -1
  11. package/dist/assets/{Error-B7SzGNr8.js → Error-CkoCqY66.js} +1 -1
  12. package/dist/assets/{ExpandLess-EFI-Ij5Y.js → ExpandLess-CudE_1oQ.js} +1 -1
  13. package/dist/assets/{Google-DYpd3dQM.js → Google-AZBuQJFI.js} +1 -1
  14. package/dist/assets/{Home-Ccm-s4KT.js → Home-BaA3V3I7.js} +1 -1
  15. package/dist/assets/{InfoOutlined-Duq1UDPu.js → InfoOutlined-Cd28U1Oc.js} +1 -1
  16. package/dist/assets/{Launch-ipC6Ic2p.js → Launch-Ddo_WSQI.js} +1 -1
  17. package/dist/assets/{LaunchOutlined-C-M166rt.js → LaunchOutlined-CO4dugwH.js} +1 -1
  18. package/dist/assets/{MoreHoriz-jwSUI8G2.js → MoreHoriz-D-L8sA4c.js} +1 -1
  19. package/dist/assets/{PlayArrow-Cv1uXXJt.js → PlayArrow-CLKgdv6H.js} +1 -1
  20. package/dist/assets/{TuneOutlined-BvxrpP1M.js → TuneOutlined-BWqIZK2m.js} +1 -1
  21. package/dist/assets/{ViewList-PrXAmQts.js → ViewList-DWudZTBg.js} +1 -1
  22. package/dist/assets/access-control-DlT-JQML.js +14 -0
  23. package/dist/assets/{actions-BA8hCarh.js → actions-azdiYocL.js} +1 -1
  24. package/dist/assets/{add-component-core-RTpy3oS3.js → add-component-core-Cm8Y0zkt.js} +13 -13
  25. package/dist/assets/{add-resource-DKnJ3N_A.js → add-resource-CVCoahx_.js} +1 -1
  26. package/dist/assets/{addon-DmglQWiB.js → addon-3ZMGwARO.js} +1 -1
  27. package/dist/assets/{advanced-CzssFl-I.js → advanced-Nvg1CqJg.js} +1 -1
  28. package/dist/assets/{appearance-DIaCQMdO.js → appearance-CAsFMLaC.js} +1 -1
  29. package/dist/assets/{audit-logs-BwUEGKxZ.js → audit-logs-BPjUleS-.js} +3 -3
  30. package/dist/assets/{authorize-DqVeyhPc.js → authorize-CdTK5Air.js} +1 -1
  31. package/dist/assets/{base32-D35YSxth.js → base32-CLrnUJal.js} +1 -1
  32. package/dist/assets/{branding-D9cgoVZN.js → branding-B8r8EJ2R.js} +2 -2
  33. package/dist/assets/{branding-yRBlkhNg.js → branding-Cr4GBUXi.js} +1 -1
  34. package/dist/assets/{bundle-avatar-BP8xFngr.js → bundle-avatar-Br48PGS5.js} +1 -1
  35. package/dist/assets/{button-Da_a32NC.js → button-8G90WP8a.js} +1 -1
  36. package/dist/assets/click-to-copy-ByEMWZD_.js +1 -0
  37. package/dist/assets/{collapse-BF9pIOsL.js → collapse-Cliwxlbv.js} +1 -1
  38. package/dist/assets/{complete-BFgID4Zc.js → complete-CzlLydJT.js} +2 -2
  39. package/dist/assets/{component-ESUBkOno.js → component-5_wmVxpp.js} +1 -1
  40. package/dist/assets/{config-rMbgmGkF.js → config-BnObxTpi.js} +1 -1
  41. package/dist/assets/{config-Bt_JcEZR.js → config-emhMgKqq.js} +1 -1
  42. package/dist/assets/{config-navigation-Dyu8rgOf.js → config-navigation-DbyhYIMw.js} +3 -3
  43. package/dist/assets/config-space-TsP5osn9.js +1 -0
  44. package/dist/assets/{confirm-CiiHIA-a.js → confirm-DI8TUyRK.js} +1 -1
  45. package/dist/assets/connect-B_BnGQjp.js +1 -0
  46. package/dist/assets/connect-D55qWQWC.js +5 -0
  47. package/dist/assets/connect-to-DzPwhREN.js +1 -0
  48. package/dist/assets/{dashboard-vkFEu-wZ.js → dashboard-AdC8-kkA.js} +3 -3
  49. package/dist/assets/{delete-confirm-BPtFZ4JP.js → delete-confirm-Bn1HZjaL.js} +1 -1
  50. package/dist/assets/{did-address-BtAnHi7m.js → did-address-BlAXR08O.js} +1 -1
  51. package/dist/assets/domain-Cod_zL8_.js +9 -0
  52. package/dist/assets/{domain-action-card-CEIB4y6O.js → domain-action-card-C4FpSn67.js} +2 -2
  53. package/dist/assets/domains-BhqtMbC1.js +1 -0
  54. package/dist/assets/dot-itVN8XTt.js +7 -0
  55. package/dist/assets/{email-D6f0kuZJ.js → email-CqVIYJc4.js} +2 -2
  56. package/dist/assets/exchange-passport-C-hTCqg0.js +1 -0
  57. package/dist/assets/{fuel-BzVicj7n.js → fuel-M5L6Wmxz.js} +1 -1
  58. package/dist/assets/{gen-access-key-DiLTrx9k.js → gen-access-key-D6jr4e_G.js} +1 -1
  59. package/dist/assets/get-safe-url-CRv5HbAK.js +1 -0
  60. package/dist/assets/get-safe-url-DrR-6D-i.js +1 -0
  61. package/dist/assets/{home-AVCu7DmN.js → home-C7e6Ftxj.js} +1 -1
  62. package/dist/assets/{iframe-CJ1Wo1WH.js → iframe-DSG-Hd99.js} +1 -1
  63. package/dist/assets/{index-99E5Ux4J.js → index-AetYfL_f.js} +1 -1
  64. package/dist/assets/{index-Biu0_3VS.js → index-B5_fBwtl.js} +9 -9
  65. package/dist/assets/{index-IuBCAZn2.js → index-BFWnCQrF.js} +1 -1
  66. package/dist/assets/{index-BhMu-yLO.js → index-BJHSgjnI.js} +14 -14
  67. package/dist/assets/{index-CCsDojsm.js → index-BJbAX71g.js} +7 -7
  68. package/dist/assets/{index-CG5aY0sO.js → index-BLbU4gf9.js} +2 -2
  69. package/dist/assets/index-BM1ZGOPs.js +55 -0
  70. package/dist/assets/{index-DeD4o13y.js → index-BUrgmCmL.js} +1 -1
  71. package/dist/assets/{index-nhpGyAFA.js → index-Bj2-CpPI.js} +2 -2
  72. package/dist/assets/{index-XdA5ax9j.js → index-C2F-GVrD.js} +4 -4
  73. package/dist/assets/{index-CVeug3aj.js → index-C4vmLohg.js} +1 -1
  74. package/dist/assets/index-CEeLwMYO.js +113 -0
  75. package/dist/assets/{index-CkuD5Vfn.js → index-CtLialsm.js} +6 -6
  76. package/dist/assets/{index-Cj_-M8SX.js → index-DSoHmrHd.js} +1 -1
  77. package/dist/assets/index-DthGrDK3.js +1 -0
  78. package/dist/assets/{index-DJzuhKQh.js → index-YbYWmpAT.js} +4 -4
  79. package/dist/assets/{index-8lA5-nM7.js → index-bIHubQ8z.js} +3 -3
  80. package/dist/assets/{index-hO3Mo-qi.js → index-iQsPOXlb.js} +1 -1
  81. package/dist/assets/{index-BDhncHq5.js → index-rn2nf2kX.js} +2 -2
  82. package/dist/assets/{index-Jryn5flm.js → index-yvg4DpNi.js} +10 -10
  83. package/dist/assets/{invitation-CbZcjplG.js → invitation-StUiuLYU.js} +5 -5
  84. package/dist/assets/invite-E96eT2DF.js +1 -0
  85. package/dist/assets/{issue-passport-3aP4u6AF.js → issue-passport-DrGPTNsG.js} +1 -1
  86. package/dist/assets/item-Dgu9vLko.js +2 -0
  87. package/dist/assets/{landing-page-B3KyXZXw.js → landing-page-BOy_W1aP.js} +1 -1
  88. package/dist/assets/{layout-BzSCNNrb.js → layout-CYJJYqb_.js} +1 -1
  89. package/dist/assets/list-C8X2Voou.js +2 -0
  90. package/dist/assets/{list-D29W3nMj.js → list-uPz9xAWJ.js} +5 -5
  91. package/dist/assets/localization-CI5Q0B2F.js +1 -0
  92. package/dist/assets/{log-D5wtGlYv.js → log-CzRRb9lq.js} +1 -1
  93. package/dist/assets/{logger-DTzDRWqY.js → logger-B4ZKcD6x.js} +1 -1
  94. package/dist/assets/login-D3GnBJn4.js +1 -0
  95. package/dist/assets/{login-oauth-callback-DjqRVYt8.js → login-oauth-callback-CVS9TwNM.js} +1 -1
  96. package/dist/assets/{logo-uploader-B-RJuXxH.js → logo-uploader-CbM-N8qP.js} +3 -3
  97. package/dist/assets/{lost-passport-n3UXYXA8.js → lost-passport-5P2EFbv0.js} +2 -2
  98. package/dist/assets/{open-window-Dyr68wBS.js → open-window-c9TGr49M.js} +1 -1
  99. package/dist/assets/{overview-C2L5ReTa.js → overview-BZRXhA-K.js} +2 -2
  100. package/dist/assets/{page-header-BS-digIw.js → page-header-D_m0ANZl.js} +1 -1
  101. package/dist/assets/{passport-item-B9iOvD4Y.js → passport-item-DE-9Q-Cx.js} +1 -1
  102. package/dist/assets/{permission-CbTKdC7W.js → permission-fpFyADH8.js} +1 -1
  103. package/dist/assets/{preferences-DETzTJeF.js → preferences-0RYr2e_y.js} +1 -1
  104. package/dist/assets/{profile-embed-7uAZGWnU.js → profile-embed-BwbGy3El.js} +1 -1
  105. package/dist/assets/{publish-resource-Bk1sOsMC.js → publish-resource-CWz86TY0.js} +1 -1
  106. package/dist/assets/{react-beautiful-dnd.esm-WW1RMrIr.js → react-beautiful-dnd.esm-G9cRB9Uf.js} +1 -1
  107. package/dist/assets/{runtime-CA329eRU.js → runtime-63aIXcah.js} +1 -1
  108. package/dist/assets/sdk-D4BoQHdn.js +1 -0
  109. package/dist/assets/{security-BYPCwU9I.js → security-YPRPQuQL.js} +4 -4
  110. package/dist/assets/{session-ugMCR4Iu.js → session-Djj2U6sa.js} +1 -1
  111. package/dist/assets/setup-C9DGbmM7.js +30 -0
  112. package/dist/assets/{spaces-CTEbtAyX.js → spaces-fGcGlx-U.js} +1 -1
  113. package/dist/assets/start-Cz_j6UYt.js +187 -0
  114. package/dist/assets/{starting-progress-Dvw39Hou.js → starting-progress-DHv9oucO.js} +1 -1
  115. package/dist/assets/{status-CH0vjcu4.js → status-B5ff49WY.js} +1 -1
  116. package/dist/assets/{step-actions-QyMIKyQA.js → step-actions-CPiUgWLW.js} +1 -1
  117. package/dist/assets/{studio-B1PGcNac.js → studio-DnKLD9XD.js} +1 -1
  118. package/dist/assets/{switch-control-D5eJVUaV.js → switch-control-DWjnOuBy.js} +1 -1
  119. package/dist/assets/{table-tips-biAHyN1z.js → table-tips-DEGQUNJa.js} +1 -1
  120. package/dist/assets/{traffic-DVUW14yF.js → traffic-C262RTgV.js} +1 -1
  121. package/dist/assets/{transfer-CsdMd63R.js → transfer-CXfjw5Xg.js} +1 -1
  122. package/dist/assets/unsubscribe-CdFXzPwR.js +1 -0
  123. package/dist/assets/{use-blocklet-logo-a8QJI4r-.js → use-blocklet-logo-C_pDvfYN.js} +2 -2
  124. package/dist/assets/use-server-logo-CxuMvwKh.js +1 -1
  125. package/dist/assets/useAsync-510ntT1B.js +1 -0
  126. package/dist/assets/{useLocalStorage-BDA4jbwL.js → useLocalStorage-DO6t2PeQ.js} +1 -1
  127. package/dist/assets/{user-center-BQcfE646.js → user-center-DR1kV4iN.js} +3 -3
  128. package/dist/assets/{util-BwAoiA7E.js → util-Cs-QbPU0.js} +1 -1
  129. package/dist/assets/{util-D-q3oYk9.js → util-VM27PwRk.js} +1 -1
  130. package/dist/assets/{vendor-arcblock-5qqHEVGo.js → vendor-arcblock-DuPySS9V.js} +85 -85
  131. package/dist/assets/{vendor-ux-did-connect-DROQhYpS.js → vendor-ux-did-connect-DIlRfE_S.js} +113 -113
  132. package/dist/assets/{wrap-locale-CvN5krOj.js → wrap-locale-BWx2hEb7.js} +1 -1
  133. package/dist/index.html +3 -3
  134. package/dist/service-worker.js +1 -1
  135. package/package.json +29 -29
  136. package/dist/assets/access-control-Dvlg7x0h.js +0 -14
  137. package/dist/assets/click-to-copy-B26zKr7i.js +0 -1
  138. package/dist/assets/config-space-D2Cjeyk0.js +0 -1
  139. package/dist/assets/connect-Druwkt_h.js +0 -1
  140. package/dist/assets/connect-QKA3Mcyx.js +0 -5
  141. package/dist/assets/connect-to-BLuNgRR8.js +0 -1
  142. package/dist/assets/domain-CSsoH0JI.js +0 -9
  143. package/dist/assets/domains-DySxSy7r.js +0 -1
  144. package/dist/assets/dot-DX56IFTM.js +0 -7
  145. package/dist/assets/exchange-passport-CyZiYD_w.js +0 -1
  146. package/dist/assets/get-safe-url-CiQ8_q49.js +0 -1
  147. package/dist/assets/get-safe-url-DSt3eVbO.js +0 -1
  148. package/dist/assets/index-B7Ih-tce.js +0 -55
  149. package/dist/assets/index-CpRFDVw4.js +0 -113
  150. package/dist/assets/index-D_aS7-BV.js +0 -1
  151. package/dist/assets/invite-CG68Mxoz.js +0 -1
  152. package/dist/assets/item-DLwktWNI.js +0 -2
  153. package/dist/assets/list-y33VQBpr.js +0 -2
  154. package/dist/assets/localization-Y6Zfd1Kb.js +0 -1
  155. package/dist/assets/login-Bq9K3qHu.js +0 -1
  156. package/dist/assets/sdk-Bxy9kDUo.js +0 -1
  157. package/dist/assets/setup-BuHGJK0U.js +0 -30
  158. package/dist/assets/start-Df7Wiv2W.js +0 -187
  159. package/dist/assets/unsubscribe-1jeXeeTi.js +0 -1
  160. package/dist/assets/useAsync-Dv214fz8.js +0 -1
  161. package/dist/assets/useAsync-KYUBhVsb.js +0 -1
@@ -1,55 +0,0 @@
1
- import{a as se,Z as U,c0 as Me,c1 as $e,I as K,b_ as Ve,b$ as Ne,ad as He,ac as Je,c2 as Ke,b4 as De,j as he,r as Pe,b2 as G,c3 as xe,am as ge,B as z,bN as Ge,a6 as Ze,c4 as Xe,a7 as Ye,a3 as Qe,a0 as et,as as Ce}from"./vendor-ux-did-connect-DROQhYpS.js";import{u as p,a as ae,f as te,c as tt}from"./vendor-hooks-BgUTpb6X.js";import{r as A}from"./vendor-react-DEoibe3W.js";import{j as e,aa as u,bs as _,bo as E,O,y as V,H,T as ne,I as oe,X as ie,ah as Oe,al as $,cI as nt,a9 as Be,e as je,ab as fe,a7 as ze,ad as st,be as at}from"./vendor-mui-core-BV2FUxWJ.js";import{a9 as rt,O as qe,X as ot,c as it}from"./vendor-arcblock-5qqHEVGo.js";import{J as Y,a8 as lt,c as Fe,D as ct,n as X,aJ as dt,A as ut,b as mt}from"./vendor-utils-rHXShPKm.js";import{D as J,G as N,aA as re,aB as L,aJ as Re}from"./index-DJzuhKQh.js";import{S as le}from"./switch-control-D5eJVUaV.js";import{S as D}from"./section-BB6hVmdO.js";import{K as pt}from"./keyboard-arrow-down-rounded-DadBVmpO.js";import{I as ht}from"./index-Cj_-M8SX.js";import{b as xt}from"./base32-D35YSxth.js";import{u as ft}from"./use-mobile-BAa0wi8o.js";import"./lottie-web-jYmAQWuC.js";const ce={enabled:!1,domain:"",clientId:"",clientSecret:""};function gt(){var v,S,i;const{api:j}=J(),{blocklet:o}=N(),{t:n}=se(),s=(v=o==null?void 0:o.meta)==null?void 0:v.did,w=Object.assign({...ce},((i=(S=o==null?void 0:o.settings)==null?void 0:S.oauth)==null?void 0:i.auth0)||{}),{handleSubmit:t,control:f,formState:c,watch:h,reset:l}=re({defaultValues:Y(w,Object.keys(ce))}),d=h("enabled"),k=p(async r=>{var T,a;try{const{blocklet:b}=await j.configOAuth({input:{did:s,oauth:JSON.stringify({auth0:r})}}),m=Object.assign({...ce},((a=(T=b==null?void 0:b.settings)==null?void 0:T.oauth)==null?void 0:a.auth0)||{});l(m),U.success(n("oauth.saveSuccess"))}catch(b){U.error(b.message||n("oauth.saveFailed"))}}),I=p(r=>r!=null&&r.trim()?!0:n("oauth.auth0.domainDescription")),x=p(r=>r!=null&&r.trim()?!0:n("oauth.auth0.clientIdDescription")),g=p(r=>r!=null&&r.trim()?!0:n("oauth.auth0.clientSecretDescription")),y=p(()=>!0);return e.jsx(u,{children:e.jsxs("form",{onSubmit:t(k),disabled:!0,children:[e.jsx(D,{title:n("oauth.auth0.enable"),mb:2.5,children:e.jsx(L,{name:"enabled",control:f,render:({field:r})=>e.jsx(_,{control:e.jsx(le,{sx:{ml:1},checked:r.value,...r})})})}),e.jsx(D,{title:n("oauth.auth0.domain"),children:e.jsx(L,{name:"domain",control:f,rules:{validate:d?I:y},render:({field:r})=>{var T;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...r,size:"small",label:n("oauth.auth0.domain"),error:!!c.errors[r.name],helperText:((T=c.errors[r.name])==null?void 0:T.message)||" ",disabled:!d})})}})}),e.jsx(D,{title:n("oauth.auth0.clientId"),children:e.jsx(L,{name:"clientId",control:f,rules:{validate:d?x:y},render:({field:r})=>{var T;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...r,size:"small",label:n("oauth.auth0.clientId"),error:!!c.errors[r.name],helperText:((T=c.errors[r.name])==null?void 0:T.message)||" ",disabled:!d})})}})}),e.jsx(D,{title:n("oauth.auth0.clientSecret"),children:e.jsx(L,{name:"clientSecret",control:f,rules:{validate:d?g:y},render:({field:r})=>{var T;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...r,size:"small",type:"password",label:n("oauth.auth0.clientSecret"),error:!!c.errors[r.name],helperText:((T=c.errors[r.name])==null?void 0:T.message)||" ",disabled:!d})})}})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:t(k),disabled:!c.isDirty,children:n("oauth.save")})]})})}const de={enabled:!1,clientId:"",clientSecret:""};function jt(){var y,v,S;const{api:j}=J(),{blocklet:o}=N(),{t:n}=se(),s=(y=o==null?void 0:o.meta)==null?void 0:y.did,w=Object.assign({...de},((S=(v=o==null?void 0:o.settings)==null?void 0:v.oauth)==null?void 0:S.github)||{}),{handleSubmit:t,control:f,formState:c,watch:h,reset:l}=re({defaultValues:Y(w,Object.keys(de))}),d=h("enabled"),k=p(async i=>{var r,T;try{const{blocklet:a}=await j.configOAuth({input:{did:s,oauth:JSON.stringify({github:i})}}),b=Object.assign({...de},((T=(r=a==null?void 0:a.settings)==null?void 0:r.oauth)==null?void 0:T.github)||{});l(b),U.success(n("oauth.saveSuccess"))}catch(a){U.error(a.message||n("oauth.saveFailed"))}}),I=p(i=>i!=null&&i.trim()?!0:n("oauth.github.clientIdDescription")),x=p(i=>i!=null&&i.trim()?!0:n("oauth.github.clientSecretDescription")),g=p(()=>!0);return e.jsx(u,{children:e.jsxs("form",{onSubmit:t(k),disabled:!0,children:[e.jsx(D,{title:n("oauth.github.enable"),mb:2.5,children:e.jsx(L,{name:"enabled",control:f,render:({field:i})=>e.jsx(_,{control:e.jsx(le,{sx:{ml:1},checked:i.value,...i})})})}),e.jsx(D,{title:n("oauth.github.clientId"),children:e.jsx(L,{name:"clientId",control:f,rules:{validate:d?I:g},render:({field:i})=>{var r;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...i,size:"small",label:n("oauth.github.clientId"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}})}),e.jsx(D,{title:n("oauth.github.clientSecret"),children:e.jsx(L,{name:"clientSecret",control:f,rules:{validate:d?x:g},render:({field:i})=>{var r;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...i,size:"small",type:"password",label:n("oauth.github.clientSecret"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:t(k),disabled:!c.isDirty,children:n("oauth.save")})]})})}const ue={enabled:!1,clientId:"",clientSecret:""};function bt(){var y,v,S;const{api:j}=J(),{blocklet:o}=N(),{t:n}=se(),s=(y=o==null?void 0:o.meta)==null?void 0:y.did,w=Object.assign({...ue},((S=(v=o==null?void 0:o.settings)==null?void 0:v.oauth)==null?void 0:S.google)||{}),{handleSubmit:t,control:f,formState:c,watch:h,reset:l}=re({defaultValues:Y(w,Object.keys(ue))}),d=h("enabled"),k=p(async i=>{var r,T;try{const{blocklet:a}=await j.configOAuth({input:{did:s,oauth:JSON.stringify({google:i})}}),b=Object.assign({...ue},((T=(r=a==null?void 0:a.settings)==null?void 0:r.oauth)==null?void 0:T.google)||{});l(b),U.success(n("oauth.saveSuccess"))}catch(a){U.error(a.message||n("oauth.saveFailed"))}}),I=p(i=>i!=null&&i.trim()?!0:n("oauth.google.clientIdDescription")),x=p(i=>i!=null&&i.trim()?!0:n("oauth.google.clientSecretDescription")),g=p(()=>!0);return e.jsx(u,{children:e.jsxs("form",{onSubmit:t(k),disabled:!0,children:[e.jsx(D,{title:n("oauth.google.enable"),mb:2.5,children:e.jsx(L,{name:"enabled",control:f,render:({field:i})=>e.jsx(_,{control:e.jsx(le,{sx:{ml:1},checked:i.value,...i})})})}),e.jsx(D,{title:n("oauth.google.clientId"),children:e.jsx(L,{name:"clientId",control:f,rules:{validate:d?I:g},render:({field:i})=>{var r;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...i,size:"small",label:n("oauth.google.clientId"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}})}),e.jsx(D,{title:n("oauth.google.clientSecret"),children:e.jsx(L,{name:"clientSecret",control:f,rules:{validate:d?x:g},render:({field:i})=>{var r;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...i,size:"small",type:"password",label:n("oauth.google.clientSecret"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:t(k),disabled:!c.isDirty,children:n("oauth.save")})]})})}const me={enabled:!1,teamId:"",serviceId:"",keyId:"",authKey:"",bundleId:""};function vt(){var i,r,T;const{api:j}=J(),{blocklet:o}=N(),{t:n}=se(),s=(i=o==null?void 0:o.meta)==null?void 0:i.did,w=Object.assign({...me},((T=(r=o==null?void 0:o.settings)==null?void 0:r.oauth)==null?void 0:T.apple)||{}),{handleSubmit:t,control:f,formState:c,watch:h,reset:l}=re({defaultValues:Y(w,Object.keys(me))}),d=h("enabled"),k=p(async a=>{var b,m;try{const{blocklet:R}=await j.configOAuth({input:{did:s,oauth:JSON.stringify({apple:a})}}),P=Object.assign({...me},((m=(b=R==null?void 0:R.settings)==null?void 0:b.oauth)==null?void 0:m.apple)||{});l(P),U.success(n("oauth.saveSuccess"))}catch(R){U.error(R.message||n("oauth.saveFailed"))}}),I=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.teamIdDescription")),x=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.serviceIdDescription")),g=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.keyIdDescription")),y=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.authKeyDescription")),v=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.bundleIdDescription")),S=p(()=>!0);return e.jsx(u,{children:e.jsxs("form",{onSubmit:t(k),disabled:!0,children:[e.jsx(D,{title:n("oauth.apple.enable"),mb:2.5,children:e.jsx(L,{name:"enabled",control:f,render:({field:a})=>e.jsx(_,{control:e.jsx(le,{sx:{ml:1},checked:a.value,...a})})})}),e.jsx(D,{title:n("oauth.apple.teamId"),children:e.jsx(L,{name:"teamId",control:f,rules:{validate:d?I:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",label:n("oauth.apple.teamId"),error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(D,{title:n("oauth.apple.bundleId"),children:e.jsx(L,{name:"bundleId",control:f,rules:{validate:d?v:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",label:n("oauth.apple.bundleId"),error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(D,{title:n("oauth.apple.serviceId"),children:e.jsx(L,{name:"serviceId",control:f,rules:{validate:d?x:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",label:n("oauth.apple.serviceId"),error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(D,{title:n("oauth.apple.keyId"),children:e.jsx(L,{name:"keyId",control:f,rules:{validate:d?g:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",label:n("oauth.apple.keyId"),error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(D,{title:n("oauth.apple.authKey"),children:e.jsx(L,{name:"authKey",control:f,rules:{validate:d?y:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",type:"password",label:n("oauth.apple.authKey"),multiline:!0,rows:4,error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:t(k),disabled:!c.isDirty,children:n("oauth.save")})]})})}const yt={width:24,height:24,body:'<path fill="currentColor" d="M9 20q-.825 0-1.413-.588T7 18q0-.825.588-1.413T9 16q.825 0 1.413.588T11 18q0 .825-.588 1.413T9 20Zm6 0q-.825 0-1.413-.588T13 18q0-.825.588-1.413T15 16q.825 0 1.413.588T17 18q0 .825-.588 1.413T15 20Zm-6-6q-.825 0-1.413-.588T7 12q0-.825.588-1.413T9 10q.825 0 1.413.588T11 12q0 .825-.588 1.413T9 14Zm6 0q-.825 0-1.413-.588T13 12q0-.825.588-1.413T15 10q.825 0 1.413.588T17 12q0 .825-.588 1.413T15 14ZM9 8q-.825 0-1.413-.588T7 6q0-.825.588-1.413T9 4q.825 0 1.413.588T11 6q0 .825-.588 1.413T9 8Zm6 0q-.825 0-1.413-.588T13 6q0-.825.588-1.413T15 4q.825 0 1.413.588T17 6q0 .825-.588 1.413T15 8Z"/>'};function be({title:j,id:o,children:n,index:s,onMove:w,defaultExpand:t,onEnd:f}){const[c,h]=A.useState(t),l=A.useRef(null),d=A.useRef(null),[{handlerId:k},I]=Me({accept:"dragItem",collect(S){return{handlerId:S.getHandlerId()}},hover(S,i){var M,Q;if(!l.current)return;const r=S.index,T=s;if(r===T)return;const a=(M=l.current)==null?void 0:M.getBoundingClientRect(),b=(Q=d.current)==null?void 0:Q.getBoundingClientRect(),m=(b.bottom-b.top)/2,P=i.getClientOffset().y-a.top;r<T&&P<m||r>T&&P>m||(w(r,T),S.index=T)}}),[{isDragging:x},g]=$e({item:{index:s,type:"dragItem"},collect:S=>({isDragging:S.isDragging()}),end:f});g(d),I(l);const y=x?.5:1,v=p(S=>{S.preventDefault(),S.stopPropagation(),h(!c)});return e.jsxs(u,{ref:l,children:[e.jsxs(u,{sx:{cursor:"pointer","&:hover":{backgroundColor:"grey.100"}},ref:d,"data-handler-id":k,children:[e.jsxs(u,{sx:{py:2,px:1,opacity:y,display:"flex",alignItems:"center",gap:.5},draggable:!1,onClick:v,children:[e.jsx(u,{sx:{pointerEvents:"auto",cursor:"grab","&:active":{cursor:"grabbing"},fontSize:0,color:"text.hint","&:hover":{color:"text.secondary"}},children:e.jsx(K,{fontSize:20,icon:yt})}),e.jsx(ne,{sx:{flex:1},children:j}),e.jsx(oe,{size:"small",sx:{pointerEvents:"auto",transform:c?"":"rotate(180deg)",transition:"transform 0.3s ease"},children:e.jsx(K,{icon:pt,style:{transform:"scale(1.5)"}})})]}),e.jsx(ie,{})]}),e.jsx(u,{sx:{pl:4,py:2.5,display:c?"block":"none"},children:n})]})}be.propTypes={title:H.string.isRequired,id:H.string.isRequired,children:H.node.isRequired,index:H.number.isRequired,onMove:H.func.isRequired,onEnd:H.func.isRequired,defaultExpand:H.bool};be.defaultProps={defaultExpand:!1};const St=[{name:"github",title:"GitHub",icon:e.jsx(K,{icon:rt}),component:e.jsx(jt,{})},{name:"google",title:"Google",icon:e.jsx(K,{icon:He}),component:e.jsx(bt,{})},{name:"apple",title:"Apple",icon:e.jsx(K,{icon:Je}),component:e.jsx(vt,{})},{name:"auth0",title:"Auth0",icon:e.jsx(K,{icon:Ke}),component:e.jsx(gt,{})}],wt=["github","google","apple","auth0"];function kt(){var k,I;const{api:j}=J(),{blocklet:o}=N(),n=(k=o==null?void 0:o.meta)==null?void 0:k.did,s=((I=o==null?void 0:o.settings)==null?void 0:I.oauth)||{},w=Object.keys(s).sort((x,g)=>{var y,v,S;return((y=s[x])==null?void 0:y.order)!==void 0&&((v=s[g])==null?void 0:v.order)!==void 0?s[x].order-s[g].order:((S=s[x])==null?void 0:S.order)!==void 0?-1:1});for(const x of wt)w.includes(x)||w.push(x);const t=ae(w.reduce((x,g,y)=>Object.assign(x,{[g]:y}),{})),f=te(()=>{const x=[...St];return x.sort((g,y)=>t[g.name]-t[y.name]),x},[t.auth0,t.github,t.google]),c={};typeof window<"u"&&(c.context=window);const h=p(async x=>{const g={};Object.keys(x).forEach(y=>{g[y]={order:x[y]}}),await j.configOAuth({input:{did:n,oauth:JSON.stringify(g)}})}),l=p((x,g)=>{const y=f[x],v=f[g];t[y.name]=g,t[v.name]=x}),d=p(async()=>{await h(t)});return e.jsx(u,{sx:{".section-left":{width:"160px"}},children:e.jsx(Ve,{backend:Ne,...c,children:f.map((x,g)=>e.jsx(be,{index:g,id:x.name,title:x.title,icon:x.icon,onMove:l,onEnd:d,defaultExpand:x.enabled,children:x.component},x.name))})})}const Z={ttl:he.SESSION_TTL,cacheTtl:he.SESSION_CACHE_TTL,email:{enabled:!1,requireVerified:!1,requireUnique:!1,trustOauthProviders:!1,trustedIssuers:[],enableDomainBlackList:!1,domainBlackList:[],enableDomainWhiteList:!1,domainWhiteList:[]},phone:{enabled:!1,requireVerified:!1,requireUnique:!1,regionBlackList:[],trustedIssuers:[]}};function W(j){return e.jsx(ot,{...j,sx:{transform:"scale(0.75)"}})}function pe(j,o=!1){const n=o?j.ttl*86400:j.ttl/86400;return{...j,ttl:n}}function Tt(){var a,b;const{api:j}=J(),{blocklet:o}=N(),n=(a=o==null?void 0:o.meta)==null?void 0:a.did,s=lt({},Z,((b=o==null?void 0:o.settings)==null?void 0:b.session)||{});Fe(s.ttl)&&(s.ttl=Z.ttl),Fe(s.cacheTtl)&&(s.cacheTtl=Z.cacheTtl),s.phone||(s.phone=Z.phone),s.email||(s.email=Z.email);const{handleSubmit:w,control:t,formState:f,reset:c,watch:h}=re({defaultValues:Y(pe(s),["ttl","cacheTtl","email","phone"])}),{t:l}=se(),d=h("email.enabled"),k=h("phone.enabled"),I=h("email.enableDomainBlackList"),x=h("email.enableDomainWhiteList"),{fields:g,append:y,remove:v}=Re({control:t,name:"email.domainBlackList"}),{fields:S,append:i,remove:r}=Re({control:t,name:"email.domainWhiteList"}),T=p(async m=>{var R;try{const{blocklet:P}=await j.updateAppSessionConfig({input:{did:n,config:ct(pe(m,!0),["phone"])}}),M=Object.assign({},Z,Y(((R=P==null?void 0:P.settings)==null?void 0:R.session)||{},["ttl","cacheTtl","email","phone"]));c(pe(M)),U.success(l("common.configSuccess"))}catch(P){U.error(P.message)}});return e.jsx(It,{onSubmit:w(T),children:e.jsxs($,{direction:"column",gap:6,children:[e.jsxs(u,{children:[e.jsxs(u,{children:[e.jsx(ne,{variant:"h6",fontWeight:600,children:l("blocklet.config.session.profile")}),e.jsx(u,{component:ie,my:3})]}),e.jsxs($,{gap:2,children:[e.jsx(D,{title:l("blocklet.config.session.fullNameEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(W,{disabled:!0,checked:!0})})}),e.jsx(D,{title:l("blocklet.config.session.avatarEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(W,{disabled:!0,checked:!0})})}),e.jsx(D,{title:l("blocklet.config.session.emailEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(L,{name:"email.enabled",control:t,render:({field:m})=>e.jsx(W,{...m,checked:m.value})})})}),d&&e.jsxs($,{direction:"column",ml:2,children:[e.jsx(D,{title:l("blocklet.config.session.emailRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(L,{name:"email.requireVerified",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),e.jsx(D,{title:l("blocklet.config.session.emailRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(L,{name:"email.requireUnique",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),e.jsx(D,{title:l("blocklet.config.session.emailTrustOauthProviders"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(L,{name:"email.trustOauthProviders",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),e.jsx(D,{title:l("blocklet.config.session.enableDomainBlackList"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(L,{name:"email.enableDomainBlackList",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),I&&e.jsxs(u,{children:[g.map((m,R)=>e.jsxs($,{direction:"row",alignItems:"center",my:1,maxWidth:"720px",children:[e.jsx(L,{name:`email.domainBlackList.${R}`,control:t,render:P=>e.jsx(O,{...P.field,size:"small",fullWidth:!0})}),e.jsx(oe,{onClick:()=>v(R),children:e.jsx(De,{})})]},m.id)),e.jsx(V,{startIcon:e.jsx(qe,{}),onClick:()=>y(""),children:l("blocklet.config.session.addDomain")})]}),e.jsx(D,{title:l("blocklet.config.session.enableDomainWhiteList"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(L,{name:"email.enableDomainWhiteList",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),x&&e.jsxs(u,{children:[S.map((m,R)=>e.jsxs($,{direction:"row",alignItems:"center",my:1,maxWidth:"720px",children:[e.jsx(L,{name:`email.domainWhiteList.${R}`,control:t,render:P=>e.jsx(O,{...P.field,size:"small",fullWidth:!0})}),e.jsx(oe,{onClick:()=>r(R),children:e.jsx(De,{})})]},m.id)),e.jsx(V,{startIcon:e.jsx(qe,{}),onClick:()=>i(""),children:l("blocklet.config.session.addDomain")})]})]}),e.jsxs(u,{sx:{display:"none"},children:[e.jsx(D,{title:l("blocklet.config.session.phoneEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(L,{name:"phone.enabled",control:t,disabled:!0,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),k&&e.jsxs($,{direction:"column",ml:2,mt:1,children:[e.jsx(D,{title:l("blocklet.config.session.phoneRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(L,{name:"phone.requireVerified",control:t,render:({field:m})=>e.jsx(_,{control:e.jsx(W,{...m,checked:m.value})})})})}),e.jsx(D,{title:l("blocklet.config.session.phoneRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(L,{name:"phone.requireUnique",control:t,render:({field:m})=>e.jsx(_,{control:e.jsx(W,{...m,checked:m.value})})})})})]})]})]})]}),e.jsxs(u,{children:[e.jsx(ne,{variant:"h6",fontWeight:600,children:l("blocklet.config.session.period")}),e.jsx(u,{component:ie,my:3}),e.jsx($,{direction:"column",spacing:2,children:e.jsx(L,{name:"ttl",control:t,rules:{min:1,max:30},render:({field:m})=>e.jsx(E,{fullWidth:!0,sx:{mb:2},children:e.jsx(D,{title:l("blocklet.config.session.ttl",{day:m.value}),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{width:"100%",maxWidth:500,px:1.5},children:e.jsx(nt,{...m,defaultValue:7,step:1,marks:[{value:1,label:l("blocklet.config.session.day",{day:1})},{value:7,label:l("blocklet.config.session.days",{day:7})},{value:14,label:l("blocklet.config.session.days",{day:14})},{value:21,label:l("blocklet.config.session.days",{day:21})},{value:30,label:l("blocklet.config.session.days",{day:30})}],min:1,max:30,valueLabelDisplay:"auto"})})})})})})]}),e.jsx(u,{children:e.jsx(V,{type:"submit",variant:"contained",disabled:!f.isDirty,children:l("oauth.save")})})]})})}const It=Oe.form`
2
- max-width: 1536px;
3
-
4
- .advanced-config {
5
- border: 0;
6
- padding: 0;
7
- }
8
-
9
- .config-form {
10
- flex-grow: 1;
11
- overflow-y: auto;
12
- will-change: transform;
13
-
14
- &:first-child {
15
- margin: 0;
16
- }
17
-
18
- ${j=>j.theme.breakpoints.down("md")} {
19
- width: 100%;
20
- flex-shrink: 0;
21
- padding: 0 24px;
22
- transform: translate(0, 0);
23
- }
24
- }
25
-
26
- .config-item {
27
- display: flex;
28
- align-items: center;
29
- justify-content: space-between;
30
- }
31
-
32
- .config-desc {
33
- font-weight: normal;
34
- font-size: 12px;
35
- color: #666;
36
- }
37
-
38
- .form-item {
39
- margin-top: 0;
40
- }
41
- `;var ve={},Lt=Be;Object.defineProperty(ve,"__esModule",{value:!0});var Ee=ve.default=void 0,Dt=Lt(Pe()),Ae=e;Ee=ve.default=(0,Dt.default)([(0,Ae.jsx)("path",{d:"M19 5v14H5V5zm0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2"},"0"),(0,Ae.jsx)("path",{d:"M14 17H7v-2h7zm3-4H7v-2h10zm0-4H7V7h10z"},"1")],"ArticleOutlined");var ye={},Ct=Be;Object.defineProperty(ye,"__esModule",{value:!0});var Se=ye.default=void 0,qt=Ct(Pe()),Ft=e;Se=ye.default=(0,qt.default)((0,Ft.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2m4.24 16L12 15.45 7.77 18l1.12-4.81-3.73-3.23 4.92-.42L12 5l1.92 4.53 4.92.42-3.73 3.23z"}),"Stars");const Rt={width:24,height:24,body:'<path fill="currentColor" d="M6 12.05q0 1.125.425 2.188T7.75 16.2l.25.25V15q0-.425.288-.713T9 14q.425 0 .713.288T10 15v4q0 .425-.288.713T9 20H5q-.425 0-.713-.288T4 19q0-.425.288-.713T5 18h1.75l-.4-.35q-1.3-1.15-1.825-2.625T4 12.05Q4 9.7 5.2 7.787T8.425 4.85q.35-.2.738-.025t.512.575q.125.375-.013.75t-.487.575q-1.45.8-2.313 2.213T6 12.05Zm12-.1q0-1.125-.425-2.187T16.25 7.8L16 7.55V9q0 .425-.288.713T15 10q-.425 0-.713-.288T14 9V5q0-.425.288-.713T15 4h4q.425 0 .713.288T20 5q0 .425-.288.713T19 6h-1.75l.4.35q1.225 1.225 1.788 2.663T20 11.95q0 2.35-1.2 4.263t-3.225 2.937q-.35.2-.737.025t-.513-.575q-.125-.375.013-.75t.487-.575q1.45-.8 2.313-2.212T18 11.95Z"/>'},{DEFAULT_IP_DOMAIN_SUFFIX:At,SLOT_FOR_IP_DNS_SITE:Pt,DEFAULT_DID_DOMAIN:Ot}=he,{encode:Ue}=xt,Bt=j=>`${Ue(j.meta.did)}-${Pt}.${At}`,zt=({did:j,didDomain:o=Ot})=>`${Ue(j)}.${o}`;var Et={getIpDnsDomainForBlocklet:Bt,getDidDomainForBlocklet:zt};const Ut=A.forwardRef((j,o)=>{var v,S;const{t:n}=A.useContext(G),{blocklet:s}=N(),{api:w}=J(),t=ae({loadingReject:!1,loadingApprove:!1,mode:"view",show:!1,data:{},callback:X}),f=je(),c=((S=(v=f==null?void 0:f.transitions)==null?void 0:v.duration)==null?void 0:S.leavingScreen)||300,h=p(()=>{t.mode="view",t.data={},t.callback=X}),l=p(()=>{t.show=!1,setTimeout(()=>{h()},c)}),d=p(i=>{t.mode="view",t.show=!0,t.data=i}),k=p((i,r=X)=>{t.mode="approve",t.show=!0,t.data=i,t.callback=r});A.useImperativeHandle(o,()=>({open:d,close:l,approve:k}),[d,l,k]);const I=te(()=>{if(!t.show)return[];t.data.migratedFrom=[t.data.appId,t.data.appPid];const i=["appName","appLogo","appId","appPid","migratedFrom","appDescription","appUrl","version","appliedAt","status","serverId","serverVersion"];return t.data.isMaster!==!1&&dt(i,"appliedAt","status"),i.map(r=>{const T=n(`federated.info.${r}`);let a=t.data[r];if(r==="appName"&&t.data.isMaster&&(a=e.jsxs(u,{children:[e.jsx(ze,{component:Se}),a]})),["appId","appPid","serverId"].includes(r)&&(a=e.jsx(xe,{children:a})),["appUrl"].includes(r)&&(a=e.jsx(u,{component:"a",href:a,target:"_blank",children:a})),["appLogo"].includes(r)){const b=ut(`https://${Et.getDidDomainForBlocklet({did:t.data.appPid})}`,"/.well-known/service/blocklet/logo");try{const m=new URL(b);m.searchParams.set("imageFilter","resize"),m.searchParams.set("w","80"),m.searchParams.set("h","80"),a=e.jsx("img",{src:m.href,width:"60",height:"60",alt:t.data.appName})}catch{a=e.jsx("img",{src:b,width:"60",height:"60",alt:t.data.appName})}}return r==="status"&&(a=a&&n(`federated.status.${a}`)),r==="migratedFrom"&&(a=(t.data.migratedFrom||[]).filter(R=>![t.data.appId,t.data.appPid].includes(R)).map(R=>e.jsx(xe,{children:R}))),mt(a)&&(a="-"),{name:T,value:a}})},[t.data]),x=t.mode==="approve",g=p(async()=>{try{t.loadingReject=!0,await w.auditFederatedLogin({input:{memberPid:t.data.appPid,did:s.appPid,status:"rejected"}}),l(),t==null||t.callback(!1)}finally{t.loadingReject=!1}}),y=p(async()=>{try{t.loadingApprove=!0,await w.auditFederatedLogin({input:{memberPid:t.data.appPid,did:s.appPid,status:"approved"}}),l(),t==null||t.callback(!0)}finally{t.loadingApprove=!1}});return e.jsx(ge,{open:t.show,title:n(x?"federated.approveToJoinLogin":"federated.siteDetail"),onClose:l,actions:x?e.jsxs(e.Fragment,{children:[e.jsxs(V,{color:"error",variant:"contained",onClick:g,disabled:t.loadingReject,children:[t.loadingReject?e.jsx(fe,{size:16,color:"grey"}):null,n("common.reject")]}),e.jsxs(V,{variant:"contained",onClick:y,disabled:t.loadingApprove,children:[t.loadingApprove?e.jsx(fe,{size:16,color:"grey"}):null,n("common.approve")]})]}):e.jsx(V,{variant:"outlined",onClick:l,children:n("common.close")}),children:I.map(i=>e.jsx(ht,{style:{alignItems:"flex-start"},valueComponent:"div",nameWidth:180,name:i.name,children:i.value},i.name))})}),_e=A.forwardRef((j,o)=>{var d,k;const n=je(),s=((k=(d=n==null?void 0:n.transitions)==null?void 0:d.duration)==null?void 0:k.leavingScreen)||300,{t:w}=A.useContext(G),t=ae({show:!1,data:{link:""}}),f=p(()=>{t.data.link=""}),c=p(()=>{t.show=!1,setTimeout(()=>{f()},s)}),h=p(({link:I})=>{t.show=!0,t.data.link=I});A.useImperativeHandle(o,()=>({open:h,close:c}),[h,c]);const l=p(()=>{tt(t.data.link),c()});return e.jsxs(ge,{open:t.show,title:w("federated.joinFederatedLogin"),onClose:c,PaperProps:{style:{minHeight:"unset"}},actions:e.jsx(z,{color:"primary",autoFocus:!0,variant:"contained",onClick:l,children:w("common.copyAndClose")}),children:[e.jsx(u,{mb:1,children:w("federated.inviteJoinFederatedLoginDescription")}),e.jsx(u,{sx:{"& .copy-button":{display:"none !important"}},children:e.jsx(Ge,{language:"shell",style:{marginBottom:0},children:t.data.link})})]})});function we({mode:j}){var Q,ke,Te,Ie,Le;const o=A.useRef(null),n=A.useRef(null),{t:s,locale:w}=A.useContext(G),{blocklet:t,actions:{refreshBlocklet:f}}=N(),{confirmApi:c,confirmHolder:h}=Ze(),{api:l}=J(),d=((Q=t.settings.federated)==null?void 0:Q.sites)||[],k=((ke=t.settings.federated)==null?void 0:ke.config)||{},I=k.isMaster!==!1,x=d.find(C=>C.appPid===t.appPid),g=ae({loadingSync:!1}),y=p(C=>{var q;(q=n.current)==null||q.open(C)}),v=p(C=>{var q;(q=n.current)==null||q.approve(C,f)}),S=p(C=>{c.open({title:s("federated.removeFederatedLogin"),content:s("federated.removeFederatedLoginDescription"),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(q){await l.quitFederatedLogin({input:{did:t.appPid,targetDid:C.appPid}}),q()}})}),i=p(C=>{c.open({title:s("federated.disableFederatedLogin"),content:s("federated.disableFederatedLoginDescription"),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(q){await l.auditFederatedLogin({input:{memberPid:C.appPid,did:t.appPid,status:"revoked"}}),q()}})}),r=p(C=>{c.open({title:s("federated.enableFederatedLogin"),content:s("federated.enableFederatedLoginDescription"),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm(q){await l.auditFederatedLogin({input:{memberPid:C.appPid,did:t.appPid,status:"approved"}}),q()}})}),T=te(()=>{const C=[{label:s("common.name"),name:"appName",options:{customBodyRenderLite:q=>{const F=d[q],ee=F.isMaster!==!1;return e.jsx(u,{display:"inline-block",children:e.jsxs(u,{component:"a",display:"flex",alignItems:"center",href:F.appUrl,target:"_blank",onClick:B=>{B.stopPropagation()},children:[ee&&e.jsx(ze,{component:Se,style:{marginRight:"4px"}}),F.appName]})})}}},{label:s("common.did"),name:"appId",options:{customBodyRenderLite:q=>{const F=d[q];return e.jsx(xe,{children:F.appId})}}},{label:s("common.status"),name:"status",options:{customBodyRenderLite:q=>{const F=d[q],ee=F.isMaster!==!1;return e.jsx(u,{children:ee?"-":s(`federated.status.${F.status}`)})}}}];return I&&C.push({label:s("common.actions"),name:"actions",options:{customBodyRenderLite:q=>{const F=d[q],ee=F.isMaster!==!1;return e.jsx(u,{display:"flex",gap:1,children:ee?e.jsxs(e.Fragment,{children:[F.status==="rejected"&&e.jsx(z,{variant:"contained",color:"error",size:"small",onClick:B=>{B.stopPropagation()},children:s("federated.status.rejected")}),F.status==="revoked"&&e.jsx(z,{variant:"contained",color:"secondary",size:"small",onClick:B=>{B.stopPropagation()},children:s("federated.status.revoked")})]}):e.jsxs(e.Fragment,{children:[e.jsx(z,{variant:"contained",color:"error",size:"small",onClick:B=>{B.stopPropagation(),S(F)},children:s("federated.quitMember")},"quiteSite"),F.status==="pending"&&e.jsx(z,{variant:"contained",color:"primary",size:"small",onClick:B=>{B.stopPropagation(),v(F)},children:s("federated.status.pending")},"auditSite"),F.status==="approved"&&e.jsx(z,{variant:"contained",color:"error",size:"small",onClick:B=>{B.stopPropagation(),i(F)},style:{whiteSpace:"nowrap"},children:s("federated.revoke")},"revokeSite"),F.status==="revoked"&&e.jsx(z,{variant:"contained",color:"warning",size:"small",onClick:B=>{B.stopPropagation(),r(F)},style:{whiteSpace:"nowrap"},children:s("federated.approve")},"approveSite")]})})}}}),C},[k.appId,d,I,s]),a=te(()=>({sort:!0,download:!1,filter:!1,print:!1,expandableRowsOnClick:!0,onRowClick(C,{dataIndex:q}){const F=d[q];y(F)}}),[]),b=p(()=>{var q;const C=t.environments.find(F=>F.key===it.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_URL);C!=null&&C.value?(q=o.current)==null||q.open({link:C.value}):U.error(s("federated.failedToGetFederatedLoginLink"))},[(Le=(Ie=(Te=t.site)==null?void 0:Te.domainAliases)==null?void 0:Ie[0])==null?void 0:Le.href]),m=p(()=>{c.open({title:s("federated.quitFederatedLogin"),content:s("federated.quitFederatedLoginDescription"),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(C){await l.quitFederatedLogin({input:{did:t.appPid}}),C()}})}),R=p(()=>{c.open({title:s("federated.disbandFederatedLogin"),content:s("federated.disbandFederatedLoginDescription"),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(C){await l.disbandFederatedLogin({input:{did:t.appPid}}),C()}})}),P=p(async()=>{try{g.loadingSync=!0,await Promise.all([await l.syncFederatedConfig({input:{did:t.appPid}}),Xe(500)]),U.success(s("common.succeeded"))}finally{g.loadingSync=!1}}),M=[];return x.status!=="pending"&&M.push(e.jsx(st,{title:s("federated.syncConfig"),children:e.jsx(oe,{size:"small",onClick:P,disabled:g.loadingSync,sx:[{"@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}},g.loadingSync?{animation:"spin 1s linear infinite"}:{}],children:e.jsx(K,{icon:Rt,style:{fontSize:24}})},"syncConfig")})),j==="master"?(M.push(e.jsx(z,{size:"small",variant:"contained",onClick:b,sx:{ml:1},children:s("federated.inviteJoinFederatedLogin")},"inviteJoinFederatedLogin")),M.push(e.jsx(z,{color:"error",size:"small",variant:"contained",onClick:R,sx:{ml:1},children:s("federated.disbandFederatedLogin")},"disbandFederatedLogin"))):M.push(e.jsx(z,{size:"small",variant:"contained",color:"error",onClick:m,sx:{ml:1},children:s("federated.quitFederatedLogin")},"quitFederatedLogin")),e.jsxs(e.Fragment,{children:[e.jsx(Ye,{className:"main-table",locale:w,data:d,columns:T,customButtons:M,title:e.jsx(u,{className:"table-toolbar-left",children:s("oauth.federated")}),options:a}),h,e.jsx(_e,{ref:o}),e.jsx(Ut,{ref:n})]})}we.propTypes={mode:H.oneOf(["member","master"])};we.defaultProps={mode:"member"};const _t=A.forwardRef((j,o)=>{var g,y;const{t:n}=A.useContext(G),{api:s}=J(),{blocklet:w}=N(),t=w==null?void 0:w.appPid,f=je(),c=((y=(g=f==null?void 0:f.transitions)==null?void 0:g.duration)==null?void 0:y.leavingScreen)||300,h=ae({loading:!1,show:!1,appUrl:"",appUrlError:"",callback:X}),l=p(()=>{h.appUrl="",h.appUrlError="",h.callback=X}),d=p(()=>{h.show=!1,setTimeout(()=>{l()},c)}),k=p((v=X)=>{h.show=!0,h.callback=v});A.useImperativeHandle(o,()=>({open:k,close:d}),[k,d]);const I=p(v=>{if(!v)throw new Error(n("federated.federatedJoinAppUrlRequired"));if(!Qe(v))throw new Error(n("federated.federatedJoinAppUrlInvalid"))}),x=p(async()=>{try{I(h.appUrl),h.loading=!0;const v=await s.joinFederatedLogin({input:{did:t,appUrl:h.appUrl}});h.show=!1,d(),h==null||h.callback(v)}catch(v){h.appUrlError=v.message}finally{h.loading=!1}});return e.jsxs(ge,{open:h.show,title:n("federated.joinFederatedLogin"),onClose:d,PaperProps:{style:{minHeight:"unset"}},actions:e.jsxs(z,{color:"primary",autoFocus:!0,variant:"contained",onClick:x,disabled:h.loading,children:[h.loading?e.jsx(fe,{size:16,sx:{mr:1},color:"grey"}):null,n("common.confirm")]}),children:[e.jsx(u,{mb:1,children:n("federated.joinFederatedLoginDescription")}),e.jsx(O,{fullWidth:!0,variant:"outlined",margin:"dense",placeholder:n("federated.federatedJoinAppUrl"),label:n("federated.federatedJoinAppUrl"),value:h.appUrl,error:!!h.appUrlError,helperText:h.appUrlError||"eg: https://www.arcblock.io",onChange:v=>{h.appUrl=v.target.value}})]})});function Wt(){const{t:j}=A.useContext(G);return e.jsxs($,{direction:"row",spacing:2,alignItems:"flex-start",p:2,children:[e.jsx(Ee,{fontSize:"large",color:"primary"}),e.jsxs(u,{children:[e.jsx(ne,{variant:"h6",gutterBottom:!0,children:j("federated.title")}),e.jsx(ne,{variant:"body2",color:"text.secondary",children:j("federated.description")}),e.jsx(at,{href:"https://www.arcblock.io/blog/zh/did-connect-federated-login-support",underline:"hover",variant:"body2",color:"primary",target:"_blank",sx:{display:"inline-flex",alignItems:"center",mt:1},children:j("federated.link")})]})]})}function Mt(){var c,h,l,d,k;const j=A.useRef(null),o=A.useRef(null),{t:n}=A.useContext(G),{blocklet:s,actions:{refreshBlocklet:w}}=N(),t=p(()=>{var x,g,y,v;const I=(y=(g=(x=s.site)==null?void 0:x.domainAliases)==null?void 0:g[0])==null?void 0:y.href;if(I)try{const S=new URL(I);(v=j.current)==null||v.open({link:S.origin})}catch{U.error(n("federated.failedToGetFederatedLoginLink"))}},[(l=(h=(c=s.site)==null?void 0:c.domainAliases)==null?void 0:h[0])==null?void 0:l.href]),f=p(()=>{var I;(I=o.current)==null||I.open(()=>{w()})});if(((d=s.settings.federated)==null?void 0:d.sites.length)>0){const I=((k=s.settings.federated)==null?void 0:k.config.isMaster)!==!1;return e.jsx(we,{mode:I?"master":"member"})}return e.jsxs(e.Fragment,{children:[e.jsx(u,{display:"flex",flexDirection:"column",gap:2,justifyContent:"center",alignItems:"center",minHeight:"200px",children:e.jsxs(u,{sx:{maxWidth:400,borderRadius:2,border:"1px solid",borderColor:"divider"},children:[e.jsx(Wt,{}),e.jsx(ie,{sx:{width:1}}),e.jsxs($,{width:1,p:2,gap:1.5,children:[e.jsx(z,{variant:"contained",onClick:t,sx:{width:1},children:n("federated.inviteJoinFederatedLogin")}),e.jsx(z,{variant:"outlined",onClick:f,sx:{width:1},children:n("federated.joinFederatedLogin")})]})]})}),e.jsx(_e,{ref:j}),e.jsx(_t,{ref:o})]})}function We({orientation:j="horizontal"}){const{t:o}=A.useContext(G),n=ft({key:"lg"}),s=[{label:e.jsx(u,{textAlign:"center",width:"100%",children:o("oauth.commonSettings")}),value:"settings"},{label:e.jsx(u,{textAlign:"center",width:"100%",children:o("oauth.federated")}),value:"federated"},{label:e.jsx(u,{textAlign:"center",width:"100%",children:o("oauth.oauth")}),value:"oauth"},{label:e.jsx(u,{textAlign:"center",width:"100%",children:o("oauth.moreLogin")}),value:"more"}],[w,t]=A.useState(s[0].value),f=te(()=>({oauth:e.jsx(kt,{}),federated:e.jsx(Mt,{}),more:e.jsx(et,{children:o("oauth.comingSoon")}),settings:e.jsx(Tt,{})}),[o]);return j==="vertical"?e.jsx($t,{children:e.jsxs($,{direction:{md:"column",lg:"row"},gap:2,children:[e.jsx(u,{sx:{minWidth:"240px",flexShrink:0},children:e.jsx(Ce,{tabs:s,current:w,orientation:n?"horizontal":"vertical",onChange:t,sx:{borderRight:n?0:1,height:"100%",borderColor:"divider"}})}),e.jsx(u,{sx:{flexGrow:1,minWidth:0},children:e.jsx(u,{maxWidth:"1200px",children:f[w]})})]})}):e.jsxs(u,{children:[e.jsx(Ce,{tabs:s,current:w,onChange:t}),e.jsx(u,{marginTop:"10px",children:f[w]})]})}We.propTypes={orientation:H.oneOf(["horizontal","vertical"])};We.defaultProps={orientation:"horizontal"};const $t=Oe.div`
42
- .MuiTab-root {
43
- text-align: left;
44
- align-items: flex-start;
45
- font-weight: normal;
46
-
47
- div {
48
- text-align: left;
49
- }
50
- }
51
-
52
- .Mui-selected {
53
- font-weight: bold;
54
- }
55
- `;export{We as default};
@@ -1,113 +0,0 @@
1
- import{g as Ut,r as C}from"./vendor-react-DEoibe3W.js";import{ah as ue,al as ht,j as e,aa as T,O as te,bs as ge,bt as We,bo as Y,ad as xt,H as x,a9 as Je,T as ae,E as Qe,bz as gt,bQ as Ke,bR as qe,y as Le,b3 as Me,ab as bt,bI as jt,Y as vt,cp as yt,m as Ht,bb as dt,br as Vt,bn as Yt,q as ut,bY as Gt,I as Jt}from"./vendor-mui-core-BV2FUxWJ.js";import{J as St,z as Qt,A as Xt,e as fe,aB as ye,C as Zt}from"./vendor-utils-rHXShPKm.js";import{a as re,a6 as Ct,Z as q,bQ as es,B as me,b2 as ts,as as wt,j as W,b7 as ss,r as Xe,bR as ns,Y as Tt,a7 as Rt,bn as Ae,am as Nt,W as is,bu as as}from"./vendor-ux-did-connect-DROQhYpS.js";import{D as Ze,G as Et,aA as It,aB as X,y as se,n as rs,K as pt}from"./index-DJzuhKQh.js";import{a as Te,u as V,f as ce}from"./vendor-hooks-BgUTpb6X.js";import{a as et,b as os}from"./dashboard-vkFEu-wZ.js";import{l as ls,v as ke}from"./vendor-arcblock-5qqHEVGo.js";import{f as $e,i as cs,d as ds}from"./use-blocklet-logo-a8QJI4r-.js";import{A as us,a as ps,d as fs,b as ms}from"./collapse-BF9pIOsL.js";import{S as ee}from"./section-BB6hVmdO.js";import{S as Re}from"./shorten-label-DPIZ5X7v.js";import{I as At}from"./index-Cj_-M8SX.js";import{R as Ot,A as hs,S as xs,a as gs,b as bs,B as js}from"./list-D29W3nMj.js";import{W as vs}from"./did-address-BtAnHi7m.js";import{p as Dt}from"./util-D-q3oYk9.js";import{D as ys,g as Ss}from"./traffic-DVUW14yF.js";import{B as Lt}from"./bundle-avatar-BP8xFngr.js";import{u as Cs}from"./use-mobile-BAa0wi8o.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-BDA4jbwL.js";import"./index-8eXqqyHQ.js";import"./confirm-CiiHIA-a.js";import"./PlayArrow-Cv1uXXJt.js";import"./get-safe-url-CiQ8_q49.js";import"./session-ugMCR4Iu.js";import"./InfoOutlined-Duq1UDPu.js";import"./dot-DX56IFTM.js";import"./useAsync-Dv214fz8.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-C21X4TYN.js";import"./index-D2uDBC1o.js";import"./CheckCircle-DsdIIzds.js";import"./index-nhpGyAFA.js";import"./Phone-BkOMNOMO.js";import"./Location-DxPzfR_p.js";import"./Email-BirbvqZ3.js";import"./Timezone-D91Of94T.js";import"./base32-D35YSxth.js";import"./iframe-CJ1Wo1WH.js";import"./LaunchOutlined-C-M166rt.js";import"./ChevronLeft-BXDIS6AE.js";import"./ChevronRight-BfSAowju.js";import"./index-iB7JyXwh.js";import"./base-chart-D6qRW4Yg.js";import"./index-J3Tqz9ZT.js";import"./vendor-mui-x-Bo-XOtzq.js";import"./AdapterDayjs-Bs_Q9JXL.js";var Ue={exports:{}},He={exports:{}},Ve={exports:{}};(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s;function s(r){return r==null}n.exports=t.default,n.exports.default=t.default})(Ve,Ve.exports);var ws=Ve.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=p;var s=o(ls),r=o(ws);function o(h){return h&&h.__esModule?h:{default:h}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,y=/^[-+]?[0-9]+$/;function p(h,i){(0,s.default)(h),i=i||{};var A=i.allow_leading_zeroes===!1?l:y,O=!i.hasOwnProperty("min")||(0,r.default)(i.min)||h>=i.min,R=!i.hasOwnProperty("max")||(0,r.default)(i.max)||h<=i.max,S=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||h<i.lt,D=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||h>i.gt;return A.test(h)&&O&&R&&S&&D}n.exports=t.default,n.exports.default=t.default})(He,He.exports);var Ts=He.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var s=r(Ts);function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,s.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=t.default,n.exports.default=t.default})(Ue,Ue.exports);var Rs=Ue.exports;const Ns=Ut(Rs),Fe={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Es(){var N,E,P;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(N=t==null?void 0:t.meta)==null?void 0:N.did,y=Object.assign({...Fe},((P=(E=t==null?void 0:t.settings)==null?void 0:E.notification)==null?void 0:P.email)||{}),{handleSubmit:p,control:h,formState:i,watch:A,reset:O}=It({defaultValues:St(y,Object.keys(Fe))}),R=Te({testReceiver:"",testReceiverError:""}),S=A("enabled"),D=V(async(a,m,$=!0)=>{var U,oe;try{const{blocklet:le}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),pe=Object.assign({...Fe},((oe=(U=le==null?void 0:le.settings)==null?void 0:U.notification)==null?void 0:oe.email)||{});O(pe),$&&q.success(s("oauth.saveSuccess"))}catch(le){if($)q.error(le.message||s("oauth.saveFailed"));else throw le}}),G=V(async(a,m,$)=>{try{i.isDirty&&await D(a,m,!1),await n.sendEmail({input:{did:l,receiver:$,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),q.success(s("notification.email.testSuccess"))}catch(U){q.error(U.message||s("notification.email.testfailed"))}}),z=V((a,m)=>{R.testReceiver="",R.testReceiverError="",r.open({title:s("notification.email.testSendEmail"),content:()=>e.jsx(T,{sx:{width:"300px"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.email.inputTestReceiver"),value:R.testReceiver,onChange:$=>{R.testReceiver=$.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm($){var oe;const U=(oe=R.testReceiver)==null?void 0:oe.trim();if(!U){R.testReceiverError=s("notification.email.receiverRequired");return}if(!ke(U)){R.testReceiverError=s("notification.email.receiverInvalid");return}R.testReceiverError="",await G(a,m,U),$()}})}),B=V(a=>{const m=a==null?void 0:a.trim();return m?ke(m)?!0:s("notification.email.fromInvalid"):s("notification.email.fromRequired")}),_=V(a=>{const m=a==null?void 0:a.trim();return m?$e(m,{require_host:!1,protocols:[]})?!0:s("notification.email.hostInvalid"):s("notification.email.hostRequired")}),M=V(a=>a?Ns(a)?!0:s("notification.email.portInvalid"):s("notification.email.portRequired")),J=V(a=>a!=null&&a.trim()?!0:s("notification.email.userRequired")),ie=V(a=>a!=null&&a.trim()?!0:s("notification.email.passwordRequired")),c=V(a=>a!=null&&a.trim()&&!$e(a,{protocols:["http","https"],require_protocol:!0})?s("notification.email.linkInvalid"):!0),g=V(a=>a!=null&&a.trim()&&!ke(a)?s("notification.email.emailInvalid"):!0),j=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(Is,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.email.enable"),my:2.5,children:e.jsx(X,{name:"enabled",control:h,render:({field:a})=>e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a})})})}),e.jsx(ee,{title:s("notification.email.from"),children:e.jsx(X,{name:"from",control:h,rules:{validate:S?B:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,label:s("notification.email.from"),error:!!i.errors[a.name],helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.host"),children:e.jsx(X,{name:"host",control:h,rules:{validate:S?_:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.host"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.port"),children:e.jsx(X,{name:"port",control:h,rules:{validate:S?M:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:s("notification.email.port"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.user"),children:e.jsx(X,{name:"user",control:h,rules:{validate:S?J:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.user"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.password"),children:e.jsx(X,{name:"password",control:h,rules:{validate:S?ie:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:s("notification.email.password"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.secure"),children:e.jsx(X,{name:"secure",control:h,rules:{validate:j},render:({field:a})=>e.jsx(Y,{fullWidth:!0,children:e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a,disabled:!S})})})})}),e.jsxs(us,{children:[e.jsxs(ps,{expandIcon:e.jsx(fs,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[s("notification.email.signature"),e.jsx(xt,{title:s("notification.email.signatureTooltip"),children:e.jsx(es,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(ms,{children:[e.jsx(ee,{title:s("notification.email.companyName"),children:e.jsx(X,{name:"companyName",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyName"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyLink"),children:e.jsx(X,{name:"companyLink",control:h,rules:{validate:S?c:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyLink"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyAddress"),children:e.jsx(X,{name:"companyAddress",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyAddress"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.supportEmail"),children:e.jsx(X,{name:"supportEmail",control:h,rules:{validate:S?g:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:s("notification.email.supportEmail"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})})]})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const Is=ue(ht)``,Be={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function As(){var M,J,ie;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(M=t==null?void 0:t.meta)==null?void 0:M.did,y=Object.assign({...Be},((ie=(J=t==null?void 0:t.settings)==null?void 0:J.notification)==null?void 0:ie.pushKit)||{}),{handleSubmit:p,control:h,formState:i,watch:A,reset:O}=It({defaultValues:St(y,Object.keys(Be))}),R=Te({testReceiver:"",testReceiverError:""}),S=A("enabled"),D=V(async(c,g,j=!0)=>{var N,E;try{const{blocklet:P}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:c})}}),a=Object.assign({...Be},((E=(N=P==null?void 0:P.settings)==null?void 0:N.notification)==null?void 0:E.pushKit)||{});O(a),j&&q.success(s("oauth.saveSuccess"))}catch(P){if(j)q.error(P.message||s("oauth.saveFailed"));else throw P}}),G=V(async(c,g)=>{var j,N,E;try{i.isDirty&&await D(c,g,!1);const P=(j=((t==null?void 0:t.configs)||[]).find($=>$.key==="BLOCKLET_APP_URL"))==null?void 0:j.value,a=Qt(Xt(P,"/.well-known/service/blocklet/logo"),{v:(N=t==null?void 0:t.meta)==null?void 0:N.version,t:new Date((t==null?void 0:t.updatedAt)||0).getTime()}),m={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:t==null?void 0:t.appDid,fullName:(E=t==null?void 0:t.meta)==null?void 0:E.title,avatar:a}}}};await n.sendPush({input:{did:l,receiver:R.testReceiver,notification:JSON.stringify(m)}}),q.success(s("notification.pushKit.testSuccess"))}catch(P){q.error(P.message||s("notification.pushKit.testfailed"))}}),z=V((c,g)=>{R.testReceiverError="",r.open({title:s("notification.pushKit.testSend"),content:()=>e.jsx(T,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.pushKit.inputTestReceiver"),value:R.testReceiver,onChange:j=>{R.testReceiver=j.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm(j){var E;if(!((E=R.testReceiver)==null?void 0:E.trim())){R.testReceiverError=s("notification.pushKit.receiverRequired");return}R.testReceiverError="",await G(c,g),j()}})}),B=V(c=>{const g=c==null?void 0:c.trim();return g?$e(g)?!0:s("notification.pushKit.endpointInvalid"):s("notification.pushKit.endpointRequired")}),_=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(Os,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.pushKit.enable"),my:2.5,children:e.jsx(X,{name:"enabled",control:h,render:({field:c})=>e.jsx(ge,{control:e.jsx(We,{checked:c.value,...c})})})}),e.jsx(ee,{title:s("notification.pushKit.endpoint"),children:e.jsx(X,{name:"endpoint",control:h,rules:{validate:S?B:_},render:({field:c})=>{var g;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",required:!0,label:s("notification.pushKit.endpoint"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})}),e.jsxs(ee,{title:s("notification.pushKit.customOptions"),children:[e.jsx(X,{name:"did",control:h,render:({field:c})=>{var g;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.did"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}}),e.jsx(X,{name:"pushPath",control:h,render:({field:c})=>{var g;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.pushPath"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const Os=ue(ht)``,ft=[{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Email"}),value:"email"},{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Push Kit"}),value:"pushKit"}];function Ds(){const[n,t]=C.useState(ft[0].value),{locale:s}=C.useContext(ts),r=ce(()=>({email:e.jsx(Es,{}),pushKit:e.jsx(As,{})}),[s]),o=C.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(T,{children:[e.jsx(wt,{tabs:ft,current:n,onChange:t}),e.jsx(T,{style:o,children:r[n]})]})}const Pt=C.createContext({}),{Provider:Ls,Consumer:oi}=Pt;function Ps({children:n,blocklet:t=""}){const{api:s,inService:r,ws:{useSubscription:o}}=Ze(),[l,y]=C.useState([]),[p,h]=C.useState({total:0,pageSize:20,pageCount:0,page:1}),i=ce(()=>{var c;return(c=t.meta)==null?void 0:c.did},[t]),[A,O]=C.useState([]),[R,S]=C.useState({}),D=ce(()=>l.length?new Set(l.map(c=>c.id)):new Set,[l]),G=async({page:c=1,pageSize:g=20,...j}={})=>{if(!i)return[];try{const N={paging:{page:c,pageSize:g},...j,teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0},{dids:E,...P}=N;let a="";E&&E.includes("system")&&(a="system");const m=E?E.filter(oe=>oe!=="system"):[],$={...P,source:a,componentDids:m},U=await s.getNotificationSendLog({input:$});return S($),y(U.list),h(U.paging),U.list}catch(N){return q.error(N.message),[]}},z=async()=>{const c=await s.getNotificationComponents({input:{teamDid:i}});O(c.componentDids)},B=C.useCallback(c=>{const g=t.children.find(j=>{var N;return((N=j.meta)==null?void 0:N.did)===c});if(g)return g.ancestors=[t],g},[t]),_=async({notificationId:c,receivers:g,channels:j,...N})=>{await s.resendNotification({input:{teamDid:i,notificationId:c,receivers:g,channels:j.map(E=>E==="wallet"?W.NOTIFICATION_SEND_CHANNEL.WALLET:E==="pushKit"?W.NOTIFICATION_SEND_CHANNEL.PUSH:E),...N}})},M=C.useCallback(async c=>(await s.getUser({input:{teamDid:i,user:{did:c}}})).user,[s,i]),J=C.useCallback(async({page:c=1,pageSize:g=20,...j}={})=>{try{const N={paging:{page:c,pageSize:g},...j,userName:j.searchText||"",teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0};return await s.getReceivers({input:N})}catch(N){throw q.error(N.message),N}},[s,i]);C.useEffect(()=>{i&&z()},[i]),o(W.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,c=>{D.has(c.notificationId)&&G(R)},[D,R]),o(W.EVENTS.NOTIFICATION_BLOCKLET_CREATE,c=>{D.has(c.id)||G(R)},[D,R]);const ie={fetch:G,data:l,paging:p,blocklet:t,getComponent:B,resendNotification:_,getUser:M,componentDids:A,getReceivers:J,inService:r,teamDid:i};return e.jsx(Ls,{value:{notificationRecords:ie},children:n})}function tt(){const{notificationRecords:n}=C.useContext(Pt);return n}Ne.propTypes={severity:x.oneOf(Object.values(["info","success","error","warning"])).isRequired};const _s={info:"primary",success:"success",error:"error",warning:"warning"};function Ne({severity:n="info"}){return e.jsx(ss,{type:_s[n],children:n})}var st={},ks=Je;Object.defineProperty(st,"__esModule",{value:!0});var _t=st.default=void 0,Fs=ks(Xe()),Bs=e;_t=st.default=(0,Fs.default)((0,Bs.jsx)("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"CheckCircleOutline");var nt={},zs=Je;Object.defineProperty(nt,"__esModule",{value:!0});var kt=nt.default=void 0,Ws=zs(Xe()),Ks=e;kt=nt.default=(0,Ws.default)((0,Ks.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12m8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8"}),"Block");var it={},qs=Je;Object.defineProperty(it,"__esModule",{value:!0});var Ft=it.default=void 0,Ms=qs(Xe()),$s=e;Ft=it.default=(0,Ms.default)((0,$s.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");const Us=(n,t,s="")=>{if(!s||!t)return"";switch(s){case W.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return s}};function Bt(n,t,s={}){const{status:r,updatedAt:o,reason:l="",channel:y="wallet"}=s,p=o?n("notification.sendStatus.sentTime",{date:rs(o,t)}):"",h=Us(n,y,l);return r===W.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:p,reason:h}:r===W.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:p}:{status:"pending",title:n("notification.sendStatus.pending"),reason:h,sentTime:p}}const Ye={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ge=["wallet","pushKit","email"],mt=["info","success","error","warning"],zt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.email)==null?void 0:r.enabled},Wt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.pushKit)==null?void 0:r.enabled},Hs=(n,t)=>{const s=fe(t,"extra.notifications.email",!0);return{available:zt(n),enabled:s}},Vs=(n,t)=>{const s=fe(t,"extra.notifications.push",!0);return{available:Wt(n),enabled:s}},Ys=n=>({enabled:fe(n,"extra.notifications.wallet",!0)}),Gs=n=>({enabled:fe(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(t=>{setTimeout(()=>{t()},n*1e3)}),Js=(n,t)=>t==="wallet"||t==="webhook"?[{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:t==="pushKit"||t==="email"?[{channel:t,type:"available",pass:n("notification.sendStatus.reason.available",{channel:t}),fail:n("notification.sendStatus.reason.unavailable",{channel:t})},{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:[],Ie=(n=[])=>{const t=se().startOf("day");return n.filter(s=>se(s.sendAt).isSame(t,"day")).length},Qs=(n,t="")=>{if(t&&Ge.includes(t)){const l=`${t}SendRecord`,y=fe(n,l,[]);return Ie(y)}const s=fe(n,"webhook",{}),r=Object.keys(s??{})??[];if(t&&r.includes(t)){const l=s[t]??[];return Ie(l)}const o={};return Ge.forEach(l=>{const y=`${l}SendRecord`,p=fe(n,y,[]),h=Ie(p);o[l]=h}),r.length>0&&r.forEach(l=>{const y=s[l]??[],p=Ie(y);o[l]=p}),o},Oe=(n,t,s)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[s].splice(t,1),n},De=(n,t)=>{if(!Array.isArray(t))throw new Error("filters must be an array");return t.length?!t.includes(n):!1},Xs=n=>{switch(n){case W.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case W.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case W.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case W.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Kt=()=>({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:t=!0,showTitle:s=!1,children:r}){const{status:o,title:l="",sentTime:y="",reason:p=""}=n,h=[l,p].filter(Boolean).join(", ");return e.jsx(xt,{title:t?e.jsxs(e.Fragment,{children:[e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:h}),e.jsx("span",{children:y})]}):null,arrow:!0,placement:"top",children:e.jsxs(T,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(T,{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center",children:[e.jsx(T,{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Ye[o],style:{opacity:.15}}),e.jsx(T,{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Ye[o]})]}),e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:s?l:r})]})})}de.propTypes={config:x.object.isRequired,enableTooltip:x.bool,showTitle:x.bool,children:x.node};de.defaultProps={enableTooltip:!0,showTitle:!1,children:null};Se.propTypes={list:x.array.isRequired,label:x.string.isRequired,onDelete:x.func};Se.defaultProps={onDelete:()=>{}};function Se({list:n,label:t,onDelete:s}){const{t:r,locale:o}=re();return e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(ae,{children:[t,": "]}),n.map(l=>{const y=Bt(r,o,{status:l});return e.jsx(Qe,{size:"small",label:e.jsx(T,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(de,{config:y,enableTooltip:!1,children:y.title})}),onDelete:p=>s(p,l)},l)})]})}at.propTypes={filterList:x.array.isRequired,onChange:x.func.isRequired,index:x.number.isRequired,column:x.object.isRequired,filterValues:x.array.isRequired,label:x.string.isRequired,renderLabel:x.func.isRequired};function at({filterList:n,onChange:t,index:s,column:r,filterValues:o,label:l,renderLabel:y}){return e.jsxs(Y,{className:"filter-container",children:[e.jsx(gt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(p=>e.jsx(ge,{control:e.jsx(qe,{checked:n[s].indexOf(p.value??p)>-1,onChange:h=>{const i=[...n];h.target.checked?i[s]=[...i[s],p.value??p]:i[s]=i[s].filter(A=>A!==(p.value??p)),t(i[s],s,r)},name:p.value??p}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:y(p)})},p.value??p))})]})}function ze(n){return e.jsx(at,{...n,renderLabel:t=>e.jsx(de,{enableTooltip:!1,config:{status:t.status},children:t.label})})}ve.propTypes={status:x.number.isRequired,updatedAt:x.string.isRequired,reason:x.string,channel:x.string,onResend:x.func};function ve({status:n,updatedAt:t,reason:s="",channel:r="wallet",onResend:o}){const{t:l,locale:y}=re(),p=Bt(l,y,{status:n,updatedAt:t,reason:s,channel:r});return e.jsxs(T,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(de,{config:p,showTitle:!0}),p.status!=="success"&&e.jsx(Le,{className:"resend-btn",size:"small",startIcon:e.jsx(et,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}rt.propTypes={value:x.array.isRequired,onChange:x.func};function rt({value:n,onChange:t}){const{locale:s}=re(),r=se().toDate(),[o,l]=C.useState(null),y=C.useCallback(i=>{l(o?null:i.currentTarget)},[o]),p=!!o,h=C.useCallback(i=>{if(!i.startDate||!i.endDate){q.error("Please select a date range");return}if(se(i.startDate).isAfter(i.endDate)||!se(i.startDate).isValid()||!se(i.endDate).isValid()){q.error("Invalid date range");return}t([i.startDate,i.endDate]),l(null)},[t]);return e.jsxs("div",{children:[e.jsx(ae,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:0,children:e.jsxs(Le,{onClick:y,variant:"outlined",size:"small",color:"inherit",children:[pt(n[0],s)," - ",pt(n[1],s)]})}),e.jsx(Me,{open:p,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(ys,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:y,definedRanges:Ss(r),onChange:h})})]})}ot.propTypes={itemComponent:x.elementType.isRequired};function ot({itemComponent:n,...t}){var o;const{t:s}=re();return!((o=t==null?void 0:t.filterList)!=null&&o.filter(l=>l.length).length)?null:e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsx("div",{className:"toolbar-filter-title",children:s("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(ns.TableFilterList,{...t,ItemComponent:n})})]})}function Pe({label:n,onDelete:t,canDelete:s=()=>!0,...r}){const o=t&&typeof t=="function"?t:void 0;let l=!0;return s&&typeof s=="function"&&(l=s({label:n,...r})),e.jsx(Qe,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}Pe.propTypes={label:x.string.isRequired,onDelete:x.func,canDelete:x.func};Pe.defaultProps={canDelete:()=>!0};const Zs=[{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}];lt.propTypes={loading:x.bool,onCancel:x.func,onConfirm:x.func};lt.defaultProps={loading:!1,onCancel:()=>{},onConfirm:()=>{}};function lt({loading:n=!1,onCancel:t,onConfirm:s}){const{t:r}=re(),[o,l]=C.useState(Zs),[y,p]=C.useState(!0),h=(A,O)=>{O.checked=A.target.checked;const R=o.map(S=>({...S,checked:S.value===O.value?O.checked:S.checked}));l(R)},i=A=>{A.stopPropagation(),s({channels:o.filter(O=>O.checked).map(O=>O.value),isResendFailedOnly:y})};return e.jsxs(T,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ae,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(T,{className:"choose-channel",children:e.jsxs(Y,{component:"fieldset",variant:"standard",children:[e.jsx(gt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(A=>e.jsx(ge,{control:e.jsx(qe,{checked:A.checked,onChange:O=>h(O,A),name:A.value}),label:A.label},A.value))})]})}),e.jsx(T,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(ge,{control:e.jsx(qe,{checked:y,onChange:A=>p(A.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(T,{display:"flex",justifyContent:"flex-end",gap:1,className:"resend-config-footer-tip",children:[e.jsx(Le,{onClick:A=>{A.stopPropagation(),t()},color:"inherit",children:r("common.cancel")}),e.jsxs(Le,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(bt,{size:16}),r("common.confirm")]})]})]})}qt.propTypes={notificationId:x.string.isRequired,handleResend:x.func,resending:x.bool};function qt({notificationId:n,handleResend:t,resending:s=!1}){const{t:r,locale:o}=re(),l=jt(),y=C.useMemo(()=>vt(l,Kt()),[l]),{getReceivers:p,inService:h,teamDid:i,getUser:A,blocklet:O}=tt(),[R,S]=C.useState(!1),[D,G]=C.useState([]),z=Te({anchorEl:null,position:null}),B=Te({anchorEl:null,position:null}),[_,M]=C.useState(null),[J,ie]=C.useState({total:0,pageSize:10,pageCount:0,page:1}),[c,g]=C.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[se().subtract(1,"month").startOf("day").toDate(),se().endOf("day").toDate()]}),[j,N]=C.useState([]),E=[{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"}],P=async()=>{if(!R&&n)try{S(!0);const d=await p({notificationId:n,...c}),u=d.list.map(f=>({...f,receiverUser:{...f.receiverUser,avatar:Dt(f.receiverUser.avatar,i,h)}}));G(u),ie(d.paging),S(!1)}catch(d){q.error(d.message),S(!1)}};C.useEffect(()=>{P()},[c]);const a=d=>{d.stopPropagation();const u=d.currentTarget;B.anchorEl=u;const f=u.getBoundingClientRect();B.position={top:f.top+window.scrollY,left:f.left+window.scrollX}},m=d=>d.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(me,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(et,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:a,children:r("notification.resend")})}):null,$={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:J.page-1,rowsPerPage:J.pageSize,count:J.total,searchText:c.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:j,onRowSelectionChange:(d,u)=>{N(u.map(f=>f.dataIndex))},customToolbarSelect:m},U=({page:d,rowsPerPage:u,searchText:f,filterList:L})=>{const[,K=[],Z=[],Q=[]]=L;c.pageSize!==u?g(H=>({...H,pageSize:u,page:1})):c.page!==d+1?g(H=>({...H,page:d+1})):c.searchText!==f?g(H=>({...H,searchText:f,page:1})):ye(K,c.walletSendStatus)?ye(Z,c.pushKitSendStatus)?ye(Q,c.emailSendStatus)||g(H=>({...H,emailSendStatus:Q,page:1})):g(H=>({...H,pushKitSendStatus:Z,page:1})):g(H=>({...H,walletSendStatus:K,page:1}))},oe=C.useCallback(async(d,u)=>{if(!u)return!1;const f=await A(u);return f?d==="wallet"?Ys(f):d==="email"?Hs(O,f):d==="pushKit"?Vs(O,f):d==="webhook"?Gs(f):!0:!1},[A,O]),le=C.useCallback(d=>Js(r,d),[r]),pe=()=>{z.anchorEl=null,z.position=null,M(null)},be=()=>{B.anchorEl=null,B.position=null},je=async(d,u,f=!0,L="")=>{if(!(!u.length||!d.length))try{t(d,u,f,L),B.anchorEl||(await Ee(.5),pe())}catch(K){console.error("handleResend error",{error:K})}},v=async({channels:d,isResendFailedOnly:u})=>{const f=j.map(L=>D[L].receiver);await je(d,f,u),await Ee(.5),be(),N([])},b=async(d,u=[],f=!0)=>{try{await je(["webhook"],[d.receiver],f,u)}catch(L){q.error(L.response?L.response.statusText:L.message)}},w=async(d,u,f,L=[],K=!0)=>{if(d.stopPropagation(),Qs(u,f)>=4){q.warning(r("notification.resendLimit"));return}if(!Ge.includes(f)){await b(u,L,K);return}if(d){const Q=d.currentTarget,H=Q.getBoundingClientRect();z.anchorEl=Q,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}M({channel:f});try{const Q=await oe(f,u.receiver);await Ee(1),M({channel:f,result:Q}),(typeof Q=="boolean"&&Q||Zt(Q)&&Object.values(Q).every(H=>!!H))&&(await t([f],[u.receiver],K),B.anchorEl||(await Ee(.5),pe()))}catch(Q){q.error(Q.message)}},I=d=>{g(u=>({...u,dateRange:d,page:1}))},k=(d,u,f,L)=>{d.stopPropagation();const K=f.filter(Z=>Z!==u);g(Z=>({...Z,[L]:K,page:1}))},F=ce(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:d=>{const{receiverUser:u,receiver:f}=D[d];return u?e.jsxs(T,{"data-cy":`member-name-${u.fullName}`,display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start",children:[e.jsx(Tt,{src:`${u.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:f,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Re,{children:u.fullName})]},f):e.jsx(vs,{size:14,responsive:!1,compact:!0,copyable:!1,did:f})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:c.walletSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Wallet",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[1].options.filterList,"walletSendStatus")}}),update:Oe},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Wallet",filterList:d,onChange:u,index:f,column:L,filterValues:E})},customBodyRenderLite:d=>{const{walletSendStatus:u,walletSendAt:f,walletSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"wallet",onResend:K=>w(K,D[d],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{pushKitSendStatus:u,pushKitSendAt:f,pushKitSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"pushkit",onResend:K=>w(K,D[d],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:c.pushKitSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Push Kit",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[2].options.filterList,"pushKitSendStatus")}}),update:Oe},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Push Kit",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{emailSendStatus:u,emailSendAt:f,emailSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"email",onResend:K=>w(K,D[d],"email",[],!1)})},filter:!0,filterType:"custom",filterList:c.emailSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Email",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[3].options.filterList,"emailSendStatus")}}),update:Oe},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Email",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{webhook:u}=D[d];if(!u)return null;const f=Object.entries(u)[0];if(!f)return null;const[L,K]=f,Z=K[0];return e.jsx(T,{display:"flex",flexDirection:"column",gap:1,children:e.jsxs(T,{className:"webhook-item",fontSize:12,children:[e.jsx(Re,{maxLength:30,children:L},L),e.jsx(ve,{status:Z.status,updatedAt:Z.sendAt,reason:Z.failedReason,channel:"webhook",onResend:Q=>w(Q,D[d],"webhook",[L],!1)})]},L)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:d=>{const{createdAt:u}=D[d];return e.jsx(Ot,{value:u,locale:o,shouldUpdate:!0})}}}],[D,o,c,r]),ne=[e.jsx(rt,{value:c.dateRange,onChange:I},"date-picker"),e.jsx(me,{variant:"contained",size:"small",color:"primary",loading:R,startIcon:e.jsx(Ft,{}),onClick:()=>P(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(T,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(tn,{children:e.jsxs(yt,{theme:y,children:[e.jsx(Rt,{className:"receivers-table",locale:o,loading:R,columns:F,data:D,onChange:U,options:$,customButtons:ne,components:{TableFilterList:d=>e.jsx(ot,{...d,itemComponent:u=>e.jsx(Pe,{...u,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Me,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:pe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(sn,{children:[e.jsxs(ae,{variant:"body1",component:"div",className:"check-title",children:[_==null?void 0:_.channel," Checking"]}),e.jsx(T,{display:"flex",flexDirection:"column",sx:{gap:"4px"},children:le(_==null?void 0:_.channel).map(d=>{var K,Z;const{type:u,pass:f,fail:L}=d;return!(_!=null&&_.result)||(K=_==null?void 0:_.result)!=null&&K[u]?e.jsxs(ae,{variant:"body1",component:"div",className:"check-item",display:"flex",alignItems:"center",sx:{gap:"4px",color:(Z=_==null?void 0:_.result)!=null&&Z[u]?Ae.success.main:"inherit"},children:[_!=null&&_.result?e.jsx(_t,{}):e.jsx(bt,{size:12,sx:{color:Ae.primary.main}}),e.jsx("span",{children:f})]},u):e.jsxs(ae,{variant:"body1",component:"div",display:"flex",alignItems:"center",className:"check-item",sx:{gap:"4px",color:Ae.error.main},children:[e.jsx(kt,{}),e.jsx("span",{children:L})]},u)})})]})}),B.anchorEl&&e.jsx(Me,{open:!!B.anchorEl,anchorReference:"anchorPosition",anchorPosition:B.position,onClose:be,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(lt,{loading:s,onCancel:be,onConfirm:v})})]})})})}const en=C.memo(qt),tn=ue.div`
2
- td.MuiTableCell-footer {
3
- border: none !important;
4
- }
5
- .sent-status-cell {
6
- .resend-btn {
7
- display: none;
8
- }
9
- &:hover {
10
- .resend-btn {
11
- display: flex;
12
- }
13
- }
14
- }
15
- `,sn=ue.div`
16
- padding: 8px 16px;
17
- .check-title {
18
- font-weight: 500;
19
- margin-bottom: 8px;
20
- &::first-letter {
21
- text-transform: uppercase;
22
- }
23
- }
24
- .check-item {
25
- svg {
26
- font-size: 16px;
27
- }
28
- font-size: 12px;
29
- }
30
- `,Ce=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:n;function nn(n){const{wallet:t,push:s,email:r,webhook:o}=n;return[{name:"Wallet",value:e.jsx(he,{item:t})},{name:"Push",value:e.jsx(he,{item:s})},{name:"Email",value:e.jsx(he,{item:r})},...o.total>0?[{name:"Webhook",value:e.jsx(he,{item:o,isWebhook:!0})}]:[]]}function an(n,t,s){const{wallet:r,push:o,email:l,webhook:y}=n;return[{name:"Wallet",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.WALLET,item:r,onResend:t})},{name:"Push",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.PUSH,item:o,onResend:t})},{name:"Email",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.EMAIL,item:l,onResend:t})},...y.total>0?[{name:"Webhook",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.WEBHOOK,item:y,isWebhook:!0,onResend:t})}]:[]]}_e.propTypes={statistics:x.object.isRequired,onResend:x.func,mode:x.oneOf(["simple","detail"]),resending:x.bool};_e.defaultProps={mode:"simple",onResend:()=>{},resending:!1};he.propTypes={item:x.object.isRequired,isWebhook:x.bool};he.defaultProps={isWebhook:!1};function he({item:n,isWebhook:t=!1}){const{t:s}=re(),r=t?n.success.length:n.success,o=n.total,l=r===o?"success":"failed";return e.jsx(T,{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:2,children:e.jsx(T,{display:"flex",alignItems:"center",gap:1,children:e.jsxs(de,{config:{status:l},enableTooltip:!1,children:[Ce(r)," / ",Ce(o)," ",s("notification.sendStatus.success")]})})})}xe.propTypes={item:x.object.isRequired,isWebhook:x.bool,channel:x.string,onResend:x.func,loading:x.bool};xe.defaultProps={isWebhook:!1,channel:W.NOTIFICATION_SEND_CHANNEL.WALLET,onResend:()=>{},loading:!1};function xe({channel:n,item:t,isWebhook:s=!1,onResend:r,loading:o}){const{t:l}=re(),{success:y,failed:p,pending:h}=t,i=Xs(n),A=s?y.length:y,O=s?p.length:p,R=s?h.length:h,S=async B=>{B.stopPropagation();const _=s?[...new Set([...y,...p].map(M=>M))]:[];await r([n],[],!0,_)},D=A+O,G=D>0?A/D*100:0,z=D>0?O/D*100:0;return e.jsxs(rn,{successRatio:G,failedRatio:z,children:[e.jsxs(ae,{variant:"h6",children:[i," (",t.total,")"]}),e.jsxs(ae,{variant:"body1",sx:{mb:2},children:[e.jsx("span",{style:{color:Ye.success,fontWeight:600,fontSize:24},children:Ce(A)}),e.jsx("small",{style:{paddingLeft:4},children:l("notification.sendStatus.success")})]}),e.jsxs(T,{className:"unsent-area",children:[e.jsxs(T,{children:[e.jsxs(de,{config:{status:"failed"},enableTooltip:!1,children:[Ce(O)," ",l("notification.sendStatus.failed")]}),e.jsxs(de,{config:{status:"pending"},enableTooltip:!1,children:[Ce(R)," ",l("notification.sendStatus.pending")]})]}),O>0&&e.jsx(T,{className:"resend-btn",children:e.jsx(me,{size:"small",color:"primary",loading:o,variant:"contained",startIcon:e.jsx(et,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:S,children:l("notification.resend")})})]})]})}function _e({statistics:n,mode:t="simple",onResend:s,resending:r}){const o=ce(()=>t==="simple"?nn(n):an(n,s,r),[n,t]);return t==="simple"?e.jsx("div",{children:o.map(l=>e.jsx(At,{style:{alignItems:"flex-start",marginBottom:t==="simple"?0:16},valueComponent:"div",nameWidth:100,name:l.name,children:l.value},l.name))}):e.jsx(dt,{container:!0,spacing:2,children:o.map(l=>e.jsx(dt,{item:!0,md:4,sm:6,xs:12,children:l.value},l.name))})}const rn=ue(T)`
31
- display: flex;
32
- flex-direction: column;
33
- align-items: flex-start;
34
- padding: 16px;
35
- border-radius: 8px;
36
- background: ${({successRatio:n,failedRatio:t,theme:s})=>n===0&&t===0?s.palette.grey[300]:`linear-gradient(to right, ${Ht(s.palette.success.light,.4)} ${n}%, ${s.palette.grey[100]} ${n}%)`};
37
- transition: 'background 0.5s ease';
38
- cursor: pointer;
39
- .unsent-area {
40
- width: 100%;
41
- position: relative;
42
- .resend-btn {
43
- position: absolute;
44
- right: 0;
45
- bottom: 0;
46
- }
47
- }
48
- `;Mt.propTypes={notification:x.object.isRequired,onCancel:x.func,blocklet:x.object.isRequired,tab:x.string};function Mt({notification:n,onCancel:t=()=>{},blocklet:s,tab:r="info"}){const{t:o,locale:l}=re(),{getComponent:y,resendNotification:p}=tt(),[h,i]=C.useState(!1),A=ce(()=>y(n.componentDid)||s,[s,n.componentDid]),O=Te({tab:r||"info"}),R=C.useCallback(async(c,g,j=!0,N=[])=>{var a;if(!c.length||!n.id)return;const E=g.length>0?g:(a=n==null?void 0:n.receivers)==null?void 0:a.map(m=>m.receiver);if(!E.length)return;let P=[...c];if(P.includes(W.NOTIFICATION_SEND_CHANNEL.PUSH)&&!Wt(s)&&(q.warning(o("notification.sendStatus.reason.unavailable",{channel:"Push Kit"})),P=P.filter(m=>m!==W.NOTIFICATION_SEND_CHANNEL.PUSH)),P.includes(W.NOTIFICATION_SEND_CHANNEL.EMAIL)&&!zt(s)&&(q.warning(o("notification.sendStatus.reason.unavailable",{channel:"Email"})),P=P.filter(m=>m!==W.NOTIFICATION_SEND_CHANNEL.EMAIL)),!!P.length)try{i(!0),await p({notificationId:n.id,receivers:E,channels:P,resendFailedOnly:j,...P.includes("webhook")&&N.length?{webhookUrls:N}:{}}),q.success("Message has been sent!")}catch(m){console.error("handleResend error",{error:m}),q.error(m.response?m.response.statusText:m.message)}finally{i(!1)}},[s,n.id,n==null?void 0:n.receivers,p,o]),S=ce(()=>cs(n),[n]),D=ce(()=>ds(n),[n]),G=ce(()=>S?n==null?void 0:n.actorInfo:[],[n]),z=ce(()=>{var c;return(s==null?void 0:s.did)||((c=s==null?void 0:s.meta)==null?void 0:c.did)||""},[s]);function B(){return[{name:o("notification.from"),value:S&&D?e.jsx(hs,{actors:G,teamDid:z,size:32,showName:!0}):e.jsx(xs,{size:32,blocklet:A,showName:!0,hideDot:!0})},{name:o("notification.notificationTitle"),value:e.jsx(Re,{maxLength:50,children:n.title})},{name:o("notification.body"),value:S?e.jsx(gs,{notification:n,blocklet:s}):e.jsx(bs,{notification:n,rows:0})},{name:o("notification.severity"),value:e.jsx(Ne,{severity:n.severity})},{name:o("notification.createdAt"),value:e.jsx(is,{value:n.createdAt,locale:l,shouldUpdate:!0,type:"all"})}].map(g=>e.jsx(At,{style:{alignItems:"flex-start"},valueComponent:"div",nameWidth:120,name:g.name,children:g.value},g.name))}const _={info:{label:o("common.basicInfo"),value:"info",component:B},receivers:{label:o("notification.receiver"),value:"receivers"},statistics:{label:o("notification.statistics"),value:"statistics"}},M=Object.values(_).map(({label:c,value:g})=>({label:c,value:g})),J=_[O.tab]||_.info,ie=c=>{O.tab=c};return e.jsx(Nt,{title:o("notification.notificationDetails"),fullWidth:!0,maxWidth:"lg",onClose:()=>{O.tab="info",t()},open:!0,actionsPosition:"left",sx:{".ux-dialog_header":{paddingBottom:0},".MuiDialogContent-root":{paddingTop:0}},children:e.jsxs(ln,{children:[e.jsx(T,{mx:3,className:"tabs",children:e.jsx(wt,{tabs:M,current:O.tab,onChange:ie,scrollButtons:"auto"})}),e.jsxs("div",{className:"body",children:[O.tab==="receivers"&&e.jsx(en,{notificationId:n.id,resending:h,handleResend:R}),O.tab==="statistics"&&e.jsx(_e,{statistics:n.statistics,mode:"detail",resending:h,onResend:R}),O.tab==="info"&&e.jsx(J.component,{})]})]})})}const on=C.memo(Mt),ln=ue.div`
49
- & > .notification-row {
50
- padding: 0;
51
- }
52
-
53
- .tabs {
54
- margin: 0;
55
- }
56
- .body {
57
- margin-top: 16px;
58
- }
59
-
60
- .channel-item {
61
- display: flex;
62
- padding: 4px;
63
- justify-content: flex-start;
64
- align-items: center;
65
- gap: 8px;
66
- > p {
67
- font-size: 15px;
68
- }
69
- .resend-btn {
70
- svg {
71
- font-size: 16px;
72
- }
73
- display: flex;
74
- align-items: center;
75
- font-size: 12px;
76
- cursor: pointer;
77
- &.disabled {
78
- cursor: not-allowed;
79
- color: ${Ae.text.disabled};
80
- }
81
- }
82
- }
83
- `;we.propTypes={blocklet:x.object,label:x.string};we.defaultProps={blocklet:null,label:""};const cn=ue.div`
84
- display: flex;
85
- justify-items: flex-start;
86
- align-items: center;
87
- gap: 8px;
88
- .name {
89
- display: block;
90
- max-width: 260px;
91
- white-space: nowrap;
92
- overflow: hidden;
93
- text-overflow: ellipsis;
94
- }
95
- `;function we({blocklet:n,label:t}){var s;return e.jsx(cn,{children:n?e.jsxs(e.Fragment,{children:[e.jsx(Lt,{size:24,blocklet:n,ancestors:n.ancestors}),e.jsx("span",{className:"name",children:n.title||((s=n.meta)==null?void 0:s.title)})]}):e.jsx("span",{className:"name",children:t})})}ct.propTypes={list:x.array.isRequired,label:x.string.isRequired,onDelete:x.func};ct.defaultProps={onDelete:()=>{}};function ct({list:n,label:t,onDelete:s}){return e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(ae,{children:[t,": "]}),n.map(r=>e.jsx(Qe,{size:"small",label:e.jsx(T,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(Ne,{severity:r})}),onDelete:o=>s(o,r)},r))]})}function dn(n){return e.jsx(at,{...n,renderLabel:t=>e.jsx(Ne,{severity:t})})}function un({customTableButtons:n}){var je;const{t,locale:s}=re(),r=jt(),o=C.useMemo(()=>vt(r,Kt()),[r]),[l,y]=C.useState(!1),{data:p,paging:h,blocklet:i,fetch:A,getComponent:O,componentDids:R,inService:S,teamDid:D}=tt(),G=C.useRef(null),[z,B]=C.useState(null),[_,M]=C.useState("info"),J=Cs(),[ie,c]=C.useState(!1),g=`notification-records-${(je=i.meta)==null?void 0:je.did}`,j=as(g),[N,E]=C.useState({pageSize:j.rowsPerPage||10,page:j.page?j.page+1:1,dids:j.dids||[],dateRange:j.dateRange||[se().subtract(1,"month").startOf("day").toDate(),se().endOf("day").toDate()]}),P=ce(()=>{if(!i.children||!i.children.length)return[];const v=[];return i.children.forEach(b=>{var I;const w=b.did||((I=b.meta)==null?void 0:I.did);R.includes(w)&&(b.ancestors=[i],v.push(b))}),v},[R,i]),a=async v=>{try{y(!0),await A(v),y(!1)}finally{y(!1)}};C.useEffect(()=>{a(N)},[N]),C.useEffect(()=>{const v=p.find(b=>b.id===(z==null?void 0:z.id));z&&v&&B({...v})},[p]);const m=(v,b,w,I)=>{v.stopPropagation();const k=w.filter(F=>F!==b);E(F=>({...F,[I]:k,page:1}))},$=({page:v,rowsPerPage:b,filterList:w})=>{const[I=[],,,,k=[]]=w;N.pageSize!==b?E(F=>({...F,pageSize:b,page:1})):N.page!==v+1?E(F=>({...F,page:v+1})):ye(N.dids,I)?ye(N.severities,k)||E(F=>({...F,severities:k,page:1})):E(F=>({...F,dids:I,page:1}))},U=C.useCallback(()=>{B(null),M("info")},[]),oe=C.useCallback(()=>{A(N)},[A,N]),le=[{label:t("notification.from"),name:"sender",width:400,options:{filter:!0,filterType:"custom",customFilterListOptions:{render:v=>v.map((b,w)=>{var k;if(b==="system")return e.jsx("span",{children:t("notification.system")},`system-${w}`);const I=P.find(F=>{var d;return(F.did||((d=F.meta)==null?void 0:d.did))===b});return e.jsx(we,{blocklet:I,label:(I==null?void 0:I.title)||((k=I==null?void 0:I.meta)==null?void 0:k.title)},b)}),update:(v,b,w)=>(v[w].splice(b,1),v)},filterOptions:{names:P,logic:(v,b)=>b.length?!b.includes(v):!1,display:(v,b,w,I)=>e.jsxs(Y,{style:{width:"380px"},children:[e.jsx(Vt,{id:"demo-simple-select-label",style:{background:"#ffffff"},children:"Sender"}),e.jsxs(Yt,{multiple:!0,value:v[w],renderValue:k=>e.jsx(T,{display:"flex",gap:1,alignItems:"center",style:{overflow:"hidden",textOverflow:"ellipsis"},children:k.map(F=>{var d;if(F==="system")return e.jsx("span",{children:t("notification.system")},F);const ne=P.find(u=>{var L;return(u.did||((L=u.meta)==null?void 0:L.did))===F});return e.jsx(we,{blocklet:ne,label:(ne==null?void 0:ne.title)||((d=ne==null?void 0:ne.meta)==null?void 0:d.title)},F)})}),onChange:k=>{v[w]=k.target.value,b(v[w],w,I)},children:[e.jsx(ut,{value:"system",children:t("notification.system")}),P.map(k=>{var ne,d;const F=k.did||((ne=k.meta)==null?void 0:ne.did);return e.jsx(ut,{value:F,children:e.jsx(we,{blocklet:k,label:k.title||((d=k.meta)==null?void 0:d.title)})},F)})]})]})},customBodyRenderLite:v=>{var I,k;const b=p[v],w=O(b.componentDid);return e.jsxs(T,{display:"flex",alignItems:"center",gap:1,children:[w?e.jsx(Lt,{size:32,blocklet:w,ancestors:w.ancestors??[]}):e.jsx(js,{blocklet:i,size:32}),e.jsx(Re,{maxLength:50,children:((I=w==null?void 0:w.meta)==null?void 0:I.title)||((k=i==null?void 0:i.meta)==null?void 0:k.title)})]})}}},{label:t("notification.receiver"),name:"receivers",width:300,options:{filter:!1,customBodyRenderLite:v=>{const b=p[v],{receivers:w}=b;return e.jsx(Gt,{total:w.length,renderSurplus:I=>I<100?e.jsxs("span",{children:["+",I]}):e.jsx("span",{children:"99+"}),max:3,sx:{justifyContent:"flex-end",height:"32px",".MuiAvatar-root":{width:"32px",height:"32px",fontSize:"12px",border:0,zIndex:2}},onClick:I=>{I.stopPropagation(),B(b),M("receivers")},children:w.map(I=>{const{receiverUser:k}=I,F=Dt(k.avatar,D,S);return e.jsx(Tt,{alt:k.fullName,src:`${F}?imageFilter=resize&w=48&h=48`,size:32,did:I.receiver,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}},I.receiver)})})}}},{label:t("notification.statistics"),name:"statistics",width:400,options:{filter:!1,customBodyRenderLite:v=>{const b=p[v];return e.jsx(T,{onClick:w=>{w.stopPropagation(),B(b),M("statistics")},children:e.jsx(_e,{statistics:b.statistics})})}}},{label:t("notification.notificationPreview"),name:"data",options:{filter:!1,customBodyRenderLite:v=>{const b=p[v];return e.jsx(Re,{maxLength:50,children:b.title})}}},{label:t("notification.severity"),name:"severity",width:200,options:{setCellProps:()=>({className:"severity-cell"}),customBodyRenderLite:v=>{const b=p[v];return e.jsx(Ne,{severity:b.severity})},filter:!0,filterType:"custom",filterList:N.severities??[],customFilterListOptions:{render:v=>e.jsx(ct,{list:v,label:t("notification.severity"),onDelete:(b,w)=>{b.stopPropagation(),m(b,w,le[4].options.filterList,"severities")}}),update:Oe},filterOptions:{names:mt,fullWidth:!0,logic:De,display:(v,b,w,I)=>e.jsx(dn,{label:t("notification.severity"),filterList:v,onChange:b,index:w,column:I,filterValues:mt})}}},{label:t("common.createdAt"),name:"createdAt",width:300,options:{filter:!1,customBodyRenderLite:v=>{const{createdAt:b}=p[v];return e.jsx(Ot,{value:b,locale:s,shouldUpdate:!0})}}}],pe=v=>{E(b=>({...b,dateRange:v,page:1}))},be=[e.jsxs(T,{display:"flex",alignItems:"center",gap:1.5,children:[e.jsx(Jt,{onClick:()=>c(!0),sx:{p:J?0:void 0},children:e.jsx(os,{})},"settings"),J?e.jsx(ae,{children:t("common.setting")}):null]}),...n||[]];return e.jsxs(T,{ref:G,sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:[e.jsx(pn,{children:e.jsx(yt,{theme:o,children:e.jsx(Rt,{className:"main-table",verticalKeyWidth:100,loading:l,locale:s,columns:le,data:p,durable:g,onChange:$,options:{sort:!1,download:!1,print:!1,search:!1,expandableRowsOnClick:!0,page:h.page-1,rowsPerPage:h.pageSize,count:h.total,...j,onRowClick:(v,{dataIndex:b})=>{B(p[b])}},customPreButtons:[e.jsx(rt,{value:N.dateRange,onChange:pe})],customButtons:be,components:{TableFilterList:v=>e.jsx(ot,{...v,itemComponent:b=>e.jsx(Pe,{...b,canDelete:w=>{var k;const I=(k=w==null?void 0:w.columnNames)==null?void 0:k[(w==null?void 0:w.index)||0];return(I==null?void 0:I.name)==="sender"}})})}})})}),z&&e.jsx(on,{refresh:oe,onCancel:U,notification:z,blocklet:i,tab:_}),e.jsx(Nt,{title:`${t("common.notification")} ${t("common.setting")}`,fullWidth:!0,maxWidth:"md",open:ie,onClose:()=>c(!1),PaperProps:{style:{minHeight:"500px"}},children:e.jsx(T,{sx:{mt:"-16px",overflowY:"hidden"},children:e.jsx(Ds,{})})})]})}const pn=ue.div`
96
- td.MuiTableCell-footer {
97
- border: none !important;
98
- }
99
- .sent-status-cell {
100
- .resend-btn {
101
- display: none;
102
- }
103
- &:hover {
104
- .resend-btn {
105
- display: flex;
106
- }
107
- }
108
- }
109
-
110
- .custom-toobar-btns {
111
- gap: 4px;
112
- }
113
- `;$t.propTypes={blocklet:x.object.isRequired,customTableButtons:x.array};$t.defaultProps={customTableButtons:[]};function $t({blocklet:n={},customTableButtons:t}){return e.jsx(Ps,{blocklet:n,children:e.jsx(un,{customTableButtons:t})})}export{$t as default};
@@ -1 +0,0 @@
1
- import{a as B,Z as q,bN as U,I as ge,bO as fe,a0 as je,a7 as ye,bu as we}from"./vendor-ux-did-connect-DROQhYpS.js";import{t as ke,l as de,j as Ee}from"./vendor-hooks-BgUTpb6X.js";import{r as T,b as Q}from"./vendor-react-DEoibe3W.js";import{d as X}from"./InfoOutlined-Duq1UDPu.js";import{j as ve,O as Ce}from"./vendor-arcblock-5qqHEVGo.js";import{D as F,aA as Se,aB as K,G as pe,y as Te}from"./index-DJzuhKQh.js";import{u as _}from"./dashboard-vkFEu-wZ.js";import{u as Re}from"./use-mobile-BAa0wi8o.js";import{H as t,j as e,D as Ie,aj as ze,t as De,aa as m,O as re,T as R,ab as M,ak as Z,z as Pe,y as H,bs as le,bR as Y,ad as $,L as J,A as G,bc as Oe,E as L,I as ee,C as Ae,bq as We,al as D,cg as qe,X as $e,bb as V,bp as Le,b4 as Be,ch as Me,ci as He,b5 as Ne,an as Fe,c0 as _e,s as ue,v as Ue,cj as Ke,ck as Ye,cl as Ve,cm as Je}from"./vendor-mui-core-BV2FUxWJ.js";import{d as Ge}from"./ExpandLess-EFI-Ij5Y.js";import{b as he,z as Qe,A as Xe}from"./vendor-utils-rHXShPKm.js";import{C as Ze}from"./confirm-CiiHIA-a.js";import{A as et}from"./actions-BA8hCarh.js";import{T as ae}from"./table-tips-biAHyN1z.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-BDA4jbwL.js";import"./index-8eXqqyHQ.js";import"./PlayArrow-Cv1uXXJt.js";import"./get-safe-url-CiQ8_q49.js";import"./session-ugMCR4Iu.js";import"./use-blocklet-logo-a8QJI4r-.js";import"./dot-DX56IFTM.js";import"./useAsync-Dv214fz8.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-C21X4TYN.js";import"./MoreHoriz-jwSUI8G2.js";const tt=o=>{var f,w;const[p,u]=T.useState(null),[E,s]=T.useState(!o),[I,c]=T.useState(null),{blocklet:a}=pe(),d=(w=(f=a==null?void 0:a.site)==null?void 0:f.domainAliases[0])==null?void 0:w.value,j=T.useMemo(()=>{const b={};return p&&(p.sources.forEach(l=>{b[l.did]={source:l,events:[],count:0}}),p.events.forEach(l=>{b[l.source]&&(b[l.source].events.push(l),b[l.source].count+=1)})),b},[p]),y=async()=>{try{if(s(!0),!d)return;const l=await(await fetch(`https://${d}/.well-known/service/openevent.json`)).json();u(l),c(null)}catch(b){c(b instanceof Error?b:new Error(String(b)))}finally{s(!1)}};return T.useEffect(()=>{y()},[d]),{openEvent:p,setOpenEvent:u,eventsBySource:j,loading:E,error:I,loadData:y}};function te({eventsBySource:o,selectedEvents:p,setSelectedEvents:u,error:E}){const{t:s}=B(),[I,c]=T.useState({}),a=T.useMemo(()=>{const l={};return Object.entries(o).forEach(([g,{events:h}])=>{const S=h.filter(x=>p[`${x.type}-${x.source}`]).length;l[g]=S}),l},[o,p]),d=T.useMemo(()=>Object.values(a).reduce((l,g)=>l+g,0),[a]),j=T.useMemo(()=>Object.values(o).reduce((l,{events:g})=>l+g.length,0),[o]),y=(l,g)=>{g.stopPropagation(),c({...I,[l]:!I[l]})},f=l=>{const g=`${l.type}-${l.source}`;u(h=>({...h,[g]:!h[g]}))},w=(l,g)=>{const h={};l.forEach(S=>{const x=`${S.type}-${S.source}`;h[x]=!g}),u(S=>({...S,...h}))},b=l=>{const g={};Object.values(o).forEach(({events:h})=>{h.forEach(S=>{const x=`${S.type}-${S.source}`;g[x]=l.target.checked})}),u(g)};return e.jsxs(m,{sx:{width:"100%"},children:[e.jsxs(m,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(le,{control:e.jsx(Y,{onChange:b,checked:d>0&&d===j}),label:e.jsxs(m,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[s("webhookEndpoint.selectAllEvents"),e.jsx(m,{sx:{display:"flex",alignItems:"center"},children:e.jsx($,{title:s("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(X,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),d>0&&e.jsx(R,{variant:"body2",color:"primary",sx:{ml:"auto"},children:s("webhookEndpoint.selectedEventsCount",{count:d})})]}),e.jsx(m,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(J,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:"4px"},children:Object.entries(o).map(([l,{source:g,events:h,count:S}],x)=>{const z=a[l]>0,k=a[l]===h.length&&h.length>0,O=I[l];return e.jsxs(Q.Fragment,{children:[e.jsx(G,{sx:{borderBottom:({palette:i})=>x<Object.keys(o).length-1?`1px solid ${i.divider}`:"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(m,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:i=>{i.target.closest(".MuiFormControlLabel-root")||y(l,i)},children:[e.jsx(m,{sx:{display:"flex",alignItems:"center"},children:h.length>0&&e.jsx(le,{control:e.jsx(Y,{checked:k,indeterminate:z&&!k,onChange:i=>{i.stopPropagation(),w(h,k)}}),label:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[g.logo&&e.jsx(Oe,{src:g.logo,sx:{width:24,height:24}}),e.jsx(m,{children:g.title||l}),z&&e.jsx(L,{label:s("webhookEndpoint.selectedCount",{count:a[l]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:i=>`${i.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(m,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(R,{variant:"body2",color:"text.secondary",sx:{mr:1},children:s("webhookEndpoint.eventsCount",{count:S})}),h.length>0&&e.jsx(ee,{size:"small",edge:"end",children:O?e.jsx(Ge,{}):e.jsx(ve,{})})]})]})}),h.length>0&&e.jsx(Ae,{in:O,timeout:"auto",unmountOnExit:!0,children:e.jsx(J,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:h.map(i=>{const r=`${i.type}-${i.source}`,n=!!p[r];return e.jsx(G,{dense:!0,sx:{py:.75},onClick:()=>f(i),children:e.jsxs(m,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(Y,{checked:n,sx:{mr:1}}),e.jsxs(m,{children:[e.jsx(R,{variant:"body1",sx:{cursor:"pointer"},children:i.type}),e.jsx(R,{variant:"caption",color:"text.disabled",sx:{display:"block",cursor:"pointer"},children:i.description})]})]})},r)})})})]},l)})})}),E&&e.jsx(We,{error:!0,sx:{mt:1},children:E})]})}te.propTypes={eventsBySource:t.objectOf(t.shape({source:t.shape({did:t.string.isRequired,title:t.string,description:t.string,version:t.string,logo:t.string}).isRequired,events:t.arrayOf(t.shape({type:t.string.isRequired,description:t.string.isRequired,source:t.string.isRequired})).isRequired,count:t.number.isRequired})).isRequired,selectedEvents:t.objectOf(t.bool).isRequired,setSelectedEvents:t.func.isRequired,error:t.string};te.defaultProps={error:null};function oe({id:o,url:p,description:u,enabledEvents:E,onSubmit:s,onClose:I}){var i;const{t:c}=B(),[a,d]=T.useState({}),{teamDid:j}=_(),{api:y}=F(),{loading:f,error:w,eventsBySource:b}=tt(),{control:l,handleSubmit:g,formState:{errors:h},reset:S,setValue:x,trigger:z}=Se({defaultValues:{url:"",description:""}});T.useEffect(()=>{const r=Object.values(a).some(n=>n);x("selectedEvents",r?"valid":""),z("selectedEvents")},[a,x,z]);const k=()=>{d({}),S(),I()},O=async r=>{const n=Object.keys(a).filter(v=>a[v]),C={url:r.url,description:r.description,enabledEvents:n.map(v=>{const[P,W]=v.split("-");return!P||!W?null:{type:P,source:W}}).filter(Boolean)};try{if(o){const v=await y.updateWebhookEndpoint({input:{teamDid:j,id:o,data:C}});q.success(`${c("webhookEndpoint.updateWebhook")} ${c("webhookEndpoint.success")}`),s(v)}else{const v=await y.createWebhookEndpoint({input:{teamDid:j,input:C}});q.success(`${c("webhookEndpoint.createWebhook")} ${c("webhookEndpoint.success")}`),s(v)}}catch(v){q.error(v==null?void 0:v.message)}k()};return T.useEffect(()=>{S({url:p,description:u}),d(E.reduce((r,n)=>(r[`${n.type}-${n.source}`]=!0,r),{}))},[S,d,p,u,E]),e.jsx(Ie,{open:!0,onClose:k,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:g(O),children:[e.jsx(ze,{children:c(o?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(De,{children:e.jsxs(m,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(K,{name:"url",control:l,rules:{required:c("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:c("webhookEndpoint.validation.urlInvalid")}},render:({field:r})=>{var n;return e.jsx(re,{...r,label:c("webhookEndpoint.url.label"),fullWidth:!0,error:!!h.url,helperText:(n=h.url)==null?void 0:n.message})}}),e.jsx(K,{name:"description",control:l,rules:{required:c("webhookEndpoint.validation.descriptionRequired")},render:({field:r})=>{var n;return e.jsx(re,{...r,label:c("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!h.description,helperText:(n=h.description)==null?void 0:n.message})}}),e.jsx(K,{name:"selectedEvents",control:l,rules:{required:c("webhookEndpoint.validation.eventRequired")},render:({field:r})=>e.jsx("input",{type:"hidden",...r})}),!f&&b&&Object.keys(b).length>0&&e.jsx(te,{eventsBySource:b,selectedEvents:a,setSelectedEvents:d,error:(i=h.selectedEvents)==null?void 0:i.message}),!f&&(!b||Object.keys(b).length===0)&&e.jsx(R,{color:"text.secondary",children:c("webhookEndpoint.noAvailableEvents")}),f&&e.jsx(m,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(M,{size:20})}),w&&e.jsx(Z,{severity:"error",children:c("webhookEndpoint.loadingError",{message:w==null?void 0:w.message})})]})}),e.jsxs(Pe,{sx:{p:"8px 24px 24px"},children:[e.jsx(H,{onClick:k,children:c("common.cancel")}),e.jsx(H,{type:"submit",variant:"contained",color:"primary",children:c(o?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}oe.propTypes={onSubmit:t.func.isRequired,id:t.string,url:t.string,description:t.string,enabledEvents:t.arrayOf(t.shape({type:t.string.isRequired,source:t.string.isRequired})),onClose:t.func};oe.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function xe(o){switch(o){case"enabled":return"success";case"disabled":default:return"default"}}const ot=(o="en")=>o==="tw"?"zh":o;function N(o,p="YYYY-MM-DD HH:mm:ss",u="en"){return o?Te(o).locale(ot(u)).format(p):"-"}function st(o){return typeof o=="number"?!1:he(o)}function nt(o){return o>=200&&o<300}function A(o){const p=st(o.value);return e.jsxs(e.Fragment,{children:[e.jsxs(D,{direction:"column",alignItems:"flex-start",children:[e.jsxs(R,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[o.label,!!o.tip&&e.jsx($,{title:o.tip,children:e.jsx(qe,{fontSize:"small"})})]}),e.jsx(R,{component:"div",variant:"body1",color:p?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:p?"-":o.value})]}),o.divider&&e.jsx($e,{orientation:"vertical",flexItem:!0})]})}A.propTypes={label:t.oneOfType([t.string,t.node]).isRequired,value:t.oneOfType([t.string,t.node]).isRequired,tip:t.oneOfType([t.string,t.node]),divider:t.bool};A.defaultProps={tip:"",divider:!1};function se(o){return e.jsxs(D,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:o.mb,mt:o.mt,pb:1},children:[e.jsx(R,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:o.title}),o.children]})}se.propTypes={title:t.oneOfType([t.string,t.node]).isRequired,children:t.node,mb:t.number,mt:t.number};se.defaultProps={children:null,mb:1.5,mt:1.5};const it=o=>{const p={};return o.forEach(u=>{var s;const E=new Date(u.createdAt).toLocaleDateString();p[E]||(p[E]=[]),(s=p[E])==null||s.push(u)}),p};function ne({eventId:o,webhookEndpointId:p,event:u}){const{api:E}=F(),{t:s}=B(),{teamDid:I}=_(),{blocklet:c}=pe(),{data:a,loadMore:d,loadingMore:j,loading:y}=ke(x=>{const k=x?Math.ceil(x.list.length/15)+1:1;return E.getWebhookAttempts({input:{teamDid:I,input:{eventId:o,webhookId:p},paging:{page:k,pageSize:15}}})},{reloadDeps:[o,p]}),f=(a==null?void 0:a.list)||[],[w,b]=T.useState(null),l=it(f);T.useEffect(()=>{!w&&(a!=null&&a.list.length)&&b(a.list[0])},[a==null?void 0:a.list.length,w]);const g=x=>{b(x)};if(y)return e.jsx(M,{});const h=a&&a.list.length<a.paging.total,S=x=>{var z,k,O,i,r;if(x.responseBody&&((z=x.responseBody)!=null&&z.sessionId)&&((k=x.responseBody)!=null&&k.projectId)&&((O=x.responseBody)!=null&&O.agentId)){const n=(r=(i=c==null?void 0:c.site)==null?void 0:i.domainAliases[0])==null?void 0:r.value,C=(c.children||[]).find(P=>{var W;return((W=P==null?void 0:P.meta)==null?void 0:W.name)==="ai-studio"}),v=Qe(Xe(`https://${n}`,(C==null?void 0:C.mountPoint)||"","projects",x.responseBody.projectId,"logs/main"),{sessionId:x.responseBody.sessionId,agentId:x.responseBody.agentId});return e.jsx(ee,{sx:{fontSize:20},onClick:()=>window.open(v,"_blank"),children:e.jsx(m,{component:ge,icon:fe})})}return null};return e.jsxs(V,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(V,{item:!0,xs:12,md:4,height:1,children:he(Object.keys(l))?e.jsx(R,{color:"text.secondary",children:s("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(J,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(l).map(([x,z])=>e.jsxs(Q.Fragment,{children:[e.jsx(Le,{children:x}),z.map(k=>e.jsxs(G,{sx:{cursor:"pointer"},onClick:()=>g(k),selected:w===k,secondaryAction:e.jsx(R,{color:"text.secondary",children:N(k.createdAt,"HH:mm:ss")}),children:[e.jsx(Be,{sx:{minWidth:0,mr:1.5},children:nt(k.responseStatus)===!1?e.jsx(Me,{color:"error"}):e.jsx(He,{color:"success"})}),e.jsx(Ne,{primary:e.jsx(R,{color:"text.primary",children:k.event.type})})]},k.id))]},x))}),h&&e.jsx(m,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(H,{variant:"text",type:"button",color:"inherit",onClick:d,disabled:j,sx:{color:x=>x.palette.text.disabled},children:s(j?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(V,{item:!0,xs:12,md:8,height:1,children:[w&&e.jsxs(D,{height:1,overflow:"auto",direction:"column",spacing:2,sx:{pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(R,{variant:"h6",children:o?w.endpoint.url:w.event.type}),e.jsx(m,{children:S(w)})]}),e.jsxs(m,{children:[e.jsxs(R,{variant:"h6",children:[s("webhookEndpoint.response")," (",w.responseStatus,")"]}),e.jsx(U,{language:"json",children:JSON.stringify(w.responseBody,null,2)})]}),e.jsxs(m,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(R,{variant:"h6",children:s("webhookEndpoint.request")})}),e.jsx(U,{language:"json",sx:{margin:0},children:JSON.stringify(w.event,null,2)})]})]}),(a==null?void 0:a.list.length)===0&&u&&e.jsxs(m,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(R,{variant:"h6",children:s("webhookEndpoint.eventData")})}),e.jsx(U,{language:"json",sx:{margin:0},children:JSON.stringify(u.data,null,2)})]})]})]})}ne.propTypes={eventId:t.string,webhookEndpointId:t.string,event:t.shape({type:t.string,data:t.object,request:t.object,requestInfo:t.object})};ne.defaultProps={eventId:"",webhookEndpointId:"",event:null};function me({id:o,onClose:p}){var j,y,f,w;const{t:u}=B(),{api:E}=F(),{teamDid:s}=_(),{loading:I,error:c,data:a}=de(()=>E.getWebhookEndpoint({input:{teamDid:s,id:o}})),d=a==null?void 0:a.data;return c?e.jsx(Z,{severity:"error",children:c.message}):I||!d?e.jsx(m,{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1,children:e.jsx(M,{})}):e.jsxs(rt,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(m,{children:[e.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(D,{flex:1,width:0,children:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(R,{variant:"h5",fontWeight:600,sx:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:d.description}),e.jsx($,{title:d.url,children:e.jsx(X,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(D,{direction:"row",alignItems:"center",children:e.jsx(ee,{edge:"end",color:"inherit",onClick:p,children:e.jsx(_e,{})})})]}),e.jsx(m,{mt:2,children:e.jsxs(D,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},justifyContent:"flex-start",flexWrap:"wrap",sx:{pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx(A,{label:u("common.status"),value:e.jsx(L,{size:"small",variant:"filled",label:d.status,color:xe(d.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx(A,{label:u("webhookEndpoint.listen"),value:e.jsx($,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:d.enabledEvents.map(b=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:b==null?void 0:b.type},b))}),children:e.jsx(L,{size:"small",variant:"filled",label:u("webhookEndpoint.eventsCount",{count:d.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(A,{label:u("webhookEndpoint.version"),value:d.apiVersion,divider:!0}),e.jsx(A,{label:u("common.createdAt"),value:N(d.createdAt),divider:!0}),e.jsx(A,{label:u("common.updatedAt"),value:N(d.updatedAt),divider:!0}),e.jsx(A,{label:u("common.createdBy"),value:e.jsx($,{arrow:!0,title:(j=d.createUser)==null?void 0:j.did,children:e.jsx(L,{size:"small",variant:"filled",label:(y=d.createUser)==null?void 0:y.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(A,{label:u("common.updatedBy"),value:e.jsx($,{arrow:!0,title:(f=d.updateUser)==null?void 0:f.did,children:e.jsx(L,{size:"small",variant:"filled",label:(w=d.updateUser)==null?void 0:w.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(D,{className:"section",flex:1,height:0,overflow:"hidden",children:[e.jsx(se,{title:u("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(D,{height:0,flex:1,overflow:"hidden",children:e.jsx(ne,{webhookEndpointId:d.id})})]})]})}me.propTypes={id:t.string.isRequired,onClose:t.func.isRequired};const rt=ue(D)``;function be({open:o,onClose:p,id:u}){return e.jsx(Fe,{anchor:"right",open:o,onClose:p,PaperProps:{sx:{width:"90vw",maxWidth:"1200px"}},children:e.jsx(m,{sx:{height:"100vh",p:3},children:e.jsx(me,{id:u,onClose:p})})})}be.propTypes={open:t.bool.isRequired,onClose:t.func.isRequired,id:t.string.isRequired};function ce(){return null}const ie=Q.memo(({options:o,columns:p,toolbar:u=!0,footer:E=!0,hasRowLink:s=!1,emptyNodeText:I="",...c})=>{const{locale:a}=B(),d=Ue(f=>f.breakpoints.down("md")),j={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:d?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},y={};return u||(y.TableToolbar=ce),E||(y.TableFooter=ce),e.jsx(lt,{locale:a,options:{...j,...o},columns:(p||[]).map(f=>(f.options=f.options||{},f.options.filter=f.options.filter||!1,f.options.sort=f.options.sort||!1,f)),emptyNode:e.jsx(je,{children:I}),...c,components:y,hasRowLink:s,isMobile:d})});ie.propTypes={options:t.object,columns:t.array,toolbar:t.bool,footer:t.bool,hasRowLink:t.bool,emptyNodeText:t.node,durable:t.string,durableKeys:t.array,data:t.array,loading:t.bool,onChange:t.func,title:t.node,components:t.object};ie.defaultProps={options:{},columns:[],toolbar:!0,footer:!0,hasRowLink:!1,emptyNodeText:null,durable:"",durableKeys:[],data:[],loading:!1,onChange:()=>{},title:null,components:{}};const lt=ue(ye)``,at=ie;function Wt(){const{teamDid:o}=_(),p=Re(),u=`webhook-endpoints-${o}`,E=we(u),{t:s,locale:I}=B(),{api:c}=F(),[a,d]=T.useState(""),[j,y]=T.useState({webhookDetail:{open:!1,id:null},createEdit:{open:!1,id:null,url:"",description:"",enabledEvents:[]},deleteConfirm:null}),[f,w]=Ee(u,{defaultValue:{pageSize:E.rowsPerPage||20,page:E.page?E.page+1:1}}),{loading:b,error:l,data:g,refresh:h}=de(()=>c.getWebhookEndpoints({input:{teamDid:o,paging:{page:f.page,pageSize:f.pageSize}}}));T.useEffect(()=>{h()},[f,h]);const S=T.useCallback(async(i,r)=>{try{await c.updateWebhookEndpoint({input:{teamDid:o,id:i.id,data:{status:r?"disabled":"enabled"}}}),h(),q.success(`${s(r?"webhookEndpoint.disable":"webhookEndpoint.enable")}${s("webhookEndpoint.success")}`)}catch(n){q.error(n==null?void 0:n.message)}},[c,o,h,s]),x=T.useCallback(async i=>{try{await c.deleteWebhookEndpoint({input:{teamDid:o,id:i}}),h(),y(r=>({...r,deleteConfirm:null})),q.success(`${s("common.delete")}${s("webhookEndpoint.success")}`)}catch(r){q.error(r==null?void 0:r.message)}},[c,o,h,s]),z=(i,r)=>{let n=i.page+1;const C=i.searchText||"";if(C!==a){d(C);return}if(r==="changePage"||r==="changeRowsPerPage"){r!=="changePage"&&(n=1);const v={page:n,pageSize:i.rowsPerPage};d(""),w(v)}};if(l)return e.jsx(Z,{severity:"error",children:l.message});if(b||!g)return e.jsx(m,{display:"flex",justifyContent:"center",alignItems:"center",width:1,height:500,children:e.jsx(M,{})});const k=((g==null?void 0:g.list)||[]).filter(i=>{if(!a)return!0;const r=a.toLowerCase();return i.description.toLowerCase().includes(r)||i.url.toLowerCase().includes(r)}),O=[{label:"URL",name:"url",options:{customBodyRenderLite:(i,r)=>{const n=k[r];return e.jsxs(m,{sx:{display:"flex",alignItems:"center",cursor:"pointer",gap:.5},children:[e.jsx(R,{variant:"body2",children:n.description}),e.jsx(m,{sx:{display:"flex"},onClick:C=>{C.stopPropagation()},children:e.jsx($,{title:n.url,children:e.jsx(X,{sx:{fontSize:"15px",marginTop:"1px"}})})})]})}}},{label:"Events",name:"events",options:{customBodyRenderLite:(i,r)=>{const n=k[r];return e.jsx(m,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:n.enabledEvents.map(C=>e.jsx(L,{size:"small",variant:"filled",label:C.type,sx:{borderRadius:"4px",textTransform:"capitalize"}},`${n.source}-${C.type}`))})}}},{label:s("common.status"),name:"status",options:{customBodyRenderLite:(i,r)=>{const n=k[r];return e.jsx(L,{size:"small",variant:"filled",label:s(`webhookEndpoint.${n==null?void 0:n.status}`),color:xe(n==null?void 0:n.status),sx:{borderRadius:"4px",textTransform:"capitalize"}},`status-${n.status}`)}}},{label:s("common.createdAt"),name:"createdAt",minWidth:200,options:{customBodyRender:i=>N(i)}},{label:s("common.actions"),name:"actions",width:100,align:"center",verticalKeyAlign:"center",options:{customBodyRenderLite:(i,r)=>{const n=k[r],C=(n==null?void 0:n.status)==="enabled";return e.jsx(et,{actions:[{icon:C?e.jsx(Ke,{}):e.jsx(Ye,{}),text:s(C?"webhookEndpoint.disable":"webhookEndpoint.enable"),onClick:v=>{v.stopPropagation(),S(n,C)}},{icon:e.jsx(Ve,{}),text:s("common.edit"),onClick:v=>{v.stopPropagation(),y(P=>({...P,createEdit:{open:!0,id:n.id,url:n.url,description:n.description,enabledEvents:n.enabledEvents}}))}},{icon:e.jsx(Je,{}),text:s("common.delete"),onClick:v=>{v.stopPropagation(),y(P=>({...P,deleteConfirm:{title:s("webhookEndpoint.deleteWebhook.title"),description:s("webhookEndpoint.deleteWebhook.description"),confirm:s("common.confirm"),cancel:s("common.cancel"),onConfirm:()=>x(n.id),onCancel:()=>y(W=>({...W,deleteConfirm:null}))}}))}}]})}}}];return e.jsxs(m,{sx:{".custom-toobar-btns":{gap:"8px"},".custom-toobar-title .custom-toobar-title-inner>span":{display:"flex",alignItems:"center","white-space":"inherit",height:"100%"}},children:[p?e.jsx(ae,{title:s("webhookEndpoint.listTitle"),tooltipTitle:s("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${I}/webhook`}):null,e.jsx(at,{durable:u,durableKeys:["page","rowsPerPage"],data:k,columns:O,options:{count:g.count,page:f.page-1,rowsPerPage:f.pageSize,viewColumns:!1,onRowClick:(i,{dataIndex:r})=>{const n=g.list[r];y(C=>({...C,webhookDetail:{open:!0,id:n.id}}))}},loading:b,onChange:z,emptyNodeText:e.jsx(D,{gap:1,children:s("webhookEndpoint.noWebhooksAdded")}),title:p?null:e.jsx(ae,{title:s("webhookEndpoint.listTitle"),tooltipTitle:s("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${I}/webhook`}),customButtons:[e.jsxs(H,{sx:{color:"common.white"},edge:"end",variant:"contained",color:"primary",onClick:()=>y(i=>({...i,createEdit:{...i.createEdit,open:!0}})),className:"rule-action",children:[b?e.jsx(M,{size:16}):e.jsx(Ce,{style:{fontSize:16}}),s("common.create")]},"add")]}),j.webhookDetail.open&&e.jsx(be,{open:!0,onClose:()=>y(i=>({...i,webhookDetail:{open:!1,id:null}})),id:j.webhookDetail.id}),j.createEdit.open&&e.jsx(oe,{onSubmit:h,...j.createEdit,onClose:()=>y(i=>({...i,createEdit:{id:null,url:"",description:"",enabledEvents:[],open:!1}}))}),j.deleteConfirm&&e.jsx(Ze,{title:j.deleteConfirm.title,description:j.deleteConfirm.description,confirm:j.deleteConfirm.confirm,cancel:j.deleteConfirm.cancel,params:j.deleteConfirm.params,onConfirm:j.deleteConfirm.onConfirm,onCancel:j.deleteConfirm.onCancel})]})}export{Wt as default};
@@ -1 +0,0 @@
1
- import{j as i,aa as g}from"./vendor-mui-core-BV2FUxWJ.js";import{f as x,r as v}from"./vendor-react-DEoibe3W.js";import{u}from"./vendor-hooks-BgUTpb6X.js";import{I as w}from"./invitation-CbZcjplG.js";import{L as I}from"./landing-page-B3KyXZXw.js";import{a as S,aT as T,j}from"./vendor-ux-did-connect-DROQhYpS.js";import{H as P}from"./vendor-arcblock-5qqHEVGo.js";import{g as k}from"./get-safe-url-DSt3eVbO.js";import{u as E,d as L,c as R,s as W,a as C}from"./index-DJzuhKQh.js";import"./vendor-utils-rHXShPKm.js";import"./use-passport-id-B-b-_oYF.js";import"./session-ugMCR4Iu.js";import"./sdk-Bxy9kDUo.js";import"./CheckCircle-DsdIIzds.js";import"./wrap-locale-CvN5krOj.js";import"./lottie-web-jYmAQWuC.js";function y(c){var r;const m=x(),{searchParams:s}=new URL(window.location.href),{api:p,session:d}=E(),{t:f}=S(),a=s.get("inviteId"),n=s.get("redirect"),h=v.useCallback(async()=>{const{data:t}=await L.get("invitation",{params:{inviteId:a}});return t},[a]),l=u(async(t,o=e=>e)=>{t&&(W(o(t.sessionToken)),C(o(t.refreshToken)),t.visitorId&&T(o(t.visitorId))),await d.refresh(),setTimeout(()=>{if(n){const e=decodeURIComponent(n);e.startsWith(j.WELLKNOWN_SERVICE_PATH_PREFIX)?m(e,{replace:!0}):window.location.href=k(e)}else window.location.href=window.env.pathPrefix||"/"},50)});return i.jsxs(I,{did:(r=window.blocklet)==null?void 0:r.appPid,children:[i.jsx(P,{children:i.jsx("title",{children:f("pageTitle.invite")})}),i.jsx(g,{sx:{width:"560px",maxWidth:"100%",height:"100%"},className:"page-invite",children:i.jsx(w,{...c,getDataFn:h,checkFn:p.get,createPassportSvg:t=>R({...t}),onLoginSuccess:l,inService:!0})})]})}export{y as default};