@abtnode/blocklet-services 1.17.6-beta-20251216-081847-bf91c4db → 1.17.6-beta-20251216-223535-283b9ffe
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.
- package/api/emails/_components/compose.js +1 -1
- package/api/libs/connect/session.js +1 -1
- package/api/routes/blocklet.js +2 -0
- package/api/services/auth/session.js +9 -6
- package/dist/assets/{AdapterDayjs-Bfr4sW4C.js → AdapterDayjs-DqOr9LFk.js} +1 -1
- package/dist/assets/{Google-DA3WTnLE.js → Google-CQ1n6aSx.js} +1 -1
- package/dist/assets/{access-control-BZvc7AZG.js → access-control-LXesuJ2_.js} +1 -1
- package/dist/assets/{add-component-core-CNH5E2RR.js → add-component-core-L7bwC_64.js} +1 -1
- package/dist/assets/{add-resource-BWEvlWkH.js → add-resource-DeMXdPX_.js} +1 -1
- package/dist/assets/{addon-uM70Qwac.js → addon-kaBWGHOu.js} +1 -1
- package/dist/assets/{advanced-Caeqx4XB.js → advanced-DOrtiTqV.js} +1 -1
- package/dist/assets/{aigne-B9drp8Pq.js → aigne-BuWtyQrV.js} +1 -1
- package/dist/assets/api-2a4FTO9k.js +1 -0
- package/dist/assets/{appearance-DM7p-6Wl.js → appearance-DUs_om38.js} +1 -1
- package/dist/assets/{audit-logs-L-gO50KL.js → audit-logs-DUV4-vTj.js} +3 -3
- package/dist/assets/{authorize-D2d4GCpP.js → authorize-DC7FpxvU.js} +1 -1
- package/dist/assets/{base-chart-DSDnGziZ.js → base-chart-CRe-9w5H.js} +1 -1
- package/dist/assets/{base32-B-7CnEFd.js → base32-BqL5pnrU.js} +1 -1
- package/dist/assets/bind-account-DpXvkxLj.js +1 -0
- package/dist/assets/{branding-Dx40btDl.js → branding-BWncfl5y.js} +1 -1
- package/dist/assets/{branding-aCdIMhb0.js → branding-Btcz8N1M.js} +3 -3
- package/dist/assets/branding-DMOcia4y.js +1 -0
- package/dist/assets/{bundle-avatar-B1jZNqcH.js → bundle-avatar-BSv_e0lp.js} +1 -1
- package/dist/assets/button-C2uxCAba.js +1 -0
- package/dist/assets/click-to-copy-03_3P1nz.js +1 -0
- package/dist/assets/{cloneDeep-B_fYlLpl.js → cloneDeep-DqDclz1x.js} +1 -1
- package/dist/assets/{complete-Rr-_Zaon.js → complete-AlcncYrN.js} +2 -2
- package/dist/assets/{component-DZretbSC.js → component-Bsd478Wd.js} +2 -2
- package/dist/assets/{config-BkqISfFO.js → config-B8HbrPnF.js} +4 -4
- package/dist/assets/{config-Dw0qq-09.js → config-BBXBmv_e.js} +2 -2
- package/dist/assets/{config-Bjbv_xI5.js → config-CvvSF8W2.js} +1 -1
- package/dist/assets/{config-navigation-Dj8qf6cK.js → config-navigation-BAqSkXxH.js} +8 -8
- package/dist/assets/config-space-DnDf6PO2.js +1 -0
- package/dist/assets/{confirm-Bpit6U3-.js → confirm-Dul9DyCY.js} +1 -1
- package/dist/assets/connect-BRfx3zbS.js +1 -0
- package/dist/assets/{connect-B1ZA3nS8.js → connect-C1kqlbsb.js} +1 -1
- package/dist/assets/{connect-to-BsxW3JJi.js → connect-to-DNZM_E4B.js} +1 -1
- package/dist/assets/{create-passport-svg-DGPNsGUE.js → create-passport-svg-Cs4mVLsE.js} +1 -1
- package/dist/assets/{createClass-B5uCYz0o.js → createClass-BRKh_6kd.js} +1 -1
- package/dist/assets/{dashboard-DBwE7l6f.js → dashboard-DHNx2Vjq.js} +7 -7
- package/dist/assets/{delete-confirm-L0HXJtqt.js → delete-confirm-BT4RGlre.js} +1 -1
- package/dist/assets/did-address-DpdRECuJ.js +1 -0
- package/dist/assets/{domain-BoEowNlU.js → domain-Bc5sJ6GV.js} +1 -1
- package/dist/assets/{domain-action-card-BB0jQwcH.js → domain-action-card-DaWxksqg.js} +2 -2
- package/dist/assets/domains-CGPUezw9.js +1 -0
- package/dist/assets/{email-BAr61Jer.js → email-DsXuaICi.js} +2 -2
- package/dist/assets/engine-BaNtB6sW.js +1 -0
- package/dist/assets/{exchange-passport-BuJUAVgN.js → exchange-passport-DDScDnbP.js} +1 -1
- package/dist/assets/{form-kdwSU-mv.js → form-CmTyQIow.js} +2 -2
- package/dist/assets/{form-text-input-B_h8beXh.js → form-text-input-CsXLsIFW.js} +2 -2
- package/dist/assets/{fuel-C9kfBZ4R.js → fuel-BJDVWtLE.js} +2 -2
- package/dist/assets/{gen-access-key-Bh-o1OFU.js → gen-access-key-Ftv91l1v.js} +1 -1
- package/dist/assets/gen-simple-access-key-CWrV9bpF.js +1 -0
- package/dist/assets/get-safe-url-CqIO9371.js +1 -0
- package/dist/assets/{home-Cb5I193s.js → home-CxNed9GY.js} +1 -1
- package/dist/assets/{iframe-C233G1py.js → iframe-dmFx9kP7.js} +1 -1
- package/dist/assets/{index-MQEkIEm-.js → index-A-uhNQXl.js} +1 -1
- package/dist/assets/{index-BScxMPlP.js → index-B4sVJOOj.js} +1 -1
- package/dist/assets/{index-C-vVEZcs.js → index-B6IM_Z38.js} +3 -3
- package/dist/assets/{index-D-a8pZtp.js → index-BKE6R9dc.js} +1 -1
- package/dist/assets/{index-DuDIkjct.js → index-BNiqMLPn.js} +1 -1
- package/dist/assets/{index-DjpxFmgG.js → index-BWxvQ-Ka.js} +7 -7
- package/dist/assets/index-Bh8glecC.js +29 -0
- package/dist/assets/index-C0FXkPiP.js +62 -0
- package/dist/assets/{index-Bf3Peb0q.js → index-C6LgIqoY.js} +3 -3
- package/dist/assets/{index-CtORPeiq.js → index-CIJYNIAS.js} +2 -2
- package/dist/assets/{index-CGP3CGlC.js → index-CbTMv_sq.js} +6 -6
- package/dist/assets/{index-D29her4n.js → index-CeGNmiXz.js} +1 -1
- package/dist/assets/{index-CaTDaKrX.js → index-CiQKtWIW.js} +1 -1
- package/dist/assets/{index-WT6M-zj8.js → index-CiYSV3ew.js} +2 -2
- package/dist/assets/{index-D24LKXzO.js → index-Ck7gs4Oo.js} +1 -1
- package/dist/assets/{index-BT70k77_.js → index-CmDzr29Q.js} +2 -2
- package/dist/assets/index-CqsKmRBp.js +1 -0
- package/dist/assets/{index-lK6Pf_qM.js → index-CueIV4dA.js} +2 -2
- package/dist/assets/{index-DwJ_NASi.js → index-D4Ik9OgC.js} +2 -2
- package/dist/assets/index-DGg3AL9l.js +1039 -0
- package/dist/assets/{index-CUlOq3Sr.js → index-DQFDP0zB.js} +3 -3
- package/dist/assets/{index-CK3KHeKw.js → index-DTKew0E_.js} +1 -1
- package/dist/assets/{index-xE7OidBo.js → index-DVoa7OYS.js} +1 -1
- package/dist/assets/{index-CZBIYuko.js → index-DZnXlBSX.js} +1 -1
- package/dist/assets/{index-oS8X43Pb.js → index-DjCd3BVH.js} +6 -6
- package/dist/assets/{index-D_u0j8BO.js → index-DriYV-w5.js} +1 -1
- package/dist/assets/{index-CI3rRJqa.js → index-DzDWMabe.js} +12 -12
- package/dist/assets/{index-KIswy2vM.js → index-NpB7Thbw.js} +5 -5
- package/dist/assets/{index-CqD-x8pw.js → index-W43xyvqt.js} +2 -2
- package/dist/assets/{index-DACtt7qd.js → index-XVoTh0rZ.js} +1 -1
- package/dist/assets/{index-LaMi0T4w.js → index-cWpptG8N.js} +1 -1
- package/dist/assets/{invitation-C2S2tPzG.js → invitation-DaAeUQvL.js} +5 -5
- package/dist/assets/{invitations-Dil5QWBY.js → invitations-DY6AII7i.js} +2 -2
- package/dist/assets/{invite-GVnju9RQ.js → invite-BfQp8T_i.js} +1 -1
- package/dist/assets/{isURL-ZFgr0DWl.js → isURL-HdHdFI5D.js} +1 -1
- package/dist/assets/{issue-passport-BmU6NmKw.js → issue-passport-BKAe--H8.js} +1 -1
- package/dist/assets/{item-DfQKizv4.js → item-D8-oGTEp.js} +1 -1
- package/dist/assets/{landing-page-C3zTr0-n.js → landing-page-DQd97swG.js} +1 -1
- package/dist/assets/{layout-tkk_Lr2y.js → layout-PDwTMZS3.js} +1 -1
- package/dist/assets/list-B9c3yQuf.js +2 -0
- package/dist/assets/{list-YOpLH3o0.js → list-DYFxkX2y.js} +1 -1
- package/dist/assets/localization-XbNv70VN.js +1 -0
- package/dist/assets/{log-C0zcaEbO.js → log-ClrACcuw.js} +1 -1
- package/dist/assets/logger-D3ELa8t7.js +1 -0
- package/dist/assets/login-C3CgZVaH.js +1 -0
- package/dist/assets/{login-oauth-callback-DCJMx5J1.js → login-oauth-callback-DVq62YiP.js} +1 -1
- package/dist/assets/{logo-uploader-TLOlwvRt.js → logo-uploader-CPZeytzo.js} +1 -1
- package/dist/assets/{lost-passport-DE5KGhjz.js → lost-passport-rqbtayK0.js} +2 -2
- package/dist/assets/{omit-D_PYZZLm.js → omit-5AwbF-Ja.js} +1 -1
- package/dist/assets/{open-window-CPNpPXku.js → open-window-B20A6mUS.js} +1 -1
- package/dist/assets/{over-due-invoice-payment-1EZsSUm4.js → over-due-invoice-payment-Dpy6U-OB.js} +1 -1
- package/dist/assets/{overview-CMduEuAK.js → overview-DSMOnuTp.js} +2 -2
- package/dist/assets/passport-BeTGnBZp.js +1 -0
- package/dist/assets/{passport-item-QbgyHapR.js → passport-item-6fDG-tjs.js} +1 -1
- package/dist/assets/{permission-C0bmOzVj.js → permission-CjBTXkmT.js} +1 -1
- package/dist/assets/{preferences-0l0Zmaom.js → preferences-YojWKSr3.js} +1 -1
- package/dist/assets/profile-embed-CRKFFFmF.js +1 -0
- package/dist/assets/{publish-resource-ggObFvMi.js → publish-resource-CXd42xoH.js} +1 -1
- package/dist/assets/{react-beautiful-dnd.esm-zYw9dagY.js → react-beautiful-dnd.esm-By1RE6ef.js} +1 -1
- package/dist/assets/{runtime-BNKE0VfZ.js → runtime-Ydt2KUZV.js} +1 -1
- package/dist/assets/{sanitize-CtCDGQB6.js → sanitize-BOo6OPJZ.js} +1 -1
- package/dist/assets/sdk-BZuN1V4h.js +1 -0
- package/dist/assets/{security-CWEVWbF4.js → security-C6x1zjWI.js} +3 -3
- package/dist/assets/{session-Des-0R_y.js → session-Bavobyzn.js} +1 -1
- package/dist/assets/{setup-Cps_vpFS.js → setup-x3XlLP1U.js} +1 -1
- package/dist/assets/{spaces-2YPkTkBR.js → spaces-DKfk45f5.js} +1 -1
- package/dist/assets/start-WYmvvJ-x.js +187 -0
- package/dist/assets/{starting-progress-xuCef6_T.js → starting-progress-DbdtjHCx.js} +1 -1
- package/dist/assets/status-B7-tZFw7.js +1 -0
- package/dist/assets/{step-actions-AHe2MQxo.js → step-actions-BGJwIEbT.js} +1 -1
- package/dist/assets/{studio-HfI11Uc3.js → studio-D7UNnkpz.js} +1 -1
- package/dist/assets/{switch-control-CzYig10w.js → switch-control-BDwQ53GS.js} +1 -1
- package/dist/assets/{switch-rIcJ7tho.js → switch-wqsJ2qIA.js} +1 -1
- package/dist/assets/{table-tips-Ba9Kf02z.js → table-tips-BEPJMiqj.js} +1 -1
- package/dist/assets/{team-BWkxYdcc.js → team-D2fBm-il.js} +4 -4
- package/dist/assets/{traffic-jB6onGHq.js → traffic-BxfS8jav.js} +1 -1
- package/dist/assets/{transfer-DspVAdFc.js → transfer-C8A72tJr.js} +1 -1
- package/dist/assets/{unsubscribe-CKdMi1Kx.js → unsubscribe-DOgxD7dQ.js} +1 -1
- package/dist/assets/{use-app-logo-BAGvxEU-.js → use-app-logo-BwsHVK-l.js} +1 -1
- package/dist/assets/{use-window-close-D7QBHj75.js → use-window-close-edYntLdV.js} +1 -1
- package/dist/assets/{useAsync-CxjyODHb.js → useAsync-BSd-eaZO.js} +1 -1
- package/dist/assets/{useAsync-CgTefzpB.js → useAsync-DOpjtrvS.js} +1 -1
- package/dist/assets/{useAsyncRetry-BnuUJFwY.js → useAsyncRetry-v1aVMcV-.js} +1 -1
- package/dist/assets/useLocalStorage-8LihN_xG.js +1 -0
- package/dist/assets/user-center-9ue_tdF_.js +125 -0
- package/dist/assets/user-follower-DXIC4btc.js +32 -0
- package/dist/assets/{util-DXf_zMuU.js → util-CqIowTns.js} +1 -1
- package/dist/assets/{util-C9cWBCZz.js → util-pUhbKKIP.js} +1 -1
- package/dist/assets/{vendor-arcblock-DkdOhPyM.js → vendor-arcblock-DRfhQ9Yl.js} +1 -1
- package/dist/assets/{vendor-hooks-BZ19vVZ7.js → vendor-hooks-DpqqC65c.js} +1 -1
- package/dist/assets/vendor-utils-BqKQizRf.js +213 -0
- package/dist/assets/{vendor-ux-DMZIE6wA.js → vendor-ux-KtPBvlG0.js} +7 -7
- package/dist/assets/{wait-connect-D2wPrbE3.js → wait-connect-BwtwczC4.js} +1 -1
- package/dist/assets/{wizard-EYZCXWG5.js → wizard-LT-uDnMP.js} +1 -1
- package/dist/assets/wizard-components-BmdyIe7R.js +52 -0
- package/dist/assets/wrap-locale-C-cgVToU.js +1 -0
- package/dist/assets/{zh-CXK3bXGt.js → zh-DZyuEbhr.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +24 -24
- package/dist/assets/api-C75sLx9p.js +0 -1
- package/dist/assets/bind-account-DuzArGdZ.js +0 -1
- package/dist/assets/branding-bYH66Nug.js +0 -1
- package/dist/assets/button-BnSiFtNt.js +0 -1
- package/dist/assets/click-to-copy-CwdgHxjB.js +0 -1
- package/dist/assets/config-space-Dw6ITGIj.js +0 -1
- package/dist/assets/connect-Bl7-1lbc.js +0 -1
- package/dist/assets/did-address-uvYuZ4wv.js +0 -1
- package/dist/assets/domains-kgzxNW_C.js +0 -1
- package/dist/assets/engine-DWk3y4cO.js +0 -1
- package/dist/assets/gen-simple-access-key-DHmIlRFl.js +0 -1
- package/dist/assets/get-safe-url-gaxZoVzJ.js +0 -1
- package/dist/assets/index-B7DVpLRM.js +0 -63
- package/dist/assets/index-BaaFi7Vh.js +0 -1
- package/dist/assets/index-DwyzCfdd.js +0 -1041
- package/dist/assets/index-OMkyTUNX.js +0 -29
- package/dist/assets/list-BvgV1Jbh.js +0 -2
- package/dist/assets/localization-DcnSNZHz.js +0 -1
- package/dist/assets/logger-BbBkOuwH.js +0 -1
- package/dist/assets/login-BR26IXZx.js +0 -1
- package/dist/assets/passport-Dg1YWagy.js +0 -1
- package/dist/assets/profile-embed-BQzLZZkK.js +0 -1
- package/dist/assets/sdk-YVE2MSze.js +0 -1
- package/dist/assets/start-CuCNmoqX.js +0 -187
- package/dist/assets/status-DleDsf-t.js +0 -1
- package/dist/assets/useLocalStorage-Bj52e1ZW.js +0 -1
- package/dist/assets/user-center-CL_lKzgJ.js +0 -125
- package/dist/assets/user-follower-CfiG4RXf.js +0 -32
- package/dist/assets/vendor-utils-D5UG1a5Y.js +0 -213
- package/dist/assets/wizard-components-PMRUmw6U.js +0 -52
- package/dist/assets/wrap-locale-B4E8Yvgz.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as x}from"./vendor-react-CTtPmzVP.js";import{j as e,W as d,am as mt,ak as N,T as Q,U as ke,y as Fe,bk as Ve,b$ as Re,bX as Te,a5 as Ie,Q as Ce,dH as Pe,aN as Ee,a6 as Ge,D as Qe,cD as ht,ad as Xe,e4 as gt,e5 as xt,at as ae,b4 as Ue,n as bt,J as yt,x as jt,bZ as St,M as He,cB as vt}from"./vendor-mui-core-DnR6WYuU.js";import{e as ee,F as Ct,aC as pe}from"./vendor-utils-D5UG1a5Y.js";import{Q as H,b4 as Nt,V as Y,cU as wt,m as Ye,$ as Ze,J as Ae,aZ as Je,bs as be,aU as Rt,b3 as Tt,bb as It,bi as Et}from"./vendor-ux-DMZIE6wA.js";import{Z as At,Q as U,c as E,C as Dt,a1 as qe}from"./index-DwyzCfdd.js";import{a as X,g as De}from"./vendor-hooks-BZ19vVZ7.js";import{S as me}from"./shorten-label-C4py9TLA.js";import{v as et}from"./index-CaTDaKrX.js";import{R as tt,A as Ot,S as Lt,a as kt,B as Ft}from"./list-YOpLH3o0.js";import{i as Pt,e as _t,N as Bt}from"./team-BWkxYdcc.js";import{W as zt}from"./did-address-uvYuZ4wv.js";import{p as st}from"./util-C9cWBCZz.js";import{D as Wt,g as Mt}from"./traffic-jB6onGHq.js";import{B as nt}from"./bundle-avatar-B1jZNqcH.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DkdOhPyM.js";import"./server-logo-notext.svg-xZ-i1SpD.js";import"./session-Des-0R_y.js";import"./isURL-ZFgr0DWl.js";import"./use-app-logo-BAGvxEU-.js";import"./base32-B-7CnEFd.js";import"./useAsyncRetry-BnuUJFwY.js";import"./useAsync-CxjyODHb.js";import"./iframe-C233G1py.js";import"./index-BScxMPlP.js";import"./index-DBs9Ljax.js";import"./base-chart-DSDnGziZ.js";import"./index-CZBIYuko.js";import"./vendor-mui-x-CQc01l4r.js";import"./AdapterDayjs-Bfr4sW4C.js";const at=x.createContext({}),{Provider:Kt,Consumer:Us}=at;function Ut({children:t,blocklet:s=""}){const{api:n,inService:r,ws:{useSubscription:i}}=At(),[l,b]=x.useState([]),[m,S]=x.useState({total:0,pageSize:20,pageCount:0,page:1}),h=X(()=>s.meta?.did,[s]),[y,v]=x.useState([]),[P,F]=x.useState({}),w=X(()=>l.length?new Set(l.map(p=>p.id)):new Set,[l]),q=async({page:p=1,pageSize:g=20,...T}={})=>{if(!h)return[];try{const D={paging:{page:p,pageSize:g},...T,teamDid:h,dateRange:T.dateRange?[U(T.dateRange[0]).toISOString(),U(T.dateRange[1]).toISOString()]:void 0},{dids:O,...z}=D;let _="";O&&O.includes("system")&&(_="system");const ie=O?O.filter(oe=>oe!=="system"):[],se={...z,source:_,componentDids:ie},J=await n.getNotificationSendLog({input:se});return F(se),b(J.list),S(J.paging),J.list}catch(D){return H.error(D.message),[]}},M=async()=>{const p=await n.getNotificationComponents({input:{teamDid:h}});v(p.componentDids)},L=x.useCallback(p=>{const g=s.children.find(T=>T.meta?.did===p);if(g)return g.ancestors=[s],g},[s]),k=async({notificationId:p,receivers:g,channels:T,...D})=>{await n.resendNotification({input:{teamDid:h,notificationId:p,receivers:g,channels:T.map(O=>O==="wallet"?E.NOTIFICATION_SEND_CHANNEL.WALLET:O==="pushKit"?E.NOTIFICATION_SEND_CHANNEL.PUSH:O),...D}})},$=x.useCallback(async p=>(await n.getUser({input:{teamDid:h,user:{did:p},options:{enableConnectedAccount:!0}}})).user,[n,h]),V=x.useCallback(async({page:p=1,pageSize:g=20,...T}={})=>{try{const D={paging:{page:p,pageSize:g},...T,userName:T.searchText||"",teamDid:h,dateRange:T.dateRange?[U(T.dateRange[0]).toISOString(),U(T.dateRange[1]).toISOString()]:void 0};return await n.getReceivers({input:D})}catch(D){throw H.error(D.message),D}},[n,h]);x.useEffect(()=>{h&&M()},[h]),i(E.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,p=>{w.has(p.notificationId)&&q(P)},[w,P]),i(E.EVENTS.NOTIFICATION_BLOCKLET_CREATE,p=>{w.has(p.id)||q(P)},[w,P]);const Z={fetch:q,data:l,paging:m,blocklet:s,getComponent:L,resendNotification:k,getUser:$,componentDids:y,getReceivers:V,inService:r,teamDid:h};return e.jsx(Kt,{value:{notificationRecords:Z},children:t})}function _e(){const{notificationRecords:t}=x.useContext(at);return t}he.propTypes={severity:d.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ht={info:"primary",success:"success",error:"error",warning:"warning"};function he({severity:t="info"}){return e.jsx(Nt,{type:Ht[t],children:t})}const qt=(t,s,n="")=>{if(!n||!s)return"";switch(n){case E.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return t("notification.sendStatus.reason.disabled",{channel:s});case E.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return t("notification.sendStatus.reason.unavailable",{channel:s});case E.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return t("notification.sendStatus.reason.notSent",{channel:s});case E.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return t("notification.sendStatus.reason.offline");default:return n}};function it(t,s,n={}){const{status:r,updatedAt:i,reason:l="",channel:b="wallet"}=n,m=i?t("notification.sendStatus.sentTime",{date:Dt(i,s)}):"",S=qt(t,b,l);return r===E.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:t("notification.sendStatus.failed"),sentTime:m,reason:S}:r===E.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:t("notification.sendStatus.success"),sentTime:m}:{status:"pending",title:t("notification.sendStatus.pending"),reason:S,sentTime:m}}const Oe={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Le=["wallet","pushKit","email"],$e=["info","success","error","warning"],ot=t=>{const{settings:s}=t;return s?.notification?.email?.enabled},rt=t=>{const{settings:s}=t;return s?.notification?.pushKit?.enabled},$t=(t,s)=>{const n=ee(s,"extra.notifications.email",!0);return{available:ot(t),enabled:n}},Vt=(t,s)=>{const n=ee(s,"extra.notifications.push",!0);return{available:rt(t),enabled:n}},Gt=t=>({enabled:ee(t,"extra.notifications.wallet",!0)}),Qt=t=>({enabled:ee(t,"extra.webhooks",[]).length>0}),ge=(t=3)=>new Promise(s=>{setTimeout(()=>{s()},t*1e3)}),Xt=(t,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:t("notification.sendStatus.reason.available",{channel:s}),fail:t("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:[],xe=(t=[])=>{const s=U().startOf("day");return t.filter(n=>U(n.sendAt).isSame(s,"day")).length},Yt=(t,s="")=>{if(s&&Le.includes(s)){const l=`${s}SendRecord`,b=ee(t,l,[]);return xe(b)}const n=ee(t,"webhook",{}),r=Object.keys(n??{})??[];if(s&&r.includes(s)){const l=n[s]??[];return xe(l)}const i={};return Le.forEach(l=>{const b=`${l}SendRecord`,m=ee(t,b,[]),S=xe(m);i[l]=S}),r.length>0&&r.forEach(l=>{const b=n[l]??[],m=xe(b);i[l]=m}),i},ye=(t,s,n)=>{if(!Array.isArray(t))throw new Error("Invalid filterList or index");return t[n].splice(s,1),t},je=(t,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(t):!1},Zt=t=>{switch(t){case E.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case E.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case E.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case E.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function te({config:t,enableTooltip:s=!0,showTitle:n=!1,children:r=null}){const{status:i,title:l="",sentTime:b="",reason:m=""}=t,S=[l,m].filter(Boolean).join(", ");return e.jsx(mt,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(Q,{color:"inherit",sx:{fontSize:12},children:S}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(N,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(N,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(N,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Oe[i]}}),e.jsx(N,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Oe[i]}})]}),e.jsx(Q,{color:"inherit",sx:{fontSize:12},children:n?l:r})]})})}te.propTypes={config:d.object.isRequired,enableTooltip:d.bool,showTitle:d.bool,children:d.node};Se.propTypes={list:d.array.isRequired,label:d.string.isRequired,onDelete:d.func};function Se({list:t,label:s,onDelete:n=()=>{}}){const{t:r,locale:i}=Y();return e.jsxs(N,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(Q,{children:[s,": "]}),t.map(l=>{const b=it(r,i,{status:l});return e.jsx(ke,{size:"small",label:e.jsx(N,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(te,{config:b,enableTooltip:!1,children:b.title})}),onDelete:m=>n(m,l)},l)})]})}Be.propTypes={filterList:d.array.isRequired,onChange:d.func.isRequired,index:d.number.isRequired,column:d.object.isRequired,filterValues:d.array.isRequired,label:d.string.isRequired,renderLabel:d.func.isRequired};function Be({filterList:t,onChange:s,index:n,column:r,filterValues:i,label:l,renderLabel:b}){return e.jsxs(Fe,{className:"filter-container",children:[e.jsx(Ve,{component:"legend",children:l}),e.jsx(Re,{row:!0,children:i.map(m=>e.jsx(Te,{control:e.jsx(Ie,{checked:t[n].indexOf(m.value??m)>-1,onChange:S=>{const h=[...t];S.target.checked?h[n]=[...h[n],m.value??m]:h[n]=h[n].filter(y=>y!==(m.value??m)),s(h[n],n,r)},name:m.value??m}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(m)})},m.value??m))})]})}function we(t){return e.jsx(Be,{...t,renderLabel:s=>e.jsx(te,{enableTooltip:!1,config:{status:s.status},children:s.label})})}ce.propTypes={status:d.number.isRequired,updatedAt:d.string.isRequired,reason:d.string,channel:d.string,onResend:d.func};function ce({status:t,updatedAt:s,reason:n="",channel:r="wallet",onResend:i}){const{t:l,locale:b}=Y(),m=it(l,b,{status:t,updatedAt:s,reason:n,channel:r});return e.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(te,{config:m,showTitle:!0}),m.status!=="success"&&e.jsx(Ce,{className:"resend-btn",size:"small",startIcon:e.jsx(Pe,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:i,children:l("notification.resend")})]})}ze.propTypes={value:d.array.isRequired,onChange:d.func};function ze({value:t,onChange:s}){const{locale:n}=Y(),r=U().toDate(),[i,l]=x.useState(null),b=x.useCallback(h=>{l(i?null:h.currentTarget)},[i]),m=!!i,S=x.useCallback(h=>{if(!h.startDate||!h.endDate){H.error("Please select a date range");return}if(U(h.startDate).isAfter(h.endDate)||!U(h.startDate).isValid()||!U(h.endDate).isValid()){H.error("Invalid date range");return}s([h.startDate,h.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(Q,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Ce,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[qe(t[0],n)," - ",qe(t[1],n)]})}),e.jsx(Ee,{open:m,anchorEl:i,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(Wt,{open:!0,maxDate:r,initialDateRange:{startDate:t[0],endDate:t[1]},toggle:b,definedRanges:Mt(r),onChange:S})})]})}We.propTypes={itemComponent:d.elementType.isRequired};function We({itemComponent:t,...s}){const{t:n}=Y();return!s?.filterList?.filter(i=>i.length).length?null:e.jsxs(N,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:n("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(wt.TableFilterList,{...s,ItemComponent:t})})]})}function Me({label:t,onDelete:s,canDelete:n=()=>!0,...r}){const i=s&&typeof s=="function"?s:void 0;let l=!0;return n&&typeof n=="function"&&(l=n({label:t,...r})),e.jsx(ke,{label:t,variant:"outlined",...i&&l?{onDelete:i}:{}})}Me.propTypes={label:d.string.isRequired,onDelete:d.func,canDelete:d.func};const Jt=[{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}];ct.propTypes={loading:d.bool,onCancel:d.func,onConfirm:d.func};function ct({loading:t=!1,onCancel:s=()=>{},onConfirm:n=()=>{}}){const{t:r}=Y(),[i,l]=x.useState(Jt),[b,m]=x.useState(!0),S=(y,v)=>{v.checked=y.target.checked;const P=i.map(F=>({...F,checked:F.value===v.value?v.checked:F.checked}));l(P)},h=y=>{y.stopPropagation(),n({channels:i.filter(v=>v.checked).map(v=>v.value),isResendFailedOnly:b})};return e.jsxs(N,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(Q,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(N,{className:"choose-channel",children:e.jsxs(Fe,{component:"fieldset",variant:"standard",children:[e.jsx(Ve,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Re,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:i.map(y=>e.jsx(Te,{control:e.jsx(Ie,{checked:y.checked,onChange:v=>S(v,y),name:y.value}),label:y.label},y.value))})]})}),e.jsx(N,{className:"resend-config-footer",children:e.jsx(Re,{children:e.jsx(Te,{control:e.jsx(Ie,{checked:b,onChange:y=>m(y.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(N,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Ce,{onClick:y=>{y.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Ce,{onClick:h,color:"primary",disabled:t,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[t&&e.jsx(Ge,{size:16}),r("common.confirm")]})]})]})}dt.propTypes={notificationId:d.string.isRequired,handleResend:d.func,resending:d.bool};function dt({notificationId:t,handleResend:s,resending:n=!1}){const{t:r,locale:i}=Y(),l=Qe(),b=x.useMemo(()=>Ye(l,lt()),[l]),{getReceivers:m,inService:S,teamDid:h,getUser:y,blocklet:v}=_e(),[P,F]=x.useState(!1),[w,q]=x.useState([]),M=De({anchorEl:null,position:null}),L=De({anchorEl:null,position:null}),[k,$]=x.useState(null),[V,Z]=x.useState({total:0,pageSize:10,pageCount:0,page:1}),[p,g]=x.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[U().subtract(1,"month").startOf("day").toDate(),U().endOf("day").toDate()]}),[T,D]=x.useState([]),O=[{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"}],z=async()=>{if(!P&&t)try{F(!0);const a=await m({notificationId:t,...p}),o=a.list.map(c=>({...c,receiverUser:{...c.receiverUser,avatar:st(c.receiverUser.avatar,h,S)}}));q(o),Z(a.paging),F(!1)}catch(a){H.error(a.message),F(!1)}};x.useEffect(()=>{z()},[p]);const _=a=>{a.stopPropagation();const o=a.currentTarget;L.anchorEl=o;const c=o.getBoundingClientRect();L.position={top:c.top+window.scrollY,left:c.left+window.scrollX}},ie=a=>a.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(Ae,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Pe,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:_,children:r("notification.resend")})}):null,se={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:V.page-1,rowsPerPage:V.pageSize,count:V.total,searchText:p.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:T,onRowSelectionChange:(a,o)=>{D(o.map(c=>c.dataIndex))},customToolbarSelect:ie},J=({page:a,rowsPerPage:o,searchText:c,filterList:C})=>{const[,B=[],G=[],K=[]]=C;p.pageSize!==o?g(W=>({...W,pageSize:o,page:1})):p.page!==a+1?g(W=>({...W,page:a+1})):p.searchText!==c?g(W=>({...W,searchText:c,page:1})):pe(B,p.walletSendStatus)?pe(G,p.pushKitSendStatus)?pe(K,p.emailSendStatus)||g(W=>({...W,emailSendStatus:K,page:1})):g(W=>({...W,pushKitSendStatus:G,page:1})):g(W=>({...W,walletSendStatus:B,page:1}))},oe=x.useCallback(async(a,o)=>{if(!o)return!1;const c=await y(o);return c?a==="wallet"?Gt(c):a==="email"?$t(v,c):a==="pushKit"?Vt(v,c):a==="webhook"?Qt(c):!0:!1},[y,v]),Ne=x.useCallback(a=>Xt(r,a),[r]),f=()=>{M.anchorEl=null,M.position=null,$(null)},u=()=>{L.anchorEl=null,L.position=null},j=async(a,o,c=!0,C="")=>{if(!(!o.length||!a.length))try{s(a,o,c,C),L.anchorEl||(await ge(.5),f())}catch(B){console.error("handleResend error",{error:B})}},I=async({channels:a,isResendFailedOnly:o})=>{const c=T.map(C=>w[C].receiver);await j(a,c,o),await ge(.5),u(),D([])},A=async(a,o=[],c=!0)=>{try{await j(["webhook"],[a.receiver],c,o)}catch(C){H.error(C.response?C.response.statusText:C.message)}},R=async(a,o,c,C=[],B=!0)=>{if(a.stopPropagation(),Yt(o,c)>=4){H.warning(r("notification.resendLimit"));return}if(!Le.includes(c)){await A(o,C,B);return}if(a){const K=a.currentTarget,W=K.getBoundingClientRect();M.anchorEl=K,M.position={top:W.top+window.scrollY,left:W.left+window.scrollX}}$({channel:c});try{const K=await oe(c,o.receiver);await ge(1),$({channel:c,result:K}),(typeof K=="boolean"&&K||Ct(K)&&Object.values(K).every(W=>!!W))&&(await s([c],[o.receiver],B),L.anchorEl||(await ge(.5),f()))}catch(K){H.error(K.message)}},re=a=>{g(o=>({...o,dateRange:a,page:1}))},ne=(a,o,c,C)=>{a.stopPropagation();const B=c.filter(G=>G!==o);g(G=>({...G,[C]:B,page:1}))},le=X(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:a=>{const{receiverUser:o,receiver:c}=w[a];return o?e.jsxs(N,{"data-cy":`member-name-${o.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(Ze,{src:`${o.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:c,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(me,{children:o.fullName})]},c):e.jsx(zt,{size:14,responsive:!1,compact:!0,copyable:!1,did:c})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:p.walletSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Wallet",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[1].options.filterList,"walletSendStatus")}}),update:ye},filterOptions:{names:O,fullWidth:!0,logic:je,display:(a,o,c,C)=>e.jsx(we,{label:"Wallet",filterList:a,onChange:o,index:c,column:C,filterValues:O})},customBodyRenderLite:a=>{const{walletSendStatus:o,walletSendAt:c,walletSendFailedReason:C}=w[a];return e.jsx(ce,{status:o,updatedAt:c,reason:C,channel:"wallet",onResend:B=>R(B,w[a],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{pushKitSendStatus:o,pushKitSendAt:c,pushKitSendFailedReason:C}=w[a];return e.jsx(ce,{status:o,updatedAt:c,reason:C,channel:"pushkit",onResend:B=>R(B,w[a],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:p.pushKitSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Push Kit",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[2].options.filterList,"pushKitSendStatus")}}),update:ye},filterOptions:{names:O,fullWidth:!0,logic:je,display:(a,o,c,C)=>e.jsx(we,{label:"Push Kit",filterList:a,onChange:o,index:c,column:C,filterValues:O})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{emailSendStatus:o,emailSendAt:c,emailSendFailedReason:C}=w[a];return e.jsx(ce,{status:o,updatedAt:c,reason:C,channel:"email",onResend:B=>R(B,w[a],"email",[],!1)})},filter:!0,filterType:"custom",filterList:p.emailSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Email",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[3].options.filterList,"emailSendStatus")}}),update:ye},filterOptions:{names:O,fullWidth:!0,logic:je,display:(a,o,c,C)=>e.jsx(we,{label:"Email",filterList:a,onChange:o,index:c,column:C,filterValues:O})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{webhook:o}=w[a];if(!o)return null;const c=Object.entries(o)[0];if(!c)return null;const[C,B]=c,G=B[0];return e.jsx(N,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(N,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(me,{maxLength:30,children:C},C),e.jsx(ce,{status:G.status,updatedAt:G.sendAt,reason:G.failedReason,channel:"webhook",onResend:K=>R(K,w[a],"webhook",[C],!1)})]},C)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:a=>{const{createdAt:o}=w[a];return e.jsx(tt,{value:o,locale:i,shouldUpdate:!0})}}}],[w,i,p,r]),ft=[e.jsx(ze,{value:p.dateRange,onChange:re},"date-picker"),e.jsx(Ae,{variant:"contained",size:"small",color:"primary",loading:P,startIcon:e.jsx(ht,{}),onClick:()=>z(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(N,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(ts,{children:e.jsxs(Xe,{theme:b,children:[e.jsx(Je,{className:"receivers-table",locale:i,loading:P,columns:le,data:w,onChange:J,options:se,customButtons:ft,components:{TableFilterList:a=>e.jsx(We,{...a,itemComponent:o=>e.jsx(Me,{...o,canDelete:()=>!1})})}}),M.anchorEl&&e.jsx(Ee,{open:!!M.anchorEl,anchorReference:"anchorPosition",anchorPosition:M.position,onClose:f,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(ss,{children:[e.jsxs(Q,{variant:"body1",component:"div",className:"check-title",children:[k?.channel," Checking"]}),e.jsx(N,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Ne(k?.channel).map(a=>{const{type:o,pass:c,fail:C}=a;return!k?.result||k?.result?.[o]?e.jsxs(Q,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:k?.result?.[o]?be.success.main:"inherit"},children:[k?.result?e.jsx(gt,{}):e.jsx(Ge,{size:12,sx:{color:be.primary.main}}),e.jsx("span",{children:c})]},o):e.jsxs(Q,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:be.error.main},children:[e.jsx(xt,{}),e.jsx("span",{children:C})]},o)})})]})}),L.anchorEl&&e.jsx(Ee,{open:!!L.anchorEl,anchorReference:"anchorPosition",anchorPosition:L.position,onClose:u,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(ct,{loading:n,onCancel:u,onConfirm:I})})]})})})}const es=x.memo(dt),ts=ae.div`
|
|
1
|
+
import{r as x}from"./vendor-react-CTtPmzVP.js";import{j as e,W as d,am as mt,ak as N,T as Q,U as ke,y as Fe,bk as Ve,b$ as Re,bX as Te,a5 as Ie,Q as Ce,dH as Pe,aN as Ee,a6 as Ge,D as Qe,cD as ht,ad as Xe,e4 as gt,e5 as xt,at as ae,b4 as He,n as bt,J as yt,x as jt,bZ as St,M as Ue,cB as vt}from"./vendor-mui-core-DnR6WYuU.js";import{e as ee,F as Ct,aC as pe}from"./vendor-utils-BqKQizRf.js";import{H as U,aV as Nt,V as Y,cM as wt,m as Ye,$ as Je,w as Ae,aO as Ze,bh as be,aJ as Rt,aU as Tt,b0 as It,b7 as Et}from"./vendor-ux-KtPBvlG0.js";import{Z as At,Q as H,c as E,C as Dt,a1 as qe}from"./index-DGg3AL9l.js";import{a as X,g as De}from"./vendor-hooks-DpqqC65c.js";import{S as me}from"./shorten-label-C4py9TLA.js";import{v as et}from"./index-CiQKtWIW.js";import{R as tt,A as Ot,S as Lt,a as kt,B as Ft}from"./list-DYFxkX2y.js";import{i as Pt,e as _t,N as Bt}from"./team-D2fBm-il.js";import{W as zt}from"./did-address-DpdRECuJ.js";import{p as st}from"./util-pUhbKKIP.js";import{D as Wt,g as Mt}from"./traffic-BxfS8jav.js";import{B as nt}from"./bundle-avatar-BSv_e0lp.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DRfhQ9Yl.js";import"./server-logo-notext.svg-xZ-i1SpD.js";import"./session-Bavobyzn.js";import"./isURL-HdHdFI5D.js";import"./use-app-logo-BwsHVK-l.js";import"./base32-BqL5pnrU.js";import"./useAsyncRetry-v1aVMcV-.js";import"./useAsync-BSd-eaZO.js";import"./iframe-dmFx9kP7.js";import"./index-B4sVJOOj.js";import"./index-DBs9Ljax.js";import"./base-chart-CRe-9w5H.js";import"./index-DZnXlBSX.js";import"./vendor-mui-x-CQc01l4r.js";import"./AdapterDayjs-DqOr9LFk.js";const at=x.createContext({}),{Provider:Kt,Consumer:Hs}=at;function Ht({children:t,blocklet:s=""}){const{api:n,inService:r,ws:{useSubscription:i}}=At(),[l,b]=x.useState([]),[m,S]=x.useState({total:0,pageSize:20,pageCount:0,page:1}),h=X(()=>s.meta?.did,[s]),[y,v]=x.useState([]),[P,F]=x.useState({}),w=X(()=>l.length?new Set(l.map(p=>p.id)):new Set,[l]),q=async({page:p=1,pageSize:g=20,...T}={})=>{if(!h)return[];try{const D={paging:{page:p,pageSize:g},...T,teamDid:h,dateRange:T.dateRange?[H(T.dateRange[0]).toISOString(),H(T.dateRange[1]).toISOString()]:void 0},{dids:O,...z}=D;let _="";O&&O.includes("system")&&(_="system");const ie=O?O.filter(oe=>oe!=="system"):[],se={...z,source:_,componentDids:ie},Z=await n.getNotificationSendLog({input:se});return F(se),b(Z.list),S(Z.paging),Z.list}catch(D){return U.error(D.message),[]}},M=async()=>{const p=await n.getNotificationComponents({input:{teamDid:h}});v(p.componentDids)},L=x.useCallback(p=>{const g=s.children.find(T=>T.meta?.did===p);if(g)return g.ancestors=[s],g},[s]),k=async({notificationId:p,receivers:g,channels:T,...D})=>{await n.resendNotification({input:{teamDid:h,notificationId:p,receivers:g,channels:T.map(O=>O==="wallet"?E.NOTIFICATION_SEND_CHANNEL.WALLET:O==="pushKit"?E.NOTIFICATION_SEND_CHANNEL.PUSH:O),...D}})},$=x.useCallback(async p=>(await n.getUser({input:{teamDid:h,user:{did:p},options:{enableConnectedAccount:!0}}})).user,[n,h]),V=x.useCallback(async({page:p=1,pageSize:g=20,...T}={})=>{try{const D={paging:{page:p,pageSize:g},...T,userName:T.searchText||"",teamDid:h,dateRange:T.dateRange?[H(T.dateRange[0]).toISOString(),H(T.dateRange[1]).toISOString()]:void 0};return await n.getReceivers({input:D})}catch(D){throw U.error(D.message),D}},[n,h]);x.useEffect(()=>{h&&M()},[h]),i(E.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,p=>{w.has(p.notificationId)&&q(P)},[w,P]),i(E.EVENTS.NOTIFICATION_BLOCKLET_CREATE,p=>{w.has(p.id)||q(P)},[w,P]);const J={fetch:q,data:l,paging:m,blocklet:s,getComponent:L,resendNotification:k,getUser:$,componentDids:y,getReceivers:V,inService:r,teamDid:h};return e.jsx(Kt,{value:{notificationRecords:J},children:t})}function _e(){const{notificationRecords:t}=x.useContext(at);return t}he.propTypes={severity:d.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ut={info:"primary",success:"success",error:"error",warning:"warning"};function he({severity:t="info"}){return e.jsx(Nt,{type:Ut[t],children:t})}const qt=(t,s,n="")=>{if(!n||!s)return"";switch(n){case E.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return t("notification.sendStatus.reason.disabled",{channel:s});case E.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return t("notification.sendStatus.reason.unavailable",{channel:s});case E.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return t("notification.sendStatus.reason.notSent",{channel:s});case E.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return t("notification.sendStatus.reason.offline");default:return n}};function it(t,s,n={}){const{status:r,updatedAt:i,reason:l="",channel:b="wallet"}=n,m=i?t("notification.sendStatus.sentTime",{date:Dt(i,s)}):"",S=qt(t,b,l);return r===E.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:t("notification.sendStatus.failed"),sentTime:m,reason:S}:r===E.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:t("notification.sendStatus.success"),sentTime:m}:{status:"pending",title:t("notification.sendStatus.pending"),reason:S,sentTime:m}}const Oe={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Le=["wallet","pushKit","email"],$e=["info","success","error","warning"],ot=t=>{const{settings:s}=t;return s?.notification?.email?.enabled},rt=t=>{const{settings:s}=t;return s?.notification?.pushKit?.enabled},$t=(t,s)=>{const n=ee(s,"extra.notifications.email",!0);return{available:ot(t),enabled:n}},Vt=(t,s)=>{const n=ee(s,"extra.notifications.push",!0);return{available:rt(t),enabled:n}},Gt=t=>({enabled:ee(t,"extra.notifications.wallet",!0)}),Qt=t=>({enabled:ee(t,"extra.webhooks",[]).length>0}),ge=(t=3)=>new Promise(s=>{setTimeout(()=>{s()},t*1e3)}),Xt=(t,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:t("notification.sendStatus.reason.available",{channel:s}),fail:t("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:[],xe=(t=[])=>{const s=H().startOf("day");return t.filter(n=>H(n.sendAt).isSame(s,"day")).length},Yt=(t,s="")=>{if(s&&Le.includes(s)){const l=`${s}SendRecord`,b=ee(t,l,[]);return xe(b)}const n=ee(t,"webhook",{}),r=Object.keys(n??{})??[];if(s&&r.includes(s)){const l=n[s]??[];return xe(l)}const i={};return Le.forEach(l=>{const b=`${l}SendRecord`,m=ee(t,b,[]),S=xe(m);i[l]=S}),r.length>0&&r.forEach(l=>{const b=n[l]??[],m=xe(b);i[l]=m}),i},ye=(t,s,n)=>{if(!Array.isArray(t))throw new Error("Invalid filterList or index");return t[n].splice(s,1),t},je=(t,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(t):!1},Jt=t=>{switch(t){case E.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case E.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case E.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case E.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function te({config:t,enableTooltip:s=!0,showTitle:n=!1,children:r=null}){const{status:i,title:l="",sentTime:b="",reason:m=""}=t,S=[l,m].filter(Boolean).join(", ");return e.jsx(mt,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(Q,{color:"inherit",sx:{fontSize:12},children:S}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(N,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(N,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(N,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Oe[i]}}),e.jsx(N,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Oe[i]}})]}),e.jsx(Q,{color:"inherit",sx:{fontSize:12},children:n?l:r})]})})}te.propTypes={config:d.object.isRequired,enableTooltip:d.bool,showTitle:d.bool,children:d.node};Se.propTypes={list:d.array.isRequired,label:d.string.isRequired,onDelete:d.func};function Se({list:t,label:s,onDelete:n=()=>{}}){const{t:r,locale:i}=Y();return e.jsxs(N,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(Q,{children:[s,": "]}),t.map(l=>{const b=it(r,i,{status:l});return e.jsx(ke,{size:"small",label:e.jsx(N,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(te,{config:b,enableTooltip:!1,children:b.title})}),onDelete:m=>n(m,l)},l)})]})}Be.propTypes={filterList:d.array.isRequired,onChange:d.func.isRequired,index:d.number.isRequired,column:d.object.isRequired,filterValues:d.array.isRequired,label:d.string.isRequired,renderLabel:d.func.isRequired};function Be({filterList:t,onChange:s,index:n,column:r,filterValues:i,label:l,renderLabel:b}){return e.jsxs(Fe,{className:"filter-container",children:[e.jsx(Ve,{component:"legend",children:l}),e.jsx(Re,{row:!0,children:i.map(m=>e.jsx(Te,{control:e.jsx(Ie,{checked:t[n].indexOf(m.value??m)>-1,onChange:S=>{const h=[...t];S.target.checked?h[n]=[...h[n],m.value??m]:h[n]=h[n].filter(y=>y!==(m.value??m)),s(h[n],n,r)},name:m.value??m}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(m)})},m.value??m))})]})}function we(t){return e.jsx(Be,{...t,renderLabel:s=>e.jsx(te,{enableTooltip:!1,config:{status:s.status},children:s.label})})}ce.propTypes={status:d.number.isRequired,updatedAt:d.string.isRequired,reason:d.string,channel:d.string,onResend:d.func};function ce({status:t,updatedAt:s,reason:n="",channel:r="wallet",onResend:i}){const{t:l,locale:b}=Y(),m=it(l,b,{status:t,updatedAt:s,reason:n,channel:r});return e.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(te,{config:m,showTitle:!0}),m.status!=="success"&&e.jsx(Ce,{className:"resend-btn",size:"small",startIcon:e.jsx(Pe,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:i,children:l("notification.resend")})]})}ze.propTypes={value:d.array.isRequired,onChange:d.func};function ze({value:t,onChange:s}){const{locale:n}=Y(),r=H().toDate(),[i,l]=x.useState(null),b=x.useCallback(h=>{l(i?null:h.currentTarget)},[i]),m=!!i,S=x.useCallback(h=>{if(!h.startDate||!h.endDate){U.error("Please select a date range");return}if(H(h.startDate).isAfter(h.endDate)||!H(h.startDate).isValid()||!H(h.endDate).isValid()){U.error("Invalid date range");return}s([h.startDate,h.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(Q,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Ce,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[qe(t[0],n)," - ",qe(t[1],n)]})}),e.jsx(Ee,{open:m,anchorEl:i,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(Wt,{open:!0,maxDate:r,initialDateRange:{startDate:t[0],endDate:t[1]},toggle:b,definedRanges:Mt(r),onChange:S})})]})}We.propTypes={itemComponent:d.elementType.isRequired};function We({itemComponent:t,...s}){const{t:n}=Y();return!s?.filterList?.filter(i=>i.length).length?null:e.jsxs(N,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:n("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(wt.TableFilterList,{...s,ItemComponent:t})})]})}function Me({label:t,onDelete:s,canDelete:n=()=>!0,...r}){const i=s&&typeof s=="function"?s:void 0;let l=!0;return n&&typeof n=="function"&&(l=n({label:t,...r})),e.jsx(ke,{label:t,variant:"outlined",...i&&l?{onDelete:i}:{}})}Me.propTypes={label:d.string.isRequired,onDelete:d.func,canDelete:d.func};const Zt=[{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}];ct.propTypes={loading:d.bool,onCancel:d.func,onConfirm:d.func};function ct({loading:t=!1,onCancel:s=()=>{},onConfirm:n=()=>{}}){const{t:r}=Y(),[i,l]=x.useState(Zt),[b,m]=x.useState(!0),S=(y,v)=>{v.checked=y.target.checked;const P=i.map(F=>({...F,checked:F.value===v.value?v.checked:F.checked}));l(P)},h=y=>{y.stopPropagation(),n({channels:i.filter(v=>v.checked).map(v=>v.value),isResendFailedOnly:b})};return e.jsxs(N,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(Q,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(N,{className:"choose-channel",children:e.jsxs(Fe,{component:"fieldset",variant:"standard",children:[e.jsx(Ve,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Re,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:i.map(y=>e.jsx(Te,{control:e.jsx(Ie,{checked:y.checked,onChange:v=>S(v,y),name:y.value}),label:y.label},y.value))})]})}),e.jsx(N,{className:"resend-config-footer",children:e.jsx(Re,{children:e.jsx(Te,{control:e.jsx(Ie,{checked:b,onChange:y=>m(y.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(N,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Ce,{onClick:y=>{y.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Ce,{onClick:h,color:"primary",disabled:t,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[t&&e.jsx(Ge,{size:16}),r("common.confirm")]})]})]})}dt.propTypes={notificationId:d.string.isRequired,handleResend:d.func,resending:d.bool};function dt({notificationId:t,handleResend:s,resending:n=!1}){const{t:r,locale:i}=Y(),l=Qe(),b=x.useMemo(()=>Ye(l,lt()),[l]),{getReceivers:m,inService:S,teamDid:h,getUser:y,blocklet:v}=_e(),[P,F]=x.useState(!1),[w,q]=x.useState([]),M=De({anchorEl:null,position:null}),L=De({anchorEl:null,position:null}),[k,$]=x.useState(null),[V,J]=x.useState({total:0,pageSize:10,pageCount:0,page:1}),[p,g]=x.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[H().subtract(1,"month").startOf("day").toDate(),H().endOf("day").toDate()]}),[T,D]=x.useState([]),O=[{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"}],z=async()=>{if(!P&&t)try{F(!0);const a=await m({notificationId:t,...p}),o=a.list.map(c=>({...c,receiverUser:{...c.receiverUser,avatar:st(c.receiverUser.avatar,h,S)}}));q(o),J(a.paging),F(!1)}catch(a){U.error(a.message),F(!1)}};x.useEffect(()=>{z()},[p]);const _=a=>{a.stopPropagation();const o=a.currentTarget;L.anchorEl=o;const c=o.getBoundingClientRect();L.position={top:c.top+window.scrollY,left:c.left+window.scrollX}},ie=a=>a.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(Ae,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Pe,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:_,children:r("notification.resend")})}):null,se={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:V.page-1,rowsPerPage:V.pageSize,count:V.total,searchText:p.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:T,onRowSelectionChange:(a,o)=>{D(o.map(c=>c.dataIndex))},customToolbarSelect:ie},Z=({page:a,rowsPerPage:o,searchText:c,filterList:C})=>{const[,B=[],G=[],K=[]]=C;p.pageSize!==o?g(W=>({...W,pageSize:o,page:1})):p.page!==a+1?g(W=>({...W,page:a+1})):p.searchText!==c?g(W=>({...W,searchText:c,page:1})):pe(B,p.walletSendStatus)?pe(G,p.pushKitSendStatus)?pe(K,p.emailSendStatus)||g(W=>({...W,emailSendStatus:K,page:1})):g(W=>({...W,pushKitSendStatus:G,page:1})):g(W=>({...W,walletSendStatus:B,page:1}))},oe=x.useCallback(async(a,o)=>{if(!o)return!1;const c=await y(o);return c?a==="wallet"?Gt(c):a==="email"?$t(v,c):a==="pushKit"?Vt(v,c):a==="webhook"?Qt(c):!0:!1},[y,v]),Ne=x.useCallback(a=>Xt(r,a),[r]),f=()=>{M.anchorEl=null,M.position=null,$(null)},u=()=>{L.anchorEl=null,L.position=null},j=async(a,o,c=!0,C="")=>{if(!(!o.length||!a.length))try{s(a,o,c,C),L.anchorEl||(await ge(.5),f())}catch(B){console.error("handleResend error",{error:B})}},I=async({channels:a,isResendFailedOnly:o})=>{const c=T.map(C=>w[C].receiver);await j(a,c,o),await ge(.5),u(),D([])},A=async(a,o=[],c=!0)=>{try{await j(["webhook"],[a.receiver],c,o)}catch(C){U.error(C.response?C.response.statusText:C.message)}},R=async(a,o,c,C=[],B=!0)=>{if(a.stopPropagation(),Yt(o,c)>=4){U.warning(r("notification.resendLimit"));return}if(!Le.includes(c)){await A(o,C,B);return}if(a){const K=a.currentTarget,W=K.getBoundingClientRect();M.anchorEl=K,M.position={top:W.top+window.scrollY,left:W.left+window.scrollX}}$({channel:c});try{const K=await oe(c,o.receiver);await ge(1),$({channel:c,result:K}),(typeof K=="boolean"&&K||Ct(K)&&Object.values(K).every(W=>!!W))&&(await s([c],[o.receiver],B),L.anchorEl||(await ge(.5),f()))}catch(K){U.error(K.message)}},re=a=>{g(o=>({...o,dateRange:a,page:1}))},ne=(a,o,c,C)=>{a.stopPropagation();const B=c.filter(G=>G!==o);g(G=>({...G,[C]:B,page:1}))},le=X(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:a=>{const{receiverUser:o,receiver:c}=w[a];return o?e.jsxs(N,{"data-cy":`member-name-${o.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(Je,{src:`${o.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:c,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(me,{children:o.fullName})]},c):e.jsx(zt,{size:14,responsive:!1,compact:!0,copyable:!1,did:c})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:p.walletSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Wallet",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[1].options.filterList,"walletSendStatus")}}),update:ye},filterOptions:{names:O,fullWidth:!0,logic:je,display:(a,o,c,C)=>e.jsx(we,{label:"Wallet",filterList:a,onChange:o,index:c,column:C,filterValues:O})},customBodyRenderLite:a=>{const{walletSendStatus:o,walletSendAt:c,walletSendFailedReason:C}=w[a];return e.jsx(ce,{status:o,updatedAt:c,reason:C,channel:"wallet",onResend:B=>R(B,w[a],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{pushKitSendStatus:o,pushKitSendAt:c,pushKitSendFailedReason:C}=w[a];return e.jsx(ce,{status:o,updatedAt:c,reason:C,channel:"pushkit",onResend:B=>R(B,w[a],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:p.pushKitSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Push Kit",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[2].options.filterList,"pushKitSendStatus")}}),update:ye},filterOptions:{names:O,fullWidth:!0,logic:je,display:(a,o,c,C)=>e.jsx(we,{label:"Push Kit",filterList:a,onChange:o,index:c,column:C,filterValues:O})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{emailSendStatus:o,emailSendAt:c,emailSendFailedReason:C}=w[a];return e.jsx(ce,{status:o,updatedAt:c,reason:C,channel:"email",onResend:B=>R(B,w[a],"email",[],!1)})},filter:!0,filterType:"custom",filterList:p.emailSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Email",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[3].options.filterList,"emailSendStatus")}}),update:ye},filterOptions:{names:O,fullWidth:!0,logic:je,display:(a,o,c,C)=>e.jsx(we,{label:"Email",filterList:a,onChange:o,index:c,column:C,filterValues:O})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{webhook:o}=w[a];if(!o)return null;const c=Object.entries(o)[0];if(!c)return null;const[C,B]=c,G=B[0];return e.jsx(N,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(N,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(me,{maxLength:30,children:C},C),e.jsx(ce,{status:G.status,updatedAt:G.sendAt,reason:G.failedReason,channel:"webhook",onResend:K=>R(K,w[a],"webhook",[C],!1)})]},C)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:a=>{const{createdAt:o}=w[a];return e.jsx(tt,{value:o,locale:i,shouldUpdate:!0})}}}],[w,i,p,r]),ft=[e.jsx(ze,{value:p.dateRange,onChange:re},"date-picker"),e.jsx(Ae,{variant:"contained",size:"small",color:"primary",loading:P,startIcon:e.jsx(ht,{}),onClick:()=>z(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(N,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(ts,{children:e.jsxs(Xe,{theme:b,children:[e.jsx(Ze,{className:"receivers-table",locale:i,loading:P,columns:le,data:w,onChange:Z,options:se,customButtons:ft,components:{TableFilterList:a=>e.jsx(We,{...a,itemComponent:o=>e.jsx(Me,{...o,canDelete:()=>!1})})}}),M.anchorEl&&e.jsx(Ee,{open:!!M.anchorEl,anchorReference:"anchorPosition",anchorPosition:M.position,onClose:f,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(ss,{children:[e.jsxs(Q,{variant:"body1",component:"div",className:"check-title",children:[k?.channel," Checking"]}),e.jsx(N,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Ne(k?.channel).map(a=>{const{type:o,pass:c,fail:C}=a;return!k?.result||k?.result?.[o]?e.jsxs(Q,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:k?.result?.[o]?be.success.main:"inherit"},children:[k?.result?e.jsx(gt,{}):e.jsx(Ge,{size:12,sx:{color:be.primary.main}}),e.jsx("span",{children:c})]},o):e.jsxs(Q,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:be.error.main},children:[e.jsx(xt,{}),e.jsx("span",{children:C})]},o)})})]})}),L.anchorEl&&e.jsx(Ee,{open:!!L.anchorEl,anchorReference:"anchorPosition",anchorPosition:L.position,onClose:u,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(ct,{loading:n,onCancel:u,onConfirm:I})})]})})})}const es=x.memo(dt),ts=ae.div`
|
|
2
2
|
td.MuiTableCell-footer {
|
|
3
3
|
border: none !important;
|
|
4
4
|
}
|
|
@@ -27,7 +27,7 @@ import{r as x}from"./vendor-react-CTtPmzVP.js";import{j as e,W as d,am as mt,ak
|
|
|
27
27
|
}
|
|
28
28
|
font-size: 12px;
|
|
29
29
|
}
|
|
30
|
-
`,fe=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t;function ns(t){const{wallet:s,push:n,email:r,webhook:i}=t;return[{name:"Wallet",value:e.jsx(de,{item:s})},{name:"Push",value:e.jsx(de,{item:n})},{name:"Email",value:e.jsx(de,{item:r})},...i.total>0?[{name:"Webhook",value:e.jsx(de,{item:i,isWebhook:!0})}]:[]]}function as(t,s,n){const{wallet:r,push:i,email:l,webhook:b}=t;return[{name:"Wallet",value:e.jsx(ue,{loading:n,channel:E.NOTIFICATION_SEND_CHANNEL.WALLET,item:r,onResend:s})},{name:"Push",value:e.jsx(ue,{loading:n,channel:E.NOTIFICATION_SEND_CHANNEL.PUSH,item:i,onResend:s})},{name:"Email",value:e.jsx(ue,{loading:n,channel:E.NOTIFICATION_SEND_CHANNEL.EMAIL,item:l,onResend:s})},...b.total>0?[{name:"Webhook",value:e.jsx(ue,{loading:n,channel:E.NOTIFICATION_SEND_CHANNEL.WEBHOOK,item:b,isWebhook:!0,onResend:s})}]:[]]}Ke.propTypes={statistics:d.object.isRequired,onResend:d.func,mode:d.oneOf(["simple","detail"]),resending:d.bool};de.propTypes={item:d.object.isRequired,isWebhook:d.bool};function de({item:t,isWebhook:s=!1}){const{t:n}=Y(),r=s?t.success.length:t.success,i=t.total,l=r===i?"success":"failed";return e.jsx(N,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:2},children:e.jsx(N,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsxs(te,{config:{status:l},enableTooltip:!1,children:[fe(r)," / ",fe(i)," ",n("notification.sendStatus.success")]})})})}ue.propTypes={item:d.object.isRequired,isWebhook:d.bool,channel:d.string,onResend:d.func,loading:d.bool};function ue({channel:t=E.NOTIFICATION_SEND_CHANNEL.WALLET,item:s,isWebhook:n=!1,onResend:r=()=>{},loading:i=!1}){const{t:l}=Y(),{success:b,failed:m,pending:S}=s,h=
|
|
30
|
+
`,fe=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t;function ns(t){const{wallet:s,push:n,email:r,webhook:i}=t;return[{name:"Wallet",value:e.jsx(de,{item:s})},{name:"Push",value:e.jsx(de,{item:n})},{name:"Email",value:e.jsx(de,{item:r})},...i.total>0?[{name:"Webhook",value:e.jsx(de,{item:i,isWebhook:!0})}]:[]]}function as(t,s,n){const{wallet:r,push:i,email:l,webhook:b}=t;return[{name:"Wallet",value:e.jsx(ue,{loading:n,channel:E.NOTIFICATION_SEND_CHANNEL.WALLET,item:r,onResend:s})},{name:"Push",value:e.jsx(ue,{loading:n,channel:E.NOTIFICATION_SEND_CHANNEL.PUSH,item:i,onResend:s})},{name:"Email",value:e.jsx(ue,{loading:n,channel:E.NOTIFICATION_SEND_CHANNEL.EMAIL,item:l,onResend:s})},...b.total>0?[{name:"Webhook",value:e.jsx(ue,{loading:n,channel:E.NOTIFICATION_SEND_CHANNEL.WEBHOOK,item:b,isWebhook:!0,onResend:s})}]:[]]}Ke.propTypes={statistics:d.object.isRequired,onResend:d.func,mode:d.oneOf(["simple","detail"]),resending:d.bool};de.propTypes={item:d.object.isRequired,isWebhook:d.bool};function de({item:t,isWebhook:s=!1}){const{t:n}=Y(),r=s?t.success.length:t.success,i=t.total,l=r===i?"success":"failed";return e.jsx(N,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:2},children:e.jsx(N,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsxs(te,{config:{status:l},enableTooltip:!1,children:[fe(r)," / ",fe(i)," ",n("notification.sendStatus.success")]})})})}ue.propTypes={item:d.object.isRequired,isWebhook:d.bool,channel:d.string,onResend:d.func,loading:d.bool};function ue({channel:t=E.NOTIFICATION_SEND_CHANNEL.WALLET,item:s,isWebhook:n=!1,onResend:r=()=>{},loading:i=!1}){const{t:l}=Y(),{success:b,failed:m,pending:S}=s,h=Jt(t),y=n?b.length:b,v=n?m.length:m,P=n?S.length:S,F=async L=>{L.stopPropagation();const k=n?[...new Set([...b,...m].map($=>$))]:[];await r([t],[],!0,k)},w=y+v,q=w>0?y/w*100:0,M=w>0?v/w*100:0;return e.jsxs(is,{successRatio:q,failedRatio:M,children:[e.jsxs(Q,{variant:"h6",children:[h," (",s.total,")"]}),e.jsxs(Q,{variant:"body1",sx:{mb:2},children:[e.jsx("span",{style:{color:Oe.success,fontWeight:600,fontSize:24},children:fe(y)}),e.jsx("small",{style:{paddingLeft:4},children:l("notification.sendStatus.success")})]}),e.jsxs(N,{className:"unsent-area",children:[e.jsxs(N,{children:[e.jsxs(te,{config:{status:"failed"},enableTooltip:!1,children:[fe(v)," ",l("notification.sendStatus.failed")]}),e.jsxs(te,{config:{status:"pending"},enableTooltip:!1,children:[fe(P)," ",l("notification.sendStatus.pending")]})]}),v>0&&e.jsx(N,{className:"resend-btn",children:e.jsx(Ae,{size:"small",color:"primary",loading:i,variant:"contained",startIcon:e.jsx(Pe,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:F,children:l("notification.resend")})})]})]})}function Ke({statistics:t,mode:s="simple",onResend:n=()=>{},resending:r=!1}){const i=X(()=>s==="simple"?ns(t):as(t,n,r),[t,s]);return s==="simple"?e.jsx("div",{children:i.map(l=>e.jsx(et,{style:{alignItems:"flex-start",marginBottom:s==="simple"?0:16},valueComponent:"div",nameWidth:100,name:l.name,children:l.value},l.name))}):e.jsx(He,{container:!0,spacing:2,children:i.map(l=>e.jsx(He,{size:{md:4,sm:6,xs:12},children:l.value},l.name))})}const is=ae(N)`
|
|
31
31
|
display: flex;
|
|
32
32
|
flex-direction: column;
|
|
33
33
|
align-items: flex-start;
|
|
@@ -45,7 +45,7 @@ import{r as x}from"./vendor-react-CTtPmzVP.js";import{j as e,W as d,am as mt,ak
|
|
|
45
45
|
bottom: 0;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
`;ut.propTypes={notification:d.object.isRequired,onCancel:d.func,blocklet:d.object.isRequired,tab:d.string};function ut({notification:t,onCancel:s=()=>{},blocklet:n,tab:r="info"}){const{t:i,locale:l}=Y(),{getComponent:b,resendNotification:m}=_e(),[S,h]=x.useState(!1),y=X(()=>b(t.componentDid)||n,[n,t.componentDid]),v=De({tab:r||"info"}),P=x.useCallback(async(p,g,T=!0,D=[])=>{if(!p.length||!t.id)return;const O=g.length>0?g:t?.receivers?.map(_=>_.receiver);if(!O.length)return;let z=[...p];if(z.includes(E.NOTIFICATION_SEND_CHANNEL.PUSH)&&!rt(n)&&(
|
|
48
|
+
`;ut.propTypes={notification:d.object.isRequired,onCancel:d.func,blocklet:d.object.isRequired,tab:d.string};function ut({notification:t,onCancel:s=()=>{},blocklet:n,tab:r="info"}){const{t:i,locale:l}=Y(),{getComponent:b,resendNotification:m}=_e(),[S,h]=x.useState(!1),y=X(()=>b(t.componentDid)||n,[n,t.componentDid]),v=De({tab:r||"info"}),P=x.useCallback(async(p,g,T=!0,D=[])=>{if(!p.length||!t.id)return;const O=g.length>0?g:t?.receivers?.map(_=>_.receiver);if(!O.length)return;let z=[...p];if(z.includes(E.NOTIFICATION_SEND_CHANNEL.PUSH)&&!rt(n)&&(U.warning(i("notification.sendStatus.reason.unavailable",{channel:"Push Kit"})),z=z.filter(_=>_!==E.NOTIFICATION_SEND_CHANNEL.PUSH)),z.includes(E.NOTIFICATION_SEND_CHANNEL.EMAIL)&&!ot(n)&&(U.warning(i("notification.sendStatus.reason.unavailable",{channel:"Email"})),z=z.filter(_=>_!==E.NOTIFICATION_SEND_CHANNEL.EMAIL)),!!z.length)try{h(!0),await m({notificationId:t.id,receivers:O,channels:z,resendFailedOnly:T,...z.includes("webhook")&&D.length?{webhookUrls:D}:{}}),U.success("Message has been sent!")}catch(_){console.error("handleResend error",{error:_}),U.error(_.response?_.response.statusText:_.message)}finally{h(!1)}},[n,t.id,t?.receivers,m,i]),F=X(()=>Pt(t),[t]),w=X(()=>_t(t),[t]),q=X(()=>F?t?.actorInfo:[],[t]),M=X(()=>n?.did||n?.meta?.did||"",[n]);function L(){return[{name:i("notification.from"),value:F&&w?e.jsx(Ot,{actors:q,teamDid:M,size:32,showName:!0}):e.jsx(Lt,{size:32,blocklet:y,showName:!0,hideDot:!0})},{name:i("notification.notificationTitle"),value:e.jsx(me,{maxLength:50,children:t.title})},{name:i("notification.body"),value:F?e.jsx(kt,{notification:t,blocklet:n}):e.jsx(Bt,{notification:t,rows:0})},{name:i("notification.severity"),value:e.jsx(he,{severity:t.severity})},{name:i("notification.createdAt"),value:e.jsx(It,{value:t.createdAt,locale:l,shouldUpdate:!0,type:"all"})}].map(g=>e.jsx(et,{style:{alignItems:"flex-start"},valueComponent:"div",nameWidth:120,name:g.name,children:g.value},g.name))}const k={info:{label:i("common.basicInfo"),value:"info",component:L},receivers:{label:i("notification.receiver"),value:"receivers"},statistics:{label:i("notification.statistics"),value:"statistics"}},$=Object.values(k).map(({label:p,value:g})=>({label:p,value:g})),V=k[v.tab]||k.info,J=p=>{v.tab=p};return e.jsx(Rt,{title:i("notification.notificationDetails"),fullWidth:!0,maxWidth:"lg",onClose:()=>{v.tab="info",s()},open:!0,actionsPosition:"left",sx:{".ux-dialog_header":{paddingBottom:0},".MuiDialogContent-root":{paddingTop:0}},children:e.jsxs(rs,{children:[e.jsx(N,{className:"tabs",sx:{mx:3},children:e.jsx(Tt,{tabs:$,current:v.tab,onChange:J,scrollButtons:"auto"})}),e.jsxs("div",{className:"body",children:[v.tab==="receivers"&&e.jsx(es,{notificationId:t.id,resending:S,handleResend:P}),v.tab==="statistics"&&e.jsx(Ke,{statistics:t.statistics,mode:"detail",resending:S,onResend:P}),v.tab==="info"&&e.jsx(V.component,{})]})]})})}const os=x.memo(ut),rs=ae.div`
|
|
49
49
|
& > .notification-row {
|
|
50
50
|
padding: 0;
|
|
51
51
|
}
|
|
@@ -92,7 +92,7 @@ import{r as x}from"./vendor-react-CTtPmzVP.js";import{j as e,W as d,am as mt,ak
|
|
|
92
92
|
overflow: hidden;
|
|
93
93
|
text-overflow: ellipsis;
|
|
94
94
|
}
|
|
95
|
-
`;function ve({blocklet:t=null,label:s=""}){return e.jsx(ls,{children:t?e.jsxs(e.Fragment,{children:[e.jsx(nt,{size:24,blocklet:t,ancestors:t.ancestors}),e.jsx("span",{className:"name",children:t.title||t.meta?.title})]}):e.jsx("span",{className:"name",children:s})})}pt.propTypes={list:d.array.isRequired,label:d.string.isRequired,onDelete:d.func};function pt({list:t,label:s,onDelete:n=()=>{}}){return e.jsxs(N,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(Q,{children:[s,": "]}),t.map(r=>e.jsx(ke,{size:"small",label:e.jsx(N,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(he,{severity:r})}),onDelete:i=>n(i,r)},r))]})}function cs(t){return e.jsx(Be,{...t,renderLabel:s=>e.jsx(he,{severity:s})})}function ds({customTableButtons:t}){const{t:s,locale:n}=Y(),r=Qe(),i=yt(r.breakpoints.down("sm")),l=x.useMemo(()=>Ye(r,lt()),[r]),[b,m]=x.useState(!1),{data:S,paging:h,blocklet:y,fetch:v,getComponent:P,componentDids:F,inService:w,teamDid:q}=_e(),M=x.useRef(null),[L,k]=x.useState(null),[$,V]=x.useState("info"),
|
|
95
|
+
`;function ve({blocklet:t=null,label:s=""}){return e.jsx(ls,{children:t?e.jsxs(e.Fragment,{children:[e.jsx(nt,{size:24,blocklet:t,ancestors:t.ancestors}),e.jsx("span",{className:"name",children:t.title||t.meta?.title})]}):e.jsx("span",{className:"name",children:s})})}pt.propTypes={list:d.array.isRequired,label:d.string.isRequired,onDelete:d.func};function pt({list:t,label:s,onDelete:n=()=>{}}){return e.jsxs(N,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(Q,{children:[s,": "]}),t.map(r=>e.jsx(ke,{size:"small",label:e.jsx(N,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(he,{severity:r})}),onDelete:i=>n(i,r)},r))]})}function cs(t){return e.jsx(Be,{...t,renderLabel:s=>e.jsx(he,{severity:s})})}function ds({customTableButtons:t}){const{t:s,locale:n}=Y(),r=Qe(),i=yt(r.breakpoints.down("sm")),l=x.useMemo(()=>Ye(r,lt()),[r]),[b,m]=x.useState(!1),{data:S,paging:h,blocklet:y,fetch:v,getComponent:P,componentDids:F,inService:w,teamDid:q}=_e(),M=x.useRef(null),[L,k]=x.useState(null),[$,V]=x.useState("info"),J=`notification-records-${y.meta?.did}`,p=Et(J),[g,T]=x.useState({pageSize:p.rowsPerPage||10,page:p.page?p.page+1:1,dids:p.dids||[],dateRange:p.dateRange||[H().subtract(1,"month").startOf("day").toDate(),H().endOf("day").toDate()]}),D=X(()=>{if(!y.children||!y.children.length)return[];const f=[];return y.children.forEach(u=>{const j=u.did||u.meta?.did;F.includes(j)&&(u.ancestors=[y],f.push(u))}),f},[F,y]),O=async f=>{try{m(!0),await v(f),m(!1)}finally{m(!1)}};x.useEffect(()=>{O(g)},[g]),x.useEffect(()=>{const f=S.find(u=>u.id===L?.id);L&&f&&k({...f})},[S]);const z=(f,u,j,I)=>{f.stopPropagation();const A=j.filter(R=>R!==u);T(R=>({...R,[I]:A,page:1}))},_=({page:f,rowsPerPage:u,filterList:j})=>{const[I=[],,,,A=[]]=j;g.pageSize!==u?T(R=>({...R,pageSize:u,page:1})):g.page!==f+1?T(R=>({...R,page:f+1})):pe(g.dids,I)?pe(g.severities,A)||T(R=>({...R,severities:A,page:1})):T(R=>({...R,dids:I,page:1}))},ie=x.useCallback(()=>{k(null),V("info")},[]),se=x.useCallback(()=>{v(g)},[v,g]),Z=[{label:s("notification.from"),name:"sender",width:400,options:{filter:!0,filterType:"custom",customFilterListOptions:{render:f=>f.map((u,j)=>{if(u==="system")return e.jsx("span",{children:s("notification.system")},`system-${j}`);const I=D.find(A=>(A.did||A.meta?.did)===u);return e.jsx(ve,{blocklet:I,label:I?.title||I?.meta?.title},u)}),update:(f,u,j)=>(f[j].splice(u,1),f)},filterOptions:{names:D,logic:(f,u)=>u.length?!u.includes(f):!1,display:(f,u,j,I)=>e.jsxs(Fe,{style:{width:"380px"},children:[e.jsx(jt,{id:"demo-simple-select-label",style:{background:"#ffffff"},children:"Sender"}),e.jsxs(St,{multiple:!0,value:f[j],renderValue:A=>e.jsx(N,{style:{overflow:"hidden",textOverflow:"ellipsis"},sx:{display:"flex",gap:1,alignItems:"center"},children:A.map(R=>{if(R==="system")return e.jsx("span",{children:s("notification.system")},R);const re=D.find(ne=>(ne.did||ne.meta?.did)===R);return e.jsx(ve,{blocklet:re,label:re?.title||re?.meta?.title},R)})}),onChange:A=>{f[j]=A.target.value,u(f[j],j,I)},children:[e.jsx(Ue,{value:"system",children:s("notification.system")}),D.map(A=>{const R=A.did||A.meta?.did;return e.jsx(Ue,{value:R,children:e.jsx(ve,{blocklet:A,label:A.title||A.meta?.title})},R)})]})]})},customBodyRenderLite:f=>{const u=S[f],j=P(u.componentDid);return e.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[j?e.jsx(nt,{size:32,blocklet:j,ancestors:j.ancestors??[]}):e.jsx(Ft,{blocklet:y,size:32}),e.jsx(me,{maxLength:50,children:j?.meta?.title||y?.meta?.title})]})}}},{label:s("notification.receiver"),name:"receivers",width:300,options:{filter:!1,customBodyRenderLite:f=>{const u=S[f],{receivers:j}=u;return e.jsx(vt,{total:j.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(),k(u),V("receivers")},children:j.map(I=>{const{receiverUser:A}=I,R=st(A.avatar,q,w);return e.jsx(Je,{alt:A.fullName,src:`${R}?imageFilter=resize&w=48&h=48`,size:32,did:I.receiver,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}},I.receiver)})})}}},{label:s("notification.statistics"),name:"statistics",width:400,options:{filter:!1,customBodyRenderLite:f=>{const u=S[f];return e.jsx(N,{onClick:j=>{j.stopPropagation(),k(u),V("statistics")},children:e.jsx(Ke,{statistics:u.statistics})})}}},{label:s("notification.notificationPreview"),name:"data",options:{filter:!1,customBodyRenderLite:f=>{const u=S[f];return e.jsx(me,{maxLength:50,children:u.title})}}},{label:s("notification.severity"),name:"severity",width:200,options:{setCellProps:()=>({className:"severity-cell"}),customBodyRenderLite:f=>{const u=S[f];return e.jsx(he,{severity:u.severity})},filter:!0,filterType:"custom",filterList:g.severities??[],customFilterListOptions:{render:f=>e.jsx(pt,{list:f,label:s("notification.severity"),onDelete:(u,j)=>{u.stopPropagation(),z(u,j,Z[4].options.filterList,"severities")}}),update:ye},filterOptions:{names:$e,fullWidth:!0,logic:je,display:(f,u,j,I)=>e.jsx(cs,{label:s("notification.severity"),filterList:f,onChange:u,index:j,column:I,filterValues:$e})}}},{label:s("common.createdAt"),name:"createdAt",width:300,options:{filter:!1,customBodyRenderLite:f=>{const{createdAt:u}=S[f];return e.jsx(tt,{value:u,locale:n,shouldUpdate:!0})}}}],oe=f=>{T(u=>({...u,dateRange:f,page:1}))},Ne=[...t||[]];return e.jsxs(N,{ref:M,sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:[e.jsx(us,{isBreakpointsDownSm:i,children:e.jsx(Xe,{theme:l,children:e.jsx(Ze,{className:"main-table",verticalKeyWidth:100,loading:b,locale:n,columns:Z,data:S,durable:J,onChange:_,options:{sort:!1,download:!1,print:!1,search:!1,expandableRowsOnClick:!0,page:h.page-1,rowsPerPage:h.pageSize,count:h.total,...p,onRowClick:(f,{dataIndex:u})=>{k(S[u])}},title:e.jsx(ze,{value:g.dateRange,onChange:oe}),customButtons:Ne,components:{TableFilterList:f=>e.jsx(We,{...f,itemComponent:u=>e.jsx(Me,{...u,canDelete:j=>j?.columnNames?.[j?.index||0]?.name==="sender"})})}})})}),L&&e.jsx(os,{refresh:se,onCancel:ie,notification:L,blocklet:y,tab:$})]})}const us=ae.div`
|
|
96
96
|
td.MuiTableCell-footer {
|
|
97
97
|
border: none !important;
|
|
98
98
|
}
|
|
@@ -117,4 +117,4 @@ import{r as x}from"./vendor-react-CTtPmzVP.js";import{j as e,W as d,am as mt,ak
|
|
|
117
117
|
flex-wrap: wrap;
|
|
118
118
|
gap: 8px;
|
|
119
119
|
}
|
|
120
|
-
`;ps.propTypes={blocklet:d.object.isRequired,customTableButtons:d.array};function ps({blocklet:t={},customTableButtons:s=[]}){return e.jsx(
|
|
120
|
+
`;ps.propTypes={blocklet:d.object.isRequired,customTableButtons:d.array};function ps({blocklet:t={},customTableButtons:s=[]}){return e.jsx(Ht,{blocklet:t,children:e.jsx(ds,{customTableButtons:s})})}export{ps as default};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{V as B,Q as q,N as F,bk as K,aY as Ce,aZ as Se,bi as Te}from"./vendor-ux-DMZIE6wA.js";import{v as Ie,q as ae,o as Re}from"./vendor-hooks-BZ19vVZ7.js";import{r as v,a as ce}from"./vendor-react-CTtPmzVP.js";import{D as We,J as de,j as e,Y as ze,b5 as De,$ as Oe,ak as d,z as ne,T as C,a6 as U,aZ as te,R as Ae,Q as N,bX as ie,am as P,bl as _,a5 as Q,V as Z,S as G,b2 as $e,U as L,I as M,c0 as Pe,b0 as qe,a7 as Le,F as Be,W as t,b6 as W,a3 as pe,b4 as ee,c9 as Me,aO as Ne,aP as Fe,dQ as He,dR as Ue,dS as _e,s as oe,aU as Ye,aj as Ve,cv as Ke,cu as Qe,bi as Je}from"./vendor-mui-core-DnR6WYuU.js";import{Z as Y,c as ue,Q as Xe,Y as Ze,cn as J,ba as xe,bb as he,bc as me}from"./index-DwyzCfdd.js";import{S as Ge}from"./switch-rIcJ7tho.js";import{b as V}from"./team-BWkxYdcc.js";import{u as et}from"./use-mobile-BINJTzMb.js";import{u as tt,C as X}from"./index.esm-Co8ZxFyk.js";import{C as ge,a as be,J as ot}from"./vendor-utils-D5UG1a5Y.js";import{C as st}from"./confirm-Bpit6U3-.js";import{A as nt}from"./actions-Dfiiwkit.js";import{T as re}from"./table-tips-Ba9Kf02z.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DkdOhPyM.js";import"./session-Des-0R_y.js";import"./isURL-ZFgr0DWl.js";import"./use-app-logo-BAGvxEU-.js";import"./index-DBs9Ljax.js";const it=n=>{const[p,c]=v.useState(null),[f,r]=v.useState(!0),[w,u]=v.useState(null),j=window.blocklet?.appUrl,a=v.useMemo(()=>{const g={};return p&&(p.sources.forEach(y=>{g[y.did]={source:y,events:[],count:0}}),p.events.forEach(y=>{g[y.source]&&(g[y.source].events.push(y),g[y.source].count+=1)})),g},[p]),b=async()=>{try{if(r(!0),!j)return;const y=await(await fetch(ge(j,ue.WELLKNOWN_SERVICE_PATH_PREFIX,"/openevent.json"))).json();c(y),u(null)}catch(g){u(g instanceof Error?g:new Error(String(g)))}finally{r(!1)}};return v.useEffect(()=>{b()},[j]),{openEvent:p,setOpenEvent:c,eventsBySource:a,loading:f,error:w,loadData:b}};function fe({eventsBySource:n,selectedEvents:p,setSelectedEvents:c,error:f=null}){const{t:r}=B(),[w,u]=v.useState({}),j=v.useMemo(()=>{const s={};return Object.entries(n).forEach(([l,{events:m}])=>{const k=m.filter(S=>p[`${S.type}-${S.source}`]).length;s[l]=k}),s},[n,p]),a=v.useMemo(()=>Object.values(j).reduce((s,l)=>s+l,0),[j]),b=v.useMemo(()=>Object.values(n).reduce((s,{events:l})=>s+l.length,0),[n]),g=(s,l)=>{l.stopPropagation(),u({...w,[s]:!w[s]})},y=s=>{const l=`${s.type}-${s.source}`;c(m=>({...m,[l]:!m[l]}))},z=(s,l)=>{const m={};s.forEach(k=>{const S=`${k.type}-${k.source}`;m[S]=!l}),c(k=>({...k,...m}))},I=s=>{const l={};Object.values(n).forEach(({events:m})=>{m.forEach(k=>{const S=`${k.type}-${k.source}`;l[S]=s.target.checked})}),c(l)};return e.jsxs(d,{sx:{width:"100%"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ie,{control:e.jsx(Q,{onChange:I,checked:a>0&&a===b}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[r("webhookEndpoint.selectAllEvents"),e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:e.jsx(P,{title:r("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(_,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),a>0&&e.jsx(C,{variant:"body2",color:"primary",sx:{ml:"auto"},children:r("webhookEndpoint.selectedEventsCount",{count:a})})]}),e.jsx(d,{className:"webhook-event-selector",sx:{maxHeight:"50vh",overflowY:"auto",overflowX:"hidden"},children:e.jsx(Z,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:.5},children:Object.entries(n).map(([s,{source:l,events:m,count:k}],S)=>{const D=j[s]>0,R=j[s]===m.length&&m.length>0,O=w[s];return e.jsxs(ce.Fragment,{children:[e.jsx(G,{sx:{borderBottom:({palette:i})=>S<Object.keys(n).length-1?`1px solid ${i.divider}`:"none",px:0,py:1,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(d,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:i=>{i.target.closest(".MuiFormControlLabel-root")||g(s,i)},children:[e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:m.length>0&&e.jsx(ie,{control:e.jsx(Q,{checked:R,indeterminate:D&&!R,onChange:i=>{i.stopPropagation(),z(m,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[l.logo&&e.jsx($e,{src:l.logo,sx:{width:24,height:24}}),e.jsx(d,{children:l.title||s}),D&&e.jsx(L,{label:r("webhookEndpoint.selectedCount",{count:j[s]}),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(d,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(C,{variant:"body2",sx:{color:"text.secondary",mr:1},children:r("webhookEndpoint.eventsCount",{count:k})}),m.length>0&&e.jsx(M,{size:"small",edge:"end",children:O?e.jsx(Pe,{}):e.jsx(qe,{})})]})]})}),m.length>0&&e.jsx(Le,{in:O,timeout:"auto",unmountOnExit:!0,children:e.jsx(Z,{disablePadding:!0,sx:{p:0,bgcolor:"rgba(0, 0, 0, 0.01)"},children:m.map(i=>{const h=`${i.type}-${i.source}`,o=!!p[h];return e.jsx(G,{dense:!0,sx:{py:.75,px:1},onClick:()=>y(i),children:e.jsxs(d,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(Q,{checked:o,sx:{flexShrink:0}}),e.jsxs(d,{sx:{flex:1,minWidth:0},children:[e.jsx(C,{variant:"body1",className:"webhook-event-type",sx:{cursor:"pointer",color:"text.primary",wordBreak:"break-word",overflowWrap:"break-word"},children:i.type}),e.jsx(C,{variant:"caption",sx:{color:"text.secondary",display:"block",cursor:"pointer",wordBreak:"break-word",overflowWrap:"break-word"},children:i.description})]})]})},h)})})})]},s)})})}),f&&e.jsx(Be,{error:!0,sx:{mt:1},children:f})]})}fe.propTypes={eventsBySource:t.objectOf(t.shape({source:t.shape({did:t.string.isRequired,title:t.string,description:t.string,version:t.string,logo:t.string}).isRequired,events:t.arrayOf(t.shape({type:t.string.isRequired,description:t.string.isRequired,source:t.string.isRequired})).isRequired,count:t.number.isRequired})).isRequired,selectedEvents:t.objectOf(t.bool).isRequired,setSelectedEvents:t.func.isRequired,error:t.string};function je({id:n=null,url:p="",description:c="",enabledEvents:f=[],onSubmit:r,onClose:w=()=>{}}){const{t:u}=B(),[j,a]=v.useState({}),{teamDid:b}=V(),{api:g}=Y(),{loading:y,error:z,eventsBySource:I}=it(),s=We(),{control:l,handleSubmit:m,formState:{errors:k},reset:S,setValue:D,trigger:R}=tt({defaultValues:{url:"",description:""}}),O=de(s.breakpoints.down("md"));v.useEffect(()=>{const o=Object.values(j).some(x=>x);D("selectedEvents",o?"valid":""),R("selectedEvents")},[j,D,R]);const i=()=>{a({}),S(),w()},h=async o=>{const x=Object.keys(j).filter(T=>j[T]),E={url:o.url,description:o.description,enabledEvents:x.map(T=>{const[A,se]=T.split("-");return!A||!se?null:{type:A,source:se}}).filter(Boolean)};try{if(n){const T=await g.updateWebhookEndpoint({input:{teamDid:b,id:n,data:E}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),r(T)}else{const T=await g.createWebhookEndpoint({input:{teamDid:b,input:E}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),r(T)}}catch(T){q.error(T?.message)}i()};return v.useEffect(()=>{S({url:p,description:c}),a(f.reduce((o,x)=>(o[`${x.type}-${x.source}`]=!0,o),{}))},[S,a,p,c,f]),e.jsx(ze,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,fullScreen:O,children:e.jsxs("form",{onSubmit:m(h),children:[e.jsx(De,{children:u(n?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Oe,{children:e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(X,{name:"url",control:l,rules:{required:u("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:u("webhookEndpoint.validation.urlInvalid")}},render:({field:o})=>e.jsx(ne,{...o,label:u("webhookEndpoint.url.label"),fullWidth:!0,error:!!k.url,helperText:k.url?.message})}),e.jsx(X,{name:"description",control:l,rules:{required:u("webhookEndpoint.validation.descriptionRequired")},render:({field:o})=>e.jsx(ne,{...o,label:u("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!k.description,helperText:k.description?.message})}),e.jsx(X,{name:"selectedEvents",control:l,rules:{required:u("webhookEndpoint.validation.eventRequired")},render:({field:o})=>e.jsx("input",{type:"hidden",...o})}),!y&&I&&Object.keys(I).length>0&&e.jsx(fe,{eventsBySource:I,selectedEvents:j,setSelectedEvents:a,error:k.selectedEvents?.message}),!y&&(!I||Object.keys(I).length===0)&&e.jsx(C,{sx:{color:"text.secondary"},children:u("webhookEndpoint.noAvailableEvents")}),y&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(U,{size:20})}),z&&e.jsx(te,{severity:"error",children:u("webhookEndpoint.loadingError",{message:z?.message})})]})}),e.jsxs(Ae,{sx:{p:"8px 24px 24px"},children:[e.jsx(N,{onClick:i,children:u("common.cancel")}),e.jsx(N,{type:"submit",variant:"contained",color:"primary",children:u(n?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}je.propTypes={onSubmit:t.func.isRequired,id:t.string,url:t.string,description:t.string,enabledEvents:t.arrayOf(t.shape({type:t.string.isRequired,source:t.string.isRequired})),onClose:t.func};function rt(n){switch(n){case"enabled":return"success";case"disabled":default:return"default"}}const lt=(n="en")=>n==="tw"?"zh":n;function H(n,p="YYYY-MM-DD HH:mm:ss",c="en"){return n?Xe(n).locale(lt(c)).format(p):"-"}function at(n){return typeof n=="number"?!1:be(n)}function ct(n){return n>=200&&n<300}function $({value:n,label:p,tip:c="",divider:f=!1}){const r=at(n);return e.jsxs(e.Fragment,{children:[e.jsxs(W,{direction:"column",alignItems:"flex-start",children:[e.jsxs(C,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[p,!!c&&e.jsx(P,{title:c,children:e.jsx(_,{fontSize:"small"})})]}),e.jsx(C,{component:"div",variant:"body1",color:r?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:r?"-":n})]}),f&&e.jsx(pe,{orientation:"vertical",flexItem:!0})]})}$.propTypes={label:t.oneOfType([t.string,t.node]).isRequired,value:t.oneOfType([t.string,t.node]).isRequired,tip:t.oneOfType([t.string,t.node]),divider:t.bool};function ye({title:n,children:p=null,mb:c=1.5,mt:f=1.5}){return e.jsxs(W,{className:"section-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,mb:c,mt:f,pb:1},children:[e.jsx(C,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:n}),p]})}ye.propTypes={title:t.oneOfType([t.string,t.node]).isRequired,children:t.node,mb:t.number,mt:t.number};const dt={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},pt=n=>{const p={};return n.forEach(c=>{const f=new Date(c.createdAt).toLocaleDateString();p[f]||(p[f]=[]),p[f]?.push(c)}),p};function we({eventId:n="",webhookEndpointId:p="",event:c=null}){const{api:f,ws:{useSubscription:r}}=Y(),{t:w}=B(),{teamDid:u}=V(),{blocklet:j}=Ze(),{data:a,loadMore:b,loadingMore:g,loading:y,mutate:z}=Ie(o=>{const E=o?Math.ceil(o.list.length/15)+1:1;return f.getWebhookAttempts({input:{teamDid:u,input:{eventId:n,webhookId:p},paging:{page:E,pageSize:15}}})},{reloadDeps:[n,p]}),I=a?.list||[],[s,l]=v.useState(null),[m,k]=v.useState(!1),S=pt(I);if(v.useEffect(()=>{!s&&a?.list.length&&l(a.list[0])},[a?.list.length,s]),r(ue.EVENTS.WEBHOOK_ATTEMPT,o=>{z(x=>{if(x.list.find(T=>T.id===o.id)){const T=x.list.map(A=>A.id===o.id?{...A,...o}:A);return{...x,list:T}}return o.endpoint=x.list[0]?.endpoint,o.event=x.list[0]?.event,{...x,list:[o,...x.list]}})},[]),y)return e.jsx(U,{});const D=a&&a.list.length<a.paging.total,R=async()=>{s&&(k(!0),await f.retryWebhookAttempt({input:{teamDid:u,eventId:s.event.id,webhookId:p,attemptId:s.id}}).finally(()=>{setTimeout(()=>{k(!1)},1e3)}))},O=o=>{if(o.responseBody&&o.responseBody?.sessionId&&o.responseBody?.projectId&&o.responseBody?.agentId){const x=j?.site?.domainAliases[0]?.value,E=(j.children||[]).find(A=>A?.meta?.name==="ai-studio"),T=ot(ge(`https://${x}`,E?.mountPoint||"","projects",o.responseBody.projectId,"logs/main"),{sessionId:o.responseBody.sessionId,agentId:o.responseBody.agentId});return e.jsx(M,{sx:{fontSize:20},onClick:()=>window.open(T,"_blank"),children:e.jsx(d,{component:F,icon:J})})}return null},i=o=>o.status==="pending"?e.jsx(He,{color:"warning"}):ct(o.responseStatus)?e.jsx(Ue,{color:"success"}):e.jsx(_e,{color:"error"}),h=s?.triggeredFrom&&(a?.list||[]).find(o=>o.id===s.triggeredFrom);return e.jsxs(ut,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ee,{size:{xs:12,md:4},sx:{height:1},children:be(Object.keys(S))?e.jsx(C,{sx:{color:"text.secondary"},children:w("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(S).map(([o,x])=>e.jsxs(ce.Fragment,{children:[e.jsx(Me,{sx:{p:0},children:o}),x.map(E=>e.jsxs(G,{sx:{cursor:"pointer",px:1},onClick:()=>l(E),selected:s&&s?.id===E?.id,secondaryAction:e.jsx(C,{sx:{color:"text.secondary"},children:H(E.createdAt,"HH:mm:ss")}),children:[e.jsx(Ne,{sx:{minWidth:0,mr:1.5},children:i(E)}),e.jsx(Fe,{primary:e.jsx(C,{sx:{color:"text.primary"},children:E.event.type})})]},E.id))]},o))}),D&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1},children:e.jsx(N,{variant:"text",type:"button",color:"inherit",onClick:b,disabled:g,sx:{color:o=>o.palette.text.disabled},children:w(g?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ee,{size:{xs:12,md:8},sx:{height:1},children:[s&&e.jsxs(W,{direction:"column",spacing:2,sx:{height:1,overflow:"auto",pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"h4",children:w(`common.${s.status}`)}),e.jsx(d,{children:O(s)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[h&&e.jsx(P,{placement:"left",title:e.jsxs(W,{onClick:()=>l(h),sx:{gap:1,cursor:"pointer",".did-address-text":{color:"common.white"}},children:[e.jsx(xe,{showDid:!0,did:s.triggeredBy,cardType:me.Detailed,infoType:he.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(pe,{}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(C,{variant:"body2",sx:{color:"primary.main"},children:w("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"body2",children:s.id}),e.jsx(M,{onClick:()=>l(h),children:e.jsx(d,{component:F,icon:J,sx:{fontSize:16,color:"common.white"}})})]})]})]}),slotProps:{tooltip:{sx:{maxWidth:400}}},children:e.jsx(M,{onClick:()=>l(h),children:e.jsx(d,{component:F,icon:J,sx:{fontSize:16}})})}),e.jsxs(N,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:m,children:[e.jsx(d,{component:F,icon:dt,sx:{fontSize:16,animation:m?"spin 1s linear infinite":"none",mr:.5}}),w("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(C,{variant:"h6",children:[w("webhookEndpoint.response")," (",s.responseStatus,")"]}),e.jsx(K,{language:"json",children:JSON.stringify(s.responseBody,null,2)})]}),e.jsxs(d,{children:[e.jsx(W,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(C,{variant:"h6",children:w("webhookEndpoint.request")})}),e.jsx(K,{language:"json",sx:{margin:0},children:JSON.stringify(s.event,null,2)})]})]}),a?.list.length===0&&c&&e.jsxs(d,{children:[e.jsx(W,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(C,{variant:"h6",children:w("webhookEndpoint.eventData")})}),e.jsx(K,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}we.propTypes={eventId:t.string,webhookEndpointId:t.string,event:t.shape({type:t.string,data:t.object,request:t.object,requestInfo:t.object})};const ut=oe(ee)`
|
|
1
|
+
import{V as B,H as q,z as F,b9 as K,aN as Ce,aO as Se,b7 as Te}from"./vendor-ux-KtPBvlG0.js";import{v as Ie,q as ae,o as Re}from"./vendor-hooks-DpqqC65c.js";import{r as v,a as ce}from"./vendor-react-CTtPmzVP.js";import{D as We,J as de,j as e,Y as ze,b5 as De,$ as Oe,ak as d,z as se,T as C,a6 as U,aZ as te,R as Ae,Q as N,bX as ie,am as P,bl as _,a5 as J,V as Z,S as G,b2 as $e,U as L,I as M,c0 as Pe,b0 as qe,a7 as Le,F as Be,W as t,b6 as W,a3 as pe,b4 as ee,c9 as Me,aO as Ne,aP as Fe,dQ as He,dR as Ue,dS as _e,s as oe,aU as Ve,aj as Ye,cv as Ke,cu as Je,bi as Qe}from"./vendor-mui-core-DnR6WYuU.js";import{Z as V,c as ue,Q as Xe,Y as Ze,cn as Q,ba as xe,bb as he,bc as me}from"./index-DGg3AL9l.js";import{S as Ge}from"./switch-wqsJ2qIA.js";import{b as Y}from"./team-D2fBm-il.js";import{u as et}from"./use-mobile-BINJTzMb.js";import{u as tt,C as X}from"./index.esm-Co8ZxFyk.js";import{C as ge,a as be,J as ot}from"./vendor-utils-BqKQizRf.js";import{C as nt}from"./confirm-Dul9DyCY.js";import{A as st}from"./actions-Dfiiwkit.js";import{T as re}from"./table-tips-BEPJMiqj.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DRfhQ9Yl.js";import"./session-Bavobyzn.js";import"./isURL-HdHdFI5D.js";import"./use-app-logo-BwsHVK-l.js";import"./index-DBs9Ljax.js";const it=s=>{const[p,c]=v.useState(null),[f,r]=v.useState(!0),[w,u]=v.useState(null),j=window.blocklet?.appUrl,a=v.useMemo(()=>{const g={};return p&&(p.sources.forEach(y=>{g[y.did]={source:y,events:[],count:0}}),p.events.forEach(y=>{g[y.source]&&(g[y.source].events.push(y),g[y.source].count+=1)})),g},[p]),b=async()=>{try{if(r(!0),!j)return;const y=await(await fetch(ge(j,ue.WELLKNOWN_SERVICE_PATH_PREFIX,"/openevent.json"))).json();c(y),u(null)}catch(g){u(g instanceof Error?g:new Error(String(g)))}finally{r(!1)}};return v.useEffect(()=>{b()},[j]),{openEvent:p,setOpenEvent:c,eventsBySource:a,loading:f,error:w,loadData:b}};function fe({eventsBySource:s,selectedEvents:p,setSelectedEvents:c,error:f=null}){const{t:r}=B(),[w,u]=v.useState({}),j=v.useMemo(()=>{const n={};return Object.entries(s).forEach(([l,{events:m}])=>{const k=m.filter(S=>p[`${S.type}-${S.source}`]).length;n[l]=k}),n},[s,p]),a=v.useMemo(()=>Object.values(j).reduce((n,l)=>n+l,0),[j]),b=v.useMemo(()=>Object.values(s).reduce((n,{events:l})=>n+l.length,0),[s]),g=(n,l)=>{l.stopPropagation(),u({...w,[n]:!w[n]})},y=n=>{const l=`${n.type}-${n.source}`;c(m=>({...m,[l]:!m[l]}))},z=(n,l)=>{const m={};n.forEach(k=>{const S=`${k.type}-${k.source}`;m[S]=!l}),c(k=>({...k,...m}))},I=n=>{const l={};Object.values(s).forEach(({events:m})=>{m.forEach(k=>{const S=`${k.type}-${k.source}`;l[S]=n.target.checked})}),c(l)};return e.jsxs(d,{sx:{width:"100%"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ie,{control:e.jsx(J,{onChange:I,checked:a>0&&a===b}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[r("webhookEndpoint.selectAllEvents"),e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:e.jsx(P,{title:r("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(_,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),a>0&&e.jsx(C,{variant:"body2",color:"primary",sx:{ml:"auto"},children:r("webhookEndpoint.selectedEventsCount",{count:a})})]}),e.jsx(d,{className:"webhook-event-selector",sx:{maxHeight:"50vh",overflowY:"auto",overflowX:"hidden"},children:e.jsx(Z,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:.5},children:Object.entries(s).map(([n,{source:l,events:m,count:k}],S)=>{const D=j[n]>0,R=j[n]===m.length&&m.length>0,O=w[n];return e.jsxs(ce.Fragment,{children:[e.jsx(G,{sx:{borderBottom:({palette:i})=>S<Object.keys(s).length-1?`1px solid ${i.divider}`:"none",px:0,py:1,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(d,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:i=>{i.target.closest(".MuiFormControlLabel-root")||g(n,i)},children:[e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:m.length>0&&e.jsx(ie,{control:e.jsx(J,{checked:R,indeterminate:D&&!R,onChange:i=>{i.stopPropagation(),z(m,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[l.logo&&e.jsx($e,{src:l.logo,sx:{width:24,height:24}}),e.jsx(d,{children:l.title||n}),D&&e.jsx(L,{label:r("webhookEndpoint.selectedCount",{count:j[n]}),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(d,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(C,{variant:"body2",sx:{color:"text.secondary",mr:1},children:r("webhookEndpoint.eventsCount",{count:k})}),m.length>0&&e.jsx(M,{size:"small",edge:"end",children:O?e.jsx(Pe,{}):e.jsx(qe,{})})]})]})}),m.length>0&&e.jsx(Le,{in:O,timeout:"auto",unmountOnExit:!0,children:e.jsx(Z,{disablePadding:!0,sx:{p:0,bgcolor:"rgba(0, 0, 0, 0.01)"},children:m.map(i=>{const h=`${i.type}-${i.source}`,o=!!p[h];return e.jsx(G,{dense:!0,sx:{py:.75,px:1},onClick:()=>y(i),children:e.jsxs(d,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(J,{checked:o,sx:{flexShrink:0}}),e.jsxs(d,{sx:{flex:1,minWidth:0},children:[e.jsx(C,{variant:"body1",className:"webhook-event-type",sx:{cursor:"pointer",color:"text.primary",wordBreak:"break-word",overflowWrap:"break-word"},children:i.type}),e.jsx(C,{variant:"caption",sx:{color:"text.secondary",display:"block",cursor:"pointer",wordBreak:"break-word",overflowWrap:"break-word"},children:i.description})]})]})},h)})})})]},n)})})}),f&&e.jsx(Be,{error:!0,sx:{mt:1},children:f})]})}fe.propTypes={eventsBySource:t.objectOf(t.shape({source:t.shape({did:t.string.isRequired,title:t.string,description:t.string,version:t.string,logo:t.string}).isRequired,events:t.arrayOf(t.shape({type:t.string.isRequired,description:t.string.isRequired,source:t.string.isRequired})).isRequired,count:t.number.isRequired})).isRequired,selectedEvents:t.objectOf(t.bool).isRequired,setSelectedEvents:t.func.isRequired,error:t.string};function je({id:s=null,url:p="",description:c="",enabledEvents:f=[],onSubmit:r,onClose:w=()=>{}}){const{t:u}=B(),[j,a]=v.useState({}),{teamDid:b}=Y(),{api:g}=V(),{loading:y,error:z,eventsBySource:I}=it(),n=We(),{control:l,handleSubmit:m,formState:{errors:k},reset:S,setValue:D,trigger:R}=tt({defaultValues:{url:"",description:""}}),O=de(n.breakpoints.down("md"));v.useEffect(()=>{const o=Object.values(j).some(x=>x);D("selectedEvents",o?"valid":""),R("selectedEvents")},[j,D,R]);const i=()=>{a({}),S(),w()},h=async o=>{const x=Object.keys(j).filter(T=>j[T]),E={url:o.url,description:o.description,enabledEvents:x.map(T=>{const[A,ne]=T.split("-");return!A||!ne?null:{type:A,source:ne}}).filter(Boolean)};try{if(s){const T=await g.updateWebhookEndpoint({input:{teamDid:b,id:s,data:E}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),r(T)}else{const T=await g.createWebhookEndpoint({input:{teamDid:b,input:E}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),r(T)}}catch(T){q.error(T?.message)}i()};return v.useEffect(()=>{S({url:p,description:c}),a(f.reduce((o,x)=>(o[`${x.type}-${x.source}`]=!0,o),{}))},[S,a,p,c,f]),e.jsx(ze,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,fullScreen:O,children:e.jsxs("form",{onSubmit:m(h),children:[e.jsx(De,{children:u(s?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Oe,{children:e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(X,{name:"url",control:l,rules:{required:u("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:u("webhookEndpoint.validation.urlInvalid")}},render:({field:o})=>e.jsx(se,{...o,label:u("webhookEndpoint.url.label"),fullWidth:!0,error:!!k.url,helperText:k.url?.message})}),e.jsx(X,{name:"description",control:l,rules:{required:u("webhookEndpoint.validation.descriptionRequired")},render:({field:o})=>e.jsx(se,{...o,label:u("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!k.description,helperText:k.description?.message})}),e.jsx(X,{name:"selectedEvents",control:l,rules:{required:u("webhookEndpoint.validation.eventRequired")},render:({field:o})=>e.jsx("input",{type:"hidden",...o})}),!y&&I&&Object.keys(I).length>0&&e.jsx(fe,{eventsBySource:I,selectedEvents:j,setSelectedEvents:a,error:k.selectedEvents?.message}),!y&&(!I||Object.keys(I).length===0)&&e.jsx(C,{sx:{color:"text.secondary"},children:u("webhookEndpoint.noAvailableEvents")}),y&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(U,{size:20})}),z&&e.jsx(te,{severity:"error",children:u("webhookEndpoint.loadingError",{message:z?.message})})]})}),e.jsxs(Ae,{sx:{p:"8px 24px 24px"},children:[e.jsx(N,{onClick:i,children:u("common.cancel")}),e.jsx(N,{type:"submit",variant:"contained",color:"primary",children:u(s?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}je.propTypes={onSubmit:t.func.isRequired,id:t.string,url:t.string,description:t.string,enabledEvents:t.arrayOf(t.shape({type:t.string.isRequired,source:t.string.isRequired})),onClose:t.func};function rt(s){switch(s){case"enabled":return"success";case"disabled":default:return"default"}}const lt=(s="en")=>s==="tw"?"zh":s;function H(s,p="YYYY-MM-DD HH:mm:ss",c="en"){return s?Xe(s).locale(lt(c)).format(p):"-"}function at(s){return typeof s=="number"?!1:be(s)}function ct(s){return s>=200&&s<300}function $({value:s,label:p,tip:c="",divider:f=!1}){const r=at(s);return e.jsxs(e.Fragment,{children:[e.jsxs(W,{direction:"column",alignItems:"flex-start",children:[e.jsxs(C,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[p,!!c&&e.jsx(P,{title:c,children:e.jsx(_,{fontSize:"small"})})]}),e.jsx(C,{component:"div",variant:"body1",color:r?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:r?"-":s})]}),f&&e.jsx(pe,{orientation:"vertical",flexItem:!0})]})}$.propTypes={label:t.oneOfType([t.string,t.node]).isRequired,value:t.oneOfType([t.string,t.node]).isRequired,tip:t.oneOfType([t.string,t.node]),divider:t.bool};function ye({title:s,children:p=null,mb:c=1.5,mt:f=1.5}){return e.jsxs(W,{className:"section-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,mb:c,mt:f,pb:1},children:[e.jsx(C,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:s}),p]})}ye.propTypes={title:t.oneOfType([t.string,t.node]).isRequired,children:t.node,mb:t.number,mt:t.number};const dt={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},pt=s=>{const p={};return s.forEach(c=>{const f=new Date(c.createdAt).toLocaleDateString();p[f]||(p[f]=[]),p[f]?.push(c)}),p};function we({eventId:s="",webhookEndpointId:p="",event:c=null}){const{api:f,ws:{useSubscription:r}}=V(),{t:w}=B(),{teamDid:u}=Y(),{blocklet:j}=Ze(),{data:a,loadMore:b,loadingMore:g,loading:y,mutate:z}=Ie(o=>{const E=o?Math.ceil(o.list.length/15)+1:1;return f.getWebhookAttempts({input:{teamDid:u,input:{eventId:s,webhookId:p},paging:{page:E,pageSize:15}}})},{reloadDeps:[s,p]}),I=a?.list||[],[n,l]=v.useState(null),[m,k]=v.useState(!1),S=pt(I);if(v.useEffect(()=>{!n&&a?.list.length&&l(a.list[0])},[a?.list.length,n]),r(ue.EVENTS.WEBHOOK_ATTEMPT,o=>{z(x=>{if(x.list.find(T=>T.id===o.id)){const T=x.list.map(A=>A.id===o.id?{...A,...o}:A);return{...x,list:T}}return o.endpoint=x.list[0]?.endpoint,o.event=x.list[0]?.event,{...x,list:[o,...x.list]}})},[]),y)return e.jsx(U,{});const D=a&&a.list.length<a.paging.total,R=async()=>{n&&(k(!0),await f.retryWebhookAttempt({input:{teamDid:u,eventId:n.event.id,webhookId:p,attemptId:n.id}}).finally(()=>{setTimeout(()=>{k(!1)},1e3)}))},O=o=>{if(o.responseBody&&o.responseBody?.sessionId&&o.responseBody?.projectId&&o.responseBody?.agentId){const x=j?.site?.domainAliases[0]?.value,E=(j.children||[]).find(A=>A?.meta?.name==="ai-studio"),T=ot(ge(`https://${x}`,E?.mountPoint||"","projects",o.responseBody.projectId,"logs/main"),{sessionId:o.responseBody.sessionId,agentId:o.responseBody.agentId});return e.jsx(M,{sx:{fontSize:20},onClick:()=>window.open(T,"_blank"),children:e.jsx(d,{component:F,icon:Q})})}return null},i=o=>o.status==="pending"?e.jsx(He,{color:"warning"}):ct(o.responseStatus)?e.jsx(Ue,{color:"success"}):e.jsx(_e,{color:"error"}),h=n?.triggeredFrom&&(a?.list||[]).find(o=>o.id===n.triggeredFrom);return e.jsxs(ut,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ee,{size:{xs:12,md:4},sx:{height:1},children:be(Object.keys(S))?e.jsx(C,{sx:{color:"text.secondary"},children:w("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(S).map(([o,x])=>e.jsxs(ce.Fragment,{children:[e.jsx(Me,{sx:{p:0},children:o}),x.map(E=>e.jsxs(G,{sx:{cursor:"pointer",px:1},onClick:()=>l(E),selected:n&&n?.id===E?.id,secondaryAction:e.jsx(C,{sx:{color:"text.secondary"},children:H(E.createdAt,"HH:mm:ss")}),children:[e.jsx(Ne,{sx:{minWidth:0,mr:1.5},children:i(E)}),e.jsx(Fe,{primary:e.jsx(C,{sx:{color:"text.primary"},children:E.event.type})})]},E.id))]},o))}),D&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1},children:e.jsx(N,{variant:"text",type:"button",color:"inherit",onClick:b,disabled:g,sx:{color:o=>o.palette.text.disabled},children:w(g?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ee,{size:{xs:12,md:8},sx:{height:1},children:[n&&e.jsxs(W,{direction:"column",spacing:2,sx:{height:1,overflow:"auto",pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"h4",children:w(`common.${n.status}`)}),e.jsx(d,{children:O(n)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[h&&e.jsx(P,{placement:"left",title:e.jsxs(W,{onClick:()=>l(h),sx:{gap:1,cursor:"pointer",".did-address-text":{color:"common.white"}},children:[e.jsx(xe,{showDid:!0,did:n.triggeredBy,cardType:me.Detailed,infoType:he.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(pe,{}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(C,{variant:"body2",sx:{color:"primary.main"},children:w("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"body2",children:n.id}),e.jsx(M,{onClick:()=>l(h),children:e.jsx(d,{component:F,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),slotProps:{tooltip:{sx:{maxWidth:400}}},children:e.jsx(M,{onClick:()=>l(h),children:e.jsx(d,{component:F,icon:Q,sx:{fontSize:16}})})}),e.jsxs(N,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:m,children:[e.jsx(d,{component:F,icon:dt,sx:{fontSize:16,animation:m?"spin 1s linear infinite":"none",mr:.5}}),w("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(C,{variant:"h6",children:[w("webhookEndpoint.response")," (",n.responseStatus,")"]}),e.jsx(K,{language:"json",children:JSON.stringify(n.responseBody,null,2)})]}),e.jsxs(d,{children:[e.jsx(W,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(C,{variant:"h6",children:w("webhookEndpoint.request")})}),e.jsx(K,{language:"json",sx:{margin:0},children:JSON.stringify(n.event,null,2)})]})]}),a?.list.length===0&&c&&e.jsxs(d,{children:[e.jsx(W,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(C,{variant:"h6",children:w("webhookEndpoint.eventData")})}),e.jsx(K,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}we.propTypes={eventId:t.string,webhookEndpointId:t.string,event:t.shape({type:t.string,data:t.object,request:t.object,requestInfo:t.object})};const ut=oe(ee)`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
to {
|
|
4
4
|
transform: rotate(360deg);
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
`;function ke({id:
|
|
7
|
+
`;function ke({id:s,onClose:p}){const{t:c}=B(),{api:f}=V(),{teamDid:r}=Y(),{loading:w,error:u,data:j}=ae(()=>f.getWebhookEndpoint({input:{teamDid:r,id:s}})),a=j?.data;return u?e.jsx(te,{severity:"error",children:u.message}):w||!a?e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1},children:e.jsx(U,{})}):e.jsxs(xt,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(d,{children:[e.jsxs(W,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsx(W,{sx:{flex:1,width:0},children:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"h5",sx:{fontWeight:600,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:a.description}),e.jsx(P,{title:a.url,children:e.jsx(_,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(W,{direction:"row",sx:{alignItems:"center"},children:e.jsx(M,{edge:"end",color:"inherit",onClick:p,children:e.jsx(Ye,{})})})]}),e.jsx(d,{sx:{mt:2},children:e.jsxs(W,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},sx:{justifyContent:"flex-start",flexWrap:"wrap",pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx($,{label:c("common.status"),value:e.jsx(L,{size:"small",variant:"filled",label:a.status,color:rt(a.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx($,{label:c("webhookEndpoint.listen"),value:e.jsx(P,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:a.enabledEvents.map(b=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:b?.type},b))}),children:e.jsx(L,{size:"small",variant:"filled",label:c("webhookEndpoint.eventsCount",{count:a.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx($,{label:c("webhookEndpoint.version"),value:a.apiVersion,divider:!0}),e.jsx($,{label:c("common.createdAt"),value:H(a.createdAt),divider:!0}),e.jsx($,{label:c("common.updatedAt"),value:H(a.updatedAt),divider:!0}),e.jsx($,{label:c("common.createdBy"),value:e.jsx(P,{arrow:!0,title:a.createUser?.did,children:e.jsx(L,{size:"small",variant:"filled",label:a.createUser?.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx($,{label:c("common.updatedBy"),value:e.jsx(P,{arrow:!0,title:a.updateUser?.did,children:e.jsx(L,{size:"small",variant:"filled",label:a.updateUser?.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(W,{className:"section",sx:{flex:1,height:0,overflow:"hidden"},children:[e.jsx(ye,{title:c("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(W,{sx:{height:0,flex:1,overflow:"hidden"},children:e.jsx(we,{webhookEndpointId:a.id})})]})]})}ke.propTypes={id:t.string.isRequired,onClose:t.func.isRequired};const xt=oe(W)``;function Ee({open:s,onClose:p,id:c}){return e.jsx(Ve,{anchor:"right",open:s,onClose:p,slotProps:{paper:{sx:{width:"90vw",maxWidth:"1200px"}}},children:e.jsx(d,{sx:{height:"100vh",p:3},children:e.jsx(ke,{id:c,onClose:p})})})}Ee.propTypes={open:t.bool.isRequired,onClose:t.func.isRequired,id:t.string.isRequired};function le(){return null}function ve({options:s={},columns:p=[],toolbar:c=!0,footer:f=!0,hasRowLink:r=!1,emptyNodeText:w="",durable:u="",durableKeys:j=[],data:a=[],loading:b=!1,...g}){const{locale:y}=B(),z=de(l=>l.breakpoints.down("md")),I={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:z?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},n={};return c||(n.TableToolbar=le),f||(n.TableFooter=le),e.jsx(ht,{locale:y,options:{...I,...s},columns:(p||[]).map(l=>(l.options=l.options||{},l.options.filter=l.options.filter||!1,l.options.sort=l.options.sort||!1,l)),emptyNode:e.jsx(Ce,{children:w}),...g,durable:u,durableKeys:j,data:a,loading:b,components:n,hasRowLink:r,isMobile:z})}ve.propTypes={options:t.object,columns:t.array,toolbar:t.bool,footer:t.bool,hasRowLink:t.bool,emptyNodeText:t.node,durable:t.string,durableKeys:t.array,data:t.array,loading:t.bool,onChange:t.func,title:t.node,components:t.object};const ht=oe(Se)``,mt=v.memo(ve);function $t(){const{teamDid:s}=Y(),p=et(),c=`webhook-endpoints-${s}`,f=Te(c),{t:r,locale:w}=B(),{api:u}=V(),[j,a]=v.useState(""),[b,g]=v.useState({webhookDetail:{open:!1,id:null},createEdit:{open:!1,id:null,url:"",description:"",enabledEvents:[]},deleteConfirm:null}),[y,z]=Re(c,{defaultValue:{pageSize:f.rowsPerPage||20,page:f.page?f.page+1:1}}),{loading:I,error:n,data:l,refresh:m}=ae(()=>u.getWebhookEndpoints({input:{teamDid:s,paging:{page:y.page,pageSize:y.pageSize}}}));v.useEffect(()=>{m()},[y,m]);const k=v.useCallback(async(i,h)=>{try{await u.updateWebhookEndpoint({input:{teamDid:s,id:i.id,data:{status:h?"disabled":"enabled"}}}),m(),q.success(`${r(h?"webhookEndpoint.disable":"webhookEndpoint.enable")}${r("webhookEndpoint.success")}`)}catch(o){q.error(o?.message)}},[u,s,m,r]),S=v.useCallback(async i=>{try{await u.deleteWebhookEndpoint({input:{teamDid:s,id:i}}),m(),g(h=>({...h,deleteConfirm:null})),q.success(`${r("common.delete")}${r("webhookEndpoint.success")}`)}catch(h){q.error(h?.message)}},[u,s,m,r]),D=(i,h)=>{let o=i.page+1;const x=i.searchText||"";if(x!==j){a(x);return}if(h==="changePage"||h==="changeRowsPerPage"){h!=="changePage"&&(o=1);const E={page:o,pageSize:i.rowsPerPage};a(""),z(E)}};if(n)return e.jsx(te,{severity:"error",children:n.message});const R=(l?.list||[]).filter(i=>{if(!j)return!0;const h=j.toLowerCase();return i.description.toLowerCase().includes(h)||i.url.toLowerCase().includes(h)}),O=[{label:"URL",name:"url",options:{customBodyRenderLite:(i,h)=>{const o=R[h];return e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer",gap:.5},children:[e.jsx(C,{variant:"body2",children:o.description}),e.jsx(d,{sx:{display:"flex"},onClick:x=>{x.stopPropagation()},children:e.jsx(P,{title:o.url,children:e.jsx(_,{sx:{fontSize:"15px",marginTop:"1px"}})})})]})}}},{label:"Events",name:"events",options:{customBodyRenderLite:(i,h)=>{const o=R[h];return e.jsx(d,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:o.enabledEvents.map(x=>e.jsx(L,{size:"small",variant:"filled",label:x.type,sx:{borderRadius:"4px",textTransform:"capitalize"}},`${o.source}-${x.type}`))})}}},{label:r("common.status"),name:"status",options:{customBodyRenderLite:(i,h)=>{const o=R[h],x=o?.status==="enabled";return e.jsx(d,{onClick:E=>E.stopPropagation(),children:e.jsx(Ge,{checked:x,onChange:()=>k(o,x)},`status-${o.status}`)})}}},{label:r("common.createdAt"),name:"createdAt",minWidth:200,options:{customBodyRender:i=>H(i)}},{label:r("common.createdBy"),name:"createUser",width:100,options:{customBodyRender:i=>i?e.jsx(xe,{showDid:!0,did:i?.did,cardType:me.Detailed,infoType:he.Minimal,sx:{border:0,padding:0}}):"-"}},{label:r("common.actions"),name:"actions",width:100,align:"center",verticalKeyAlign:"center",options:{customBodyRenderLite:(i,h)=>{const o=R[h];return e.jsx(st,{actions:[{icon:e.jsx(Ke,{}),text:r("common.edit"),onClick:x=>{x.stopPropagation(),g(E=>({...E,createEdit:{open:!0,id:o.id,url:o.url,description:o.description,enabledEvents:o.enabledEvents}}))}},{icon:e.jsx(Je,{}),text:r("common.delete"),onClick:x=>{x.stopPropagation(),g(E=>({...E,deleteConfirm:{title:r("webhookEndpoint.deleteWebhook.title"),description:r("webhookEndpoint.deleteWebhook.description"),confirm:r("common.confirm"),cancel:r("common.cancel"),onConfirm:()=>S(o.id),onCancel:()=>g(T=>({...T,deleteConfirm:null}))}}))}}]})}}}];return e.jsxs(d,{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(re,{title:r("webhookEndpoint.listTitle"),tooltipTitle:r("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${w}/webhook`}):null,e.jsx(mt,{durable:c,durableKeys:["page","rowsPerPage"],data:R,columns:O,options:{count:l?.count||0,page:y.page-1,rowsPerPage:y.pageSize,viewColumns:!1,onRowClick:(i,{dataIndex:h})=>{const o=l.list[h];g(x=>({...x,webhookDetail:{open:!0,id:o.id}}))}},loading:I||!l,onChange:D,emptyNodeText:e.jsx(W,{sx:{gap:1},children:r("webhookEndpoint.noWebhooksAdded")}),title:p?null:e.jsx(re,{title:r("webhookEndpoint.listTitle"),tooltipTitle:r("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${w}/webhook`}),customButtons:[e.jsxs(N,{edge:"end",variant:"contained",color:"primary",onClick:()=>g(i=>({...i,createEdit:{...i.createEdit,open:!0}})),className:"rule-action",children:[I?e.jsx(U,{size:16}):e.jsx(Qe,{style:{fontSize:16}}),r("common.create")]},"add")]}),b.webhookDetail.open&&e.jsx(Ee,{open:!0,onClose:()=>g(i=>({...i,webhookDetail:{open:!1,id:null}})),id:b.webhookDetail.id}),b.createEdit.open&&e.jsx(je,{onSubmit:m,...b.createEdit,onClose:()=>g(i=>({...i,createEdit:{id:null,url:"",description:"",enabledEvents:[],open:!1}}))}),b.deleteConfirm&&e.jsx(nt,{title:b.deleteConfirm.title,description:b.deleteConfirm.description,confirm:b.deleteConfirm.confirm,cancel:b.deleteConfirm.cancel,params:b.deleteConfirm.params,onConfirm:b.deleteConfirm.onConfirm,onCancel:b.deleteConfirm.onCancel})]})}export{$t as default};
|