@abtnode/blocklet-services 1.16.41-beta-20250317-081605-78d4ac9f → 1.16.41-beta-20250318-012955-51b0ae39
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/routes/federated.js +1 -1
- package/dist/assets/{ArrowDropDown-CtEg66Nq.js → ArrowDropDown-qWbq0JMo.js} +1 -1
- package/dist/assets/{CheckCircle-BuPNyrGd.js → CheckCircle-B3DI9-8u.js} +1 -1
- package/dist/assets/{ChevronLeft-BZHXIpzy.js → ChevronLeft-QmS7XZ0_.js} +1 -1
- package/dist/assets/{ChevronRight-BXXXrhFv.js → ChevronRight-C-wVLPcS.js} +1 -1
- package/dist/assets/{DeleteOutline-DCfU8S8N.js → DeleteOutline-DMkWy6Ct.js} +1 -1
- package/dist/assets/{Done-Bsq7HbxW.js → Done-DMtnp3P-.js} +1 -1
- package/dist/assets/{Download-BLfOzhjl.js → Download-BBNJo00y.js} +1 -1
- package/dist/assets/{Error-qNvnuA99.js → Error-H665t4TD.js} +1 -1
- package/dist/assets/{ExpandLess-DAOEsB9B.js → ExpandLess-DBi9UnX8.js} +1 -1
- package/dist/assets/{Google-C4J7xVtM.js → Google-Dmn0CqqC.js} +1 -1
- package/dist/assets/{InfoOutlined-rkRdeKC5.js → InfoOutlined-A0h5OX7J.js} +1 -1
- package/dist/assets/{Launch-DV_ImUvs.js → Launch-Ca2Avd-H.js} +1 -1
- package/dist/assets/{LaunchOutlined-CDg4y6WY.js → LaunchOutlined-LqfRJ-HK.js} +1 -1
- package/dist/assets/{MoreHoriz-CuvFfU0y.js → MoreHoriz-I4HIq7xK.js} +1 -1
- package/dist/assets/{PlayArrow-CLDLFBEz.js → PlayArrow-ByDKBx4g.js} +1 -1
- package/dist/assets/{ViewList-BrYCQvV9.js → ViewList-CHv7QZAz.js} +1 -1
- package/dist/assets/{access-control-DII-9ikG.js → access-control-CWfdDjGm.js} +1 -1
- package/dist/assets/{actions-DjjGu4UQ.js → actions-BlT0cxUG.js} +1 -1
- package/dist/assets/{add-component-core-l7eYqkcZ.js → add-component-core-CkafMVNq.js} +1 -1
- package/dist/assets/{add-resource-B-uOSjee.js → add-resource-B6yfNhfJ.js} +1 -1
- package/dist/assets/{addon-Fx9KF8Su.js → addon-CY_qIvTD.js} +1 -1
- package/dist/assets/{analytics-BzVmZXLx.js → analytics-DjXhSquU.js} +1 -1
- package/dist/assets/{audit-logs-6d1SUyKM.js → audit-logs-f63v6qb6.js} +1 -1
- package/dist/assets/{base32-D0fEqWLU.js → base32-BFbPN3_B.js} +1 -1
- package/dist/assets/{branding-Cc0iMYBr.js → branding-M3jcBXbn.js} +2 -2
- package/dist/assets/{bundle-avatar-B24HOX02.js → bundle-avatar-CV6DwAbG.js} +1 -1
- package/dist/assets/{button-Ovivwijh.js → button-CobAXYnZ.js} +1 -1
- package/dist/assets/{click-to-copy-B-4HpGBR.js → click-to-copy-4DAi5FNW.js} +1 -1
- package/dist/assets/{complete-klpTcUr7.js → complete-BV8Jki_A.js} +1 -1
- package/dist/assets/{component-JusM4mdk.js → component-CHjmE2X3.js} +1 -1
- package/dist/assets/{config-DSpXNs0H.js → config-AQxF4UXZ.js} +1 -1
- package/dist/assets/{config-B7Op-jMJ.js → config-D26mW5ts.js} +1 -1
- package/dist/assets/{config-navigation-Cck8KMTG.js → config-navigation-CWecd6yU.js} +3 -3
- package/dist/assets/{config-space-CA1tXI_o.js → config-space-CEfS-edx.js} +1 -1
- package/dist/assets/{confirm-DMy0Z-Cg.js → confirm-AquAQGjx.js} +1 -1
- package/dist/assets/{connect-CGsQ7PAL.js → connect-BUUxpeii.js} +1 -1
- package/dist/assets/{connect-CAQBQP_r.js → connect-C3HOcFE4.js} +1 -1
- package/dist/assets/{connect-to-C48I4t4k.js → connect-to-DIh1QUDe.js} +1 -1
- package/dist/assets/{dashboard-C8G4QNFK.js → dashboard-CgU5vYTc.js} +3 -3
- package/dist/assets/{delete-confirm-BzVr7-y3.js → delete-confirm-3NLpiaw3.js} +1 -1
- package/dist/assets/{did-address-DI0KYPba.js → did-address-BOFBaeCw.js} +1 -1
- package/dist/assets/{domain-CO5mMUbM.js → domain-By_3gkYk.js} +1 -1
- package/dist/assets/{domain-action-card-DitTZMiy.js → domain-action-card-3cxCJSVs.js} +1 -1
- package/dist/assets/domains-UcV83Tm2.js +1 -0
- package/dist/assets/{email-TJz2dZ0g.js → email-CIF4NKca.js} +1 -1
- package/dist/assets/{exchange-passport-BA3EOJok.js → exchange-passport-CzS1Xb1d.js} +1 -1
- package/dist/assets/{form-text-input-CegsXoAM.js → form-text-input-BAXS_3xu.js} +1 -1
- package/dist/assets/{fuel-D9brmzbD.js → fuel-mq0wsfbI.js} +1 -1
- package/dist/assets/{fullpage-uIWsQtmj.js → fullpage-Bo8SoEA1.js} +1 -1
- package/dist/assets/{get-safe-url-B4zzurU3.js → get-safe-url-RpxfbZMw.js} +1 -1
- package/dist/assets/{get-safe-url-hqF7Ndco.js → get-safe-url-zNlUtfl-.js} +1 -1
- package/dist/assets/{home-qtsqiK-L.js → home-D5_68Jum.js} +1 -1
- package/dist/assets/{iframe-C4ss0xsS.js → iframe-Dg-K9tKI.js} +1 -1
- package/dist/assets/{index-CrhkEqZc.js → index-9xLdpFIQ.js} +1 -1
- package/dist/assets/{index-CpY5Ue9D.js → index-B1eW_9jO.js} +1 -1
- package/dist/assets/{index-D2EPosV7.js → index-BNbCkJGk.js} +1 -1
- package/dist/assets/{index-U5YoDbx2.js → index-BQaClmdg.js} +1 -1
- package/dist/assets/{index-BBAxz1Tc.js → index-BYV52_OZ.js} +1 -1
- package/dist/assets/{index-CbTQ4lIG.js → index-Bgf07DdH.js} +4 -4
- package/dist/assets/{index-DncDUWgv.js → index-BkWaMAY7.js} +1 -1
- package/dist/assets/{index-PBzCnxwv.js → index-C564BFHJ.js} +1 -1
- package/dist/assets/{index-Bj3VGwFb.js → index-CE2_NNHG.js} +1 -1
- package/dist/assets/{index-DDbdl3JK.js → index-CT7JoARP.js} +1 -1
- package/dist/assets/{index-DQfSqIsx.js → index-CeZInncP.js} +1 -1
- package/dist/assets/{index-DtRVG_dr.js → index-CosUPggW.js} +1 -1
- package/dist/assets/{index-D0Krnqwu.js → index-DNXaKH5L.js} +3 -3
- package/dist/assets/{index-B7Yzqt2Y.js → index-DXodzmv1.js} +3 -3
- package/dist/assets/{index-Bq4sZh-h.js → index-DxEhSAq4.js} +1 -1
- package/dist/assets/{index-ETElQ8TU.js → index-S_LbRHmk.js} +1 -1
- package/dist/assets/{invitation-BN7im9vR.js → invitation-BXtb5O-j.js} +1 -1
- package/dist/assets/{invite-CnZFo52T.js → invite-WH242mWa.js} +1 -1
- package/dist/assets/{issue-passport-Bn015I73.js → issue-passport-B4E8dvwf.js} +1 -1
- package/dist/assets/{item-DYR84j8s.js → item-CBVHWk6p.js} +1 -1
- package/dist/assets/{layout-Bl-9oVlU.js → layout-DfSNPKMl.js} +1 -1
- package/dist/assets/{list-ZqiWwQBr.js → list-CENIOVAm.js} +1 -1
- package/dist/assets/{localization-DBsXh-vs.js → localization-Dp5KNtVj.js} +1 -1
- package/dist/assets/{log-DydzQpeq.js → log-BXebsTbr.js} +1 -1
- package/dist/assets/{login-DeyHmh3s.js → login-Ocw0I3pN.js} +1 -1
- package/dist/assets/{login-oauth-callback-D68ITJ_5.js → login-oauth-callback-BRNb2ryy.js} +1 -1
- package/dist/assets/{logo-uploader-E6Z1ifEI.js → logo-uploader-BbLU5__c.js} +3 -3
- package/dist/assets/{lost-passport-Cls8Ny2g.js → lost-passport-AqXyVK_F.js} +1 -1
- package/dist/assets/{open-window-ebi04F1H.js → open-window-Cd4yc8mA.js} +1 -1
- package/dist/assets/{overview-DuL7x-9z.js → overview-3qBN9FRv.js} +1 -1
- package/dist/assets/{page-header-Jx-c4tin.js → page-header-5sm-cgQK.js} +1 -1
- package/dist/assets/{permission-ClEZ_MHG.js → permission-DQCYXQUJ.js} +1 -1
- package/dist/assets/{preferences-BX88oaKC.js → preferences-CGAPawRw.js} +1 -1
- package/dist/assets/{profile-embed-Ciu1TPD5.js → profile-embed-CsLOY-3P.js} +1 -1
- package/dist/assets/{publish-resource-Cx1UaR8u.js → publish-resource-CAFJkTLS.js} +1 -1
- package/dist/assets/{react-beautiful-dnd.esm-BESvhBe5.js → react-beautiful-dnd.esm-CIox0WsN.js} +1 -1
- package/dist/assets/{relative-time-C4f3PU1u.js → relative-time-CRrl1gSW.js} +1 -1
- package/dist/assets/sdk-CrU7nlFr.js +1 -0
- package/dist/assets/{session-IeX2Dw6x.js → session-D7wR69VL.js} +1 -1
- package/dist/assets/{setup-Z0et4-i9.js → setup-JUlzHBjh.js} +3 -3
- package/dist/assets/{start-CfKV19sr.js → start-CAAERMvb.js} +1 -1
- package/dist/assets/{status-DzqZofA0.js → status-DnvDsTz6.js} +1 -1
- package/dist/assets/{step-actions-BT4kSCcI.js → step-actions-LZ6_MGpe.js} +1 -1
- package/dist/assets/{studio-CWhY3lnO.js → studio-Ccy_TWjv.js} +1 -1
- package/dist/assets/{switch-control-oTrySiOn.js → switch-control-BsVebsZm.js} +1 -1
- package/dist/assets/{traffic-CSjRXGq0.js → traffic-BHL1S-qx.js} +1 -1
- package/dist/assets/{transfer-Bggrb00q.js → transfer-Cnv8HjKE.js} +1 -1
- package/dist/assets/{unsubscribe-CnJy5hkO.js → unsubscribe-BviNUKwm.js} +1 -1
- package/dist/assets/{useLocalStorage-DWM7Bn98.js → useLocalStorage-CCDYY4Oj.js} +1 -1
- package/dist/assets/{user-center-CgSHPqou.js → user-center-D0D8fiVb.js} +1 -1
- package/dist/assets/{util-CUEC1wTh.js → util-B7dUkIpg.js} +1 -1
- package/dist/assets/{util-Bslt0VzU.js → util-pKcd70El.js} +1 -1
- package/dist/assets/{vendor-arcblock-Cy3mvd3t.js → vendor-arcblock-BmGcldk1.js} +154 -154
- package/dist/assets/{vendor-ux-did-connect-2-XNNtOB.js → vendor-ux-did-connect-4bCiyPYS.js} +72 -72
- package/dist/assets/{wrap-locale-i2hWItZ7.js → wrap-locale-h-Rh8AV-.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/service-worker.js +1 -1
- package/package.json +32 -32
- package/dist/assets/domains-oxnp0m5c.js +0 -1
- package/dist/assets/sdk-DraYzvwl.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as q,V as z,bK as K,i as be,X as fe,a2 as ge,bC as je}from"./vendor-ux-did-connect-2-XNNtOB.js";import{w as ye,l as de,j as we}from"./vendor-hooks-DbRTDIFw.js";import{r as C,b as X}from"./vendor-react-DoD83n6N.js";import{d as Z}from"./InfoOutlined-rkRdeKC5.js";import{z as N,C as ce,G as ke}from"./index-B7Yzqt2Y.js";import{u as F}from"./dashboard-C8G4QNFK.js";import{E as o,j as e,D as ve,ab as Ee,r as Ce,a3 as f,M as ie,T as S,a2 as U,ac as ee,y as Te,x as B,bn as le,bO as V,a4 as A,L as G,z as Q,bg as Se,A as O,I as _,C as Re,bl as Ie,ad as P,cG as Me,ak as Pe,bd as Y,bk as De,b1 as We,cH as ze,cI as Ae,b2 as Oe,af as $e,bS as qe,s as pe,t as Le,cJ as Be,cK as He,cL as Ne,cM as Fe,cN as Ue}from"./vendor-mui-core-O22FPGM4.js";import{u as _e,C as J}from"./index.esm-CWepf7I_.js";import{n as Ke}from"./vendor-arcblock-Cy3mvd3t.js";import{d as Ve}from"./ExpandLess-DAOEsB9B.js";import{y as ue,w as Ye,x as Je}from"./vendor-utils-DJ1bmiuG.js";import{C as Ge}from"./confirm-DMy0Z-Cg.js";import{A as Qe}from"./actions-DjjGu4UQ.js";import"./lottie-web-B6s7dDoL.js";import"./useLocalStorage-DWM7Bn98.js";import"./PlayArrow-CLDLFBEz.js";import"./get-safe-url-hqF7Ndco.js";import"./format-error-LAoTjvJe.js";import"./index-CrhkEqZc.js";import"./session-IeX2Dw6x.js";import"./useAsyncRetry-CcF3e_P6.js";import"./useAsync-CDzQ0uN6.js";import"./useSetState-BL3ktMon.js";import"./MoreHoriz-CuvFfU0y.js";const Xe=t=>{var j,y;const[d,c]=C.useState(null),[a,b]=C.useState(!t),[R,p]=C.useState(null),{blocklet:n}=ce(),l=(y=(j=n==null?void 0:n.site)==null?void 0:j.domainAliases[0])==null?void 0:y.value,v=C.useMemo(()=>{const h={};return d&&(d.sources.forEach(r=>{h[r.did]={source:r,events:[],count:0}}),d.events.forEach(r=>{h[r.source]&&(h[r.source].events.push(r),h[r.source].count+=1)})),h},[d]),T=async()=>{try{if(b(!0),!l)return;const r=await(await fetch(`https://${l}/.well-known/service/openevent.json`)).json();c(r),p(null)}catch(h){p(h instanceof Error?h:new Error(String(h)))}finally{b(!1)}};return C.useEffect(()=>{T()},[l]),{openEvent:d,setOpenEvent:c,eventsBySource:v,loading:a,error:R,loadData:T}};function te({eventsBySource:t,selectedEvents:d,setSelectedEvents:c,error:a}){const{t:b}=q(),[R,p]=C.useState({}),n=C.useMemo(()=>{const r={};return Object.entries(t).forEach(([w,{events:g}])=>{const E=g.filter(u=>d[`${u.type}-${u.source}`]).length;r[w]=E}),r},[t,d]),l=C.useMemo(()=>Object.values(n).reduce((r,w)=>r+w,0),[n]),v=C.useMemo(()=>Object.values(t).reduce((r,{events:w})=>r+w.length,0),[t]),T=(r,w)=>{w.stopPropagation(),p({...R,[r]:!R[r]})},j=r=>{const w=`${r.type}-${r.source}`;c(g=>({...g,[w]:!g[w]}))},y=(r,w)=>{const g={};r.forEach(E=>{const u=`${E.type}-${E.source}`;g[u]=!w}),c(E=>({...E,...g}))},h=r=>{const w={};Object.values(t).forEach(({events:g})=>{g.forEach(E=>{const u=`${E.type}-${E.source}`;w[u]=r.target.checked})}),c(w)};return e.jsxs(f,{sx:{width:"100%"},children:[e.jsxs(f,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(le,{control:e.jsx(V,{onChange:h,checked:l>0&&l===v}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[b("webhookEndpoint.selectAllEvents"),e.jsx(f,{sx:{display:"flex",alignItems:"center"},children:e.jsx(A,{title:b("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(Z,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),l>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:b("webhookEndpoint.selectedEventsCount",{count:l})})]}),e.jsx(f,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(G,{disablePadding:!0,sx:{border:"1px solid #e0e0e0",borderRadius:"4px"},children:Object.entries(t).map(([r,{source:w,events:g,count:E}],u)=>{const M=n[r]>0,i=n[r]===g.length&&g.length>0,x=R[r];return e.jsxs(X.Fragment,{children:[e.jsx(Q,{sx:{borderBottom:u<Object.keys(t).length-1?"1px solid #f0f0f0":"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(f,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:s=>{s.target.closest(".MuiFormControlLabel-root")||T(r,s)},children:[e.jsx(f,{sx:{display:"flex",alignItems:"center"},children:g.length>0&&e.jsx(le,{control:e.jsx(V,{checked:i,indeterminate:M&&!i,onChange:s=>{s.stopPropagation(),y(g,i)}}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[w.logo&&e.jsx(Se,{src:w.logo,sx:{width:24,height:24}}),e.jsx(f,{children:w.title||r}),M&&e.jsx(O,{label:b("webhookEndpoint.selectedCount",{count:n[r]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:s=>`${s.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(f,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",color:"text.secondary",sx:{mr:1},children:b("webhookEndpoint.eventsCount",{count:E})}),g.length>0&&e.jsx(_,{size:"small",edge:"end",children:x?e.jsx(Ve,{}):e.jsx(Ke,{})})]})]})}),g.length>0&&e.jsx(Re,{in:x,timeout:"auto",unmountOnExit:!0,children:e.jsx(G,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:g.map(s=>{const m=`${s.type}-${s.source}`,k=!!d[m];return e.jsx(Q,{dense:!0,sx:{py:.75},onClick:()=>j(s),children:e.jsxs(f,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(V,{checked:k,sx:{mr:1}}),e.jsxs(f,{children:[e.jsx(S,{variant:"body1",sx:{cursor:"pointer"},children:s.type}),e.jsx(S,{variant:"caption",color:"text.disabled",sx:{display:"block",cursor:"pointer"},children:s.description})]})]})},m)})})})]},r)})})}),a&&e.jsx(Ie,{error:!0,sx:{mt:1},children:a})]})}te.propTypes={eventsBySource:o.objectOf(o.shape({source:o.shape({did:o.string.isRequired,title:o.string,description:o.string,version:o.string,logo:o.string}).isRequired,events:o.arrayOf(o.shape({type:o.string.isRequired,description:o.string.isRequired,source:o.string.isRequired})).isRequired,count:o.number.isRequired})).isRequired,selectedEvents:o.objectOf(o.bool).isRequired,setSelectedEvents:o.func.isRequired,error:o.string};te.defaultProps={error:null};function oe({id:t,url:d,description:c,enabledEvents:a,onSubmit:b,onClose:R}){var s;const{t:p}=q(),[n,l]=C.useState({}),{teamDid:v}=F(),{api:T}=N(),{loading:j,error:y,eventsBySource:h}=Xe(),{control:r,handleSubmit:w,formState:{errors:g},reset:E,setValue:u,trigger:M}=_e({defaultValues:{url:"",description:""}});C.useEffect(()=>{const m=Object.values(n).some(k=>k);u("selectedEvents",m?"valid":""),M("selectedEvents")},[n,u,M]);const i=()=>{l({}),E(),R()},x=async m=>{const k=Object.keys(n).filter(I=>n[I]),D={url:m.url,description:m.description,enabledEvents:k.map(I=>{const[$,L]=I.split("-");return!$||!L?null:{type:$,source:L}}).filter(Boolean)};try{if(t){const I=await T.updateWebhookEndpoint({input:{teamDid:v,id:t,data:D}});z.success(`${p("webhookEndpoint.updateWebhook")} ${p("webhookEndpoint.success")}`),b(I)}else{const I=await T.createWebhookEndpoint({input:{teamDid:v,input:D}});z.success(`${p("webhookEndpoint.createWebhook")} ${p("webhookEndpoint.success")}`),b(I)}}catch(I){z.error(I==null?void 0:I.message)}i()};return C.useEffect(()=>{E({url:d,description:c}),l(a.reduce((m,k)=>(m[`${k.type}-${k.source}`]=!0,m),{}))},[E,l,d,c,a]),e.jsx(ve,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:w(x),children:[e.jsx(Ee,{children:p(t?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Ce,{children:e.jsxs(f,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(J,{name:"url",control:r,rules:{required:p("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:p("webhookEndpoint.validation.urlInvalid")}},render:({field:m})=>{var k;return e.jsx(ie,{...m,label:p("webhookEndpoint.url.label"),fullWidth:!0,error:!!g.url,helperText:(k=g.url)==null?void 0:k.message})}}),e.jsx(J,{name:"description",control:r,rules:{required:p("webhookEndpoint.validation.descriptionRequired")},render:({field:m})=>{var k;return e.jsx(ie,{...m,label:p("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!g.description,helperText:(k=g.description)==null?void 0:k.message})}}),e.jsx(J,{name:"selectedEvents",control:r,rules:{required:p("webhookEndpoint.validation.eventRequired")},render:({field:m})=>e.jsx("input",{type:"hidden",...m})}),!j&&h&&Object.keys(h).length>0&&e.jsx(te,{eventsBySource:h,selectedEvents:n,setSelectedEvents:l,error:(s=g.selectedEvents)==null?void 0:s.message}),!j&&(!h||Object.keys(h).length===0)&&e.jsx(S,{color:"text.secondary",children:p("webhookEndpoint.noAvailableEvents")}),j&&e.jsx(f,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(U,{size:20})}),y&&e.jsx(ee,{severity:"error",children:p("webhookEndpoint.loadingError",{message:y==null?void 0:y.message})})]})}),e.jsxs(Te,{sx:{p:"8px 24px 24px"},children:[e.jsx(B,{onClick:i,children:p("common.cancel")}),e.jsx(B,{type:"submit",variant:"contained",color:"primary",children:p(t?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}oe.propTypes={onSubmit:o.func.isRequired,id:o.string,url:o.string,description:o.string,enabledEvents:o.arrayOf(o.shape({type:o.string.isRequired,source:o.string.isRequired})),onClose:o.func};oe.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function he(t){switch(t){case"enabled":return"success";case"disabled":default:return"default"}}const Ze=(t="en")=>t==="tw"?"zh":t;function H(t,d="YYYY-MM-DD HH:mm:ss",c="en"){return t?ke(t).locale(Ze(c)).format(d):"-"}function et(t){return typeof t=="number"?!1:ue(t)}function tt(t){return t>=200&&t<300}function W(t){const d=et(t.value);return e.jsxs(e.Fragment,{children:[e.jsxs(P,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[t.label,!!t.tip&&e.jsx(A,{title:t.tip,children:e.jsx(Me,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:d?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:d?"-":t.value})]}),t.divider&&e.jsx(Pe,{orientation:"vertical",flexItem:!0})]})}W.propTypes={label:o.oneOfType([o.string,o.node]).isRequired,value:o.oneOfType([o.string,o.node]).isRequired,tip:o.oneOfType([o.string,o.node]),divider:o.bool};W.defaultProps={tip:"",divider:!1};function ne(t){return e.jsxs(P,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:t.mb,mt:t.mt,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:t.title}),t.children]})}ne.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};ne.defaultProps={children:null,mb:1.5,mt:1.5};const ot={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6m-7 1l9-9m-5 0h5v5"/>'},nt=t=>{const d={};return t.forEach(c=>{var b;const a=new Date(c.createdAt).toLocaleDateString();d[a]||(d[a]=[]),(b=d[a])==null||b.push(c)}),d};function se({eventId:t,webhookEndpointId:d,event:c}){const{api:a}=N(),{t:b}=q(),{teamDid:R}=F(),{blocklet:p}=ce(),{data:n,loadMore:l,loadingMore:v,loading:T}=ye(u=>{const i=u?Math.ceil(u.list.length/15)+1:1;return a.getWebhookAttempts({input:{teamDid:R,input:{eventId:t,webhookId:d},paging:{page:i,pageSize:15}}})},{reloadDeps:[t,d]}),j=(n==null?void 0:n.list)||[],[y,h]=C.useState(null),r=nt(j);C.useEffect(()=>{!y&&(n!=null&&n.list.length)&&h(n.list[0])},[n==null?void 0:n.list.length,y]);const w=u=>{h(u)};if(T)return e.jsx(U,{});const g=n&&n.list.length<n.paging.total,E=u=>{var M,i,x,s,m;if(u.responseBody&&((M=u.responseBody)!=null&&M.sessionId)&&((i=u.responseBody)!=null&&i.projectId)&&((x=u.responseBody)!=null&&x.agentId)){const k=(m=(s=p==null?void 0:p.site)==null?void 0:s.domainAliases[0])==null?void 0:m.value,D=(p.children||[]).find($=>{var L;return((L=$==null?void 0:$.meta)==null?void 0:L.name)==="ai-studio"}),I=Ye(Je(`https://${k}`,(D==null?void 0:D.mountPoint)||"","projects",u.responseBody.projectId,"logs/main"),{sessionId:u.responseBody.sessionId,agentId:u.responseBody.agentId});return e.jsx(_,{sx:{fontSize:20},onClick:()=>window.open(I,"_blank"),children:e.jsx(f,{component:be,icon:ot})})}return null};return e.jsxs(Y,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(Y,{item:!0,xs:12,md:4,height:1,children:ue(Object.keys(r))?e.jsx(S,{color:"text.secondary",children:b("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(G,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(r).map(([u,M])=>e.jsxs(X.Fragment,{children:[e.jsx(De,{children:u}),M.map(i=>e.jsxs(Q,{sx:{cursor:"pointer"},onClick:()=>w(i),selected:y===i,secondaryAction:e.jsx(S,{color:"text.secondary",children:H(i.createdAt,"HH:mm:ss")}),children:[e.jsx(We,{sx:{minWidth:0,mr:1.5},children:tt(i.responseStatus)===!1?e.jsx(ze,{color:"error"}):e.jsx(Ae,{color:"success"})}),e.jsx(Oe,{primary:e.jsx(S,{color:"text.primary",children:i.event.type})})]},i.id))]},u))}),g&&e.jsx(f,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(B,{variant:"text",type:"button",color:"inherit",onClick:l,disabled:v,sx:{color:u=>u.palette.text.disabled},children:b(v?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(Y,{item:!0,xs:12,md:8,height:1,children:[y&&e.jsxs(P,{height:1,overflow:"auto",direction:"column",spacing:2,sx:{pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h6",children:t?y.endpoint.url:y.event.type}),e.jsx(f,{children:E(y)})]}),e.jsxs(f,{children:[e.jsxs(S,{variant:"h6",children:[b("webhookEndpoint.response")," (",y.responseStatus,")"]}),e.jsx(K,{language:"json",children:JSON.stringify(y.responseBody,null,2)})]}),e.jsxs(f,{children:[e.jsx(P,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:b("webhookEndpoint.request")})}),e.jsx(K,{language:"json",sx:{margin:0},children:JSON.stringify(y.event,null,2)})]})]}),(n==null?void 0:n.list.length)===0&&c&&e.jsxs(f,{children:[e.jsx(P,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:b("webhookEndpoint.eventData")})}),e.jsx(K,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}se.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};se.defaultProps={eventId:"",webhookEndpointId:"",event:null};function xe({id:t,onClose:d}){var v,T,j,y;const{t:c}=q(),{api:a}=N(),{teamDid:b}=F(),{loading:R,error:p,data:n}=de(()=>a.getWebhookEndpoint({input:{teamDid:b,id:t}})),l=n==null?void 0:n.data;return p?e.jsx(ee,{severity:"error",children:p.message}):R||!l?e.jsx(f,{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1,children:e.jsx(U,{})}):e.jsxs(st,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(f,{children:[e.jsxs(P,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(P,{flex:1,width:0,children:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h5",fontWeight:600,sx:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:l.description}),e.jsx(A,{title:l.url,children:e.jsx(Z,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(P,{direction:"row",alignItems:"center",children:e.jsx(_,{edge:"end",color:"inherit",onClick:d,children:e.jsx(qe,{})})})]}),e.jsx(f,{mt:2,children:e.jsxs(P,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},justifyContent:"flex-start",flexWrap:"wrap",sx:{pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx(W,{label:c("common.status"),value:e.jsx(O,{size:"small",variant:"filled",label:l.status,color:he(l.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx(W,{label:c("webhookEndpoint.listen"),value:e.jsx(A,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:l.enabledEvents.map(h=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:h==null?void 0:h.type},h))}),children:e.jsx(O,{size:"small",variant:"filled",label:c("webhookEndpoint.eventsCount",{count:l.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(W,{label:c("webhookEndpoint.version"),value:l.apiVersion,divider:!0}),e.jsx(W,{label:c("common.createdAt"),value:H(l.createdAt),divider:!0}),e.jsx(W,{label:c("common.updatedAt"),value:H(l.updatedAt),divider:!0}),e.jsx(W,{label:c("common.createdBy"),value:e.jsx(A,{arrow:!0,title:(v=l.createUser)==null?void 0:v.did,children:e.jsx(O,{size:"small",variant:"filled",label:(T=l.createUser)==null?void 0:T.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(W,{label:c("common.updatedBy"),value:e.jsx(A,{arrow:!0,title:(j=l.updateUser)==null?void 0:j.did,children:e.jsx(O,{size:"small",variant:"filled",label:(y=l.updateUser)==null?void 0:y.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(P,{className:"section",flex:1,height:0,overflow:"hidden",children:[e.jsx(ne,{title:c("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(P,{height:0,flex:1,overflow:"hidden",children:e.jsx(se,{webhookEndpointId:l.id})})]})]})}xe.propTypes={id:o.string.isRequired,onClose:o.func.isRequired};const st=pe(P)``;function me({open:t,onClose:d,id:c}){return e.jsx($e,{anchor:"right",open:t,onClose:d,PaperProps:{sx:{width:"90vw",maxWidth:"1200px"}},children:e.jsx(f,{sx:{height:"100vh",p:3},children:e.jsx(xe,{id:c,onClose:d})})})}me.propTypes={open:o.bool.isRequired,onClose:o.func.isRequired,id:o.string.isRequired};function ae(){return null}const re=X.memo(({options:t,columns:d,toolbar:c=!0,footer:a=!0,hasRowLink:b=!1,emptyNodeText:R="",...p})=>{const{locale:n}=q(),l=Le(j=>j.breakpoints.down("md")),v={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:l?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},T={};return c||(T.TableToolbar=ae),a||(T.TableFooter=ae),e.jsx(rt,{locale:n,options:{...v,...t},columns:(d||[]).map(j=>(j.options=j.options||{},j.options.filter=j.options.filter||!1,j.options.sort=j.options.sort||!1,j)),emptyNode:e.jsx(fe,{children:R}),...p,components:T,hasRowLink:b,isMobile:l})});re.propTypes={options:o.object,columns:o.array,toolbar:o.bool,footer:o.bool,hasRowLink:o.bool,emptyNodeText:o.node,durable:o.string,durableKeys:o.array,data:o.array,loading:o.bool,onChange:o.func,title:o.node,components:o.object};re.defaultProps={options:{},columns:[],toolbar:!0,footer:!0,hasRowLink:!1,emptyNodeText:null,durable:"",durableKeys:[],data:[],loading:!1,onChange:()=>{},title:null,components:{}};const rt=pe(ge)`
|
|
1
|
+
import{u as q,V as z,bK as K,i as be,X as fe,a2 as ge,bC as je}from"./vendor-ux-did-connect-4bCiyPYS.js";import{w as ye,l as de,j as we}from"./vendor-hooks-DbRTDIFw.js";import{r as C,b as X}from"./vendor-react-DoD83n6N.js";import{d as Z}from"./InfoOutlined-A0h5OX7J.js";import{z as N,C as ce,G as ke}from"./index-DXodzmv1.js";import{u as F}from"./dashboard-CgU5vYTc.js";import{E as o,j as e,D as ve,ab as Ee,r as Ce,a3 as f,M as ie,T as S,a2 as U,ac as ee,y as Te,x as B,bn as le,bO as V,a4 as A,L as G,z as Q,bg as Se,A as O,I as _,C as Re,bl as Ie,ad as P,cG as Me,ak as Pe,bd as Y,bk as De,b1 as We,cH as ze,cI as Ae,b2 as Oe,af as $e,bS as qe,s as pe,t as Le,cJ as Be,cK as He,cL as Ne,cM as Fe,cN as Ue}from"./vendor-mui-core-O22FPGM4.js";import{u as _e,C as J}from"./index.esm-CWepf7I_.js";import{n as Ke}from"./vendor-arcblock-BmGcldk1.js";import{d as Ve}from"./ExpandLess-DBi9UnX8.js";import{y as ue,w as Ye,x as Je}from"./vendor-utils-DJ1bmiuG.js";import{C as Ge}from"./confirm-AquAQGjx.js";import{A as Qe}from"./actions-BlT0cxUG.js";import"./lottie-web-B6s7dDoL.js";import"./useLocalStorage-CCDYY4Oj.js";import"./PlayArrow-ByDKBx4g.js";import"./get-safe-url-zNlUtfl-.js";import"./format-error-LAoTjvJe.js";import"./index-9xLdpFIQ.js";import"./session-D7wR69VL.js";import"./useAsyncRetry-CcF3e_P6.js";import"./useAsync-CDzQ0uN6.js";import"./useSetState-BL3ktMon.js";import"./MoreHoriz-I4HIq7xK.js";const Xe=t=>{var j,y;const[d,c]=C.useState(null),[a,b]=C.useState(!t),[R,p]=C.useState(null),{blocklet:n}=ce(),l=(y=(j=n==null?void 0:n.site)==null?void 0:j.domainAliases[0])==null?void 0:y.value,v=C.useMemo(()=>{const h={};return d&&(d.sources.forEach(r=>{h[r.did]={source:r,events:[],count:0}}),d.events.forEach(r=>{h[r.source]&&(h[r.source].events.push(r),h[r.source].count+=1)})),h},[d]),T=async()=>{try{if(b(!0),!l)return;const r=await(await fetch(`https://${l}/.well-known/service/openevent.json`)).json();c(r),p(null)}catch(h){p(h instanceof Error?h:new Error(String(h)))}finally{b(!1)}};return C.useEffect(()=>{T()},[l]),{openEvent:d,setOpenEvent:c,eventsBySource:v,loading:a,error:R,loadData:T}};function te({eventsBySource:t,selectedEvents:d,setSelectedEvents:c,error:a}){const{t:b}=q(),[R,p]=C.useState({}),n=C.useMemo(()=>{const r={};return Object.entries(t).forEach(([w,{events:g}])=>{const E=g.filter(u=>d[`${u.type}-${u.source}`]).length;r[w]=E}),r},[t,d]),l=C.useMemo(()=>Object.values(n).reduce((r,w)=>r+w,0),[n]),v=C.useMemo(()=>Object.values(t).reduce((r,{events:w})=>r+w.length,0),[t]),T=(r,w)=>{w.stopPropagation(),p({...R,[r]:!R[r]})},j=r=>{const w=`${r.type}-${r.source}`;c(g=>({...g,[w]:!g[w]}))},y=(r,w)=>{const g={};r.forEach(E=>{const u=`${E.type}-${E.source}`;g[u]=!w}),c(E=>({...E,...g}))},h=r=>{const w={};Object.values(t).forEach(({events:g})=>{g.forEach(E=>{const u=`${E.type}-${E.source}`;w[u]=r.target.checked})}),c(w)};return e.jsxs(f,{sx:{width:"100%"},children:[e.jsxs(f,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(le,{control:e.jsx(V,{onChange:h,checked:l>0&&l===v}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[b("webhookEndpoint.selectAllEvents"),e.jsx(f,{sx:{display:"flex",alignItems:"center"},children:e.jsx(A,{title:b("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(Z,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),l>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:b("webhookEndpoint.selectedEventsCount",{count:l})})]}),e.jsx(f,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(G,{disablePadding:!0,sx:{border:"1px solid #e0e0e0",borderRadius:"4px"},children:Object.entries(t).map(([r,{source:w,events:g,count:E}],u)=>{const M=n[r]>0,i=n[r]===g.length&&g.length>0,x=R[r];return e.jsxs(X.Fragment,{children:[e.jsx(Q,{sx:{borderBottom:u<Object.keys(t).length-1?"1px solid #f0f0f0":"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(f,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:s=>{s.target.closest(".MuiFormControlLabel-root")||T(r,s)},children:[e.jsx(f,{sx:{display:"flex",alignItems:"center"},children:g.length>0&&e.jsx(le,{control:e.jsx(V,{checked:i,indeterminate:M&&!i,onChange:s=>{s.stopPropagation(),y(g,i)}}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[w.logo&&e.jsx(Se,{src:w.logo,sx:{width:24,height:24}}),e.jsx(f,{children:w.title||r}),M&&e.jsx(O,{label:b("webhookEndpoint.selectedCount",{count:n[r]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:s=>`${s.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(f,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",color:"text.secondary",sx:{mr:1},children:b("webhookEndpoint.eventsCount",{count:E})}),g.length>0&&e.jsx(_,{size:"small",edge:"end",children:x?e.jsx(Ve,{}):e.jsx(Ke,{})})]})]})}),g.length>0&&e.jsx(Re,{in:x,timeout:"auto",unmountOnExit:!0,children:e.jsx(G,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:g.map(s=>{const m=`${s.type}-${s.source}`,k=!!d[m];return e.jsx(Q,{dense:!0,sx:{py:.75},onClick:()=>j(s),children:e.jsxs(f,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(V,{checked:k,sx:{mr:1}}),e.jsxs(f,{children:[e.jsx(S,{variant:"body1",sx:{cursor:"pointer"},children:s.type}),e.jsx(S,{variant:"caption",color:"text.disabled",sx:{display:"block",cursor:"pointer"},children:s.description})]})]})},m)})})})]},r)})})}),a&&e.jsx(Ie,{error:!0,sx:{mt:1},children:a})]})}te.propTypes={eventsBySource:o.objectOf(o.shape({source:o.shape({did:o.string.isRequired,title:o.string,description:o.string,version:o.string,logo:o.string}).isRequired,events:o.arrayOf(o.shape({type:o.string.isRequired,description:o.string.isRequired,source:o.string.isRequired})).isRequired,count:o.number.isRequired})).isRequired,selectedEvents:o.objectOf(o.bool).isRequired,setSelectedEvents:o.func.isRequired,error:o.string};te.defaultProps={error:null};function oe({id:t,url:d,description:c,enabledEvents:a,onSubmit:b,onClose:R}){var s;const{t:p}=q(),[n,l]=C.useState({}),{teamDid:v}=F(),{api:T}=N(),{loading:j,error:y,eventsBySource:h}=Xe(),{control:r,handleSubmit:w,formState:{errors:g},reset:E,setValue:u,trigger:M}=_e({defaultValues:{url:"",description:""}});C.useEffect(()=>{const m=Object.values(n).some(k=>k);u("selectedEvents",m?"valid":""),M("selectedEvents")},[n,u,M]);const i=()=>{l({}),E(),R()},x=async m=>{const k=Object.keys(n).filter(I=>n[I]),D={url:m.url,description:m.description,enabledEvents:k.map(I=>{const[$,L]=I.split("-");return!$||!L?null:{type:$,source:L}}).filter(Boolean)};try{if(t){const I=await T.updateWebhookEndpoint({input:{teamDid:v,id:t,data:D}});z.success(`${p("webhookEndpoint.updateWebhook")} ${p("webhookEndpoint.success")}`),b(I)}else{const I=await T.createWebhookEndpoint({input:{teamDid:v,input:D}});z.success(`${p("webhookEndpoint.createWebhook")} ${p("webhookEndpoint.success")}`),b(I)}}catch(I){z.error(I==null?void 0:I.message)}i()};return C.useEffect(()=>{E({url:d,description:c}),l(a.reduce((m,k)=>(m[`${k.type}-${k.source}`]=!0,m),{}))},[E,l,d,c,a]),e.jsx(ve,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:w(x),children:[e.jsx(Ee,{children:p(t?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Ce,{children:e.jsxs(f,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(J,{name:"url",control:r,rules:{required:p("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:p("webhookEndpoint.validation.urlInvalid")}},render:({field:m})=>{var k;return e.jsx(ie,{...m,label:p("webhookEndpoint.url.label"),fullWidth:!0,error:!!g.url,helperText:(k=g.url)==null?void 0:k.message})}}),e.jsx(J,{name:"description",control:r,rules:{required:p("webhookEndpoint.validation.descriptionRequired")},render:({field:m})=>{var k;return e.jsx(ie,{...m,label:p("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!g.description,helperText:(k=g.description)==null?void 0:k.message})}}),e.jsx(J,{name:"selectedEvents",control:r,rules:{required:p("webhookEndpoint.validation.eventRequired")},render:({field:m})=>e.jsx("input",{type:"hidden",...m})}),!j&&h&&Object.keys(h).length>0&&e.jsx(te,{eventsBySource:h,selectedEvents:n,setSelectedEvents:l,error:(s=g.selectedEvents)==null?void 0:s.message}),!j&&(!h||Object.keys(h).length===0)&&e.jsx(S,{color:"text.secondary",children:p("webhookEndpoint.noAvailableEvents")}),j&&e.jsx(f,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(U,{size:20})}),y&&e.jsx(ee,{severity:"error",children:p("webhookEndpoint.loadingError",{message:y==null?void 0:y.message})})]})}),e.jsxs(Te,{sx:{p:"8px 24px 24px"},children:[e.jsx(B,{onClick:i,children:p("common.cancel")}),e.jsx(B,{type:"submit",variant:"contained",color:"primary",children:p(t?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}oe.propTypes={onSubmit:o.func.isRequired,id:o.string,url:o.string,description:o.string,enabledEvents:o.arrayOf(o.shape({type:o.string.isRequired,source:o.string.isRequired})),onClose:o.func};oe.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function he(t){switch(t){case"enabled":return"success";case"disabled":default:return"default"}}const Ze=(t="en")=>t==="tw"?"zh":t;function H(t,d="YYYY-MM-DD HH:mm:ss",c="en"){return t?ke(t).locale(Ze(c)).format(d):"-"}function et(t){return typeof t=="number"?!1:ue(t)}function tt(t){return t>=200&&t<300}function W(t){const d=et(t.value);return e.jsxs(e.Fragment,{children:[e.jsxs(P,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[t.label,!!t.tip&&e.jsx(A,{title:t.tip,children:e.jsx(Me,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:d?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:d?"-":t.value})]}),t.divider&&e.jsx(Pe,{orientation:"vertical",flexItem:!0})]})}W.propTypes={label:o.oneOfType([o.string,o.node]).isRequired,value:o.oneOfType([o.string,o.node]).isRequired,tip:o.oneOfType([o.string,o.node]),divider:o.bool};W.defaultProps={tip:"",divider:!1};function ne(t){return e.jsxs(P,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:t.mb,mt:t.mt,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:t.title}),t.children]})}ne.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};ne.defaultProps={children:null,mb:1.5,mt:1.5};const ot={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6m-7 1l9-9m-5 0h5v5"/>'},nt=t=>{const d={};return t.forEach(c=>{var b;const a=new Date(c.createdAt).toLocaleDateString();d[a]||(d[a]=[]),(b=d[a])==null||b.push(c)}),d};function se({eventId:t,webhookEndpointId:d,event:c}){const{api:a}=N(),{t:b}=q(),{teamDid:R}=F(),{blocklet:p}=ce(),{data:n,loadMore:l,loadingMore:v,loading:T}=ye(u=>{const i=u?Math.ceil(u.list.length/15)+1:1;return a.getWebhookAttempts({input:{teamDid:R,input:{eventId:t,webhookId:d},paging:{page:i,pageSize:15}}})},{reloadDeps:[t,d]}),j=(n==null?void 0:n.list)||[],[y,h]=C.useState(null),r=nt(j);C.useEffect(()=>{!y&&(n!=null&&n.list.length)&&h(n.list[0])},[n==null?void 0:n.list.length,y]);const w=u=>{h(u)};if(T)return e.jsx(U,{});const g=n&&n.list.length<n.paging.total,E=u=>{var M,i,x,s,m;if(u.responseBody&&((M=u.responseBody)!=null&&M.sessionId)&&((i=u.responseBody)!=null&&i.projectId)&&((x=u.responseBody)!=null&&x.agentId)){const k=(m=(s=p==null?void 0:p.site)==null?void 0:s.domainAliases[0])==null?void 0:m.value,D=(p.children||[]).find($=>{var L;return((L=$==null?void 0:$.meta)==null?void 0:L.name)==="ai-studio"}),I=Ye(Je(`https://${k}`,(D==null?void 0:D.mountPoint)||"","projects",u.responseBody.projectId,"logs/main"),{sessionId:u.responseBody.sessionId,agentId:u.responseBody.agentId});return e.jsx(_,{sx:{fontSize:20},onClick:()=>window.open(I,"_blank"),children:e.jsx(f,{component:be,icon:ot})})}return null};return e.jsxs(Y,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(Y,{item:!0,xs:12,md:4,height:1,children:ue(Object.keys(r))?e.jsx(S,{color:"text.secondary",children:b("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(G,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(r).map(([u,M])=>e.jsxs(X.Fragment,{children:[e.jsx(De,{children:u}),M.map(i=>e.jsxs(Q,{sx:{cursor:"pointer"},onClick:()=>w(i),selected:y===i,secondaryAction:e.jsx(S,{color:"text.secondary",children:H(i.createdAt,"HH:mm:ss")}),children:[e.jsx(We,{sx:{minWidth:0,mr:1.5},children:tt(i.responseStatus)===!1?e.jsx(ze,{color:"error"}):e.jsx(Ae,{color:"success"})}),e.jsx(Oe,{primary:e.jsx(S,{color:"text.primary",children:i.event.type})})]},i.id))]},u))}),g&&e.jsx(f,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(B,{variant:"text",type:"button",color:"inherit",onClick:l,disabled:v,sx:{color:u=>u.palette.text.disabled},children:b(v?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(Y,{item:!0,xs:12,md:8,height:1,children:[y&&e.jsxs(P,{height:1,overflow:"auto",direction:"column",spacing:2,sx:{pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h6",children:t?y.endpoint.url:y.event.type}),e.jsx(f,{children:E(y)})]}),e.jsxs(f,{children:[e.jsxs(S,{variant:"h6",children:[b("webhookEndpoint.response")," (",y.responseStatus,")"]}),e.jsx(K,{language:"json",children:JSON.stringify(y.responseBody,null,2)})]}),e.jsxs(f,{children:[e.jsx(P,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:b("webhookEndpoint.request")})}),e.jsx(K,{language:"json",sx:{margin:0},children:JSON.stringify(y.event,null,2)})]})]}),(n==null?void 0:n.list.length)===0&&c&&e.jsxs(f,{children:[e.jsx(P,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:b("webhookEndpoint.eventData")})}),e.jsx(K,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}se.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};se.defaultProps={eventId:"",webhookEndpointId:"",event:null};function xe({id:t,onClose:d}){var v,T,j,y;const{t:c}=q(),{api:a}=N(),{teamDid:b}=F(),{loading:R,error:p,data:n}=de(()=>a.getWebhookEndpoint({input:{teamDid:b,id:t}})),l=n==null?void 0:n.data;return p?e.jsx(ee,{severity:"error",children:p.message}):R||!l?e.jsx(f,{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1,children:e.jsx(U,{})}):e.jsxs(st,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(f,{children:[e.jsxs(P,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(P,{flex:1,width:0,children:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h5",fontWeight:600,sx:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:l.description}),e.jsx(A,{title:l.url,children:e.jsx(Z,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(P,{direction:"row",alignItems:"center",children:e.jsx(_,{edge:"end",color:"inherit",onClick:d,children:e.jsx(qe,{})})})]}),e.jsx(f,{mt:2,children:e.jsxs(P,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},justifyContent:"flex-start",flexWrap:"wrap",sx:{pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx(W,{label:c("common.status"),value:e.jsx(O,{size:"small",variant:"filled",label:l.status,color:he(l.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx(W,{label:c("webhookEndpoint.listen"),value:e.jsx(A,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:l.enabledEvents.map(h=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:h==null?void 0:h.type},h))}),children:e.jsx(O,{size:"small",variant:"filled",label:c("webhookEndpoint.eventsCount",{count:l.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(W,{label:c("webhookEndpoint.version"),value:l.apiVersion,divider:!0}),e.jsx(W,{label:c("common.createdAt"),value:H(l.createdAt),divider:!0}),e.jsx(W,{label:c("common.updatedAt"),value:H(l.updatedAt),divider:!0}),e.jsx(W,{label:c("common.createdBy"),value:e.jsx(A,{arrow:!0,title:(v=l.createUser)==null?void 0:v.did,children:e.jsx(O,{size:"small",variant:"filled",label:(T=l.createUser)==null?void 0:T.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(W,{label:c("common.updatedBy"),value:e.jsx(A,{arrow:!0,title:(j=l.updateUser)==null?void 0:j.did,children:e.jsx(O,{size:"small",variant:"filled",label:(y=l.updateUser)==null?void 0:y.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(P,{className:"section",flex:1,height:0,overflow:"hidden",children:[e.jsx(ne,{title:c("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(P,{height:0,flex:1,overflow:"hidden",children:e.jsx(se,{webhookEndpointId:l.id})})]})]})}xe.propTypes={id:o.string.isRequired,onClose:o.func.isRequired};const st=pe(P)``;function me({open:t,onClose:d,id:c}){return e.jsx($e,{anchor:"right",open:t,onClose:d,PaperProps:{sx:{width:"90vw",maxWidth:"1200px"}},children:e.jsx(f,{sx:{height:"100vh",p:3},children:e.jsx(xe,{id:c,onClose:d})})})}me.propTypes={open:o.bool.isRequired,onClose:o.func.isRequired,id:o.string.isRequired};function ae(){return null}const re=X.memo(({options:t,columns:d,toolbar:c=!0,footer:a=!0,hasRowLink:b=!1,emptyNodeText:R="",...p})=>{const{locale:n}=q(),l=Le(j=>j.breakpoints.down("md")),v={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:l?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},T={};return c||(T.TableToolbar=ae),a||(T.TableFooter=ae),e.jsx(rt,{locale:n,options:{...v,...t},columns:(d||[]).map(j=>(j.options=j.options||{},j.options.filter=j.options.filter||!1,j.options.sort=j.options.sort||!1,j)),emptyNode:e.jsx(fe,{children:R}),...p,components:T,hasRowLink:b,isMobile:l})});re.propTypes={options:o.object,columns:o.array,toolbar:o.bool,footer:o.bool,hasRowLink:o.bool,emptyNodeText:o.node,durable:o.string,durableKeys:o.array,data:o.array,loading:o.bool,onChange:o.func,title:o.node,components:o.object};re.defaultProps={options:{},columns:[],toolbar:!0,footer:!0,hasRowLink:!1,emptyNodeText:null,durable:"",durableKeys:[],data:[],loading:!1,onChange:()=>{},title:null,components:{}};const rt=pe(ge)`
|
|
2
2
|
.MuiPaper-root {
|
|
3
3
|
border-radius: 8px;
|
|
4
4
|
overflow: hidden;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as b}from"./vendor-react-DoD83n6N.js";import{j as e,E as d,a1 as Pe,R as bt,a4 as jt,T as G,a3 as R,A as Fe,bj as _e,co as et,cn as Te,bn as Ie,bO as De,x as ye,aj as Ee,a2 as tt,a9 as ae,V as nt,bd as Xe,bm as vt,bi as yt,ai as Je,cp as St}from"./vendor-mui-core-O22FPGM4.js";import{b as Z,av as re,z as Ct}from"./vendor-utils-DJ1bmiuG.js";import{V,p as L,a$ as Nt,r as Be,u as X,bM as wt,U as st,B as Ae,a2 as at,bd as be,ak as Rt,aq as Tt,bC as It}from"./vendor-ux-did-connect-2-XNNtOB.js";import{z as Dt,G as H,m as Et,I as Qe}from"./index-B7Yzqt2Y.js";import{f as pe,a as Oe}from"./vendor-hooks-DbRTDIFw.js";import{S as ue}from"./shorten-label-DXrhdUJE.js";import{I as it}from"./index-DDbdl3JK.js";import{S as At,a as Ot}from"./list-ZqiWwQBr.js";import{R as ze}from"./relative-time-C4f3PU1u.js";import{b as We}from"./dashboard-C8G4QNFK.js";import{W as Lt}from"./did-address-DI0KYPba.js";import{p as ot}from"./util-Bslt0VzU.js";import{D as kt,g as Pt}from"./traffic-CSjRXGq0.js";import{B as rt}from"./bundle-avatar-B24HOX02.js";import{B as Ft}from"./index-CrhkEqZc.js";import"./lottie-web-B6s7dDoL.js";import"./vendor-arcblock-Cy3mvd3t.js";import"./index-C46rA4HG.js";import"./InfoOutlined-rkRdeKC5.js";import"./useLocalStorage-DWM7Bn98.js";import"./confirm-DMy0Z-Cg.js";import"./format-error-LAoTjvJe.js";import"./PlayArrow-CLDLFBEz.js";import"./get-safe-url-hqF7Ndco.js";import"./session-IeX2Dw6x.js";import"./useAsyncRetry-CcF3e_P6.js";import"./useAsync-CDzQ0uN6.js";import"./useSetState-BL3ktMon.js";import"./base32-D0fEqWLU.js";import"./iframe-C4ss0xsS.js";import"./LaunchOutlined-CDg4y6WY.js";import"./ChevronLeft-BZHXIpzy.js";import"./ChevronRight-BXXXrhFv.js";import"./index-DWJc5Rxl.js";import"./vendor-mui-x-K-9WHqhO.js";const lt=b.createContext({}),{Provider:_t,Consumer:es}=lt;function Bt({children:t,blocklet:n=""}){const{api:s,inService:i}=Dt(),[a,l]=b.useState([]),[p,f]=b.useState({total:0,pageSize:20,pageCount:0,page:1}),y=pe(()=>{var j;return(j=n.meta)==null?void 0:j.did},[n]),[S,T]=b.useState([]),N=async({page:j=1,pageSize:v=20,...x}={})=>{if(!y)return[];try{const w={paging:{page:j,pageSize:v},...x,teamDid:y,dateRange:x.dateRange?[H(x.dateRange[0]).toISOString(),H(x.dateRange[1]).toISOString()]:void 0},{dids:M,...B}=w;let K="";M.includes("system")&&(K="system");const _=M.filter(ee=>ee!=="system"),Q=await s.getNotificationSendLog({input:{...B,source:K,componentDids:_}});return l(Q.list),f(Q.paging),Q.list}catch(w){return V.error(w.message),[]}},A=async()=>{const j=await s.getNotificationComponents({input:{teamDid:y}});T(j.componentDids)},P=b.useCallback(j=>{const v=n.children.find(x=>{var w;return((w=x.meta)==null?void 0:w.did)===j});if(v)return v.ancestors=[n],v},[n]),O=async({notificationId:j,receivers:v,channels:x,...w})=>{await s.resendNotification({input:{teamDid:y,notificationId:j,receivers:v,channels:x.map(M=>M==="wallet"?L.NOTIFICATION_SEND_CHANNEL.WALLET:M==="pushKit"?L.NOTIFICATION_SEND_CHANNEL.PUSH:M),...w}})},F=b.useCallback(async j=>(await s.getUser({input:{teamDid:y,user:{did:j}}})).user,[s,y]),I=b.useCallback(async({page:j=1,pageSize:v=20,...x}={})=>{try{const w={paging:{page:j,pageSize:v},...x,userName:x.searchText||"",teamDid:y,dateRange:x.dateRange?[H(x.dateRange[0]).toISOString(),H(x.dateRange[1]).toISOString()]:void 0};return await s.getReceivers({input:w})}catch(w){throw V.error(w.message),w}},[s,y]);b.useEffect(()=>{y&&A()},[y]);const U={fetch:N,data:a,paging:p,blocklet:n,getComponent:P,resendNotification:O,getUser:F,componentDids:S,getReceivers:I,inService:i,teamDid:y};return e.jsx(_t,{value:{notificationRecords:U},children:t})}function Me(){const{notificationRecords:t}=b.useContext(lt);return t}fe.propTypes={severity:d.oneOf(Object.values(["info","success","error","warning"])).isRequired};const zt={info:"primary",success:"success",error:"error",warning:"warning"};function fe({severity:t="info"}){return e.jsx(Nt,{type:zt[t],children:t})}var qe={},Wt=Pe;Object.defineProperty(qe,"__esModule",{value:!0});var ct=qe.default=void 0,Mt=Wt(Be()),qt=e;ct=qe.default=(0,Mt.default)((0,qt.jsx)("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"CheckCircleOutline");var Ke={},Kt=Pe;Object.defineProperty(Ke,"__esModule",{value:!0});var dt=Ke.default=void 0,$t=Kt(Be()),Ht=e;dt=Ke.default=(0,$t.default)((0,Ht.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12m8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8"}),"Block");var $e={},Ut=Pe;Object.defineProperty($e,"__esModule",{value:!0});var ut=$e.default=void 0,Vt=Ut(Be()),Gt=e;ut=$e.default=(0,Vt.default)((0,Gt.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");const Yt=(t,n,s="")=>{if(!s||!n)return"";switch(s){case L.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return t("notification.sendStatus.reason.disabled",{channel:n});case L.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return t("notification.sendStatus.reason.unavailable",{channel:n});case L.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return t("notification.sendStatus.reason.notSent",{channel:n});case L.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return t("notification.sendStatus.reason.offline");default:return s}};function pt(t,n,s={}){const{status:i,updatedAt:a,reason:l="",channel:p="wallet"}=s,f=a?t("notification.sendStatus.sentTime",{date:Et(a,n)}):"",y=Yt(t,p,l);return i===L.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:t("notification.sendStatus.failed"),sentTime:f,reason:y}:i===L.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:t("notification.sendStatus.success"),sentTime:f}:{status:"pending",title:t("notification.sendStatus.pending"),reason:y,sentTime:f}}const Le={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},ke=["wallet","pushKit","email"],Ze=["info","success","error","warning"],ft=t=>{var s,i;const{settings:n}=t;return(i=(s=n==null?void 0:n.notification)==null?void 0:s.email)==null?void 0:i.enabled},mt=t=>{var s,i;const{settings:n}=t;return(i=(s=n==null?void 0:n.notification)==null?void 0:s.pushKit)==null?void 0:i.enabled},Xt=(t,n)=>{const s=Z(n,"extra.notifications.email",!0);return{available:ft(t),enabled:s}},Jt=(t,n)=>{const s=Z(n,"extra.notifications.push",!0);return{available:mt(t),enabled:s}},Qt=t=>({enabled:Z(t,"extra.notifications.wallet",!0)}),Zt=t=>({enabled:Z(t,"extra.webhooks",[]).length>0}),ge=(t=3)=>new Promise(n=>{setTimeout(()=>{n()},t*1e3)}),en=(t,n)=>n==="wallet"||n==="webhook"?[{channel:n,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:n}),fail:t("notification.sendStatus.reason.disabled",{channel:n})}]:n==="pushKit"||n==="email"?[{channel:n,type:"available",pass:t("notification.sendStatus.reason.available",{channel:n}),fail:t("notification.sendStatus.reason.unavailable",{channel:n})},{channel:n,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:n}),fail:t("notification.sendStatus.reason.disabled",{channel:n})}]:[],xe=(t=[])=>{const n=H().startOf("day");return t.filter(s=>H(s.sendAt).isSame(n,"day")).length},tn=(t,n="")=>{if(n&&ke.includes(n)){const l=`${n}SendRecord`,p=Z(t,l,[]);return xe(p)}const s=Z(t,"webhook",{}),i=Object.keys(s??{})??[];if(n&&i.includes(n)){const l=s[n]??[];return xe(l)}const a={};return ke.forEach(l=>{const p=`${l}SendRecord`,f=Z(t,p,[]),y=xe(f);a[l]=y}),i.length>0&&i.forEach(l=>{const p=s[l]??[],f=xe(p);a[l]=f}),a},je=(t,n,s)=>{if(!Array.isArray(t))throw new Error("Invalid filterList or index");return t[s].splice(n,1),t},ve=(t,n)=>{if(!Array.isArray(n))throw new Error("filters must be an array");return n.length?!n.includes(t):!1},nn=t=>{switch(t){case L.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case L.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case L.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case L.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},ht=()=>bt({typography:{fontSize:14,button:{textTransform:"none"}},palette:{primary:{main:"#1DC1C7",contrastText:"#fff"},secondary:{main:"#030712",contrastText:"#fff"},storeSecondary:{main:"#EBFEFF",contrastText:"#fff"}},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 J({config:t,enableTooltip:n=!0,showTitle:s=!1,children:i}){const{status:a,title:l="",sentTime:p="",reason:f=""}=t,y=[l,f].filter(Boolean).join(", ");return e.jsx(jt,{title:n?e.jsxs(e.Fragment,{children:[e.jsx(G,{color:"inherit",sx:{fontSize:12},children:y}),e.jsx("span",{children:p})]}):null,arrow:!0,placement:"top",children:e.jsxs(R,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(R,{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center",children:[e.jsx(R,{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Le[a],style:{opacity:.15}}),e.jsx(R,{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Le[a]})]}),e.jsx(G,{color:"inherit",sx:{fontSize:12},children:s?l:i})]})})}J.propTypes={config:d.object.isRequired,enableTooltip:d.bool,showTitle:d.bool,children:d.node};J.defaultProps={enableTooltip:!0,showTitle:!1,children:null};le.propTypes={list:d.array.isRequired,label:d.string.isRequired,onDelete:d.func};le.defaultProps={onDelete:()=>{}};function le({list:t,label:n,onDelete:s}){const{t:i,locale:a}=X();return e.jsxs(R,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(G,{children:[n,": "]}),t.map(l=>{const p=pt(i,a,{status:l});return e.jsx(Fe,{size:"small",label:e.jsx(R,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(J,{config:p,enableTooltip:!1,children:p.title})}),onDelete:f=>s(f,l)},l)})]})}He.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 He({filterList:t,onChange:n,index:s,column:i,filterValues:a,label:l,renderLabel:p}){return e.jsxs(_e,{className:"filter-container",children:[e.jsx(et,{component:"legend",children:l}),e.jsx(Te,{row:!0,children:a.map(f=>e.jsx(Ie,{control:e.jsx(De,{checked:t[s].indexOf(f.value??f)>-1,onChange:y=>{const S=[...t];y.target.checked?S[s]=[...S[s],f.value??f]:S[s]=S[s].filter(T=>T!==(f.value??f)),n(S[s],s,i)},name:f.value??f}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:p(f)})},f.value??f))})]})}function Re(t){return e.jsx(He,{...t,renderLabel:n=>e.jsx(J,{enableTooltip:!1,config:{status:n.status},children:n.label})})}oe.propTypes={status:d.number.isRequired,updatedAt:d.string.isRequired,reason:d.string,channel:d.string,onResend:d.func};function oe({status:t,updatedAt:n,reason:s="",channel:i="wallet",onResend:a}){const{t:l,locale:p}=X(),f=pt(l,p,{status:t,updatedAt:n,reason:s,channel:i});return e.jsxs(R,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(J,{config:f,showTitle:!0}),f.status!=="success"&&e.jsx(ye,{className:"resend-btn",size:"small",startIcon:e.jsx(We,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:a,children:l("notification.resend")})]})}Ue.propTypes={value:d.array.isRequired,onChange:d.func};function Ue({value:t,onChange:n}){const{locale:s}=X(),i=H().toDate(),[a,l]=b.useState(null),p=b.useCallback(S=>{l(a?null:S.currentTarget)},[a]),f=!!a,y=b.useCallback(S=>{if(!S.startDate||!S.endDate){V.error("Please select a date range");return}if(H(S.startDate).isAfter(S.endDate)||!H(S.startDate).isValid()||!H(S.endDate).isValid()){V.error("Invalid date range");return}n([S.startDate,S.endDate]),l(null)},[n]);return e.jsxs("div",{children:[e.jsx(G,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:0,children:e.jsxs(ye,{onClick:p,variant:"outlined",size:"small",color:"inherit",children:[Qe(t[0],s)," - ",Qe(t[1],s)]})}),e.jsx(Ee,{open:f,anchorEl:a,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(kt,{open:!0,maxDate:i,initialDateRange:{startDate:t[0],endDate:t[1]},toggle:p,definedRanges:Pt(i),onChange:y})})]})}Ve.propTypes={itemComponent:d.elementType.isRequired};function Ve({itemComponent:t,...n}){var a;const{t:s}=X();return!((a=n==null?void 0:n.filterList)!=null&&a.filter(l=>l.length).length)?null:e.jsxs(R,{display:"flex",gap:1,alignItems:"center",children:[e.jsx("div",{className:"toolbar-filter-title",children:s("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(wt.TableFilterList,{...n,ItemComponent:t})})]})}function Se({label:t,onDelete:n,canDelete:s=()=>!0,...i}){const a=n&&typeof n=="function"?n:void 0;let l=!0;return s&&typeof s=="function"&&(l=s({label:t,...i})),e.jsx(Fe,{label:t,variant:"outlined",...a&&l?{onDelete:a}:{}})}Se.propTypes={label:d.string.isRequired,onDelete:d.func,canDelete:d.func};Se.defaultProps={canDelete:()=>!0};const sn=[{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}];Ge.propTypes={loading:d.bool,onCancel:d.func,onConfirm:d.func};Ge.defaultProps={loading:!1,onCancel:()=>{},onConfirm:()=>{}};function Ge({loading:t=!1,onCancel:n,onConfirm:s}){const{t:i}=X(),[a,l]=b.useState(sn),[p,f]=b.useState(!0),y=(T,N)=>{N.checked=T.target.checked;const A=a.map(P=>({...P,checked:P.value===N.value?N.checked:P.checked}));l(A)},S=T=>{T.stopPropagation(),s({channels:a.filter(N=>N.checked).map(N=>N.value),isResendFailedOnly:p})};return e.jsxs(R,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(G,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:i("notification.config")}),e.jsx(R,{className:"choose-channel",children:e.jsxs(_e,{component:"fieldset",variant:"standard",children:[e.jsx(et,{component:"legend",children:i("notification.selectChannels")}),e.jsx(Te,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:a.map(T=>e.jsx(Ie,{control:e.jsx(De,{checked:T.checked,onChange:N=>y(N,T),name:T.value}),label:T.label},T.value))})]})}),e.jsx(R,{className:"resend-config-footer",children:e.jsx(Te,{children:e.jsx(Ie,{control:e.jsx(De,{checked:p,onChange:T=>f(T.target.checked)}),label:i("notification.resendFailedOnly")})})}),e.jsxs(R,{display:"flex",justifyContent:"flex-end",gap:1,className:"resend-config-footer-tip",children:[e.jsx(ye,{onClick:T=>{T.stopPropagation(),n()},color:"inherit",children:i("common.cancel")}),e.jsxs(ye,{onClick:S,color:"primary",disabled:t,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[t&&e.jsx(tt,{size:16}),i("common.confirm")]})]})]})}gt.propTypes={notificationId:d.string.isRequired,handleResend:d.func,resending:d.bool};function gt({notificationId:t,handleResend:n,resending:s=!1}){const{t:i,locale:a}=X(),{getReceivers:l,inService:p,teamDid:f,getUser:y,blocklet:S}=Me(),[T,N]=b.useState(!1),[A,P]=b.useState([]),O=Oe({anchorEl:null,position:null}),F=Oe({anchorEl:null,position:null}),[I,U]=b.useState(null),[j,v]=b.useState({total:0,pageSize:10,pageCount:0,page:1}),[x,w]=b.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[H().subtract(1,"month").startOf("day").toDate(),H().endOf("day").toDate()]}),[M,B]=b.useState([]),K=[{label:i("notification.sendStatus.pending"),value:0,status:"pending"},{label:i("notification.sendStatus.success"),value:1,status:"success"},{label:i("notification.sendStatus.failed"),value:2,status:"failed"}],_=async()=>{if(!T&&t)try{N(!0);const o=await l({notificationId:t,...x}),r=o.list.map(c=>({...c,receiverUser:{...c.receiverUser,avatar:ot(c.receiverUser.avatar,f,p)}}));P(r),v(o.paging),N(!1)}catch(o){V.error(o.message),N(!1)}};b.useEffect(()=>{_()},[x]);const Q=o=>{o.stopPropagation();const r=o.currentTarget;F.anchorEl=r;const c=r.getBoundingClientRect();F.position={top:c.top+window.scrollY,left:c.left+window.scrollX}},ee=o=>o.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(We,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:Q,children:i("notification.resend")})}):null,Ne={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:i("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:j.page-1,rowsPerPage:j.pageSize,count:j.total,searchText:x.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:M,onRowSelectionChange:(o,r)=>{B(r.map(c=>c.dataIndex))},customToolbarSelect:ee},we=({page:o,rowsPerPage:r,searchText:c,filterList:C})=>{const[,k=[],$=[],q=[]]=C;x.pageSize!==r?w(W=>({...W,pageSize:r,page:1})):x.page!==o+1?w(W=>({...W,page:o+1})):x.searchText!==c?w(W=>({...W,searchText:c,page:1})):re(k,x.walletSendStatus)?re($,x.pushKitSendStatus)?re(q,x.emailSendStatus)||w(W=>({...W,emailSendStatus:q,page:1})):w(W=>({...W,pushKitSendStatus:$,page:1})):w(W=>({...W,walletSendStatus:k,page:1}))},me=b.useCallback(async(o,r)=>{if(!r)return!1;const c=await y(r);return c?o==="wallet"?Qt(c):o==="email"?Xt(S,c):o==="pushKit"?Jt(S,c):o==="webhook"?Zt(c):!0:!1},[y,S]),h=b.useCallback(o=>en(i,o),[i]),u=()=>{O.anchorEl=null,O.position=null,U(null)},m=()=>{F.anchorEl=null,F.position=null},g=async(o,r,c=!0,C="")=>{if(!(!r.length||!o.length))try{n(o,r,c,C),F.anchorEl||(await ge(.5),u())}catch(k){console.error("handleResend error",{error:k})}},D=async({channels:o,isResendFailedOnly:r})=>{const c=M.map(C=>A[C].receiver);await g(o,c,r),await ge(.5),m(),B([])},E=async(o,r=[],c=!0)=>{try{await g(["webhook"],[o.receiver],c,r)}catch(C){V.error(C.response?C.response.statusText:C.message)}},z=async(o,r,c,C=[],k=!0)=>{if(o.stopPropagation(),tn(r,c)>=4){V.warning(i("notification.resendLimit"));return}if(!ke.includes(c)){await E(r,C,k);return}if(o){const q=o.currentTarget,W=q.getBoundingClientRect();O.anchorEl=q,O.position={top:W.top+window.scrollY,left:W.left+window.scrollX}}U({channel:c});try{const q=await me(c,r.receiver);await ge(1),U({channel:c,result:q}),(typeof q=="boolean"&&q||Ct(q)&&Object.values(q).every(W=>!!W))&&(await n([c],[r.receiver],k),F.anchorEl||(await ge(.5),u()))}catch(q){V.error(q.message)}},Y=o=>{w(r=>({...r,dateRange:o,page:1}))},te=(o,r,c,C)=>{o.stopPropagation();const k=c.filter($=>$!==r);w($=>({...$,[C]:k,page:1}))},ie=pe(()=>[{label:i("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:o=>{const{receiverUser:r,receiver:c}=A[o];return r?e.jsxs(R,{"data-cy":`member-name-${r.fullName}`,display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start",children:[e.jsx(st,{src:`${r.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:c,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(ue,{children:r.fullName})]},c):e.jsx(Lt,{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:x.walletSendStatus??[],customFilterListOptions:{render:o=>e.jsx(le,{list:o,label:"Wallet",onDelete:(r,c)=>{r.stopPropagation(),te(r,c,ie[1].options.filterList,"walletSendStatus")}}),update:je},filterOptions:{names:K,fullWidth:!0,logic:ve,display:(o,r,c,C)=>e.jsx(Re,{label:"Wallet",filterList:o,onChange:r,index:c,column:C,filterValues:K})},customBodyRenderLite:o=>{const{walletSendStatus:r,walletSendAt:c,walletSendFailedReason:C}=A[o];return e.jsx(oe,{status:r,updatedAt:c,reason:C,channel:"wallet",onResend:k=>z(k,A[o],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:o=>{const{pushKitSendStatus:r,pushKitSendAt:c,pushKitSendFailedReason:C}=A[o];return e.jsx(oe,{status:r,updatedAt:c,reason:C,channel:"pushkit",onResend:k=>z(k,A[o],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:x.pushKitSendStatus??[],customFilterListOptions:{render:o=>e.jsx(le,{list:o,label:"Push Kit",onDelete:(r,c)=>{r.stopPropagation(),te(r,c,ie[2].options.filterList,"pushKitSendStatus")}}),update:je},filterOptions:{names:K,fullWidth:!0,logic:ve,display:(o,r,c,C)=>e.jsx(Re,{label:"Push Kit",filterList:o,onChange:r,index:c,column:C,filterValues:K})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:o=>{const{emailSendStatus:r,emailSendAt:c,emailSendFailedReason:C}=A[o];return e.jsx(oe,{status:r,updatedAt:c,reason:C,channel:"email",onResend:k=>z(k,A[o],"email",[],!1)})},filter:!0,filterType:"custom",filterList:x.emailSendStatus??[],customFilterListOptions:{render:o=>e.jsx(le,{list:o,label:"Email",onDelete:(r,c)=>{r.stopPropagation(),te(r,c,ie[3].options.filterList,"emailSendStatus")}}),update:je},filterOptions:{names:K,fullWidth:!0,logic:ve,display:(o,r,c,C)=>e.jsx(Re,{label:"Email",filterList:o,onChange:r,index:c,column:C,filterValues:K})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:o=>{const{webhook:r}=A[o];if(!r)return null;const c=Object.entries(r)[0];if(!c)return null;const[C,k]=c,$=k[0];return e.jsx(R,{display:"flex",flexDirection:"column",gap:1,children:e.jsxs(R,{className:"webhook-item",fontSize:12,children:[e.jsx(ue,{maxLength:30,children:C},C),e.jsx(oe,{status:$.status,updatedAt:$.sendAt,reason:$.failedReason,channel:"webhook",onResend:q=>z(q,A[o],"webhook",[C],!1)})]},C)})}}},{label:i("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:o=>{const{createdAt:r}=A[o];return e.jsx(ze,{value:r,locale:a,shouldUpdate:!0})}}}],[A,a,x,i]),he=[e.jsx(Ue,{value:x.dateRange,onChange:Y},"date-picker"),e.jsx(Ae,{variant:"contained",size:"small",color:"primary",loading:T,startIcon:e.jsx(ut,{}),onClick:()=>_(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:i("common.refresh")},"refresh")];return e.jsx(R,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(on,{children:e.jsxs(nt,{theme:ht(),children:[e.jsx(at,{className:"receivers-table",locale:a,loading:T,columns:ie,data:A,onChange:we,options:Ne,customButtons:he,components:{TableFilterList:o=>e.jsx(Ve,{...o,itemComponent:r=>e.jsx(Se,{...r,canDelete:()=>!1})})}}),O.anchorEl&&e.jsx(Ee,{open:!!O.anchorEl,anchorReference:"anchorPosition",anchorPosition:O.position,onClose:u,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(rn,{children:[e.jsxs(G,{variant:"body1",component:"div",className:"check-title",children:[I==null?void 0:I.channel," Checking"]}),e.jsx(R,{display:"flex",flexDirection:"column",sx:{gap:"4px"},children:h(I==null?void 0:I.channel).map(o=>{var k,$;const{type:r,pass:c,fail:C}=o;return!(I!=null&&I.result)||(k=I==null?void 0:I.result)!=null&&k[r]?e.jsxs(G,{variant:"body1",component:"div",className:"check-item",display:"flex",alignItems:"center",sx:{gap:"4px",color:($=I==null?void 0:I.result)!=null&&$[r]?be.success.main:"inherit"},children:[I!=null&&I.result?e.jsx(ct,{}):e.jsx(tt,{size:12,sx:{color:be.primary.main}}),e.jsx("span",{children:c})]},r):e.jsxs(G,{variant:"body1",component:"div",display:"flex",alignItems:"center",className:"check-item",sx:{gap:"4px",color:be.error.main},children:[e.jsx(dt,{}),e.jsx("span",{children:C})]},r)})})]})}),F.anchorEl&&e.jsx(Ee,{open:!!F.anchorEl,anchorReference:"anchorPosition",anchorPosition:F.position,onClose:m,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Ge,{loading:s,onCancel:m,onConfirm:D})})]})})})}const an=b.memo(gt),on=ae.div`
|
|
1
|
+
import{r as b}from"./vendor-react-DoD83n6N.js";import{j as e,E as d,a1 as Pe,R as bt,a4 as jt,T as G,a3 as R,A as Fe,bj as _e,co as et,cn as Te,bn as Ie,bO as De,x as ye,aj as Ee,a2 as tt,a9 as ae,V as nt,bd as Xe,bm as vt,bi as yt,ai as Je,cp as St}from"./vendor-mui-core-O22FPGM4.js";import{b as Z,av as re,z as Ct}from"./vendor-utils-DJ1bmiuG.js";import{V,p as L,a$ as Nt,r as Be,u as X,bM as wt,U as st,B as Ae,a2 as at,bd as be,ak as Rt,aq as Tt,bC as It}from"./vendor-ux-did-connect-4bCiyPYS.js";import{z as Dt,G as H,m as Et,I as Qe}from"./index-DXodzmv1.js";import{f as pe,a as Oe}from"./vendor-hooks-DbRTDIFw.js";import{S as ue}from"./shorten-label-DXrhdUJE.js";import{I as it}from"./index-CT7JoARP.js";import{S as At,a as Ot}from"./list-CENIOVAm.js";import{R as ze}from"./relative-time-CRrl1gSW.js";import{b as We}from"./dashboard-CgU5vYTc.js";import{W as Lt}from"./did-address-BOFBaeCw.js";import{p as ot}from"./util-pKcd70El.js";import{D as kt,g as Pt}from"./traffic-BHL1S-qx.js";import{B as rt}from"./bundle-avatar-CV6DwAbG.js";import{B as Ft}from"./index-9xLdpFIQ.js";import"./lottie-web-B6s7dDoL.js";import"./vendor-arcblock-BmGcldk1.js";import"./index-C46rA4HG.js";import"./InfoOutlined-A0h5OX7J.js";import"./useLocalStorage-CCDYY4Oj.js";import"./confirm-AquAQGjx.js";import"./format-error-LAoTjvJe.js";import"./PlayArrow-ByDKBx4g.js";import"./get-safe-url-zNlUtfl-.js";import"./session-D7wR69VL.js";import"./useAsyncRetry-CcF3e_P6.js";import"./useAsync-CDzQ0uN6.js";import"./useSetState-BL3ktMon.js";import"./base32-BFbPN3_B.js";import"./iframe-Dg-K9tKI.js";import"./LaunchOutlined-LqfRJ-HK.js";import"./ChevronLeft-QmS7XZ0_.js";import"./ChevronRight-C-wVLPcS.js";import"./index-DWJc5Rxl.js";import"./vendor-mui-x-K-9WHqhO.js";const lt=b.createContext({}),{Provider:_t,Consumer:es}=lt;function Bt({children:t,blocklet:n=""}){const{api:s,inService:i}=Dt(),[a,l]=b.useState([]),[p,f]=b.useState({total:0,pageSize:20,pageCount:0,page:1}),y=pe(()=>{var j;return(j=n.meta)==null?void 0:j.did},[n]),[S,T]=b.useState([]),N=async({page:j=1,pageSize:v=20,...x}={})=>{if(!y)return[];try{const w={paging:{page:j,pageSize:v},...x,teamDid:y,dateRange:x.dateRange?[H(x.dateRange[0]).toISOString(),H(x.dateRange[1]).toISOString()]:void 0},{dids:M,...B}=w;let K="";M.includes("system")&&(K="system");const _=M.filter(ee=>ee!=="system"),Q=await s.getNotificationSendLog({input:{...B,source:K,componentDids:_}});return l(Q.list),f(Q.paging),Q.list}catch(w){return V.error(w.message),[]}},A=async()=>{const j=await s.getNotificationComponents({input:{teamDid:y}});T(j.componentDids)},P=b.useCallback(j=>{const v=n.children.find(x=>{var w;return((w=x.meta)==null?void 0:w.did)===j});if(v)return v.ancestors=[n],v},[n]),O=async({notificationId:j,receivers:v,channels:x,...w})=>{await s.resendNotification({input:{teamDid:y,notificationId:j,receivers:v,channels:x.map(M=>M==="wallet"?L.NOTIFICATION_SEND_CHANNEL.WALLET:M==="pushKit"?L.NOTIFICATION_SEND_CHANNEL.PUSH:M),...w}})},F=b.useCallback(async j=>(await s.getUser({input:{teamDid:y,user:{did:j}}})).user,[s,y]),I=b.useCallback(async({page:j=1,pageSize:v=20,...x}={})=>{try{const w={paging:{page:j,pageSize:v},...x,userName:x.searchText||"",teamDid:y,dateRange:x.dateRange?[H(x.dateRange[0]).toISOString(),H(x.dateRange[1]).toISOString()]:void 0};return await s.getReceivers({input:w})}catch(w){throw V.error(w.message),w}},[s,y]);b.useEffect(()=>{y&&A()},[y]);const U={fetch:N,data:a,paging:p,blocklet:n,getComponent:P,resendNotification:O,getUser:F,componentDids:S,getReceivers:I,inService:i,teamDid:y};return e.jsx(_t,{value:{notificationRecords:U},children:t})}function Me(){const{notificationRecords:t}=b.useContext(lt);return t}fe.propTypes={severity:d.oneOf(Object.values(["info","success","error","warning"])).isRequired};const zt={info:"primary",success:"success",error:"error",warning:"warning"};function fe({severity:t="info"}){return e.jsx(Nt,{type:zt[t],children:t})}var qe={},Wt=Pe;Object.defineProperty(qe,"__esModule",{value:!0});var ct=qe.default=void 0,Mt=Wt(Be()),qt=e;ct=qe.default=(0,Mt.default)((0,qt.jsx)("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"CheckCircleOutline");var Ke={},Kt=Pe;Object.defineProperty(Ke,"__esModule",{value:!0});var dt=Ke.default=void 0,$t=Kt(Be()),Ht=e;dt=Ke.default=(0,$t.default)((0,Ht.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12m8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8"}),"Block");var $e={},Ut=Pe;Object.defineProperty($e,"__esModule",{value:!0});var ut=$e.default=void 0,Vt=Ut(Be()),Gt=e;ut=$e.default=(0,Vt.default)((0,Gt.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");const Yt=(t,n,s="")=>{if(!s||!n)return"";switch(s){case L.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return t("notification.sendStatus.reason.disabled",{channel:n});case L.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return t("notification.sendStatus.reason.unavailable",{channel:n});case L.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return t("notification.sendStatus.reason.notSent",{channel:n});case L.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return t("notification.sendStatus.reason.offline");default:return s}};function pt(t,n,s={}){const{status:i,updatedAt:a,reason:l="",channel:p="wallet"}=s,f=a?t("notification.sendStatus.sentTime",{date:Et(a,n)}):"",y=Yt(t,p,l);return i===L.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:t("notification.sendStatus.failed"),sentTime:f,reason:y}:i===L.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:t("notification.sendStatus.success"),sentTime:f}:{status:"pending",title:t("notification.sendStatus.pending"),reason:y,sentTime:f}}const Le={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},ke=["wallet","pushKit","email"],Ze=["info","success","error","warning"],ft=t=>{var s,i;const{settings:n}=t;return(i=(s=n==null?void 0:n.notification)==null?void 0:s.email)==null?void 0:i.enabled},mt=t=>{var s,i;const{settings:n}=t;return(i=(s=n==null?void 0:n.notification)==null?void 0:s.pushKit)==null?void 0:i.enabled},Xt=(t,n)=>{const s=Z(n,"extra.notifications.email",!0);return{available:ft(t),enabled:s}},Jt=(t,n)=>{const s=Z(n,"extra.notifications.push",!0);return{available:mt(t),enabled:s}},Qt=t=>({enabled:Z(t,"extra.notifications.wallet",!0)}),Zt=t=>({enabled:Z(t,"extra.webhooks",[]).length>0}),ge=(t=3)=>new Promise(n=>{setTimeout(()=>{n()},t*1e3)}),en=(t,n)=>n==="wallet"||n==="webhook"?[{channel:n,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:n}),fail:t("notification.sendStatus.reason.disabled",{channel:n})}]:n==="pushKit"||n==="email"?[{channel:n,type:"available",pass:t("notification.sendStatus.reason.available",{channel:n}),fail:t("notification.sendStatus.reason.unavailable",{channel:n})},{channel:n,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:n}),fail:t("notification.sendStatus.reason.disabled",{channel:n})}]:[],xe=(t=[])=>{const n=H().startOf("day");return t.filter(s=>H(s.sendAt).isSame(n,"day")).length},tn=(t,n="")=>{if(n&&ke.includes(n)){const l=`${n}SendRecord`,p=Z(t,l,[]);return xe(p)}const s=Z(t,"webhook",{}),i=Object.keys(s??{})??[];if(n&&i.includes(n)){const l=s[n]??[];return xe(l)}const a={};return ke.forEach(l=>{const p=`${l}SendRecord`,f=Z(t,p,[]),y=xe(f);a[l]=y}),i.length>0&&i.forEach(l=>{const p=s[l]??[],f=xe(p);a[l]=f}),a},je=(t,n,s)=>{if(!Array.isArray(t))throw new Error("Invalid filterList or index");return t[s].splice(n,1),t},ve=(t,n)=>{if(!Array.isArray(n))throw new Error("filters must be an array");return n.length?!n.includes(t):!1},nn=t=>{switch(t){case L.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case L.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case L.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case L.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},ht=()=>bt({typography:{fontSize:14,button:{textTransform:"none"}},palette:{primary:{main:"#1DC1C7",contrastText:"#fff"},secondary:{main:"#030712",contrastText:"#fff"},storeSecondary:{main:"#EBFEFF",contrastText:"#fff"}},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 J({config:t,enableTooltip:n=!0,showTitle:s=!1,children:i}){const{status:a,title:l="",sentTime:p="",reason:f=""}=t,y=[l,f].filter(Boolean).join(", ");return e.jsx(jt,{title:n?e.jsxs(e.Fragment,{children:[e.jsx(G,{color:"inherit",sx:{fontSize:12},children:y}),e.jsx("span",{children:p})]}):null,arrow:!0,placement:"top",children:e.jsxs(R,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(R,{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center",children:[e.jsx(R,{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Le[a],style:{opacity:.15}}),e.jsx(R,{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Le[a]})]}),e.jsx(G,{color:"inherit",sx:{fontSize:12},children:s?l:i})]})})}J.propTypes={config:d.object.isRequired,enableTooltip:d.bool,showTitle:d.bool,children:d.node};J.defaultProps={enableTooltip:!0,showTitle:!1,children:null};le.propTypes={list:d.array.isRequired,label:d.string.isRequired,onDelete:d.func};le.defaultProps={onDelete:()=>{}};function le({list:t,label:n,onDelete:s}){const{t:i,locale:a}=X();return e.jsxs(R,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(G,{children:[n,": "]}),t.map(l=>{const p=pt(i,a,{status:l});return e.jsx(Fe,{size:"small",label:e.jsx(R,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(J,{config:p,enableTooltip:!1,children:p.title})}),onDelete:f=>s(f,l)},l)})]})}He.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 He({filterList:t,onChange:n,index:s,column:i,filterValues:a,label:l,renderLabel:p}){return e.jsxs(_e,{className:"filter-container",children:[e.jsx(et,{component:"legend",children:l}),e.jsx(Te,{row:!0,children:a.map(f=>e.jsx(Ie,{control:e.jsx(De,{checked:t[s].indexOf(f.value??f)>-1,onChange:y=>{const S=[...t];y.target.checked?S[s]=[...S[s],f.value??f]:S[s]=S[s].filter(T=>T!==(f.value??f)),n(S[s],s,i)},name:f.value??f}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:p(f)})},f.value??f))})]})}function Re(t){return e.jsx(He,{...t,renderLabel:n=>e.jsx(J,{enableTooltip:!1,config:{status:n.status},children:n.label})})}oe.propTypes={status:d.number.isRequired,updatedAt:d.string.isRequired,reason:d.string,channel:d.string,onResend:d.func};function oe({status:t,updatedAt:n,reason:s="",channel:i="wallet",onResend:a}){const{t:l,locale:p}=X(),f=pt(l,p,{status:t,updatedAt:n,reason:s,channel:i});return e.jsxs(R,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(J,{config:f,showTitle:!0}),f.status!=="success"&&e.jsx(ye,{className:"resend-btn",size:"small",startIcon:e.jsx(We,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:a,children:l("notification.resend")})]})}Ue.propTypes={value:d.array.isRequired,onChange:d.func};function Ue({value:t,onChange:n}){const{locale:s}=X(),i=H().toDate(),[a,l]=b.useState(null),p=b.useCallback(S=>{l(a?null:S.currentTarget)},[a]),f=!!a,y=b.useCallback(S=>{if(!S.startDate||!S.endDate){V.error("Please select a date range");return}if(H(S.startDate).isAfter(S.endDate)||!H(S.startDate).isValid()||!H(S.endDate).isValid()){V.error("Invalid date range");return}n([S.startDate,S.endDate]),l(null)},[n]);return e.jsxs("div",{children:[e.jsx(G,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:0,children:e.jsxs(ye,{onClick:p,variant:"outlined",size:"small",color:"inherit",children:[Qe(t[0],s)," - ",Qe(t[1],s)]})}),e.jsx(Ee,{open:f,anchorEl:a,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(kt,{open:!0,maxDate:i,initialDateRange:{startDate:t[0],endDate:t[1]},toggle:p,definedRanges:Pt(i),onChange:y})})]})}Ve.propTypes={itemComponent:d.elementType.isRequired};function Ve({itemComponent:t,...n}){var a;const{t:s}=X();return!((a=n==null?void 0:n.filterList)!=null&&a.filter(l=>l.length).length)?null:e.jsxs(R,{display:"flex",gap:1,alignItems:"center",children:[e.jsx("div",{className:"toolbar-filter-title",children:s("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(wt.TableFilterList,{...n,ItemComponent:t})})]})}function Se({label:t,onDelete:n,canDelete:s=()=>!0,...i}){const a=n&&typeof n=="function"?n:void 0;let l=!0;return s&&typeof s=="function"&&(l=s({label:t,...i})),e.jsx(Fe,{label:t,variant:"outlined",...a&&l?{onDelete:a}:{}})}Se.propTypes={label:d.string.isRequired,onDelete:d.func,canDelete:d.func};Se.defaultProps={canDelete:()=>!0};const sn=[{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}];Ge.propTypes={loading:d.bool,onCancel:d.func,onConfirm:d.func};Ge.defaultProps={loading:!1,onCancel:()=>{},onConfirm:()=>{}};function Ge({loading:t=!1,onCancel:n,onConfirm:s}){const{t:i}=X(),[a,l]=b.useState(sn),[p,f]=b.useState(!0),y=(T,N)=>{N.checked=T.target.checked;const A=a.map(P=>({...P,checked:P.value===N.value?N.checked:P.checked}));l(A)},S=T=>{T.stopPropagation(),s({channels:a.filter(N=>N.checked).map(N=>N.value),isResendFailedOnly:p})};return e.jsxs(R,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(G,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:i("notification.config")}),e.jsx(R,{className:"choose-channel",children:e.jsxs(_e,{component:"fieldset",variant:"standard",children:[e.jsx(et,{component:"legend",children:i("notification.selectChannels")}),e.jsx(Te,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:a.map(T=>e.jsx(Ie,{control:e.jsx(De,{checked:T.checked,onChange:N=>y(N,T),name:T.value}),label:T.label},T.value))})]})}),e.jsx(R,{className:"resend-config-footer",children:e.jsx(Te,{children:e.jsx(Ie,{control:e.jsx(De,{checked:p,onChange:T=>f(T.target.checked)}),label:i("notification.resendFailedOnly")})})}),e.jsxs(R,{display:"flex",justifyContent:"flex-end",gap:1,className:"resend-config-footer-tip",children:[e.jsx(ye,{onClick:T=>{T.stopPropagation(),n()},color:"inherit",children:i("common.cancel")}),e.jsxs(ye,{onClick:S,color:"primary",disabled:t,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[t&&e.jsx(tt,{size:16}),i("common.confirm")]})]})]})}gt.propTypes={notificationId:d.string.isRequired,handleResend:d.func,resending:d.bool};function gt({notificationId:t,handleResend:n,resending:s=!1}){const{t:i,locale:a}=X(),{getReceivers:l,inService:p,teamDid:f,getUser:y,blocklet:S}=Me(),[T,N]=b.useState(!1),[A,P]=b.useState([]),O=Oe({anchorEl:null,position:null}),F=Oe({anchorEl:null,position:null}),[I,U]=b.useState(null),[j,v]=b.useState({total:0,pageSize:10,pageCount:0,page:1}),[x,w]=b.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[H().subtract(1,"month").startOf("day").toDate(),H().endOf("day").toDate()]}),[M,B]=b.useState([]),K=[{label:i("notification.sendStatus.pending"),value:0,status:"pending"},{label:i("notification.sendStatus.success"),value:1,status:"success"},{label:i("notification.sendStatus.failed"),value:2,status:"failed"}],_=async()=>{if(!T&&t)try{N(!0);const o=await l({notificationId:t,...x}),r=o.list.map(c=>({...c,receiverUser:{...c.receiverUser,avatar:ot(c.receiverUser.avatar,f,p)}}));P(r),v(o.paging),N(!1)}catch(o){V.error(o.message),N(!1)}};b.useEffect(()=>{_()},[x]);const Q=o=>{o.stopPropagation();const r=o.currentTarget;F.anchorEl=r;const c=r.getBoundingClientRect();F.position={top:c.top+window.scrollY,left:c.left+window.scrollX}},ee=o=>o.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(We,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:Q,children:i("notification.resend")})}):null,Ne={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:i("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:j.page-1,rowsPerPage:j.pageSize,count:j.total,searchText:x.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:M,onRowSelectionChange:(o,r)=>{B(r.map(c=>c.dataIndex))},customToolbarSelect:ee},we=({page:o,rowsPerPage:r,searchText:c,filterList:C})=>{const[,k=[],$=[],q=[]]=C;x.pageSize!==r?w(W=>({...W,pageSize:r,page:1})):x.page!==o+1?w(W=>({...W,page:o+1})):x.searchText!==c?w(W=>({...W,searchText:c,page:1})):re(k,x.walletSendStatus)?re($,x.pushKitSendStatus)?re(q,x.emailSendStatus)||w(W=>({...W,emailSendStatus:q,page:1})):w(W=>({...W,pushKitSendStatus:$,page:1})):w(W=>({...W,walletSendStatus:k,page:1}))},me=b.useCallback(async(o,r)=>{if(!r)return!1;const c=await y(r);return c?o==="wallet"?Qt(c):o==="email"?Xt(S,c):o==="pushKit"?Jt(S,c):o==="webhook"?Zt(c):!0:!1},[y,S]),h=b.useCallback(o=>en(i,o),[i]),u=()=>{O.anchorEl=null,O.position=null,U(null)},m=()=>{F.anchorEl=null,F.position=null},g=async(o,r,c=!0,C="")=>{if(!(!r.length||!o.length))try{n(o,r,c,C),F.anchorEl||(await ge(.5),u())}catch(k){console.error("handleResend error",{error:k})}},D=async({channels:o,isResendFailedOnly:r})=>{const c=M.map(C=>A[C].receiver);await g(o,c,r),await ge(.5),m(),B([])},E=async(o,r=[],c=!0)=>{try{await g(["webhook"],[o.receiver],c,r)}catch(C){V.error(C.response?C.response.statusText:C.message)}},z=async(o,r,c,C=[],k=!0)=>{if(o.stopPropagation(),tn(r,c)>=4){V.warning(i("notification.resendLimit"));return}if(!ke.includes(c)){await E(r,C,k);return}if(o){const q=o.currentTarget,W=q.getBoundingClientRect();O.anchorEl=q,O.position={top:W.top+window.scrollY,left:W.left+window.scrollX}}U({channel:c});try{const q=await me(c,r.receiver);await ge(1),U({channel:c,result:q}),(typeof q=="boolean"&&q||Ct(q)&&Object.values(q).every(W=>!!W))&&(await n([c],[r.receiver],k),F.anchorEl||(await ge(.5),u()))}catch(q){V.error(q.message)}},Y=o=>{w(r=>({...r,dateRange:o,page:1}))},te=(o,r,c,C)=>{o.stopPropagation();const k=c.filter($=>$!==r);w($=>({...$,[C]:k,page:1}))},ie=pe(()=>[{label:i("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:o=>{const{receiverUser:r,receiver:c}=A[o];return r?e.jsxs(R,{"data-cy":`member-name-${r.fullName}`,display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start",children:[e.jsx(st,{src:`${r.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:c,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(ue,{children:r.fullName})]},c):e.jsx(Lt,{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:x.walletSendStatus??[],customFilterListOptions:{render:o=>e.jsx(le,{list:o,label:"Wallet",onDelete:(r,c)=>{r.stopPropagation(),te(r,c,ie[1].options.filterList,"walletSendStatus")}}),update:je},filterOptions:{names:K,fullWidth:!0,logic:ve,display:(o,r,c,C)=>e.jsx(Re,{label:"Wallet",filterList:o,onChange:r,index:c,column:C,filterValues:K})},customBodyRenderLite:o=>{const{walletSendStatus:r,walletSendAt:c,walletSendFailedReason:C}=A[o];return e.jsx(oe,{status:r,updatedAt:c,reason:C,channel:"wallet",onResend:k=>z(k,A[o],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:o=>{const{pushKitSendStatus:r,pushKitSendAt:c,pushKitSendFailedReason:C}=A[o];return e.jsx(oe,{status:r,updatedAt:c,reason:C,channel:"pushkit",onResend:k=>z(k,A[o],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:x.pushKitSendStatus??[],customFilterListOptions:{render:o=>e.jsx(le,{list:o,label:"Push Kit",onDelete:(r,c)=>{r.stopPropagation(),te(r,c,ie[2].options.filterList,"pushKitSendStatus")}}),update:je},filterOptions:{names:K,fullWidth:!0,logic:ve,display:(o,r,c,C)=>e.jsx(Re,{label:"Push Kit",filterList:o,onChange:r,index:c,column:C,filterValues:K})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:o=>{const{emailSendStatus:r,emailSendAt:c,emailSendFailedReason:C}=A[o];return e.jsx(oe,{status:r,updatedAt:c,reason:C,channel:"email",onResend:k=>z(k,A[o],"email",[],!1)})},filter:!0,filterType:"custom",filterList:x.emailSendStatus??[],customFilterListOptions:{render:o=>e.jsx(le,{list:o,label:"Email",onDelete:(r,c)=>{r.stopPropagation(),te(r,c,ie[3].options.filterList,"emailSendStatus")}}),update:je},filterOptions:{names:K,fullWidth:!0,logic:ve,display:(o,r,c,C)=>e.jsx(Re,{label:"Email",filterList:o,onChange:r,index:c,column:C,filterValues:K})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:o=>{const{webhook:r}=A[o];if(!r)return null;const c=Object.entries(r)[0];if(!c)return null;const[C,k]=c,$=k[0];return e.jsx(R,{display:"flex",flexDirection:"column",gap:1,children:e.jsxs(R,{className:"webhook-item",fontSize:12,children:[e.jsx(ue,{maxLength:30,children:C},C),e.jsx(oe,{status:$.status,updatedAt:$.sendAt,reason:$.failedReason,channel:"webhook",onResend:q=>z(q,A[o],"webhook",[C],!1)})]},C)})}}},{label:i("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:o=>{const{createdAt:r}=A[o];return e.jsx(ze,{value:r,locale:a,shouldUpdate:!0})}}}],[A,a,x,i]),he=[e.jsx(Ue,{value:x.dateRange,onChange:Y},"date-picker"),e.jsx(Ae,{variant:"contained",size:"small",color:"primary",loading:T,startIcon:e.jsx(ut,{}),onClick:()=>_(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:i("common.refresh")},"refresh")];return e.jsx(R,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(on,{children:e.jsxs(nt,{theme:ht(),children:[e.jsx(at,{className:"receivers-table",locale:a,loading:T,columns:ie,data:A,onChange:we,options:Ne,customButtons:he,components:{TableFilterList:o=>e.jsx(Ve,{...o,itemComponent:r=>e.jsx(Se,{...r,canDelete:()=>!1})})}}),O.anchorEl&&e.jsx(Ee,{open:!!O.anchorEl,anchorReference:"anchorPosition",anchorPosition:O.position,onClose:u,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(rn,{children:[e.jsxs(G,{variant:"body1",component:"div",className:"check-title",children:[I==null?void 0:I.channel," Checking"]}),e.jsx(R,{display:"flex",flexDirection:"column",sx:{gap:"4px"},children:h(I==null?void 0:I.channel).map(o=>{var k,$;const{type:r,pass:c,fail:C}=o;return!(I!=null&&I.result)||(k=I==null?void 0:I.result)!=null&&k[r]?e.jsxs(G,{variant:"body1",component:"div",className:"check-item",display:"flex",alignItems:"center",sx:{gap:"4px",color:($=I==null?void 0:I.result)!=null&&$[r]?be.success.main:"inherit"},children:[I!=null&&I.result?e.jsx(ct,{}):e.jsx(tt,{size:12,sx:{color:be.primary.main}}),e.jsx("span",{children:c})]},r):e.jsxs(G,{variant:"body1",component:"div",display:"flex",alignItems:"center",className:"check-item",sx:{gap:"4px",color:be.error.main},children:[e.jsx(dt,{}),e.jsx("span",{children:C})]},r)})})]})}),F.anchorEl&&e.jsx(Ee,{open:!!F.anchorEl,anchorReference:"anchorPosition",anchorPosition:F.position,onClose:m,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Ge,{loading:s,onCancel:m,onConfirm:D})})]})})})}const an=b.memo(gt),on=ae.div`
|
|
2
2
|
td.MuiTableCell-footer {
|
|
3
3
|
border: none !important;
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{E as r,a9 as f,j as i,by as T,a3 as S,a2 as D}from"./vendor-mui-core-O22FPGM4.js";import{a as $,k as E,u as P,l as U}from"./vendor-hooks-DbRTDIFw.js";import{N as q,R as F}from"./vendor-arcblock-
|
|
1
|
+
import{E as r,a9 as f,j as i,by as T,a3 as S,a2 as D}from"./vendor-mui-core-O22FPGM4.js";import{a as $,k as E,u as P,l as U}from"./vendor-hooks-DbRTDIFw.js";import{N as q,R as F}from"./vendor-arcblock-BmGcldk1.js";import{r as m}from"./vendor-react-DoD83n6N.js";import{aX as M,ak as H,u as j,aL as O,p as B,aY as I,U as W}from"./vendor-ux-did-connect-4bCiyPYS.js";import{x as X}from"./vendor-utils-DJ1bmiuG.js";import{v as V,w as L,x as z}from"./index-DXodzmv1.js";import{u as Y}from"./use-passport-id-B-b-_oYF.js";import{u as J}from"./session-D7wR69VL.js";import{b as K}from"./sdk-CrU7nlFr.js";import{d as G}from"./CheckCircle-B3DI9-8u.js";import{w as Q}from"./wrap-locale-h-Rh8AV-.js";function k({invitation:e,createPassportSvg:a,passportColor:c}){const[p,n]=m.useState(!1),{t}=m.useContext(M),l=m.useMemo(()=>(e.role.title||e.role.name).toUpperCase(),[e.role.title,e.role.name]),u=m.useMemo(()=>a({title:l,issuer:e.info.name,issuerDid:e.info.appDid,ownerName:"Your Name",ownerDid:e.info.appDid,preferredColor:e.info.passportColor||c}),[e,l]),x=m.useCallback(()=>{n(!0)},[]),s=m.useCallback(()=>{n(!1)},[]);return i.jsxs(i.Fragment,{children:[i.jsx(Z,{children:i.jsxs("div",{className:"invite-passport__card",onClick:x,children:[!!e.display&&i.jsx(q,{data:e.display,style:{width:"100%",height:"100%"}}),!e.display&&i.jsx("div",{className:"invite-passport__cover",dangerouslySetInnerHTML:{__html:u}})]})}),i.jsx(H,{open:p,title:t("invite.viewPermission"),PaperProps:{style:{minHeight:"auto",paddingBottom:"20px"}},onClose:s,children:e.role.permissions&&e.role.permissions.length>0?i.jsx("ul",{style:{listStyle:"circle",padding:"0 20px"},children:e.role.permissions.map(o=>i.jsx("li",{style:{listStyle:"circle"},children:o.description},o.name))}):i.jsxs("div",{style:{color:"#999",textAlign:"center"},children:[i.jsx(T,{style:{width:"30px",height:"30px"}}),i.jsx("div",{children:t("invite.emptyPermission")})]})})]})}k.propTypes={invitation:r.object.isRequired,createPassportSvg:r.func.isRequired,passportColor:r.string};k.defaultProps={passportColor:"auto"};const Z=f.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
max-width: 350px;
|
|
4
4
|
margin: 30px auto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as i,a3 as x}from"./vendor-mui-core-O22FPGM4.js";import{k as g,r as u}from"./vendor-react-DoD83n6N.js";import{u as v}from"./vendor-hooks-DbRTDIFw.js";import{I as w}from"./invitation-
|
|
1
|
+
import{j as i,a3 as x}from"./vendor-mui-core-O22FPGM4.js";import{k as g,r as u}from"./vendor-react-DoD83n6N.js";import{u as v}from"./vendor-hooks-DbRTDIFw.js";import{I as w}from"./invitation-BXtb5O-j.js";import{F as I}from"./fullpage-Bo8SoEA1.js";import{u as k,aN as S,p as T}from"./vendor-ux-did-connect-4bCiyPYS.js";import{H as j}from"./vendor-arcblock-BmGcldk1.js";import{g as E}from"./get-safe-url-RpxfbZMw.js";import{u as P,d as F,c as R,s as W,a as C}from"./index-DXodzmv1.js";import"./vendor-utils-DJ1bmiuG.js";import"./use-passport-id-B-b-_oYF.js";import"./session-D7wR69VL.js";import"./sdk-CrU7nlFr.js";import"./CheckCircle-B3DI9-8u.js";import"./wrap-locale-h-Rh8AV-.js";import"./lottie-web-B6s7dDoL.js";function y(c){var r;const m=g(),{searchParams:s}=new URL(window.location.href),{api:p,session:d}=P(),{t:f}=k(),a=s.get("inviteId"),n=s.get("redirect"),h=u.useCallback(async()=>{const{data:t}=await F.get("invitation",{params:{inviteId:a}});return t},[a]),l=v(async(t,o=e=>e)=>{t&&(W(o(t.sessionToken)),C(o(t.refreshToken)),t.visitorId&&S(o(t.visitorId))),await d.refresh(),setTimeout(()=>{if(n){const e=decodeURIComponent(n);e.startsWith(T.WELLKNOWN_SERVICE_PATH_PREFIX)?m(e,{replace:!0}):window.location.href=E(e)}else window.location.href=window.env.pathPrefix||"/"},50)});return i.jsxs(I,{did:(r=window.blocklet)==null?void 0:r.appPid,children:[i.jsx(j,{children:i.jsx("title",{children:f("pageTitle.invite")})}),i.jsx(x,{sx:{width:"560px",maxWidth:"100%",height:"100%"},className:"page-invite",children:i.jsx(w,{...c,getDataFn:h,checkFn:p.get,createPassportSvg:R,onLoginSuccess:l,inService:!0})})]})}export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,a2 as w,a3 as v}from"./vendor-mui-core-O22FPGM4.js";import{a as I,l as P,u as m}from"./vendor-hooks-DbRTDIFw.js";import{I as T}from"./invitation-
|
|
1
|
+
import{j as e,a2 as w,a3 as v}from"./vendor-mui-core-O22FPGM4.js";import{a as I,l as P,u as m}from"./vendor-hooks-DbRTDIFw.js";import{I as T}from"./invitation-BXtb5O-j.js";import{F as k}from"./fullpage-Bo8SoEA1.js";import{u as j,aN as R,p as S}from"./vendor-ux-did-connect-4bCiyPYS.js";import{H as E}from"./vendor-arcblock-BmGcldk1.js";import{g as F}from"./get-safe-url-RpxfbZMw.js";import{u as C,c as L,s as N,a as W}from"./index-DXodzmv1.js";import{k as H}from"./vendor-react-DoD83n6N.js";import"./vendor-utils-DJ1bmiuG.js";import"./use-passport-id-B-b-_oYF.js";import"./session-D7wR69VL.js";import"./sdk-CrU7nlFr.js";import"./CheckCircle-B3DI9-8u.js";import"./wrap-locale-h-Rh8AV-.js";import"./lottie-web-B6s7dDoL.js";function Q(f){var p;const{searchParams:a}=new URL(window.location.href),{api:r,session:d}=C(),u=H(),{t:h}=j(),n=a.get("id"),c=a.get("redirect"),l=I({state:""}),s=P(async()=>{if(!n)return null;const{data:t}=await r.get("/api/invitation",{params:{inviteId:n,mode:"issue-passport"}});return t}),g=m(()=>{if(s.error)throw s.error;return s==null?void 0:s.data}),x=m(async(t,i=o=>o)=>{t&&(t.sessionToken&&N(i(t.sessionToken)),t.refreshToken&&W(i(t.refreshToken)),t.visitorId&&R(i(t.visitorId)),await d.refresh()),setTimeout(()=>{if(c){const o=decodeURIComponent(c);o.startsWith(S.WELLKNOWN_SERVICE_PATH_PREFIX)?u(o,{replace:!0}):window.location.href=F(o)}else window.location.href=window.env.pathPrefix||"/"},50)});return s.loading?e.jsx(w,{}):e.jsxs(k,{did:(p=window.blocklet)==null?void 0:p.appPid,children:[e.jsx(E,{children:e.jsx("title",{children:h("pageTitle.issuePassport")})}),e.jsx(v,{className:"page-invite",sx:{width:"560px",maxWidth:"100%",height:"100%"},children:e.jsx(T,{...f,action:"issue-passport",getDataFn:g,checkFn:r.get,createPassportSvg:L,onLoginSuccess:x,inService:!0,status:l.state})})]})}export{Q as default};
|