@abtnode/blocklet-services 1.16.44-beta-20250512-155818-937e465d → 1.16.44-beta-20250513-030435-c2d99062
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{access-control-CCSlKYYz.js → access-control-Din7doVd.js} +1 -1
- package/dist/assets/{add-component-core-C7-Epxoj.js → add-component-core-5x4gTem5.js} +1 -1
- package/dist/assets/{add-resource-CJHw7ea0.js → add-resource-BrZnm53f.js} +1 -1
- package/dist/assets/{advanced-tG5IRVhQ.js → advanced-CN6mCSES.js} +1 -1
- package/dist/assets/{appearance-bRLsRDs2.js → appearance-Bowm1Shj.js} +1 -1
- package/dist/assets/{audit-logs-B3-Fo3nR.js → audit-logs-DczjqamJ.js} +1 -1
- package/dist/assets/{authorize-DNTNbUhI.js → authorize-D2LCmekq.js} +1 -1
- package/dist/assets/{branding-By8KDk5Q.js → branding-B6AmOMI6.js} +1 -1
- package/dist/assets/{branding-hDeNkLC2.js → branding-CwhhJRKu.js} +2 -2
- package/dist/assets/{bundle-avatar-DYTLzqlT.js → bundle-avatar-CDJRatFg.js} +1 -1
- package/dist/assets/{complete-6R-n_Ra9.js → complete-CKhw9u_z.js} +1 -1
- package/dist/assets/{component-Blsql2u0.js → component-Cb3m5qUw.js} +1 -1
- package/dist/assets/{config-D6r2ZAFY.js → config-kGXJEkFJ.js} +1 -1
- package/dist/assets/{config-navigation-B0nu0al4.js → config-navigation-CKVyFhfH.js} +3 -3
- package/dist/assets/{config-space-d34Deg7R.js → config-space-CogRdhoQ.js} +1 -1
- package/dist/assets/{confirm-DjTZImyg.js → confirm-SdqBW-ti.js} +1 -1
- package/dist/assets/{connect-Cu2Ssv5A.js → connect-BMn4CxDk.js} +1 -1
- package/dist/assets/connect-HAC-YfHh.js +5 -0
- package/dist/assets/{connect-to-BG15Vnyg.js → connect-to-eNQDY2rc.js} +1 -1
- package/dist/assets/{dashboard-BIOpvfj3.js → dashboard-BYxl5V9e.js} +3 -3
- package/dist/assets/{delete-confirm-BzuBR6TW.js → delete-confirm-CKF_eljP.js} +1 -1
- package/dist/assets/domain-DotN6lCb.js +9 -0
- package/dist/assets/{domain-action-card-Bcs_GWxq.js → domain-action-card-DHH9PLRG.js} +1 -1
- package/dist/assets/domains-BV2pykxi.js +1 -0
- package/dist/assets/dot-BA3EvSrh.js +7 -0
- package/dist/assets/{email-BZVu6WP-.js → email-CHR0EOis.js} +1 -1
- package/dist/assets/{exchange-passport-8jdiPDph.js → exchange-passport-D0iIXJxD.js} +1 -1
- package/dist/assets/{fuel-Dx_cnsCl.js → fuel-nMTHNcy-.js} +1 -1
- package/dist/assets/{gen-access-key-CqKmmKML.js → gen-access-key-DH4wNzRm.js} +1 -1
- package/dist/assets/{index-Dyl-XQ73.js → index-B54lTbup.js} +1 -1
- package/dist/assets/{index-SzdSxpkq.js → index-BA8C83iz.js} +1 -1
- package/dist/assets/{index-C-A13dEh.js → index-BCNchyGN.js} +1 -1
- package/dist/assets/{index-C5SsKJ2n.js → index-BCtmnJeV.js} +1 -1
- package/dist/assets/{index-B9nvthxv.js → index-BJxv6GA4.js} +1 -1
- package/dist/assets/{index-Jnk92KZC.js → index-BLGGjT7N.js} +5 -5
- package/dist/assets/{index-Btl_rz0J.js → index-B_-kynzD.js} +3 -3
- package/dist/assets/{index-Bju4sfVL.js → index-BuXc3Oag.js} +1 -1
- package/dist/assets/{index-DefO2n6z.js → index-CIkPfxzG.js} +2 -2
- package/dist/assets/{index-ioZVVJtg.js → index-CYeNo51G.js} +1 -1
- package/dist/assets/{index-Cc-e6lxg.js → index-CfxcUIhC.js} +1 -1
- package/dist/assets/{index-USO5zFMh.js → index-Ctzl9JDw.js} +1 -1
- package/dist/assets/{index-HU4yqI-9.js → index-CxwBhS0_.js} +1 -1
- package/dist/assets/{index-DjEDWgGs.js → index-D7eC9ptO.js} +1 -1
- package/dist/assets/{index-Du38Vjy4.js → index-D9KfgDPN.js} +4 -4
- package/dist/assets/{invitation-1bsb30Yz.js → invitation-DzT9Qa0A.js} +1 -1
- package/dist/assets/{invite-CALl83Zc.js → invite-CQPeUOT4.js} +1 -1
- package/dist/assets/{issue-passport-BcStTsbv.js → issue-passport-BYhvmLsl.js} +1 -1
- package/dist/assets/{item-Bk_1JLeG.js → item-D942q-4T.js} +1 -1
- package/dist/assets/{layout-D93HKT6w.js → layout-BcLfVSqs.js} +1 -1
- package/dist/assets/{list-rt6nku1-.js → list-BiJWMg_P.js} +1 -1
- package/dist/assets/{list-D96_O-GY.js → list-DKUSPdB6.js} +2 -2
- package/dist/assets/{log--AX8zo75.js → log-Iko0jLNA.js} +1 -1
- package/dist/assets/{login-WRcteY7r.js → login-4Yq_pPSw.js} +1 -1
- package/dist/assets/{logo-uploader-CQCy6MG3.js → logo-uploader-Cnkdgyfv.js} +2 -2
- package/dist/assets/{lost-passport-kJX7pEJj.js → lost-passport-D5jMtgH_.js} +1 -1
- package/dist/assets/open-window--2G6Qjbq.js +1 -1
- package/dist/assets/{overview-CpKMiGEK.js → overview-CaQ-tV1t.js} +1 -1
- package/dist/assets/{passport-item-CIvCqz_R.js → passport-item-DH3_49G1.js} +1 -1
- package/dist/assets/{publish-resource-CCa5xfwz.js → publish-resource-BtFRgv4P.js} +1 -1
- package/dist/assets/{runtime-eXYlg9Cz.js → runtime-B0207zk1.js} +1 -1
- package/dist/assets/{security-DM8MeY05.js → security-CX01lhxW.js} +1 -1
- package/dist/assets/setup-DIAgbS7c.js +30 -0
- package/dist/assets/{start-CIjuDAiX.js → start-CMRQU8Px.js} +1 -1
- package/dist/assets/{status-CUMJd-nJ.js → status-DSQPLYSp.js} +1 -1
- package/dist/assets/{step-actions-CeJCmiCS.js → step-actions-BfGTFkaB.js} +1 -1
- package/dist/assets/{traffic-B5x_6GvF.js → traffic-ClE631in.js} +1 -1
- package/dist/assets/{transfer-CTEHVklh.js → transfer-BnR8fjLW.js} +1 -1
- package/dist/assets/{unsubscribe-Bi2IV-2n.js → unsubscribe-rUE2LcLN.js} +1 -1
- package/dist/assets/{use-blocklet-logo-BEy8Tnso.js → use-blocklet-logo-Phq7jasP.js} +1 -1
- package/dist/assets/useAsync-DV3NyLhI.js +1 -0
- package/dist/assets/{user-center-DcXdjtRX.js → user-center-D25Vw-wP.js} +1 -1
- package/dist/assets/{util-MKllNgBs.js → util-Btd7aQEC.js} +1 -1
- package/dist/assets/{wrap-locale-B9TkXFQe.js → wrap-locale-CPW6a0PM.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/service-worker.js +1 -1
- package/package.json +21 -21
- package/dist/assets/connect-K4ZmMu4L.js +0 -5
- package/dist/assets/domain-wh85yL2O.js +0 -9
- package/dist/assets/domains-bzKFbARj.js +0 -1
- package/dist/assets/dot-C4hULxc0.js +0 -7
- package/dist/assets/setup-BEsU41BB.js +0 -30
- package/dist/assets/useAsync-C8ydfEEr.js +0 -1
- package/dist/assets/useAsync-CMWsznMW.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as r,ah as m}from"./vendor-mui-core-D_bnq77o.js";import{C as c}from"./content-layout-BzF-fNQz.js";import{u,_ as s}from"./vendor-ux-did-connect-DHrruicZ.js";import{c as i}from"./vendor-arcblock-uz9DVywv.js";import{H as p}from"./index-
|
|
1
|
+
import{j as r,ah as m}from"./vendor-mui-core-D_bnq77o.js";import{C as c}from"./content-layout-BzF-fNQz.js";import{u,_ as s}from"./vendor-ux-did-connect-DHrruicZ.js";import{c as i}from"./vendor-arcblock-uz9DVywv.js";import{H as p}from"./index-CIkPfxzG.js";const d=m(c)`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
width: 100%;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as p}from"./vendor-react-DEoibe3W.js";import{H as i,j as r,bd as Y,ad as te,e as P,ap as ie,aa as m,ah as E,T as A,v as W,X as oe,bL as $e,bM as rt,ar as nt,ai as st,a9 as Ae,m as it,bZ as ot,y as at,s as lt,I as ct}from"./vendor-mui-core-D_bnq77o.js";import{f as L,u as re,l as dt}from"./vendor-hooks-rDgu5KV9.js";import{u as ae,h as ut,aJ as pt,j as Pe,Y as le,b2 as ce,b6 as ht,r as Ne,I as ze,bi as mt}from"./vendor-ux-did-connect-DHrruicZ.js";import{S as ft}from"./index-BYCeMwoO.js";import{B as xt}from"./bundle-avatar-
|
|
1
|
+
import{r as p}from"./vendor-react-DEoibe3W.js";import{H as i,j as r,bd as Y,ad as te,e as P,ap as ie,aa as m,ah as E,T as A,v as W,X as oe,bL as $e,bM as rt,ar as nt,ai as st,a9 as Ae,m as it,bZ as ot,y as at,s as lt,I as ct}from"./vendor-mui-core-D_bnq77o.js";import{f as L,u as re,l as dt}from"./vendor-hooks-rDgu5KV9.js";import{u as ae,h as ut,aJ as pt,j as Pe,Y as le,b2 as ce,b6 as ht,r as Ne,I as ze,bi as mt}from"./vendor-ux-did-connect-DHrruicZ.js";import{S as ft}from"./index-BYCeMwoO.js";import{B as xt}from"./bundle-avatar-CDJRatFg.js";import{a as gt,p as Te,g as de,b as ue,c as B,s as G,H as yt,u as De,M as Le,d as Q,e as vt,m as bt,i as jt}from"./use-blocklet-logo-Phq7jasP.js";import{l as Ce,F as wt,z as kt}from"./index-CIkPfxzG.js";import{A as U,ag as Tt,z as Ee,b as _,a0 as Ct}from"./vendor-utils-rHXShPKm.js";import{u as _e,p as Rt,h as X,f as He,w as It}from"./vendor-arcblock-uz9DVywv.js";import{d as Mt}from"./InfoOutlined-DkG0jjos.js";import{d as St}from"./CheckCircle-Ds4QI0ey.js";import{U as $t,C as At,I as Pt}from"./index-BIPRCLBG.js";import{p as Nt}from"./util-CEAObyfj.js";function pe({blocklet:e,style:t,size:s,...n}){const o=gt({blocklet:e,square:!0}),{variant:l}=n;return r.jsx(Y,{variant:l||"square",style:Object.assign({backgroundColor:"transparent",width:s,height:s,borderRadius:10},t),...n,children:r.jsx("img",{src:o,alt:"",style:{width:s}})})}pe.propTypes={blocklet:i.object.isRequired,style:i.object,size:i.oneOfType([i.number,i.string])};pe.defaultProps={style:{},size:40};function Re(e){return e.includes(" ")?new Date(e.replace(" ","T").replace(" ","")).getTime():new Date(e).getTime()}function J({value:e,shouldUpdate:t=!1,...s}){const{t:n,locale:o}=ae(),[l,a]=p.useState(0);if(p.useEffect(()=>{let v;if(t){const j=Re(e),k=Date.now(),T=Math.abs(Math.floor((j-k)/1e3)),d=()=>{a(h=>{const f=Math.random()*1e3;return parseFloat((h+f).toFixed(4))})};T<60?v=setInterval(d,1e3):T<60*60?v=setInterval(d,6e4):v=setInterval(d,36e5)}return()=>{clearInterval(v)}},[e,l,t]),!e)return"-";const c={locale:wt(o),compact:!0},u=Re(e),g=Date.now();if(u>g){const v=Te(u-g,c);return r.jsx(te,{title:Ce(e,o),placement:"top-end",enterTouchDelay:0,children:r.jsx("span",{...s,children:n("common.afterTime",{time:v})})})}const y=Te(g-u,c);return r.jsx(te,{title:Ce(e,o),placement:"top-end",enterTouchDelay:0,children:r.jsx("span",{...s,children:n("common.timeAgo",{time:y})})})}J.propTypes={value:i.any,shouldUpdate:i.bool};J.defaultProps={value:"",shouldUpdate:!1};function qe({attachment:e}){const{data:t}=e,s=P();let n="";try{n=new URL(t.url).host}catch{n=t.url}return r.jsxs(ie,{target:"_blank",rel:"noopener noreferrer",href:t.url,className:"link",style:{wordBreak:"break-all"},onClick:o=>{o.customPreventRedirect=!0},children:[!!n&&r.jsx("span",{className:"url",children:n}),!!t.title&&r.jsx(m,{className:"title",style:{whiteSpace:"unset"},children:t.title}),!!t.description&&r.jsx(m,{className:"description",style:{whiteSpace:"unset",color:s.palette.text.secondary},children:t.description}),!!t.image&&r.jsx("img",{src:_e.getImagePath(t.image),alt:t.title||"",height:128,style:{borderRadius:"8px",maxWidth:"256px",objectFit:"cover"}})]})}qe.propTypes={attachment:i.object.isRequired};function We({attachment:e}){const{data:t}=e;return r.jsx("img",{src:_e.getImagePath(t.url),alt:t.title||"",height:128,style:{borderRadius:"8px",maxWidth:"256px",objectFit:"cover"}})}We.propTypes={attachment:i.object.isRequired};function Be({attachment:e,...t}){var c;const{data:s}=e,n=((c=s.color)==null?void 0:c.toLowerCase())||t.color,o=s.size||t.size,l=s.fontWeight||t.fontWeight||400;let a="14px";return o==="small"?a="12px":o==="normal"?a="14px":o==="big"?a="16px":o==="large"&&(a="18px"),r.jsx(zt,{className:"title",style:{fontSize:a,color:n,whiteSpace:"unset",fontWeight:l},children:s.text})}Be.propTypes={attachment:i.object.isRequired};const zt=E.span`
|
|
2
2
|
width: 100%;
|
|
3
3
|
display: -webkit-box;
|
|
4
4
|
-webkit-box-orient: vertical;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{r as b,b as Ue}from"./vendor-react-DEoibe3W.js";import{u as F,d as H,j as K,_ as M,Z as le,X as $,b4 as be,a7 as ve}from"./vendor-ux-did-connect-DHrruicZ.js";import{H as s,j as e,D as G,aj as X,I as Z,t as J,al as P,T as k,aa as u,O as w,br as C,bL as Ce,bR as ne,bt as se,bS as oe,X as Q,ak as ae,z as ce,y as L,ab as Y,ad as ye}from"./vendor-mui-core-D_bnq77o.js";import{M as de,_ as we}from"./vendor-arcblock-uz9DVywv.js";import{d as Te}from"./Edit-CbR4eoK8.js";import{_ as Se}from"./dot-C4hULxc0.js";import{l as ue}from"./index-CPfvVvHv.js";import{z as _,au as pe,av as S,C as ke}from"./index-DefO2n6z.js";import{u as B}from"./dashboard-BIOpvfj3.js";import{o as Ie,c as Re,A as re}from"./vendor-utils-rHXShPKm.js";import{E as qe}from"./empty-spinner-n0_Ehns5.js";import{C as v}from"./click-to-copy-CFiGx48J.js";import{D as Ae}from"./delete-confirm-BzuBR6TW.js";import{b as Oe}from"./passport-item-CIvCqz_R.js";import{A as Pe}from"./actions-BjTeIzgS.js";import"./vendor-hooks-rDgu5KV9.js";import"./lottie-web-jYmAQWuC.js";import"./useAsync-CMWsznMW.js";import"./useLocalStorage-DVnkpneF.js";import"./confirm-DjTZImyg.js";import"./format-error-BrmqJs5a.js";import"./PlayArrow-BToG9L6q.js";import"./get-safe-url-Bk6PlU7n.js";import"./session-CHdTc1We.js";import"./use-blocklet-logo-BEy8Tnso.js";import"./InfoOutlined-DkG0jjos.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-DyX6Fl8Z.js";import"./index-BIPRCLBG.js";import"./Phone-DcHUzCa-.js";import"./Location-DUEOr9J2.js";import"./Email-DWueGk7t.js";import"./Timezone-B-Ho_Uno.js";import"./did-address-DjwPl1uy.js";import"./util-CEAObyfj.js";import"./base32-_zEVBJUg.js";import"./MoreHoriz-B6KdR0Y8.js";const Ne={clientName:"",clientUri:"",redirectUris:"",scope:["profile:read"],contacts:"",tosUri:"",policyUri:""};function he({onCreated:i,onClose:d}){const[t,m]=b.useState(!1),{t:n}=F(),{api:o}=_(),{teamDid:U}=B(),{control:p,handleSubmit:R,formState:{errors:x},watch:j,setValue:y}=pe({defaultValues:Ne,mode:"onChange"}),h=j("scope"),I=a=>{a!=="profile:read"&&y("scope",h.includes(a)?h.filter(c=>c!==a):[...h,a])},q=async a=>{m(!0);try{const c={...a,redirectUris:a.redirectUris,contacts:a.contacts?a.contacts.split(",").map(A=>A.trim()):[],scope:a.scope.join(" ")};await o.createOAuthClient({input:{teamDid:U,input:Ie(c,Re)}}),i(c)}catch(c){M.error(c.message||"Failed to create OAuth App")}finally{m(!1)}};return e.jsxs(G,{open:!0,onClose:d,maxWidth:"md",fullWidth:!0,children:[e.jsxs(X,{children:[n("oauth.client.register")," ",e.jsx(Z,{onClick:d,sx:{position:"absolute",right:8,top:8},children:e.jsx(H,{})})]}),e.jsx(J,{children:e.jsxs(P,{spacing:4,sx:{mt:2},children:[e.jsx(k,{variant:"h6",gutterBottom:!0,children:n("oauth.client.requiredInformation")}),e.jsx(u,{children:e.jsx(S,{name:"clientName",control:p,rules:{required:n("oauth.client.validate.clientName"),minLength:{value:3,message:n("oauth.client.validate.clientNameMinLength")}},render:({field:a})=>{var c;return e.jsxs(e.Fragment,{children:[e.jsx(w,{size:"small",...a,label:n("oauth.client.name"),required:!0,fullWidth:!0,placeholder:n("oauth.client.input.clientNamePlaceholder"),error:!!x.clientName,helperText:(c=x.clientName)==null?void 0:c.message}),e.jsx(C,{children:n("oauth.client.helperText.clientName")})]})}})}),e.jsx(u,{children:e.jsx(S,{name:"clientUri",control:p,rules:{required:n("oauth.client.validate.clientUri"),pattern:{value:/^https?:\/\/.+/,message:n("oauth.client.validate.clientUriInvalid")}},render:({field:a})=>{var c;return e.jsxs(e.Fragment,{children:[e.jsx(w,{size:"small",...a,label:n("oauth.client.input.clientUri"),required:!0,fullWidth:!0,placeholder:n("oauth.client.input.clientUriPlaceholder"),error:!!x.clientUri,helperText:(c=x.clientUri)==null?void 0:c.message}),e.jsx(C,{children:n("oauth.client.helperText.clientUri")})]})}})}),e.jsx(u,{children:e.jsx(S,{name:"redirectUris",control:p,rules:{required:n("oauth.client.validate.redirectUris"),pattern:{value:/^https?:\/\/.+/,message:n("oauth.client.validate.redirectUrisInvalid")}},render:({field:a})=>{var c;return e.jsxs(e.Fragment,{children:[e.jsx(w,{size:"small",...a,label:n("oauth.client.input.redirectUris"),required:!0,fullWidth:!0,placeholder:n("oauth.client.input.redirectUrisPlaceholder"),error:!!x.redirectUris,helperText:(c=x.redirectUris)==null?void 0:c.message}),e.jsxs(u,{sx:{display:"flex",gap:"2px"},children:[e.jsx(C,{children:n("oauth.client.helperText.redirectUris")}),e.jsx(C,{children:n("oauth.client.helperText.read")}),e.jsx(C,{sx:{color:"info.main"},component:"a",href:"https://www.arcblock.io/docs/blocklet-developer/en/oauth-service",target:"_blank",rel:"noopener noreferrer",children:n("oauth.client.helperText.document")}),e.jsx(C,{children:n("oauth.client.helperText.more")})]})]})}})}),e.jsxs(Ce,{variant:"outlined",sx:{p:2,display:"none"},children:[e.jsx(k,{variant:"subtitle2",gutterBottom:!0,children:n("oauth.client.input.permissions")}),e.jsx(u,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1,p:2},children:e.jsx(ne,{children:Object.entries(K.OAUTH_SCOPES).map(([a,c])=>e.jsx(se,{control:e.jsx(oe,{checked:h.includes(a),onChange:()=>I(a),disabled:a==="profile:read",color:"primary"}),label:e.jsx(u,{children:e.jsx(k,{variant:"body2",sx:{fontWeight:500},children:c})})},a))})})]}),e.jsx(Q,{}),e.jsx(k,{variant:"h6",gutterBottom:!0,children:n("oauth.client.optionalInformation")}),e.jsx(P,{children:e.jsx(S,{name:"contacts",control:p,rules:{pattern:{value:/^$|^[^@\s]+@[^@\s]+\.[^@\s]+(\s*,\s*[^@\s]+@[^@\s]+\.[^@\s]+)*$/,message:n("oauth.client.validate.contacts")}},render:({field:a})=>{var c;return e.jsxs(e.Fragment,{children:[e.jsx(w,{size:"small",...a,label:n("oauth.client.input.contacts"),fullWidth:!0,placeholder:n("oauth.client.input.contactsPlaceholder"),error:!!x.contacts,helperText:(c=x.contacts)==null?void 0:c.message}),e.jsx(C,{children:n("oauth.client.helperText.contacts")})]})}})}),e.jsxs(P,{direction:{xs:"column",sm:"row"},spacing:2,children:[e.jsx(S,{name:"tosUri",control:p,rules:{pattern:{value:/^$|^https?:\/\/.+/,message:n("oauth.client.validate.tosUriInvalid")}},render:({field:a})=>{var c;return e.jsxs(u,{sx:{width:"50%"},children:[e.jsx(w,{size:"small",...a,label:n("oauth.client.input.tosUri"),fullWidth:!0,placeholder:n("oauth.client.input.tosUriPlaceholder"),error:!!x.tosUri,helperText:(c=x.tosUri)==null?void 0:c.message}),e.jsx(C,{children:n("oauth.client.helperText.tosUri")})]})}}),e.jsx(S,{name:"policyUri",control:p,rules:{pattern:{value:/^$|^https?:\/\/.+/,message:n("oauth.client.validate.policyUriInvalid")}},render:({field:a})=>{var c;return e.jsxs(u,{sx:{width:"50%"},children:[e.jsx(w,{size:"small",...a,label:n("oauth.client.input.policyUri"),fullWidth:!0,placeholder:n("oauth.client.input.policyUriPlaceholder"),error:!!x.policyUri,helperText:(c=x.policyUri)==null?void 0:c.message}),e.jsx(C,{children:n("oauth.client.helperText.policyUri")})]})}})]}),x.error&&e.jsx(ae,{severity:"error",children:x.error.message})]})}),e.jsxs(ce,{children:[e.jsx(L,{onClick:d,children:n("common.cancel")}),e.jsxs(L,{onClick:R(q),disabled:t,variant:"contained",color:"primary",children:[t?e.jsx(Y,{size:20,sx:{mr:1}}):null,n("oauth.client.registerButton")]})]})]})}he.propTypes={onCreated:s.func.isRequired,onClose:s.func.isRequired};function V({scope:i,...d}){if(!i)return null;const t=i.split(" ").filter(Boolean);return e.jsx(P,{direction:"row",flexWrap:"wrap",gap:1,...d,children:t.map(m=>e.jsx(Ue.Fragment,{children:e.jsx(ye,{title:K.OAUTH_SCOPES[m],children:e.jsx(v,{children:m})})},m))})}V.propTypes={scope:s.string};V.defaultProps={scope:""};const ee=i=>{const{prefix:d}=_(),{blocklet:t}=ke(),m=re(d,"/api/media/upload",t.appPid),n=b.useCallback(U=>U?U.startsWith("http")?U:`${re(d,"/api/media/upload",t.appPid)}/${U}`:"",[d,t.appPid]);return{clientLogoUrl:b.useMemo(()=>n(i),[i,n]),apiPath:m,getClientLogoUrl:n}},We=b.lazy(()=>we(()=>import("./index-Btl_rz0J.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(i=>({default:i.Uploader})));function me({client:i,onUpdate:d,onClose:t}){const[m,n]=b.useState(!1),{t:o,locale:U}=F(),p=b.useRef(null),{api:R}=_(),{teamDid:x}=B(),{control:j,handleSubmit:y,formState:{errors:h},watch:I,setValue:q,getValues:a}=pe({defaultValues:{clientName:i.clientName||"",clientUri:i.clientUri||"",redirectUris:Array.isArray(i.redirectUris)?i.redirectUris.join(","):"",scope:i.scope?i.scope.split(" "):["profile:read"],contacts:Array.isArray(i.contacts)?i.contacts.join(","):"",tosUri:i.tosUri||"",policyUri:i.policyUri||"",logoUri:i.logoUri||""},mode:"onChange"}),c=I("scope"),A=I("logoUri"),{clientLogoUrl:T,apiPath:W}=ee(A),z=r=>{r!=="profile:read"&&q("scope",c.includes(r)?c.filter(l=>l!==r):[...c,r])},O=async r=>{const l={clientId:i.clientId,clientName:r.clientName.trim(),clientUri:r.clientUri,redirectUris:r.redirectUris.split(",").map(f=>f.trim()).filter(Boolean),contacts:r.contacts?r.contacts.split(",").map(f=>f.trim()):[],scope:r.scope.join(" "),tosUri:r.tosUri,policyUri:r.policyUri,logoUri:r.logoUri};await R.updateOAuthClient({input:{teamDid:x,input:l}})},g=async r=>{n(!0);try{await O(r),d(),t()}catch(l){M.error(l.message||o("oauth.client.updateFailed"))}finally{n(!1)}};return e.jsxs(G,{open:!0,onClose:t,maxWidth:"md",fullWidth:!0,children:[e.jsxs(X,{children:[o("oauth.client.update")," ",e.jsx(Z,{onClick:t,sx:{position:"absolute",right:8,top:8},children:e.jsx(H,{})})]}),e.jsx(J,{children:e.jsxs(P,{spacing:3,sx:{mt:2},children:[e.jsxs(u,{sx:{mb:3},children:[e.jsx(k,{variant:"subtitle1",sx:{fontWeight:500,mb:1},children:o("oauth.client.logo")}),e.jsxs(u,{children:[e.jsx(u,{sx:{width:120,height:120,position:"relative",borderRadius:"4px",overflow:"hidden"},children:T?e.jsx(u,{children:e.jsx("img",{src:T,alt:"client-logo",style:{width:"100%",height:"100%"}})}):e.jsx(u,{onClick:()=>{var r;(r=p.current)==null||r.open()},sx:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"grey.200"},children:e.jsx(de,{sx:{fontSize:40,color:"common.white"}})})}),e.jsx(L,{sx:{mt:2},variant:"outlined",size:"small",onClick:()=>{var r;(r=p.current)==null||r.open()},children:o(T?"common.change":"common.upload")})]}),e.jsx(u,{sx:{display:"flex",alignItems:"center"},children:e.jsx(b.Suspense,{fallback:e.jsx(qe,{}),children:e.jsx(We,{ref:p,locale:U,popup:!0,onUploadFinish:r=>{q("logoUri",r.data.filename),O(a()).then(()=>{d()}).catch(l=>{M.error(l.message||o("oauth.client.updateFailed"))}).finally(()=>{var l;(l=p.current)==null||l.close()})},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:W,disableMediaKitPrefix:!0,disableAutoPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/png","image/jpeg","image/webp","image/svg+xml"],maxFileSize:1024*1024*.5,maxNumberOfFiles:1}},dashboardProps:{autoOpen:"imageEditor"},imageEditorProps:{actions:{revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!1,cropWidescreen:!1,cropWidescreenVertical:!1},cropperOptions:{autoCrop:!0,aspectRatio:1,initialAspectRatio:1,autoCropArea:1,croppedCanvasOptions:{minWidth:256,minHeight:256}}}},"uploader-logo")})})]}),e.jsx(k,{variant:"subtitle1",sx:{fontWeight:500},children:o("oauth.client.requiredInformation")}),e.jsx(w,{label:"Client Id",fullWidth:!0,value:i.clientId,disabled:!0}),e.jsx(u,{children:e.jsx(S,{name:"clientName",control:j,rules:{required:o("oauth.client.validate.clientName"),minLength:{value:3,message:o("oauth.client.validate.clientNameMinLength")}},render:({field:r})=>{var l;return e.jsxs(e.Fragment,{children:[e.jsx(w,{...r,label:o("oauth.client.name"),required:!0,fullWidth:!0,error:!!h.clientName,helperText:(l=h.clientName)==null?void 0:l.message}),e.jsx(C,{children:o("oauth.client.helperText.clientName")})]})}})}),e.jsx(u,{children:e.jsx(S,{name:"clientUri",control:j,rules:{required:o("oauth.client.validate.clientUri"),pattern:{value:/^https?:\/\/.+/,message:o("oauth.client.validate.clientUriInvalid")}},render:({field:r})=>{var l;return e.jsxs(e.Fragment,{children:[e.jsx(w,{...r,label:o("oauth.client.input.clientUri"),required:!0,fullWidth:!0,error:!!h.clientUri,helperText:(l=h.clientUri)==null?void 0:l.message}),e.jsx(C,{children:o("oauth.client.helperText.clientUri")})]})}})}),e.jsx(u,{children:e.jsx(S,{name:"redirectUris",control:j,rules:{required:o("oauth.client.validate.redirectUris"),pattern:{value:/^https?:\/\/.+/,message:o("oauth.client.validate.redirectUrisInvalid")}},render:({field:r})=>{var l;return e.jsxs(e.Fragment,{children:[e.jsx(w,{...r,label:o("oauth.client.input.redirectUris"),required:!0,fullWidth:!0,multiline:!0,rows:2,error:!!h.redirectUris,helperText:(l=h.redirectUris)==null?void 0:l.message}),e.jsx(C,{children:o("oauth.client.helperText.redirectUris")})]})}})}),e.jsxs(u,{sx:{display:"none"},children:[e.jsx(k,{variant:"subtitle2",sx:{mb:1},children:o("oauth.client.input.permissions")}),e.jsx(u,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1,p:2},children:e.jsx(ne,{children:Object.entries(K.OAUTH_SCOPES).map(([r,l])=>e.jsx(se,{control:e.jsx(oe,{checked:c.includes(r),onChange:()=>z(r),disabled:r==="profile:read",color:"primary"}),label:e.jsx(u,{children:e.jsx(k,{variant:"body2",sx:{fontWeight:500},children:l})})},r))})})]}),e.jsx(Q,{}),e.jsx(k,{variant:"subtitle1",sx:{fontWeight:500},children:o("oauth.client.optionalInformation")}),e.jsx(u,{children:e.jsx(S,{name:"contacts",control:j,rules:{pattern:{value:/^$|^[^@\s]+@[^@\s]+\.[^@\s]+(\s*,\s*[^@\s]+@[^@\s]+\.[^@\s]+)*$/,message:o("oauth.client.validate.contacts")}},render:({field:r})=>{var l;return e.jsxs(e.Fragment,{children:[e.jsx(w,{...r,label:o("oauth.client.input.contacts"),fullWidth:!0,error:!!h.contacts,helperText:(l=h.contacts)==null?void 0:l.message}),e.jsx(C,{children:o("oauth.client.helperText.contacts")})]})}})}),e.jsxs(P,{direction:{xs:"column",sm:"row"},spacing:2,children:[e.jsx(S,{name:"tosUri",control:j,rules:{pattern:{value:/^$|^https?:\/\/.+/,message:o("oauth.client.validate.tosUriInvalid")}},render:({field:r})=>{var l;return e.jsxs(u,{sx:{width:"50%"},children:[e.jsx(w,{...r,label:o("oauth.client.input.tosUri"),fullWidth:!0,error:!!h.tosUri,helperText:(l=h.tosUri)==null?void 0:l.message}),e.jsx(C,{children:o("oauth.client.helperText.tosUri")})]})}}),e.jsx(S,{name:"policyUri",control:j,rules:{pattern:{value:/^$|^https?:\/\/.+/,message:o("oauth.client.validate.policyUriInvalid")}},render:({field:r})=>{var l;return e.jsxs(u,{sx:{width:"50%"},children:[e.jsx(w,{...r,label:o("oauth.client.input.policyUri"),fullWidth:!0,error:!!h.policyUri,helperText:(l=h.policyUri)==null?void 0:l.message}),e.jsx(C,{children:o("oauth.client.helperText.policyUri")})]})}})]}),h.error&&e.jsx(ae,{severity:"error",children:h.error.message})]})}),e.jsxs(ce,{children:[e.jsx(L,{onClick:t,children:o("common.cancel")}),e.jsx(L,{onClick:y(g),disabled:m,variant:"contained",color:"primary",children:m?e.jsx(Y,{size:16}):o("common.update")})]})]})}me.propTypes={client:s.shape({clientId:s.string.isRequired,clientName:s.string.isRequired,clientUri:s.string,redirectUris:s.arrayOf(s.string),scope:s.string,contacts:s.arrayOf(s.string),tosUri:s.string,policyUri:s.string,logoUri:s.string}).isRequired,onUpdate:s.func.isRequired,onClose:s.func.isRequired};function xe({client:i,onUpdate:d,onClose:t}){return e.jsx(me,{client:i,onUpdate:m=>d(m),onClose:t})}xe.propTypes={client:s.shape({clientId:s.string.isRequired,clientName:s.string.isRequired,clientUri:s.string,redirectUris:s.arrayOf(s.string),scope:s.string,contacts:s.arrayOf(s.string),tosUri:s.string,policyUri:s.string,logoUri:s.string}).isRequired,onUpdate:s.func.isRequired,onClose:s.func.isRequired};function te(i){const{t:d}=F(),{api:t}=_(),{teamDid:m}=B(),{clientId:n,clientName:o,onDelete:U=()=>{},onClose:p=()=>{}}=i,R=()=>{p()},x=async()=>{try{await t.deleteOAuthClient({input:{teamDid:m,clientId:n}}),U()}catch(y){M.error(y==null?void 0:y.message)}finally{R()}},j={keyName:o,title:d("oauth.client.delete.title"),description:d("oauth.client.delete.description",{name:`<b>${o}</b>`}),confirmPlaceholder:d("oauth.client.delete.description",{name:o}),confirm:d("common.delConfirm"),cancel:d("common.cancel"),onConfirm:x,onCancel:R};return e.jsx(Ae,{keyName:j.keyName,title:j.title,description:j.description,confirmPlaceholder:j.confirmPlaceholder,confirm:j.confirm,cancel:j.cancel,params:j.params,onConfirm:j.onConfirm,onCancel:j.onCancel})}te.propTypes={clientId:s.string.isRequired,clientName:s.string.isRequired,onDelete:s.func,onClose:s.func};te.defaultProps={onDelete:()=>{},onClose:()=>{}};function je({title:i,items:d}){return e.jsxs(u,{mb:3,children:[e.jsx(k,{variant:"h6",sx:{mb:1.5},children:i}),e.jsx(P,{spacing:1.5,children:d.map(({label:t,value:m})=>e.jsxs(u,{display:"flex",alignItems:"center",gap:2,children:[e.jsx(k,{variant:"subtitle2",color:"textSecondary",sx:{minWidth:200},children:t}),e.jsx(k,{sx:{wordBreak:"break-all"},children:m||"-"})]},t))})]})}je.propTypes={title:s.string.isRequired,items:s.arrayOf(s.shape({label:s.string.isRequired,value:s.any})).isRequired};function ge({client:i,onClose:d}){const{t,locale:m}=F(),{teamDid:n}=B(),{clientName:o,clientId:U,clientSecret:p,redirectUris:R,scope:x,clientUri:j,logoUri:y,contacts:h,tosUri:I,policyUri:q,jwksUri:a,jwks:c,softwareId:A,softwareVersion:T,clientIdIssuedAt:W,clientSecretExpiresAt:z,updatedAt:O,createUser:g}=i,{clientLogoUrl:r}=ee(y),l=N=>{try{const E=new URL(window.blocklet.appUrl);return E.pathname=N,E.toString()}catch{return"-"}},f=ue.fromAppDid(U,n),D=[{title:t("common.baseInfo"),items:[{label:t("oauth.client.name"),value:o},{label:t("oauth.client.logoUri"),value:e.jsx(le,{variant:"rounded",shape:"square",src:r,did:f.address,size:64})},{label:t("oauth.client.clientUri"),value:j?e.jsx(v,{children:j}):"-"},{label:t("oauth.client.clientId"),value:e.jsx(v,{children:U})},{label:t("oauth.client.clientSecret"),value:e.jsx(v,{children:p})},{label:t("oauth.client.redirectUris"),value:e.jsx(v,{children:(R||[]).join(", ")})},{label:t("oauth.client.scope"),value:e.jsx(V,{scope:x})},{label:t("oauth.client.createUser"),value:g?Oe(g,!0):t("oauth.client.openRegistration")}]},{title:t("oauth.client.oauthEndpoints"),items:[{label:t("oauth.client.openidConfiguration"),value:e.jsx(v,{children:l("/.well-known/openid-configuration")})},{label:t("oauth.client.authorizationEndpoint"),value:e.jsx(v,{children:l("/.well-known/service/oauth/authorize")})},{label:t("oauth.client.tokenEndpoint"),value:e.jsx(v,{children:l("/.well-known/service/oauth/token")})},{label:t("oauth.client.userinfoEndpoint"),value:e.jsx(v,{children:l("/.well-known/service/oauth/userinfo")})},{label:t("oauth.client.jwksUri"),value:e.jsx(v,{children:l("/.well-known/service/oauth/jwks")})},{label:t("oauth.client.registrationEndpoint"),value:e.jsx(v,{children:l("/.well-known/service/oauth/register")})},{label:t("oauth.client.endSessionEndpoint"),value:e.jsx(v,{children:l("/.well-known/service/oauth/logout")})}]},{title:t("oauth.client.metaContact"),items:[{label:t("oauth.client.contacts"),value:h.length?e.jsx(v,{children:(h||[]).join(", ")}):"-"},{label:t("oauth.client.tosUri"),value:I?e.jsx(v,{children:I}):"-"},{label:t("oauth.client.policyUri"),value:q?e.jsx(v,{children:q}):"-"},{label:t("oauth.client.jwksUri"),value:a},{label:t("oauth.client.jwks"),value:c},{label:t("oauth.client.softwareId"),value:A},{label:t("oauth.client.softwareVersion"),value:T}]},{title:t("common.timeInfo"),items:[{label:t("oauth.client.clientIdIssuedAt"),value:W?e.jsx($,{value:W*1e3,type:"all",locale:m}):"-"},{label:t("oauth.client.clientSecretExpiresAt"),value:z?e.jsx($,{value:z*1e3,type:"all",locale:m}):"-"},{label:t("common.updatedAt"),value:O?e.jsx($,{value:O,type:"all",locale:m}):"-"}]}].filter(Boolean);return e.jsxs(G,{open:!0,onClose:d,maxWidth:"lg",fullWidth:!0,children:[e.jsxs(X,{children:[t("oauth.client.oauthAppDetails"),e.jsx(Z,{onClick:d,sx:{position:"absolute",right:8,top:8},children:e.jsx(H,{})})]}),e.jsx(J,{children:e.jsx(u,{mt:1,children:D.map((N,E)=>e.jsxs(u,{children:[e.jsx(je,{title:N.title,items:N.items}),E!==D.length-1&&e.jsx(Q,{sx:{my:2}})]},N.title))})})]})}ge.propTypes={client:s.object.isRequired,onClose:s.func.isRequired};function ze(i){return e.jsx($,{value:i*1e3})}function ie({selected:i,onClose:d}){return i?e.jsx(ge,{client:i,onClose:d}):null}ie.propTypes={selected:s.object,onClose:s.func.isRequired};ie.defaultProps={selected:null};function fe({open:i,onCreated:d,onClose:t}){return i?e.jsx(he,{onCreated:d,onClose:t}):null}fe.propTypes={open:s.bool.isRequired,onCreated:s.func.isRequired,onClose:s.func.isRequired};function bt(){var O;const[i,d]=b.useState({searchText:"",pageSize:10,page:1}),[t,m]=b.useState(null),[n,o]=b.useState(!1),U=b.useRef(null),{t:p}=F(),{api:R}=_(),{teamDid:x}=B(),[j,y]=b.useState(null),[h,I]=b.useState(null),{getClientLogoUrl:q}=ee(),a=Se(async()=>await R.getOAuthClients({input:{teamDid:x,paging:{page:i.page,pageSize:i.pageSize}}}),[i.page,i.pageSize]),{loading:c}=a,A=b.useMemo(()=>{var g;return((g=a.value)==null?void 0:g.list)||[]},[(O=a.value)==null?void 0:O.list]),T=b.useMemo(()=>i.searchText?A.filter(g=>g.clientName.toLowerCase().includes(i.searchText.toLowerCase())||g.clientId.toLowerCase().includes(i.searchText.toLowerCase())||g.scope.toLowerCase().includes(i.searchText.toLowerCase())):A,[i.searchText,A]),W=b.useMemo(()=>[{label:p("oauth.client.name"),name:"clientName",options:{customBodyRender:(g,{rowIndex:r})=>{const l=T[r],f=q(l.logoUri),D=ue.fromAppDid(l.clientId,x);return e.jsx(u,{sx:{display:"flex",alignItems:"center",gap:2},children:e.jsxs(u,{display:"flex",alignItems:"center",gap:2,sx:{cursor:"pointer"},onClick:N=>{N.stopPropagation(),window.open(l.clientUri,"_blank")},children:[e.jsx(le,{variant:"rounded",shape:"square",did:D.address,src:f,size:48}),e.jsxs(P,{gap:.5,children:[e.jsx(u,{sx:{color:"text.primary"},children:l.clientName}),e.jsx(u,{sx:{color:"text.secondary"},children:l.clientUri})]})]})})}}},{label:p("oauth.client.clientId"),name:"clientId"},{label:p("oauth.client.scope"),name:"scope",options:{customBodyRender:g=>e.jsx(V,{scope:g})}},{label:p("common.createdAt"),name:"clientIdIssuedAt",options:{customBodyRender:ze}},{label:p("common.actions"),name:"actions",width:100,align:"center",verticalKeyAlign:"center",options:{customBodyRender:(g,{rowIndex:r})=>{const l=T[r];return e.jsx(Pe,{actions:[{icon:e.jsx(Te,{}),text:p("common.edit"),onClick:f=>{f.stopPropagation(),y(l)}},{icon:e.jsx(be,{}),text:p("common.delete"),onClick:f=>{f.stopPropagation(),I(l)}}]})}}}],[T,p,q,x,y,I]),z=({page:g,rowsPerPage:r,searchText:l})=>{i.pageSize!==r?d(f=>({...f,searchText:"",pageSize:r,page:1})):i.page!==g+1?d(f=>({...f,searchText:"",page:g+1})):i.searchText!==l&&d(f=>({...f,searchText:l,page:1}))};return e.jsxs(u,{ref:U,sx:{".custom-toobar-btns":{gap:"8px"}},children:[e.jsx(ve,{data:T,columns:W,options:{sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,page:i.page-1,rowsPerPage:i.pageSize,count:T.length,searchDebounceTime:400,onRowClick(g,{dataIndex:r},l){var f;if((f=U.current)!=null&&f.contains(l.target)){const D=T[r];m(D)}}},onChange:z,customButtons:[e.jsxs(L,{variant:"contained",size:"small",onClick:()=>o(!0),children:[c?e.jsx(Y,{size:16}):e.jsx(de,{style:{fontSize:16}}),p("common.create")]},"add")],loading:!1}),e.jsx(ie,{selected:t,onClose:()=>m(null)}),e.jsx(fe,{open:n,onCreated:()=>{o(!1),a.retry()},onClose:()=>o(!1)}),j&&e.jsx(xe,{client:j,onUpdate:a.retry,onClose:()=>y(null)}),h&&e.jsx(te,{...h,onDelete:a.retry,onClose:()=>I(null)})]})}export{bt as default};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B_-kynzD.js","assets/vendor-ux-did-connect-DHrruicZ.js","assets/vendor-react-DEoibe3W.js","assets/vendor-utils-rHXShPKm.js","assets/vendor-mui-core-D_bnq77o.js","assets/vendor-hooks-rDgu5KV9.js","assets/lottie-web-jYmAQWuC.js","assets/vendor-ux-did-connect-DpSGLE7B.css","assets/vendor-arcblock-uz9DVywv.js","assets/index-Bs1kxR8_.js","assets/index-CIkPfxzG.js","assets/index-DOq-_YXu.css","assets/index-DVQCgvFb.js","assets/index-AgKpYdvC.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as b,b as Ue}from"./vendor-react-DEoibe3W.js";import{u as F,d as H,j as K,_ as M,Z as le,X as $,b4 as be,a7 as ve}from"./vendor-ux-did-connect-DHrruicZ.js";import{H as s,j as e,D as G,aj as X,I as Z,t as J,al as P,T as k,aa as u,O as w,br as C,bL as Ce,bR as ne,bt as se,bS as oe,X as Q,ak as ae,z as ce,y as L,ab as Y,ad as ye}from"./vendor-mui-core-D_bnq77o.js";import{M as de,_ as we}from"./vendor-arcblock-uz9DVywv.js";import{d as Te}from"./Edit-CbR4eoK8.js";import{_ as Se}from"./dot-BA3EvSrh.js";import{l as ue}from"./index-CPfvVvHv.js";import{z as _,au as pe,av as S,C as ke}from"./index-CIkPfxzG.js";import{u as B}from"./dashboard-BYxl5V9e.js";import{o as Ie,c as Re,A as re}from"./vendor-utils-rHXShPKm.js";import{E as qe}from"./empty-spinner-n0_Ehns5.js";import{C as v}from"./click-to-copy-CFiGx48J.js";import{D as Ae}from"./delete-confirm-CKF_eljP.js";import{b as Oe}from"./passport-item-DH3_49G1.js";import{A as Pe}from"./actions-BjTeIzgS.js";import"./vendor-hooks-rDgu5KV9.js";import"./lottie-web-jYmAQWuC.js";import"./useAsync-DV3NyLhI.js";import"./useLocalStorage-DVnkpneF.js";import"./confirm-SdqBW-ti.js";import"./format-error-BrmqJs5a.js";import"./PlayArrow-BToG9L6q.js";import"./get-safe-url-B5RJTMjC.js";import"./session-CHdTc1We.js";import"./use-blocklet-logo-Phq7jasP.js";import"./InfoOutlined-DkG0jjos.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-DyX6Fl8Z.js";import"./index-BIPRCLBG.js";import"./Phone-DcHUzCa-.js";import"./Location-DUEOr9J2.js";import"./Email-DWueGk7t.js";import"./Timezone-B-Ho_Uno.js";import"./did-address-DjwPl1uy.js";import"./util-CEAObyfj.js";import"./base32-_zEVBJUg.js";import"./MoreHoriz-B6KdR0Y8.js";const Ne={clientName:"",clientUri:"",redirectUris:"",scope:["profile:read"],contacts:"",tosUri:"",policyUri:""};function he({onCreated:i,onClose:d}){const[t,m]=b.useState(!1),{t:n}=F(),{api:o}=_(),{teamDid:U}=B(),{control:p,handleSubmit:R,formState:{errors:x},watch:j,setValue:y}=pe({defaultValues:Ne,mode:"onChange"}),h=j("scope"),I=a=>{a!=="profile:read"&&y("scope",h.includes(a)?h.filter(c=>c!==a):[...h,a])},q=async a=>{m(!0);try{const c={...a,redirectUris:a.redirectUris,contacts:a.contacts?a.contacts.split(",").map(A=>A.trim()):[],scope:a.scope.join(" ")};await o.createOAuthClient({input:{teamDid:U,input:Ie(c,Re)}}),i(c)}catch(c){M.error(c.message||"Failed to create OAuth App")}finally{m(!1)}};return e.jsxs(G,{open:!0,onClose:d,maxWidth:"md",fullWidth:!0,children:[e.jsxs(X,{children:[n("oauth.client.register")," ",e.jsx(Z,{onClick:d,sx:{position:"absolute",right:8,top:8},children:e.jsx(H,{})})]}),e.jsx(J,{children:e.jsxs(P,{spacing:4,sx:{mt:2},children:[e.jsx(k,{variant:"h6",gutterBottom:!0,children:n("oauth.client.requiredInformation")}),e.jsx(u,{children:e.jsx(S,{name:"clientName",control:p,rules:{required:n("oauth.client.validate.clientName"),minLength:{value:3,message:n("oauth.client.validate.clientNameMinLength")}},render:({field:a})=>{var c;return e.jsxs(e.Fragment,{children:[e.jsx(w,{size:"small",...a,label:n("oauth.client.name"),required:!0,fullWidth:!0,placeholder:n("oauth.client.input.clientNamePlaceholder"),error:!!x.clientName,helperText:(c=x.clientName)==null?void 0:c.message}),e.jsx(C,{children:n("oauth.client.helperText.clientName")})]})}})}),e.jsx(u,{children:e.jsx(S,{name:"clientUri",control:p,rules:{required:n("oauth.client.validate.clientUri"),pattern:{value:/^https?:\/\/.+/,message:n("oauth.client.validate.clientUriInvalid")}},render:({field:a})=>{var c;return e.jsxs(e.Fragment,{children:[e.jsx(w,{size:"small",...a,label:n("oauth.client.input.clientUri"),required:!0,fullWidth:!0,placeholder:n("oauth.client.input.clientUriPlaceholder"),error:!!x.clientUri,helperText:(c=x.clientUri)==null?void 0:c.message}),e.jsx(C,{children:n("oauth.client.helperText.clientUri")})]})}})}),e.jsx(u,{children:e.jsx(S,{name:"redirectUris",control:p,rules:{required:n("oauth.client.validate.redirectUris"),pattern:{value:/^https?:\/\/.+/,message:n("oauth.client.validate.redirectUrisInvalid")}},render:({field:a})=>{var c;return e.jsxs(e.Fragment,{children:[e.jsx(w,{size:"small",...a,label:n("oauth.client.input.redirectUris"),required:!0,fullWidth:!0,placeholder:n("oauth.client.input.redirectUrisPlaceholder"),error:!!x.redirectUris,helperText:(c=x.redirectUris)==null?void 0:c.message}),e.jsxs(u,{sx:{display:"flex",gap:"2px"},children:[e.jsx(C,{children:n("oauth.client.helperText.redirectUris")}),e.jsx(C,{children:n("oauth.client.helperText.read")}),e.jsx(C,{sx:{color:"info.main"},component:"a",href:"https://www.arcblock.io/docs/blocklet-developer/en/oauth-service",target:"_blank",rel:"noopener noreferrer",children:n("oauth.client.helperText.document")}),e.jsx(C,{children:n("oauth.client.helperText.more")})]})]})}})}),e.jsxs(Ce,{variant:"outlined",sx:{p:2,display:"none"},children:[e.jsx(k,{variant:"subtitle2",gutterBottom:!0,children:n("oauth.client.input.permissions")}),e.jsx(u,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1,p:2},children:e.jsx(ne,{children:Object.entries(K.OAUTH_SCOPES).map(([a,c])=>e.jsx(se,{control:e.jsx(oe,{checked:h.includes(a),onChange:()=>I(a),disabled:a==="profile:read",color:"primary"}),label:e.jsx(u,{children:e.jsx(k,{variant:"body2",sx:{fontWeight:500},children:c})})},a))})})]}),e.jsx(Q,{}),e.jsx(k,{variant:"h6",gutterBottom:!0,children:n("oauth.client.optionalInformation")}),e.jsx(P,{children:e.jsx(S,{name:"contacts",control:p,rules:{pattern:{value:/^$|^[^@\s]+@[^@\s]+\.[^@\s]+(\s*,\s*[^@\s]+@[^@\s]+\.[^@\s]+)*$/,message:n("oauth.client.validate.contacts")}},render:({field:a})=>{var c;return e.jsxs(e.Fragment,{children:[e.jsx(w,{size:"small",...a,label:n("oauth.client.input.contacts"),fullWidth:!0,placeholder:n("oauth.client.input.contactsPlaceholder"),error:!!x.contacts,helperText:(c=x.contacts)==null?void 0:c.message}),e.jsx(C,{children:n("oauth.client.helperText.contacts")})]})}})}),e.jsxs(P,{direction:{xs:"column",sm:"row"},spacing:2,children:[e.jsx(S,{name:"tosUri",control:p,rules:{pattern:{value:/^$|^https?:\/\/.+/,message:n("oauth.client.validate.tosUriInvalid")}},render:({field:a})=>{var c;return e.jsxs(u,{sx:{width:"50%"},children:[e.jsx(w,{size:"small",...a,label:n("oauth.client.input.tosUri"),fullWidth:!0,placeholder:n("oauth.client.input.tosUriPlaceholder"),error:!!x.tosUri,helperText:(c=x.tosUri)==null?void 0:c.message}),e.jsx(C,{children:n("oauth.client.helperText.tosUri")})]})}}),e.jsx(S,{name:"policyUri",control:p,rules:{pattern:{value:/^$|^https?:\/\/.+/,message:n("oauth.client.validate.policyUriInvalid")}},render:({field:a})=>{var c;return e.jsxs(u,{sx:{width:"50%"},children:[e.jsx(w,{size:"small",...a,label:n("oauth.client.input.policyUri"),fullWidth:!0,placeholder:n("oauth.client.input.policyUriPlaceholder"),error:!!x.policyUri,helperText:(c=x.policyUri)==null?void 0:c.message}),e.jsx(C,{children:n("oauth.client.helperText.policyUri")})]})}})]}),x.error&&e.jsx(ae,{severity:"error",children:x.error.message})]})}),e.jsxs(ce,{children:[e.jsx(L,{onClick:d,children:n("common.cancel")}),e.jsxs(L,{onClick:R(q),disabled:t,variant:"contained",color:"primary",children:[t?e.jsx(Y,{size:20,sx:{mr:1}}):null,n("oauth.client.registerButton")]})]})]})}he.propTypes={onCreated:s.func.isRequired,onClose:s.func.isRequired};function V({scope:i,...d}){if(!i)return null;const t=i.split(" ").filter(Boolean);return e.jsx(P,{direction:"row",flexWrap:"wrap",gap:1,...d,children:t.map(m=>e.jsx(Ue.Fragment,{children:e.jsx(ye,{title:K.OAUTH_SCOPES[m],children:e.jsx(v,{children:m})})},m))})}V.propTypes={scope:s.string};V.defaultProps={scope:""};const ee=i=>{const{prefix:d}=_(),{blocklet:t}=ke(),m=re(d,"/api/media/upload",t.appPid),n=b.useCallback(U=>U?U.startsWith("http")?U:`${re(d,"/api/media/upload",t.appPid)}/${U}`:"",[d,t.appPid]);return{clientLogoUrl:b.useMemo(()=>n(i),[i,n]),apiPath:m,getClientLogoUrl:n}},We=b.lazy(()=>we(()=>import("./index-B_-kynzD.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(i=>({default:i.Uploader})));function me({client:i,onUpdate:d,onClose:t}){const[m,n]=b.useState(!1),{t:o,locale:U}=F(),p=b.useRef(null),{api:R}=_(),{teamDid:x}=B(),{control:j,handleSubmit:y,formState:{errors:h},watch:I,setValue:q,getValues:a}=pe({defaultValues:{clientName:i.clientName||"",clientUri:i.clientUri||"",redirectUris:Array.isArray(i.redirectUris)?i.redirectUris.join(","):"",scope:i.scope?i.scope.split(" "):["profile:read"],contacts:Array.isArray(i.contacts)?i.contacts.join(","):"",tosUri:i.tosUri||"",policyUri:i.policyUri||"",logoUri:i.logoUri||""},mode:"onChange"}),c=I("scope"),A=I("logoUri"),{clientLogoUrl:T,apiPath:W}=ee(A),z=r=>{r!=="profile:read"&&q("scope",c.includes(r)?c.filter(l=>l!==r):[...c,r])},O=async r=>{const l={clientId:i.clientId,clientName:r.clientName.trim(),clientUri:r.clientUri,redirectUris:r.redirectUris.split(",").map(f=>f.trim()).filter(Boolean),contacts:r.contacts?r.contacts.split(",").map(f=>f.trim()):[],scope:r.scope.join(" "),tosUri:r.tosUri,policyUri:r.policyUri,logoUri:r.logoUri};await R.updateOAuthClient({input:{teamDid:x,input:l}})},g=async r=>{n(!0);try{await O(r),d(),t()}catch(l){M.error(l.message||o("oauth.client.updateFailed"))}finally{n(!1)}};return e.jsxs(G,{open:!0,onClose:t,maxWidth:"md",fullWidth:!0,children:[e.jsxs(X,{children:[o("oauth.client.update")," ",e.jsx(Z,{onClick:t,sx:{position:"absolute",right:8,top:8},children:e.jsx(H,{})})]}),e.jsx(J,{children:e.jsxs(P,{spacing:3,sx:{mt:2},children:[e.jsxs(u,{sx:{mb:3},children:[e.jsx(k,{variant:"subtitle1",sx:{fontWeight:500,mb:1},children:o("oauth.client.logo")}),e.jsxs(u,{children:[e.jsx(u,{sx:{width:120,height:120,position:"relative",borderRadius:"4px",overflow:"hidden"},children:T?e.jsx(u,{children:e.jsx("img",{src:T,alt:"client-logo",style:{width:"100%",height:"100%"}})}):e.jsx(u,{onClick:()=>{var r;(r=p.current)==null||r.open()},sx:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"grey.200"},children:e.jsx(de,{sx:{fontSize:40,color:"common.white"}})})}),e.jsx(L,{sx:{mt:2},variant:"outlined",size:"small",onClick:()=>{var r;(r=p.current)==null||r.open()},children:o(T?"common.change":"common.upload")})]}),e.jsx(u,{sx:{display:"flex",alignItems:"center"},children:e.jsx(b.Suspense,{fallback:e.jsx(qe,{}),children:e.jsx(We,{ref:p,locale:U,popup:!0,onUploadFinish:r=>{q("logoUri",r.data.filename),O(a()).then(()=>{d()}).catch(l=>{M.error(l.message||o("oauth.client.updateFailed"))}).finally(()=>{var l;(l=p.current)==null||l.close()})},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:W,disableMediaKitPrefix:!0,disableAutoPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/png","image/jpeg","image/webp","image/svg+xml"],maxFileSize:1024*1024*.5,maxNumberOfFiles:1}},dashboardProps:{autoOpen:"imageEditor"},imageEditorProps:{actions:{revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!1,cropWidescreen:!1,cropWidescreenVertical:!1},cropperOptions:{autoCrop:!0,aspectRatio:1,initialAspectRatio:1,autoCropArea:1,croppedCanvasOptions:{minWidth:256,minHeight:256}}}},"uploader-logo")})})]}),e.jsx(k,{variant:"subtitle1",sx:{fontWeight:500},children:o("oauth.client.requiredInformation")}),e.jsx(w,{label:"Client Id",fullWidth:!0,value:i.clientId,disabled:!0}),e.jsx(u,{children:e.jsx(S,{name:"clientName",control:j,rules:{required:o("oauth.client.validate.clientName"),minLength:{value:3,message:o("oauth.client.validate.clientNameMinLength")}},render:({field:r})=>{var l;return e.jsxs(e.Fragment,{children:[e.jsx(w,{...r,label:o("oauth.client.name"),required:!0,fullWidth:!0,error:!!h.clientName,helperText:(l=h.clientName)==null?void 0:l.message}),e.jsx(C,{children:o("oauth.client.helperText.clientName")})]})}})}),e.jsx(u,{children:e.jsx(S,{name:"clientUri",control:j,rules:{required:o("oauth.client.validate.clientUri"),pattern:{value:/^https?:\/\/.+/,message:o("oauth.client.validate.clientUriInvalid")}},render:({field:r})=>{var l;return e.jsxs(e.Fragment,{children:[e.jsx(w,{...r,label:o("oauth.client.input.clientUri"),required:!0,fullWidth:!0,error:!!h.clientUri,helperText:(l=h.clientUri)==null?void 0:l.message}),e.jsx(C,{children:o("oauth.client.helperText.clientUri")})]})}})}),e.jsx(u,{children:e.jsx(S,{name:"redirectUris",control:j,rules:{required:o("oauth.client.validate.redirectUris"),pattern:{value:/^https?:\/\/.+/,message:o("oauth.client.validate.redirectUrisInvalid")}},render:({field:r})=>{var l;return e.jsxs(e.Fragment,{children:[e.jsx(w,{...r,label:o("oauth.client.input.redirectUris"),required:!0,fullWidth:!0,multiline:!0,rows:2,error:!!h.redirectUris,helperText:(l=h.redirectUris)==null?void 0:l.message}),e.jsx(C,{children:o("oauth.client.helperText.redirectUris")})]})}})}),e.jsxs(u,{sx:{display:"none"},children:[e.jsx(k,{variant:"subtitle2",sx:{mb:1},children:o("oauth.client.input.permissions")}),e.jsx(u,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1,p:2},children:e.jsx(ne,{children:Object.entries(K.OAUTH_SCOPES).map(([r,l])=>e.jsx(se,{control:e.jsx(oe,{checked:c.includes(r),onChange:()=>z(r),disabled:r==="profile:read",color:"primary"}),label:e.jsx(u,{children:e.jsx(k,{variant:"body2",sx:{fontWeight:500},children:l})})},r))})})]}),e.jsx(Q,{}),e.jsx(k,{variant:"subtitle1",sx:{fontWeight:500},children:o("oauth.client.optionalInformation")}),e.jsx(u,{children:e.jsx(S,{name:"contacts",control:j,rules:{pattern:{value:/^$|^[^@\s]+@[^@\s]+\.[^@\s]+(\s*,\s*[^@\s]+@[^@\s]+\.[^@\s]+)*$/,message:o("oauth.client.validate.contacts")}},render:({field:r})=>{var l;return e.jsxs(e.Fragment,{children:[e.jsx(w,{...r,label:o("oauth.client.input.contacts"),fullWidth:!0,error:!!h.contacts,helperText:(l=h.contacts)==null?void 0:l.message}),e.jsx(C,{children:o("oauth.client.helperText.contacts")})]})}})}),e.jsxs(P,{direction:{xs:"column",sm:"row"},spacing:2,children:[e.jsx(S,{name:"tosUri",control:j,rules:{pattern:{value:/^$|^https?:\/\/.+/,message:o("oauth.client.validate.tosUriInvalid")}},render:({field:r})=>{var l;return e.jsxs(u,{sx:{width:"50%"},children:[e.jsx(w,{...r,label:o("oauth.client.input.tosUri"),fullWidth:!0,error:!!h.tosUri,helperText:(l=h.tosUri)==null?void 0:l.message}),e.jsx(C,{children:o("oauth.client.helperText.tosUri")})]})}}),e.jsx(S,{name:"policyUri",control:j,rules:{pattern:{value:/^$|^https?:\/\/.+/,message:o("oauth.client.validate.policyUriInvalid")}},render:({field:r})=>{var l;return e.jsxs(u,{sx:{width:"50%"},children:[e.jsx(w,{...r,label:o("oauth.client.input.policyUri"),fullWidth:!0,error:!!h.policyUri,helperText:(l=h.policyUri)==null?void 0:l.message}),e.jsx(C,{children:o("oauth.client.helperText.policyUri")})]})}})]}),h.error&&e.jsx(ae,{severity:"error",children:h.error.message})]})}),e.jsxs(ce,{children:[e.jsx(L,{onClick:t,children:o("common.cancel")}),e.jsx(L,{onClick:y(g),disabled:m,variant:"contained",color:"primary",children:m?e.jsx(Y,{size:16}):o("common.update")})]})]})}me.propTypes={client:s.shape({clientId:s.string.isRequired,clientName:s.string.isRequired,clientUri:s.string,redirectUris:s.arrayOf(s.string),scope:s.string,contacts:s.arrayOf(s.string),tosUri:s.string,policyUri:s.string,logoUri:s.string}).isRequired,onUpdate:s.func.isRequired,onClose:s.func.isRequired};function xe({client:i,onUpdate:d,onClose:t}){return e.jsx(me,{client:i,onUpdate:m=>d(m),onClose:t})}xe.propTypes={client:s.shape({clientId:s.string.isRequired,clientName:s.string.isRequired,clientUri:s.string,redirectUris:s.arrayOf(s.string),scope:s.string,contacts:s.arrayOf(s.string),tosUri:s.string,policyUri:s.string,logoUri:s.string}).isRequired,onUpdate:s.func.isRequired,onClose:s.func.isRequired};function te(i){const{t:d}=F(),{api:t}=_(),{teamDid:m}=B(),{clientId:n,clientName:o,onDelete:U=()=>{},onClose:p=()=>{}}=i,R=()=>{p()},x=async()=>{try{await t.deleteOAuthClient({input:{teamDid:m,clientId:n}}),U()}catch(y){M.error(y==null?void 0:y.message)}finally{R()}},j={keyName:o,title:d("oauth.client.delete.title"),description:d("oauth.client.delete.description",{name:`<b>${o}</b>`}),confirmPlaceholder:d("oauth.client.delete.description",{name:o}),confirm:d("common.delConfirm"),cancel:d("common.cancel"),onConfirm:x,onCancel:R};return e.jsx(Ae,{keyName:j.keyName,title:j.title,description:j.description,confirmPlaceholder:j.confirmPlaceholder,confirm:j.confirm,cancel:j.cancel,params:j.params,onConfirm:j.onConfirm,onCancel:j.onCancel})}te.propTypes={clientId:s.string.isRequired,clientName:s.string.isRequired,onDelete:s.func,onClose:s.func};te.defaultProps={onDelete:()=>{},onClose:()=>{}};function je({title:i,items:d}){return e.jsxs(u,{mb:3,children:[e.jsx(k,{variant:"h6",sx:{mb:1.5},children:i}),e.jsx(P,{spacing:1.5,children:d.map(({label:t,value:m})=>e.jsxs(u,{display:"flex",alignItems:"center",gap:2,children:[e.jsx(k,{variant:"subtitle2",color:"textSecondary",sx:{minWidth:200},children:t}),e.jsx(k,{sx:{wordBreak:"break-all"},children:m||"-"})]},t))})]})}je.propTypes={title:s.string.isRequired,items:s.arrayOf(s.shape({label:s.string.isRequired,value:s.any})).isRequired};function ge({client:i,onClose:d}){const{t,locale:m}=F(),{teamDid:n}=B(),{clientName:o,clientId:U,clientSecret:p,redirectUris:R,scope:x,clientUri:j,logoUri:y,contacts:h,tosUri:I,policyUri:q,jwksUri:a,jwks:c,softwareId:A,softwareVersion:T,clientIdIssuedAt:W,clientSecretExpiresAt:z,updatedAt:O,createUser:g}=i,{clientLogoUrl:r}=ee(y),l=N=>{try{const E=new URL(window.blocklet.appUrl);return E.pathname=N,E.toString()}catch{return"-"}},f=ue.fromAppDid(U,n),D=[{title:t("common.baseInfo"),items:[{label:t("oauth.client.name"),value:o},{label:t("oauth.client.logoUri"),value:e.jsx(le,{variant:"rounded",shape:"square",src:r,did:f.address,size:64})},{label:t("oauth.client.clientUri"),value:j?e.jsx(v,{children:j}):"-"},{label:t("oauth.client.clientId"),value:e.jsx(v,{children:U})},{label:t("oauth.client.clientSecret"),value:e.jsx(v,{children:p})},{label:t("oauth.client.redirectUris"),value:e.jsx(v,{children:(R||[]).join(", ")})},{label:t("oauth.client.scope"),value:e.jsx(V,{scope:x})},{label:t("oauth.client.createUser"),value:g?Oe(g,!0):t("oauth.client.openRegistration")}]},{title:t("oauth.client.oauthEndpoints"),items:[{label:t("oauth.client.openidConfiguration"),value:e.jsx(v,{children:l("/.well-known/openid-configuration")})},{label:t("oauth.client.authorizationEndpoint"),value:e.jsx(v,{children:l("/.well-known/service/oauth/authorize")})},{label:t("oauth.client.tokenEndpoint"),value:e.jsx(v,{children:l("/.well-known/service/oauth/token")})},{label:t("oauth.client.userinfoEndpoint"),value:e.jsx(v,{children:l("/.well-known/service/oauth/userinfo")})},{label:t("oauth.client.jwksUri"),value:e.jsx(v,{children:l("/.well-known/service/oauth/jwks")})},{label:t("oauth.client.registrationEndpoint"),value:e.jsx(v,{children:l("/.well-known/service/oauth/register")})},{label:t("oauth.client.endSessionEndpoint"),value:e.jsx(v,{children:l("/.well-known/service/oauth/logout")})}]},{title:t("oauth.client.metaContact"),items:[{label:t("oauth.client.contacts"),value:h.length?e.jsx(v,{children:(h||[]).join(", ")}):"-"},{label:t("oauth.client.tosUri"),value:I?e.jsx(v,{children:I}):"-"},{label:t("oauth.client.policyUri"),value:q?e.jsx(v,{children:q}):"-"},{label:t("oauth.client.jwksUri"),value:a},{label:t("oauth.client.jwks"),value:c},{label:t("oauth.client.softwareId"),value:A},{label:t("oauth.client.softwareVersion"),value:T}]},{title:t("common.timeInfo"),items:[{label:t("oauth.client.clientIdIssuedAt"),value:W?e.jsx($,{value:W*1e3,type:"all",locale:m}):"-"},{label:t("oauth.client.clientSecretExpiresAt"),value:z?e.jsx($,{value:z*1e3,type:"all",locale:m}):"-"},{label:t("common.updatedAt"),value:O?e.jsx($,{value:O,type:"all",locale:m}):"-"}]}].filter(Boolean);return e.jsxs(G,{open:!0,onClose:d,maxWidth:"lg",fullWidth:!0,children:[e.jsxs(X,{children:[t("oauth.client.oauthAppDetails"),e.jsx(Z,{onClick:d,sx:{position:"absolute",right:8,top:8},children:e.jsx(H,{})})]}),e.jsx(J,{children:e.jsx(u,{mt:1,children:D.map((N,E)=>e.jsxs(u,{children:[e.jsx(je,{title:N.title,items:N.items}),E!==D.length-1&&e.jsx(Q,{sx:{my:2}})]},N.title))})})]})}ge.propTypes={client:s.object.isRequired,onClose:s.func.isRequired};function ze(i){return e.jsx($,{value:i*1e3})}function ie({selected:i,onClose:d}){return i?e.jsx(ge,{client:i,onClose:d}):null}ie.propTypes={selected:s.object,onClose:s.func.isRequired};ie.defaultProps={selected:null};function fe({open:i,onCreated:d,onClose:t}){return i?e.jsx(he,{onCreated:d,onClose:t}):null}fe.propTypes={open:s.bool.isRequired,onCreated:s.func.isRequired,onClose:s.func.isRequired};function bt(){var O;const[i,d]=b.useState({searchText:"",pageSize:10,page:1}),[t,m]=b.useState(null),[n,o]=b.useState(!1),U=b.useRef(null),{t:p}=F(),{api:R}=_(),{teamDid:x}=B(),[j,y]=b.useState(null),[h,I]=b.useState(null),{getClientLogoUrl:q}=ee(),a=Se(async()=>await R.getOAuthClients({input:{teamDid:x,paging:{page:i.page,pageSize:i.pageSize}}}),[i.page,i.pageSize]),{loading:c}=a,A=b.useMemo(()=>{var g;return((g=a.value)==null?void 0:g.list)||[]},[(O=a.value)==null?void 0:O.list]),T=b.useMemo(()=>i.searchText?A.filter(g=>g.clientName.toLowerCase().includes(i.searchText.toLowerCase())||g.clientId.toLowerCase().includes(i.searchText.toLowerCase())||g.scope.toLowerCase().includes(i.searchText.toLowerCase())):A,[i.searchText,A]),W=b.useMemo(()=>[{label:p("oauth.client.name"),name:"clientName",options:{customBodyRender:(g,{rowIndex:r})=>{const l=T[r],f=q(l.logoUri),D=ue.fromAppDid(l.clientId,x);return e.jsx(u,{sx:{display:"flex",alignItems:"center",gap:2},children:e.jsxs(u,{display:"flex",alignItems:"center",gap:2,sx:{cursor:"pointer"},onClick:N=>{N.stopPropagation(),window.open(l.clientUri,"_blank")},children:[e.jsx(le,{variant:"rounded",shape:"square",did:D.address,src:f,size:48}),e.jsxs(P,{gap:.5,children:[e.jsx(u,{sx:{color:"text.primary"},children:l.clientName}),e.jsx(u,{sx:{color:"text.secondary"},children:l.clientUri})]})]})})}}},{label:p("oauth.client.clientId"),name:"clientId"},{label:p("oauth.client.scope"),name:"scope",options:{customBodyRender:g=>e.jsx(V,{scope:g})}},{label:p("common.createdAt"),name:"clientIdIssuedAt",options:{customBodyRender:ze}},{label:p("common.actions"),name:"actions",width:100,align:"center",verticalKeyAlign:"center",options:{customBodyRender:(g,{rowIndex:r})=>{const l=T[r];return e.jsx(Pe,{actions:[{icon:e.jsx(Te,{}),text:p("common.edit"),onClick:f=>{f.stopPropagation(),y(l)}},{icon:e.jsx(be,{}),text:p("common.delete"),onClick:f=>{f.stopPropagation(),I(l)}}]})}}}],[T,p,q,x,y,I]),z=({page:g,rowsPerPage:r,searchText:l})=>{i.pageSize!==r?d(f=>({...f,searchText:"",pageSize:r,page:1})):i.page!==g+1?d(f=>({...f,searchText:"",page:g+1})):i.searchText!==l&&d(f=>({...f,searchText:l,page:1}))};return e.jsxs(u,{ref:U,sx:{".custom-toobar-btns":{gap:"8px"}},children:[e.jsx(ve,{data:T,columns:W,options:{sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,page:i.page-1,rowsPerPage:i.pageSize,count:T.length,searchDebounceTime:400,onRowClick(g,{dataIndex:r},l){var f;if((f=U.current)!=null&&f.contains(l.target)){const D=T[r];m(D)}}},onChange:z,customButtons:[e.jsxs(L,{variant:"contained",size:"small",onClick:()=>o(!0),children:[c?e.jsx(Y,{size:16}):e.jsx(de,{style:{fontSize:16}}),p("common.create")]},"add")],loading:!1}),e.jsx(ie,{selected:t,onClose:()=>m(null)}),e.jsx(fe,{open:n,onCreated:()=>{o(!1),a.retry()},onClose:()=>o(!1)}),j&&e.jsx(xe,{client:j,onUpdate:a.retry,onClose:()=>y(null)}),h&&e.jsx(te,{...h,onDelete:a.retry,onClose:()=>I(null)})]})}export{bt as default};
|