@abtnode/blocklet-services 1.16.45-beta-20250626-115702-00b49b4c → 1.16.45-beta-20250627-075343-5af3ad9a
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/dist/assets/access-control-BH4SKMry.js +1 -1
- package/dist/assets/add-component-core-DsuA1aKD.js +1 -1
- package/dist/assets/add-resource-BHpNuRRT.js +1 -1
- package/dist/assets/advanced-Dv4hgvDN.js +1 -1
- package/dist/assets/appearance-D25Cy4CD.js +1 -1
- package/dist/assets/audit-logs-DxpLWxIb.js +1 -1
- package/dist/assets/complete-DZkXZTgu.js +1 -1
- package/dist/assets/component-ufgkgw5l.js +1 -1
- package/dist/assets/config-4oY1pbez.js +1 -1
- package/dist/assets/config-navigation-Bc7wRQPN.js +1 -1
- package/dist/assets/connect-B0psb3-s.js +1 -1
- package/dist/assets/dashboard-Cvfy6NEE.js +2 -2
- package/dist/assets/domain-syiX0-xT.js +1 -1
- package/dist/assets/email-D1fetol9.js +1 -1
- package/dist/assets/exchange-passport-6gauQ6xB.js +1 -1
- package/dist/assets/fuel-C0n-khQ9.js +1 -1
- package/dist/assets/index-7mvFZreO.js +1 -1
- package/dist/assets/index-C4yBWU5s.js +1 -1
- package/dist/assets/index-CMYHZyLG.js +1 -1
- package/dist/assets/index-CW1Uu8tM.js +1 -1
- package/dist/assets/index-CssP44F_.js +1 -1
- package/dist/assets/index-Cza1eXOB.js +1 -1
- package/dist/assets/index-D0mjW5YA.js +1 -1
- package/dist/assets/index-DC-aJClV.js +1 -1
- package/dist/assets/index-DOM4CWCV.js +1 -1
- package/dist/assets/index-YTd3fqJi.js +1 -1
- package/dist/assets/index-ZnxES9EB.js +1 -1
- package/dist/assets/invite-DB6Gc2ZO.js +1 -1
- package/dist/assets/issue-passport-BElK-FIZ.js +1 -1
- package/dist/assets/item-D95t-at-.js +1 -1
- package/dist/assets/list-q5d_hBMT.js +1 -1
- package/dist/assets/login-Bs3IhQdt.js +1 -1
- package/dist/assets/lost-passport-CHgCTW2X.js +1 -1
- package/dist/assets/open-window-hpzKFxn5.js +1 -1
- package/dist/assets/overview-BlZSVHbX.js +1 -1
- package/dist/assets/publish-resource-CjbA8eXl.js +1 -1
- package/dist/assets/runtime-BAC7Yn-4.js +1 -1
- package/dist/assets/security-BdzQGoAm.js +1 -1
- package/dist/assets/setup-mVNNI9iB.js +2 -2
- package/dist/assets/start-CGuvKy2s.js +1 -1
- package/dist/assets/step-actions-Bps0yIu_.js +1 -1
- package/dist/assets/table-tips-BzPqsKYQ.js +1 -1
- package/dist/assets/use-server-logo-UTr-CyJD.js +1 -1
- package/package.json +23 -23
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as Ut,r as C}from"./vendor-react-DEoibe3W.js";import{ah as ue,al as ht,j as e,aa as T,O as te,bs as ge,bt as We,bo as G,ad as xt,H as x,a9 as Je,T as ae,E as Xe,bz as gt,bQ as Ke,bR as qe,y as Le,b6 as Me,ab as bt,bI as jt,Y as vt,cn as yt,m as Ht,as as dt,br as Vt,bn as Gt,q as ut,bX as Yt,I as Jt}from"./vendor-mui-core-Bq8gXTan.js";import{J as St,z as Xt,A as Qt,e as fe,aB as ye,C as Zt}from"./vendor-utils-BfZ4tlod.js";import{y as es,a as re,ab as Ct,a3 as q,X as ke,c1 as ts,B as me,k as W,bb as ss,ax as wt,bg as ns,r as Qe,c2 as is,a2 as Tt,ac as Rt,bB as Oe,ar as Nt,$ as as,bI as rs}from"./vendor-ux-did-connect-pzpsrvqx.js";import{D as Ze,G as Et,aC as It,aD as Q,y as se,n as os,K as pt}from"./index-CMYHZyLG.js";import{a as Te,u as V,b as ce}from"./vendor-hooks-DqdmWCmo.js";import{a as et,b as ls}from"./dashboard-Cvfy6NEE.js";import{f as $e,i as cs,d as ds}from"./use-blocklet-logo-CWdlYyrq.js";import{A as us,a as ps,d as fs,b as ms}from"./collapse-DAaiuAEY.js";import{S as ee}from"./section-BDMQAX_r.js";import{S as Re}from"./shorten-label-BQvbtscf.js";import{I as Ot}from"./index-DPIWnhb5.js";import{R as At,A as hs,S as xs,a as gs,b as bs,B as js}from"./list-Dk6LlvZw.js";import{W as vs}from"./did-address-NnOD1W_A.js";import{p as Dt}from"./util-BQAJqeb4.js";import{D as ys,g as Ss}from"./traffic-BXZ-j7u7.js";import{B as Lt}from"./bundle-avatar-o4aWU1WK.js";import{u as Cs}from"./use-mobile-DwzRjjku.js";import"./lottie-web-jYmAQWuC.js";import"./vendor-arcblock-CwufDgLV.js";import"./useLocalStorage-CaPDqrQ7.js";import"./index-8eXqqyHQ.js";import"./confirm-CYOuqhW9.js";import"./PlayArrow-BqVYRyLK.js";import"./get-safe-url-D5KSEAKZ.js";import"./session-BGdAM8zS.js";import"./InfoOutlined-BVWbftGI.js";import"./dot-4jhL56kz.js";import"./useAsync-C62uE2pS.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-CtTQsfXN.js";import"./index-DEZojGsm.js";import"./CheckCircle-DUJmWceY.js";import"./base32-DUSifB4M.js";import"./iframe-DFg8oeD0.js";import"./LaunchOutlined-C1x4Og4u.js";import"./ChevronLeft-BBJJJhVi.js";import"./ChevronRight-BU9I7WD4.js";import"./index-B2NkqENf.js";import"./base-chart-CoApVzod.js";import"./index-w4f-mlFt.js";import"./vendor-mui-x-1nqAyytV.js";import"./AdapterDayjs-BRnJ9bMs.js";var Ue={exports:{}},He={exports:{}},Ve={exports:{}};(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s;function s(r){return r==null}n.exports=t.default,n.exports.default=t.default})(Ve,Ve.exports);var ws=Ve.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=p;var s=o(es),r=o(ws);function o(h){return h&&h.__esModule?h:{default:h}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,y=/^[-+]?[0-9]+$/;function p(h,i){(0,s.default)(h),i=i||{};var O=i.allow_leading_zeroes===!1?l:y,A=!i.hasOwnProperty("min")||(0,r.default)(i.min)||h>=i.min,R=!i.hasOwnProperty("max")||(0,r.default)(i.max)||h<=i.max,S=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||h<i.lt,D=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||h>i.gt;return O.test(h)&&A&&R&&S&&D}n.exports=t.default,n.exports.default=t.default})(He,He.exports);var Ts=He.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var s=r(Ts);function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,s.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=t.default,n.exports.default=t.default})(Ue,Ue.exports);var Rs=Ue.exports;const Ns=Ut(Rs),Fe={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Es(){var N,E,P;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(N=t==null?void 0:t.meta)==null?void 0:N.did,y=Object.assign({...Fe},((P=(E=t==null?void 0:t.settings)==null?void 0:E.notification)==null?void 0:P.email)||{}),{handleSubmit:p,control:h,formState:i,watch:O,reset:A}=It({defaultValues:St(y,Object.keys(Fe))}),R=Te({testReceiver:"",testReceiverError:""}),S=O("enabled"),D=V(async(a,m,$=!0)=>{var U,oe;try{const{blocklet:le}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),pe=Object.assign({...Fe},((oe=(U=le==null?void 0:le.settings)==null?void 0:U.notification)==null?void 0:oe.email)||{});A(pe),$&&q.success(s("oauth.saveSuccess"))}catch(le){if($)q.error(le.message||s("oauth.saveFailed"));else throw le}}),Y=V(async(a,m,$)=>{try{i.isDirty&&await D(a,m,!1),await n.sendEmail({input:{did:l,receiver:$,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),q.success(s("notification.email.testSuccess"))}catch(U){q.error(U.message||s("notification.email.testfailed"))}}),z=V((a,m)=>{R.testReceiver="",R.testReceiverError="",r.open({title:s("notification.email.testSendEmail"),content:()=>e.jsx(T,{sx:{width:"300px"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.email.inputTestReceiver"),value:R.testReceiver,onChange:$=>{R.testReceiver=$.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm($){var oe;const U=(oe=R.testReceiver)==null?void 0:oe.trim();if(!U){R.testReceiverError=s("notification.email.receiverRequired");return}if(!ke(U)){R.testReceiverError=s("notification.email.receiverInvalid");return}R.testReceiverError="",await Y(a,m,U),$()}})}),B=V(a=>{const m=a==null?void 0:a.trim();return m?ke(m)?!0:s("notification.email.fromInvalid"):s("notification.email.fromRequired")}),_=V(a=>{const m=a==null?void 0:a.trim();return m?$e(m,{require_host:!1,protocols:[]})?!0:s("notification.email.hostInvalid"):s("notification.email.hostRequired")}),M=V(a=>a?Ns(a)?!0:s("notification.email.portInvalid"):s("notification.email.portRequired")),J=V(a=>a!=null&&a.trim()?!0:s("notification.email.userRequired")),ie=V(a=>a!=null&&a.trim()?!0:s("notification.email.passwordRequired")),c=V(a=>a!=null&&a.trim()&&!$e(a,{protocols:["http","https"],require_protocol:!0})?s("notification.email.linkInvalid"):!0),g=V(a=>a!=null&&a.trim()&&!ke(a)?s("notification.email.emailInvalid"):!0),j=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(Is,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.email.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:a})=>e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a})})})}),e.jsx(ee,{title:s("notification.email.from"),children:e.jsx(Q,{name:"from",control:h,rules:{validate:S?B:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,label:s("notification.email.from"),error:!!i.errors[a.name],helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.host"),children:e.jsx(Q,{name:"host",control:h,rules:{validate:S?_:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.host"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.port"),children:e.jsx(Q,{name:"port",control:h,rules:{validate:S?M:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:s("notification.email.port"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.user"),children:e.jsx(Q,{name:"user",control:h,rules:{validate:S?J:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.user"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.password"),children:e.jsx(Q,{name:"password",control:h,rules:{validate:S?ie:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:s("notification.email.password"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.secure"),children:e.jsx(Q,{name:"secure",control:h,rules:{validate:j},render:({field:a})=>e.jsx(G,{fullWidth:!0,children:e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a,disabled:!S})})})})}),e.jsxs(us,{children:[e.jsxs(ps,{expandIcon:e.jsx(fs,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[s("notification.email.signature"),e.jsx(xt,{title:s("notification.email.signatureTooltip"),children:e.jsx(ts,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(ms,{children:[e.jsx(ee,{title:s("notification.email.companyName"),children:e.jsx(Q,{name:"companyName",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyName"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyLink"),children:e.jsx(Q,{name:"companyLink",control:h,rules:{validate:S?c:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyLink"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyAddress"),children:e.jsx(Q,{name:"companyAddress",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyAddress"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.supportEmail"),children:e.jsx(Q,{name:"supportEmail",control:h,rules:{validate:S?g:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:s("notification.email.supportEmail"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})})]})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const Is=ue(ht)``,Be={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function Os(){var M,J,ie;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(M=t==null?void 0:t.meta)==null?void 0:M.did,y=Object.assign({...Be},((ie=(J=t==null?void 0:t.settings)==null?void 0:J.notification)==null?void 0:ie.pushKit)||{}),{handleSubmit:p,control:h,formState:i,watch:O,reset:A}=It({defaultValues:St(y,Object.keys(Be))}),R=Te({testReceiver:"",testReceiverError:""}),S=O("enabled"),D=V(async(c,g,j=!0)=>{var N,E;try{const{blocklet:P}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:c})}}),a=Object.assign({...Be},((E=(N=P==null?void 0:P.settings)==null?void 0:N.notification)==null?void 0:E.pushKit)||{});A(a),j&&q.success(s("oauth.saveSuccess"))}catch(P){if(j)q.error(P.message||s("oauth.saveFailed"));else throw P}}),Y=V(async(c,g)=>{var j,N,E;try{i.isDirty&&await D(c,g,!1);const P=(j=((t==null?void 0:t.configs)||[]).find($=>$.key==="BLOCKLET_APP_URL"))==null?void 0:j.value,a=Xt(Qt(P,W.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:(N=t==null?void 0:t.meta)==null?void 0:N.version,t:new Date((t==null?void 0:t.updatedAt)||0).getTime()}),m={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:t==null?void 0:t.appDid,fullName:(E=t==null?void 0:t.meta)==null?void 0:E.title,avatar:a}}}};await n.sendPush({input:{did:l,receiver:R.testReceiver,notification:JSON.stringify(m)}}),q.success(s("notification.pushKit.testSuccess"))}catch(P){q.error(P.message||s("notification.pushKit.testfailed"))}}),z=V((c,g)=>{R.testReceiverError="",r.open({title:s("notification.pushKit.testSend"),content:()=>e.jsx(T,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.pushKit.inputTestReceiver"),value:R.testReceiver,onChange:j=>{R.testReceiver=j.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm(j){var E;if(!((E=R.testReceiver)==null?void 0:E.trim())){R.testReceiverError=s("notification.pushKit.receiverRequired");return}R.testReceiverError="",await Y(c,g),j()}})}),B=V(c=>{const g=c==null?void 0:c.trim();return g?$e(g)?!0:s("notification.pushKit.endpointInvalid"):s("notification.pushKit.endpointRequired")}),_=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(As,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.pushKit.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:c})=>e.jsx(ge,{control:e.jsx(We,{checked:c.value,...c})})})}),e.jsx(ee,{title:s("notification.pushKit.endpoint"),children:e.jsx(Q,{name:"endpoint",control:h,rules:{validate:S?B:_},render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",required:!0,label:s("notification.pushKit.endpoint"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})}),e.jsxs(ee,{title:s("notification.pushKit.customOptions"),children:[e.jsx(Q,{name:"did",control:h,render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.did"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}}),e.jsx(Q,{name:"pushPath",control:h,render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.pushPath"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const As=ue(ht)``,ft=[{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Email"}),value:"email"},{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Push Kit"}),value:"pushKit"}];function Ds(){const[n,t]=C.useState(ft[0].value),{locale:s}=C.useContext(ss),r=ce(()=>({email:e.jsx(Es,{}),pushKit:e.jsx(Os,{})}),[s]),o=C.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(T,{children:[e.jsx(wt,{tabs:ft,current:n,onChange:t}),e.jsx(T,{style:o,children:r[n]})]})}const Pt=C.createContext({}),{Provider:Ls,Consumer:si}=Pt;function Ps({children:n,blocklet:t=""}){const{api:s,inService:r,ws:{useSubscription:o}}=Ze(),[l,y]=C.useState([]),[p,h]=C.useState({total:0,pageSize:20,pageCount:0,page:1}),i=ce(()=>{var c;return(c=t.meta)==null?void 0:c.did},[t]),[O,A]=C.useState([]),[R,S]=C.useState({}),D=ce(()=>l.length?new Set(l.map(c=>c.id)):new Set,[l]),Y=async({page:c=1,pageSize:g=20,...j}={})=>{if(!i)return[];try{const N={paging:{page:c,pageSize:g},...j,teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0},{dids:E,...P}=N;let a="";E&&E.includes("system")&&(a="system");const m=E?E.filter(oe=>oe!=="system"):[],$={...P,source:a,componentDids:m},U=await s.getNotificationSendLog({input:$});return S($),y(U.list),h(U.paging),U.list}catch(N){return q.error(N.message),[]}},z=async()=>{const c=await s.getNotificationComponents({input:{teamDid:i}});A(c.componentDids)},B=C.useCallback(c=>{const g=t.children.find(j=>{var N;return((N=j.meta)==null?void 0:N.did)===c});if(g)return g.ancestors=[t],g},[t]),_=async({notificationId:c,receivers:g,channels:j,...N})=>{await s.resendNotification({input:{teamDid:i,notificationId:c,receivers:g,channels:j.map(E=>E==="wallet"?W.NOTIFICATION_SEND_CHANNEL.WALLET:E==="pushKit"?W.NOTIFICATION_SEND_CHANNEL.PUSH:E),...N}})},M=C.useCallback(async c=>(await s.getUser({input:{teamDid:i,user:{did:c}}})).user,[s,i]),J=C.useCallback(async({page:c=1,pageSize:g=20,...j}={})=>{try{const N={paging:{page:c,pageSize:g},...j,userName:j.searchText||"",teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0};return await s.getReceivers({input:N})}catch(N){throw q.error(N.message),N}},[s,i]);C.useEffect(()=>{i&&z()},[i]),o(W.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,c=>{D.has(c.notificationId)&&Y(R)},[D,R]),o(W.EVENTS.NOTIFICATION_BLOCKLET_CREATE,c=>{D.has(c.id)||Y(R)},[D,R]);const ie={fetch:Y,data:l,paging:p,blocklet:t,getComponent:B,resendNotification:_,getUser:M,componentDids:O,getReceivers:J,inService:r,teamDid:i};return e.jsx(Ls,{value:{notificationRecords:ie},children:n})}function tt(){const{notificationRecords:n}=C.useContext(Pt);return n}Ne.propTypes={severity:x.oneOf(Object.values(["info","success","error","warning"])).isRequired};const _s={info:"primary",success:"success",error:"error",warning:"warning"};function Ne({severity:n="info"}){return e.jsx(ns,{type:_s[n],children:n})}var st={},ks=Je;Object.defineProperty(st,"__esModule",{value:!0});var _t=st.default=void 0,Fs=ks(Qe()),Bs=e;_t=st.default=(0,Fs.default)((0,Bs.jsx)("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"CheckCircleOutline");var nt={},zs=Je;Object.defineProperty(nt,"__esModule",{value:!0});var kt=nt.default=void 0,Ws=zs(Qe()),Ks=e;kt=nt.default=(0,Ws.default)((0,Ks.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12m8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8"}),"Block");var it={},qs=Je;Object.defineProperty(it,"__esModule",{value:!0});var Ft=it.default=void 0,Ms=qs(Qe()),$s=e;Ft=it.default=(0,Ms.default)((0,$s.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");const Us=(n,t,s="")=>{if(!s||!t)return"";switch(s){case W.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return s}};function Bt(n,t,s={}){const{status:r,updatedAt:o,reason:l="",channel:y="wallet"}=s,p=o?n("notification.sendStatus.sentTime",{date:os(o,t)}):"",h=Us(n,y,l);return r===W.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:p,reason:h}:r===W.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:p}:{status:"pending",title:n("notification.sendStatus.pending"),reason:h,sentTime:p}}const Ge={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ye=["wallet","pushKit","email"],mt=["info","success","error","warning"],zt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.email)==null?void 0:r.enabled},Wt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.pushKit)==null?void 0:r.enabled},Hs=(n,t)=>{const s=fe(t,"extra.notifications.email",!0);return{available:zt(n),enabled:s}},Vs=(n,t)=>{const s=fe(t,"extra.notifications.push",!0);return{available:Wt(n),enabled:s}},Gs=n=>({enabled:fe(n,"extra.notifications.wallet",!0)}),Ys=n=>({enabled:fe(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(t=>{setTimeout(()=>{t()},n*1e3)}),Js=(n,t)=>t==="wallet"||t==="webhook"?[{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:t==="pushKit"||t==="email"?[{channel:t,type:"available",pass:n("notification.sendStatus.reason.available",{channel:t}),fail:n("notification.sendStatus.reason.unavailable",{channel:t})},{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:[],Ie=(n=[])=>{const t=se().startOf("day");return n.filter(s=>se(s.sendAt).isSame(t,"day")).length},Xs=(n,t="")=>{if(t&&Ye.includes(t)){const l=`${t}SendRecord`,y=fe(n,l,[]);return Ie(y)}const s=fe(n,"webhook",{}),r=Object.keys(s??{})??[];if(t&&r.includes(t)){const l=s[t]??[];return Ie(l)}const o={};return Ye.forEach(l=>{const y=`${l}SendRecord`,p=fe(n,y,[]),h=Ie(p);o[l]=h}),r.length>0&&r.forEach(l=>{const y=s[l]??[],p=Ie(y);o[l]=p}),o},Ae=(n,t,s)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[s].splice(t,1),n},De=(n,t)=>{if(!Array.isArray(t))throw new Error("filters must be an array");return t.length?!t.includes(n):!1},Qs=n=>{switch(n){case W.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case W.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case W.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case W.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Kt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:t=!0,showTitle:s=!1,children:r}){const{status:o,title:l="",sentTime:y="",reason:p=""}=n,h=[l,p].filter(Boolean).join(", ");return e.jsx(xt,{title:t?e.jsxs(e.Fragment,{children:[e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:h}),e.jsx("span",{children:y})]}):null,arrow:!0,placement:"top",children:e.jsxs(T,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(T,{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center",children:[e.jsx(T,{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Ge[o],style:{opacity:.15}}),e.jsx(T,{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Ge[o]})]}),e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:s?l:r})]})})}de.propTypes={config:x.object.isRequired,enableTooltip:x.bool,showTitle:x.bool,children:x.node};de.defaultProps={enableTooltip:!0,showTitle:!1,children:null};Se.propTypes={list:x.array.isRequired,label:x.string.isRequired,onDelete:x.func};Se.defaultProps={onDelete:()=>{}};function Se({list:n,label:t,onDelete:s}){const{t:r,locale:o}=re();return e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(ae,{children:[t,": "]}),n.map(l=>{const y=Bt(r,o,{status:l});return e.jsx(Xe,{size:"small",label:e.jsx(T,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(de,{config:y,enableTooltip:!1,children:y.title})}),onDelete:p=>s(p,l)},l)})]})}at.propTypes={filterList:x.array.isRequired,onChange:x.func.isRequired,index:x.number.isRequired,column:x.object.isRequired,filterValues:x.array.isRequired,label:x.string.isRequired,renderLabel:x.func.isRequired};function at({filterList:n,onChange:t,index:s,column:r,filterValues:o,label:l,renderLabel:y}){return e.jsxs(G,{className:"filter-container",children:[e.jsx(gt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(p=>e.jsx(ge,{control:e.jsx(qe,{checked:n[s].indexOf(p.value??p)>-1,onChange:h=>{const i=[...n];h.target.checked?i[s]=[...i[s],p.value??p]:i[s]=i[s].filter(O=>O!==(p.value??p)),t(i[s],s,r)},name:p.value??p}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:y(p)})},p.value??p))})]})}function ze(n){return e.jsx(at,{...n,renderLabel:t=>e.jsx(de,{enableTooltip:!1,config:{status:t.status},children:t.label})})}ve.propTypes={status:x.number.isRequired,updatedAt:x.string.isRequired,reason:x.string,channel:x.string,onResend:x.func};function ve({status:n,updatedAt:t,reason:s="",channel:r="wallet",onResend:o}){const{t:l,locale:y}=re(),p=Bt(l,y,{status:n,updatedAt:t,reason:s,channel:r});return e.jsxs(T,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(de,{config:p,showTitle:!0}),p.status!=="success"&&e.jsx(Le,{className:"resend-btn",size:"small",startIcon:e.jsx(et,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}rt.propTypes={value:x.array.isRequired,onChange:x.func};function rt({value:n,onChange:t}){const{locale:s}=re(),r=se().toDate(),[o,l]=C.useState(null),y=C.useCallback(i=>{l(o?null:i.currentTarget)},[o]),p=!!o,h=C.useCallback(i=>{if(!i.startDate||!i.endDate){q.error("Please select a date range");return}if(se(i.startDate).isAfter(i.endDate)||!se(i.startDate).isValid()||!se(i.endDate).isValid()){q.error("Invalid date range");return}t([i.startDate,i.endDate]),l(null)},[t]);return e.jsxs("div",{children:[e.jsx(ae,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:0,children:e.jsxs(Le,{onClick:y,variant:"outlined",size:"small",color:"inherit",children:[pt(n[0],s)," - ",pt(n[1],s)]})}),e.jsx(Me,{open:p,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(ys,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:y,definedRanges:Ss(r),onChange:h})})]})}ot.propTypes={itemComponent:x.elementType.isRequired};function ot({itemComponent:n,...t}){var o;const{t:s}=re();return!((o=t==null?void 0:t.filterList)!=null&&o.filter(l=>l.length).length)?null:e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsx("div",{className:"toolbar-filter-title",children:s("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(is.TableFilterList,{...t,ItemComponent:n})})]})}function Pe({label:n,onDelete:t,canDelete:s=()=>!0,...r}){const o=t&&typeof t=="function"?t:void 0;let l=!0;return s&&typeof s=="function"&&(l=s({label:n,...r})),e.jsx(Xe,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}Pe.propTypes={label:x.string.isRequired,onDelete:x.func,canDelete:x.func};Pe.defaultProps={canDelete:()=>!0};const Zs=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];lt.propTypes={loading:x.bool,onCancel:x.func,onConfirm:x.func};lt.defaultProps={loading:!1,onCancel:()=>{},onConfirm:()=>{}};function lt({loading:n=!1,onCancel:t,onConfirm:s}){const{t:r}=re(),[o,l]=C.useState(Zs),[y,p]=C.useState(!0),h=(O,A)=>{A.checked=O.target.checked;const R=o.map(S=>({...S,checked:S.value===A.value?A.checked:S.checked}));l(R)},i=O=>{O.stopPropagation(),s({channels:o.filter(A=>A.checked).map(A=>A.value),isResendFailedOnly:y})};return e.jsxs(T,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ae,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(T,{className:"choose-channel",children:e.jsxs(G,{component:"fieldset",variant:"standard",children:[e.jsx(gt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(O=>e.jsx(ge,{control:e.jsx(qe,{checked:O.checked,onChange:A=>h(A,O),name:O.value}),label:O.label},O.value))})]})}),e.jsx(T,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(ge,{control:e.jsx(qe,{checked:y,onChange:O=>p(O.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(T,{display:"flex",justifyContent:"flex-end",gap:1,className:"resend-config-footer-tip",children:[e.jsx(Le,{onClick:O=>{O.stopPropagation(),t()},color:"inherit",children:r("common.cancel")}),e.jsxs(Le,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(bt,{size:16}),r("common.confirm")]})]})]})}qt.propTypes={notificationId:x.string.isRequired,handleResend:x.func,resending:x.bool};function qt({notificationId:n,handleResend:t,resending:s=!1}){const{t:r,locale:o}=re(),l=jt(),y=C.useMemo(()=>vt(l,Kt()),[l]),{getReceivers:p,inService:h,teamDid:i,getUser:O,blocklet:A}=tt(),[R,S]=C.useState(!1),[D,Y]=C.useState([]),z=Te({anchorEl:null,position:null}),B=Te({anchorEl:null,position:null}),[_,M]=C.useState(null),[J,ie]=C.useState({total:0,pageSize:10,pageCount:0,page:1}),[c,g]=C.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[se().subtract(1,"month").startOf("day").toDate(),se().endOf("day").toDate()]}),[j,N]=C.useState([]),E=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],P=async()=>{if(!R&&n)try{S(!0);const d=await p({notificationId:n,...c}),u=d.list.map(f=>({...f,receiverUser:{...f.receiverUser,avatar:Dt(f.receiverUser.avatar,i,h)}}));Y(u),ie(d.paging),S(!1)}catch(d){q.error(d.message),S(!1)}};C.useEffect(()=>{P()},[c]);const a=d=>{d.stopPropagation();const u=d.currentTarget;B.anchorEl=u;const f=u.getBoundingClientRect();B.position={top:f.top+window.scrollY,left:f.left+window.scrollX}},m=d=>d.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(me,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(et,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:a,children:r("notification.resend")})}):null,$={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:J.page-1,rowsPerPage:J.pageSize,count:J.total,searchText:c.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:j,onRowSelectionChange:(d,u)=>{N(u.map(f=>f.dataIndex))},customToolbarSelect:m},U=({page:d,rowsPerPage:u,searchText:f,filterList:L})=>{const[,K=[],Z=[],X=[]]=L;c.pageSize!==u?g(H=>({...H,pageSize:u,page:1})):c.page!==d+1?g(H=>({...H,page:d+1})):c.searchText!==f?g(H=>({...H,searchText:f,page:1})):ye(K,c.walletSendStatus)?ye(Z,c.pushKitSendStatus)?ye(X,c.emailSendStatus)||g(H=>({...H,emailSendStatus:X,page:1})):g(H=>({...H,pushKitSendStatus:Z,page:1})):g(H=>({...H,walletSendStatus:K,page:1}))},oe=C.useCallback(async(d,u)=>{if(!u)return!1;const f=await O(u);return f?d==="wallet"?Gs(f):d==="email"?Hs(A,f):d==="pushKit"?Vs(A,f):d==="webhook"?Ys(f):!0:!1},[O,A]),le=C.useCallback(d=>Js(r,d),[r]),pe=()=>{z.anchorEl=null,z.position=null,M(null)},be=()=>{B.anchorEl=null,B.position=null},je=async(d,u,f=!0,L="")=>{if(!(!u.length||!d.length))try{t(d,u,f,L),B.anchorEl||(await Ee(.5),pe())}catch(K){console.error("handleResend error",{error:K})}},v=async({channels:d,isResendFailedOnly:u})=>{const f=j.map(L=>D[L].receiver);await je(d,f,u),await Ee(.5),be(),N([])},b=async(d,u=[],f=!0)=>{try{await je(["webhook"],[d.receiver],f,u)}catch(L){q.error(L.response?L.response.statusText:L.message)}},w=async(d,u,f,L=[],K=!0)=>{if(d.stopPropagation(),Xs(u,f)>=4){q.warning(r("notification.resendLimit"));return}if(!Ye.includes(f)){await b(u,L,K);return}if(d){const X=d.currentTarget,H=X.getBoundingClientRect();z.anchorEl=X,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}M({channel:f});try{const X=await oe(f,u.receiver);await Ee(1),M({channel:f,result:X}),(typeof X=="boolean"&&X||Zt(X)&&Object.values(X).every(H=>!!H))&&(await t([f],[u.receiver],K),B.anchorEl||(await Ee(.5),pe()))}catch(X){q.error(X.message)}},I=d=>{g(u=>({...u,dateRange:d,page:1}))},k=(d,u,f,L)=>{d.stopPropagation();const K=f.filter(Z=>Z!==u);g(Z=>({...Z,[L]:K,page:1}))},F=ce(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:d=>{const{receiverUser:u,receiver:f}=D[d];return u?e.jsxs(T,{"data-cy":`member-name-${u.fullName}`,display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start",children:[e.jsx(Tt,{src:`${u.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:f,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Re,{children:u.fullName})]},f):e.jsx(vs,{size:14,responsive:!1,compact:!0,copyable:!1,did:f})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:c.walletSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Wallet",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[1].options.filterList,"walletSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Wallet",filterList:d,onChange:u,index:f,column:L,filterValues:E})},customBodyRenderLite:d=>{const{walletSendStatus:u,walletSendAt:f,walletSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"wallet",onResend:K=>w(K,D[d],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{pushKitSendStatus:u,pushKitSendAt:f,pushKitSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"pushkit",onResend:K=>w(K,D[d],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:c.pushKitSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Push Kit",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[2].options.filterList,"pushKitSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Push Kit",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{emailSendStatus:u,emailSendAt:f,emailSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"email",onResend:K=>w(K,D[d],"email",[],!1)})},filter:!0,filterType:"custom",filterList:c.emailSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Email",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[3].options.filterList,"emailSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Email",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{webhook:u}=D[d];if(!u)return null;const f=Object.entries(u)[0];if(!f)return null;const[L,K]=f,Z=K[0];return e.jsx(T,{display:"flex",flexDirection:"column",gap:1,children:e.jsxs(T,{className:"webhook-item",fontSize:12,children:[e.jsx(Re,{maxLength:30,children:L},L),e.jsx(ve,{status:Z.status,updatedAt:Z.sendAt,reason:Z.failedReason,channel:"webhook",onResend:X=>w(X,D[d],"webhook",[L],!1)})]},L)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:d=>{const{createdAt:u}=D[d];return e.jsx(At,{value:u,locale:o,shouldUpdate:!0})}}}],[D,o,c,r]),ne=[e.jsx(rt,{value:c.dateRange,onChange:I},"date-picker"),e.jsx(me,{variant:"contained",size:"small",color:"primary",loading:R,startIcon:e.jsx(Ft,{}),onClick:()=>P(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(T,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(tn,{children:e.jsxs(yt,{theme:y,children:[e.jsx(Rt,{className:"receivers-table",locale:o,loading:R,columns:F,data:D,onChange:U,options:$,customButtons:ne,components:{TableFilterList:d=>e.jsx(ot,{...d,itemComponent:u=>e.jsx(Pe,{...u,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Me,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:pe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(sn,{children:[e.jsxs(ae,{variant:"body1",component:"div",className:"check-title",children:[_==null?void 0:_.channel," Checking"]}),e.jsx(T,{display:"flex",flexDirection:"column",sx:{gap:"4px"},children:le(_==null?void 0:_.channel).map(d=>{var K,Z;const{type:u,pass:f,fail:L}=d;return!(_!=null&&_.result)||(K=_==null?void 0:_.result)!=null&&K[u]?e.jsxs(ae,{variant:"body1",component:"div",className:"check-item",display:"flex",alignItems:"center",sx:{gap:"4px",color:(Z=_==null?void 0:_.result)!=null&&Z[u]?Oe.success.main:"inherit"},children:[_!=null&&_.result?e.jsx(_t,{}):e.jsx(bt,{size:12,sx:{color:Oe.primary.main}}),e.jsx("span",{children:f})]},u):e.jsxs(ae,{variant:"body1",component:"div",display:"flex",alignItems:"center",className:"check-item",sx:{gap:"4px",color:Oe.error.main},children:[e.jsx(kt,{}),e.jsx("span",{children:L})]},u)})})]})}),B.anchorEl&&e.jsx(Me,{open:!!B.anchorEl,anchorReference:"anchorPosition",anchorPosition:B.position,onClose:be,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(lt,{loading:s,onCancel:be,onConfirm:v})})]})})})}const en=C.memo(qt),tn=ue.div`
|
|
1
|
+
import{g as Ut,r as C}from"./vendor-react-DEoibe3W.js";import{ah as ue,al as ht,j as e,aa as T,O as te,bs as ge,bt as We,bo as G,ad as xt,H as x,a9 as Je,T as ae,E as Xe,bz as gt,bQ as Ke,bR as qe,y as Le,b6 as Me,ab as bt,bI as jt,Y as vt,cn as yt,m as Ht,as as dt,br as Vt,bn as Gt,q as ut,bX as Yt,I as Jt}from"./vendor-mui-core-Bq8gXTan.js";import{J as St,z as Xt,A as Qt,e as fe,aB as ye,C as Zt}from"./vendor-utils-BfZ4tlod.js";import{y as es,a as re,ab as Ct,a3 as q,X as ke,c1 as ts,B as me,k as W,bb as ss,ax as wt,bg as ns,r as Qe,c2 as is,a2 as Tt,ac as Rt,bB as Oe,ar as Nt,$ as as,bI as rs}from"./vendor-ux-did-connect-pzpsrvqx.js";import{D as Ze,G as Et,aC as It,aD as Q,y as se,n as os,K as pt}from"./index-CMYHZyLG.js";import{a as Te,u as V,b as ce}from"./vendor-hooks-DqdmWCmo.js";import{a as et,b as ls}from"./dashboard-Cvfy6NEE.js";import{f as $e,i as cs,d as ds}from"./use-blocklet-logo-CWdlYyrq.js";import{A as us,a as ps,d as fs,b as ms}from"./collapse-DAaiuAEY.js";import{S as ee}from"./section-BDMQAX_r.js";import{S as Re}from"./shorten-label-BQvbtscf.js";import{I as Ot}from"./index-DPIWnhb5.js";import{R as At,A as hs,S as xs,a as gs,b as bs,B as js}from"./list-Dk6LlvZw.js";import{W as vs}from"./did-address-NnOD1W_A.js";import{p as Dt}from"./util-BQAJqeb4.js";import{D as ys,g as Ss}from"./traffic-BXZ-j7u7.js";import{B as Lt}from"./bundle-avatar-o4aWU1WK.js";import{u as Cs}from"./use-mobile-CtTQsfXN.js";import"./lottie-web-jYmAQWuC.js";import"./vendor-arcblock-CwufDgLV.js";import"./useLocalStorage-CaPDqrQ7.js";import"./index-8eXqqyHQ.js";import"./confirm-CYOuqhW9.js";import"./PlayArrow-BqVYRyLK.js";import"./get-safe-url-B0-S5PGZ.js";import"./session-BGdAM8zS.js";import"./InfoOutlined-BVWbftGI.js";import"./dot-4jhL56kz.js";import"./useAsync-C62uE2pS.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-DwzRjjku.js";import"./index-DEZojGsm.js";import"./CheckCircle-DUJmWceY.js";import"./base32-DUSifB4M.js";import"./iframe-DFg8oeD0.js";import"./LaunchOutlined-C1x4Og4u.js";import"./ChevronLeft-BBJJJhVi.js";import"./ChevronRight-BU9I7WD4.js";import"./index-B2NkqENf.js";import"./base-chart-CoApVzod.js";import"./index-w4f-mlFt.js";import"./vendor-mui-x-1nqAyytV.js";import"./AdapterDayjs-BRnJ9bMs.js";var Ue={exports:{}},He={exports:{}},Ve={exports:{}};(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s;function s(r){return r==null}n.exports=t.default,n.exports.default=t.default})(Ve,Ve.exports);var ws=Ve.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=p;var s=o(es),r=o(ws);function o(h){return h&&h.__esModule?h:{default:h}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,y=/^[-+]?[0-9]+$/;function p(h,i){(0,s.default)(h),i=i||{};var O=i.allow_leading_zeroes===!1?l:y,A=!i.hasOwnProperty("min")||(0,r.default)(i.min)||h>=i.min,R=!i.hasOwnProperty("max")||(0,r.default)(i.max)||h<=i.max,S=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||h<i.lt,D=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||h>i.gt;return O.test(h)&&A&&R&&S&&D}n.exports=t.default,n.exports.default=t.default})(He,He.exports);var Ts=He.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var s=r(Ts);function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,s.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=t.default,n.exports.default=t.default})(Ue,Ue.exports);var Rs=Ue.exports;const Ns=Ut(Rs),Fe={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Es(){var N,E,P;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(N=t==null?void 0:t.meta)==null?void 0:N.did,y=Object.assign({...Fe},((P=(E=t==null?void 0:t.settings)==null?void 0:E.notification)==null?void 0:P.email)||{}),{handleSubmit:p,control:h,formState:i,watch:O,reset:A}=It({defaultValues:St(y,Object.keys(Fe))}),R=Te({testReceiver:"",testReceiverError:""}),S=O("enabled"),D=V(async(a,m,$=!0)=>{var U,oe;try{const{blocklet:le}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),pe=Object.assign({...Fe},((oe=(U=le==null?void 0:le.settings)==null?void 0:U.notification)==null?void 0:oe.email)||{});A(pe),$&&q.success(s("oauth.saveSuccess"))}catch(le){if($)q.error(le.message||s("oauth.saveFailed"));else throw le}}),Y=V(async(a,m,$)=>{try{i.isDirty&&await D(a,m,!1),await n.sendEmail({input:{did:l,receiver:$,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),q.success(s("notification.email.testSuccess"))}catch(U){q.error(U.message||s("notification.email.testfailed"))}}),z=V((a,m)=>{R.testReceiver="",R.testReceiverError="",r.open({title:s("notification.email.testSendEmail"),content:()=>e.jsx(T,{sx:{width:"300px"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.email.inputTestReceiver"),value:R.testReceiver,onChange:$=>{R.testReceiver=$.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm($){var oe;const U=(oe=R.testReceiver)==null?void 0:oe.trim();if(!U){R.testReceiverError=s("notification.email.receiverRequired");return}if(!ke(U)){R.testReceiverError=s("notification.email.receiverInvalid");return}R.testReceiverError="",await Y(a,m,U),$()}})}),B=V(a=>{const m=a==null?void 0:a.trim();return m?ke(m)?!0:s("notification.email.fromInvalid"):s("notification.email.fromRequired")}),_=V(a=>{const m=a==null?void 0:a.trim();return m?$e(m,{require_host:!1,protocols:[]})?!0:s("notification.email.hostInvalid"):s("notification.email.hostRequired")}),M=V(a=>a?Ns(a)?!0:s("notification.email.portInvalid"):s("notification.email.portRequired")),J=V(a=>a!=null&&a.trim()?!0:s("notification.email.userRequired")),ie=V(a=>a!=null&&a.trim()?!0:s("notification.email.passwordRequired")),c=V(a=>a!=null&&a.trim()&&!$e(a,{protocols:["http","https"],require_protocol:!0})?s("notification.email.linkInvalid"):!0),g=V(a=>a!=null&&a.trim()&&!ke(a)?s("notification.email.emailInvalid"):!0),j=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(Is,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.email.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:a})=>e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a})})})}),e.jsx(ee,{title:s("notification.email.from"),children:e.jsx(Q,{name:"from",control:h,rules:{validate:S?B:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,label:s("notification.email.from"),error:!!i.errors[a.name],helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.host"),children:e.jsx(Q,{name:"host",control:h,rules:{validate:S?_:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.host"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.port"),children:e.jsx(Q,{name:"port",control:h,rules:{validate:S?M:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:s("notification.email.port"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.user"),children:e.jsx(Q,{name:"user",control:h,rules:{validate:S?J:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.user"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.password"),children:e.jsx(Q,{name:"password",control:h,rules:{validate:S?ie:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:s("notification.email.password"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.secure"),children:e.jsx(Q,{name:"secure",control:h,rules:{validate:j},render:({field:a})=>e.jsx(G,{fullWidth:!0,children:e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a,disabled:!S})})})})}),e.jsxs(us,{children:[e.jsxs(ps,{expandIcon:e.jsx(fs,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[s("notification.email.signature"),e.jsx(xt,{title:s("notification.email.signatureTooltip"),children:e.jsx(ts,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(ms,{children:[e.jsx(ee,{title:s("notification.email.companyName"),children:e.jsx(Q,{name:"companyName",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyName"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyLink"),children:e.jsx(Q,{name:"companyLink",control:h,rules:{validate:S?c:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyLink"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyAddress"),children:e.jsx(Q,{name:"companyAddress",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyAddress"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.supportEmail"),children:e.jsx(Q,{name:"supportEmail",control:h,rules:{validate:S?g:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:s("notification.email.supportEmail"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})})]})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const Is=ue(ht)``,Be={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function Os(){var M,J,ie;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(M=t==null?void 0:t.meta)==null?void 0:M.did,y=Object.assign({...Be},((ie=(J=t==null?void 0:t.settings)==null?void 0:J.notification)==null?void 0:ie.pushKit)||{}),{handleSubmit:p,control:h,formState:i,watch:O,reset:A}=It({defaultValues:St(y,Object.keys(Be))}),R=Te({testReceiver:"",testReceiverError:""}),S=O("enabled"),D=V(async(c,g,j=!0)=>{var N,E;try{const{blocklet:P}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:c})}}),a=Object.assign({...Be},((E=(N=P==null?void 0:P.settings)==null?void 0:N.notification)==null?void 0:E.pushKit)||{});A(a),j&&q.success(s("oauth.saveSuccess"))}catch(P){if(j)q.error(P.message||s("oauth.saveFailed"));else throw P}}),Y=V(async(c,g)=>{var j,N,E;try{i.isDirty&&await D(c,g,!1);const P=(j=((t==null?void 0:t.configs)||[]).find($=>$.key==="BLOCKLET_APP_URL"))==null?void 0:j.value,a=Xt(Qt(P,W.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:(N=t==null?void 0:t.meta)==null?void 0:N.version,t:new Date((t==null?void 0:t.updatedAt)||0).getTime()}),m={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:t==null?void 0:t.appDid,fullName:(E=t==null?void 0:t.meta)==null?void 0:E.title,avatar:a}}}};await n.sendPush({input:{did:l,receiver:R.testReceiver,notification:JSON.stringify(m)}}),q.success(s("notification.pushKit.testSuccess"))}catch(P){q.error(P.message||s("notification.pushKit.testfailed"))}}),z=V((c,g)=>{R.testReceiverError="",r.open({title:s("notification.pushKit.testSend"),content:()=>e.jsx(T,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.pushKit.inputTestReceiver"),value:R.testReceiver,onChange:j=>{R.testReceiver=j.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm(j){var E;if(!((E=R.testReceiver)==null?void 0:E.trim())){R.testReceiverError=s("notification.pushKit.receiverRequired");return}R.testReceiverError="",await Y(c,g),j()}})}),B=V(c=>{const g=c==null?void 0:c.trim();return g?$e(g)?!0:s("notification.pushKit.endpointInvalid"):s("notification.pushKit.endpointRequired")}),_=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(As,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.pushKit.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:c})=>e.jsx(ge,{control:e.jsx(We,{checked:c.value,...c})})})}),e.jsx(ee,{title:s("notification.pushKit.endpoint"),children:e.jsx(Q,{name:"endpoint",control:h,rules:{validate:S?B:_},render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",required:!0,label:s("notification.pushKit.endpoint"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})}),e.jsxs(ee,{title:s("notification.pushKit.customOptions"),children:[e.jsx(Q,{name:"did",control:h,render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.did"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}}),e.jsx(Q,{name:"pushPath",control:h,render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.pushPath"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const As=ue(ht)``,ft=[{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Email"}),value:"email"},{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Push Kit"}),value:"pushKit"}];function Ds(){const[n,t]=C.useState(ft[0].value),{locale:s}=C.useContext(ss),r=ce(()=>({email:e.jsx(Es,{}),pushKit:e.jsx(Os,{})}),[s]),o=C.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(T,{children:[e.jsx(wt,{tabs:ft,current:n,onChange:t}),e.jsx(T,{style:o,children:r[n]})]})}const Pt=C.createContext({}),{Provider:Ls,Consumer:si}=Pt;function Ps({children:n,blocklet:t=""}){const{api:s,inService:r,ws:{useSubscription:o}}=Ze(),[l,y]=C.useState([]),[p,h]=C.useState({total:0,pageSize:20,pageCount:0,page:1}),i=ce(()=>{var c;return(c=t.meta)==null?void 0:c.did},[t]),[O,A]=C.useState([]),[R,S]=C.useState({}),D=ce(()=>l.length?new Set(l.map(c=>c.id)):new Set,[l]),Y=async({page:c=1,pageSize:g=20,...j}={})=>{if(!i)return[];try{const N={paging:{page:c,pageSize:g},...j,teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0},{dids:E,...P}=N;let a="";E&&E.includes("system")&&(a="system");const m=E?E.filter(oe=>oe!=="system"):[],$={...P,source:a,componentDids:m},U=await s.getNotificationSendLog({input:$});return S($),y(U.list),h(U.paging),U.list}catch(N){return q.error(N.message),[]}},z=async()=>{const c=await s.getNotificationComponents({input:{teamDid:i}});A(c.componentDids)},B=C.useCallback(c=>{const g=t.children.find(j=>{var N;return((N=j.meta)==null?void 0:N.did)===c});if(g)return g.ancestors=[t],g},[t]),_=async({notificationId:c,receivers:g,channels:j,...N})=>{await s.resendNotification({input:{teamDid:i,notificationId:c,receivers:g,channels:j.map(E=>E==="wallet"?W.NOTIFICATION_SEND_CHANNEL.WALLET:E==="pushKit"?W.NOTIFICATION_SEND_CHANNEL.PUSH:E),...N}})},M=C.useCallback(async c=>(await s.getUser({input:{teamDid:i,user:{did:c}}})).user,[s,i]),J=C.useCallback(async({page:c=1,pageSize:g=20,...j}={})=>{try{const N={paging:{page:c,pageSize:g},...j,userName:j.searchText||"",teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0};return await s.getReceivers({input:N})}catch(N){throw q.error(N.message),N}},[s,i]);C.useEffect(()=>{i&&z()},[i]),o(W.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,c=>{D.has(c.notificationId)&&Y(R)},[D,R]),o(W.EVENTS.NOTIFICATION_BLOCKLET_CREATE,c=>{D.has(c.id)||Y(R)},[D,R]);const ie={fetch:Y,data:l,paging:p,blocklet:t,getComponent:B,resendNotification:_,getUser:M,componentDids:O,getReceivers:J,inService:r,teamDid:i};return e.jsx(Ls,{value:{notificationRecords:ie},children:n})}function tt(){const{notificationRecords:n}=C.useContext(Pt);return n}Ne.propTypes={severity:x.oneOf(Object.values(["info","success","error","warning"])).isRequired};const _s={info:"primary",success:"success",error:"error",warning:"warning"};function Ne({severity:n="info"}){return e.jsx(ns,{type:_s[n],children:n})}var st={},ks=Je;Object.defineProperty(st,"__esModule",{value:!0});var _t=st.default=void 0,Fs=ks(Qe()),Bs=e;_t=st.default=(0,Fs.default)((0,Bs.jsx)("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"CheckCircleOutline");var nt={},zs=Je;Object.defineProperty(nt,"__esModule",{value:!0});var kt=nt.default=void 0,Ws=zs(Qe()),Ks=e;kt=nt.default=(0,Ws.default)((0,Ks.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12m8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8"}),"Block");var it={},qs=Je;Object.defineProperty(it,"__esModule",{value:!0});var Ft=it.default=void 0,Ms=qs(Qe()),$s=e;Ft=it.default=(0,Ms.default)((0,$s.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");const Us=(n,t,s="")=>{if(!s||!t)return"";switch(s){case W.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return s}};function Bt(n,t,s={}){const{status:r,updatedAt:o,reason:l="",channel:y="wallet"}=s,p=o?n("notification.sendStatus.sentTime",{date:os(o,t)}):"",h=Us(n,y,l);return r===W.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:p,reason:h}:r===W.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:p}:{status:"pending",title:n("notification.sendStatus.pending"),reason:h,sentTime:p}}const Ge={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ye=["wallet","pushKit","email"],mt=["info","success","error","warning"],zt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.email)==null?void 0:r.enabled},Wt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.pushKit)==null?void 0:r.enabled},Hs=(n,t)=>{const s=fe(t,"extra.notifications.email",!0);return{available:zt(n),enabled:s}},Vs=(n,t)=>{const s=fe(t,"extra.notifications.push",!0);return{available:Wt(n),enabled:s}},Gs=n=>({enabled:fe(n,"extra.notifications.wallet",!0)}),Ys=n=>({enabled:fe(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(t=>{setTimeout(()=>{t()},n*1e3)}),Js=(n,t)=>t==="wallet"||t==="webhook"?[{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:t==="pushKit"||t==="email"?[{channel:t,type:"available",pass:n("notification.sendStatus.reason.available",{channel:t}),fail:n("notification.sendStatus.reason.unavailable",{channel:t})},{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:[],Ie=(n=[])=>{const t=se().startOf("day");return n.filter(s=>se(s.sendAt).isSame(t,"day")).length},Xs=(n,t="")=>{if(t&&Ye.includes(t)){const l=`${t}SendRecord`,y=fe(n,l,[]);return Ie(y)}const s=fe(n,"webhook",{}),r=Object.keys(s??{})??[];if(t&&r.includes(t)){const l=s[t]??[];return Ie(l)}const o={};return Ye.forEach(l=>{const y=`${l}SendRecord`,p=fe(n,y,[]),h=Ie(p);o[l]=h}),r.length>0&&r.forEach(l=>{const y=s[l]??[],p=Ie(y);o[l]=p}),o},Ae=(n,t,s)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[s].splice(t,1),n},De=(n,t)=>{if(!Array.isArray(t))throw new Error("filters must be an array");return t.length?!t.includes(n):!1},Qs=n=>{switch(n){case W.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case W.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case W.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case W.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Kt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:t=!0,showTitle:s=!1,children:r}){const{status:o,title:l="",sentTime:y="",reason:p=""}=n,h=[l,p].filter(Boolean).join(", ");return e.jsx(xt,{title:t?e.jsxs(e.Fragment,{children:[e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:h}),e.jsx("span",{children:y})]}):null,arrow:!0,placement:"top",children:e.jsxs(T,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(T,{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center",children:[e.jsx(T,{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Ge[o],style:{opacity:.15}}),e.jsx(T,{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Ge[o]})]}),e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:s?l:r})]})})}de.propTypes={config:x.object.isRequired,enableTooltip:x.bool,showTitle:x.bool,children:x.node};de.defaultProps={enableTooltip:!0,showTitle:!1,children:null};Se.propTypes={list:x.array.isRequired,label:x.string.isRequired,onDelete:x.func};Se.defaultProps={onDelete:()=>{}};function Se({list:n,label:t,onDelete:s}){const{t:r,locale:o}=re();return e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(ae,{children:[t,": "]}),n.map(l=>{const y=Bt(r,o,{status:l});return e.jsx(Xe,{size:"small",label:e.jsx(T,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(de,{config:y,enableTooltip:!1,children:y.title})}),onDelete:p=>s(p,l)},l)})]})}at.propTypes={filterList:x.array.isRequired,onChange:x.func.isRequired,index:x.number.isRequired,column:x.object.isRequired,filterValues:x.array.isRequired,label:x.string.isRequired,renderLabel:x.func.isRequired};function at({filterList:n,onChange:t,index:s,column:r,filterValues:o,label:l,renderLabel:y}){return e.jsxs(G,{className:"filter-container",children:[e.jsx(gt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(p=>e.jsx(ge,{control:e.jsx(qe,{checked:n[s].indexOf(p.value??p)>-1,onChange:h=>{const i=[...n];h.target.checked?i[s]=[...i[s],p.value??p]:i[s]=i[s].filter(O=>O!==(p.value??p)),t(i[s],s,r)},name:p.value??p}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:y(p)})},p.value??p))})]})}function ze(n){return e.jsx(at,{...n,renderLabel:t=>e.jsx(de,{enableTooltip:!1,config:{status:t.status},children:t.label})})}ve.propTypes={status:x.number.isRequired,updatedAt:x.string.isRequired,reason:x.string,channel:x.string,onResend:x.func};function ve({status:n,updatedAt:t,reason:s="",channel:r="wallet",onResend:o}){const{t:l,locale:y}=re(),p=Bt(l,y,{status:n,updatedAt:t,reason:s,channel:r});return e.jsxs(T,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(de,{config:p,showTitle:!0}),p.status!=="success"&&e.jsx(Le,{className:"resend-btn",size:"small",startIcon:e.jsx(et,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}rt.propTypes={value:x.array.isRequired,onChange:x.func};function rt({value:n,onChange:t}){const{locale:s}=re(),r=se().toDate(),[o,l]=C.useState(null),y=C.useCallback(i=>{l(o?null:i.currentTarget)},[o]),p=!!o,h=C.useCallback(i=>{if(!i.startDate||!i.endDate){q.error("Please select a date range");return}if(se(i.startDate).isAfter(i.endDate)||!se(i.startDate).isValid()||!se(i.endDate).isValid()){q.error("Invalid date range");return}t([i.startDate,i.endDate]),l(null)},[t]);return e.jsxs("div",{children:[e.jsx(ae,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:0,children:e.jsxs(Le,{onClick:y,variant:"outlined",size:"small",color:"inherit",children:[pt(n[0],s)," - ",pt(n[1],s)]})}),e.jsx(Me,{open:p,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(ys,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:y,definedRanges:Ss(r),onChange:h})})]})}ot.propTypes={itemComponent:x.elementType.isRequired};function ot({itemComponent:n,...t}){var o;const{t:s}=re();return!((o=t==null?void 0:t.filterList)!=null&&o.filter(l=>l.length).length)?null:e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsx("div",{className:"toolbar-filter-title",children:s("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(is.TableFilterList,{...t,ItemComponent:n})})]})}function Pe({label:n,onDelete:t,canDelete:s=()=>!0,...r}){const o=t&&typeof t=="function"?t:void 0;let l=!0;return s&&typeof s=="function"&&(l=s({label:n,...r})),e.jsx(Xe,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}Pe.propTypes={label:x.string.isRequired,onDelete:x.func,canDelete:x.func};Pe.defaultProps={canDelete:()=>!0};const Zs=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];lt.propTypes={loading:x.bool,onCancel:x.func,onConfirm:x.func};lt.defaultProps={loading:!1,onCancel:()=>{},onConfirm:()=>{}};function lt({loading:n=!1,onCancel:t,onConfirm:s}){const{t:r}=re(),[o,l]=C.useState(Zs),[y,p]=C.useState(!0),h=(O,A)=>{A.checked=O.target.checked;const R=o.map(S=>({...S,checked:S.value===A.value?A.checked:S.checked}));l(R)},i=O=>{O.stopPropagation(),s({channels:o.filter(A=>A.checked).map(A=>A.value),isResendFailedOnly:y})};return e.jsxs(T,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ae,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(T,{className:"choose-channel",children:e.jsxs(G,{component:"fieldset",variant:"standard",children:[e.jsx(gt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(O=>e.jsx(ge,{control:e.jsx(qe,{checked:O.checked,onChange:A=>h(A,O),name:O.value}),label:O.label},O.value))})]})}),e.jsx(T,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(ge,{control:e.jsx(qe,{checked:y,onChange:O=>p(O.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(T,{display:"flex",justifyContent:"flex-end",gap:1,className:"resend-config-footer-tip",children:[e.jsx(Le,{onClick:O=>{O.stopPropagation(),t()},color:"inherit",children:r("common.cancel")}),e.jsxs(Le,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(bt,{size:16}),r("common.confirm")]})]})]})}qt.propTypes={notificationId:x.string.isRequired,handleResend:x.func,resending:x.bool};function qt({notificationId:n,handleResend:t,resending:s=!1}){const{t:r,locale:o}=re(),l=jt(),y=C.useMemo(()=>vt(l,Kt()),[l]),{getReceivers:p,inService:h,teamDid:i,getUser:O,blocklet:A}=tt(),[R,S]=C.useState(!1),[D,Y]=C.useState([]),z=Te({anchorEl:null,position:null}),B=Te({anchorEl:null,position:null}),[_,M]=C.useState(null),[J,ie]=C.useState({total:0,pageSize:10,pageCount:0,page:1}),[c,g]=C.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[se().subtract(1,"month").startOf("day").toDate(),se().endOf("day").toDate()]}),[j,N]=C.useState([]),E=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],P=async()=>{if(!R&&n)try{S(!0);const d=await p({notificationId:n,...c}),u=d.list.map(f=>({...f,receiverUser:{...f.receiverUser,avatar:Dt(f.receiverUser.avatar,i,h)}}));Y(u),ie(d.paging),S(!1)}catch(d){q.error(d.message),S(!1)}};C.useEffect(()=>{P()},[c]);const a=d=>{d.stopPropagation();const u=d.currentTarget;B.anchorEl=u;const f=u.getBoundingClientRect();B.position={top:f.top+window.scrollY,left:f.left+window.scrollX}},m=d=>d.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(me,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(et,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:a,children:r("notification.resend")})}):null,$={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:J.page-1,rowsPerPage:J.pageSize,count:J.total,searchText:c.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:j,onRowSelectionChange:(d,u)=>{N(u.map(f=>f.dataIndex))},customToolbarSelect:m},U=({page:d,rowsPerPage:u,searchText:f,filterList:L})=>{const[,K=[],Z=[],X=[]]=L;c.pageSize!==u?g(H=>({...H,pageSize:u,page:1})):c.page!==d+1?g(H=>({...H,page:d+1})):c.searchText!==f?g(H=>({...H,searchText:f,page:1})):ye(K,c.walletSendStatus)?ye(Z,c.pushKitSendStatus)?ye(X,c.emailSendStatus)||g(H=>({...H,emailSendStatus:X,page:1})):g(H=>({...H,pushKitSendStatus:Z,page:1})):g(H=>({...H,walletSendStatus:K,page:1}))},oe=C.useCallback(async(d,u)=>{if(!u)return!1;const f=await O(u);return f?d==="wallet"?Gs(f):d==="email"?Hs(A,f):d==="pushKit"?Vs(A,f):d==="webhook"?Ys(f):!0:!1},[O,A]),le=C.useCallback(d=>Js(r,d),[r]),pe=()=>{z.anchorEl=null,z.position=null,M(null)},be=()=>{B.anchorEl=null,B.position=null},je=async(d,u,f=!0,L="")=>{if(!(!u.length||!d.length))try{t(d,u,f,L),B.anchorEl||(await Ee(.5),pe())}catch(K){console.error("handleResend error",{error:K})}},v=async({channels:d,isResendFailedOnly:u})=>{const f=j.map(L=>D[L].receiver);await je(d,f,u),await Ee(.5),be(),N([])},b=async(d,u=[],f=!0)=>{try{await je(["webhook"],[d.receiver],f,u)}catch(L){q.error(L.response?L.response.statusText:L.message)}},w=async(d,u,f,L=[],K=!0)=>{if(d.stopPropagation(),Xs(u,f)>=4){q.warning(r("notification.resendLimit"));return}if(!Ye.includes(f)){await b(u,L,K);return}if(d){const X=d.currentTarget,H=X.getBoundingClientRect();z.anchorEl=X,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}M({channel:f});try{const X=await oe(f,u.receiver);await Ee(1),M({channel:f,result:X}),(typeof X=="boolean"&&X||Zt(X)&&Object.values(X).every(H=>!!H))&&(await t([f],[u.receiver],K),B.anchorEl||(await Ee(.5),pe()))}catch(X){q.error(X.message)}},I=d=>{g(u=>({...u,dateRange:d,page:1}))},k=(d,u,f,L)=>{d.stopPropagation();const K=f.filter(Z=>Z!==u);g(Z=>({...Z,[L]:K,page:1}))},F=ce(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:d=>{const{receiverUser:u,receiver:f}=D[d];return u?e.jsxs(T,{"data-cy":`member-name-${u.fullName}`,display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start",children:[e.jsx(Tt,{src:`${u.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:f,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Re,{children:u.fullName})]},f):e.jsx(vs,{size:14,responsive:!1,compact:!0,copyable:!1,did:f})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:c.walletSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Wallet",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[1].options.filterList,"walletSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Wallet",filterList:d,onChange:u,index:f,column:L,filterValues:E})},customBodyRenderLite:d=>{const{walletSendStatus:u,walletSendAt:f,walletSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"wallet",onResend:K=>w(K,D[d],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{pushKitSendStatus:u,pushKitSendAt:f,pushKitSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"pushkit",onResend:K=>w(K,D[d],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:c.pushKitSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Push Kit",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[2].options.filterList,"pushKitSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Push Kit",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{emailSendStatus:u,emailSendAt:f,emailSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"email",onResend:K=>w(K,D[d],"email",[],!1)})},filter:!0,filterType:"custom",filterList:c.emailSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Email",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[3].options.filterList,"emailSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Email",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{webhook:u}=D[d];if(!u)return null;const f=Object.entries(u)[0];if(!f)return null;const[L,K]=f,Z=K[0];return e.jsx(T,{display:"flex",flexDirection:"column",gap:1,children:e.jsxs(T,{className:"webhook-item",fontSize:12,children:[e.jsx(Re,{maxLength:30,children:L},L),e.jsx(ve,{status:Z.status,updatedAt:Z.sendAt,reason:Z.failedReason,channel:"webhook",onResend:X=>w(X,D[d],"webhook",[L],!1)})]},L)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:d=>{const{createdAt:u}=D[d];return e.jsx(At,{value:u,locale:o,shouldUpdate:!0})}}}],[D,o,c,r]),ne=[e.jsx(rt,{value:c.dateRange,onChange:I},"date-picker"),e.jsx(me,{variant:"contained",size:"small",color:"primary",loading:R,startIcon:e.jsx(Ft,{}),onClick:()=>P(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(T,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(tn,{children:e.jsxs(yt,{theme:y,children:[e.jsx(Rt,{className:"receivers-table",locale:o,loading:R,columns:F,data:D,onChange:U,options:$,customButtons:ne,components:{TableFilterList:d=>e.jsx(ot,{...d,itemComponent:u=>e.jsx(Pe,{...u,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Me,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:pe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(sn,{children:[e.jsxs(ae,{variant:"body1",component:"div",className:"check-title",children:[_==null?void 0:_.channel," Checking"]}),e.jsx(T,{display:"flex",flexDirection:"column",sx:{gap:"4px"},children:le(_==null?void 0:_.channel).map(d=>{var K,Z;const{type:u,pass:f,fail:L}=d;return!(_!=null&&_.result)||(K=_==null?void 0:_.result)!=null&&K[u]?e.jsxs(ae,{variant:"body1",component:"div",className:"check-item",display:"flex",alignItems:"center",sx:{gap:"4px",color:(Z=_==null?void 0:_.result)!=null&&Z[u]?Oe.success.main:"inherit"},children:[_!=null&&_.result?e.jsx(_t,{}):e.jsx(bt,{size:12,sx:{color:Oe.primary.main}}),e.jsx("span",{children:f})]},u):e.jsxs(ae,{variant:"body1",component:"div",display:"flex",alignItems:"center",className:"check-item",sx:{gap:"4px",color:Oe.error.main},children:[e.jsx(kt,{}),e.jsx("span",{children:L})]},u)})})]})}),B.anchorEl&&e.jsx(Me,{open:!!B.anchorEl,anchorReference:"anchorPosition",anchorPosition:B.position,onClose:be,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(lt,{loading:s,onCancel:be,onConfirm:v})})]})})})}const en=C.memo(qt),tn=ue.div`
|
|
2
2
|
td.MuiTableCell-footer {
|
|
3
3
|
border: none !important;
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as P,t as bn,g as Cn,e as wt,a as jn}from"./vendor-react-DEoibe3W.js";import{a9 as Ut,j as e,aa as O,bo as Be,br as Fe,bn as $e,q as je,T as G,O as me,ab as ie,bx as qe,ak as oe,H as v,ah as z,e as Sn,ad as ue,w as wn,y as _t,b7 as Pn,b8 as kn,I as In,bh as Tn,bs as Dn,bR as An}from"./vendor-mui-core-Bq8gXTan.js";import{B as Pt,e as We,a0 as Rn,ay as Ln,n as kt,A as En,b as On}from"./vendor-utils-BfZ4tlod.js";import{r as Bt,aR as Ft,bL as Nn,i as Un,a as K,a2 as _n,a1 as Bn,a3 as Y,ar as ne,B as W,f as Fn,at as $n,d as Wn,bb as fe,bC as zn,k as Q,a5 as $t,an as Mn,br as Wt,bs as zt,bt as qn,I as Hn,ax as Vn,$ as ze,bd as Kn,ac as Mt,ab as qt,bI as Zn}from"./vendor-ux-did-connect-pzpsrvqx.js";import{c as J,a as Yn,G as Ht,v as Se,n as Gn,I as Qn}from"./vendor-arcblock-CwufDgLV.js";import{d as Jn}from"./ViewList-BOGcbymi.js";import{a2 as Xn,f as es,D as H,ay as we,n as pe,a3 as ts,V as se,az as ns,G as Vt,aA as Kt,y as ss,b as rs,aB as os}from"./index-CMYHZyLG.js";import{k as is,u as He,a as Ve,c as as,m as ls,b as cs}from"./vendor-hooks-DqdmWCmo.js";import{l as ds}from"./index-BLfUtUpB.js";import{u as Z,d as It,W as Zt}from"./dashboard-Cvfy6NEE.js";import{W as Ke}from"./did-address-NnOD1W_A.js";import{P as X}from"./permission-DQvXGutX.js";import{C as Te}from"./click-to-copy-By4fgGR7.js";import{T as Yt}from"./index-z4rrXifq.js";import{f as ee}from"./index-8eXqqyHQ.js";import{_ as ms}from"./useAsync-C62uE2pS.js";import{I as q}from"./index-DPIWnhb5.js";import{d as us}from"./DeleteOutline-BKSMNwfT.js";import{C as ge}from"./confirm-CYOuqhW9.js";import{u as he}from"./session-BGdAM8zS.js";import{i as Gt,a as Pe,p as Qt}from"./util-BQAJqeb4.js";import{b as ps}from"./sdk-BmeKtHic.js";import{A as fs}from"./actions-DnTVXQ_Z.js";import{S as gs}from"./shorten-label-BQvbtscf.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-CaPDqrQ7.js";import"./PlayArrow-BqVYRyLK.js";import"./get-safe-url-D5KSEAKZ.js";import"./use-blocklet-logo-CWdlYyrq.js";import"./InfoOutlined-BVWbftGI.js";import"./dot-4jhL56kz.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-CtTQsfXN.js";import"./vendor-mui-x-1nqAyytV.js";import"./AdapterDayjs-BRnJ9bMs.js";import"./base32-DUSifB4M.js";import"./MoreHoriz-ChJ3K52h.js";var Ze={},hs=Ut;Object.defineProperty(Ze,"__esModule",{value:!0});var Jt=Ze.default=void 0,xs=hs(Bt()),ys=e;Jt=Ze.default=(0,xs.default)((0,ys.jsx)("path",{d:"M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8m0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4z"}),"Loop");var Ye=function(t){return e.jsxs("svg",{...t,children:[e.jsx("g",{clipPath:"url(#clip0)",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.99997 1.59778C8.19071 1.59778 7.39961 1.83775 6.72673 2.28736C6.05385 2.73697 5.5294 3.37601 5.21971 4.12367C4.91001 4.87134 4.82898 5.69405 4.98686 6.48777C5.14474 7.28149 5.53444 8.01056 6.10668 8.5828C6.67892 9.15504 7.408 9.54474 8.20172 9.70262C8.99544 9.8605 9.81815 9.77947 10.5658 9.46978C11.3135 9.16009 11.9525 8.63564 12.4021 7.96276C12.8517 7.28987 13.0917 6.49878 13.0917 5.68951C13.0917 4.60432 12.6606 3.56357 11.8933 2.79622C11.1259 2.02887 10.0852 1.59778 8.99997 1.59778ZM7.27426 3.9638C7.73195 3.50611 8.35271 3.24899 8.99997 3.24899C9.48266 3.24899 9.95452 3.39212 10.3559 3.66029C10.7572 3.92846 11.07 4.30962 11.2547 4.75556C11.4394 5.20151 11.4878 5.69222 11.3936 6.16563C11.2994 6.63905 11.067 7.07391 10.7257 7.41522C10.3844 7.75654 9.94951 7.98897 9.4761 8.08314C9.00268 8.17731 8.51197 8.12898 8.06603 7.94426C7.62008 7.75954 7.23892 7.44674 6.97075 7.04539C6.70258 6.64405 6.55945 6.1722 6.55945 5.68951C6.55945 5.04224 6.81658 4.42149 7.27426 3.9638ZM7.36691 10.3075C6.28172 10.3075 5.24097 10.7385 4.47362 11.5059C3.70627 12.2732 3.27518 13.314 3.27518 14.3992V17.121C3.27518 17.2763 3.4011 17.4022 3.55643 17.4022H4.64514C4.80047 17.4022 4.92639 17.2763 4.92639 17.121V14.3992C4.92639 13.7519 5.18351 13.1312 5.6412 12.6735C6.09889 12.2158 6.71964 11.9587 7.36691 11.9587H10.633C10.9535 11.9587 11.2709 12.0218 11.567 12.1444C11.8631 12.2671 12.1321 12.4469 12.3588 12.6735C12.5854 12.9001 12.7651 13.1691 12.8878 13.4652C13.0104 13.7613 13.0736 14.0787 13.0736 14.3992V17.121C13.0736 17.2763 13.1995 17.4022 13.3548 17.4022H14.4435C14.5989 17.4022 14.7248 17.2763 14.7248 17.121V14.3992C14.7248 13.314 14.2937 12.2732 13.5263 11.5059C12.759 10.7385 11.7182 10.3075 10.633 10.3075H7.36691Z"})}),e.jsx("defs",{children:e.jsx("clipPath",{id:"clip0",children:e.jsx("rect",{width:"18",height:"18",transform:"translate(0 0.5)"})})})]})};Ye.defaultProps={width:"18",height:"19",viewBox:"0 0 18 19",xmlns:"http://www.w3.org/2000/svg"};Ye.displayName="person";const vs=Ye;var Ge=function(t){return e.jsxs("svg",{...t,children:[e.jsx("path",{d:"M1.25 2.7087C1.25 2.24826 1.62326 1.875 2.0837 1.875H14.339C14.7995 1.875 15.1727 2.24826 15.1727 2.7087V9.31574C15.1727 9.77618 14.7995 10.1494 14.339 10.1494C13.8786 10.1494 13.5053 9.77618 13.5053 9.31574V3.54239H2.91739V16.7565H6.53772H8.34788H9.32435C9.78479 16.7565 10.158 17.1297 10.158 17.5902C10.158 18.0506 9.78479 18.4239 9.32435 18.4239H8.34788H2.0837C1.62326 18.4239 1.25 18.0506 1.25 17.5902V2.7087Z"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.21129 7.91935C7.70481 7.91935 7.29422 8.32993 7.29422 8.83641C7.29422 9.34289 7.70481 9.75348 8.21129 9.75348C8.71777 9.75348 9.12836 9.34289 9.12836 8.83641C9.12836 8.32993 8.71777 7.91935 8.21129 7.91935ZM5.62683 8.83641C5.62683 7.40905 6.78393 6.25195 8.21129 6.25195C9.63865 6.25195 10.7957 7.40905 10.7957 8.83641C10.7957 10.2638 9.63865 11.4209 8.21129 11.4209C6.78393 11.4209 5.62683 10.2638 5.62683 8.83641Z"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.62683 13.2133C5.62683 12.7529 6.00009 12.3796 6.46053 12.3796H9.96205C10.4225 12.3796 10.7957 12.7529 10.7957 13.2133C10.7957 13.6737 10.4225 14.047 9.96205 14.047H6.46053C6.00009 14.047 5.62683 13.6737 5.62683 13.2133Z"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.6406 11.3125C15.8547 11.3125 16.0503 11.434 16.145 11.626L17.1779 13.7184L19.4876 14.056C19.6994 14.087 19.8753 14.2355 19.9413 14.4391C20.0074 14.6427 19.9521 14.8662 19.7987 15.0156L18.1279 16.643L18.5222 18.9421C18.5584 19.1532 18.4716 19.3665 18.2984 19.4923C18.1252 19.6182 17.8955 19.6347 17.706 19.5351L15.6406 18.4489L13.5753 19.5351C13.3858 19.6347 13.1561 19.6182 12.9829 19.4923C12.8096 19.3665 12.7229 19.1532 12.7591 18.9421L13.1534 16.643L11.4825 15.0156C11.3292 14.8662 11.2739 14.6427 11.3399 14.4391C11.406 14.2355 11.5818 14.087 11.7937 14.056L14.1034 13.7184L15.1362 11.626C15.231 11.434 15.4265 11.3125 15.6406 11.3125ZM15.6406 13.1458L14.9815 14.4813C14.8996 14.6471 14.7414 14.7621 14.5584 14.7889L13.0835 15.0044L14.1503 16.0435C14.283 16.1727 14.3435 16.359 14.3122 16.5416L14.0606 18.0088L15.3788 17.3155C15.5427 17.2293 15.7386 17.2293 15.9025 17.3155L17.2207 18.0088L16.969 16.5416C16.9377 16.359 16.9983 16.1727 17.131 16.0435L18.1978 15.0044L16.7229 14.7889C16.5399 14.7621 16.3817 14.6471 16.2998 14.4813L15.6406 13.1458Z"})]})};Ge.defaultProps={width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"};Ge.displayName="external-issuer";const Xt=Ge;var Ce={},bs=t=>encodeURIComponent(t).replace(/[!'()*]/g,o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`),en="%[a-f0-9]{2}",Tt=new RegExp("("+en+")|([^%]+?)","gi"),Dt=new RegExp("("+en+")+","gi");function Me(t,o){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;o=o||1;var l=t.slice(0,o),p=t.slice(o);return Array.prototype.concat.call([],Me(l),Me(p))}function Cs(t){try{return decodeURIComponent(t)}catch{for(var o=t.match(Tt)||[],l=1;l<o.length;l++)t=Me(o,l).join(""),o=t.match(Tt)||[];return t}}function js(t){for(var o={"%FE%FF":"��","%FF%FE":"��"},l=Dt.exec(t);l;){try{o[l[0]]=decodeURIComponent(l[0])}catch{var p=Cs(l[0]);p!==l[0]&&(o[l[0]]=p)}l=Dt.exec(t)}o["%C2"]="�";for(var d=Object.keys(o),h=0;h<d.length;h++){var S=d[h];t=t.replace(new RegExp(S,"g"),o[S])}return t}var Ss=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return js(t)}},ws=(t,o)=>{if(!(typeof t=="string"&&typeof o=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(o==="")return[t];const l=t.indexOf(o);return l===-1?[t]:[t.slice(0,l),t.slice(l+o.length)]},Ps=function(t,o){for(var l={},p=Object.keys(t),d=Array.isArray(o),h=0;h<p.length;h++){var S=p[h],f=t[S];(d?o.indexOf(S)!==-1:o(S,f,t))&&(l[S]=f)}return l};(function(t){const o=bs,l=Ss,p=ws,d=Ps,h=n=>n==null;function S(n){switch(n.arrayFormat){case"index":return s=>(r,c)=>{const y=r.length;return c===void 0||n.skipNull&&c===null||n.skipEmptyString&&c===""?r:c===null?[...r,[g(s,n),"[",y,"]"].join("")]:[...r,[g(s,n),"[",g(y,n),"]=",g(c,n)].join("")]};case"bracket":return s=>(r,c)=>c===void 0||n.skipNull&&c===null||n.skipEmptyString&&c===""?r:c===null?[...r,[g(s,n),"[]"].join("")]:[...r,[g(s,n),"[]=",g(c,n)].join("")];case"comma":case"separator":return s=>(r,c)=>c==null||c.length===0?r:r.length===0?[[g(s,n),"=",g(c,n)].join("")]:[[r,g(c,n)].join(n.arrayFormatSeparator)];default:return s=>(r,c)=>c===void 0||n.skipNull&&c===null||n.skipEmptyString&&c===""?r:c===null?[...r,g(s,n)]:[...r,[g(s,n),"=",g(c,n)].join("")]}}function f(n){let s;switch(n.arrayFormat){case"index":return(r,c,y)=>{if(s=/\[(\d*)\]$/.exec(r),r=r.replace(/\[\d*\]$/,""),!s){y[r]=c;return}y[r]===void 0&&(y[r]={}),y[r][s[1]]=c};case"bracket":return(r,c,y)=>{if(s=/(\[\])$/.exec(r),r=r.replace(/\[\]$/,""),!s){y[r]=c;return}if(y[r]===void 0){y[r]=[c];return}y[r]=[].concat(y[r],c)};case"comma":case"separator":return(r,c,y)=>{const x=typeof c=="string"&&c.includes(n.arrayFormatSeparator),w=typeof c=="string"&&!x&&i(c,n).includes(n.arrayFormatSeparator);c=w?i(c,n):c;const U=x||w?c.split(n.arrayFormatSeparator).map(F=>i(F,n)):c===null?c:i(c,n);y[r]=U};default:return(r,c,y)=>{if(y[r]===void 0){y[r]=c;return}y[r]=[].concat(y[r],c)}}}function b(n){if(typeof n!="string"||n.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(n,s){return s.encode?s.strict?o(n):encodeURIComponent(n):n}function i(n,s){return s.decode?l(n):n}function T(n){return Array.isArray(n)?n.sort():typeof n=="object"?T(Object.keys(n)).sort((s,r)=>Number(s)-Number(r)).map(s=>n[s]):n}function C(n){const s=n.indexOf("#");return s!==-1&&(n=n.slice(0,s)),n}function k(n){let s="";const r=n.indexOf("#");return r!==-1&&(s=n.slice(r)),s}function a(n){n=C(n);const s=n.indexOf("?");return s===-1?"":n.slice(s+1)}function I(n,s){return s.parseNumbers&&!Number.isNaN(Number(n))&&typeof n=="string"&&n.trim()!==""?n=Number(n):s.parseBooleans&&n!==null&&(n.toLowerCase()==="true"||n.toLowerCase()==="false")&&(n=n.toLowerCase()==="true"),n}function m(n,s){s=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},s),b(s.arrayFormatSeparator);const r=f(s),c=Object.create(null);if(typeof n!="string"||(n=n.trim().replace(/^[?#&]/,""),!n))return c;for(const y of n.split("&")){if(y==="")continue;let[x,w]=p(s.decode?y.replace(/\+/g," "):y,"=");w=w===void 0?null:["comma","separator"].includes(s.arrayFormat)?w:i(w,s),r(i(x,s),w,c)}for(const y of Object.keys(c)){const x=c[y];if(typeof x=="object"&&x!==null)for(const w of Object.keys(x))x[w]=I(x[w],s);else c[y]=I(x,s)}return s.sort===!1?c:(s.sort===!0?Object.keys(c).sort():Object.keys(c).sort(s.sort)).reduce((y,x)=>{const w=c[x];return w&&typeof w=="object"&&!Array.isArray(w)?y[x]=T(w):y[x]=w,y},Object.create(null))}t.extract=a,t.parse=m,t.stringify=(n,s)=>{if(!n)return"";s=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},s),b(s.arrayFormatSeparator);const r=w=>s.skipNull&&h(n[w])||s.skipEmptyString&&n[w]==="",c=S(s),y={};for(const w of Object.keys(n))r(w)||(y[w]=n[w]);const x=Object.keys(y);return s.sort!==!1&&x.sort(s.sort),x.map(w=>{const U=n[w];return U===void 0?"":U===null?g(w,s):Array.isArray(U)?U.reduce(c(w),[]).join("&"):g(w,s)+"="+g(U,s)}).filter(w=>w.length>0).join("&")},t.parseUrl=(n,s)=>{s=Object.assign({decode:!0},s);const[r,c]=p(n,"#");return Object.assign({url:r.split("?")[0]||"",query:m(a(n),s)},s&&s.parseFragmentIdentifier&&c?{fragmentIdentifier:i(c,s)}:{})},t.stringifyUrl=(n,s)=>{s=Object.assign({encode:!0,strict:!0},s);const r=C(n.url).split("?")[0]||"",c=t.extract(n.url),y=t.parse(c,{sort:!1}),x=Object.assign(y,n.query);let w=t.stringify(x,s);w&&(w=`?${w}`);let U=k(n.url);return n.fragmentIdentifier&&(U=`#${g(n.fragmentIdentifier,s)}`),`${r}${w}${U}`},t.pick=(n,s,r)=>{r=Object.assign({parseFragmentIdentifier:!0},r);const{url:c,query:y,fragmentIdentifier:x}=t.parseUrl(n,r);return t.stringifyUrl({url:c,query:d(y,s),fragmentIdentifier:x},r)},t.exclude=(n,s,r)=>{const c=Array.isArray(s)?y=>!s.includes(y):(y,x)=>!s(y,x);return t.pick(n,c,r)}})(Ce);const le=bn,ks={parseNumbers:!1,parseBooleans:!1},Is={skipNull:!1,skipEmptyString:!1},Ts=(t,o)=>{var l,p;const{navigateMode:d="push",parseOptions:h,stringifyOptions:S}={},f=Object.assign(Object.assign({},ks),h),b=Object.assign(Object.assign({},Is),S),g=le.useLocation(),i=(l=le.useHistory)===null||l===void 0?void 0:l.call(le),T=(p=le.useNavigate)===null||p===void 0?void 0:p.call(le),C=is(),k=P.useRef(typeof t=="function"?t():t||{}),a=P.useMemo(()=>Ce.parse(g.search,f),[g.search]),I=P.useMemo(()=>Object.assign(Object.assign({},k.current),a),[a]);return[I,He(n=>{const s=typeof n=="function"?n(I):n;C(),i&&i[d]({hash:g.hash,search:Ce.stringify(Object.assign(Object.assign({},a),s),b)||"?"},g.state),T&&T({hash:g.hash,search:Ce.stringify(Object.assign(Object.assign({},a),s),b)||"?"},{replace:d==="replace",state:g.state})})]},Ds=Ts,As=Ft,Ne=Nn,Ue=Un,Rs=ds,At={role:As.types.RoleType.ROLE_APPLICATION},Ls=(t,o,l,p)=>{let d=l||At;const h=(0,Ue.isEthereumType)((0,Ue.DidType)(l));if(h?d=(0,Ne.WalletType)(l):d=(0,Ne.WalletType)(At),!(0,Ue.isValid)(t)){let S="";try{return h?S=t.slice(0,66):S=t,(0,Ne.fromSecretKey)(S,d)}catch(f){throw new Error(`Cannot get blocklet wallet with invalid blocklet did or custom sk: ${f.message}`)}}if(!o)throw new Error("Cannot get blocklet wallet with empty node sk");return(0,Rs.fromAppDid)(t,o,d,p||0)};var Es=Ls,tn=wt&&wt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const ce=tn(Xn),Os=Ft,ve=tn(Es),Ns=es,Us=(t,o,{returnWallet:l=!0}={})=>{var F,A;if(!t||typeof t!="object"||!Array.isArray(t.environments)||!(0,ce.default)(t,"meta.did"))throw new Error("Blocklet state must be an object");const{environments:p,configs:d=[]}=t,h=[...d,...p],S=h.find(D=>D.key==="BLOCKLET_APP_DESCRIPTION"),f=h.find(D=>D.key==="BLOCKLET_PASSPORT_COLOR"),b=h.find(D=>D.key==="BLOCKLET_APP_URL"),g=h.find(D=>D.key==="BLOCKLET_APP_TENANT_MODE"),{did:i,version:T}=t.meta,C=(0,Ns.getDisplayName)(t),k=(0,ce.default)(S,"value",t.meta.description),a=(0,ce.default)(f,"value","auto"),I=(0,ce.default)(b,"value",""),m=(0,ce.default)(g,"value","");if(!l)return{did:i,version:T,name:C,description:k,passportColor:a,appUrl:I,secret:"",wallet:null,permanentWallet:null,tenantMode:m};const n=h.find(D=>D.key==="BLOCKLET_APP_SK"),s=h.find(D=>D.key==="BLOCKLET_APP_CHAIN_TYPE")||h.find(D=>D.key==="BLOCKLET_WALLET_TYPE"),r=h.find(D=>D.key==="BLOCKLET_APP_PSK");let c;s&&(s.value==="ethereum"||s.value==="eth")&&(c=s.value);let y=null,x=null;if(n&&n.value)y=(0,ve.default)(n.value,void 0,c),r&&r.value&&r.value!==n.value&&(x=(0,ve.default)(r.value,void 0,c));else{if(!o||typeof o!="string")throw new Error("Node secret key must be a string");s?y=(0,ve.default)(t.meta.did,o,c):y=(0,ve.default)(t.meta.did,o)}const w=((A=(F=t.settings)==null?void 0:F.session)==null?void 0:A.salt)||"",U=Os.Hasher.SHA3.hash256(Pt.concat([y.secretKey,y.address,w].filter(Boolean).map(D=>Pt.from(D))));return{did:i,version:T,name:C,description:k,passportColor:a,appUrl:I,secret:U,wallet:y,permanentWallet:x||y,tenantMode:m}};var _s=Us;const Bs=Cn(_s);function Qe({teamDid:t,roles:o,apps:l,onCancel:p,onSuccess:d,onError:h,endpoint:S}){var I;const{api:f}=H(),{t:b,locale:g}=K(),i=Ve({loading:!1,error:null,activeStep:0,inviteInfo:null,role:"",remark:"",sourceAppPid:l.length>0?l[0].appPid:null,display:null,passportExpireTime:null,showPicker:!1}),T=async()=>{if(!i.role){i.error=b("team.member.error.passportEmpty");return}const m=i.remark.trim();i.error=null,i.loading=!0;try{let n=i.sourceAppPid??null;n===t&&(n=null);const s={teamDid:t,role:i.role,remark:m,sourceAppPid:n,passportExpireTime:i.passportExpireTime?i.passportExpireTime.toISOString():""};i.display&&(s.display={type:"url",content:i.display});const{inviteInfo:r}=await f.createMemberInvitation({input:s});i.inviteInfo=r,i.activeStep=1}catch(n){const s=ee(n);i.error=s,h(n)}finally{i.loading=!1}},C=o.find(m=>m.name===i.role),a=[{body:e.jsxs(O,{sx:{display:"flex",flexDirection:"column",gap:3},children:[l.length>1?e.jsxs(Be,{fullWidth:!0,children:[e.jsx(Fe,{children:b("common.sourceApp")}),e.jsx($e,{value:i.sourceAppPid,onChange:m=>{i.error=null,i.sourceAppPid=m.target.value},fullWidth:!0,label:b("common.passport"),disabled:i.loading,children:l.map(m=>e.jsx(je,{value:m.appPid,children:e.jsxs(O,{sx:{display:"flex",justifyContent:"space-between",gap:2,width:"100%"},children:[e.jsxs(O,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(_n,{did:m.appPid,size:28}),m.appName]}),e.jsx(Bn,{did:m.appPid,compact:!0,responsive:!1})]})},m.appPid))})]}):null,e.jsxs(Be,{fullWidth:!0,variant:"outlined",children:[e.jsx(Fe,{children:b("common.passport")}),e.jsx($e,{"data-cy":"invite-member-select-role",value:i.role,onChange:m=>{i.error=null,i.role=m.target.value},fullWidth:!0,label:b("common.passport"),disabled:i.loading,onKeyPress:m=>{m.key==="Enter"&&(m.preventDefault(),T())},children:o.filter(m=>m.name!=="owner").map(m=>e.jsx(je,{value:m.name,"data-cy":`invite-member-select-option-${m.name}`,children:e.jsxs(O,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(G,{variant:"subtitle1",children:m.title||m.name}),e.jsx(G,{variant:"caption",sx:{opacity:.7},children:m.description})]})},m.name))})]}),((I=C==null?void 0:C.extra)==null?void 0:I.display)==="custom"&&e.jsx(me,{label:b("common.display"),type:"url",value:i.display,onChange:m=>{i.error=null,i.display=m.target.value},fullWidth:!0,variant:"outlined",margin:"normal"}),e.jsx(me,{label:b("common.remark"),autoComplete:"off",variant:"outlined",fullWidth:!0,value:i.remark,onChange:m=>{i.error=null,i.remark=m.target.value},disabled:i.loading,"data-cy":"invite-member-input-remark"}),e.jsx(Yt,{value:i.passportExpireTime,onChange:m=>{i.passportExpireTime=m}})]}),cancel:b("common.cancel"),confirm:b("team.member.inviteDialog.createInviteLink"),onCancel:p,onConfirm:T},{body:()=>{var n,s;const m=we({inviteId:(n=i.inviteInfo)==null?void 0:n.inviteId,endpoint:S});return e.jsxs("div",{children:[e.jsx(O,{sx:{fontSize:16,fontWeight:"bold"},children:b("team.member.inviteDialog.createSuccessTip",{expireDate:pe((s=i.inviteInfo)==null?void 0:s.expireDate,g)})}),e.jsx("div",{style:{marginTop:"40px"}}),e.jsx(Te,{children:m})]})},confirm:b("common.copy"),onConfirm:()=>{var n;const m=we({inviteId:(n=i.inviteInfo)==null?void 0:n.inviteId,endpoint:S});as(m),Y.success(b("common.copied")),d()},cancel:b("common.cancel"),onCancel:p}][i.activeStep];return e.jsxs(ne,{title:b("common.invite"),fullWidth:!0,open:!0,showCloseButton:!1,actions:e.jsxs(e.Fragment,{children:[a.cancel&&e.jsx(W,{onClick:a.onCancel,color:"inherit",children:a.cancel}),e.jsxs(W,{onClick:a.onConfirm,color:"primary",disabled:i.loading||!i.role,variant:"contained",autoFocus:!0,children:[i.loading&&e.jsx(ie,{size:16}),a.confirm]})]}),children:[e.jsx(qe,{component:"div",children:typeof a.body=="function"?a.body():a.body}),!!i.error&&e.jsx(oe,{severity:"error",variant:"icon",children:i.error})]})}Qe.propTypes={teamDid:v.string.isRequired,onCancel:v.func.isRequired,onSuccess:v.func.isRequired,onError:v.func,roles:v.array,apps:v.array,endpoint:v.string};Qe.defaultProps={onError:()=>{},roles:[],apps:[],endpoint:""};function Je({teamDid:t,onCancel:o,onSuccess:l,onError:p,endpoint:d}){const{api:h,info:S}=H(),{api:f}=P.useContext(Fn),[b,g]=P.useState(!1),{t:i,locale:T}=K(),[C,k]=P.useState(""),[a,I]=P.useState(!1),[m,n]=P.useState(0),[s,r]=P.useState(""),[c,y]=P.useState(""),x=!!We(S,"ownerNft.did"),w=ms(async()=>{if(x){const{state:R}=await h.getDelegationState();return R}return{delegated:!0}});if(w.loading)return e.jsx(ne,{title:i("team.transferNode.inviteDialog.title"),fullWidth:!0,open:!0,onClose:o,children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(ie,{})})});if(w.error)return e.jsx(ne,{title:i("team.transferNode.inviteDialog.title"),fullWidth:!0,open:!0,onClose:o,children:e.jsx(oe,{severity:"error",variant:"icon",children:ee(w.error)})});const U=async()=>{k(null),g(!0);try{const{inviteInfo:R}=await h.createTransferInvitation({input:{teamDid:t,role:"owner",remark:c.trim()}});r(R),n(D.length-1)}catch(R){const V=ee(R);k(V),p(R)}finally{g(!1)}},F=()=>{I(!0),n(1)},A=()=>{I(!1),n(0)},D=[{body:e.jsxs(G,{component:"div",children:[e.jsxs(oe,{severity:"warning",children:[e.jsx(G,{children:i("team.transferNode.inviteDialog.tips.progress")}),e.jsx(G,{children:i("team.transferNode.inviteDialog.tips.newOwnerPermissions")})]}),e.jsx(oe,{severity:"warning",children:e.jsx(G,{children:i("team.transferNode.inviteDialog.tips.revoke")})}),e.jsx("div",{style:{marginTop:20,marginBottom:10}}),e.jsx(me,{label:i("common.remark"),autoComplete:"off",variant:"outlined",fullWidth:!0,style:{marginBottom:8},value:c,onChange:R=>{k(null),y(R.target.value)},disabled:b,"data-cy":"transfer-node-input-remark"}),e.jsx("div",{style:{marginTop:20,marginBottom:10}})]}),cancel:i("common.cancel"),confirm:i("team.transferNode.inviteDialog.createInviteLink"),onCancel:o,onConfirm:x&&!We(w,"value.delegated")?F:U},{body:()=>e.jsx($n,{action:"delegate-transfer-nft",open:a,locale:T,checkFn:f.get,onClose:A,onSuccess:U,checkTimeout:5*60*1e3,webWalletUrl:ts(S),extraParams:{targetDID:S.did},messages:{title:i("team.transferNode.delegateDialog.title"),scan:i("team.transferNode.delegateDialog.scan"),confirm:i("team.transferNode.delegateDialog.confirm"),success:i("team.transferNode.delegateDialog.success")},popup:!0})},{body:()=>{const R=we({inviteId:s.inviteId,endpoint:d});return e.jsxs("div",{children:[e.jsx(Fs,{children:i("team.transferNode.inviteDialog.createSuccessTip",{expireDate:pe(s.expireDate,T)})}),e.jsx("div",{style:{marginTop:"40px"}}),e.jsx(Te,{children:R})]})},confirm:i("common.confirm"),onConfirm:l}],E=D[m];return e.jsxs(ne,{title:i("team.transferNode.inviteDialog.title"),fullWidth:!0,open:!0,showCloseButton:!1,actions:e.jsxs(e.Fragment,{children:[E.cancel&&e.jsx(W,{onClick:E.onCancel,color:"inherit",children:E.cancel}),e.jsxs(W,{onClick:E.onConfirm,color:"primary",disabled:b,variant:"contained",autoFocus:!0,children:[b&&e.jsx(ie,{size:16}),E.confirm]})]}),children:[e.jsx(qe,{component:"div",children:typeof E.body=="function"?E.body():E.body}),!!C&&e.jsx(oe,{severity:"error",variant:"icon",children:C})]})}Je.propTypes={teamDid:v.string.isRequired,onCancel:v.func.isRequired,onSuccess:v.func.isRequired,onError:v.func,endpoint:v.string};Je.defaultProps={onError:()=>{},endpoint:""};const Fs=z.div`
|
|
1
|
+
import{r as P,t as bn,g as Cn,e as wt,a as jn}from"./vendor-react-DEoibe3W.js";import{a9 as Ut,j as e,aa as O,bo as Be,br as Fe,bn as $e,q as je,T as G,O as me,ab as ie,bx as qe,ak as oe,H as v,ah as z,e as Sn,ad as ue,w as wn,y as _t,b7 as Pn,b8 as kn,I as In,bh as Tn,bs as Dn,bR as An}from"./vendor-mui-core-Bq8gXTan.js";import{B as Pt,e as We,a0 as Rn,ay as Ln,n as kt,A as En,b as On}from"./vendor-utils-BfZ4tlod.js";import{r as Bt,aR as Ft,bL as Nn,i as Un,a as K,a2 as _n,a1 as Bn,a3 as Y,ar as ne,B as W,f as Fn,at as $n,d as Wn,bb as fe,bC as zn,k as Q,a5 as $t,an as Mn,br as Wt,bs as zt,bt as qn,I as Hn,ax as Vn,$ as ze,bd as Kn,ac as Mt,ab as qt,bI as Zn}from"./vendor-ux-did-connect-pzpsrvqx.js";import{c as J,a as Yn,G as Ht,v as Se,n as Gn,I as Qn}from"./vendor-arcblock-CwufDgLV.js";import{d as Jn}from"./ViewList-BOGcbymi.js";import{a2 as Xn,f as es,D as H,ay as we,n as pe,a3 as ts,V as se,az as ns,G as Vt,aA as Kt,y as ss,b as rs,aB as os}from"./index-CMYHZyLG.js";import{k as is,u as He,a as Ve,c as as,m as ls,b as cs}from"./vendor-hooks-DqdmWCmo.js";import{l as ds}from"./index-BLfUtUpB.js";import{u as Z,d as It,W as Zt}from"./dashboard-Cvfy6NEE.js";import{W as Ke}from"./did-address-NnOD1W_A.js";import{P as X}from"./permission-DQvXGutX.js";import{C as Te}from"./click-to-copy-By4fgGR7.js";import{T as Yt}from"./index-z4rrXifq.js";import{f as ee}from"./index-8eXqqyHQ.js";import{_ as ms}from"./useAsync-C62uE2pS.js";import{I as q}from"./index-DPIWnhb5.js";import{d as us}from"./DeleteOutline-BKSMNwfT.js";import{C as ge}from"./confirm-CYOuqhW9.js";import{u as he}from"./session-BGdAM8zS.js";import{i as Gt,a as Pe,p as Qt}from"./util-BQAJqeb4.js";import{b as ps}from"./sdk-BmeKtHic.js";import{A as fs}from"./actions-DnTVXQ_Z.js";import{S as gs}from"./shorten-label-BQvbtscf.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-CaPDqrQ7.js";import"./PlayArrow-BqVYRyLK.js";import"./get-safe-url-B0-S5PGZ.js";import"./use-blocklet-logo-CWdlYyrq.js";import"./InfoOutlined-BVWbftGI.js";import"./dot-4jhL56kz.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-DwzRjjku.js";import"./vendor-mui-x-1nqAyytV.js";import"./AdapterDayjs-BRnJ9bMs.js";import"./base32-DUSifB4M.js";import"./MoreHoriz-ChJ3K52h.js";var Ze={},hs=Ut;Object.defineProperty(Ze,"__esModule",{value:!0});var Jt=Ze.default=void 0,xs=hs(Bt()),ys=e;Jt=Ze.default=(0,xs.default)((0,ys.jsx)("path",{d:"M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8m0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4z"}),"Loop");var Ye=function(t){return e.jsxs("svg",{...t,children:[e.jsx("g",{clipPath:"url(#clip0)",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.99997 1.59778C8.19071 1.59778 7.39961 1.83775 6.72673 2.28736C6.05385 2.73697 5.5294 3.37601 5.21971 4.12367C4.91001 4.87134 4.82898 5.69405 4.98686 6.48777C5.14474 7.28149 5.53444 8.01056 6.10668 8.5828C6.67892 9.15504 7.408 9.54474 8.20172 9.70262C8.99544 9.8605 9.81815 9.77947 10.5658 9.46978C11.3135 9.16009 11.9525 8.63564 12.4021 7.96276C12.8517 7.28987 13.0917 6.49878 13.0917 5.68951C13.0917 4.60432 12.6606 3.56357 11.8933 2.79622C11.1259 2.02887 10.0852 1.59778 8.99997 1.59778ZM7.27426 3.9638C7.73195 3.50611 8.35271 3.24899 8.99997 3.24899C9.48266 3.24899 9.95452 3.39212 10.3559 3.66029C10.7572 3.92846 11.07 4.30962 11.2547 4.75556C11.4394 5.20151 11.4878 5.69222 11.3936 6.16563C11.2994 6.63905 11.067 7.07391 10.7257 7.41522C10.3844 7.75654 9.94951 7.98897 9.4761 8.08314C9.00268 8.17731 8.51197 8.12898 8.06603 7.94426C7.62008 7.75954 7.23892 7.44674 6.97075 7.04539C6.70258 6.64405 6.55945 6.1722 6.55945 5.68951C6.55945 5.04224 6.81658 4.42149 7.27426 3.9638ZM7.36691 10.3075C6.28172 10.3075 5.24097 10.7385 4.47362 11.5059C3.70627 12.2732 3.27518 13.314 3.27518 14.3992V17.121C3.27518 17.2763 3.4011 17.4022 3.55643 17.4022H4.64514C4.80047 17.4022 4.92639 17.2763 4.92639 17.121V14.3992C4.92639 13.7519 5.18351 13.1312 5.6412 12.6735C6.09889 12.2158 6.71964 11.9587 7.36691 11.9587H10.633C10.9535 11.9587 11.2709 12.0218 11.567 12.1444C11.8631 12.2671 12.1321 12.4469 12.3588 12.6735C12.5854 12.9001 12.7651 13.1691 12.8878 13.4652C13.0104 13.7613 13.0736 14.0787 13.0736 14.3992V17.121C13.0736 17.2763 13.1995 17.4022 13.3548 17.4022H14.4435C14.5989 17.4022 14.7248 17.2763 14.7248 17.121V14.3992C14.7248 13.314 14.2937 12.2732 13.5263 11.5059C12.759 10.7385 11.7182 10.3075 10.633 10.3075H7.36691Z"})}),e.jsx("defs",{children:e.jsx("clipPath",{id:"clip0",children:e.jsx("rect",{width:"18",height:"18",transform:"translate(0 0.5)"})})})]})};Ye.defaultProps={width:"18",height:"19",viewBox:"0 0 18 19",xmlns:"http://www.w3.org/2000/svg"};Ye.displayName="person";const vs=Ye;var Ge=function(t){return e.jsxs("svg",{...t,children:[e.jsx("path",{d:"M1.25 2.7087C1.25 2.24826 1.62326 1.875 2.0837 1.875H14.339C14.7995 1.875 15.1727 2.24826 15.1727 2.7087V9.31574C15.1727 9.77618 14.7995 10.1494 14.339 10.1494C13.8786 10.1494 13.5053 9.77618 13.5053 9.31574V3.54239H2.91739V16.7565H6.53772H8.34788H9.32435C9.78479 16.7565 10.158 17.1297 10.158 17.5902C10.158 18.0506 9.78479 18.4239 9.32435 18.4239H8.34788H2.0837C1.62326 18.4239 1.25 18.0506 1.25 17.5902V2.7087Z"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.21129 7.91935C7.70481 7.91935 7.29422 8.32993 7.29422 8.83641C7.29422 9.34289 7.70481 9.75348 8.21129 9.75348C8.71777 9.75348 9.12836 9.34289 9.12836 8.83641C9.12836 8.32993 8.71777 7.91935 8.21129 7.91935ZM5.62683 8.83641C5.62683 7.40905 6.78393 6.25195 8.21129 6.25195C9.63865 6.25195 10.7957 7.40905 10.7957 8.83641C10.7957 10.2638 9.63865 11.4209 8.21129 11.4209C6.78393 11.4209 5.62683 10.2638 5.62683 8.83641Z"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.62683 13.2133C5.62683 12.7529 6.00009 12.3796 6.46053 12.3796H9.96205C10.4225 12.3796 10.7957 12.7529 10.7957 13.2133C10.7957 13.6737 10.4225 14.047 9.96205 14.047H6.46053C6.00009 14.047 5.62683 13.6737 5.62683 13.2133Z"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.6406 11.3125C15.8547 11.3125 16.0503 11.434 16.145 11.626L17.1779 13.7184L19.4876 14.056C19.6994 14.087 19.8753 14.2355 19.9413 14.4391C20.0074 14.6427 19.9521 14.8662 19.7987 15.0156L18.1279 16.643L18.5222 18.9421C18.5584 19.1532 18.4716 19.3665 18.2984 19.4923C18.1252 19.6182 17.8955 19.6347 17.706 19.5351L15.6406 18.4489L13.5753 19.5351C13.3858 19.6347 13.1561 19.6182 12.9829 19.4923C12.8096 19.3665 12.7229 19.1532 12.7591 18.9421L13.1534 16.643L11.4825 15.0156C11.3292 14.8662 11.2739 14.6427 11.3399 14.4391C11.406 14.2355 11.5818 14.087 11.7937 14.056L14.1034 13.7184L15.1362 11.626C15.231 11.434 15.4265 11.3125 15.6406 11.3125ZM15.6406 13.1458L14.9815 14.4813C14.8996 14.6471 14.7414 14.7621 14.5584 14.7889L13.0835 15.0044L14.1503 16.0435C14.283 16.1727 14.3435 16.359 14.3122 16.5416L14.0606 18.0088L15.3788 17.3155C15.5427 17.2293 15.7386 17.2293 15.9025 17.3155L17.2207 18.0088L16.969 16.5416C16.9377 16.359 16.9983 16.1727 17.131 16.0435L18.1978 15.0044L16.7229 14.7889C16.5399 14.7621 16.3817 14.6471 16.2998 14.4813L15.6406 13.1458Z"})]})};Ge.defaultProps={width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"};Ge.displayName="external-issuer";const Xt=Ge;var Ce={},bs=t=>encodeURIComponent(t).replace(/[!'()*]/g,o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`),en="%[a-f0-9]{2}",Tt=new RegExp("("+en+")|([^%]+?)","gi"),Dt=new RegExp("("+en+")+","gi");function Me(t,o){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;o=o||1;var l=t.slice(0,o),p=t.slice(o);return Array.prototype.concat.call([],Me(l),Me(p))}function Cs(t){try{return decodeURIComponent(t)}catch{for(var o=t.match(Tt)||[],l=1;l<o.length;l++)t=Me(o,l).join(""),o=t.match(Tt)||[];return t}}function js(t){for(var o={"%FE%FF":"��","%FF%FE":"��"},l=Dt.exec(t);l;){try{o[l[0]]=decodeURIComponent(l[0])}catch{var p=Cs(l[0]);p!==l[0]&&(o[l[0]]=p)}l=Dt.exec(t)}o["%C2"]="�";for(var d=Object.keys(o),h=0;h<d.length;h++){var S=d[h];t=t.replace(new RegExp(S,"g"),o[S])}return t}var Ss=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return js(t)}},ws=(t,o)=>{if(!(typeof t=="string"&&typeof o=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(o==="")return[t];const l=t.indexOf(o);return l===-1?[t]:[t.slice(0,l),t.slice(l+o.length)]},Ps=function(t,o){for(var l={},p=Object.keys(t),d=Array.isArray(o),h=0;h<p.length;h++){var S=p[h],f=t[S];(d?o.indexOf(S)!==-1:o(S,f,t))&&(l[S]=f)}return l};(function(t){const o=bs,l=Ss,p=ws,d=Ps,h=n=>n==null;function S(n){switch(n.arrayFormat){case"index":return s=>(r,c)=>{const y=r.length;return c===void 0||n.skipNull&&c===null||n.skipEmptyString&&c===""?r:c===null?[...r,[g(s,n),"[",y,"]"].join("")]:[...r,[g(s,n),"[",g(y,n),"]=",g(c,n)].join("")]};case"bracket":return s=>(r,c)=>c===void 0||n.skipNull&&c===null||n.skipEmptyString&&c===""?r:c===null?[...r,[g(s,n),"[]"].join("")]:[...r,[g(s,n),"[]=",g(c,n)].join("")];case"comma":case"separator":return s=>(r,c)=>c==null||c.length===0?r:r.length===0?[[g(s,n),"=",g(c,n)].join("")]:[[r,g(c,n)].join(n.arrayFormatSeparator)];default:return s=>(r,c)=>c===void 0||n.skipNull&&c===null||n.skipEmptyString&&c===""?r:c===null?[...r,g(s,n)]:[...r,[g(s,n),"=",g(c,n)].join("")]}}function f(n){let s;switch(n.arrayFormat){case"index":return(r,c,y)=>{if(s=/\[(\d*)\]$/.exec(r),r=r.replace(/\[\d*\]$/,""),!s){y[r]=c;return}y[r]===void 0&&(y[r]={}),y[r][s[1]]=c};case"bracket":return(r,c,y)=>{if(s=/(\[\])$/.exec(r),r=r.replace(/\[\]$/,""),!s){y[r]=c;return}if(y[r]===void 0){y[r]=[c];return}y[r]=[].concat(y[r],c)};case"comma":case"separator":return(r,c,y)=>{const x=typeof c=="string"&&c.includes(n.arrayFormatSeparator),w=typeof c=="string"&&!x&&i(c,n).includes(n.arrayFormatSeparator);c=w?i(c,n):c;const U=x||w?c.split(n.arrayFormatSeparator).map(F=>i(F,n)):c===null?c:i(c,n);y[r]=U};default:return(r,c,y)=>{if(y[r]===void 0){y[r]=c;return}y[r]=[].concat(y[r],c)}}}function b(n){if(typeof n!="string"||n.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(n,s){return s.encode?s.strict?o(n):encodeURIComponent(n):n}function i(n,s){return s.decode?l(n):n}function T(n){return Array.isArray(n)?n.sort():typeof n=="object"?T(Object.keys(n)).sort((s,r)=>Number(s)-Number(r)).map(s=>n[s]):n}function C(n){const s=n.indexOf("#");return s!==-1&&(n=n.slice(0,s)),n}function k(n){let s="";const r=n.indexOf("#");return r!==-1&&(s=n.slice(r)),s}function a(n){n=C(n);const s=n.indexOf("?");return s===-1?"":n.slice(s+1)}function I(n,s){return s.parseNumbers&&!Number.isNaN(Number(n))&&typeof n=="string"&&n.trim()!==""?n=Number(n):s.parseBooleans&&n!==null&&(n.toLowerCase()==="true"||n.toLowerCase()==="false")&&(n=n.toLowerCase()==="true"),n}function m(n,s){s=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},s),b(s.arrayFormatSeparator);const r=f(s),c=Object.create(null);if(typeof n!="string"||(n=n.trim().replace(/^[?#&]/,""),!n))return c;for(const y of n.split("&")){if(y==="")continue;let[x,w]=p(s.decode?y.replace(/\+/g," "):y,"=");w=w===void 0?null:["comma","separator"].includes(s.arrayFormat)?w:i(w,s),r(i(x,s),w,c)}for(const y of Object.keys(c)){const x=c[y];if(typeof x=="object"&&x!==null)for(const w of Object.keys(x))x[w]=I(x[w],s);else c[y]=I(x,s)}return s.sort===!1?c:(s.sort===!0?Object.keys(c).sort():Object.keys(c).sort(s.sort)).reduce((y,x)=>{const w=c[x];return w&&typeof w=="object"&&!Array.isArray(w)?y[x]=T(w):y[x]=w,y},Object.create(null))}t.extract=a,t.parse=m,t.stringify=(n,s)=>{if(!n)return"";s=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},s),b(s.arrayFormatSeparator);const r=w=>s.skipNull&&h(n[w])||s.skipEmptyString&&n[w]==="",c=S(s),y={};for(const w of Object.keys(n))r(w)||(y[w]=n[w]);const x=Object.keys(y);return s.sort!==!1&&x.sort(s.sort),x.map(w=>{const U=n[w];return U===void 0?"":U===null?g(w,s):Array.isArray(U)?U.reduce(c(w),[]).join("&"):g(w,s)+"="+g(U,s)}).filter(w=>w.length>0).join("&")},t.parseUrl=(n,s)=>{s=Object.assign({decode:!0},s);const[r,c]=p(n,"#");return Object.assign({url:r.split("?")[0]||"",query:m(a(n),s)},s&&s.parseFragmentIdentifier&&c?{fragmentIdentifier:i(c,s)}:{})},t.stringifyUrl=(n,s)=>{s=Object.assign({encode:!0,strict:!0},s);const r=C(n.url).split("?")[0]||"",c=t.extract(n.url),y=t.parse(c,{sort:!1}),x=Object.assign(y,n.query);let w=t.stringify(x,s);w&&(w=`?${w}`);let U=k(n.url);return n.fragmentIdentifier&&(U=`#${g(n.fragmentIdentifier,s)}`),`${r}${w}${U}`},t.pick=(n,s,r)=>{r=Object.assign({parseFragmentIdentifier:!0},r);const{url:c,query:y,fragmentIdentifier:x}=t.parseUrl(n,r);return t.stringifyUrl({url:c,query:d(y,s),fragmentIdentifier:x},r)},t.exclude=(n,s,r)=>{const c=Array.isArray(s)?y=>!s.includes(y):(y,x)=>!s(y,x);return t.pick(n,c,r)}})(Ce);const le=bn,ks={parseNumbers:!1,parseBooleans:!1},Is={skipNull:!1,skipEmptyString:!1},Ts=(t,o)=>{var l,p;const{navigateMode:d="push",parseOptions:h,stringifyOptions:S}={},f=Object.assign(Object.assign({},ks),h),b=Object.assign(Object.assign({},Is),S),g=le.useLocation(),i=(l=le.useHistory)===null||l===void 0?void 0:l.call(le),T=(p=le.useNavigate)===null||p===void 0?void 0:p.call(le),C=is(),k=P.useRef(typeof t=="function"?t():t||{}),a=P.useMemo(()=>Ce.parse(g.search,f),[g.search]),I=P.useMemo(()=>Object.assign(Object.assign({},k.current),a),[a]);return[I,He(n=>{const s=typeof n=="function"?n(I):n;C(),i&&i[d]({hash:g.hash,search:Ce.stringify(Object.assign(Object.assign({},a),s),b)||"?"},g.state),T&&T({hash:g.hash,search:Ce.stringify(Object.assign(Object.assign({},a),s),b)||"?"},{replace:d==="replace",state:g.state})})]},Ds=Ts,As=Ft,Ne=Nn,Ue=Un,Rs=ds,At={role:As.types.RoleType.ROLE_APPLICATION},Ls=(t,o,l,p)=>{let d=l||At;const h=(0,Ue.isEthereumType)((0,Ue.DidType)(l));if(h?d=(0,Ne.WalletType)(l):d=(0,Ne.WalletType)(At),!(0,Ue.isValid)(t)){let S="";try{return h?S=t.slice(0,66):S=t,(0,Ne.fromSecretKey)(S,d)}catch(f){throw new Error(`Cannot get blocklet wallet with invalid blocklet did or custom sk: ${f.message}`)}}if(!o)throw new Error("Cannot get blocklet wallet with empty node sk");return(0,Rs.fromAppDid)(t,o,d,p||0)};var Es=Ls,tn=wt&&wt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const ce=tn(Xn),Os=Ft,ve=tn(Es),Ns=es,Us=(t,o,{returnWallet:l=!0}={})=>{var F,A;if(!t||typeof t!="object"||!Array.isArray(t.environments)||!(0,ce.default)(t,"meta.did"))throw new Error("Blocklet state must be an object");const{environments:p,configs:d=[]}=t,h=[...d,...p],S=h.find(D=>D.key==="BLOCKLET_APP_DESCRIPTION"),f=h.find(D=>D.key==="BLOCKLET_PASSPORT_COLOR"),b=h.find(D=>D.key==="BLOCKLET_APP_URL"),g=h.find(D=>D.key==="BLOCKLET_APP_TENANT_MODE"),{did:i,version:T}=t.meta,C=(0,Ns.getDisplayName)(t),k=(0,ce.default)(S,"value",t.meta.description),a=(0,ce.default)(f,"value","auto"),I=(0,ce.default)(b,"value",""),m=(0,ce.default)(g,"value","");if(!l)return{did:i,version:T,name:C,description:k,passportColor:a,appUrl:I,secret:"",wallet:null,permanentWallet:null,tenantMode:m};const n=h.find(D=>D.key==="BLOCKLET_APP_SK"),s=h.find(D=>D.key==="BLOCKLET_APP_CHAIN_TYPE")||h.find(D=>D.key==="BLOCKLET_WALLET_TYPE"),r=h.find(D=>D.key==="BLOCKLET_APP_PSK");let c;s&&(s.value==="ethereum"||s.value==="eth")&&(c=s.value);let y=null,x=null;if(n&&n.value)y=(0,ve.default)(n.value,void 0,c),r&&r.value&&r.value!==n.value&&(x=(0,ve.default)(r.value,void 0,c));else{if(!o||typeof o!="string")throw new Error("Node secret key must be a string");s?y=(0,ve.default)(t.meta.did,o,c):y=(0,ve.default)(t.meta.did,o)}const w=((A=(F=t.settings)==null?void 0:F.session)==null?void 0:A.salt)||"",U=Os.Hasher.SHA3.hash256(Pt.concat([y.secretKey,y.address,w].filter(Boolean).map(D=>Pt.from(D))));return{did:i,version:T,name:C,description:k,passportColor:a,appUrl:I,secret:U,wallet:y,permanentWallet:x||y,tenantMode:m}};var _s=Us;const Bs=Cn(_s);function Qe({teamDid:t,roles:o,apps:l,onCancel:p,onSuccess:d,onError:h,endpoint:S}){var I;const{api:f}=H(),{t:b,locale:g}=K(),i=Ve({loading:!1,error:null,activeStep:0,inviteInfo:null,role:"",remark:"",sourceAppPid:l.length>0?l[0].appPid:null,display:null,passportExpireTime:null,showPicker:!1}),T=async()=>{if(!i.role){i.error=b("team.member.error.passportEmpty");return}const m=i.remark.trim();i.error=null,i.loading=!0;try{let n=i.sourceAppPid??null;n===t&&(n=null);const s={teamDid:t,role:i.role,remark:m,sourceAppPid:n,passportExpireTime:i.passportExpireTime?i.passportExpireTime.toISOString():""};i.display&&(s.display={type:"url",content:i.display});const{inviteInfo:r}=await f.createMemberInvitation({input:s});i.inviteInfo=r,i.activeStep=1}catch(n){const s=ee(n);i.error=s,h(n)}finally{i.loading=!1}},C=o.find(m=>m.name===i.role),a=[{body:e.jsxs(O,{sx:{display:"flex",flexDirection:"column",gap:3},children:[l.length>1?e.jsxs(Be,{fullWidth:!0,children:[e.jsx(Fe,{children:b("common.sourceApp")}),e.jsx($e,{value:i.sourceAppPid,onChange:m=>{i.error=null,i.sourceAppPid=m.target.value},fullWidth:!0,label:b("common.passport"),disabled:i.loading,children:l.map(m=>e.jsx(je,{value:m.appPid,children:e.jsxs(O,{sx:{display:"flex",justifyContent:"space-between",gap:2,width:"100%"},children:[e.jsxs(O,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(_n,{did:m.appPid,size:28}),m.appName]}),e.jsx(Bn,{did:m.appPid,compact:!0,responsive:!1})]})},m.appPid))})]}):null,e.jsxs(Be,{fullWidth:!0,variant:"outlined",children:[e.jsx(Fe,{children:b("common.passport")}),e.jsx($e,{"data-cy":"invite-member-select-role",value:i.role,onChange:m=>{i.error=null,i.role=m.target.value},fullWidth:!0,label:b("common.passport"),disabled:i.loading,onKeyPress:m=>{m.key==="Enter"&&(m.preventDefault(),T())},children:o.filter(m=>m.name!=="owner").map(m=>e.jsx(je,{value:m.name,"data-cy":`invite-member-select-option-${m.name}`,children:e.jsxs(O,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(G,{variant:"subtitle1",children:m.title||m.name}),e.jsx(G,{variant:"caption",sx:{opacity:.7},children:m.description})]})},m.name))})]}),((I=C==null?void 0:C.extra)==null?void 0:I.display)==="custom"&&e.jsx(me,{label:b("common.display"),type:"url",value:i.display,onChange:m=>{i.error=null,i.display=m.target.value},fullWidth:!0,variant:"outlined",margin:"normal"}),e.jsx(me,{label:b("common.remark"),autoComplete:"off",variant:"outlined",fullWidth:!0,value:i.remark,onChange:m=>{i.error=null,i.remark=m.target.value},disabled:i.loading,"data-cy":"invite-member-input-remark"}),e.jsx(Yt,{value:i.passportExpireTime,onChange:m=>{i.passportExpireTime=m}})]}),cancel:b("common.cancel"),confirm:b("team.member.inviteDialog.createInviteLink"),onCancel:p,onConfirm:T},{body:()=>{var n,s;const m=we({inviteId:(n=i.inviteInfo)==null?void 0:n.inviteId,endpoint:S});return e.jsxs("div",{children:[e.jsx(O,{sx:{fontSize:16,fontWeight:"bold"},children:b("team.member.inviteDialog.createSuccessTip",{expireDate:pe((s=i.inviteInfo)==null?void 0:s.expireDate,g)})}),e.jsx("div",{style:{marginTop:"40px"}}),e.jsx(Te,{children:m})]})},confirm:b("common.copy"),onConfirm:()=>{var n;const m=we({inviteId:(n=i.inviteInfo)==null?void 0:n.inviteId,endpoint:S});as(m),Y.success(b("common.copied")),d()},cancel:b("common.cancel"),onCancel:p}][i.activeStep];return e.jsxs(ne,{title:b("common.invite"),fullWidth:!0,open:!0,showCloseButton:!1,actions:e.jsxs(e.Fragment,{children:[a.cancel&&e.jsx(W,{onClick:a.onCancel,color:"inherit",children:a.cancel}),e.jsxs(W,{onClick:a.onConfirm,color:"primary",disabled:i.loading||!i.role,variant:"contained",autoFocus:!0,children:[i.loading&&e.jsx(ie,{size:16}),a.confirm]})]}),children:[e.jsx(qe,{component:"div",children:typeof a.body=="function"?a.body():a.body}),!!i.error&&e.jsx(oe,{severity:"error",variant:"icon",children:i.error})]})}Qe.propTypes={teamDid:v.string.isRequired,onCancel:v.func.isRequired,onSuccess:v.func.isRequired,onError:v.func,roles:v.array,apps:v.array,endpoint:v.string};Qe.defaultProps={onError:()=>{},roles:[],apps:[],endpoint:""};function Je({teamDid:t,onCancel:o,onSuccess:l,onError:p,endpoint:d}){const{api:h,info:S}=H(),{api:f}=P.useContext(Fn),[b,g]=P.useState(!1),{t:i,locale:T}=K(),[C,k]=P.useState(""),[a,I]=P.useState(!1),[m,n]=P.useState(0),[s,r]=P.useState(""),[c,y]=P.useState(""),x=!!We(S,"ownerNft.did"),w=ms(async()=>{if(x){const{state:R}=await h.getDelegationState();return R}return{delegated:!0}});if(w.loading)return e.jsx(ne,{title:i("team.transferNode.inviteDialog.title"),fullWidth:!0,open:!0,onClose:o,children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(ie,{})})});if(w.error)return e.jsx(ne,{title:i("team.transferNode.inviteDialog.title"),fullWidth:!0,open:!0,onClose:o,children:e.jsx(oe,{severity:"error",variant:"icon",children:ee(w.error)})});const U=async()=>{k(null),g(!0);try{const{inviteInfo:R}=await h.createTransferInvitation({input:{teamDid:t,role:"owner",remark:c.trim()}});r(R),n(D.length-1)}catch(R){const V=ee(R);k(V),p(R)}finally{g(!1)}},F=()=>{I(!0),n(1)},A=()=>{I(!1),n(0)},D=[{body:e.jsxs(G,{component:"div",children:[e.jsxs(oe,{severity:"warning",children:[e.jsx(G,{children:i("team.transferNode.inviteDialog.tips.progress")}),e.jsx(G,{children:i("team.transferNode.inviteDialog.tips.newOwnerPermissions")})]}),e.jsx(oe,{severity:"warning",children:e.jsx(G,{children:i("team.transferNode.inviteDialog.tips.revoke")})}),e.jsx("div",{style:{marginTop:20,marginBottom:10}}),e.jsx(me,{label:i("common.remark"),autoComplete:"off",variant:"outlined",fullWidth:!0,style:{marginBottom:8},value:c,onChange:R=>{k(null),y(R.target.value)},disabled:b,"data-cy":"transfer-node-input-remark"}),e.jsx("div",{style:{marginTop:20,marginBottom:10}})]}),cancel:i("common.cancel"),confirm:i("team.transferNode.inviteDialog.createInviteLink"),onCancel:o,onConfirm:x&&!We(w,"value.delegated")?F:U},{body:()=>e.jsx($n,{action:"delegate-transfer-nft",open:a,locale:T,checkFn:f.get,onClose:A,onSuccess:U,checkTimeout:5*60*1e3,webWalletUrl:ts(S),extraParams:{targetDID:S.did},messages:{title:i("team.transferNode.delegateDialog.title"),scan:i("team.transferNode.delegateDialog.scan"),confirm:i("team.transferNode.delegateDialog.confirm"),success:i("team.transferNode.delegateDialog.success")},popup:!0})},{body:()=>{const R=we({inviteId:s.inviteId,endpoint:d});return e.jsxs("div",{children:[e.jsx(Fs,{children:i("team.transferNode.inviteDialog.createSuccessTip",{expireDate:pe(s.expireDate,T)})}),e.jsx("div",{style:{marginTop:"40px"}}),e.jsx(Te,{children:R})]})},confirm:i("common.confirm"),onConfirm:l}],E=D[m];return e.jsxs(ne,{title:i("team.transferNode.inviteDialog.title"),fullWidth:!0,open:!0,showCloseButton:!1,actions:e.jsxs(e.Fragment,{children:[E.cancel&&e.jsx(W,{onClick:E.onCancel,color:"inherit",children:E.cancel}),e.jsxs(W,{onClick:E.onConfirm,color:"primary",disabled:b,variant:"contained",autoFocus:!0,children:[b&&e.jsx(ie,{size:16}),E.confirm]})]}),children:[e.jsx(qe,{component:"div",children:typeof E.body=="function"?E.body():E.body}),!!C&&e.jsx(oe,{severity:"error",variant:"icon",children:C})]})}Je.propTypes={teamDid:v.string.isRequired,onCancel:v.func.isRequired,onSuccess:v.func.isRequired,onError:v.func,endpoint:v.string};Je.defaultProps={onError:()=>{},endpoint:""};const Fs=z.div`
|
|
2
2
|
font-size: 16px;
|
|
3
3
|
font-weight: bold;
|
|
4
4
|
`;var Xe=function(t){return e.jsxs("svg",{...t,children:[e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.88619 1.875C5.0541 1.875 4.24071 2.12174 3.54885 2.58402C2.857 3.0463 2.31777 3.70336 1.99934 4.47211C1.68092 5.24085 1.5976 6.08676 1.75994 6.90285C1.92227 7.71895 2.32295 8.46858 2.91133 9.05695C3.4997 9.64532 4.24933 10.046 5.06543 10.2083C5.88152 10.3707 6.72743 10.2874 7.49617 9.96893C8.26492 9.65051 8.92198 9.11128 9.38426 8.41942C9.84654 7.72757 10.0933 6.91417 10.0933 6.08209C10.0933 4.9663 9.65003 3.89621 8.86105 3.10723C8.07207 2.31825 7.00198 1.875 5.88619 1.875ZM4.11182 4.30773C4.58242 3.83714 5.22067 3.57276 5.88619 3.57276C6.38249 3.57276 6.86764 3.71993 7.2803 3.99566C7.69295 4.27139 8.01458 4.66329 8.20451 5.12181C8.39443 5.58033 8.44413 6.08487 8.3473 6.57164C8.25048 7.0584 8.01149 7.50552 7.66055 7.85645C7.30962 8.20739 6.8625 8.44638 6.37574 8.5432C5.88897 8.64003 5.38443 8.59033 4.92591 8.40041C4.46739 8.21048 4.07549 7.88885 3.79976 7.4762C3.52403 7.06354 3.37686 6.57839 3.37686 6.08209C3.37686 5.41657 3.64123 4.77832 4.11182 4.30773ZM4.20709 10.8302C3.0913 10.8302 2.02121 11.2735 1.23223 12.0624C0.443246 12.8514 0 13.9215 0 15.0373V17.8358C0 17.9955 0.12947 18.125 0.289179 18.125H1.40858C1.56829 18.125 1.69776 17.9955 1.69776 17.8358V15.0373C1.69776 14.3718 1.96214 13.7335 2.43273 13.2629C2.90332 12.7924 3.54157 12.528 4.20709 12.528H7.5653C7.89483 12.528 8.22113 12.5929 8.52558 12.719C8.83002 12.8451 9.10665 13.0299 9.33966 13.2629C9.57267 13.496 9.75751 13.7726 9.88361 14.077C10.0097 14.3815 10.0746 14.7078 10.0746 15.0373V17.8358C10.0746 17.9955 10.2041 18.125 10.3638 18.125H11.4832C11.6429 18.125 11.7724 17.9955 11.7724 17.8358V15.0373C11.7724 13.9215 11.3291 12.8514 10.5402 12.0624C9.75118 11.2735 8.68109 10.8302 7.5653 10.8302H4.20709Z"}),e.jsx("rect",{x:"12.5",y:"9.375",width:"7.5",height:"1.875",rx:"0.9375"})]})};Xe.defaultProps={width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"};Xe.displayName="forbid-login";const nn=Xe;var et=function(t){return e.jsxs("svg",{...t,children:[e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.88619 1.875C5.0541 1.875 4.24071 2.12174 3.54885 2.58402C2.857 3.0463 2.31777 3.70336 1.99934 4.47211C1.68092 5.24085 1.5976 6.08676 1.75994 6.90285C1.92227 7.71895 2.32295 8.46858 2.91133 9.05695C3.4997 9.64532 4.24933 10.046 5.06543 10.2083C5.88152 10.3707 6.72743 10.2874 7.49617 9.96893C8.26492 9.65051 8.92198 9.11128 9.38426 8.41942C9.84654 7.72757 10.0933 6.91417 10.0933 6.08209C10.0933 4.9663 9.65003 3.89621 8.86105 3.10723C8.07207 2.31825 7.00198 1.875 5.88619 1.875ZM4.11182 4.30773C4.58242 3.83714 5.22067 3.57276 5.88619 3.57276C6.38249 3.57276 6.86764 3.71993 7.2803 3.99566C7.69295 4.27139 8.01458 4.66329 8.20451 5.12181C8.39443 5.58033 8.44413 6.08487 8.3473 6.57164C8.25048 7.0584 8.01149 7.50552 7.66055 7.85645C7.30962 8.20739 6.8625 8.44638 6.37574 8.5432C5.88897 8.64003 5.38443 8.59033 4.92591 8.40041C4.46739 8.21048 4.07549 7.88885 3.79976 7.4762C3.52403 7.06354 3.37686 6.57839 3.37686 6.08209C3.37686 5.41657 3.64123 4.77832 4.11182 4.30773ZM4.20709 10.8302C3.0913 10.8302 2.02121 11.2735 1.23223 12.0624C0.443246 12.8514 0 13.9215 0 15.0373V17.8358C0 17.9955 0.12947 18.125 0.289179 18.125H1.40858C1.56829 18.125 1.69776 17.9955 1.69776 17.8358V15.0373C1.69776 14.3718 1.96214 13.7335 2.43273 13.2629C2.90332 12.7924 3.54157 12.528 4.20709 12.528H7.5653C7.89483 12.528 8.22113 12.5929 8.52558 12.719C8.83002 12.8451 9.10665 13.0299 9.33966 13.2629C9.57267 13.496 9.75751 13.7726 9.88361 14.077C10.0097 14.3815 10.0746 14.7078 10.0746 15.0373V17.8358C10.0746 17.9955 10.2041 18.125 10.3638 18.125H11.4832C11.6429 18.125 11.7724 17.9955 11.7724 17.8358V15.0373C11.7724 13.9215 11.3291 12.8514 10.5402 12.0624C9.75118 11.2735 8.68109 10.8302 7.5653 10.8302H4.20709Z"}),e.jsx("rect",{x:"12.5",y:"9.375",width:"7.5",height:"1.875",rx:"0.9375"}),e.jsx("rect",{x:"15.3125",y:"14.0625",width:"7.5",height:"1.875",rx:"0.9375",transform:"rotate(-90 15.3125 14.0625)"})]})};et.defaultProps={width:"20",height:"20",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"};et.displayName="allow-login";const sn=et;function ke(t){const{passport:o,onDelete:l,...p}=t;return e.jsxs($s,{...p,children:[o.title||o.name," ",!!l&&e.jsx(Wn,{"data-cy":"delete-issuance",className:"delete",onClick:l})]})}ke.propTypes={passport:v.object.isRequired,onDelete:v.func};ke.defaultProps={onDelete:null};const $s=z.span`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as C}from"./vendor-react-DEoibe3W.js";import{a as I,$,k as W,B as F,bb as Te,ar as me,b$ as H,a3 as ve,aI as q,br as ue,bs as xe,bt as fe,bI as Ke,cg as we,bd as Ae,ac as Se,a5 as De}from"./vendor-ux-did-connect-pzpsrvqx.js";import{d as Ie}from"./Edit-CiTb-w5P.js";import{f as Re}from"./index-8eXqqyHQ.js";import{r as ye}from"./passport-item-C1Pxlerj.js";import{D as R,n as O,aN as $e,G as Be,f as Pe}from"./index-CMYHZyLG.js";import{u as N}from"./dashboard-Cvfy6NEE.js";import{j as e,H as f,bo as X,br as Q,bn as J,q as Y,aa as g,al as Z,O as V,ab as _e,bs as Ne,bR as Ee,ah as E,T as P,ad as de,ak as Le}from"./vendor-mui-core-Bq8gXTan.js";import{v as We,K as Ue}from"./vendor-arcblock-CwufDgLV.js";import{T as he}from"./index-z4rrXifq.js";import{C as ge}from"./confirm-CYOuqhW9.js";import{a1 as qe,A as _}from"./vendor-utils-BfZ4tlod.js";import{C as G}from"./click-to-copy-By4fgGR7.js";import{D as ze}from"./delete-confirm-DkwIz2kG.js";import{P as Me}from"./permission-DQvXGutX.js";import{B as Fe}from"./bundle-avatar-o4aWU1WK.js";import{W as He}from"./did-address-NnOD1W_A.js";import{A as Oe}from"./actions-DnTVXQ_Z.js";import{u as Ve}from"./use-mobile-
|
|
1
|
+
import{r as C}from"./vendor-react-DEoibe3W.js";import{a as I,$,k as W,B as F,bb as Te,ar as me,b$ as H,a3 as ve,aI as q,br as ue,bs as xe,bt as fe,bI as Ke,cg as we,bd as Ae,ac as Se,a5 as De}from"./vendor-ux-did-connect-pzpsrvqx.js";import{d as Ie}from"./Edit-CiTb-w5P.js";import{f as Re}from"./index-8eXqqyHQ.js";import{r as ye}from"./passport-item-C1Pxlerj.js";import{D as R,n as O,aN as $e,G as Be,f as Pe}from"./index-CMYHZyLG.js";import{u as N}from"./dashboard-Cvfy6NEE.js";import{j as e,H as f,bo as X,br as Q,bn as J,q as Y,aa as g,al as Z,O as V,ab as _e,bs as Ne,bR as Ee,ah as E,T as P,ad as de,ak as Le}from"./vendor-mui-core-Bq8gXTan.js";import{v as We,K as Ue}from"./vendor-arcblock-CwufDgLV.js";import{T as he}from"./index-z4rrXifq.js";import{C as ge}from"./confirm-CYOuqhW9.js";import{a1 as qe,A as _}from"./vendor-utils-BfZ4tlod.js";import{C as G}from"./click-to-copy-By4fgGR7.js";import{D as ze}from"./delete-confirm-DkwIz2kG.js";import{P as Me}from"./permission-DQvXGutX.js";import{B as Fe}from"./bundle-avatar-o4aWU1WK.js";import{W as He}from"./did-address-NnOD1W_A.js";import{A as Oe}from"./actions-DnTVXQ_Z.js";import{u as Ve}from"./use-mobile-CtTQsfXN.js";import{T as pe}from"./table-tips-BzPqsKYQ.js";import{y as Ge}from"./vendor-hooks-DqdmWCmo.js";import"./lottie-web-jYmAQWuC.js";import"./util-BQAJqeb4.js";import"./base32-DUSifB4M.js";import"./useLocalStorage-CaPDqrQ7.js";import"./PlayArrow-BqVYRyLK.js";import"./get-safe-url-B0-S5PGZ.js";import"./session-BGdAM8zS.js";import"./use-blocklet-logo-CWdlYyrq.js";import"./InfoOutlined-BVWbftGI.js";import"./dot-4jhL56kz.js";import"./useAsync-C62uE2pS.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-DwzRjjku.js";import"./vendor-mui-x-1nqAyytV.js";import"./AdapterDayjs-BRnJ9bMs.js";import"./MoreHoriz-ChJ3K52h.js";function ee({value:t}){const{t:s,locale:m}=I(),c=new Date;return new Date(t)<c?e.jsxs("span",{style:{color:"red"},children:[e.jsx($,{value:t,locale:m}),`${s("setting.accessKey.expired",{time:""})}`]}):e.jsx($,{value:t,locale:m,type:"all"})}ee.propTypes={value:f.string.isRequired};function te({value:t,onChange:s,...m}){const{t:c}=I(),r=C.useMemo(()=>[{value:"signature",title:c("setting.accessKey.signature"),description:c("setting.accessKey.signatureDesc")},{value:"simple",title:c("setting.accessKey.simple"),description:c("setting.accessKey.simpleDesc")}],[c]);return e.jsxs(X,{style:{width:"100%"},variant:"outlined",...m,children:[e.jsx(Q,{children:c("setting.accessKey.authType")}),e.jsx(J,{value:t,onChange:s,fullWidth:!0,label:c("setting.accessKey.authType"),children:r.map(i=>e.jsx(Y,{value:i.value,children:e.jsxs(g,{children:[e.jsx("span",{children:i.title}),e.jsx(g,{maxWidth:510,fontSize:12,color:"#999",whiteSpace:"normal",children:i.description})]})},i.value))})]})}te.propTypes={value:f.string.isRequired,onChange:f.func.isRequired};const U=()=>{const t=W.RBAC_CONFIG.roles.filter(r=>r.passport),{inService:s}=R(),{roles:m}=N(),c=[...t,...s?m:[]];return qe(c,"name").filter(r=>r.name!==W.ROLES.OWNER)};function se(t){const{remark:s,onCreate:m}=t,{api:c}=R(),{teamDid:r}=N(),{t:i}=I(),[b,j]=C.useState(!1),[y,k]=C.useState(null),d=U(),w=()=>{j(!1),k(null)},v=async n=>{const{remark:x,passport:h,authType:o}=n;j(!0);const l=await c.createAccessKey({input:{teamDid:r,remark:x.trim(),passport:h,expireAt:n.expireAt?new Date(n.expireAt).getTime():null,authType:o}}),{data:K}=l;m(K),k(null),j(!1)},u={title:`${i("common.create")} ${i("accessKey")}`,description:(n,x,h)=>e.jsxs(Z,{gap:3,children:[e.jsx(V,{label:i("setting.accessKey.tip"),autoComplete:"off",variant:"outlined",name:"remark",inputProps:{"data-cy":"remark-input"},fullWidth:!0,autoFocus:!0,margin:"dense",value:n.remark,onChange:o=>{x({...n,remark:o.target.value,__disableConfirm:!n.passport||!o.target.value.trim()}),o.target.value.trim()?h(""):h(i("setting.accessKey.remarkInvalid"))}}),e.jsxs(X,{style:{width:"100%"},variant:"outlined",children:[e.jsx(Q,{children:i("setting.accessKey.passport")}),e.jsx(J,{"data-cy":"create-access-key-select-passport",value:n.passport,onChange:o=>{const l=o.target.value;h(null),x({...n,passport:l,__disableConfirm:!n.remark||!l})},fullWidth:!0,label:i("setting.accessKey.passport"),disabled:b,children:d.map(o=>e.jsx(Y,{value:o.name,"data-cy":`create-access-key-passport-option-${o.name}`,children:e.jsxs(g,{children:[e.jsx("span",{children:o.title||o.name}),e.jsx(g,{maxWidth:440,fontSize:12,color:"#999",whiteSpace:"normal",textAlign:"justify",children:o.description})]})},o.name))})]}),e.jsx(te,{value:n.authType,onChange:o=>{x({...n,authType:o.target.value})}}),e.jsx(he,{placeholder:i("setting.accessKey.expireTime"),value:n.expireAt,onChange:o=>{x({...n,expireAt:o,__disableConfirm:!n.passport||!n.remark||!o})}})]}),confirm:i("common.confirm"),cancel:i("common.cancel"),color:"primary",params:{remark:s,authType:"signature",__disableConfirm:!s.trim()},onConfirm:v,onCancel:w};return e.jsxs(e.Fragment,{children:[e.jsxs(F,{sx:{color:"common.white"},edge:"end",variant:"contained",color:"primary","data-cy":"add-access-key-btn",onClick:()=>k(u),className:"rule-action",children:[b?e.jsx(_e,{size:16}):e.jsx(We,{style:{fontSize:16}}),i("common.create")]}),y&&e.jsx(ge,{title:y.title,description:y.description,confirm:y.confirm,color:y.color,cancel:y.cancel,params:y.params,onConfirm:y.onConfirm,onCancel:y.onCancel})]})}se.propTypes={remark:f.string,onCreate:f.func};se.defaultProps={onCreate:()=>{},remark:""};function ne(t){var h,o;const{onConfirm:s,accessKeyId:m,accessKeySecret:c,hideSecret:r}=t,{t:i}=C.useContext(Te),[b,j]=C.useState(!1),[y,k]=C.useState(()=>r),d=R(),w=()=>{k(!y)},v=l=>{j(l.target.checked)},u=_(window.location.origin,(o=(h=d==null?void 0:d.info)==null?void 0:h.routing)==null?void 0:o.adminPath),n=C.useMemo(()=>{var l,K,p,D;return r?`const Client = require('@abtnode/client');
|
|
2
2
|
const ensureServerEndpoint = require('@abtnode/util/lib/ensure-server-endpoint');
|
|
3
3
|
const { joinURL } = require('ufo');
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as S,g as Ee,b as dt}from"./vendor-react-DEoibe3W.js";import{a as pt,l as ne}from"./vendor-hooks-DqdmWCmo.js";import{j as e,aa as y,H as w,ah as H,E as ut,T as E,X as mt,al as te,ad as Y,ab as $,ak as $e,a9 as ft,I as q,O as W,q as oe,N as ht,br as Me,cl as Oe,cm as ee,bT as We,bq as qe,bx as xt,bs as gt,bR as yt,v as jt,y as vt,bn as bt,s as Ct}from"./vendor-mui-core-Bq8gXTan.js";import{a as L,ar as U,ax as St,$ as fe,a3 as A,ac as xe,k as G,aV as Tt,B as _,r as wt,a5 as ge,bJ as He,i as Ue,bg as Pt,c0 as Ae,bu as It,bI as Rt}from"./vendor-ux-did-connect-pzpsrvqx.js";import{D as F,y as Ge,n as Dt,V as J,G as kt,ad as At,f as Ft,b as re,aE as Nt,T as Ve}from"./index-CMYHZyLG.js";import{l as Lt,c as Bt,v as ye,M as X}from"./vendor-arcblock-CwufDgLV.js";import{W as je}from"./did-address-NnOD1W_A.js";import{u as M}from"./dashboard-Cvfy6NEE.js";import{r as ve,a as be,b as Ce,c as ie,d as zt,e as Ke,u as _t,f as Et}from"./passport-item-C1Pxlerj.js";import{p as Ye}from"./util-BQAJqeb4.js";import{u as $t}from"./use-mobile-
|
|
1
|
+
import{r as S,g as Ee,b as dt}from"./vendor-react-DEoibe3W.js";import{a as pt,l as ne}from"./vendor-hooks-DqdmWCmo.js";import{j as e,aa as y,H as w,ah as H,E as ut,T as E,X as mt,al as te,ad as Y,ab as $,ak as $e,a9 as ft,I as q,O as W,q as oe,N as ht,br as Me,cl as Oe,cm as ee,bT as We,bq as qe,bx as xt,bs as gt,bR as yt,v as jt,y as vt,bn as bt,s as Ct}from"./vendor-mui-core-Bq8gXTan.js";import{a as L,ar as U,ax as St,$ as fe,a3 as A,ac as xe,k as G,aV as Tt,B as _,r as wt,a5 as ge,bJ as He,i as Ue,bg as Pt,c0 as Ae,bu as It,bI as Rt}from"./vendor-ux-did-connect-pzpsrvqx.js";import{D as F,y as Ge,n as Dt,V as J,G as kt,ad as At,f as Ft,b as re,aE as Nt,T as Ve}from"./index-CMYHZyLG.js";import{l as Lt,c as Bt,v as ye,M as X}from"./vendor-arcblock-CwufDgLV.js";import{W as je}from"./did-address-NnOD1W_A.js";import{u as M}from"./dashboard-Cvfy6NEE.js";import{r as ve,a as be,b as Ce,c as ie,d as zt,e as Ke,u as _t,f as Et}from"./passport-item-C1Pxlerj.js";import{p as Ye}from"./util-BQAJqeb4.js";import{u as $t}from"./use-mobile-CtTQsfXN.js";import{w as V,P as Ze}from"./permission-DQvXGutX.js";import{C as Mt}from"./Google-C28yeMZW.js";import{P as Z,aA as Ot,K as Wt}from"./vendor-utils-BfZ4tlod.js";import{E as le}from"./EditIcon-DfiDnAsm.js";import{C as Se}from"./confirm-CYOuqhW9.js";import{L as Je}from"./list-header-C7gle0n0.js";import{f as se}from"./index-8eXqqyHQ.js";import{_ as qt}from"./useSetState-CWq0AVWn.js";import{L as Ht}from"./LockIcon-BEG59s5q.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-CaPDqrQ7.js";import"./PlayArrow-BqVYRyLK.js";import"./get-safe-url-B0-S5PGZ.js";import"./session-BGdAM8zS.js";import"./use-blocklet-logo-CWdlYyrq.js";import"./InfoOutlined-BVWbftGI.js";import"./dot-4jhL56kz.js";import"./useAsync-C62uE2pS.js";import"./use-mobile-DwzRjjku.js";import"./base32-DUSifB4M.js";import"./cloneDeep-CDl5kZTY.js";const Fe="info";function Te({createPassportSvg:c,passport:o,onCancel:d,onSwitchPassport:f}){const{t:u}=L(),l=pt({tab:Fe}),h={info:{label:u("common.basicInfo"),value:Fe,component:()=>e.jsx(Qe,{passport:o,createPassportSvg:c})},logs:{label:u("common.logs"),value:"logs",component:()=>e.jsx(tt,{passport:o})},related:{label:u("team.passport.related"),value:"related",component:()=>e.jsx(st,{passport:o,onSwitchPassport:f})}},s=Object.values(h).map(({label:n,value:t})=>({label:n,value:t})).filter(n=>n.value==="related"?o.parentDid:!0),m=h[l.tab]||h.info,r=n=>{l.tab=n};return e.jsx(U,{title:u("common.passport"),onClose:d,open:!0,PaperProps:{style:{maxWidth:800,minHeight:"80vh"}},fullWidth:!0,children:e.jsxs(Ut,{children:[e.jsx(y,{className:"tabs",children:e.jsx(St,{tabs:s,current:l.tab,onChange:r,scrollButtons:"auto"})}),e.jsx(y,{className:"body",children:e.jsx(m.component,{})})]})})}Te.propTypes={createPassportSvg:w.func.isRequired,passport:w.object.isRequired,onCancel:w.func.isRequired,onSwitchPassport:w.func};Te.defaultProps={onSwitchPassport:()=>{}};const Ut=H(y)`
|
|
2
2
|
margin-top: -16px;
|
|
3
3
|
|
|
4
4
|
.tabs {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as _,a3 as q,k as ve,r as se,br as Ee,bs as Ce,bt as Se,I as U,b_ as Q,b$ as X,a5 as Me,ac as Le,bI as _e}from"./vendor-ux-did-connect-pzpsrvqx.js";import{t as Be,l as Te,j as Fe}from"./vendor-hooks-DqdmWCmo.js";import{r as C,b as ie}from"./vendor-react-DEoibe3W.js";import{d as re}from"./InfoOutlined-BVWbftGI.js";import{i as He,v as Ne}from"./vendor-arcblock-CwufDgLV.js";import{D as V,aC as Ue,aD as Z,G as Ie,y as Ke}from"./index-CMYHZyLG.js";import{u as Y}from"./dashboard-Cvfy6NEE.js";import{u as Ve}from"./use-mobile-DwzRjjku.js";import{H as o,j as e,D as Ye,aj as Je,t as Ge,aa as d,O as je,T as S,ab as H,ak as le,z as Qe,y as N,bs as ye,bR as ee,ad as A,L as te,A as oe,aq as Xe,E as M,I as F,C as Ze,bq as et,al as D,cg as tt,X as Re,a9 as ae,s as de,as as ne,bp as ot,b7 as nt,b8 as st,an as it,b$ as rt,v as lt,ch as at,ci as dt,cj as ct,ck as ut}from"./vendor-mui-core-Bq8gXTan.js";import{d as pt}from"./ExpandLess-CcLTbsdW.js";import{b as De,z as ht,A as xt}from"./vendor-utils-BfZ4tlod.js";import{C as mt}from"./confirm-CYOuqhW9.js";import{A as ft}from"./actions-DnTVXQ_Z.js";import{T as we}from"./table-tips-BzPqsKYQ.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-CaPDqrQ7.js";import"./index-8eXqqyHQ.js";import"./PlayArrow-BqVYRyLK.js";import"./get-safe-url-D5KSEAKZ.js";import"./session-BGdAM8zS.js";import"./use-blocklet-logo-CWdlYyrq.js";import"./dot-4jhL56kz.js";import"./useAsync-C62uE2pS.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-CtTQsfXN.js";import"./MoreHoriz-ChJ3K52h.js";const gt=s=>{var b,T;const[c,p]=C.useState(null),[v,l]=C.useState(!s),[k,u]=C.useState(null),{blocklet:f}=Ie(),i=(T=(b=f==null?void 0:f.site)==null?void 0:b.domainAliases[0])==null?void 0:T.value,y=C.useMemo(()=>{const j={};return c&&(c.sources.forEach(n=>{j[n.did]={source:n,events:[],count:0}}),c.events.forEach(n=>{j[n.source]&&(j[n.source].events.push(n),j[n.source].count+=1)})),j},[c]),w=async()=>{try{if(l(!0),!i)return;const n=await(await fetch(`https://${i}${ve.WELLKNOWN_SERVICE_PATH_PREFIX}/openevent.json`)).json();p(n),u(null)}catch(j){u(j instanceof Error?j:new Error(String(j)))}finally{l(!1)}};return C.useEffect(()=>{w()},[i]),{openEvent:c,setOpenEvent:p,eventsBySource:y,loading:v,error:k,loadData:w}};function ce({eventsBySource:s,selectedEvents:c,setSelectedEvents:p,error:v}){const{t:l}=_(),[k,u]=C.useState({}),f=C.useMemo(()=>{const n={};return Object.entries(s).forEach(([h,{events:x}])=>{const E=x.filter(I=>c[`${I.type}-${I.source}`]).length;n[h]=E}),n},[s,c]),i=C.useMemo(()=>Object.values(f).reduce((n,h)=>n+h,0),[f]),y=C.useMemo(()=>Object.values(s).reduce((n,{events:h})=>n+h.length,0),[s]),w=(n,h)=>{h.stopPropagation(),u({...k,[n]:!k[n]})},b=n=>{const h=`${n.type}-${n.source}`;p(x=>({...x,[h]:!x[h]}))},T=(n,h)=>{const x={};n.forEach(E=>{const I=`${E.type}-${E.source}`;x[I]=!h}),p(E=>({...E,...x}))},j=n=>{const h={};Object.values(s).forEach(({events:x})=>{x.forEach(E=>{const I=`${E.type}-${E.source}`;h[I]=n.target.checked})}),p(h)};return e.jsxs(d,{sx:{width:"100%"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ye,{control:e.jsx(ee,{onChange:j,checked:i>0&&i===y}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[l("webhookEndpoint.selectAllEvents"),e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:e.jsx(A,{title:l("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(re,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),i>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:l("webhookEndpoint.selectedEventsCount",{count:i})})]}),e.jsx(d,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(te,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:"4px"},children:Object.entries(s).map(([n,{source:h,events:x,count:E}],I)=>{const O=f[n]>0,R=f[n]===x.length&&x.length>0,$=k[n];return e.jsxs(ie.Fragment,{children:[e.jsx(oe,{sx:{borderBottom:({palette:r})=>I<Object.keys(s).length-1?`1px solid ${r.divider}`:"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(d,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:r=>{r.target.closest(".MuiFormControlLabel-root")||w(n,r)},children:[e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:x.length>0&&e.jsx(ye,{control:e.jsx(ee,{checked:R,indeterminate:O&&!R,onChange:r=>{r.stopPropagation(),T(x,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.logo&&e.jsx(Xe,{src:h.logo,sx:{width:24,height:24}}),e.jsx(d,{children:h.title||n}),O&&e.jsx(M,{label:l("webhookEndpoint.selectedCount",{count:f[n]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:r=>`${r.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(d,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",color:"text.secondary",sx:{mr:1},children:l("webhookEndpoint.eventsCount",{count:E})}),x.length>0&&e.jsx(F,{size:"small",edge:"end",children:$?e.jsx(pt,{}):e.jsx(He,{})})]})]})}),x.length>0&&e.jsx(Ze,{in:$,timeout:"auto",unmountOnExit:!0,children:e.jsx(te,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:x.map(r=>{const a=`${r.type}-${r.source}`,t=!!c[a];return e.jsx(oe,{dense:!0,sx:{py:.75},onClick:()=>b(r),children:e.jsxs(d,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(ee,{checked:t,sx:{mr:1}}),e.jsxs(d,{children:[e.jsx(S,{variant:"body1",sx:{cursor:"pointer",color:"text.primary"},children:r.type}),e.jsx(S,{variant:"caption",color:"text.secondary",sx:{display:"block",cursor:"pointer"},children:r.description})]})]})},a)})})})]},n)})})}),v&&e.jsx(et,{error:!0,sx:{mt:1},children:v})]})}ce.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};ce.defaultProps={error:null};function ue({id:s,url:c,description:p,enabledEvents:v,onSubmit:l,onClose:k}){var r;const{t:u}=_(),[f,i]=C.useState({}),{teamDid:y}=Y(),{api:w}=V(),{loading:b,error:T,eventsBySource:j}=gt(),{control:n,handleSubmit:h,formState:{errors:x},reset:E,setValue:I,trigger:O}=Ue({defaultValues:{url:"",description:""}});C.useEffect(()=>{const a=Object.values(f).some(t=>t);I("selectedEvents",a?"valid":""),O("selectedEvents")},[f,I,O]);const R=()=>{i({}),E(),k()},$=async a=>{const t=Object.keys(f).filter(m=>f[m]),g={url:a.url,description:a.description,enabledEvents:t.map(m=>{const[P,z]=m.split("-");return!P||!z?null:{type:P,source:z}}).filter(Boolean)};try{if(s){const m=await w.updateWebhookEndpoint({input:{teamDid:y,id:s,data:g}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),l(m)}else{const m=await w.createWebhookEndpoint({input:{teamDid:y,input:g}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),l(m)}}catch(m){q.error(m==null?void 0:m.message)}R()};return C.useEffect(()=>{E({url:c,description:p}),i(v.reduce((a,t)=>(a[`${t.type}-${t.source}`]=!0,a),{}))},[E,i,c,p,v]),e.jsx(Ye,{open:!0,onClose:R,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:h($),children:[e.jsx(Je,{children:u(s?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Ge,{children:e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(Z,{name:"url",control:n,rules:{required:u("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:u("webhookEndpoint.validation.urlInvalid")}},render:({field:a})=>{var t;return e.jsx(je,{...a,label:u("webhookEndpoint.url.label"),fullWidth:!0,error:!!x.url,helperText:(t=x.url)==null?void 0:t.message})}}),e.jsx(Z,{name:"description",control:n,rules:{required:u("webhookEndpoint.validation.descriptionRequired")},render:({field:a})=>{var t;return e.jsx(je,{...a,label:u("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!x.description,helperText:(t=x.description)==null?void 0:t.message})}}),e.jsx(Z,{name:"selectedEvents",control:n,rules:{required:u("webhookEndpoint.validation.eventRequired")},render:({field:a})=>e.jsx("input",{type:"hidden",...a})}),!b&&j&&Object.keys(j).length>0&&e.jsx(ce,{eventsBySource:j,selectedEvents:f,setSelectedEvents:i,error:(r=x.selectedEvents)==null?void 0:r.message}),!b&&(!j||Object.keys(j).length===0)&&e.jsx(S,{color:"text.secondary",children:u("webhookEndpoint.noAvailableEvents")}),b&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(H,{size:20})}),T&&e.jsx(le,{severity:"error",children:u("webhookEndpoint.loadingError",{message:T==null?void 0:T.message})})]})}),e.jsxs(Qe,{sx:{p:"8px 24px 24px"},children:[e.jsx(N,{onClick:R,children:u("common.cancel")}),e.jsx(N,{type:"submit",variant:"contained",color:"primary",children:u(s?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}ue.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};ue.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function Pe(s){switch(s){case"enabled":return"success";case"disabled":default:return"default"}}const bt=(s="en")=>s==="tw"?"zh":s;function K(s,c="YYYY-MM-DD HH:mm:ss",p="en"){return s?Ke(s).locale(bt(p)).format(c):"-"}function jt(s){return typeof s=="number"?!1:De(s)}function yt(s){return s>=200&&s<300}function W(s){const c=jt(s.value);return e.jsxs(e.Fragment,{children:[e.jsxs(D,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[s.label,!!s.tip&&e.jsx(A,{title:s.tip,children:e.jsx(tt,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:c?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:c?"-":s.value})]}),s.divider&&e.jsx(Re,{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 pe(s){return e.jsxs(D,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:s.mb,mt:s.mt,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:s.title}),s.children]})}pe.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};pe.defaultProps={children:null,mb:1.5,mt:1.5};var he={},wt=ae;Object.defineProperty(he,"__esModule",{value:!0});var ze=he.default=void 0,kt=wt(se()),vt=e;ze=he.default=(0,kt.default)((0,vt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5"}),"Pending");var xe={},Et=ae;Object.defineProperty(xe,"__esModule",{value:!0});var Oe=xe.default=void 0,Ct=Et(se()),St=e;Oe=xe.default=(0,Ct.default)((0,St.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"}),"CheckCircleOutlined");var me={},Tt=ae;Object.defineProperty(me,"__esModule",{value:!0});var We=me.default=void 0,It=Tt(se()),Rt=e;We=me.default=(0,It.default)((0,Rt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"ErrorOutlined");const Dt={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},Pt=s=>{const c={};return s.forEach(p=>{var l;const v=new Date(p.createdAt).toLocaleDateString();c[v]||(c[v]=[]),(l=c[v])==null||l.push(p)}),c};function fe({eventId:s,webhookEndpointId:c,event:p}){const{api:v,ws:{useSubscription:l}}=V(),{t:k}=_(),{teamDid:u}=Y(),{blocklet:f}=Ie(),{data:i,loadMore:y,loadingMore:w,loading:b,mutate:T}=Be(t=>{const m=t?Math.ceil(t.list.length/15)+1:1;return v.getWebhookAttempts({input:{teamDid:u,input:{eventId:s,webhookId:c},paging:{page:m,pageSize:15}}})},{reloadDeps:[s,c]}),j=(i==null?void 0:i.list)||[],[n,h]=C.useState(null),[x,E]=C.useState(!1),I=Pt(j);if(C.useEffect(()=>{!n&&(i!=null&&i.list.length)&&h(i.list[0])},[i==null?void 0:i.list.length,n]),l(ve.EVENTS.WEBHOOK_ATTEMPT,t=>{T(g=>{var P,z;if(g.list.find(L=>L.id===t.id)){const L=g.list.map(B=>B.id===t.id?{...B,...t}:B);return{...g,list:L}}return t.endpoint=(P=g.list[0])==null?void 0:P.endpoint,t.event=(z=g.list[0])==null?void 0:z.event,{...g,list:[t,...g.list]}})},[]),b)return e.jsx(H,{});const O=i&&i.list.length<i.paging.total,R=async()=>{n&&(E(!0),await v.retryWebhookAttempt({input:{teamDid:u,eventId:n.event.id,webhookId:c,attemptId:n.id}}).finally(()=>{setTimeout(()=>{E(!1)},1e3)}))},$=t=>{var g,m,P,z,L;if(t.responseBody&&((g=t.responseBody)!=null&&g.sessionId)&&((m=t.responseBody)!=null&&m.projectId)&&((P=t.responseBody)!=null&&P.agentId)){const B=(L=(z=f==null?void 0:f.site)==null?void 0:z.domainAliases[0])==null?void 0:L.value,J=(f.children||[]).find(G=>{var be;return((be=G==null?void 0:G.meta)==null?void 0:be.name)==="ai-studio"}),qe=ht(xt(`https://${B}`,(J==null?void 0:J.mountPoint)||"","projects",t.responseBody.projectId,"logs/main"),{sessionId:t.responseBody.sessionId,agentId:t.responseBody.agentId});return e.jsx(F,{sx:{fontSize:20},onClick:()=>window.open(qe,"_blank"),children:e.jsx(d,{component:U,icon:Q})})}return null},r=t=>t.status==="pending"?e.jsx(ze,{color:"warning"}):yt(t.responseStatus)?e.jsx(Oe,{color:"success"}):e.jsx(We,{color:"error"}),a=(n==null?void 0:n.triggeredFrom)&&((i==null?void 0:i.list)||[]).find(t=>t.id===n.triggeredFrom);return e.jsxs(zt,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ne,{item:!0,xs:12,md:4,height:1,children:De(Object.keys(I))?e.jsx(S,{color:"text.secondary",children:k("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(te,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(I).map(([t,g])=>e.jsxs(ie.Fragment,{children:[e.jsx(ot,{sx:{p:0},children:t}),g.map(m=>e.jsxs(oe,{sx:{cursor:"pointer",px:1},onClick:()=>h(m),selected:n&&(n==null?void 0:n.id)===(m==null?void 0:m.id),secondaryAction:e.jsx(S,{color:"text.secondary",children:K(m.createdAt,"HH:mm:ss")}),children:[e.jsx(nt,{sx:{minWidth:0,mr:1.5},children:r(m)}),e.jsx(st,{primary:e.jsx(S,{color:"text.primary",children:m.event.type})})]},m.id))]},t))}),O&&e.jsx(d,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(N,{variant:"text",type:"button",color:"inherit",onClick:y,disabled:w,sx:{color:t=>t.palette.text.disabled},children:k(w?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ne,{item:!0,xs:12,md:8,height:1,children:[n&&e.jsxs(D,{height:1,overflow:"auto",direction:"column",spacing:2,sx:{pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h4",children:k(`common.${n.status}`)}),e.jsx(d,{children:$(n)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[a&&e.jsx(A,{componentsProps:{tooltip:{sx:{maxWidth:400}}},placement:"left",title:e.jsxs(D,{gap:1,sx:{cursor:"pointer",".did-address-text":{color:"common.white"}},onClick:()=>h(a),children:[e.jsx(Ee,{showDid:!0,did:n.triggeredBy,cardType:Ce.Detailed,infoType:Se.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(Re,{}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(S,{variant:"body2",sx:{color:"primary.main"},children:k("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"body2",children:n.id}),e.jsx(F,{onClick:()=>h(a),children:e.jsx(d,{component:U,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),children:e.jsx(F,{onClick:()=>h(a),children:e.jsx(d,{component:U,icon:Q,sx:{fontSize:16}})})}),e.jsxs(N,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:x,children:[e.jsx(d,{component:U,icon:Dt,sx:{fontSize:16,animation:x?"spin 1s linear infinite":"none",mr:.5}}),k("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(S,{variant:"h6",children:[k("webhookEndpoint.response")," (",n.responseStatus,")"]}),e.jsx(X,{language:"json",children:JSON.stringify(n.responseBody,null,2)})]}),e.jsxs(d,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:k("webhookEndpoint.request")})}),e.jsx(X,{language:"json",sx:{margin:0},children:JSON.stringify(n.event,null,2)})]})]}),(i==null?void 0:i.list.length)===0&&p&&e.jsxs(d,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:k("webhookEndpoint.eventData")})}),e.jsx(X,{language:"json",sx:{margin:0},children:JSON.stringify(p.data,null,2)})]})]})]})}fe.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};fe.defaultProps={eventId:"",webhookEndpointId:"",event:null};const zt=de(ne)`
|
|
1
|
+
import{a as _,a3 as q,k as ve,r as se,br as Ee,bs as Ce,bt as Se,I as U,b_ as Q,b$ as X,a5 as Me,ac as Le,bI as _e}from"./vendor-ux-did-connect-pzpsrvqx.js";import{t as Be,l as Te,j as Fe}from"./vendor-hooks-DqdmWCmo.js";import{r as C,b as ie}from"./vendor-react-DEoibe3W.js";import{d as re}from"./InfoOutlined-BVWbftGI.js";import{i as He,v as Ne}from"./vendor-arcblock-CwufDgLV.js";import{D as V,aC as Ue,aD as Z,G as Ie,y as Ke}from"./index-CMYHZyLG.js";import{u as Y}from"./dashboard-Cvfy6NEE.js";import{u as Ve}from"./use-mobile-CtTQsfXN.js";import{H as o,j as e,D as Ye,aj as Je,t as Ge,aa as d,O as je,T as S,ab as H,ak as le,z as Qe,y as N,bs as ye,bR as ee,ad as A,L as te,A as oe,aq as Xe,E as M,I as F,C as Ze,bq as et,al as D,cg as tt,X as Re,a9 as ae,s as de,as as ne,bp as ot,b7 as nt,b8 as st,an as it,b$ as rt,v as lt,ch as at,ci as dt,cj as ct,ck as ut}from"./vendor-mui-core-Bq8gXTan.js";import{d as pt}from"./ExpandLess-CcLTbsdW.js";import{b as De,z as ht,A as xt}from"./vendor-utils-BfZ4tlod.js";import{C as mt}from"./confirm-CYOuqhW9.js";import{A as ft}from"./actions-DnTVXQ_Z.js";import{T as we}from"./table-tips-BzPqsKYQ.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-CaPDqrQ7.js";import"./index-8eXqqyHQ.js";import"./PlayArrow-BqVYRyLK.js";import"./get-safe-url-B0-S5PGZ.js";import"./session-BGdAM8zS.js";import"./use-blocklet-logo-CWdlYyrq.js";import"./dot-4jhL56kz.js";import"./useAsync-C62uE2pS.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-DwzRjjku.js";import"./MoreHoriz-ChJ3K52h.js";const gt=s=>{var b,T;const[c,p]=C.useState(null),[v,l]=C.useState(!s),[k,u]=C.useState(null),{blocklet:f}=Ie(),i=(T=(b=f==null?void 0:f.site)==null?void 0:b.domainAliases[0])==null?void 0:T.value,y=C.useMemo(()=>{const j={};return c&&(c.sources.forEach(n=>{j[n.did]={source:n,events:[],count:0}}),c.events.forEach(n=>{j[n.source]&&(j[n.source].events.push(n),j[n.source].count+=1)})),j},[c]),w=async()=>{try{if(l(!0),!i)return;const n=await(await fetch(`https://${i}${ve.WELLKNOWN_SERVICE_PATH_PREFIX}/openevent.json`)).json();p(n),u(null)}catch(j){u(j instanceof Error?j:new Error(String(j)))}finally{l(!1)}};return C.useEffect(()=>{w()},[i]),{openEvent:c,setOpenEvent:p,eventsBySource:y,loading:v,error:k,loadData:w}};function ce({eventsBySource:s,selectedEvents:c,setSelectedEvents:p,error:v}){const{t:l}=_(),[k,u]=C.useState({}),f=C.useMemo(()=>{const n={};return Object.entries(s).forEach(([h,{events:x}])=>{const E=x.filter(I=>c[`${I.type}-${I.source}`]).length;n[h]=E}),n},[s,c]),i=C.useMemo(()=>Object.values(f).reduce((n,h)=>n+h,0),[f]),y=C.useMemo(()=>Object.values(s).reduce((n,{events:h})=>n+h.length,0),[s]),w=(n,h)=>{h.stopPropagation(),u({...k,[n]:!k[n]})},b=n=>{const h=`${n.type}-${n.source}`;p(x=>({...x,[h]:!x[h]}))},T=(n,h)=>{const x={};n.forEach(E=>{const I=`${E.type}-${E.source}`;x[I]=!h}),p(E=>({...E,...x}))},j=n=>{const h={};Object.values(s).forEach(({events:x})=>{x.forEach(E=>{const I=`${E.type}-${E.source}`;h[I]=n.target.checked})}),p(h)};return e.jsxs(d,{sx:{width:"100%"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ye,{control:e.jsx(ee,{onChange:j,checked:i>0&&i===y}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[l("webhookEndpoint.selectAllEvents"),e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:e.jsx(A,{title:l("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(re,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),i>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:l("webhookEndpoint.selectedEventsCount",{count:i})})]}),e.jsx(d,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(te,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:"4px"},children:Object.entries(s).map(([n,{source:h,events:x,count:E}],I)=>{const O=f[n]>0,R=f[n]===x.length&&x.length>0,$=k[n];return e.jsxs(ie.Fragment,{children:[e.jsx(oe,{sx:{borderBottom:({palette:r})=>I<Object.keys(s).length-1?`1px solid ${r.divider}`:"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(d,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:r=>{r.target.closest(".MuiFormControlLabel-root")||w(n,r)},children:[e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:x.length>0&&e.jsx(ye,{control:e.jsx(ee,{checked:R,indeterminate:O&&!R,onChange:r=>{r.stopPropagation(),T(x,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.logo&&e.jsx(Xe,{src:h.logo,sx:{width:24,height:24}}),e.jsx(d,{children:h.title||n}),O&&e.jsx(M,{label:l("webhookEndpoint.selectedCount",{count:f[n]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:r=>`${r.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(d,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",color:"text.secondary",sx:{mr:1},children:l("webhookEndpoint.eventsCount",{count:E})}),x.length>0&&e.jsx(F,{size:"small",edge:"end",children:$?e.jsx(pt,{}):e.jsx(He,{})})]})]})}),x.length>0&&e.jsx(Ze,{in:$,timeout:"auto",unmountOnExit:!0,children:e.jsx(te,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:x.map(r=>{const a=`${r.type}-${r.source}`,t=!!c[a];return e.jsx(oe,{dense:!0,sx:{py:.75},onClick:()=>b(r),children:e.jsxs(d,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(ee,{checked:t,sx:{mr:1}}),e.jsxs(d,{children:[e.jsx(S,{variant:"body1",sx:{cursor:"pointer",color:"text.primary"},children:r.type}),e.jsx(S,{variant:"caption",color:"text.secondary",sx:{display:"block",cursor:"pointer"},children:r.description})]})]})},a)})})})]},n)})})}),v&&e.jsx(et,{error:!0,sx:{mt:1},children:v})]})}ce.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};ce.defaultProps={error:null};function ue({id:s,url:c,description:p,enabledEvents:v,onSubmit:l,onClose:k}){var r;const{t:u}=_(),[f,i]=C.useState({}),{teamDid:y}=Y(),{api:w}=V(),{loading:b,error:T,eventsBySource:j}=gt(),{control:n,handleSubmit:h,formState:{errors:x},reset:E,setValue:I,trigger:O}=Ue({defaultValues:{url:"",description:""}});C.useEffect(()=>{const a=Object.values(f).some(t=>t);I("selectedEvents",a?"valid":""),O("selectedEvents")},[f,I,O]);const R=()=>{i({}),E(),k()},$=async a=>{const t=Object.keys(f).filter(m=>f[m]),g={url:a.url,description:a.description,enabledEvents:t.map(m=>{const[P,z]=m.split("-");return!P||!z?null:{type:P,source:z}}).filter(Boolean)};try{if(s){const m=await w.updateWebhookEndpoint({input:{teamDid:y,id:s,data:g}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),l(m)}else{const m=await w.createWebhookEndpoint({input:{teamDid:y,input:g}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),l(m)}}catch(m){q.error(m==null?void 0:m.message)}R()};return C.useEffect(()=>{E({url:c,description:p}),i(v.reduce((a,t)=>(a[`${t.type}-${t.source}`]=!0,a),{}))},[E,i,c,p,v]),e.jsx(Ye,{open:!0,onClose:R,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:h($),children:[e.jsx(Je,{children:u(s?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Ge,{children:e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(Z,{name:"url",control:n,rules:{required:u("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:u("webhookEndpoint.validation.urlInvalid")}},render:({field:a})=>{var t;return e.jsx(je,{...a,label:u("webhookEndpoint.url.label"),fullWidth:!0,error:!!x.url,helperText:(t=x.url)==null?void 0:t.message})}}),e.jsx(Z,{name:"description",control:n,rules:{required:u("webhookEndpoint.validation.descriptionRequired")},render:({field:a})=>{var t;return e.jsx(je,{...a,label:u("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!x.description,helperText:(t=x.description)==null?void 0:t.message})}}),e.jsx(Z,{name:"selectedEvents",control:n,rules:{required:u("webhookEndpoint.validation.eventRequired")},render:({field:a})=>e.jsx("input",{type:"hidden",...a})}),!b&&j&&Object.keys(j).length>0&&e.jsx(ce,{eventsBySource:j,selectedEvents:f,setSelectedEvents:i,error:(r=x.selectedEvents)==null?void 0:r.message}),!b&&(!j||Object.keys(j).length===0)&&e.jsx(S,{color:"text.secondary",children:u("webhookEndpoint.noAvailableEvents")}),b&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(H,{size:20})}),T&&e.jsx(le,{severity:"error",children:u("webhookEndpoint.loadingError",{message:T==null?void 0:T.message})})]})}),e.jsxs(Qe,{sx:{p:"8px 24px 24px"},children:[e.jsx(N,{onClick:R,children:u("common.cancel")}),e.jsx(N,{type:"submit",variant:"contained",color:"primary",children:u(s?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}ue.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};ue.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function Pe(s){switch(s){case"enabled":return"success";case"disabled":default:return"default"}}const bt=(s="en")=>s==="tw"?"zh":s;function K(s,c="YYYY-MM-DD HH:mm:ss",p="en"){return s?Ke(s).locale(bt(p)).format(c):"-"}function jt(s){return typeof s=="number"?!1:De(s)}function yt(s){return s>=200&&s<300}function W(s){const c=jt(s.value);return e.jsxs(e.Fragment,{children:[e.jsxs(D,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[s.label,!!s.tip&&e.jsx(A,{title:s.tip,children:e.jsx(tt,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:c?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:c?"-":s.value})]}),s.divider&&e.jsx(Re,{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 pe(s){return e.jsxs(D,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:s.mb,mt:s.mt,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:s.title}),s.children]})}pe.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};pe.defaultProps={children:null,mb:1.5,mt:1.5};var he={},wt=ae;Object.defineProperty(he,"__esModule",{value:!0});var ze=he.default=void 0,kt=wt(se()),vt=e;ze=he.default=(0,kt.default)((0,vt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5"}),"Pending");var xe={},Et=ae;Object.defineProperty(xe,"__esModule",{value:!0});var Oe=xe.default=void 0,Ct=Et(se()),St=e;Oe=xe.default=(0,Ct.default)((0,St.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"}),"CheckCircleOutlined");var me={},Tt=ae;Object.defineProperty(me,"__esModule",{value:!0});var We=me.default=void 0,It=Tt(se()),Rt=e;We=me.default=(0,It.default)((0,Rt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"ErrorOutlined");const Dt={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},Pt=s=>{const c={};return s.forEach(p=>{var l;const v=new Date(p.createdAt).toLocaleDateString();c[v]||(c[v]=[]),(l=c[v])==null||l.push(p)}),c};function fe({eventId:s,webhookEndpointId:c,event:p}){const{api:v,ws:{useSubscription:l}}=V(),{t:k}=_(),{teamDid:u}=Y(),{blocklet:f}=Ie(),{data:i,loadMore:y,loadingMore:w,loading:b,mutate:T}=Be(t=>{const m=t?Math.ceil(t.list.length/15)+1:1;return v.getWebhookAttempts({input:{teamDid:u,input:{eventId:s,webhookId:c},paging:{page:m,pageSize:15}}})},{reloadDeps:[s,c]}),j=(i==null?void 0:i.list)||[],[n,h]=C.useState(null),[x,E]=C.useState(!1),I=Pt(j);if(C.useEffect(()=>{!n&&(i!=null&&i.list.length)&&h(i.list[0])},[i==null?void 0:i.list.length,n]),l(ve.EVENTS.WEBHOOK_ATTEMPT,t=>{T(g=>{var P,z;if(g.list.find(L=>L.id===t.id)){const L=g.list.map(B=>B.id===t.id?{...B,...t}:B);return{...g,list:L}}return t.endpoint=(P=g.list[0])==null?void 0:P.endpoint,t.event=(z=g.list[0])==null?void 0:z.event,{...g,list:[t,...g.list]}})},[]),b)return e.jsx(H,{});const O=i&&i.list.length<i.paging.total,R=async()=>{n&&(E(!0),await v.retryWebhookAttempt({input:{teamDid:u,eventId:n.event.id,webhookId:c,attemptId:n.id}}).finally(()=>{setTimeout(()=>{E(!1)},1e3)}))},$=t=>{var g,m,P,z,L;if(t.responseBody&&((g=t.responseBody)!=null&&g.sessionId)&&((m=t.responseBody)!=null&&m.projectId)&&((P=t.responseBody)!=null&&P.agentId)){const B=(L=(z=f==null?void 0:f.site)==null?void 0:z.domainAliases[0])==null?void 0:L.value,J=(f.children||[]).find(G=>{var be;return((be=G==null?void 0:G.meta)==null?void 0:be.name)==="ai-studio"}),qe=ht(xt(`https://${B}`,(J==null?void 0:J.mountPoint)||"","projects",t.responseBody.projectId,"logs/main"),{sessionId:t.responseBody.sessionId,agentId:t.responseBody.agentId});return e.jsx(F,{sx:{fontSize:20},onClick:()=>window.open(qe,"_blank"),children:e.jsx(d,{component:U,icon:Q})})}return null},r=t=>t.status==="pending"?e.jsx(ze,{color:"warning"}):yt(t.responseStatus)?e.jsx(Oe,{color:"success"}):e.jsx(We,{color:"error"}),a=(n==null?void 0:n.triggeredFrom)&&((i==null?void 0:i.list)||[]).find(t=>t.id===n.triggeredFrom);return e.jsxs(zt,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ne,{item:!0,xs:12,md:4,height:1,children:De(Object.keys(I))?e.jsx(S,{color:"text.secondary",children:k("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(te,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(I).map(([t,g])=>e.jsxs(ie.Fragment,{children:[e.jsx(ot,{sx:{p:0},children:t}),g.map(m=>e.jsxs(oe,{sx:{cursor:"pointer",px:1},onClick:()=>h(m),selected:n&&(n==null?void 0:n.id)===(m==null?void 0:m.id),secondaryAction:e.jsx(S,{color:"text.secondary",children:K(m.createdAt,"HH:mm:ss")}),children:[e.jsx(nt,{sx:{minWidth:0,mr:1.5},children:r(m)}),e.jsx(st,{primary:e.jsx(S,{color:"text.primary",children:m.event.type})})]},m.id))]},t))}),O&&e.jsx(d,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(N,{variant:"text",type:"button",color:"inherit",onClick:y,disabled:w,sx:{color:t=>t.palette.text.disabled},children:k(w?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ne,{item:!0,xs:12,md:8,height:1,children:[n&&e.jsxs(D,{height:1,overflow:"auto",direction:"column",spacing:2,sx:{pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h4",children:k(`common.${n.status}`)}),e.jsx(d,{children:$(n)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[a&&e.jsx(A,{componentsProps:{tooltip:{sx:{maxWidth:400}}},placement:"left",title:e.jsxs(D,{gap:1,sx:{cursor:"pointer",".did-address-text":{color:"common.white"}},onClick:()=>h(a),children:[e.jsx(Ee,{showDid:!0,did:n.triggeredBy,cardType:Ce.Detailed,infoType:Se.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(Re,{}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(S,{variant:"body2",sx:{color:"primary.main"},children:k("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"body2",children:n.id}),e.jsx(F,{onClick:()=>h(a),children:e.jsx(d,{component:U,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),children:e.jsx(F,{onClick:()=>h(a),children:e.jsx(d,{component:U,icon:Q,sx:{fontSize:16}})})}),e.jsxs(N,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:x,children:[e.jsx(d,{component:U,icon:Dt,sx:{fontSize:16,animation:x?"spin 1s linear infinite":"none",mr:.5}}),k("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(S,{variant:"h6",children:[k("webhookEndpoint.response")," (",n.responseStatus,")"]}),e.jsx(X,{language:"json",children:JSON.stringify(n.responseBody,null,2)})]}),e.jsxs(d,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:k("webhookEndpoint.request")})}),e.jsx(X,{language:"json",sx:{margin:0},children:JSON.stringify(n.event,null,2)})]})]}),(i==null?void 0:i.list.length)===0&&p&&e.jsxs(d,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:k("webhookEndpoint.eventData")})}),e.jsx(X,{language:"json",sx:{margin:0},children:JSON.stringify(p.data,null,2)})]})]})]})}fe.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};fe.defaultProps={eventId:"",webhookEndpointId:"",event:null};const zt=de(ne)`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
to {
|
|
4
4
|
transform: rotate(360deg);
|