@abtnode/blocklet-services 1.16.43-beta-20250425-130658-8da18f4d → 1.16.43-beta-20250427-132304-6da95c55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/routes/oauth/client.js +2 -0
- package/api/routes/oauth/server.js +75 -0
- package/api/routes/user.js +1 -0
- package/api/services/oauth/server.js +31 -1
- package/dist/assets/{AdapterDayjs-6a0bjomM.js → AdapterDayjs-BUGplkxR.js} +1 -1
- package/dist/assets/{ArrowDropDown-DiAXbLgf.js → ArrowDropDown-B0sLkJoY.js} +1 -1
- package/dist/assets/{CheckCircle-BOBzbtP2.js → CheckCircle-BNrN9mgy.js} +1 -1
- package/dist/assets/{ChevronLeft-JDNo_7RB.js → ChevronLeft-Dq00IS01.js} +1 -1
- package/dist/assets/{ChevronRight-Cfe-QLJe.js → ChevronRight-ZTqWK-Ga.js} +1 -1
- package/dist/assets/{DeleteOutline-DW9Kk9LF.js → DeleteOutline-C2sY6hfm.js} +1 -1
- package/dist/assets/{Done-CAPpWSLt.js → Done-JLiLhELm.js} +1 -1
- package/dist/assets/{Download-BFPjDYTH.js → Download-Ch4RfGRW.js} +1 -1
- package/dist/assets/{Edit-D6qkTeBz.js → Edit-CY6fFHQM.js} +1 -1
- package/dist/assets/{Error-SwROBcf8.js → Error-CSFUqG0m.js} +1 -1
- package/dist/assets/{ExpandLess-BpA2naWp.js → ExpandLess-BiMmSOBl.js} +1 -1
- package/dist/assets/{Google-C5jm8HrI.js → Google-GOp5YvmZ.js} +1 -1
- package/dist/assets/{InfoOutlined-B-fGWta1.js → InfoOutlined-CQB5qKm-.js} +1 -1
- package/dist/assets/{Launch-GqtcaQf1.js → Launch-fxgQvk19.js} +1 -1
- package/dist/assets/{LaunchOutlined-D7W2P0hG.js → LaunchOutlined-BV4_W1pb.js} +1 -1
- package/dist/assets/{MoreHoriz-3W8Fr_ZL.js → MoreHoriz-CX_pwfPT.js} +1 -1
- package/dist/assets/{PlayArrow-Cja7S4vv.js → PlayArrow-DFH1Psjx.js} +1 -1
- package/dist/assets/{TuneOutlined-B3W8vgdw.js → TuneOutlined-Dy2qPFGI.js} +1 -1
- package/dist/assets/{ViewList-BRsEAVjL.js → ViewList-e3CoNi3K.js} +1 -1
- package/dist/assets/{access-control-hoDAWTTL.js → access-control-B20P1UrY.js} +1 -1
- package/dist/assets/{actions-BPVh6JdI.js → actions-DA-6s_nQ.js} +1 -1
- package/dist/assets/{add-component-core-BXXPrLkI.js → add-component-core-DG9mQFsr.js} +1 -1
- package/dist/assets/{add-resource-DSoZMbAG.js → add-resource-BoS5YkVy.js} +1 -1
- package/dist/assets/{addon-CY4PNd8X.js → addon-Bcc-Xwbf.js} +1 -1
- package/dist/assets/{advanced-BV9dnonO.js → advanced-DTe2fs5L.js} +1 -1
- package/dist/assets/{appearance-DbKPqE0i.js → appearance-DYi32tlk.js} +1 -1
- package/dist/assets/{ar-mN5tHF4O.js → ar-DupP3pla.js} +1 -1
- package/dist/assets/{audit-logs-CY7CyxpG.js → audit-logs-CydL26ZC.js} +2 -2
- package/dist/assets/{authorize-CLUD6O4F.js → authorize-DUyL7MEU.js} +1 -1
- package/dist/assets/{base32-bFQC4m_a.js → base32-p9VcJrwv.js} +1 -1
- package/dist/assets/{branding-LKt9TBDZ.js → branding-CAMtNLMU.js} +1 -1
- package/dist/assets/{branding-psyKu6rz.js → branding-_VO2ZZ3t.js} +2 -2
- package/dist/assets/{bundle-avatar-CNkSW5-i.js → bundle-avatar-D0t7RLGx.js} +1 -1
- package/dist/assets/{button-BXbVAdLT.js → button-BeZibzB9.js} +1 -1
- package/dist/assets/{click-to-copy-CSwrPBKm.js → click-to-copy-BGyXQL2i.js} +1 -1
- package/dist/assets/{complete-B8igFASe.js → complete-BzCBoyhn.js} +1 -1
- package/dist/assets/{component-RJz0SwId.js → component-5gjaNHCg.js} +1 -1
- package/dist/assets/{config-C2EcTJzj.js → config-1xq1_d84.js} +1 -1
- package/dist/assets/{config-CqUiFvo_.js → config-Bh19ZUJ-.js} +1 -1
- package/dist/assets/{config-navigation-D8u4Wwi0.js → config-navigation-Dvjz9nAh.js} +3 -3
- package/dist/assets/{config-space-BytYjhBd.js → config-space-CYg-72ab.js} +1 -1
- package/dist/assets/{confirm-qekNSA6N.js → confirm-DqvNmeoz.js} +1 -1
- package/dist/assets/{connect-BPW0KY4c.js → connect-Bbc2y5nS.js} +1 -1
- package/dist/assets/{connect-DZqNlu4F.js → connect-DM2xKEWk.js} +1 -1
- package/dist/assets/{connect-to-BcxM4POV.js → connect-to-Ck5O2M1K.js} +1 -1
- package/dist/assets/{dashboard-DrtJT0zg.js → dashboard-8QXGSoVu.js} +3 -3
- package/dist/assets/{de-BP5gdcKp.js → de-TcDcBkI0.js} +1 -1
- package/dist/assets/{delete-confirm-DEV7zNkl.js → delete-confirm-_BzUlhv2.js} +1 -1
- package/dist/assets/{did-address-DZ4aPkg2.js → did-address-DUThaBlf.js} +1 -1
- package/dist/assets/{domain-action-card-B5PD8_Bw.js → domain-action-card-D3w6jyPR.js} +1 -1
- package/dist/assets/{domain-CcBq0Tmt.js → domain-ag7_Ivc1.js} +1 -1
- package/dist/assets/domains-BDxEOJh6.js +1 -0
- package/dist/assets/{email-BWcxSNWH.js → email-DKpgximx.js} +1 -1
- package/dist/assets/{es-CBFvWN06.js → es-CDD0y3ur.js} +1 -1
- package/dist/assets/{exchange-passport-Bw0lAjY5.js → exchange-passport-Izkf8qpM.js} +1 -1
- package/dist/assets/{fr-CmHa1dCv.js → fr-zYSSKlBw.js} +1 -1
- package/dist/assets/{fuel-DBFO1voi.js → fuel-CcBzY6Bt.js} +1 -1
- package/dist/assets/{gen-access-key-BW8kZ1Xs.js → gen-access-key-DxKwgiGT.js} +1 -1
- package/dist/assets/{get-safe-url-BZgGKuU5.js → get-safe-url-Bq9SFfX6.js} +1 -1
- package/dist/assets/{get-safe-url-C0AtthsC.js → get-safe-url-DBsPGn--.js} +1 -1
- package/dist/assets/{hi-CWyDCXYI.js → hi-BsP-0YrU.js} +1 -1
- package/dist/assets/{home-CTPoo1SY.js → home-Bi8fA3jh.js} +1 -1
- package/dist/assets/{id-3xH3q-wr.js → id-CY2FWdMB.js} +1 -1
- package/dist/assets/{iframe--qNemH7W.js → iframe-DZ181i8X.js} +1 -1
- package/dist/assets/{index-eeIdp1fF.js → index-B2yOcqTl.js} +1 -1
- package/dist/assets/{index-d728JwfZ.js → index-BGgGfqEc.js} +1 -1
- package/dist/assets/{index-D5iB7faJ.js → index-B_vrglsK.js} +1 -1
- package/dist/assets/{index-u9S0L-Rf.js → index-BnmeT4Bk.js} +1 -1
- package/dist/assets/{index-BvQykj-W.js → index-C8QMe2NL.js} +1 -1
- package/dist/assets/{index-Ci9HJ6Iv.js → index-CGBZONPv.js} +1 -1
- package/dist/assets/{index-C5yNf__V.js → index-Cjjg2_Xp.js} +1 -1
- package/dist/assets/{index-BUb5Yjs_.js → index-DNG6b9sp.js} +4 -4
- package/dist/assets/{index-CGJUebpH.js → index-DO3_1y-L.js} +7 -7
- package/dist/assets/{index-CnjT4Zv0.js → index-DO4cSlUf.js} +1 -1
- package/dist/assets/{index-BoJFRi1m.js → index-DcBUShKK.js} +1 -1
- package/dist/assets/{index-CY6pLbAD.js → index-Dl4W1N74.js} +1 -1
- package/dist/assets/{index-DLBv7Dtg.js → index-DuH8q5ir.js} +1 -1
- package/dist/assets/{index-DS-sLY6b.js → index-DyxFC42L.js} +3 -3
- package/dist/assets/{index-COd4R-rR.js → index-EnQ254k3.js} +1 -1
- package/dist/assets/{index-lI6b97z3.js → index-bb90BUf4.js} +1 -1
- package/dist/assets/{index-Dv_p9rOk.js → index-mDKG4SiY.js} +1 -1
- package/dist/assets/index-n0Q-fETi.js +99 -0
- package/dist/assets/{index-CXuahOvP.js → index-slEV_y-C.js} +1 -1
- package/dist/assets/{invitation-DRfkSNu9.js → invitation-BrAZQXQL.js} +1 -1
- package/dist/assets/{invite-t5XgIivH.js → invite-Cbz8B2uW.js} +1 -1
- package/dist/assets/{issue-passport-Cn04_O-m.js → issue-passport-Dd_yyO08.js} +1 -1
- package/dist/assets/{item-cpKk__48.js → item-nK3D7WH5.js} +1 -1
- package/dist/assets/{ja-Dlm9gbED.js → ja-BLPXqHM4.js} +1 -1
- package/dist/assets/{ko-JYKwx9PY.js → ko-Cxgk34co.js} +1 -1
- package/dist/assets/{landing-page-CaOceQxT.js → landing-page-BMM_oJb1.js} +1 -1
- package/dist/assets/{layout-DTFm6q61.js → layout-Cw-hwCHs.js} +1 -1
- package/dist/assets/{list-CMmXasDM.js → list-Dmtz4mRb.js} +1 -1
- package/dist/assets/localization-DATb3Y_j.js +1 -0
- package/dist/assets/{log-CYW8Ap44.js → log-Chqr_or_.js} +1 -1
- package/dist/assets/{logger-BbYYsfRo.js → logger-zix81YaM.js} +1 -1
- package/dist/assets/{login-GHsnMk-9.js → login-DjB23H9M.js} +1 -1
- package/dist/assets/{login-oauth-callback-B2HyhVt7.js → login-oauth-callback-ILeP59KT.js} +1 -1
- package/dist/assets/{logo-uploader-ly-3UjHj.js → logo-uploader-CJrdpVcQ.js} +3 -3
- package/dist/assets/{lost-passport-BduGI9L4.js → lost-passport-Do1Pl0xI.js} +1 -1
- package/dist/assets/{open-window-Cw3Ugf66.js → open-window-D8MZhu_7.js} +1 -1
- package/dist/assets/{overview-C101Lhxl.js → overview-DLA9wj6a.js} +1 -1
- package/dist/assets/{page-header-Bk-0dymm.js → page-header-CWY8mxlT.js} +1 -1
- package/dist/assets/{passport-item-BUfjEppi.js → passport-item-CWtlyIE_.js} +1 -1
- package/dist/assets/{permission-C_VicyW0.js → permission-BGM09622.js} +1 -1
- package/dist/assets/{preferences-C_nxZvVu.js → preferences-DYdbb0kG.js} +1 -1
- package/dist/assets/{profile-embed-CgXxt11D.js → profile-embed-CeEMHxEc.js} +1 -1
- package/dist/assets/{pt-BgyGyT44.js → pt-BINIHul4.js} +1 -1
- package/dist/assets/{publish-resource-DBfSpWOt.js → publish-resource-BEc_A5mC.js} +1 -1
- package/dist/assets/{react-beautiful-dnd.esm-kaYRX6nt.js → react-beautiful-dnd.esm-ByydTUk4.js} +1 -1
- package/dist/assets/{relative-time-CuIhVa08.js → relative-time-Djw-K4Zu.js} +1 -1
- package/dist/assets/{ru-CEVWIKf9.js → ru-BifF7u-P.js} +1 -1
- package/dist/assets/{runtime-Pqx3AapT.js → runtime-DXl0lfXF.js} +1 -1
- package/dist/assets/sdk-CTe6rL6c.js +1 -0
- package/dist/assets/{security-BSs6l8nY.js → security-BhkfG23R.js} +1 -1
- package/dist/assets/{session-BoLXmmdy.js → session-VIMbdc9j.js} +1 -1
- package/dist/assets/{setup-BK8QRxSP.js → setup-BmYxTt6Z.js} +9 -3
- package/dist/assets/{spaces-FInvGagn.js → spaces-WkJCApHO.js} +1 -1
- package/dist/assets/{start-e5k6uJu1.js → start-CVexuuAk.js} +1 -1
- package/dist/assets/{status-uX3_TUfC.js → status-CygZ0LuY.js} +1 -1
- package/dist/assets/{step-actions-5JhpbsMf.js → step-actions-D_1PFeFs.js} +1 -1
- package/dist/assets/{studio-gQoPFCFH.js → studio-Byjzwg8q.js} +1 -1
- package/dist/assets/{switch-control-1DAS0xgi.js → switch-control-5fEOPVKs.js} +1 -1
- package/dist/assets/{th-y94pKVk7.js → th-CBxM23U5.js} +1 -1
- package/dist/assets/{traffic-CLSnYOIK.js → traffic-T11hxc--.js} +1 -1
- package/dist/assets/{transfer-Dh9v20QV.js → transfer-ROpxn9LD.js} +1 -1
- package/dist/assets/{unsubscribe-BiCDicGU.js → unsubscribe-Cd3XOnSp.js} +1 -1
- package/dist/assets/{use-app-logo-Cc5WhrJy.js → use-app-logo-B8Kl9EZt.js} +1 -1
- package/dist/assets/{useLocalStorage-BxIzITf9.js → useLocalStorage-DldnaMbZ.js} +1 -1
- package/dist/assets/{user-center-1qavaXbB.js → user-center-CzyCbtWm.js} +1 -1
- package/dist/assets/{util-Ce3AQBfV.js → util-Bjy-tP7q.js} +1 -1
- package/dist/assets/{util-BrciyiqD.js → util-Dw9Eiuko.js} +1 -1
- package/dist/assets/{vendor-arcblock-BUng-RXZ.js → vendor-arcblock-ScFEr-lj.js} +2 -2
- package/dist/assets/{vendor-ux-did-connect-CsNUdA6Y.js → vendor-ux-did-connect-BdkhddhO.js} +1 -1
- package/dist/assets/{vi-Dw7W2UPp.js → vi-DY_Y13jR.js} +1 -1
- package/dist/assets/wrap-locale-DMTYAE64.js +1 -0
- package/dist/assets/{zh-Dag6w2Z7.js → zh-BYRCoK6F.js} +1 -1
- package/dist/assets/{zh-tw-CMYkmBeh.js → zh-tw-BG0rlH8p.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/service-worker.js +1 -1
- package/package.json +21 -21
- package/dist/assets/domains-CGsSPrGB.js +0 -1
- package/dist/assets/index-BtWj67HV.js +0 -99
- package/dist/assets/localization-Bp5pyrsz.js +0 -1
- package/dist/assets/sdk-guHRt_DC.js +0 -1
- package/dist/assets/wrap-locale-Bc5OA7-R.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as n,a9 as f,ac as z,bU as W,T as p,ag as E,bb as P,e as H,w as L}from"./vendor-mui-core-CQ38ohp2.js";import{r as x}from"./vendor-react-DEoibe3W.js";import{h as K,f as V,aJ as X,X as D,W as Z,I as G,K as U}from"./vendor-ux-did-connect-
|
|
1
|
+
import{j as n,a9 as f,ac as z,bU as W,T as p,ag as E,bb as P,e as H,w as L}from"./vendor-mui-core-CQ38ohp2.js";import{r as x}from"./vendor-react-DEoibe3W.js";import{h as K,f as V,aJ as X,X as D,W as Z,I as G,K as U}from"./vendor-ux-did-connect-BdkhddhO.js";import{f as v,u as J}from"./vendor-hooks-DftG_2gV.js";import{ag as R,y as q,X as Q}from"./vendor-utils-BNHJB5U7.js";import{C as Y,w as B,x as ee}from"./vendor-arcblock-ScFEr-lj.js";import re from"./Phone-KP65huHK.js";import ne from"./Location-B8EOY3d0.js";import te from"./Email-Dz2Eyqu0.js";import M from"./Timezone-Ce4E1Xey.js";let j=function(e){return e.AvatarOnly="AvatarOnly",e.Detailed="Detailed",e}({}),S=function(e){return e.NameOnly="NameOnly",e.Minimal="Minimal",e.Basic="Basic",e}({}),k=null;try{k=new K}catch(e){console.error("Failed to initialize BlockletSDK:",e),k=null}function ie(e){if(!e)return null;let r="";return e.fullName?r=e.fullName.charAt(0).toUpperCase():e.email?r=e.email.split("@")[0].charAt(0).toUpperCase():r=e.did?e.did.charAt(0).toUpperCase():"?",r}function ae(e){if(!e||typeof e!="string")return!1;try{const r=V.toTypeInfo(e);return r.role!==void 0&&r.role!==X.types.RoleType.ROLE_APPLICATION}catch(r){return console.error("Failed to check if did is user did:",r),!1}}async function oe(e){if(!k)return null;try{return await k.user.getUserPublicInfo({did:e})}catch(r){return console.error("Failed to get user by did:",r),null}}const $=(e,r=48,i=void 0,t=void 0,o=!1)=>{const a=s=>{t==null||t(e,s)};if(!e.avatar){const s=ie(e);return n.jsx(D,{size:r,did:e.did,variant:"circle",onClick:a,sx:{fontSize:r*.4,cursor:o||t?"pointer":"default"},...i||{},children:s})}return n.jsx(D,{size:r,did:e.did,variant:"circle",style:{cursor:o||t?"pointer":"default"},onClick:a,src:e.avatar,alt:e.fullName||"",...i||{}})},le=(e,r=120)=>e?n.jsx(f,{sx:{maxWidth:r},className:"user-card__top-right-content",children:e()}):null;function F({user:e,avatarSize:r,shouldShowHoverCard:i,renderCardContent:t,tooltipTitle:o,tooltipProps:a,avatarProps:s,onAvatarClick:m}){const h=n.jsx(f,{display:"inline-block",children:$(e,r,s,m,i||!!o)});return o?n.jsx(z,{enterDelay:200,title:o,placement:"bottom",...a??{},children:h}):i?n.jsx(z,{enterDelay:200,title:t?t():null,placement:"bottom",arrow:!1,TransitionComponent:W,PopperProps:{sx:{"& .MuiTooltip-tooltip":{backgroundColor:"transparent",p:0,maxWidth:500,zIndex:1e3}}},...a??{},children:h}):h}function se(e){const{user:r,infoType:i,avatarSize:t=48,shouldShowHoverCard:o=!1,renderCardContent:a,...s}=e;return i===S.NameOnly?n.jsx(F,{user:r,avatarSize:t,shouldShowHoverCard:!1,renderCardContent:a,tooltipTitle:r.fullName||r.email||r.did,...s}):n.jsx(F,{user:r,avatarSize:t,shouldShowHoverCard:o,renderCardContent:a,...s})}function ce(e){const{user:r,avatarSize:i=48,onAvatarClick:t}=e;return n.jsxs(n.Fragment,{children:[$(r,i,e.avatarProps,t),n.jsx(p,{variant:"body1",children:r.fullName||r.email||r.did})]})}function de(e,r=10){return e?e.length<=r?e:`${e.slice(0,r-1)}...${e.slice(-2)}`:""}function ue({children:e,maxLength:r=10,sx:i=void 0,hiddenTip:t=!1}){const o=x.useMemo(()=>de(e,r),[e,r]);return(e==null?void 0:e.length)<=r?n.jsx(p,{sx:i,children:e}):t?n.jsx(p,{sx:i,children:o}):n.jsx(z,{title:e,placement:"top",children:n.jsx(p,{sx:i,children:o})})}function fe(e){const{user:r,showDid:i,didProps:t,avatarSize:o,shouldShowHoverCard:a,renderCardContent:s,renderTopRightContent:m,topRightMaxWidth:h,avatarProps:b,shortenLabelProps:C,renderName:g,...w}=e;return n.jsxs(f,{display:"flex",justifyContent:"space-between",alignItems:"center",className:"user-card__avatar-content",children:[n.jsxs(f,{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:2,flex:1,minWidth:0,children:[n.jsx(F,{user:r,avatarSize:o,shouldShowHoverCard:a,renderCardContent:s,avatarProps:b,...w}),n.jsxs(f,{children:[n.jsx(p,{variant:"subtitle1",fontWeight:500,color:"text.primary",className:"user-card__full-name-label",fontSize:18,noWrap:!0,sx:{lineHeight:1.1},children:g?g(r):n.jsx(ue,{sx:{fontWeight:500},...C,children:r.fullName||r.email||r.did})}),i&&r.did?n.jsx(Z,{did:r.did,size:14,copyable:!0,compact:!0,locale:"en",sx:{lineHeight:1.5},...t??{}}):null]})]}),le(m,h)]})}const me=x.memo(fe),he={timezone:M,email:te,phone:re,location:ne,link:B};function xe(e){return Q(e)}const N={width:16,height:16};function pe({value:e}){return n.jsxs(f,{display:"flex",alignItems:"center",gap:1,className:"user-card__timezone-field",children:[n.jsx(M,{...N}),n.jsx(Y,{value:e,variant:"body2",color:"grey.800"})]})}function ye({value:e}){const[r,i]=x.useState(!1),t=v(()=>{try{const a=new URL(e);return q(a.origin,"favicon.ico")}catch{return""}},[e]),o=()=>{i(!0)};return n.jsxs(f,{display:"flex",alignItems:"center",gap:1,className:"user-card__link-field",children:[t&&!r?n.jsx("img",{src:t,alt:"site icon",style:{width:16,height:16,objectFit:"contain"},onError:o}):n.jsx(B,{...N}),n.jsx(_,{variant:"body2",color:"grey.800",children:n.jsx(p,{component:"a",href:e,style:{textDecoration:"none",color:"inherit",fontSize:"inherit"},target:"_blank",variant:"body2",color:"grey.800",rel:"noopener noreferrer",children:xe(e)})})]})}function O({field:e,value:r,children:i}){const t=he[e];return n.jsxs(f,{display:"flex",alignItems:"center",gap:1,className:`user-card__${e}-field`,children:[t?n.jsx(t,{...N}):n.jsx(G,{icon:ee,...N}),n.jsx(_,{variant:"body2",color:"grey.800",children:i??r})]},e)}function je({user:e,isFull:r=!1,renderFields:i}){var I;const t=v(()=>i??["bio","email","phone","location","timezone","link"],[i]),o=v(()=>t.includes("bio"),[t]),a=v(()=>e.metadata??{joinedAt:e==null?void 0:e.createdAt,email:e==null?void 0:e.email,phone:{country:"cn",phoneNumber:(e==null?void 0:e.phone)??""}},[e]),s=v(()=>e.address,[e.address]),m=x.useCallback(l=>{var u,c,d;if(!l)return"";switch(l){case"bio":return((u=e.metadata)==null?void 0:u.bio)||"";case"email":return a.email||e.email||"";case"phone":return((c=a.phone)==null?void 0:c.phoneNumber)||e.phone||"";case"location":return(s==null?void 0:s.city)||a.location||"";case"timezone":return a.timezone||"";case"link":return((d=a.links)==null?void 0:d.map(y=>y.url).filter(Boolean))||[];default:return e[l]||""}},[e,a,s]),{effectiveRenderCount:h}=x.useMemo(()=>{const l=t.filter(c=>{if(c==="bio")return!1;const d=m(c);return d==null||d===""?!1:R(d)?d.length>0:String(d).trim().length>0}),u=l.reduce((c,d)=>{const y=m(d);return c+(Array.isArray(y)?y.filter(A=>A&&String(A).trim()).length:1)},0);return{visibleFields:l,effectiveRenderCount:u}},[t,m]),b=h>4,C=J(l=>l!=null&&String(l).trim().length>0),g=x.useMemo(()=>{const l=[];return t.forEach(u=>{if(u==="bio")return;const c=m(u);c&&(R(c)?c.forEach((d,y)=>{C(d)&&l.push({field:u,value:d,key:`${u}-${y}`})}):C(c)&&l.push({field:u,value:c,key:u}))}),l},[t,m,C]);if(t.length===0)return null;const w=l=>{const{field:u,value:c,key:d}=l;switch(u){case"link":return n.jsx(ye,{value:c},d);case"timezone":return n.jsx(pe,{value:c},d);case"email":return n.jsx(O,{field:u,value:c,children:n.jsx(p,{component:"a",href:`mailto:${c}`,rel:"noopener noreferrer",referrerPolicy:"no-referrer",style:{color:"inherit",textDecoration:"none",fontSize:"inherit"},children:c})});default:return n.jsx(O,{field:u,value:c},d)}};return n.jsxs(f,{mt:1,display:"flex",flexDirection:"column",gap:1.5,className:"user-card__basic-content",children:[o&&((I=e.metadata)==null?void 0:I.bio)&&n.jsx(_,{variant:"body2",color:"grey.800",className:"user-card__bio-field",children:e.metadata.bio}),b?n.jsx(P,{container:!0,spacing:.5,children:g.map(l=>n.jsx(P,{item:!0,xs:6,children:w(l)},l.key))}):n.jsx(f,{display:"flex",flexDirection:"column",gap:.5,children:g.map(l=>w(l))})]})}const _=E(p)`
|
|
2
2
|
flex: 1;
|
|
3
3
|
display: -webkit-box;
|
|
4
4
|
line-height: 1.5;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as y}from"./vendor-react-DEoibe3W.js";import{j as e,H as d,a8 as Pe,ac as yt,T as J,a9 as C,E as Fe,bo as _e,bz as et,bR as Te,bs as Re,bS as Ie,y as Se,b3 as Ee,aa as tt,ag as ce,a1 as st,bb as Xe,br as jt,bn as vt,q as Ze,bZ as St}from"./vendor-mui-core-CQ38ohp2.js";import{c as ie,az as ue,A as Ct}from"./vendor-utils-BNHJB5U7.js";import{Y as Z,j as P,b6 as Nt,r as ke,A as wt,u as te,bO as Tt,X as nt,B as Ae,a5 as at,al as Rt,ar as It,bt as Et}from"./vendor-ux-did-connect-CsNUdA6Y.js";import{z as At,t as V,l as Dt,I as Je}from"./index-CGJUebpH.js";import{f as ee,a as De}from"./vendor-hooks-DftG_2gV.js";import{S as he}from"./shorten-label-DFzv9EKX.js";import{I as it}from"./index-Ci9HJ6Iv.js";import{A as Ot,S as Lt,a as Pt,b as Ft,B as _t}from"./list-CMmXasDM.js";import{R as Be}from"./relative-time-CuIhVa08.js";import{a as ze}from"./dashboard-DrtJT0zg.js";import{W as kt}from"./did-address-DZ4aPkg2.js";import{p as ot}from"./util-BrciyiqD.js";import{D as Bt,g as zt}from"./traffic-CLSnYOIK.js";import{i as Wt,a as Mt}from"./index-BoJFRi1m.js";import{B as rt}from"./bundle-avatar-CNkSW5-i.js";import"./lottie-web-jYmAQWuC.js";import"./vendor-arcblock-BUng-RXZ.js";import"./index-DKhrYmrN.js";import"./use-app-logo-Cc5WhrJy.js";import"./InfoOutlined-B-fGWta1.js";import"./sdk-guHRt_DC.js";import"./CheckCircle-BOBzbtP2.js";import"./index-D5iB7faJ.js";import"./Phone-KP65huHK.js";import"./Location-B8EOY3d0.js";import"./Email-Dz2Eyqu0.js";import"./Timezone-Ce4E1Xey.js";import"./useLocalStorage-BxIzITf9.js";import"./confirm-qekNSA6N.js";import"./format-error-BrmqJs5a.js";import"./PlayArrow-Cja7S4vv.js";import"./get-safe-url-BZgGKuU5.js";import"./session-BoLXmmdy.js";import"./dot-BE1YP292.js";import"./useAsync-CGW40D2-.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-DlKplWTG.js";import"./base32-bFQC4m_a.js";import"./iframe--qNemH7W.js";import"./LaunchOutlined-D7W2P0hG.js";import"./ChevronLeft-JDNo_7RB.js";import"./ChevronRight-Cfe-QLJe.js";import"./index-BT0GBmWF.js";import"./vendor-mui-x-B0hsmEJ3.js";import"./AdapterDayjs-6a0bjomM.js";const lt=y.createContext({}),{Provider:qt,Consumer:mn}=lt;function Kt({children:t,blocklet:s=""}){const{api:n,inService:r,ws:{useSubscription:o}}=At(),[a,x]=y.useState([]),[u,R]=y.useState({total:0,pageSize:20,pageCount:0,page:1}),m=ee(()=>{var h;return(h=s.meta)==null?void 0:h.did},[s]),[v,S]=y.useState([]),[I,M]=y.useState({}),E=ee(()=>a.length?new Set(a.map(h=>h.id)):new Set,[a]),L=async({page:h=1,pageSize:O=20,...D}={})=>{if(!m)return[];try{const F={paging:{page:h,pageSize:O},...D,teamDid:m,dateRange:D.dateRange?[V(D.dateRange[0]).toISOString(),V(D.dateRange[1]).toISOString()]:void 0},{dids:B,...q}=F;let Q="";B&&B.includes("system")&&(Q="system");const z=B?B.filter(f=>f!=="system"):[],oe={...q,source:Q,componentDids:z},se=await n.getNotificationSendLog({input:oe});return M(oe),x(se.list),R(se.paging),se.list}catch(F){return Z.error(F.message),[]}},A=async()=>{const h=await n.getNotificationComponents({input:{teamDid:m}});S(h.componentDids)},G=y.useCallback(h=>{const O=s.children.find(D=>{var F;return((F=D.meta)==null?void 0:F.did)===h});if(O)return O.ancestors=[s],O},[s]),H=async({notificationId:h,receivers:O,channels:D,...F})=>{await n.resendNotification({input:{teamDid:m,notificationId:h,receivers:O,channels:D.map(B=>B==="wallet"?P.NOTIFICATION_SEND_CHANNEL.WALLET:B==="pushKit"?P.NOTIFICATION_SEND_CHANNEL.PUSH:B),...F}})},U=y.useCallback(async h=>(await n.getUser({input:{teamDid:m,user:{did:h}}})).user,[n,m]),N=y.useCallback(async({page:h=1,pageSize:O=20,...D}={})=>{try{const F={paging:{page:h,pageSize:O},...D,userName:D.searchText||"",teamDid:m,dateRange:D.dateRange?[V(D.dateRange[0]).toISOString(),V(D.dateRange[1]).toISOString()]:void 0};return await n.getReceivers({input:F})}catch(F){throw Z.error(F.message),F}},[n,m]);y.useEffect(()=>{m&&A()},[m]),o(P.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,h=>{E.has(h.notificationId)&&L(I)},[E,I]),o(P.EVENTS.NOTIFICATION_BLOCKLET_CREATE,h=>{E.has(h.id)||L(I)},[E,I]);const k={fetch:L,data:a,paging:u,blocklet:s,getComponent:G,resendNotification:H,getUser:U,componentDids:v,getReceivers:N,inService:r,teamDid:m};return e.jsx(qt,{value:{notificationRecords:k},children:t})}function We(){const{notificationRecords:t}=y.useContext(lt);return t}const ye={common:{black:"#000",white:"#fff"},primary:{main:"#3773F2",contrastText:"#fff"},secondary:{main:"#16CED1",contrastText:"#fff"},error:{main:"#F16E6E",contrastText:"#fff"},warning:{main:"#DE9E37",contrastText:"#fff"},info:{main:"#0775F8",contrastText:"#fff"},success:{main:"#34BE74",contrastText:"#fff"},grey:{50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#d5d5d5",A200:"#aaaaaa",A400:"#303030",A700:"#616161"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.54)",disabled:"rgba(0, 0, 0, 0.38)",hint:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{default:"#fff"},did:{primary:"#4598FA",secondary:"#49C3AD"}};ge.propTypes={severity:d.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ht={info:"primary",success:"success",error:"error",warning:"warning"};function ge({severity:t="info"}){return e.jsx(Nt,{type:Ht[t],children:t})}var Me={},Ut=Pe;Object.defineProperty(Me,"__esModule",{value:!0});var ct=Me.default=void 0,$t=Ut(ke()),Vt=e;ct=Me.default=(0,$t.default)((0,Vt.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 qe={},Gt=Pe;Object.defineProperty(qe,"__esModule",{value:!0});var dt=qe.default=void 0,Yt=Gt(ke()),Xt=e;dt=qe.default=(0,Yt.default)((0,Xt.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 Ke={},Zt=Pe;Object.defineProperty(Ke,"__esModule",{value:!0});var ut=Ke.default=void 0,Jt=Zt(ke()),Qt=e;ut=Ke.default=(0,Jt.default)((0,Qt.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 es=(t,s,n="")=>{if(!n||!s)return"";switch(n){case P.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return t("notification.sendStatus.reason.disabled",{channel:s});case P.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return t("notification.sendStatus.reason.unavailable",{channel:s});case P.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return t("notification.sendStatus.reason.notSent",{channel:s});case P.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return t("notification.sendStatus.reason.offline");default:return n}};function pt(t,s,n={}){const{status:r,updatedAt:o,reason:a="",channel:x="wallet"}=n,u=o?t("notification.sendStatus.sentTime",{date:Dt(o,s)}):"",R=es(t,x,a);return r===P.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:t("notification.sendStatus.failed"),sentTime:u,reason:R}:r===P.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:t("notification.sendStatus.success"),sentTime:u}:{status:"pending",title:t("notification.sendStatus.pending"),reason:R,sentTime:u}}const Oe={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Le=["wallet","pushKit","email"],Qe=["info","success","error","warning"],ft=t=>{var n,r;const{settings:s}=t;return(r=(n=s==null?void 0:s.notification)==null?void 0:n.email)==null?void 0:r.enabled},mt=t=>{var n,r;const{settings:s}=t;return(r=(n=s==null?void 0:s.notification)==null?void 0:n.pushKit)==null?void 0:r.enabled},ts=(t,s)=>{const n=ie(s,"extra.notifications.email",!0);return{available:ft(t),enabled:n}},ss=(t,s)=>{const n=ie(s,"extra.notifications.push",!0);return{available:mt(t),enabled:n}},ns=t=>({enabled:ie(t,"extra.notifications.wallet",!0)}),as=t=>({enabled:ie(t,"extra.webhooks",[]).length>0}),xe=(t=3)=>new Promise(s=>{setTimeout(()=>{s()},t*1e3)}),is=(t,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:t("notification.sendStatus.reason.available",{channel:s}),fail:t("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:[],be=(t=[])=>{const s=V().startOf("day");return t.filter(n=>V(n.sendAt).isSame(s,"day")).length},os=(t,s="")=>{if(s&&Le.includes(s)){const a=`${s}SendRecord`,x=ie(t,a,[]);return be(x)}const n=ie(t,"webhook",{}),r=Object.keys(n??{})??[];if(s&&r.includes(s)){const a=n[s]??[];return be(a)}const o={};return Le.forEach(a=>{const x=`${a}SendRecord`,u=ie(t,x,[]),R=be(u);o[a]=R}),r.length>0&&r.forEach(a=>{const x=n[a]??[],u=be(x);o[a]=u}),o},je=(t,s,n)=>{if(!Array.isArray(t))throw new Error("Invalid filterList or index");return t[n].splice(s,1),t},ve=(t,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(t):!1},rs=t=>{switch(t){case P.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case P.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case P.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case P.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},ht=()=>wt({typography:{fontSize:14,button:{textTransform:"none"}},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 ne({config:t,enableTooltip:s=!0,showTitle:n=!1,children:r}){const{status:o,title:a="",sentTime:x="",reason:u=""}=t,R=[a,u].filter(Boolean).join(", ");return e.jsx(yt,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(J,{color:"inherit",sx:{fontSize:12},children:R}),e.jsx("span",{children:x})]}):null,arrow:!0,placement:"top",children:e.jsxs(C,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(C,{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center",children:[e.jsx(C,{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Oe[o],style:{opacity:.15}}),e.jsx(C,{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Oe[o]})]}),e.jsx(J,{color:"inherit",sx:{fontSize:12},children:n?a:r})]})})}ne.propTypes={config:d.object.isRequired,enableTooltip:d.bool,showTitle:d.bool,children:d.node};ne.defaultProps={enableTooltip:!0,showTitle:!1,children:null};pe.propTypes={list:d.array.isRequired,label:d.string.isRequired,onDelete:d.func};pe.defaultProps={onDelete:()=>{}};function pe({list:t,label:s,onDelete:n}){const{t:r,locale:o}=te();return e.jsxs(C,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(J,{children:[s,": "]}),t.map(a=>{const x=pt(r,o,{status:a});return e.jsx(Fe,{size:"small",label:e.jsx(C,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(ne,{config:x,enableTooltip:!1,children:x.title})}),onDelete:u=>n(u,a)},a)})]})}He.propTypes={filterList:d.array.isRequired,onChange:d.func.isRequired,index:d.number.isRequired,column:d.object.isRequired,filterValues:d.array.isRequired,label:d.string.isRequired,renderLabel:d.func.isRequired};function He({filterList:t,onChange:s,index:n,column:r,filterValues:o,label:a,renderLabel:x}){return e.jsxs(_e,{className:"filter-container",children:[e.jsx(et,{component:"legend",children:a}),e.jsx(Te,{row:!0,children:o.map(u=>e.jsx(Re,{control:e.jsx(Ie,{checked:t[n].indexOf(u.value??u)>-1,onChange:R=>{const m=[...t];R.target.checked?m[n]=[...m[n],u.value??u]:m[n]=m[n].filter(v=>v!==(u.value??u)),s(m[n],n,r)},name:u.value??u}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:x(u)})},u.value??u))})]})}function we(t){return e.jsx(He,{...t,renderLabel:s=>e.jsx(ne,{enableTooltip:!1,config:{status:s.status},children:s.label})})}de.propTypes={status:d.number.isRequired,updatedAt:d.string.isRequired,reason:d.string,channel:d.string,onResend:d.func};function de({status:t,updatedAt:s,reason:n="",channel:r="wallet",onResend:o}){const{t:a,locale:x}=te(),u=pt(a,x,{status:t,updatedAt:s,reason:n,channel:r});return e.jsxs(C,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(ne,{config:u,showTitle:!0}),u.status!=="success"&&e.jsx(Se,{className:"resend-btn",size:"small",startIcon:e.jsx(ze,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:a("notification.resend")})]})}Ue.propTypes={value:d.array.isRequired,onChange:d.func};function Ue({value:t,onChange:s}){const{locale:n}=te(),r=V().toDate(),[o,a]=y.useState(null),x=y.useCallback(m=>{a(o?null:m.currentTarget)},[o]),u=!!o,R=y.useCallback(m=>{if(!m.startDate||!m.endDate){Z.error("Please select a date range");return}if(V(m.startDate).isAfter(m.endDate)||!V(m.startDate).isValid()||!V(m.endDate).isValid()){Z.error("Invalid date range");return}s([m.startDate,m.endDate]),a(null)},[s]);return e.jsxs("div",{children:[e.jsx(J,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:0,children:e.jsxs(Se,{onClick:x,variant:"outlined",size:"small",color:"inherit",children:[Je(t[0],n)," - ",Je(t[1],n)]})}),e.jsx(Ee,{open:u,anchorEl:o,onClose:()=>{a(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(Bt,{open:!0,maxDate:r,initialDateRange:{startDate:t[0],endDate:t[1]},toggle:x,definedRanges:zt(r),onChange:R})})]})}$e.propTypes={itemComponent:d.elementType.isRequired};function $e({itemComponent:t,...s}){var o;const{t:n}=te();return!((o=s==null?void 0:s.filterList)!=null&&o.filter(a=>a.length).length)?null:e.jsxs(C,{display:"flex",gap:1,alignItems:"center",children:[e.jsx("div",{className:"toolbar-filter-title",children:n("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(Tt.TableFilterList,{...s,ItemComponent:t})})]})}function Ce({label:t,onDelete:s,canDelete:n=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let a=!0;return n&&typeof n=="function"&&(a=n({label:t,...r})),e.jsx(Fe,{label:t,variant:"outlined",...o&&a?{onDelete:o}:{}})}Ce.propTypes={label:d.string.isRequired,onDelete:d.func,canDelete:d.func};Ce.defaultProps={canDelete:()=>!0};const ls=[{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}];Ve.propTypes={loading:d.bool,onCancel:d.func,onConfirm:d.func};Ve.defaultProps={loading:!1,onCancel:()=>{},onConfirm:()=>{}};function Ve({loading:t=!1,onCancel:s,onConfirm:n}){const{t:r}=te(),[o,a]=y.useState(ls),[x,u]=y.useState(!0),R=(v,S)=>{S.checked=v.target.checked;const I=o.map(M=>({...M,checked:M.value===S.value?S.checked:M.checked}));a(I)},m=v=>{v.stopPropagation(),n({channels:o.filter(S=>S.checked).map(S=>S.value),isResendFailedOnly:x})};return e.jsxs(C,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(J,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(C,{className:"choose-channel",children:e.jsxs(_e,{component:"fieldset",variant:"standard",children:[e.jsx(et,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Te,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(v=>e.jsx(Re,{control:e.jsx(Ie,{checked:v.checked,onChange:S=>R(S,v),name:v.value}),label:v.label},v.value))})]})}),e.jsx(C,{className:"resend-config-footer",children:e.jsx(Te,{children:e.jsx(Re,{control:e.jsx(Ie,{checked:x,onChange:v=>u(v.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(C,{display:"flex",justifyContent:"flex-end",gap:1,className:"resend-config-footer-tip",children:[e.jsx(Se,{onClick:v=>{v.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Se,{onClick:m,color:"primary",disabled:t,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[t&&e.jsx(tt,{size:16}),r("common.confirm")]})]})]})}gt.propTypes={notificationId:d.string.isRequired,handleResend:d.func,resending:d.bool};function gt({notificationId:t,handleResend:s,resending:n=!1}){const{t:r,locale:o}=te(),{getReceivers:a,inService:x,teamDid:u,getUser:R,blocklet:m}=We(),[v,S]=y.useState(!1),[I,M]=y.useState([]),E=De({anchorEl:null,position:null}),L=De({anchorEl:null,position:null}),[A,G]=y.useState(null),[H,U]=y.useState({total:0,pageSize:10,pageCount:0,page:1}),[N,k]=y.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[V().subtract(1,"month").startOf("day").toDate(),V().endOf("day").toDate()]}),[h,O]=y.useState([]),D=[{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"}],F=async()=>{if(!v&&t)try{S(!0);const i=await a({notificationId:t,...N}),l=i.list.map(c=>({...c,receiverUser:{...c.receiverUser,avatar:ot(c.receiverUser.avatar,u,x)}}));M(l),U(i.paging),S(!1)}catch(i){Z.error(i.message),S(!1)}};y.useEffect(()=>{F()},[N]);const B=i=>{i.stopPropagation();const l=i.currentTarget;L.anchorEl=l;const c=l.getBoundingClientRect();L.position={top:c.top+window.scrollY,left:c.left+window.scrollX}},q=i=>i.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(Ae,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(ze,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:B,children:r("notification.resend")})}):null,Q={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:H.page-1,rowsPerPage:H.pageSize,count:H.total,searchText:N.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:h,onRowSelectionChange:(i,l)=>{O(l.map(c=>c.dataIndex))},customToolbarSelect:q},z=({page:i,rowsPerPage:l,searchText:c,filterList:j})=>{const[,_=[],$=[],K=[]]=j;N.pageSize!==l?k(W=>({...W,pageSize:l,page:1})):N.page!==i+1?k(W=>({...W,page:i+1})):N.searchText!==c?k(W=>({...W,searchText:c,page:1})):ue(_,N.walletSendStatus)?ue($,N.pushKitSendStatus)?ue(K,N.emailSendStatus)||k(W=>({...W,emailSendStatus:K,page:1})):k(W=>({...W,pushKitSendStatus:$,page:1})):k(W=>({...W,walletSendStatus:_,page:1}))},oe=y.useCallback(async(i,l)=>{if(!l)return!1;const c=await R(l);return c?i==="wallet"?ns(c):i==="email"?ts(m,c):i==="pushKit"?ss(m,c):i==="webhook"?as(c):!0:!1},[R,m]),se=y.useCallback(i=>is(r,i),[r]),f=()=>{E.anchorEl=null,E.position=null,G(null)},p=()=>{L.anchorEl=null,L.position=null},g=async(i,l,c=!0,j="")=>{if(!(!l.length||!i.length))try{s(i,l,c,j),L.anchorEl||(await xe(.5),f())}catch(_){console.error("handleResend error",{error:_})}},b=async({channels:i,isResendFailedOnly:l})=>{const c=h.map(j=>I[j].receiver);await g(i,c,l),await xe(.5),p(),O([])},T=async(i,l=[],c=!0)=>{try{await g(["webhook"],[i.receiver],c,l)}catch(j){Z.error(j.response?j.response.statusText:j.message)}},w=async(i,l,c,j=[],_=!0)=>{if(i.stopPropagation(),os(l,c)>=4){Z.warning(r("notification.resendLimit"));return}if(!Le.includes(c)){await T(l,j,_);return}if(i){const K=i.currentTarget,W=K.getBoundingClientRect();E.anchorEl=K,E.position={top:W.top+window.scrollY,left:W.left+window.scrollX}}G({channel:c});try{const K=await oe(c,l.receiver);await xe(1),G({channel:c,result:K}),(typeof K=="boolean"&&K||Ct(K)&&Object.values(K).every(W=>!!W))&&(await s([c],[l.receiver],_),L.anchorEl||(await xe(.5),f()))}catch(K){Z.error(K.message)}},Y=i=>{k(l=>({...l,dateRange:i,page:1}))},X=(i,l,c,j)=>{i.stopPropagation();const _=c.filter($=>$!==l);k($=>({...$,[j]:_,page:1}))},ae=ee(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:i=>{const{receiverUser:l,receiver:c}=I[i];return l?e.jsxs(C,{"data-cy":`member-name-${l.fullName}`,display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start",children:[e.jsx(nt,{src:`${l.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:c,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(he,{children:l.fullName})]},c):e.jsx(kt,{size:14,responsive:!1,compact:!0,copyable:!1,did:c})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:N.walletSendStatus??[],customFilterListOptions:{render:i=>e.jsx(pe,{list:i,label:"Wallet",onDelete:(l,c)=>{l.stopPropagation(),X(l,c,ae[1].options.filterList,"walletSendStatus")}}),update:je},filterOptions:{names:D,fullWidth:!0,logic:ve,display:(i,l,c,j)=>e.jsx(we,{label:"Wallet",filterList:i,onChange:l,index:c,column:j,filterValues:D})},customBodyRenderLite:i=>{const{walletSendStatus:l,walletSendAt:c,walletSendFailedReason:j}=I[i];return e.jsx(de,{status:l,updatedAt:c,reason:j,channel:"wallet",onResend:_=>w(_,I[i],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:i=>{const{pushKitSendStatus:l,pushKitSendAt:c,pushKitSendFailedReason:j}=I[i];return e.jsx(de,{status:l,updatedAt:c,reason:j,channel:"pushkit",onResend:_=>w(_,I[i],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:N.pushKitSendStatus??[],customFilterListOptions:{render:i=>e.jsx(pe,{list:i,label:"Push Kit",onDelete:(l,c)=>{l.stopPropagation(),X(l,c,ae[2].options.filterList,"pushKitSendStatus")}}),update:je},filterOptions:{names:D,fullWidth:!0,logic:ve,display:(i,l,c,j)=>e.jsx(we,{label:"Push Kit",filterList:i,onChange:l,index:c,column:j,filterValues:D})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:i=>{const{emailSendStatus:l,emailSendAt:c,emailSendFailedReason:j}=I[i];return e.jsx(de,{status:l,updatedAt:c,reason:j,channel:"email",onResend:_=>w(_,I[i],"email",[],!1)})},filter:!0,filterType:"custom",filterList:N.emailSendStatus??[],customFilterListOptions:{render:i=>e.jsx(pe,{list:i,label:"Email",onDelete:(l,c)=>{l.stopPropagation(),X(l,c,ae[3].options.filterList,"emailSendStatus")}}),update:je},filterOptions:{names:D,fullWidth:!0,logic:ve,display:(i,l,c,j)=>e.jsx(we,{label:"Email",filterList:i,onChange:l,index:c,column:j,filterValues:D})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:i=>{const{webhook:l}=I[i];if(!l)return null;const c=Object.entries(l)[0];if(!c)return null;const[j,_]=c,$=_[0];return e.jsx(C,{display:"flex",flexDirection:"column",gap:1,children:e.jsxs(C,{className:"webhook-item",fontSize:12,children:[e.jsx(he,{maxLength:30,children:j},j),e.jsx(de,{status:$.status,updatedAt:$.sendAt,reason:$.failedReason,channel:"webhook",onResend:K=>w(K,I[i],"webhook",[j],!1)})]},j)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:i=>{const{createdAt:l}=I[i];return e.jsx(Be,{value:l,locale:o,shouldUpdate:!0})}}}],[I,o,N,r]),Ye=[e.jsx(Ue,{value:N.dateRange,onChange:Y},"date-picker"),e.jsx(Ae,{variant:"contained",size:"small",color:"primary",loading:v,startIcon:e.jsx(ut,{}),onClick:()=>F(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(C,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(ds,{children:e.jsxs(st,{theme:ht(),children:[e.jsx(at,{className:"receivers-table",locale:o,loading:v,columns:ae,data:I,onChange:z,options:Q,customButtons:Ye,components:{TableFilterList:i=>e.jsx($e,{...i,itemComponent:l=>e.jsx(Ce,{...l,canDelete:()=>!1})})}}),E.anchorEl&&e.jsx(Ee,{open:!!E.anchorEl,anchorReference:"anchorPosition",anchorPosition:E.position,onClose:f,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(us,{children:[e.jsxs(J,{variant:"body1",component:"div",className:"check-title",children:[A==null?void 0:A.channel," Checking"]}),e.jsx(C,{display:"flex",flexDirection:"column",sx:{gap:"4px"},children:se(A==null?void 0:A.channel).map(i=>{var _,$;const{type:l,pass:c,fail:j}=i;return!(A!=null&&A.result)||(_=A==null?void 0:A.result)!=null&&_[l]?e.jsxs(J,{variant:"body1",component:"div",className:"check-item",display:"flex",alignItems:"center",sx:{gap:"4px",color:($=A==null?void 0:A.result)!=null&&$[l]?ye.success.main:"inherit"},children:[A!=null&&A.result?e.jsx(ct,{}):e.jsx(tt,{size:12,sx:{color:ye.primary.main}}),e.jsx("span",{children:c})]},l):e.jsxs(J,{variant:"body1",component:"div",display:"flex",alignItems:"center",className:"check-item",sx:{gap:"4px",color:ye.error.main},children:[e.jsx(dt,{}),e.jsx("span",{children:j})]},l)})})]})}),L.anchorEl&&e.jsx(Ee,{open:!!L.anchorEl,anchorReference:"anchorPosition",anchorPosition:L.position,onClose:p,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Ve,{loading:n,onCancel:p,onConfirm:b})})]})})})}const cs=y.memo(gt),ds=ce.div`
|
|
1
|
+
import{r as y}from"./vendor-react-DEoibe3W.js";import{j as e,H as d,a8 as Pe,ac as yt,T as J,a9 as C,E as Fe,bo as _e,bz as et,bR as Te,bs as Re,bS as Ie,y as Se,b3 as Ee,aa as tt,ag as ce,a1 as st,bb as Xe,br as jt,bn as vt,q as Ze,bZ as St}from"./vendor-mui-core-CQ38ohp2.js";import{c as ie,az as ue,A as Ct}from"./vendor-utils-BNHJB5U7.js";import{Y as Z,j as P,b6 as Nt,r as ke,A as wt,u as te,bO as Tt,X as nt,B as Ae,a5 as at,al as Rt,ar as It,bt as Et}from"./vendor-ux-did-connect-BdkhddhO.js";import{z as At,t as V,l as Dt,I as Je}from"./index-DO3_1y-L.js";import{f as ee,a as De}from"./vendor-hooks-DftG_2gV.js";import{S as he}from"./shorten-label-DFzv9EKX.js";import{I as it}from"./index-CGBZONPv.js";import{A as Ot,S as Lt,a as Pt,b as Ft,B as _t}from"./list-Dmtz4mRb.js";import{R as Be}from"./relative-time-Djw-K4Zu.js";import{a as ze}from"./dashboard-8QXGSoVu.js";import{W as kt}from"./did-address-DUThaBlf.js";import{p as ot}from"./util-Dw9Eiuko.js";import{D as Bt,g as zt}from"./traffic-T11hxc--.js";import{i as Wt,a as Mt}from"./index-DcBUShKK.js";import{B as rt}from"./bundle-avatar-D0t7RLGx.js";import"./lottie-web-jYmAQWuC.js";import"./vendor-arcblock-ScFEr-lj.js";import"./index-DKhrYmrN.js";import"./use-app-logo-B8Kl9EZt.js";import"./InfoOutlined-CQB5qKm-.js";import"./sdk-CTe6rL6c.js";import"./CheckCircle-BNrN9mgy.js";import"./index-B_vrglsK.js";import"./Phone-KP65huHK.js";import"./Location-B8EOY3d0.js";import"./Email-Dz2Eyqu0.js";import"./Timezone-Ce4E1Xey.js";import"./useLocalStorage-DldnaMbZ.js";import"./confirm-DqvNmeoz.js";import"./format-error-BrmqJs5a.js";import"./PlayArrow-DFH1Psjx.js";import"./get-safe-url-DBsPGn--.js";import"./session-VIMbdc9j.js";import"./dot-BE1YP292.js";import"./useAsync-CGW40D2-.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-C_flBrm-.js";import"./base32-p9VcJrwv.js";import"./iframe-DZ181i8X.js";import"./LaunchOutlined-BV4_W1pb.js";import"./ChevronLeft-Dq00IS01.js";import"./ChevronRight-ZTqWK-Ga.js";import"./index-BT0GBmWF.js";import"./vendor-mui-x-B0hsmEJ3.js";import"./AdapterDayjs-BUGplkxR.js";const lt=y.createContext({}),{Provider:qt,Consumer:mn}=lt;function Kt({children:t,blocklet:s=""}){const{api:n,inService:r,ws:{useSubscription:o}}=At(),[a,x]=y.useState([]),[u,R]=y.useState({total:0,pageSize:20,pageCount:0,page:1}),m=ee(()=>{var h;return(h=s.meta)==null?void 0:h.did},[s]),[v,S]=y.useState([]),[I,M]=y.useState({}),E=ee(()=>a.length?new Set(a.map(h=>h.id)):new Set,[a]),L=async({page:h=1,pageSize:O=20,...D}={})=>{if(!m)return[];try{const F={paging:{page:h,pageSize:O},...D,teamDid:m,dateRange:D.dateRange?[V(D.dateRange[0]).toISOString(),V(D.dateRange[1]).toISOString()]:void 0},{dids:B,...q}=F;let Q="";B&&B.includes("system")&&(Q="system");const z=B?B.filter(f=>f!=="system"):[],oe={...q,source:Q,componentDids:z},se=await n.getNotificationSendLog({input:oe});return M(oe),x(se.list),R(se.paging),se.list}catch(F){return Z.error(F.message),[]}},A=async()=>{const h=await n.getNotificationComponents({input:{teamDid:m}});S(h.componentDids)},G=y.useCallback(h=>{const O=s.children.find(D=>{var F;return((F=D.meta)==null?void 0:F.did)===h});if(O)return O.ancestors=[s],O},[s]),H=async({notificationId:h,receivers:O,channels:D,...F})=>{await n.resendNotification({input:{teamDid:m,notificationId:h,receivers:O,channels:D.map(B=>B==="wallet"?P.NOTIFICATION_SEND_CHANNEL.WALLET:B==="pushKit"?P.NOTIFICATION_SEND_CHANNEL.PUSH:B),...F}})},U=y.useCallback(async h=>(await n.getUser({input:{teamDid:m,user:{did:h}}})).user,[n,m]),N=y.useCallback(async({page:h=1,pageSize:O=20,...D}={})=>{try{const F={paging:{page:h,pageSize:O},...D,userName:D.searchText||"",teamDid:m,dateRange:D.dateRange?[V(D.dateRange[0]).toISOString(),V(D.dateRange[1]).toISOString()]:void 0};return await n.getReceivers({input:F})}catch(F){throw Z.error(F.message),F}},[n,m]);y.useEffect(()=>{m&&A()},[m]),o(P.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,h=>{E.has(h.notificationId)&&L(I)},[E,I]),o(P.EVENTS.NOTIFICATION_BLOCKLET_CREATE,h=>{E.has(h.id)||L(I)},[E,I]);const k={fetch:L,data:a,paging:u,blocklet:s,getComponent:G,resendNotification:H,getUser:U,componentDids:v,getReceivers:N,inService:r,teamDid:m};return e.jsx(qt,{value:{notificationRecords:k},children:t})}function We(){const{notificationRecords:t}=y.useContext(lt);return t}const ye={common:{black:"#000",white:"#fff"},primary:{main:"#3773F2",contrastText:"#fff"},secondary:{main:"#16CED1",contrastText:"#fff"},error:{main:"#F16E6E",contrastText:"#fff"},warning:{main:"#DE9E37",contrastText:"#fff"},info:{main:"#0775F8",contrastText:"#fff"},success:{main:"#34BE74",contrastText:"#fff"},grey:{50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#d5d5d5",A200:"#aaaaaa",A400:"#303030",A700:"#616161"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.54)",disabled:"rgba(0, 0, 0, 0.38)",hint:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{default:"#fff"},did:{primary:"#4598FA",secondary:"#49C3AD"}};ge.propTypes={severity:d.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ht={info:"primary",success:"success",error:"error",warning:"warning"};function ge({severity:t="info"}){return e.jsx(Nt,{type:Ht[t],children:t})}var Me={},Ut=Pe;Object.defineProperty(Me,"__esModule",{value:!0});var ct=Me.default=void 0,$t=Ut(ke()),Vt=e;ct=Me.default=(0,$t.default)((0,Vt.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 qe={},Gt=Pe;Object.defineProperty(qe,"__esModule",{value:!0});var dt=qe.default=void 0,Yt=Gt(ke()),Xt=e;dt=qe.default=(0,Yt.default)((0,Xt.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 Ke={},Zt=Pe;Object.defineProperty(Ke,"__esModule",{value:!0});var ut=Ke.default=void 0,Jt=Zt(ke()),Qt=e;ut=Ke.default=(0,Jt.default)((0,Qt.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 es=(t,s,n="")=>{if(!n||!s)return"";switch(n){case P.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return t("notification.sendStatus.reason.disabled",{channel:s});case P.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return t("notification.sendStatus.reason.unavailable",{channel:s});case P.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return t("notification.sendStatus.reason.notSent",{channel:s});case P.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return t("notification.sendStatus.reason.offline");default:return n}};function pt(t,s,n={}){const{status:r,updatedAt:o,reason:a="",channel:x="wallet"}=n,u=o?t("notification.sendStatus.sentTime",{date:Dt(o,s)}):"",R=es(t,x,a);return r===P.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:t("notification.sendStatus.failed"),sentTime:u,reason:R}:r===P.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:t("notification.sendStatus.success"),sentTime:u}:{status:"pending",title:t("notification.sendStatus.pending"),reason:R,sentTime:u}}const Oe={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Le=["wallet","pushKit","email"],Qe=["info","success","error","warning"],ft=t=>{var n,r;const{settings:s}=t;return(r=(n=s==null?void 0:s.notification)==null?void 0:n.email)==null?void 0:r.enabled},mt=t=>{var n,r;const{settings:s}=t;return(r=(n=s==null?void 0:s.notification)==null?void 0:n.pushKit)==null?void 0:r.enabled},ts=(t,s)=>{const n=ie(s,"extra.notifications.email",!0);return{available:ft(t),enabled:n}},ss=(t,s)=>{const n=ie(s,"extra.notifications.push",!0);return{available:mt(t),enabled:n}},ns=t=>({enabled:ie(t,"extra.notifications.wallet",!0)}),as=t=>({enabled:ie(t,"extra.webhooks",[]).length>0}),xe=(t=3)=>new Promise(s=>{setTimeout(()=>{s()},t*1e3)}),is=(t,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:t("notification.sendStatus.reason.available",{channel:s}),fail:t("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:[],be=(t=[])=>{const s=V().startOf("day");return t.filter(n=>V(n.sendAt).isSame(s,"day")).length},os=(t,s="")=>{if(s&&Le.includes(s)){const a=`${s}SendRecord`,x=ie(t,a,[]);return be(x)}const n=ie(t,"webhook",{}),r=Object.keys(n??{})??[];if(s&&r.includes(s)){const a=n[s]??[];return be(a)}const o={};return Le.forEach(a=>{const x=`${a}SendRecord`,u=ie(t,x,[]),R=be(u);o[a]=R}),r.length>0&&r.forEach(a=>{const x=n[a]??[],u=be(x);o[a]=u}),o},je=(t,s,n)=>{if(!Array.isArray(t))throw new Error("Invalid filterList or index");return t[n].splice(s,1),t},ve=(t,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(t):!1},rs=t=>{switch(t){case P.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case P.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case P.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case P.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},ht=()=>wt({typography:{fontSize:14,button:{textTransform:"none"}},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 ne({config:t,enableTooltip:s=!0,showTitle:n=!1,children:r}){const{status:o,title:a="",sentTime:x="",reason:u=""}=t,R=[a,u].filter(Boolean).join(", ");return e.jsx(yt,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(J,{color:"inherit",sx:{fontSize:12},children:R}),e.jsx("span",{children:x})]}):null,arrow:!0,placement:"top",children:e.jsxs(C,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(C,{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center",children:[e.jsx(C,{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Oe[o],style:{opacity:.15}}),e.jsx(C,{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Oe[o]})]}),e.jsx(J,{color:"inherit",sx:{fontSize:12},children:n?a:r})]})})}ne.propTypes={config:d.object.isRequired,enableTooltip:d.bool,showTitle:d.bool,children:d.node};ne.defaultProps={enableTooltip:!0,showTitle:!1,children:null};pe.propTypes={list:d.array.isRequired,label:d.string.isRequired,onDelete:d.func};pe.defaultProps={onDelete:()=>{}};function pe({list:t,label:s,onDelete:n}){const{t:r,locale:o}=te();return e.jsxs(C,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(J,{children:[s,": "]}),t.map(a=>{const x=pt(r,o,{status:a});return e.jsx(Fe,{size:"small",label:e.jsx(C,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(ne,{config:x,enableTooltip:!1,children:x.title})}),onDelete:u=>n(u,a)},a)})]})}He.propTypes={filterList:d.array.isRequired,onChange:d.func.isRequired,index:d.number.isRequired,column:d.object.isRequired,filterValues:d.array.isRequired,label:d.string.isRequired,renderLabel:d.func.isRequired};function He({filterList:t,onChange:s,index:n,column:r,filterValues:o,label:a,renderLabel:x}){return e.jsxs(_e,{className:"filter-container",children:[e.jsx(et,{component:"legend",children:a}),e.jsx(Te,{row:!0,children:o.map(u=>e.jsx(Re,{control:e.jsx(Ie,{checked:t[n].indexOf(u.value??u)>-1,onChange:R=>{const m=[...t];R.target.checked?m[n]=[...m[n],u.value??u]:m[n]=m[n].filter(v=>v!==(u.value??u)),s(m[n],n,r)},name:u.value??u}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:x(u)})},u.value??u))})]})}function we(t){return e.jsx(He,{...t,renderLabel:s=>e.jsx(ne,{enableTooltip:!1,config:{status:s.status},children:s.label})})}de.propTypes={status:d.number.isRequired,updatedAt:d.string.isRequired,reason:d.string,channel:d.string,onResend:d.func};function de({status:t,updatedAt:s,reason:n="",channel:r="wallet",onResend:o}){const{t:a,locale:x}=te(),u=pt(a,x,{status:t,updatedAt:s,reason:n,channel:r});return e.jsxs(C,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(ne,{config:u,showTitle:!0}),u.status!=="success"&&e.jsx(Se,{className:"resend-btn",size:"small",startIcon:e.jsx(ze,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:a("notification.resend")})]})}Ue.propTypes={value:d.array.isRequired,onChange:d.func};function Ue({value:t,onChange:s}){const{locale:n}=te(),r=V().toDate(),[o,a]=y.useState(null),x=y.useCallback(m=>{a(o?null:m.currentTarget)},[o]),u=!!o,R=y.useCallback(m=>{if(!m.startDate||!m.endDate){Z.error("Please select a date range");return}if(V(m.startDate).isAfter(m.endDate)||!V(m.startDate).isValid()||!V(m.endDate).isValid()){Z.error("Invalid date range");return}s([m.startDate,m.endDate]),a(null)},[s]);return e.jsxs("div",{children:[e.jsx(J,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:0,children:e.jsxs(Se,{onClick:x,variant:"outlined",size:"small",color:"inherit",children:[Je(t[0],n)," - ",Je(t[1],n)]})}),e.jsx(Ee,{open:u,anchorEl:o,onClose:()=>{a(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(Bt,{open:!0,maxDate:r,initialDateRange:{startDate:t[0],endDate:t[1]},toggle:x,definedRanges:zt(r),onChange:R})})]})}$e.propTypes={itemComponent:d.elementType.isRequired};function $e({itemComponent:t,...s}){var o;const{t:n}=te();return!((o=s==null?void 0:s.filterList)!=null&&o.filter(a=>a.length).length)?null:e.jsxs(C,{display:"flex",gap:1,alignItems:"center",children:[e.jsx("div",{className:"toolbar-filter-title",children:n("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(Tt.TableFilterList,{...s,ItemComponent:t})})]})}function Ce({label:t,onDelete:s,canDelete:n=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let a=!0;return n&&typeof n=="function"&&(a=n({label:t,...r})),e.jsx(Fe,{label:t,variant:"outlined",...o&&a?{onDelete:o}:{}})}Ce.propTypes={label:d.string.isRequired,onDelete:d.func,canDelete:d.func};Ce.defaultProps={canDelete:()=>!0};const ls=[{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}];Ve.propTypes={loading:d.bool,onCancel:d.func,onConfirm:d.func};Ve.defaultProps={loading:!1,onCancel:()=>{},onConfirm:()=>{}};function Ve({loading:t=!1,onCancel:s,onConfirm:n}){const{t:r}=te(),[o,a]=y.useState(ls),[x,u]=y.useState(!0),R=(v,S)=>{S.checked=v.target.checked;const I=o.map(M=>({...M,checked:M.value===S.value?S.checked:M.checked}));a(I)},m=v=>{v.stopPropagation(),n({channels:o.filter(S=>S.checked).map(S=>S.value),isResendFailedOnly:x})};return e.jsxs(C,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(J,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(C,{className:"choose-channel",children:e.jsxs(_e,{component:"fieldset",variant:"standard",children:[e.jsx(et,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Te,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(v=>e.jsx(Re,{control:e.jsx(Ie,{checked:v.checked,onChange:S=>R(S,v),name:v.value}),label:v.label},v.value))})]})}),e.jsx(C,{className:"resend-config-footer",children:e.jsx(Te,{children:e.jsx(Re,{control:e.jsx(Ie,{checked:x,onChange:v=>u(v.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(C,{display:"flex",justifyContent:"flex-end",gap:1,className:"resend-config-footer-tip",children:[e.jsx(Se,{onClick:v=>{v.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Se,{onClick:m,color:"primary",disabled:t,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[t&&e.jsx(tt,{size:16}),r("common.confirm")]})]})]})}gt.propTypes={notificationId:d.string.isRequired,handleResend:d.func,resending:d.bool};function gt({notificationId:t,handleResend:s,resending:n=!1}){const{t:r,locale:o}=te(),{getReceivers:a,inService:x,teamDid:u,getUser:R,blocklet:m}=We(),[v,S]=y.useState(!1),[I,M]=y.useState([]),E=De({anchorEl:null,position:null}),L=De({anchorEl:null,position:null}),[A,G]=y.useState(null),[H,U]=y.useState({total:0,pageSize:10,pageCount:0,page:1}),[N,k]=y.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[V().subtract(1,"month").startOf("day").toDate(),V().endOf("day").toDate()]}),[h,O]=y.useState([]),D=[{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"}],F=async()=>{if(!v&&t)try{S(!0);const i=await a({notificationId:t,...N}),l=i.list.map(c=>({...c,receiverUser:{...c.receiverUser,avatar:ot(c.receiverUser.avatar,u,x)}}));M(l),U(i.paging),S(!1)}catch(i){Z.error(i.message),S(!1)}};y.useEffect(()=>{F()},[N]);const B=i=>{i.stopPropagation();const l=i.currentTarget;L.anchorEl=l;const c=l.getBoundingClientRect();L.position={top:c.top+window.scrollY,left:c.left+window.scrollX}},q=i=>i.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(Ae,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(ze,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:B,children:r("notification.resend")})}):null,Q={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:H.page-1,rowsPerPage:H.pageSize,count:H.total,searchText:N.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:h,onRowSelectionChange:(i,l)=>{O(l.map(c=>c.dataIndex))},customToolbarSelect:q},z=({page:i,rowsPerPage:l,searchText:c,filterList:j})=>{const[,_=[],$=[],K=[]]=j;N.pageSize!==l?k(W=>({...W,pageSize:l,page:1})):N.page!==i+1?k(W=>({...W,page:i+1})):N.searchText!==c?k(W=>({...W,searchText:c,page:1})):ue(_,N.walletSendStatus)?ue($,N.pushKitSendStatus)?ue(K,N.emailSendStatus)||k(W=>({...W,emailSendStatus:K,page:1})):k(W=>({...W,pushKitSendStatus:$,page:1})):k(W=>({...W,walletSendStatus:_,page:1}))},oe=y.useCallback(async(i,l)=>{if(!l)return!1;const c=await R(l);return c?i==="wallet"?ns(c):i==="email"?ts(m,c):i==="pushKit"?ss(m,c):i==="webhook"?as(c):!0:!1},[R,m]),se=y.useCallback(i=>is(r,i),[r]),f=()=>{E.anchorEl=null,E.position=null,G(null)},p=()=>{L.anchorEl=null,L.position=null},g=async(i,l,c=!0,j="")=>{if(!(!l.length||!i.length))try{s(i,l,c,j),L.anchorEl||(await xe(.5),f())}catch(_){console.error("handleResend error",{error:_})}},b=async({channels:i,isResendFailedOnly:l})=>{const c=h.map(j=>I[j].receiver);await g(i,c,l),await xe(.5),p(),O([])},T=async(i,l=[],c=!0)=>{try{await g(["webhook"],[i.receiver],c,l)}catch(j){Z.error(j.response?j.response.statusText:j.message)}},w=async(i,l,c,j=[],_=!0)=>{if(i.stopPropagation(),os(l,c)>=4){Z.warning(r("notification.resendLimit"));return}if(!Le.includes(c)){await T(l,j,_);return}if(i){const K=i.currentTarget,W=K.getBoundingClientRect();E.anchorEl=K,E.position={top:W.top+window.scrollY,left:W.left+window.scrollX}}G({channel:c});try{const K=await oe(c,l.receiver);await xe(1),G({channel:c,result:K}),(typeof K=="boolean"&&K||Ct(K)&&Object.values(K).every(W=>!!W))&&(await s([c],[l.receiver],_),L.anchorEl||(await xe(.5),f()))}catch(K){Z.error(K.message)}},Y=i=>{k(l=>({...l,dateRange:i,page:1}))},X=(i,l,c,j)=>{i.stopPropagation();const _=c.filter($=>$!==l);k($=>({...$,[j]:_,page:1}))},ae=ee(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:i=>{const{receiverUser:l,receiver:c}=I[i];return l?e.jsxs(C,{"data-cy":`member-name-${l.fullName}`,display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start",children:[e.jsx(nt,{src:`${l.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:c,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(he,{children:l.fullName})]},c):e.jsx(kt,{size:14,responsive:!1,compact:!0,copyable:!1,did:c})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:N.walletSendStatus??[],customFilterListOptions:{render:i=>e.jsx(pe,{list:i,label:"Wallet",onDelete:(l,c)=>{l.stopPropagation(),X(l,c,ae[1].options.filterList,"walletSendStatus")}}),update:je},filterOptions:{names:D,fullWidth:!0,logic:ve,display:(i,l,c,j)=>e.jsx(we,{label:"Wallet",filterList:i,onChange:l,index:c,column:j,filterValues:D})},customBodyRenderLite:i=>{const{walletSendStatus:l,walletSendAt:c,walletSendFailedReason:j}=I[i];return e.jsx(de,{status:l,updatedAt:c,reason:j,channel:"wallet",onResend:_=>w(_,I[i],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:i=>{const{pushKitSendStatus:l,pushKitSendAt:c,pushKitSendFailedReason:j}=I[i];return e.jsx(de,{status:l,updatedAt:c,reason:j,channel:"pushkit",onResend:_=>w(_,I[i],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:N.pushKitSendStatus??[],customFilterListOptions:{render:i=>e.jsx(pe,{list:i,label:"Push Kit",onDelete:(l,c)=>{l.stopPropagation(),X(l,c,ae[2].options.filterList,"pushKitSendStatus")}}),update:je},filterOptions:{names:D,fullWidth:!0,logic:ve,display:(i,l,c,j)=>e.jsx(we,{label:"Push Kit",filterList:i,onChange:l,index:c,column:j,filterValues:D})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:i=>{const{emailSendStatus:l,emailSendAt:c,emailSendFailedReason:j}=I[i];return e.jsx(de,{status:l,updatedAt:c,reason:j,channel:"email",onResend:_=>w(_,I[i],"email",[],!1)})},filter:!0,filterType:"custom",filterList:N.emailSendStatus??[],customFilterListOptions:{render:i=>e.jsx(pe,{list:i,label:"Email",onDelete:(l,c)=>{l.stopPropagation(),X(l,c,ae[3].options.filterList,"emailSendStatus")}}),update:je},filterOptions:{names:D,fullWidth:!0,logic:ve,display:(i,l,c,j)=>e.jsx(we,{label:"Email",filterList:i,onChange:l,index:c,column:j,filterValues:D})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:i=>{const{webhook:l}=I[i];if(!l)return null;const c=Object.entries(l)[0];if(!c)return null;const[j,_]=c,$=_[0];return e.jsx(C,{display:"flex",flexDirection:"column",gap:1,children:e.jsxs(C,{className:"webhook-item",fontSize:12,children:[e.jsx(he,{maxLength:30,children:j},j),e.jsx(de,{status:$.status,updatedAt:$.sendAt,reason:$.failedReason,channel:"webhook",onResend:K=>w(K,I[i],"webhook",[j],!1)})]},j)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:i=>{const{createdAt:l}=I[i];return e.jsx(Be,{value:l,locale:o,shouldUpdate:!0})}}}],[I,o,N,r]),Ye=[e.jsx(Ue,{value:N.dateRange,onChange:Y},"date-picker"),e.jsx(Ae,{variant:"contained",size:"small",color:"primary",loading:v,startIcon:e.jsx(ut,{}),onClick:()=>F(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(C,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(ds,{children:e.jsxs(st,{theme:ht(),children:[e.jsx(at,{className:"receivers-table",locale:o,loading:v,columns:ae,data:I,onChange:z,options:Q,customButtons:Ye,components:{TableFilterList:i=>e.jsx($e,{...i,itemComponent:l=>e.jsx(Ce,{...l,canDelete:()=>!1})})}}),E.anchorEl&&e.jsx(Ee,{open:!!E.anchorEl,anchorReference:"anchorPosition",anchorPosition:E.position,onClose:f,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(us,{children:[e.jsxs(J,{variant:"body1",component:"div",className:"check-title",children:[A==null?void 0:A.channel," Checking"]}),e.jsx(C,{display:"flex",flexDirection:"column",sx:{gap:"4px"},children:se(A==null?void 0:A.channel).map(i=>{var _,$;const{type:l,pass:c,fail:j}=i;return!(A!=null&&A.result)||(_=A==null?void 0:A.result)!=null&&_[l]?e.jsxs(J,{variant:"body1",component:"div",className:"check-item",display:"flex",alignItems:"center",sx:{gap:"4px",color:($=A==null?void 0:A.result)!=null&&$[l]?ye.success.main:"inherit"},children:[A!=null&&A.result?e.jsx(ct,{}):e.jsx(tt,{size:12,sx:{color:ye.primary.main}}),e.jsx("span",{children:c})]},l):e.jsxs(J,{variant:"body1",component:"div",display:"flex",alignItems:"center",className:"check-item",sx:{gap:"4px",color:ye.error.main},children:[e.jsx(dt,{}),e.jsx("span",{children:j})]},l)})})]})}),L.anchorEl&&e.jsx(Ee,{open:!!L.anchorEl,anchorReference:"anchorPosition",anchorPosition:L.position,onClose:p,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Ve,{loading:n,onCancel:p,onConfirm:b})})]})})})}const cs=y.memo(gt),ds=ce.div`
|
|
2
2
|
td.MuiTableCell-footer {
|
|
3
3
|
border: none !important;
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as $,Y as W,bM as Y,I as be,_ as fe,a5 as ge,bt as je}from"./vendor-ux-did-connect-CsNUdA6Y.js";import{t as ye,m as de,j as we}from"./vendor-hooks-DftG_2gV.js";import{r as C,b as X}from"./vendor-react-DEoibe3W.js";import{d as Z}from"./InfoOutlined-B-fGWta1.js";import{z as F,E as ke,F as K,C as ce,t as ve}from"./index-CGJUebpH.js";import{u as N}from"./dashboard-DrtJT0zg.js";import{H as o,j as e,D as Ee,ai as Ce,t as Te,a9 as f,O as ie,T as S,aa as U,aj as ee,z as Se,y as B,bs as le,bS as V,ac as A,L as Q,A as G,bc as Re,E as O,I as _,C as Ie,bq as Me,ak as P,ce as Pe,X as De,bb as J,bp as ze,b4 as We,cf as Ae,cg as Oe,b5 as qe,am as $e,c1 as Le,s as pe,v as Be,ch as He,ci as Fe,cj as Ne,ck as Ue,cl as _e}from"./vendor-mui-core-CQ38ohp2.js";import{q as Ye}from"./vendor-arcblock-BUng-RXZ.js";import{d as Ke}from"./ExpandLess-BpA2naWp.js";import{z as ue,x as Ve,y as Je}from"./vendor-utils-BNHJB5U7.js";import{C as Qe}from"./confirm-qekNSA6N.js";import{A as Ge}from"./actions-BPVh6JdI.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-BxIzITf9.js";import"./PlayArrow-Cja7S4vv.js";import"./get-safe-url-BZgGKuU5.js";import"./format-error-BrmqJs5a.js";import"./session-BoLXmmdy.js";import"./index-BoJFRi1m.js";import"./dot-BE1YP292.js";import"./useAsync-CGW40D2-.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-DlKplWTG.js";import"./MoreHoriz-3W8Fr_ZL.js";const Xe=t=>{var j,y;const[d,c]=C.useState(null),[a,b]=C.useState(!t),[R,p]=C.useState(null),{blocklet:n}=ce(),l=(y=(j=n==null?void 0:n.site)==null?void 0:j.domainAliases[0])==null?void 0:y.value,v=C.useMemo(()=>{const h={};return d&&(d.sources.forEach(r=>{h[r.did]={source:r,events:[],count:0}}),d.events.forEach(r=>{h[r.source]&&(h[r.source].events.push(r),h[r.source].count+=1)})),h},[d]),T=async()=>{try{if(b(!0),!l)return;const r=await(await fetch(`https://${l}/.well-known/service/openevent.json`)).json();c(r),p(null)}catch(h){p(h instanceof Error?h:new Error(String(h)))}finally{b(!1)}};return C.useEffect(()=>{T()},[l]),{openEvent:d,setOpenEvent:c,eventsBySource:v,loading:a,error:R,loadData:T}};function te({eventsBySource:t,selectedEvents:d,setSelectedEvents:c,error:a}){const{t:b}=$(),[R,p]=C.useState({}),n=C.useMemo(()=>{const r={};return Object.entries(t).forEach(([w,{events:g}])=>{const E=g.filter(u=>d[`${u.type}-${u.source}`]).length;r[w]=E}),r},[t,d]),l=C.useMemo(()=>Object.values(n).reduce((r,w)=>r+w,0),[n]),v=C.useMemo(()=>Object.values(t).reduce((r,{events:w})=>r+w.length,0),[t]),T=(r,w)=>{w.stopPropagation(),p({...R,[r]:!R[r]})},j=r=>{const w=`${r.type}-${r.source}`;c(g=>({...g,[w]:!g[w]}))},y=(r,w)=>{const g={};r.forEach(E=>{const u=`${E.type}-${E.source}`;g[u]=!w}),c(E=>({...E,...g}))},h=r=>{const w={};Object.values(t).forEach(({events:g})=>{g.forEach(E=>{const u=`${E.type}-${E.source}`;w[u]=r.target.checked})}),c(w)};return e.jsxs(f,{sx:{width:"100%"},children:[e.jsxs(f,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(le,{control:e.jsx(V,{onChange:h,checked:l>0&&l===v}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[b("webhookEndpoint.selectAllEvents"),e.jsx(f,{sx:{display:"flex",alignItems:"center"},children:e.jsx(A,{title:b("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(Z,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),l>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:b("webhookEndpoint.selectedEventsCount",{count:l})})]}),e.jsx(f,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(Q,{disablePadding:!0,sx:{border:"1px solid #e0e0e0",borderRadius:"4px"},children:Object.entries(t).map(([r,{source:w,events:g,count:E}],u)=>{const M=n[r]>0,i=n[r]===g.length&&g.length>0,x=R[r];return e.jsxs(X.Fragment,{children:[e.jsx(G,{sx:{borderBottom:u<Object.keys(t).length-1?"1px solid #f0f0f0":"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(f,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:s=>{s.target.closest(".MuiFormControlLabel-root")||T(r,s)},children:[e.jsx(f,{sx:{display:"flex",alignItems:"center"},children:g.length>0&&e.jsx(le,{control:e.jsx(V,{checked:i,indeterminate:M&&!i,onChange:s=>{s.stopPropagation(),y(g,i)}}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[w.logo&&e.jsx(Re,{src:w.logo,sx:{width:24,height:24}}),e.jsx(f,{children:w.title||r}),M&&e.jsx(O,{label:b("webhookEndpoint.selectedCount",{count:n[r]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:s=>`${s.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(f,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",color:"text.secondary",sx:{mr:1},children:b("webhookEndpoint.eventsCount",{count:E})}),g.length>0&&e.jsx(_,{size:"small",edge:"end",children:x?e.jsx(Ke,{}):e.jsx(Ye,{})})]})]})}),g.length>0&&e.jsx(Ie,{in:x,timeout:"auto",unmountOnExit:!0,children:e.jsx(Q,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:g.map(s=>{const m=`${s.type}-${s.source}`,k=!!d[m];return e.jsx(G,{dense:!0,sx:{py:.75},onClick:()=>j(s),children:e.jsxs(f,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(V,{checked:k,sx:{mr:1}}),e.jsxs(f,{children:[e.jsx(S,{variant:"body1",sx:{cursor:"pointer"},children:s.type}),e.jsx(S,{variant:"caption",color:"text.disabled",sx:{display:"block",cursor:"pointer"},children:s.description})]})]})},m)})})})]},r)})})}),a&&e.jsx(Me,{error:!0,sx:{mt:1},children:a})]})}te.propTypes={eventsBySource:o.objectOf(o.shape({source:o.shape({did:o.string.isRequired,title:o.string,description:o.string,version:o.string,logo:o.string}).isRequired,events:o.arrayOf(o.shape({type:o.string.isRequired,description:o.string.isRequired,source:o.string.isRequired})).isRequired,count:o.number.isRequired})).isRequired,selectedEvents:o.objectOf(o.bool).isRequired,setSelectedEvents:o.func.isRequired,error:o.string};te.defaultProps={error:null};function oe({id:t,url:d,description:c,enabledEvents:a,onSubmit:b,onClose:R}){var s;const{t:p}=$(),[n,l]=C.useState({}),{teamDid:v}=N(),{api:T}=F(),{loading:j,error:y,eventsBySource:h}=Xe(),{control:r,handleSubmit:w,formState:{errors:g},reset:E,setValue:u,trigger:M}=ke({defaultValues:{url:"",description:""}});C.useEffect(()=>{const m=Object.values(n).some(k=>k);u("selectedEvents",m?"valid":""),M("selectedEvents")},[n,u,M]);const i=()=>{l({}),E(),R()},x=async m=>{const k=Object.keys(n).filter(I=>n[I]),D={url:m.url,description:m.description,enabledEvents:k.map(I=>{const[q,L]=I.split("-");return!q||!L?null:{type:q,source:L}}).filter(Boolean)};try{if(t){const I=await T.updateWebhookEndpoint({input:{teamDid:v,id:t,data:D}});W.success(`${p("webhookEndpoint.updateWebhook")} ${p("webhookEndpoint.success")}`),b(I)}else{const I=await T.createWebhookEndpoint({input:{teamDid:v,input:D}});W.success(`${p("webhookEndpoint.createWebhook")} ${p("webhookEndpoint.success")}`),b(I)}}catch(I){W.error(I==null?void 0:I.message)}i()};return C.useEffect(()=>{E({url:d,description:c}),l(a.reduce((m,k)=>(m[`${k.type}-${k.source}`]=!0,m),{}))},[E,l,d,c,a]),e.jsx(Ee,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:w(x),children:[e.jsx(Ce,{children:p(t?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Te,{children:e.jsxs(f,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(K,{name:"url",control:r,rules:{required:p("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:p("webhookEndpoint.validation.urlInvalid")}},render:({field:m})=>{var k;return e.jsx(ie,{...m,label:p("webhookEndpoint.url.label"),fullWidth:!0,error:!!g.url,helperText:(k=g.url)==null?void 0:k.message})}}),e.jsx(K,{name:"description",control:r,rules:{required:p("webhookEndpoint.validation.descriptionRequired")},render:({field:m})=>{var k;return e.jsx(ie,{...m,label:p("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!g.description,helperText:(k=g.description)==null?void 0:k.message})}}),e.jsx(K,{name:"selectedEvents",control:r,rules:{required:p("webhookEndpoint.validation.eventRequired")},render:({field:m})=>e.jsx("input",{type:"hidden",...m})}),!j&&h&&Object.keys(h).length>0&&e.jsx(te,{eventsBySource:h,selectedEvents:n,setSelectedEvents:l,error:(s=g.selectedEvents)==null?void 0:s.message}),!j&&(!h||Object.keys(h).length===0)&&e.jsx(S,{color:"text.secondary",children:p("webhookEndpoint.noAvailableEvents")}),j&&e.jsx(f,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(U,{size:20})}),y&&e.jsx(ee,{severity:"error",children:p("webhookEndpoint.loadingError",{message:y==null?void 0:y.message})})]})}),e.jsxs(Se,{sx:{p:"8px 24px 24px"},children:[e.jsx(B,{onClick:i,children:p("common.cancel")}),e.jsx(B,{type:"submit",variant:"contained",color:"primary",children:p(t?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}oe.propTypes={onSubmit:o.func.isRequired,id:o.string,url:o.string,description:o.string,enabledEvents:o.arrayOf(o.shape({type:o.string.isRequired,source:o.string.isRequired})),onClose:o.func};oe.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function he(t){switch(t){case"enabled":return"success";case"disabled":default:return"default"}}const Ze=(t="en")=>t==="tw"?"zh":t;function H(t,d="YYYY-MM-DD HH:mm:ss",c="en"){return t?ve(t).locale(Ze(c)).format(d):"-"}function et(t){return typeof t=="number"?!1:ue(t)}function tt(t){return t>=200&&t<300}function z(t){const d=et(t.value);return e.jsxs(e.Fragment,{children:[e.jsxs(P,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[t.label,!!t.tip&&e.jsx(A,{title:t.tip,children:e.jsx(Pe,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:d?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:d?"-":t.value})]}),t.divider&&e.jsx(De,{orientation:"vertical",flexItem:!0})]})}z.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};z.defaultProps={tip:"",divider:!1};function ne(t){return e.jsxs(P,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:t.mb,mt:t.mt,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:t.title}),t.children]})}ne.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};ne.defaultProps={children:null,mb:1.5,mt:1.5};const ot={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6m-7 1l9-9m-5 0h5v5"/>'},nt=t=>{const d={};return t.forEach(c=>{var b;const a=new Date(c.createdAt).toLocaleDateString();d[a]||(d[a]=[]),(b=d[a])==null||b.push(c)}),d};function se({eventId:t,webhookEndpointId:d,event:c}){const{api:a}=F(),{t:b}=$(),{teamDid:R}=N(),{blocklet:p}=ce(),{data:n,loadMore:l,loadingMore:v,loading:T}=ye(u=>{const i=u?Math.ceil(u.list.length/15)+1:1;return a.getWebhookAttempts({input:{teamDid:R,input:{eventId:t,webhookId:d},paging:{page:i,pageSize:15}}})},{reloadDeps:[t,d]}),j=(n==null?void 0:n.list)||[],[y,h]=C.useState(null),r=nt(j);C.useEffect(()=>{!y&&(n!=null&&n.list.length)&&h(n.list[0])},[n==null?void 0:n.list.length,y]);const w=u=>{h(u)};if(T)return e.jsx(U,{});const g=n&&n.list.length<n.paging.total,E=u=>{var M,i,x,s,m;if(u.responseBody&&((M=u.responseBody)!=null&&M.sessionId)&&((i=u.responseBody)!=null&&i.projectId)&&((x=u.responseBody)!=null&&x.agentId)){const k=(m=(s=p==null?void 0:p.site)==null?void 0:s.domainAliases[0])==null?void 0:m.value,D=(p.children||[]).find(q=>{var L;return((L=q==null?void 0:q.meta)==null?void 0:L.name)==="ai-studio"}),I=Ve(Je(`https://${k}`,(D==null?void 0:D.mountPoint)||"","projects",u.responseBody.projectId,"logs/main"),{sessionId:u.responseBody.sessionId,agentId:u.responseBody.agentId});return e.jsx(_,{sx:{fontSize:20},onClick:()=>window.open(I,"_blank"),children:e.jsx(f,{component:be,icon:ot})})}return null};return e.jsxs(J,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(J,{item:!0,xs:12,md:4,height:1,children:ue(Object.keys(r))?e.jsx(S,{color:"text.secondary",children:b("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(r).map(([u,M])=>e.jsxs(X.Fragment,{children:[e.jsx(ze,{children:u}),M.map(i=>e.jsxs(G,{sx:{cursor:"pointer"},onClick:()=>w(i),selected:y===i,secondaryAction:e.jsx(S,{color:"text.secondary",children:H(i.createdAt,"HH:mm:ss")}),children:[e.jsx(We,{sx:{minWidth:0,mr:1.5},children:tt(i.responseStatus)===!1?e.jsx(Ae,{color:"error"}):e.jsx(Oe,{color:"success"})}),e.jsx(qe,{primary:e.jsx(S,{color:"text.primary",children:i.event.type})})]},i.id))]},u))}),g&&e.jsx(f,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(B,{variant:"text",type:"button",color:"inherit",onClick:l,disabled:v,sx:{color:u=>u.palette.text.disabled},children:b(v?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(J,{item:!0,xs:12,md:8,height:1,children:[y&&e.jsxs(P,{height:1,overflow:"auto",direction:"column",spacing:2,sx:{pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h6",children:t?y.endpoint.url:y.event.type}),e.jsx(f,{children:E(y)})]}),e.jsxs(f,{children:[e.jsxs(S,{variant:"h6",children:[b("webhookEndpoint.response")," (",y.responseStatus,")"]}),e.jsx(Y,{language:"json",children:JSON.stringify(y.responseBody,null,2)})]}),e.jsxs(f,{children:[e.jsx(P,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:b("webhookEndpoint.request")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(y.event,null,2)})]})]}),(n==null?void 0:n.list.length)===0&&c&&e.jsxs(f,{children:[e.jsx(P,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:b("webhookEndpoint.eventData")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}se.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};se.defaultProps={eventId:"",webhookEndpointId:"",event:null};function xe({id:t,onClose:d}){var v,T,j,y;const{t:c}=$(),{api:a}=F(),{teamDid:b}=N(),{loading:R,error:p,data:n}=de(()=>a.getWebhookEndpoint({input:{teamDid:b,id:t}})),l=n==null?void 0:n.data;return p?e.jsx(ee,{severity:"error",children:p.message}):R||!l?e.jsx(f,{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1,children:e.jsx(U,{})}):e.jsxs(st,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(f,{children:[e.jsxs(P,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(P,{flex:1,width:0,children:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h5",fontWeight:600,sx:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:l.description}),e.jsx(A,{title:l.url,children:e.jsx(Z,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(P,{direction:"row",alignItems:"center",children:e.jsx(_,{edge:"end",color:"inherit",onClick:d,children:e.jsx(Le,{})})})]}),e.jsx(f,{mt:2,children:e.jsxs(P,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},justifyContent:"flex-start",flexWrap:"wrap",sx:{pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx(z,{label:c("common.status"),value:e.jsx(O,{size:"small",variant:"filled",label:l.status,color:he(l.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx(z,{label:c("webhookEndpoint.listen"),value:e.jsx(A,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:l.enabledEvents.map(h=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:h==null?void 0:h.type},h))}),children:e.jsx(O,{size:"small",variant:"filled",label:c("webhookEndpoint.eventsCount",{count:l.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(z,{label:c("webhookEndpoint.version"),value:l.apiVersion,divider:!0}),e.jsx(z,{label:c("common.createdAt"),value:H(l.createdAt),divider:!0}),e.jsx(z,{label:c("common.updatedAt"),value:H(l.updatedAt),divider:!0}),e.jsx(z,{label:c("common.createdBy"),value:e.jsx(A,{arrow:!0,title:(v=l.createUser)==null?void 0:v.did,children:e.jsx(O,{size:"small",variant:"filled",label:(T=l.createUser)==null?void 0:T.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(z,{label:c("common.updatedBy"),value:e.jsx(A,{arrow:!0,title:(j=l.updateUser)==null?void 0:j.did,children:e.jsx(O,{size:"small",variant:"filled",label:(y=l.updateUser)==null?void 0:y.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(P,{className:"section",flex:1,height:0,overflow:"hidden",children:[e.jsx(ne,{title:c("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(P,{height:0,flex:1,overflow:"hidden",children:e.jsx(se,{webhookEndpointId:l.id})})]})]})}xe.propTypes={id:o.string.isRequired,onClose:o.func.isRequired};const st=pe(P)``;function me({open:t,onClose:d,id:c}){return e.jsx($e,{anchor:"right",open:t,onClose:d,PaperProps:{sx:{width:"90vw",maxWidth:"1200px"}},children:e.jsx(f,{sx:{height:"100vh",p:3},children:e.jsx(xe,{id:c,onClose:d})})})}me.propTypes={open:o.bool.isRequired,onClose:o.func.isRequired,id:o.string.isRequired};function ae(){return null}const re=X.memo(({options:t,columns:d,toolbar:c=!0,footer:a=!0,hasRowLink:b=!1,emptyNodeText:R="",...p})=>{const{locale:n}=$(),l=Be(j=>j.breakpoints.down("md")),v={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:l?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},T={};return c||(T.TableToolbar=ae),a||(T.TableFooter=ae),e.jsx(rt,{locale:n,options:{...v,...t},columns:(d||[]).map(j=>(j.options=j.options||{},j.options.filter=j.options.filter||!1,j.options.sort=j.options.sort||!1,j)),emptyNode:e.jsx(fe,{children:R}),...p,components:T,hasRowLink:b,isMobile:l})});re.propTypes={options:o.object,columns:o.array,toolbar:o.bool,footer:o.bool,hasRowLink:o.bool,emptyNodeText:o.node,durable:o.string,durableKeys:o.array,data:o.array,loading:o.bool,onChange:o.func,title:o.node,components:o.object};re.defaultProps={options:{},columns:[],toolbar:!0,footer:!0,hasRowLink:!1,emptyNodeText:null,durable:"",durableKeys:[],data:[],loading:!1,onChange:()=>{},title:null,components:{}};const rt=pe(ge)`
|
|
1
|
+
import{u as $,Y as W,bM as Y,I as be,_ as fe,a5 as ge,bt as je}from"./vendor-ux-did-connect-BdkhddhO.js";import{t as ye,m as de,j as we}from"./vendor-hooks-DftG_2gV.js";import{r as C,b as X}from"./vendor-react-DEoibe3W.js";import{d as Z}from"./InfoOutlined-CQB5qKm-.js";import{z as F,E as ke,F as K,C as ce,t as ve}from"./index-DO3_1y-L.js";import{u as N}from"./dashboard-8QXGSoVu.js";import{H as o,j as e,D as Ee,ai as Ce,t as Te,a9 as f,O as ie,T as S,aa as U,aj as ee,z as Se,y as B,bs as le,bS as V,ac as A,L as Q,A as G,bc as Re,E as O,I as _,C as Ie,bq as Me,ak as P,ce as Pe,X as De,bb as J,bp as ze,b4 as We,cf as Ae,cg as Oe,b5 as qe,am as $e,c1 as Le,s as pe,v as Be,ch as He,ci as Fe,cj as Ne,ck as Ue,cl as _e}from"./vendor-mui-core-CQ38ohp2.js";import{q as Ye}from"./vendor-arcblock-ScFEr-lj.js";import{d as Ke}from"./ExpandLess-BiMmSOBl.js";import{z as ue,x as Ve,y as Je}from"./vendor-utils-BNHJB5U7.js";import{C as Qe}from"./confirm-DqvNmeoz.js";import{A as Ge}from"./actions-DA-6s_nQ.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-DldnaMbZ.js";import"./PlayArrow-DFH1Psjx.js";import"./get-safe-url-DBsPGn--.js";import"./format-error-BrmqJs5a.js";import"./session-VIMbdc9j.js";import"./index-DcBUShKK.js";import"./dot-BE1YP292.js";import"./useAsync-CGW40D2-.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-C_flBrm-.js";import"./MoreHoriz-CX_pwfPT.js";const Xe=t=>{var j,y;const[d,c]=C.useState(null),[a,b]=C.useState(!t),[R,p]=C.useState(null),{blocklet:n}=ce(),l=(y=(j=n==null?void 0:n.site)==null?void 0:j.domainAliases[0])==null?void 0:y.value,v=C.useMemo(()=>{const h={};return d&&(d.sources.forEach(r=>{h[r.did]={source:r,events:[],count:0}}),d.events.forEach(r=>{h[r.source]&&(h[r.source].events.push(r),h[r.source].count+=1)})),h},[d]),T=async()=>{try{if(b(!0),!l)return;const r=await(await fetch(`https://${l}/.well-known/service/openevent.json`)).json();c(r),p(null)}catch(h){p(h instanceof Error?h:new Error(String(h)))}finally{b(!1)}};return C.useEffect(()=>{T()},[l]),{openEvent:d,setOpenEvent:c,eventsBySource:v,loading:a,error:R,loadData:T}};function te({eventsBySource:t,selectedEvents:d,setSelectedEvents:c,error:a}){const{t:b}=$(),[R,p]=C.useState({}),n=C.useMemo(()=>{const r={};return Object.entries(t).forEach(([w,{events:g}])=>{const E=g.filter(u=>d[`${u.type}-${u.source}`]).length;r[w]=E}),r},[t,d]),l=C.useMemo(()=>Object.values(n).reduce((r,w)=>r+w,0),[n]),v=C.useMemo(()=>Object.values(t).reduce((r,{events:w})=>r+w.length,0),[t]),T=(r,w)=>{w.stopPropagation(),p({...R,[r]:!R[r]})},j=r=>{const w=`${r.type}-${r.source}`;c(g=>({...g,[w]:!g[w]}))},y=(r,w)=>{const g={};r.forEach(E=>{const u=`${E.type}-${E.source}`;g[u]=!w}),c(E=>({...E,...g}))},h=r=>{const w={};Object.values(t).forEach(({events:g})=>{g.forEach(E=>{const u=`${E.type}-${E.source}`;w[u]=r.target.checked})}),c(w)};return e.jsxs(f,{sx:{width:"100%"},children:[e.jsxs(f,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(le,{control:e.jsx(V,{onChange:h,checked:l>0&&l===v}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[b("webhookEndpoint.selectAllEvents"),e.jsx(f,{sx:{display:"flex",alignItems:"center"},children:e.jsx(A,{title:b("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(Z,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),l>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:b("webhookEndpoint.selectedEventsCount",{count:l})})]}),e.jsx(f,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(Q,{disablePadding:!0,sx:{border:"1px solid #e0e0e0",borderRadius:"4px"},children:Object.entries(t).map(([r,{source:w,events:g,count:E}],u)=>{const M=n[r]>0,i=n[r]===g.length&&g.length>0,x=R[r];return e.jsxs(X.Fragment,{children:[e.jsx(G,{sx:{borderBottom:u<Object.keys(t).length-1?"1px solid #f0f0f0":"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(f,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:s=>{s.target.closest(".MuiFormControlLabel-root")||T(r,s)},children:[e.jsx(f,{sx:{display:"flex",alignItems:"center"},children:g.length>0&&e.jsx(le,{control:e.jsx(V,{checked:i,indeterminate:M&&!i,onChange:s=>{s.stopPropagation(),y(g,i)}}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[w.logo&&e.jsx(Re,{src:w.logo,sx:{width:24,height:24}}),e.jsx(f,{children:w.title||r}),M&&e.jsx(O,{label:b("webhookEndpoint.selectedCount",{count:n[r]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:s=>`${s.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(f,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",color:"text.secondary",sx:{mr:1},children:b("webhookEndpoint.eventsCount",{count:E})}),g.length>0&&e.jsx(_,{size:"small",edge:"end",children:x?e.jsx(Ke,{}):e.jsx(Ye,{})})]})]})}),g.length>0&&e.jsx(Ie,{in:x,timeout:"auto",unmountOnExit:!0,children:e.jsx(Q,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:g.map(s=>{const m=`${s.type}-${s.source}`,k=!!d[m];return e.jsx(G,{dense:!0,sx:{py:.75},onClick:()=>j(s),children:e.jsxs(f,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(V,{checked:k,sx:{mr:1}}),e.jsxs(f,{children:[e.jsx(S,{variant:"body1",sx:{cursor:"pointer"},children:s.type}),e.jsx(S,{variant:"caption",color:"text.disabled",sx:{display:"block",cursor:"pointer"},children:s.description})]})]})},m)})})})]},r)})})}),a&&e.jsx(Me,{error:!0,sx:{mt:1},children:a})]})}te.propTypes={eventsBySource:o.objectOf(o.shape({source:o.shape({did:o.string.isRequired,title:o.string,description:o.string,version:o.string,logo:o.string}).isRequired,events:o.arrayOf(o.shape({type:o.string.isRequired,description:o.string.isRequired,source:o.string.isRequired})).isRequired,count:o.number.isRequired})).isRequired,selectedEvents:o.objectOf(o.bool).isRequired,setSelectedEvents:o.func.isRequired,error:o.string};te.defaultProps={error:null};function oe({id:t,url:d,description:c,enabledEvents:a,onSubmit:b,onClose:R}){var s;const{t:p}=$(),[n,l]=C.useState({}),{teamDid:v}=N(),{api:T}=F(),{loading:j,error:y,eventsBySource:h}=Xe(),{control:r,handleSubmit:w,formState:{errors:g},reset:E,setValue:u,trigger:M}=ke({defaultValues:{url:"",description:""}});C.useEffect(()=>{const m=Object.values(n).some(k=>k);u("selectedEvents",m?"valid":""),M("selectedEvents")},[n,u,M]);const i=()=>{l({}),E(),R()},x=async m=>{const k=Object.keys(n).filter(I=>n[I]),D={url:m.url,description:m.description,enabledEvents:k.map(I=>{const[q,L]=I.split("-");return!q||!L?null:{type:q,source:L}}).filter(Boolean)};try{if(t){const I=await T.updateWebhookEndpoint({input:{teamDid:v,id:t,data:D}});W.success(`${p("webhookEndpoint.updateWebhook")} ${p("webhookEndpoint.success")}`),b(I)}else{const I=await T.createWebhookEndpoint({input:{teamDid:v,input:D}});W.success(`${p("webhookEndpoint.createWebhook")} ${p("webhookEndpoint.success")}`),b(I)}}catch(I){W.error(I==null?void 0:I.message)}i()};return C.useEffect(()=>{E({url:d,description:c}),l(a.reduce((m,k)=>(m[`${k.type}-${k.source}`]=!0,m),{}))},[E,l,d,c,a]),e.jsx(Ee,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:w(x),children:[e.jsx(Ce,{children:p(t?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Te,{children:e.jsxs(f,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(K,{name:"url",control:r,rules:{required:p("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:p("webhookEndpoint.validation.urlInvalid")}},render:({field:m})=>{var k;return e.jsx(ie,{...m,label:p("webhookEndpoint.url.label"),fullWidth:!0,error:!!g.url,helperText:(k=g.url)==null?void 0:k.message})}}),e.jsx(K,{name:"description",control:r,rules:{required:p("webhookEndpoint.validation.descriptionRequired")},render:({field:m})=>{var k;return e.jsx(ie,{...m,label:p("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!g.description,helperText:(k=g.description)==null?void 0:k.message})}}),e.jsx(K,{name:"selectedEvents",control:r,rules:{required:p("webhookEndpoint.validation.eventRequired")},render:({field:m})=>e.jsx("input",{type:"hidden",...m})}),!j&&h&&Object.keys(h).length>0&&e.jsx(te,{eventsBySource:h,selectedEvents:n,setSelectedEvents:l,error:(s=g.selectedEvents)==null?void 0:s.message}),!j&&(!h||Object.keys(h).length===0)&&e.jsx(S,{color:"text.secondary",children:p("webhookEndpoint.noAvailableEvents")}),j&&e.jsx(f,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(U,{size:20})}),y&&e.jsx(ee,{severity:"error",children:p("webhookEndpoint.loadingError",{message:y==null?void 0:y.message})})]})}),e.jsxs(Se,{sx:{p:"8px 24px 24px"},children:[e.jsx(B,{onClick:i,children:p("common.cancel")}),e.jsx(B,{type:"submit",variant:"contained",color:"primary",children:p(t?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}oe.propTypes={onSubmit:o.func.isRequired,id:o.string,url:o.string,description:o.string,enabledEvents:o.arrayOf(o.shape({type:o.string.isRequired,source:o.string.isRequired})),onClose:o.func};oe.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function he(t){switch(t){case"enabled":return"success";case"disabled":default:return"default"}}const Ze=(t="en")=>t==="tw"?"zh":t;function H(t,d="YYYY-MM-DD HH:mm:ss",c="en"){return t?ve(t).locale(Ze(c)).format(d):"-"}function et(t){return typeof t=="number"?!1:ue(t)}function tt(t){return t>=200&&t<300}function z(t){const d=et(t.value);return e.jsxs(e.Fragment,{children:[e.jsxs(P,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[t.label,!!t.tip&&e.jsx(A,{title:t.tip,children:e.jsx(Pe,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:d?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:d?"-":t.value})]}),t.divider&&e.jsx(De,{orientation:"vertical",flexItem:!0})]})}z.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};z.defaultProps={tip:"",divider:!1};function ne(t){return e.jsxs(P,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:t.mb,mt:t.mt,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:t.title}),t.children]})}ne.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};ne.defaultProps={children:null,mb:1.5,mt:1.5};const ot={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6m-7 1l9-9m-5 0h5v5"/>'},nt=t=>{const d={};return t.forEach(c=>{var b;const a=new Date(c.createdAt).toLocaleDateString();d[a]||(d[a]=[]),(b=d[a])==null||b.push(c)}),d};function se({eventId:t,webhookEndpointId:d,event:c}){const{api:a}=F(),{t:b}=$(),{teamDid:R}=N(),{blocklet:p}=ce(),{data:n,loadMore:l,loadingMore:v,loading:T}=ye(u=>{const i=u?Math.ceil(u.list.length/15)+1:1;return a.getWebhookAttempts({input:{teamDid:R,input:{eventId:t,webhookId:d},paging:{page:i,pageSize:15}}})},{reloadDeps:[t,d]}),j=(n==null?void 0:n.list)||[],[y,h]=C.useState(null),r=nt(j);C.useEffect(()=>{!y&&(n!=null&&n.list.length)&&h(n.list[0])},[n==null?void 0:n.list.length,y]);const w=u=>{h(u)};if(T)return e.jsx(U,{});const g=n&&n.list.length<n.paging.total,E=u=>{var M,i,x,s,m;if(u.responseBody&&((M=u.responseBody)!=null&&M.sessionId)&&((i=u.responseBody)!=null&&i.projectId)&&((x=u.responseBody)!=null&&x.agentId)){const k=(m=(s=p==null?void 0:p.site)==null?void 0:s.domainAliases[0])==null?void 0:m.value,D=(p.children||[]).find(q=>{var L;return((L=q==null?void 0:q.meta)==null?void 0:L.name)==="ai-studio"}),I=Ve(Je(`https://${k}`,(D==null?void 0:D.mountPoint)||"","projects",u.responseBody.projectId,"logs/main"),{sessionId:u.responseBody.sessionId,agentId:u.responseBody.agentId});return e.jsx(_,{sx:{fontSize:20},onClick:()=>window.open(I,"_blank"),children:e.jsx(f,{component:be,icon:ot})})}return null};return e.jsxs(J,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(J,{item:!0,xs:12,md:4,height:1,children:ue(Object.keys(r))?e.jsx(S,{color:"text.secondary",children:b("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(r).map(([u,M])=>e.jsxs(X.Fragment,{children:[e.jsx(ze,{children:u}),M.map(i=>e.jsxs(G,{sx:{cursor:"pointer"},onClick:()=>w(i),selected:y===i,secondaryAction:e.jsx(S,{color:"text.secondary",children:H(i.createdAt,"HH:mm:ss")}),children:[e.jsx(We,{sx:{minWidth:0,mr:1.5},children:tt(i.responseStatus)===!1?e.jsx(Ae,{color:"error"}):e.jsx(Oe,{color:"success"})}),e.jsx(qe,{primary:e.jsx(S,{color:"text.primary",children:i.event.type})})]},i.id))]},u))}),g&&e.jsx(f,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(B,{variant:"text",type:"button",color:"inherit",onClick:l,disabled:v,sx:{color:u=>u.palette.text.disabled},children:b(v?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(J,{item:!0,xs:12,md:8,height:1,children:[y&&e.jsxs(P,{height:1,overflow:"auto",direction:"column",spacing:2,sx:{pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h6",children:t?y.endpoint.url:y.event.type}),e.jsx(f,{children:E(y)})]}),e.jsxs(f,{children:[e.jsxs(S,{variant:"h6",children:[b("webhookEndpoint.response")," (",y.responseStatus,")"]}),e.jsx(Y,{language:"json",children:JSON.stringify(y.responseBody,null,2)})]}),e.jsxs(f,{children:[e.jsx(P,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:b("webhookEndpoint.request")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(y.event,null,2)})]})]}),(n==null?void 0:n.list.length)===0&&c&&e.jsxs(f,{children:[e.jsx(P,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:b("webhookEndpoint.eventData")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}se.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};se.defaultProps={eventId:"",webhookEndpointId:"",event:null};function xe({id:t,onClose:d}){var v,T,j,y;const{t:c}=$(),{api:a}=F(),{teamDid:b}=N(),{loading:R,error:p,data:n}=de(()=>a.getWebhookEndpoint({input:{teamDid:b,id:t}})),l=n==null?void 0:n.data;return p?e.jsx(ee,{severity:"error",children:p.message}):R||!l?e.jsx(f,{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1,children:e.jsx(U,{})}):e.jsxs(st,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(f,{children:[e.jsxs(P,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(P,{flex:1,width:0,children:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h5",fontWeight:600,sx:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:l.description}),e.jsx(A,{title:l.url,children:e.jsx(Z,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(P,{direction:"row",alignItems:"center",children:e.jsx(_,{edge:"end",color:"inherit",onClick:d,children:e.jsx(Le,{})})})]}),e.jsx(f,{mt:2,children:e.jsxs(P,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},justifyContent:"flex-start",flexWrap:"wrap",sx:{pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx(z,{label:c("common.status"),value:e.jsx(O,{size:"small",variant:"filled",label:l.status,color:he(l.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx(z,{label:c("webhookEndpoint.listen"),value:e.jsx(A,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:l.enabledEvents.map(h=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:h==null?void 0:h.type},h))}),children:e.jsx(O,{size:"small",variant:"filled",label:c("webhookEndpoint.eventsCount",{count:l.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(z,{label:c("webhookEndpoint.version"),value:l.apiVersion,divider:!0}),e.jsx(z,{label:c("common.createdAt"),value:H(l.createdAt),divider:!0}),e.jsx(z,{label:c("common.updatedAt"),value:H(l.updatedAt),divider:!0}),e.jsx(z,{label:c("common.createdBy"),value:e.jsx(A,{arrow:!0,title:(v=l.createUser)==null?void 0:v.did,children:e.jsx(O,{size:"small",variant:"filled",label:(T=l.createUser)==null?void 0:T.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(z,{label:c("common.updatedBy"),value:e.jsx(A,{arrow:!0,title:(j=l.updateUser)==null?void 0:j.did,children:e.jsx(O,{size:"small",variant:"filled",label:(y=l.updateUser)==null?void 0:y.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(P,{className:"section",flex:1,height:0,overflow:"hidden",children:[e.jsx(ne,{title:c("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(P,{height:0,flex:1,overflow:"hidden",children:e.jsx(se,{webhookEndpointId:l.id})})]})]})}xe.propTypes={id:o.string.isRequired,onClose:o.func.isRequired};const st=pe(P)``;function me({open:t,onClose:d,id:c}){return e.jsx($e,{anchor:"right",open:t,onClose:d,PaperProps:{sx:{width:"90vw",maxWidth:"1200px"}},children:e.jsx(f,{sx:{height:"100vh",p:3},children:e.jsx(xe,{id:c,onClose:d})})})}me.propTypes={open:o.bool.isRequired,onClose:o.func.isRequired,id:o.string.isRequired};function ae(){return null}const re=X.memo(({options:t,columns:d,toolbar:c=!0,footer:a=!0,hasRowLink:b=!1,emptyNodeText:R="",...p})=>{const{locale:n}=$(),l=Be(j=>j.breakpoints.down("md")),v={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:l?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},T={};return c||(T.TableToolbar=ae),a||(T.TableFooter=ae),e.jsx(rt,{locale:n,options:{...v,...t},columns:(d||[]).map(j=>(j.options=j.options||{},j.options.filter=j.options.filter||!1,j.options.sort=j.options.sort||!1,j)),emptyNode:e.jsx(fe,{children:R}),...p,components:T,hasRowLink:b,isMobile:l})});re.propTypes={options:o.object,columns:o.array,toolbar:o.bool,footer:o.bool,hasRowLink:o.bool,emptyNodeText:o.node,durable:o.string,durableKeys:o.array,data:o.array,loading:o.bool,onChange:o.func,title:o.node,components:o.object};re.defaultProps={options:{},columns:[],toolbar:!0,footer:!0,hasRowLink:!1,emptyNodeText:null,durable:"",durableKeys:[],data:[],loading:!1,onChange:()=>{},title:null,components:{}};const rt=pe(ge)`
|
|
2
2
|
.MuiPaper-root {
|
|
3
3
|
border-radius: 8px;
|
|
4
4
|
overflow: hidden;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as r,T as i}from"./vendor-mui-core-CQ38ohp2.js";import{Z as p,al as x}from"./vendor-utils-BNHJB5U7.js";import{s as c}from"./vendor-ux-did-connect-
|
|
1
|
+
import{j as r,T as i}from"./vendor-mui-core-CQ38ohp2.js";import{Z as p,al as x}from"./vendor-utils-BNHJB5U7.js";import{s as c}from"./vendor-ux-did-connect-BdkhddhO.js";function h({name:t,nameFormatter:a=o=>typeof o=="string"?o.split(" ").map(f=>p(x(f))).join(" "):o,layout:n="horizontal",children:e,valueComponent:l="div",nameWidth:s=90,...m}){return r.jsxs(u,{layout:n,width:s,...m,children:[r.jsx(i,{color:"textSecondary",className:"info-row__name",children:a(t)}),e&&r.jsx(i,{color:"textPrimary",component:l,className:"info-row__value",children:e})]})}const u=c("div")`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: ${t=>t.layout==="vertical"?"column":"row"};
|
|
4
4
|
justify-content: flex-start;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as d}from"./vendor-react-DEoibe3W.js";import{H as l,j as n,a9 as g,b3 as A,O as G,I as O,aa as U,c2 as Y,ag as J}from"./vendor-mui-core-CQ38ohp2.js";import{b2 as Q,aN as Z,d as v}from"./vendor-ux-did-connect-
|
|
1
|
+
import{r as d}from"./vendor-react-DEoibe3W.js";import{H as l,j as n,a9 as g,b3 as A,O as G,I as O,aa as U,c2 as Y,ag as J}from"./vendor-mui-core-CQ38ohp2.js";import{b2 as Q,aN as Z,d as v}from"./vendor-ux-did-connect-BdkhddhO.js";import{d as ee}from"./Done-JLiLhELm.js";import{C as te}from"./Google-GOp5YvmZ.js";import{ac as ne,f as re}from"./index-DO3_1y-L.js";import{R as oe,F as se,L as ie}from"./logo-uploader-CJrdpVcQ.js";const S={description:l.string,editing:l.bool,onChange:l.func,required:l.bool,value:l.any,componentProps:l.object,render:l.func,renderFormItem:l.func};function _({editing:r,value:o,onChange:a}){const[c,u]=d.useState(!1),m=d.useRef(),p=d.useRef(o);d.useEffect(()=>{let s=null;return r&&(s=setTimeout(()=>{u(!0)},50)),()=>{clearTimeout(s)}},[r]);const k=s=>{p.current=s,a(s)},b=()=>{u(!1),a(p.current)},C=n.jsx(g,{className:"form-item-input slot",px:1,children:n.jsxs(g,{display:"flex",alignItems:"center",children:[o,o!=="auto"&&n.jsx("div",{style:{marginLeft:4,backgroundColor:o,width:"1em",height:"1em",borderRadius:"0.2em"}})]})}),f=n.jsxs(g,{display:"flex",flexGrow:1,alignItems:"center",height:"40px",onKeyDown:b,children:[n.jsx(g,{display:"flex",alignItems:"center",onClick:()=>u(!0),children:n.jsx("div",{ref:m,style:{flexShrink:0,marginLeft:"8px",backgroundColor:o,width:"32px",height:"32px",boxSizing:"border-box",borderRadius:"8px",border:"1px solid #eee",cursor:o==="auto"?"default":"pointer"}})}),n.jsx(A,{open:c,anchorEl:m.current,onClose:()=>u(!1),anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},children:n.jsx(te,{color:o,onChange:s=>k(s.hex)})})]});return r?f:C}_.propTypes=S;function D({editing:r,description:o,value:a,onChange:c,componentProps:u,...m}){const{placeholder:p}=u,k=d.useRef(a),{t:b}=d.useContext(Q),C=s=>{s.key==="Enter"&&c(k.current,"confirm")},f=s=>{k.current=s,c(s)};return r?n.jsx(G,{style:{flex:1},fullWidth:!0,value:a,onChange:s=>{s.persist(),f(s.target.value)},autoFocus:!0,size:"small",variant:"outlined",placeholder:o||p,onKeyDown:C,...m}):n.jsx(g,{px:1,className:"form-item-input slot",children:a||n.jsx("span",{className:"placeholder",children:b("common.requiredInputPlaceholder",{name:o||p})})})}D.propTypes=S;D.defaultProps={componentProps:{}};function T({editing:r,value:o,onChange:a,componentProps:c,...u}){const{blocklet:m}=c,p=o==="auto"?Z.getPassportColorFromDid(m.appDid):o;return n.jsxs(g,{display:"flex",alignItems:"center",children:[n.jsx("div",{style:{width:96,marginRight:12},dangerouslySetInnerHTML:{__html:ne({title:"Owner",issuer:re.getDisplayName(m),issuerDid:m.appDid,ownerName:"Your Name",ownerDid:m.appDid,preferredColor:o||"auto"})}}),n.jsx(_,{...u,editing:r,value:r?p:o,onChange:a,componentProps:c})]})}T.propTypes={...S,componentProps:l.shape({blocklet:l.object.isRequired}).isRequired};T.defaultProps={};const ae=Y`
|
|
2
2
|
0%, 100% {
|
|
3
3
|
transform: scale(1) translateX(0);
|
|
4
4
|
}
|