@abtnode/blocklet-services 1.16.42-beta-20250407-220350-e3782a91 → 1.16.42-beta-20250408-050422-92c8eef3
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/{ArrowDropDown-CIcX9so8.js → ArrowDropDown-WXsjNpSB.js} +1 -1
- package/dist/assets/{CheckCircle-BBenFQEZ.js → CheckCircle-D7CrWlJ6.js} +1 -1
- package/dist/assets/{ChevronLeft-XZDsaitS.js → ChevronLeft-DeulnkX8.js} +1 -1
- package/dist/assets/{ChevronRight-DfhN5qTp.js → ChevronRight-CACHNf5Y.js} +1 -1
- package/dist/assets/{DeleteOutline-DVPNhMfh.js → DeleteOutline-DT1G93_1.js} +1 -1
- package/dist/assets/{Done-Bu72PctM.js → Done-D9sjuoNQ.js} +1 -1
- package/dist/assets/{Download-CDVTENqI.js → Download-CBzqKt6X.js} +1 -1
- package/dist/assets/{Error-CDj0R4_e.js → Error-l_WxG8z-.js} +1 -1
- package/dist/assets/{ExpandLess-Dt46nF0t.js → ExpandLess-uIJAqSZm.js} +1 -1
- package/dist/assets/{Google-BxEqzKy9.js → Google-BchHLUIl.js} +1 -1
- package/dist/assets/{InfoOutlined-Cga_EIiY.js → InfoOutlined-DFTm-vVr.js} +1 -1
- package/dist/assets/{Launch-hbSlZ0zw.js → Launch-DQCS90NS.js} +1 -1
- package/dist/assets/{LaunchOutlined-FPKJQ1Ta.js → LaunchOutlined-DttrDnYo.js} +1 -1
- package/dist/assets/{MoreHoriz-CiMTPRBH.js → MoreHoriz-BD8SroCJ.js} +1 -1
- package/dist/assets/{PlayArrow-CTZ2QlWx.js → PlayArrow-BEUAi9Bt.js} +1 -1
- package/dist/assets/{TuneOutlined-BVx9kD7P.js → TuneOutlined-CzDTcEdK.js} +1 -1
- package/dist/assets/{ViewList-Rdv91ijz.js → ViewList-6gwww-su.js} +1 -1
- package/dist/assets/{access-control-DZAkdMhI.js → access-control-Bp6fLweq.js} +1 -1
- package/dist/assets/{actions-DVfOVgcp.js → actions-C9vqEgMU.js} +1 -1
- package/dist/assets/{add-component-core-BRwA72Ul.js → add-component-core-e0A2r7mm.js} +1 -1
- package/dist/assets/{add-resource-DmAz4Wic.js → add-resource-tZ8OPVzc.js} +1 -1
- package/dist/assets/{addon-dV77wOE-.js → addon-BNDsoean.js} +1 -1
- package/dist/assets/{advanced-C5DmDZyt.js → advanced-vuRNp9gZ.js} +1 -1
- package/dist/assets/{appearance-B_lR60lO.js → appearance-CFcde0Qw.js} +1 -1
- package/dist/assets/{audit-logs-C0ApIidf.js → audit-logs-C51Acdy3.js} +1 -1
- package/dist/assets/{base32-CHVLLVvB.js → base32-CEWQZb_G.js} +1 -1
- package/dist/assets/{branding-CHqonQEq.js → branding-B4OmIbxT.js} +1 -1
- package/dist/assets/{branding-DlWkjNZy.js → branding-PF95Dp3j.js} +2 -2
- package/dist/assets/{bundle-avatar-CP1Y8_9Y.js → bundle-avatar-xyEwd0kl.js} +1 -1
- package/dist/assets/{button-CYnp_Qaz.js → button-BQLtMsfK.js} +1 -1
- package/dist/assets/{click-to-copy-BNduK3fH.js → click-to-copy-CkbZjUXU.js} +1 -1
- package/dist/assets/{complete-Cb2HEBpG.js → complete-BnqT6D6R.js} +1 -1
- package/dist/assets/{component-CQscxGQo.js → component-BbpzttYw.js} +1 -1
- package/dist/assets/{config-B7w-t9zX.js → config-BRGxJ2eh.js} +1 -1
- package/dist/assets/{config-Dtwn5KYi.js → config-DXNBk8Sr.js} +1 -1
- package/dist/assets/{config-navigation-CzVRprQB.js → config-navigation-Bp_tpZTf.js} +3 -3
- package/dist/assets/{config-space-DwDB8lsp.js → config-space-DLpGXOv3.js} +1 -1
- package/dist/assets/{confirm-B2IOP2M3.js → confirm-DMfA-cen.js} +1 -1
- package/dist/assets/connect-BbnPPMBE.js +5 -0
- package/dist/assets/{connect-xfYZ8IAV.js → connect-DrhKSeJG.js} +1 -1
- package/dist/assets/{connect-to-5OMMyaiW.js → connect-to-BWtx4RxY.js} +1 -1
- package/dist/assets/{dashboard-CFCEDlP-.js → dashboard-D1IAu0pg.js} +3 -3
- package/dist/assets/{delete-confirm-CfIbUYYk.js → delete-confirm-BOPmqCDE.js} +1 -1
- package/dist/assets/{did-address-Cv_JswP5.js → did-address-_2BUka_2.js} +1 -1
- package/dist/assets/domain-C058D5cL.js +9 -0
- package/dist/assets/{domain-action-card-zrJxt72X.js → domain-action-card-hJylsZDf.js} +2 -2
- package/dist/assets/domains-CHSNHTzm.js +1 -0
- package/dist/assets/{email-CPcF02_u.js → email-DTd5dLMw.js} +1 -1
- package/dist/assets/{exchange-passport-CuVimc1z.js → exchange-passport-CUoEzJAn.js} +1 -1
- package/dist/assets/{fuel-DBtsoBpG.js → fuel-D1-QzTfA.js} +1 -1
- package/dist/assets/{get-safe-url-B0p0Sl-_.js → get-safe-url-B2pIo8YT.js} +1 -1
- package/dist/assets/{get-safe-url-DBsoYX8R.js → get-safe-url-M62JolcK.js} +1 -1
- package/dist/assets/{home-DOEBAXN2.js → home-D8xdbvkr.js} +1 -1
- package/dist/assets/{iframe-DAyXsLzg.js → iframe-BGb_KeKZ.js} +1 -1
- package/dist/assets/{index-D4WK9Fpj.js → index--QvOAcHK.js} +3 -3
- package/dist/assets/{index-CIKA5OOH.js → index-BQddb9SV.js} +4 -4
- package/dist/assets/{index-DUqwPXHV.js → index-Bcipz7Xh.js} +1 -1
- package/dist/assets/{index-DdmAJNiO.js → index-Be9flGYn.js} +1 -1
- package/dist/assets/{index-d2gQqAm6.js → index-Bgbz960f.js} +1 -1
- package/dist/assets/{index-Hx9TNFzZ.js → index-Biod65HH.js} +1 -1
- package/dist/assets/{index-BUDc_5A6.js → index-BmIHv0Ao.js} +1 -1
- package/dist/assets/{index-BVLCYG1J.js → index-Bn6qMcz9.js} +1 -1
- package/dist/assets/{index-DjhdGCFl.js → index-COXsk6dn.js} +1 -1
- package/dist/assets/{index-nHbtopN7.js → index-CqRb1YIC.js} +1 -1
- package/dist/assets/{index-CuJTCVC9.js → index-DOTrxWIb.js} +1 -1
- package/dist/assets/{index-BxtbFqQ7.js → index-DUqEJSX8.js} +1 -1
- package/dist/assets/{index-CPrWUCW6.js → index-DY7FozBP.js} +1 -1
- package/dist/assets/{index-BAphTUTz.js → index-Dja0MgHa.js} +3 -3
- package/dist/assets/{index-D9AtvVSE.js → index-DvX6CH9d.js} +1 -1
- package/dist/assets/{index-CY-SffSN.js → index-Tc7h84RU.js} +1 -1
- package/dist/assets/{index-C6oT-lJS.js → index-r4W5xGua.js} +1 -1
- package/dist/assets/{invitation-BN-WW8c1.js → invitation-CLrDi0w3.js} +1 -1
- package/dist/assets/{invite-DHJiC6BF.js → invite-BlqLHSHA.js} +1 -1
- package/dist/assets/{issue-passport-CCDXWogO.js → issue-passport-0xgFeiRm.js} +1 -1
- package/dist/assets/{item-BtVm0eZl.js → item-DFeRxihy.js} +1 -1
- package/dist/assets/{landing-page-B6GPz-DA.js → landing-page-Dl8nGCZh.js} +1 -1
- package/dist/assets/{layout-CkeNygRb.js → layout-BQ9Qhixa.js} +1 -1
- package/dist/assets/{list-8seiNFE0.js → list-BO1EU3G2.js} +1 -1
- package/dist/assets/localization-rR3sV7At.js +1 -0
- package/dist/assets/{log-CYLd2Knl.js → log-Qir3lxDV.js} +1 -1
- package/dist/assets/{login-Cuye2iE2.js → login-C780ZUv4.js} +1 -1
- package/dist/assets/{login-oauth-callback-Obvjcq-B.js → login-oauth-callback-CfaWz0tg.js} +1 -1
- package/dist/assets/{logo-uploader-CejcEz3E.js → logo-uploader-gCM0_9lk.js} +3 -3
- package/dist/assets/{lost-passport-BB_BfMMj.js → lost-passport-ieF1z1Fq.js} +1 -1
- package/dist/assets/{open-window-BSZzCk0O.js → open-window-DMkA-B_A.js} +1 -1
- package/dist/assets/{overview-CgGEof25.js → overview-CqE5Qd7t.js} +1 -1
- package/dist/assets/{page-header-BbutANxz.js → page-header-D3dCkXy7.js} +1 -1
- package/dist/assets/{permission-D7sDivJU.js → permission-ClAqVelD.js} +1 -1
- package/dist/assets/{preferences-Cr9xOl3Y.js → preferences-YM19d1y9.js} +1 -1
- package/dist/assets/{profile-embed-IW6vPild.js → profile-embed-DJJJzari.js} +1 -1
- package/dist/assets/{publish-resource-D5qodgK0.js → publish-resource-BFGnGhHk.js} +1 -1
- package/dist/assets/{react-beautiful-dnd.esm-ONm9Sfm9.js → react-beautiful-dnd.esm-Cx5BcFIr.js} +1 -1
- package/dist/assets/{relative-time-BlwUAPs3.js → relative-time-BUHtgSDe.js} +1 -1
- package/dist/assets/{runtime-C5P9bpb_.js → runtime-B5YY9Qgr.js} +1 -1
- package/dist/assets/sdk-DRBcrGrS.js +1 -0
- package/dist/assets/{security-Bpsae55i.js → security-Dad28Y4W.js} +1 -1
- package/dist/assets/{session-D21Dok5b.js → session-Clq9kJzg.js} +1 -1
- package/dist/assets/setup-DEJbIHrj.js +19 -0
- package/dist/assets/{spaces-BCWZ7kDs.js → spaces-CcqmBId2.js} +1 -1
- package/dist/assets/{start-BtbB_6hq.js → start-9UMY8DNC.js} +1 -1
- package/dist/assets/{status-CED3HmVQ.js → status-BFrUchan.js} +1 -1
- package/dist/assets/{step-actions-DKSbOH-i.js → step-actions-DZ9FTtHm.js} +1 -1
- package/dist/assets/{studio-D6is1ZB_.js → studio-Bv91lan_.js} +1 -1
- package/dist/assets/{switch-control-CHr40nyS.js → switch-control-DjMziEFc.js} +1 -1
- package/dist/assets/{traffic-BTceliDE.js → traffic-DPZuINtB.js} +1 -1
- package/dist/assets/{transfer-zO5YVafL.js → transfer-PY0D3H2H.js} +1 -1
- package/dist/assets/{unsubscribe-BIs2kGvq.js → unsubscribe-B3uFNG06.js} +1 -1
- package/dist/assets/useAsync-BmuLIImU.js +1 -0
- package/dist/assets/{useAsyncRetry-BAg_7Lam.js → useAsyncRetry-CwtLImQi.js} +2 -2
- package/dist/assets/{useLocalStorage-Bip9kD-Q.js → useLocalStorage-C1_Fkr6_.js} +1 -1
- package/dist/assets/{user-center-B6K3hCJc.js → user-center-C2i8ji9Q.js} +1 -1
- package/dist/assets/{util-CzLAhqb9.js → util-BL-qFiRh.js} +1 -1
- package/dist/assets/{util-MwMuX2uT.js → util-CORzDFgw.js} +1 -1
- package/dist/assets/{vendor-arcblock-DV12D9BN.js → vendor-arcblock-D8eCUoJY.js} +44 -44
- package/dist/assets/{vendor-ux-did-connect-BihFfRkM.js → vendor-ux-did-connect-BQ3cvv_1.js} +2 -2
- package/dist/assets/{wrap-locale-BycFng9T.js → wrap-locale-BFOSjPWa.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/service-worker.js +1 -1
- package/package.json +28 -28
- package/dist/assets/connect-rJwegOE9.js +0 -5
- package/dist/assets/domain-VSKg_phi.js +0 -9
- package/dist/assets/domains-BjnGIAJ9.js +0 -1
- package/dist/assets/localization-Da3qFRTd.js +0 -1
- package/dist/assets/sdk-DJ0rC1b9.js +0 -1
- package/dist/assets/setup-kIyimAYS.js +0 -19
- package/dist/assets/useAsync-BJWebEpq.js +0 -1
- package/dist/assets/useAsync-CX7JRRJM.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{r as x,k as gt,l as tt,L as xe,u as js,h as ks,i as ct}from"./vendor-react-DoD83n6N.js";import{a2 as ke,j as e,t as Le,a4 as c,bi as vo,E as r,a5 as me,I as ce,T as N,b_ as Co,D as ot,aa as ge,at as ys,bM as Je,ad as wo,bp as Xe,br as ht,x as se,a3 as Ye,P as So,G as Io,v as jt,a0 as Do,an as To,ak as fe,al as Rs,ac as _o,r as Po,bP as vs,K as Ve,y as qo,M as oe,ae as Se,au as Cs,L as ws,z as Ss,b4 as Is,as as $o,ar as Qe,bw as Ds,bx as Ts,b$ as _s,c0 as Ps,bk as ft,bl as qs,bn as $s,bA as Ls,bB as at}from"./vendor-mui-core-C-PhacC8.js";import{A as ye,D as ze,h as ue,a5 as Ns,f as lo,ad as ro}from"./index-D4WK9Fpj.js";import{r as Re,m as G,u as te,ai as As,B as Me,b1 as Lo,R as No,a$ as Ao,al as zs,bo as Bs,a2 as kt,V as M,_ as Es,g as ae,bp as Ws,b6 as Os,ah as $e,aj as yt,ap as Ms}from"./vendor-ux-did-connect-BihFfRkM.js";import{t as Rt,g as Vs,x as Us,_ as zo,y as De,p as Fs}from"./vendor-arcblock-DV12D9BN.js";import{d as Hs}from"./Error-CDj0R4_e.js";import{C as vt}from"./confirm-B2IOP2M3.js";import{u as Ue}from"./session-D21Dok5b.js";import{W as io}from"./did-address-Cv_JswP5.js";import{E as Fe}from"./empty-spinner-CoimPnT0.js";import{B as Ct}from"./bundle-avatar-CP1Y8_9Y.js";import{S as je}from"./shorten-label-C642GTxb.js";import{L as wt}from"./list-header-DvakxkxK.js";import{X as Gs,y as be,H as St,D as Bo}from"./vendor-utils-CRBr0QUY.js";import{d as Js}from"./Download-CDVTENqI.js";import{C as Eo}from"./click-to-copy-BNduK3fH.js";import{Q as Xs}from"./QuestionMarkCircle-BHP2onYz.js";import{u as Ys}from"./vendor-hooks-DtYI0-rF.js";import{_ as Ie}from"./useSetState-BL3ktMon.js";import{c as It}from"./index-tUQxVYYQ.js";import{E as Dt}from"./index-BYC998Xz.js";import{p as Ze}from"./index-CuJTCVC9.js";import"./api-DlN8K5Jg.js";import{d as Qs}from"./ChevronRight-DfhN5qTp.js";import{T as Zs,a as Ks}from"./vendor-mui-x-BiTj3AZC.js";import{d as co}from"./DeleteOutline-DVPNhMfh.js";import{D as ao,C as uo,P as po}from"./react-beautiful-dnd.esm-ONm9Sfm9.js";import{c as en,A as Wo,u as tn,S as on,U as sn,a as dt,b as Oo,n as nn,e as ln,f as ho,g as rn,h as cn}from"./item-BtVm0eZl.js";import{d as an}from"./ArrowDropDown-CIcX9so8.js";import{f as Ne}from"./format-error-LAoTjvJe.js";import{d as dn}from"./Launch-hbSlZ0zw.js";import{M as un}from"./index-CKv9guDo.js";import{r as pn}from"./index-DvDiL1rm.js";import{d as hn}from"./Done-Bu72PctM.js";import"./lottie-web-B6s7dDoL.js";import"./raf-schd.esm-GV-XhwE0.js";import"./delete-confirm-CfIbUYYk.js";import"./get-safe-url-B0p0Sl-_.js";var Tt={},fn=ke;Object.defineProperty(Tt,"__esModule",{value:!0});var Mo=Tt.default=void 0,bn=fn(Re()),xn=e;Mo=Tt.default=(0,bn.default)((0,xn.jsx)("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4z"}),"AddBox");var _t={},mn=ke;Object.defineProperty(_t,"__esModule",{value:!0});var Vo=_t.default=void 0,gn=mn(Re()),jn=e;Vo=_t.default=(0,gn.default)((0,jn.jsx)("path",{d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H15v-8h5V8zm-1 7V3.5L18.5 9zm4 12.66V16h5.66v2h-2.24l2.95 2.95-1.41 1.41L19 19.41v2.24h-2z"}),"FileOpen");var Pt={},kn=ke;Object.defineProperty(Pt,"__esModule",{value:!0});var Uo=Pt.default=void 0,yn=kn(Re()),Rn=e;Uo=Pt.default=(0,yn.default)((0,Rn.jsx)("path",{d:"M11 18h2v-2h-2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4"}),"HelpOutlineOutlined");function qt({did:t,projectId:o,title:s,logo:i,describe:l}){const n=`${`${G.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t}/${o}/logo/upload`}/${i}`,[u,a]=x.useState(!1),h=Le(m=>m.breakpoints.down("md"));return e.jsxs(c,{sx:{display:"flex",flexDirection:"row",color:u?"primary.main":"grey.900",gap:1},onPointerEnter:()=>a(!0),onPointerLeave:()=>a(!1),children:[e.jsx(vo,{sx:{borderRadius:1},src:n}),e.jsxs(c,{children:[e.jsx(je,{hiddenTip:!0,maxLength:"24",sx:{fontSize:"14px",fontWeight:"500",color:h?"primary.main":""},children:s||"/"}),e.jsx(je,{hiddenTip:!0,maxLength:"58",sx:{fontSize:"12px",color:h||u?"primary.main":"grey.700"},children:l||"/"})]})]})}qt.propTypes={projectId:r.string.isRequired,did:r.string.isRequired,title:r.string.isRequired,logo:r.string.isRequired,describe:r.string.isRequired};function $t({initUrl:t}){const o=gt(),s=(t==null?void 0:t.searchParams.get("tenantScope"))||"",{t:i,locale:l}=te(),{api:d}=ye(),{api:n}=Ue(),[u,a]=x.useState(!0),{blocklet:h}=ze(),[m,S]=x.useState(null),[y,p]=x.useState(!1),f=Le(g=>g.breakpoints.down("xl")),R=Le(g=>g.breakpoints.down("md")),{componentDid:I=""}=tt(),[j,D]=x.useState(null),[k,T]=x.useState(""),L=()=>{d.getProjects({input:{did:h.meta.did,componentDid:I,tenantScope:s}}).then(g=>{const _=(g==null?void 0:g.projects)||[];a(!1),D(_)}).catch(g=>{a(!1),M.error(g.message)})},z=()=>{o(`${G.UNOWNED_DID}/create/none`,{replace:!0})},B=g=>{S(g)},v=()=>{a(!1),p(!0)},C=()=>{p(!1),S(null)},H=g=>{M.error(g.message),p(!1),S(null)},W=g=>{if(!(g!=null&&g.deleted)){M.error("Delete project failed");return}L(),p(!1),S(null)};x.useEffect(()=>{L()},[]);const b=x.useMemo(()=>{if(!k)return j;let g=k==null?void 0:k.trim();return g?(g=As.toAddress(g).toLocaleLowerCase(),j.filter(_=>_.blockletTitle.toLowerCase().includes(g)||_.blockletDid.toLowerCase().includes(g))):j},[j,k]);if(!j&&u)return e.jsx(c,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Fe,{})});if(!j)return null;if(!j.length)return e.jsxs(c,{display:"flex",flexDirection:"column",alignItems:"center",pt:10,children:[e.jsx(c,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:i("blocklet.publish.blockletEmptyTip")}),e.jsx(c,{sx:{fontSize:14,color:"text.secondary",mb:3},children:i("blocklet.publish.createBlockletTip")}),e.jsx(Me,{onClick:z,variant:"contained",children:i("blocklet.publish.createBlocklet")})]});const w=[{label:"Blocklet",name:"blockletTitle",minWidth:160,options:{customBodyRenderLite:g=>{const _=j[g];return e.jsx(xe,{to:`${_.id}`,children:e.jsx(qt,{did:h.meta.did,projectId:_.id,logo:_.blockletLogo,title:_.blockletTitle,describe:_.blockletDescription})})}}},{label:"Version",name:"blockletVersion",options:{searchable:!1,customBodyRender:g=>g?e.jsx(Lo,{type:"success",children:g}):""}},{label:"DID",name:"blockletDid",options:{customBodyRender:g=>g?e.jsx(io,{size:14,compact:!0,responsive:!1,did:g}):null}},f||I?null:{label:i("common.createdBy"),name:"createdBy",options:{customBodyRender:g=>g?e.jsx(io,{onClick:()=>{o(`/.well-known/service/admin/members?did=${g}`)},style:{cursor:"pointer"},size:14,compact:!0,copyable:!1,showQrcode:!1,responsive:!1,did:g}):null}},f||I?null:{label:i("common.scope"),name:"componentDid",options:{customBodyRender:g=>{const _=(h.children||[]).find(J=>J.meta.did===g);return _?e.jsxs(c,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[e.jsx(Ct,{size:14,blocklet:_,ancestors:[h]}),e.jsx(c,{ml:.5,sx:{ml:.5,color:"text.primary",fontSize:14},children:_.meta.title})]},g):""}}},f||s?null:{label:i("blocklet.publish.tenantScope"),name:"tenantScope",options:{customBodyRender:g=>e.jsx(c,{ml:.5,sx:{ml:.5,color:"text.primary",fontSize:14},children:e.jsx(je,{children:g})})}},{label:i("common.updatedAt"),name:"updatedAt",options:{searchable:!1,customBodyRender:g=>e.jsx(No,{value:Number(g),locale:l})}},{label:i("common.actions"),name:"actions",options:{searchable:!1,customBodyRenderLite:g=>{const _=j[g];return e.jsxs(c,{display:"flex",children:[e.jsx(xe,{to:`${_.id}/new-release/${_.lastReleaseId}`,children:e.jsx(me,{title:i("blocklet.publish.createRelease"),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"create",children:e.jsx(Mo,{style:{fontSize:18}})})})}),!!_.lastReleaseId&&e.jsx(me,{title:i("blocklet.publish.viewLastRelease",{name:_.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx(xe,{style:{display:"flex"},to:`${_.id}/view/${_.lastReleaseId}`,children:e.jsx(Vo,{sx:{fontSize:18}})})})}),e.jsx(me,{title:i("blocklet.publish.delete",{name:_.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>B(_),children:e.jsx(Ao,{sx:{fontSize:18}})})})]})}}}].filter(Boolean),q=y?e.jsx(zs,{open:!0,popup:!0,onClose:C,action:"check-has-project-id",locale:l,checkFn:n.get,saveConnect:!1,forceConnected:!1,checkTimeout:5*60*1e3,onSuccess:W,onError:H,extraParams:{projectId:m.id,did:h.meta.did,name:m.blockletTitle},messages:{title:i("blocklet.publish.deleteProject.title",{name:m.blockletTitle}),scan:i("blocklet.publish.deleteProject.scan",{name:m.blockletTitle}),confirm:i("blocklet.publish.deleteProject.confirm"),success:i("blocklet.publish.deleteProject.success")}}):null;return e.jsxs(c,{children:[e.jsx(wt,{sx:{mb:2},left:e.jsxs(c,{display:"flex",flexDirection:"row",alignItems:"center",children:[e.jsx(c,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:i("common.blockletStudio")}),e.jsx(me,{title:i("blocklet.publish.createBlockletTip"),arrow:!0,placement:"right",children:e.jsx(Uo,{sx:{opacity:.6,fontSize:"1.1em",ml:1}})})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(Bs,{options:{searchPlaceholder:i("blocklet.list.searchPlaceholder"),searchDebounceTime:600,searchAlwaysOpen:R},search:k,searchText:k,searchTextUpdate:T,searchClose:()=>T(""),onSearchOpen:()=>{}}),e.jsxs(Me,{onClick:z,variant:"contained",children:[e.jsx(Rt,{style:{fontSize:"1.3em",marginRight:4}}),i("blocklet.publish.createBlocklet")]})]})}),e.jsx(kt,{className:"main-table",locale:l,data:b,columns:w,options:{search:!1,sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,searchAlwaysOpen:!0,rowsPerPageOptions:[10,20,50,100]}}),m&&e.jsx(vt,{title:`${i("common.delete")} ${m.blockletTitle}`,description:i("blocklet.publish.deleteProject.description"),confirm:i("common.confirm"),onConfirm:v,onCancel:()=>S(null),children:e.jsx(c,{sx:{marginTop:2},children:[i("blocklet.publish.deleteProject.tip1"),i("blocklet.publish.deleteProject.tip2"),i("blocklet.publish.deleteProject.tip3")].map(g=>e.jsxs(c,{sx:{display:"flex",marginTop:1,flexDirection:"row",alignItems:"flex-start"},children:[e.jsx(Hs,{color:"warning",sx:{marginRight:1,fontSize:20,marginTop:"2px"}}),e.jsx(N,{component:"span",variant:"inherit",color:"text.secondary",children:g})]}))})}),q]})}$t.propTypes={initUrl:r.object};$t.defaultProps={initUrl:null};var Lt={},vn=ke;Object.defineProperty(Lt,"__esModule",{value:!0});var Fo=Lt.default=void 0,Cn=vn(Re()),fo=e;Fo=Lt.default=(0,Cn.default)([(0,fo.jsx)("path",{d:"M20 17H4V5h8V3H4c-1.11 0-2 .89-2 2v12c0 1.1.89 2 2 2h4v2h8v-2h4c1.1 0 2-.9 2-2v-3h-2z"},"0"),(0,fo.jsx)("path",{d:"m17 14 5-5-1.41-1.41L18 10.17V3h-2v7.17l-2.59-2.58L12 9z"},"1")],"InstallDesktop");const wn=(t,o)=>{if(!t)return"";try{return o?JSON.parse(t)[o]:JSON.parse(t)}catch{}return t},Ho=wn;function Sn(){var B;const{t,locale:o}=te(),{projectId:s}=tt(),{api:i}=ye(),[l,d]=x.useState(!0),{blocklet:n}=ze(),u=Le(v=>v.breakpoints.down("md")),[a,h]=x.useState(null),[m,S]=x.useState(null),[y,p]=x.useState(null),f=(B=window.env)==null?void 0:B.serverEndpoint,R=()=>{i.getReleases({input:{did:n.meta.did,projectId:s}}).then(v=>{const C=(v==null?void 0:v.releases)||[];d(!1),h(C)}).catch(v=>{d(!1),M.error(v.message)})},I=()=>{i.doBatchQuery({getProject:{input:{did:n.meta.did,projectId:s}},getReleases:{input:{did:n.meta.did,projectId:s}}}).then(v=>{S(v.getProject.project||{}),h(v.getReleases.releases||[]),d(!1)}).catch(v=>{d(!1),M.error(v.message)})};x.useEffect(()=>{I()},[]);const[j,D]=x.useState(""),k=()=>{d(!1);const v=y.id;i.deleteRelease({input:{did:n.meta.did,projectId:s,releaseId:v}}).then(()=>{d(!1),R(),M.success(t("common.removeSuccess")),p(null)}).catch(C=>{d(!1),M.error(C.message)})},T=v=>{p(v)};if(!a&&l)return e.jsx(c,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Fe,{})});if(!a)return null;const L=e.jsxs(Co,{className:"breadcrumbs","aria-label":"breadcrumb",children:[e.jsx(xe,{to:"..",children:t("common.blockletStudio")}),e.jsx(N,{color:"text.primary",children:e.jsx(je,{maxLength:u?6:30,children:m.blockletTitle})})]});if(!a.length)return e.jsxs(e.Fragment,{children:[L,e.jsxs(c,{display:"flex",flexDirection:"column",alignItems:"center",pt:10,children:[e.jsx(c,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:t("blocklet.publish.releaseEmptyTip")}),e.jsx(c,{sx:{fontSize:14,color:"text.secondary",mb:3},children:t("blocklet.publish.createReleaseTip")}),e.jsx(xe,{to:"create/none",children:e.jsx(Me,{variant:"contained",children:t("blocklet.publish.createRelease")})})]})]});const z=[{label:t("common.version"),name:"blockletVersion",minWidth:160,options:{customBodyRenderLite:v=>{const C=a[v];return e.jsx(xe,{to:`view/${C.id}`,children:e.jsx(qt,{did:n.meta.did,projectId:m.id,logo:C.blockletLogo,title:C.blockletVersion,describe:C.blockletTitle})})}}},{label:t("blocklet.publish.releaseNote"),name:"note",options:{customBodyRenderLite:v=>{const C=a[v];return e.jsx(N,{className:"note",children:Ho(C.note,"note")})}}},{label:t("common.status"),name:"status",options:{customBodyRender:v=>e.jsx(Lo,{type:v==="published"?"success":"warning",children:v==="published"?"Released":Gs(v)})}},{label:t("common.lastPublishedAt"),name:"updatedAt",options:{customBodyRenderLite:v=>{const C=a[v];return C.status!==ue.PROJECT.RELEASE_STATUS.published?"":e.jsx(No,{value:Number(C.updatedAt),locale:o})}}},{label:t("common.actions"),name:"actions",options:{customBodyRenderLite:v=>{var q;const C=a[v];let H="",W="";const b=C.status==="published";if(b){const g=be(f,`/api/project/${n.meta.did}/${m.id}/${m.lastReleaseId}/release/blocklet.json`),_=new URL(f);_.pathname=be(_.pathname,"/launch-blocklet/agreement"),_.searchParams.set("blocklet_meta_url",g),H=_.href,W=be(`${G.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${n.meta.did}/${m.id}/${m.lastReleaseId}/download/${(m.lastReleaseFiles||[])[0]}`)}const w=(q=m.blockletComponents)!=null&&q.some(g=>g.included)||C.uploadedResource?"pack":"resource";return e.jsxs(c,{display:"flex",alignItems:"center",children:[b&&w==="pack"&&e.jsx(me,{title:t("blocklet.publish.install",{name:m.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx("a",{style:{display:"flex"},href:H,target:"_blank",rel:"noreferrer",children:e.jsx(Fo,{sx:{fontSize:18}})})})}),b&&e.jsx(me,{title:t("blocklet.publish.download",{name:m.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"download",children:e.jsx("a",{style:{display:"flex"},href:W,children:e.jsx(Js,{sx:{fontSize:18}})})})}),e.jsx(me,{title:t("blocklet.publish.delete",{name:m.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>T(C),children:e.jsx(Ao,{sx:{fontSize:18}})})})]})}}}];return e.jsxs(In,{children:[e.jsx(wt,{sx:{mb:2},left:L,actions:e.jsxs(e.Fragment,{children:[e.jsx(Me,{variant:"outlined",onClick:()=>{const v=be(f,`/api/project/${n.meta.did}/${s}/blocklet.json`);D(v)},children:t("blocklet.publish.copyInstallUrl")}),e.jsx(xe,{to:"new-release/none",children:e.jsxs(Me,{variant:"contained",children:[e.jsx(Rt,{style:{fontSize:"1.3em",marginRight:4}}),t("blocklet.publish.createRelease")]})})]})}),e.jsx(ot,{fullWidth:!0,maxWidth:"sm",open:j,onClose:()=>D(""),children:e.jsxs(c,{sx:{py:5,px:4,wordBreak:"break-all"},children:[e.jsx(N,{variant:"h6",sx:{mb:2},children:t("blocklet.publish.installResourceTip")}),e.jsx(Eo,{children:j}),e.jsxs(N,{sx:{mt:2},children:[t("blocklet.publish.installResourceTip2"),e.jsx("a",{style:{marginLeft:4},href:"https://www.arcblock.io/docs/blocklet-developer/how-to-use-install-url",target:"_blank",rel:"noreferrer",children:t("blocklet.publish.installResourceHelp")})]})]})}),e.jsx(kt,{className:"main-table",verticalKeyWidth:100,locale:o,data:a,columns:z,options:{sort:!1,download:!1,filter:!1,print:!1,search:!1}}),y&&e.jsx(vt,{title:t(`${t("common.delete")} ${y.blockletVersion}`),description:t("blocklet.publish.deleteReleaseTip"),confirm:t("common.confirm"),onConfirm:k,onCancel:()=>p(null)})]})}const In=ge(c)`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Dja0MgHa.js","assets/vendor-ux-did-connect-BQ3cvv_1.js","assets/vendor-react-DoD83n6N.js","assets/vendor-utils-CRBr0QUY.js","assets/vendor-mui-core-C-PhacC8.js","assets/vendor-hooks-DtYI0-rF.js","assets/lottie-web-B6s7dDoL.js","assets/vendor-ux-did-connect-BDmhBveY.css","assets/vendor-arcblock-D8eCUoJY.js","assets/index-B9lZsGBd.js","assets/index--QvOAcHK.js","assets/index-tUQxVYYQ.js","assets/index-AgKpYdvC.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as x,k as gt,l as tt,L as xe,u as js,h as ks,i as ct}from"./vendor-react-DoD83n6N.js";import{a2 as ke,j as e,t as Le,a4 as c,bi as vo,E as r,a5 as me,I as ce,T as N,b_ as Co,D as ot,aa as ge,at as ys,bM as Je,ad as wo,bp as Xe,br as ht,x as se,a3 as Ye,P as So,G as Io,v as jt,a0 as Do,an as To,ak as fe,al as Rs,ac as _o,r as Po,bP as vs,K as Ve,y as qo,M as oe,ae as Se,au as Cs,L as ws,z as Ss,b4 as Is,as as $o,ar as Qe,bw as Ds,bx as Ts,b$ as _s,c0 as Ps,bk as ft,bl as qs,bn as $s,bA as Ls,bB as at}from"./vendor-mui-core-C-PhacC8.js";import{A as ye,D as ze,h as ue,a5 as Ns,f as lo,ad as ro}from"./index--QvOAcHK.js";import{r as Re,m as G,u as te,ai as As,B as Me,b1 as Lo,R as No,a$ as Ao,al as zs,bo as Bs,a2 as kt,V as M,_ as Es,g as ae,bp as Ws,b6 as Os,ah as $e,aj as yt,ap as Ms}from"./vendor-ux-did-connect-BQ3cvv_1.js";import{t as Rt,g as Vs,x as Us,_ as zo,y as De,p as Fs}from"./vendor-arcblock-D8eCUoJY.js";import{d as Hs}from"./Error-l_WxG8z-.js";import{C as vt}from"./confirm-DMfA-cen.js";import{u as Ue}from"./session-Clq9kJzg.js";import{W as io}from"./did-address-_2BUka_2.js";import{E as Fe}from"./empty-spinner-CoimPnT0.js";import{B as Ct}from"./bundle-avatar-xyEwd0kl.js";import{S as je}from"./shorten-label-C642GTxb.js";import{L as wt}from"./list-header-DvakxkxK.js";import{X as Gs,y as be,H as St,D as Bo}from"./vendor-utils-CRBr0QUY.js";import{d as Js}from"./Download-CBzqKt6X.js";import{C as Eo}from"./click-to-copy-CkbZjUXU.js";import{Q as Xs}from"./QuestionMarkCircle-BHP2onYz.js";import{u as Ys}from"./vendor-hooks-DtYI0-rF.js";import{_ as Ie}from"./useSetState-BL3ktMon.js";import{c as It}from"./index-tUQxVYYQ.js";import{E as Dt}from"./index-BYC998Xz.js";import{p as Ze}from"./index-DOTrxWIb.js";import"./api-DlN8K5Jg.js";import{d as Qs}from"./ChevronRight-CACHNf5Y.js";import{T as Zs,a as Ks}from"./vendor-mui-x-BiTj3AZC.js";import{d as co}from"./DeleteOutline-DT1G93_1.js";import{D as ao,C as uo,P as po}from"./react-beautiful-dnd.esm-Cx5BcFIr.js";import{c as en,A as Wo,u as tn,S as on,U as sn,a as dt,b as Oo,n as nn,e as ln,f as ho,g as rn,h as cn}from"./item-DFeRxihy.js";import{d as an}from"./ArrowDropDown-WXsjNpSB.js";import{f as Ne}from"./format-error-LAoTjvJe.js";import{d as dn}from"./Launch-DQCS90NS.js";import{M as un}from"./index-CKv9guDo.js";import{r as pn}from"./index-DvDiL1rm.js";import{d as hn}from"./Done-D9sjuoNQ.js";import"./lottie-web-B6s7dDoL.js";import"./raf-schd.esm-GV-XhwE0.js";import"./delete-confirm-BOPmqCDE.js";import"./get-safe-url-M62JolcK.js";var Tt={},fn=ke;Object.defineProperty(Tt,"__esModule",{value:!0});var Mo=Tt.default=void 0,bn=fn(Re()),xn=e;Mo=Tt.default=(0,bn.default)((0,xn.jsx)("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4z"}),"AddBox");var _t={},mn=ke;Object.defineProperty(_t,"__esModule",{value:!0});var Vo=_t.default=void 0,gn=mn(Re()),jn=e;Vo=_t.default=(0,gn.default)((0,jn.jsx)("path",{d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H15v-8h5V8zm-1 7V3.5L18.5 9zm4 12.66V16h5.66v2h-2.24l2.95 2.95-1.41 1.41L19 19.41v2.24h-2z"}),"FileOpen");var Pt={},kn=ke;Object.defineProperty(Pt,"__esModule",{value:!0});var Uo=Pt.default=void 0,yn=kn(Re()),Rn=e;Uo=Pt.default=(0,yn.default)((0,Rn.jsx)("path",{d:"M11 18h2v-2h-2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4"}),"HelpOutlineOutlined");function qt({did:t,projectId:o,title:s,logo:i,describe:l}){const n=`${`${G.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t}/${o}/logo/upload`}/${i}`,[u,a]=x.useState(!1),h=Le(m=>m.breakpoints.down("md"));return e.jsxs(c,{sx:{display:"flex",flexDirection:"row",color:u?"primary.main":"grey.900",gap:1},onPointerEnter:()=>a(!0),onPointerLeave:()=>a(!1),children:[e.jsx(vo,{sx:{borderRadius:1},src:n}),e.jsxs(c,{children:[e.jsx(je,{hiddenTip:!0,maxLength:"24",sx:{fontSize:"14px",fontWeight:"500",color:h?"primary.main":""},children:s||"/"}),e.jsx(je,{hiddenTip:!0,maxLength:"58",sx:{fontSize:"12px",color:h||u?"primary.main":"grey.700"},children:l||"/"})]})]})}qt.propTypes={projectId:r.string.isRequired,did:r.string.isRequired,title:r.string.isRequired,logo:r.string.isRequired,describe:r.string.isRequired};function $t({initUrl:t}){const o=gt(),s=(t==null?void 0:t.searchParams.get("tenantScope"))||"",{t:i,locale:l}=te(),{api:d}=ye(),{api:n}=Ue(),[u,a]=x.useState(!0),{blocklet:h}=ze(),[m,S]=x.useState(null),[y,p]=x.useState(!1),f=Le(g=>g.breakpoints.down("xl")),R=Le(g=>g.breakpoints.down("md")),{componentDid:I=""}=tt(),[j,D]=x.useState(null),[k,T]=x.useState(""),L=()=>{d.getProjects({input:{did:h.meta.did,componentDid:I,tenantScope:s}}).then(g=>{const _=(g==null?void 0:g.projects)||[];a(!1),D(_)}).catch(g=>{a(!1),M.error(g.message)})},z=()=>{o(`${G.UNOWNED_DID}/create/none`,{replace:!0})},B=g=>{S(g)},v=()=>{a(!1),p(!0)},C=()=>{p(!1),S(null)},H=g=>{M.error(g.message),p(!1),S(null)},W=g=>{if(!(g!=null&&g.deleted)){M.error("Delete project failed");return}L(),p(!1),S(null)};x.useEffect(()=>{L()},[]);const b=x.useMemo(()=>{if(!k)return j;let g=k==null?void 0:k.trim();return g?(g=As.toAddress(g).toLocaleLowerCase(),j.filter(_=>_.blockletTitle.toLowerCase().includes(g)||_.blockletDid.toLowerCase().includes(g))):j},[j,k]);if(!j&&u)return e.jsx(c,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Fe,{})});if(!j)return null;if(!j.length)return e.jsxs(c,{display:"flex",flexDirection:"column",alignItems:"center",pt:10,children:[e.jsx(c,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:i("blocklet.publish.blockletEmptyTip")}),e.jsx(c,{sx:{fontSize:14,color:"text.secondary",mb:3},children:i("blocklet.publish.createBlockletTip")}),e.jsx(Me,{onClick:z,variant:"contained",children:i("blocklet.publish.createBlocklet")})]});const w=[{label:"Blocklet",name:"blockletTitle",minWidth:160,options:{customBodyRenderLite:g=>{const _=j[g];return e.jsx(xe,{to:`${_.id}`,children:e.jsx(qt,{did:h.meta.did,projectId:_.id,logo:_.blockletLogo,title:_.blockletTitle,describe:_.blockletDescription})})}}},{label:"Version",name:"blockletVersion",options:{searchable:!1,customBodyRender:g=>g?e.jsx(Lo,{type:"success",children:g}):""}},{label:"DID",name:"blockletDid",options:{customBodyRender:g=>g?e.jsx(io,{size:14,compact:!0,responsive:!1,did:g}):null}},f||I?null:{label:i("common.createdBy"),name:"createdBy",options:{customBodyRender:g=>g?e.jsx(io,{onClick:()=>{o(`/.well-known/service/admin/members?did=${g}`)},style:{cursor:"pointer"},size:14,compact:!0,copyable:!1,showQrcode:!1,responsive:!1,did:g}):null}},f||I?null:{label:i("common.scope"),name:"componentDid",options:{customBodyRender:g=>{const _=(h.children||[]).find(J=>J.meta.did===g);return _?e.jsxs(c,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[e.jsx(Ct,{size:14,blocklet:_,ancestors:[h]}),e.jsx(c,{ml:.5,sx:{ml:.5,color:"text.primary",fontSize:14},children:_.meta.title})]},g):""}}},f||s?null:{label:i("blocklet.publish.tenantScope"),name:"tenantScope",options:{customBodyRender:g=>e.jsx(c,{ml:.5,sx:{ml:.5,color:"text.primary",fontSize:14},children:e.jsx(je,{children:g})})}},{label:i("common.updatedAt"),name:"updatedAt",options:{searchable:!1,customBodyRender:g=>e.jsx(No,{value:Number(g),locale:l})}},{label:i("common.actions"),name:"actions",options:{searchable:!1,customBodyRenderLite:g=>{const _=j[g];return e.jsxs(c,{display:"flex",children:[e.jsx(xe,{to:`${_.id}/new-release/${_.lastReleaseId}`,children:e.jsx(me,{title:i("blocklet.publish.createRelease"),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"create",children:e.jsx(Mo,{style:{fontSize:18}})})})}),!!_.lastReleaseId&&e.jsx(me,{title:i("blocklet.publish.viewLastRelease",{name:_.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx(xe,{style:{display:"flex"},to:`${_.id}/view/${_.lastReleaseId}`,children:e.jsx(Vo,{sx:{fontSize:18}})})})}),e.jsx(me,{title:i("blocklet.publish.delete",{name:_.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>B(_),children:e.jsx(Ao,{sx:{fontSize:18}})})})]})}}}].filter(Boolean),q=y?e.jsx(zs,{open:!0,popup:!0,onClose:C,action:"check-has-project-id",locale:l,checkFn:n.get,saveConnect:!1,forceConnected:!1,checkTimeout:5*60*1e3,onSuccess:W,onError:H,extraParams:{projectId:m.id,did:h.meta.did,name:m.blockletTitle},messages:{title:i("blocklet.publish.deleteProject.title",{name:m.blockletTitle}),scan:i("blocklet.publish.deleteProject.scan",{name:m.blockletTitle}),confirm:i("blocklet.publish.deleteProject.confirm"),success:i("blocklet.publish.deleteProject.success")}}):null;return e.jsxs(c,{children:[e.jsx(wt,{sx:{mb:2},left:e.jsxs(c,{display:"flex",flexDirection:"row",alignItems:"center",children:[e.jsx(c,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:i("common.blockletStudio")}),e.jsx(me,{title:i("blocklet.publish.createBlockletTip"),arrow:!0,placement:"right",children:e.jsx(Uo,{sx:{opacity:.6,fontSize:"1.1em",ml:1}})})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(Bs,{options:{searchPlaceholder:i("blocklet.list.searchPlaceholder"),searchDebounceTime:600,searchAlwaysOpen:R},search:k,searchText:k,searchTextUpdate:T,searchClose:()=>T(""),onSearchOpen:()=>{}}),e.jsxs(Me,{onClick:z,variant:"contained",children:[e.jsx(Rt,{style:{fontSize:"1.3em",marginRight:4}}),i("blocklet.publish.createBlocklet")]})]})}),e.jsx(kt,{className:"main-table",locale:l,data:b,columns:w,options:{search:!1,sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,searchAlwaysOpen:!0,rowsPerPageOptions:[10,20,50,100]}}),m&&e.jsx(vt,{title:`${i("common.delete")} ${m.blockletTitle}`,description:i("blocklet.publish.deleteProject.description"),confirm:i("common.confirm"),onConfirm:v,onCancel:()=>S(null),children:e.jsx(c,{sx:{marginTop:2},children:[i("blocklet.publish.deleteProject.tip1"),i("blocklet.publish.deleteProject.tip2"),i("blocklet.publish.deleteProject.tip3")].map(g=>e.jsxs(c,{sx:{display:"flex",marginTop:1,flexDirection:"row",alignItems:"flex-start"},children:[e.jsx(Hs,{color:"warning",sx:{marginRight:1,fontSize:20,marginTop:"2px"}}),e.jsx(N,{component:"span",variant:"inherit",color:"text.secondary",children:g})]}))})}),q]})}$t.propTypes={initUrl:r.object};$t.defaultProps={initUrl:null};var Lt={},vn=ke;Object.defineProperty(Lt,"__esModule",{value:!0});var Fo=Lt.default=void 0,Cn=vn(Re()),fo=e;Fo=Lt.default=(0,Cn.default)([(0,fo.jsx)("path",{d:"M20 17H4V5h8V3H4c-1.11 0-2 .89-2 2v12c0 1.1.89 2 2 2h4v2h8v-2h4c1.1 0 2-.9 2-2v-3h-2z"},"0"),(0,fo.jsx)("path",{d:"m17 14 5-5-1.41-1.41L18 10.17V3h-2v7.17l-2.59-2.58L12 9z"},"1")],"InstallDesktop");const wn=(t,o)=>{if(!t)return"";try{return o?JSON.parse(t)[o]:JSON.parse(t)}catch{}return t},Ho=wn;function Sn(){var B;const{t,locale:o}=te(),{projectId:s}=tt(),{api:i}=ye(),[l,d]=x.useState(!0),{blocklet:n}=ze(),u=Le(v=>v.breakpoints.down("md")),[a,h]=x.useState(null),[m,S]=x.useState(null),[y,p]=x.useState(null),f=(B=window.env)==null?void 0:B.serverEndpoint,R=()=>{i.getReleases({input:{did:n.meta.did,projectId:s}}).then(v=>{const C=(v==null?void 0:v.releases)||[];d(!1),h(C)}).catch(v=>{d(!1),M.error(v.message)})},I=()=>{i.doBatchQuery({getProject:{input:{did:n.meta.did,projectId:s}},getReleases:{input:{did:n.meta.did,projectId:s}}}).then(v=>{S(v.getProject.project||{}),h(v.getReleases.releases||[]),d(!1)}).catch(v=>{d(!1),M.error(v.message)})};x.useEffect(()=>{I()},[]);const[j,D]=x.useState(""),k=()=>{d(!1);const v=y.id;i.deleteRelease({input:{did:n.meta.did,projectId:s,releaseId:v}}).then(()=>{d(!1),R(),M.success(t("common.removeSuccess")),p(null)}).catch(C=>{d(!1),M.error(C.message)})},T=v=>{p(v)};if(!a&&l)return e.jsx(c,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Fe,{})});if(!a)return null;const L=e.jsxs(Co,{className:"breadcrumbs","aria-label":"breadcrumb",children:[e.jsx(xe,{to:"..",children:t("common.blockletStudio")}),e.jsx(N,{color:"text.primary",children:e.jsx(je,{maxLength:u?6:30,children:m.blockletTitle})})]});if(!a.length)return e.jsxs(e.Fragment,{children:[L,e.jsxs(c,{display:"flex",flexDirection:"column",alignItems:"center",pt:10,children:[e.jsx(c,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:t("blocklet.publish.releaseEmptyTip")}),e.jsx(c,{sx:{fontSize:14,color:"text.secondary",mb:3},children:t("blocklet.publish.createReleaseTip")}),e.jsx(xe,{to:"create/none",children:e.jsx(Me,{variant:"contained",children:t("blocklet.publish.createRelease")})})]})]});const z=[{label:t("common.version"),name:"blockletVersion",minWidth:160,options:{customBodyRenderLite:v=>{const C=a[v];return e.jsx(xe,{to:`view/${C.id}`,children:e.jsx(qt,{did:n.meta.did,projectId:m.id,logo:C.blockletLogo,title:C.blockletVersion,describe:C.blockletTitle})})}}},{label:t("blocklet.publish.releaseNote"),name:"note",options:{customBodyRenderLite:v=>{const C=a[v];return e.jsx(N,{className:"note",children:Ho(C.note,"note")})}}},{label:t("common.status"),name:"status",options:{customBodyRender:v=>e.jsx(Lo,{type:v==="published"?"success":"warning",children:v==="published"?"Released":Gs(v)})}},{label:t("common.lastPublishedAt"),name:"updatedAt",options:{customBodyRenderLite:v=>{const C=a[v];return C.status!==ue.PROJECT.RELEASE_STATUS.published?"":e.jsx(No,{value:Number(C.updatedAt),locale:o})}}},{label:t("common.actions"),name:"actions",options:{customBodyRenderLite:v=>{var q;const C=a[v];let H="",W="";const b=C.status==="published";if(b){const g=be(f,`/api/project/${n.meta.did}/${m.id}/${m.lastReleaseId}/release/blocklet.json`),_=new URL(f);_.pathname=be(_.pathname,"/launch-blocklet/agreement"),_.searchParams.set("blocklet_meta_url",g),H=_.href,W=be(`${G.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${n.meta.did}/${m.id}/${m.lastReleaseId}/download/${(m.lastReleaseFiles||[])[0]}`)}const w=(q=m.blockletComponents)!=null&&q.some(g=>g.included)||C.uploadedResource?"pack":"resource";return e.jsxs(c,{display:"flex",alignItems:"center",children:[b&&w==="pack"&&e.jsx(me,{title:t("blocklet.publish.install",{name:m.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx("a",{style:{display:"flex"},href:H,target:"_blank",rel:"noreferrer",children:e.jsx(Fo,{sx:{fontSize:18}})})})}),b&&e.jsx(me,{title:t("blocklet.publish.download",{name:m.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"download",children:e.jsx("a",{style:{display:"flex"},href:W,children:e.jsx(Js,{sx:{fontSize:18}})})})}),e.jsx(me,{title:t("blocklet.publish.delete",{name:m.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>T(C),children:e.jsx(Ao,{sx:{fontSize:18}})})})]})}}}];return e.jsxs(In,{children:[e.jsx(wt,{sx:{mb:2},left:L,actions:e.jsxs(e.Fragment,{children:[e.jsx(Me,{variant:"outlined",onClick:()=>{const v=be(f,`/api/project/${n.meta.did}/${s}/blocklet.json`);D(v)},children:t("blocklet.publish.copyInstallUrl")}),e.jsx(xe,{to:"new-release/none",children:e.jsxs(Me,{variant:"contained",children:[e.jsx(Rt,{style:{fontSize:"1.3em",marginRight:4}}),t("blocklet.publish.createRelease")]})})]})}),e.jsx(ot,{fullWidth:!0,maxWidth:"sm",open:j,onClose:()=>D(""),children:e.jsxs(c,{sx:{py:5,px:4,wordBreak:"break-all"},children:[e.jsx(N,{variant:"h6",sx:{mb:2},children:t("blocklet.publish.installResourceTip")}),e.jsx(Eo,{children:j}),e.jsxs(N,{sx:{mt:2},children:[t("blocklet.publish.installResourceTip2"),e.jsx("a",{style:{marginLeft:4},href:"https://www.arcblock.io/docs/blocklet-developer/how-to-use-install-url",target:"_blank",rel:"noreferrer",children:t("blocklet.publish.installResourceHelp")})]})]})}),e.jsx(kt,{className:"main-table",verticalKeyWidth:100,locale:o,data:a,columns:z,options:{sort:!1,download:!1,filter:!1,print:!1,search:!1}}),y&&e.jsx(vt,{title:t(`${t("common.delete")} ${y.blockletVersion}`),description:t("blocklet.publish.deleteReleaseTip"),confirm:t("common.confirm"),onConfirm:k,onCancel:()=>p(null)})]})}const In=ge(c)`
|
|
3
3
|
.main-table > div:first-child {
|
|
4
4
|
display: none;
|
|
5
5
|
}
|
|
@@ -121,7 +121,7 @@ import{r as x,k as gt,l as tt,L as xe,u as js,h as ks,i as ct}from"./vendor-reac
|
|
|
121
121
|
background: #fff;
|
|
122
122
|
z-index: 10;
|
|
123
123
|
}
|
|
124
|
-
`;var Mt={},En=ke;Object.defineProperty(Mt,"__esModule",{value:!0});var bt=Mt.default=void 0,Wn=En(Re()),On=e;bt=Mt.default=(0,Wn.default)((0,On.jsx)("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"DragIndicator");const xo="lastWantToConnectStoreId";function Mn(t){var u,a;const[o,s]=x.useState(null),{session:i}=Ue(),l=x.useCallback(h=>{s(h),localStorage.setItem(xo,h==null?void 0:h.id)},[s]),d=x.useMemo(()=>{var y,p,f,R;const h=localStorage.getItem(xo),m=h?(((y=t==null?void 0:t.settings)==null?void 0:y.storeList)||[]).find(I=>I.id===h):null;if(m)return m;let S=(((p=t==null?void 0:t.settings)==null?void 0:p.storeList)||[]).find(I=>{var j;return!(I.id!==G.BLOCKLET_STORE.id||I.scope&&I.scope!=="studio"&&I.scope!==((j=i==null?void 0:i.user)==null?void 0:j.did))});return S||(S=(R=(f=t==null?void 0:t.settings)==null?void 0:f.storeList)==null?void 0:R[0]),S},[(u=t==null?void 0:t.settings)==null?void 0:u.storeList,(a=i==null?void 0:i.user)==null?void 0:a.did]);return[o||d||{},l]}const pt={};async function Qo(t,{interval:o=1e3,maxDuration:s=120*1e3,intervalFirst:i=4e3,timerKey:l=""}){pt[l]&&clearTimeout(pt[l]),await new Promise(u=>setTimeout(u,i));const d=Date.now(),n=async(u,a)=>{try{const h=await t();u(h)}catch(h){Date.now()-d>s?a(h):l?pt[l]=setTimeout(()=>n(u,a),o):setTimeout(()=>n(u,a),o)}};return new Promise(n)}function Vn(){return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)+`${Date.now()}`.slice(-6)}function Un(t,{did:o,projectId:s,messageId:i}){return Qo(async()=>{var d;const l=await t.getProject({input:{did:o,projectId:s,messageId:i}});if(!((d=l==null?void 0:l.project)!=null&&d.blockletDid))throw new Error("Connected store not found");return l.project.blockletDid},{timerKey:"connect-studio"})}function Fn(t,{did:o,projectId:s,storeId:i}){return Qo(async()=>{var n,u;const l=await t.getProject({input:{did:o,projectId:s,messageId:""}});if(!((u=(n=l==null?void 0:l.project)==null?void 0:n.connectedStores)!=null&&u.length))throw new Error("Connected store not found");if(!l.project.connectedStores.find(a=>a.storeId===i))throw new Error("Connected store not found")},{timerKey:`connect-store-${i}`})}const Hn=({fromBlocklet:t,nodeInfo:o,blocklet:s,userDid:i})=>{var n,u;const l=t?(n=s==null?void 0:s.meta)==null?void 0:n.did:o==null?void 0:o.did;let d=t?((u=s==null?void 0:s.settings)==null?void 0:u.storeList)||[]:(o==null?void 0:o.blockletRegistryList)||[];return Array.isArray(d)||(d=[]),d=d.filter(a=>a.protected||!a.scope||a.scope==="studio"||a.scope===i),{teamDid:l,storeList:d}},Vt=Hn;function Ut({blocklet:t,store:o={},onChangeStore:s,onClick:i,disabled:l,loading:d,componentDid:n}){var b,w,q;const{t:u}=te(),{session:a}=Ue(),{api:h,info:m,inService:S}=ye(),y=ze(),[p,f]=x.useState(!1),R=x.useRef(null),[I,j]=x.useState(!1),[D,k]=x.useState(null),T=g=>{s(g),f(!1)},L=()=>{f(!p)},z=g=>{R.current&&R.current.contains(g.target)||f(!1)},B=()=>{j(!0)},v=()=>{j(!1)},C=async()=>{var g;if(D)try{await h.deleteBlockletStore({input:{teamDid:t.meta.did,url:D.url,projectId:"",scope:D.scope||"studio"}}),await((g=y==null?void 0:y.actions)==null?void 0:g.refreshBlocklet())}catch(_){M.error(`Remove Blocklet Store Error: ${Ne(_)}`)}finally{k(null)}},{storeList:H}=Vt({fromBlocklet:S,blocklet:t,nodeInfo:m,componentDid:n,userDid:(b=a==null?void 0:a.user)==null?void 0:b.did}),W=(w=t==null?void 0:t.meta)==null?void 0:w.did;return e.jsxs(e.Fragment,{children:[e.jsxs(ht,{disabled:l,ref:R,variant:"contained",color:"primary","aria-label":"Button group with connect store",children:[e.jsxs(se,{onClick:i,children:[d&&e.jsx(Ye,{size:14,sx:{mr:.5}}),`${u("common.connect")} ${o.name||""}`]}),e.jsx(se,{size:"small","aria-controls":p?"split-button-menu":void 0,"aria-expanded":p?"true":void 0,"aria-label":"select merge strategy","aria-haspopup":"menu",onClick:L,children:e.jsx(an,{})})]}),e.jsx(So,{sx:{zIndex:10},open:p,anchorEl:R.current,placement:"bottom-end",role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:g})=>e.jsx(Io,{...g,style:{transformOrigin:"center top"},children:e.jsx(jt,{children:e.jsx(Do,{onClickAway:z,children:e.jsxs(To,{id:"split-button-menu",autoFocusItem:!0,sx:{maxHeight:300,overflowY:"auto",zIndex:10},children:[H==null?void 0:H.map(_=>{var J;return e.jsxs(fe,{selected:_.id===(o==null?void 0:o.id),sx:{height:56},onClick:()=>T(_),children:[e.jsxs(c,{children:[e.jsx(je,{sx:{fontSize:"16px"},maxLength:24,children:_.name}),e.jsx(je,{sx:{fontSize:"13px",opacity:.6},maxLength:30,children:_.url})]}),en({store:_,userDid:(J=a==null?void 0:a.user)==null?void 0:J.did})&&e.jsx(ce,{sx:{ml:1},onClick:U=>{U.preventDefault(),U.stopPropagation(),k(_)},children:e.jsx(ae,{icon:"ic:outline-delete"})})]},_.url)}),e.jsx(Rs,{}),e.jsxs(fe,{onClick:B,children:[e.jsx(Rt,{font:!0}),e.jsx(N,{variant:"inherit",children:u("store.blockletRegistry.addRegistry")})]})]})})})})}),I&&e.jsx(Wo,{hiddenChildren:!0,open:!0,onClose:v,teamDid:W,storeList:H,scope:"studio",onAdd:(q=y==null?void 0:y.actions)==null?void 0:q.refreshBlocklet}),D&&e.jsx(vt,{displayError:!0,title:`${u("common.delete")} ${D.name}`,description:u("blocklet.publish.deleteStoreTip",{name:D.name}),confirm:u("common.confirm"),onConfirm:C,onCancel:()=>k(null)})]})}Ut.propTypes={store:r.object,blocklet:r.object,onChangeStore:r.func.isRequired,onClick:r.func.isRequired,loading:r.bool.isRequired,disabled:r.bool.isRequired,componentDid:r.string.isRequired,projectType:r.string.isRequired,getData:r.func.isRequired};Ut.defaultProps={store:null,blocklet:null};const Gn=(t,o,s)=>{const i=`${G.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/logo/upload`,l=`${G.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/screenshot/upload`,d=t!=null&&t.blockletLogo?`${i}/${t.blockletLogo}`:`${G.WELLKNOWN_SERVICE_PATH_PREFIX}/static/images/logo.png`,n=((t==null?void 0:t.blockletScreenshots)||[]).filter(Boolean).map(u=>`${l}/${u}`);return{logoUrl:d,screenshotUrls:n,uploadLogoPrefix:i,uploadScreenshotPrefix:l}},Zo=Gn,Jn=t=>{const o=t.includes("youtube.com")||t.includes("youtu.be"),s=t.includes("vimeo.com");return o||s};function st({url:t,style:o,controls:s,modestbranding:i}){var u;const{t:l}=te(),d=t.includes("youtube.com")||t.includes("youtu.be"),n=t.includes("vimeo.com");if(d){const a=((u=t.split("v=")[1])==null?void 0:u.split("&")[0])||t.split("/").pop();return e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",pointerEvents:(o==null?void 0:o.pointerEvents)||"auto"},children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${a}?modestbranding=${i}&controls=${s}&rel=0`,title:"YouTube video player",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",...o},allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}if(n){const a=t.split("/").pop();return e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",pointerEvents:o.pointerEvents||"auto"},children:e.jsx("iframe",{src:`https://player.vimeo.com/video/${a}`,title:"Vimeo video player",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",...o},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})})}return e.jsx(c,{style:{position:"relative",width:"100%",paddingTop:"56.25%"},children:e.jsxs(c,{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",backgroundColor:"rgba(0, 0, 0, 0.04)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",...o},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,children:[e.jsx(ae,{icon:"carbon:video-off",style:{fontSize:40,marginBottom:"10px",opacity:.5}}),e.jsx(N,{variant:"body1",sx:{opacity:.5},children:l("studio.videoDialogNoSrc")})]})})}st.propTypes={url:r.string.isRequired,style:r.object,controls:r.number,modestbranding:r.number};st.defaultProps={style:{},controls:1,modestbranding:1};function Ko({setParams:t,onClose:o,params:s}){const{t:i}=te(),[l,d]=x.useState(""),n=l&&s.blockletVideos.includes(l),u=Jn(l),a=()=>{t(h=>{const m=[...h.blockletVideos];return m.push(l),{...h,blockletVideos:m}}),o()};return e.jsxs(ot,{open:!0,fullWidth:!0,maxWidth:"sm",children:[e.jsx(_o,{children:i("studio.videoDialogTitle")}),e.jsxs(Po,{children:[e.jsx(vs,{fullWidth:!0,value:l,onChange:h=>d(h.target.value),placeholder:i("studio.videoInputLabel"),endAdornment:l?e.jsx(Ve,{position:"end",children:e.jsx(ce,{onClick:()=>d(""),children:e.jsx(Os,{})})}):null,error:n}),n&&e.jsx(N,{variant:"body2",color:"error",children:i("studio.duplicateVideo")}),e.jsx(st,{url:l,style:{marginTop:"20px",borderRadius:"4px"}})]}),e.jsxs(qo,{children:[e.jsx(se,{onClick:()=>o(),children:i("studio.cancel")}),e.jsx(se,{disabled:!u||n,onClick:a,children:i("studio.confirm")})]})]})}Ko.propTypes={onClose:r.func.isRequired,params:r.object.isRequired,setParams:r.func.isRequired};function xt({errors:t,storeList:o,...s}){const{t:i}=te();return e.jsxs(c,{...s,color:"warning.main",fontSize:"14px",sx:{border:"1px solid rgba(214, 164, 64, 0.34)",borderRadius:"4px",py:2,px:1.5,position:"relative"},children:[e.jsx(N,{variant:"caption",sx:{fontWeight:"bold",position:"absolute",top:-10,left:12,backgroundColor:"white",px:1,width:"fit-content"},children:i("blocklet.publish.storeRule.warning")}),t&&Object.entries(t).map(([l,d])=>{const n=Object.values(d),u=o.find(a=>a.url===l);return n.length>0&&e.jsxs(c,{children:[e.jsx(me,{title:l,children:e.jsx(c,{component:"span",sx:{cursor:"pointer"},children:u.name})}),n.map(a=>e.jsx(c,{component:"li",ml:2,breakWords:!0,children:a},a))]},l)})]})}xt.propTypes={errors:r.object.isRequired,storeList:r.array.isRequired};const mo=x.lazy(()=>zo(()=>import("./index-BAphTUTz.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(t=>({default:t.Uploader})));function es({projectId:t,readOnly:o,loading:s,blocklet:i,params:l,setParams:d,paramsErrTip:n,setParamsErrTip:u,warning:a,setLoading:h,initUrl:m,initLogoUrl:S,setInitLogoUrl:y,componentDid:p}){const{t:f,locale:R}=te(),{api:I}=ye(),j=gt(),D=x.useRef(null),k=x.useRef(null),[T,L]=Mn(i),[z,B]=x.useState(!1),v=tn({messageType:"connect-store-message",onOpen:()=>h(!0),onClose:()=>h(!1)}),C=async $=>{const V=setTimeout(()=>{h(!1)},2e4),F=await Un(I,$);h(!1),clearTimeout(V),window.parent.postMessage({event:"studioDialog.connected",componentDid:p},"*"),j(window.location.pathname.replace(`${G.UNOWNED_DID}/create`,`${F}/create`),{replace:!0})},H=()=>{if(!l.blockletTitle){M.error(f("blocklet.publish.errorTip.noTitle"));return}if(!(T!=null&&T.url)){M.error(f("blocklet.publish.noStoreSelected"));return}const $=Vn();v(async(V,F)=>{var Q,X,ie;try{const Y=await I.connectByStudio({input:{did:(Q=i==null?void 0:i.meta)==null?void 0:Q.did,blockletTitle:l==null?void 0:l.blockletTitle,storeUrl:T.url,storeId:T.id,storeName:T.name,type:((X=l==null?void 0:l.blockletComponents)==null?void 0:X.length)>0?"pack":"resource",componentDid:p,messageId:$,tenantScope:(m==null?void 0:m.searchParams.get("tenantScope"))||""}});if(!(Y!=null&&Y.url)){M.error("failed to connect to store");return}F(Y.url),C({did:(ie=i==null?void 0:i.meta)==null?void 0:ie.did,projectId:"",messageId:$})}catch(Y){const de=Ne(Y);M.error(de),h(!1)}})},{logoUrl:W,screenshotUrls:b,uploadLogoPrefix:w,uploadScreenshotPrefix:q}=Zo(l,i,t),{logoErrors:g,screenshotErrors:_,storeList:J,hasLogoWarning:U,hasScreenshotWarning:re}=a,K=()=>o?!1:!t||t===G.UNOWNED_DID?(M.error(f("blocklet.publish.errorTip.noFirstDid")),!1):!0,ee=$=>{if(!$.destination)return;const V=Array.from(l.blockletScreenshots),[F]=V.splice($.source.index,1);V.splice($.destination.index,0,F),d(Q=>({...Q,blockletScreenshots:V}))},Be=$=>{if(!$.destination)return;const V=Array.from(l.blockletVideos),[F]=V.splice($.source.index,1);V.splice($.destination.index,0,F),d(Q=>({...Q,blockletVideos:V}))};return e.jsxs(Xn,{children:[e.jsx(c,{display:"flex",className:"section",children:e.jsxs(c,{sx:{flex:1},children:[e.jsx(oe,{disabled:s||o,label:`Blocklet ${f("common.title")}`,placeholder:`Blocklet ${f("common.title")}`,InputProps:{"data-cy":"blocklet-title",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,required:!0,value:l.blockletTitle||"",onChange:$=>{u({blockletTitle:""}),d({blockletTitle:$.target.value})},error:!!n.blockletTitle,helperText:n.blockletTitle||""}),e.jsx(oe,{required:!0,label:"Blocklet DID",fullWidth:!0,readonly:!0,disabled:!0,autoComplete:"off",variant:"outlined",InputProps:{"data-cy":"export-blocklet-did",endAdornment:t===G.UNOWNED_DID&&e.jsx(Ve,{position:"end",children:e.jsx(Ut,{blocklet:i,store:T,componentDid:p,onChangeStore:L,disabled:!l.blockletTitle||o||s,loading:s,onClick:H})})},error:!!n.projectId,helperText:n.projectId||"",value:t===G.UNOWNED_DID?"":`did:abt:${t}`,sx:{mt:3}}),e.jsx(oe,{disabled:s||o,label:`Blocklet ${f("common.description")}`,placeholder:`Blocklet ${f("common.description")}`,InputProps:{"data-cy":"blocklet-description",readOnly:o},required:!0,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletDescription||"",onChange:$=>{u({blockletDescription:""}),d({blockletDescription:$.target.value})},error:!!n.blockletDescription,helperText:n.blockletDescription||"",sx:{mt:3}}),e.jsx(oe,{disabled:s||o,label:`Blocklet ${f("common.homepageTip")}`,placeholder:`Blocklet ${f("common.homepageTip")}`,InputProps:{"data-cy":"blocklet-homepage",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletHomepage||"",onChange:$=>{$.target.value&&!/^(http|https):\/\//.test($.target.value)?u({blockletHomepage:f("blocklet.publish.errorTip.invalidUrl")}):u({blockletHomepage:""}),d({blockletHomepage:$.target.value})},error:!!n.blockletHomepage,helperText:n.blockletHomepage||"",sx:{mt:3}}),e.jsx(oe,{disabled:s||o,label:`Blocklet ${f("common.community")}`,placeholder:`Blocklet ${f("common.community")}`,InputProps:{"data-cy":"blocklet-community",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletCommunity||"",onChange:$=>{$.target.value&&!/^(http|https):\/\//.test($.target.value)?u({blockletCommunity:f("blocklet.publish.errorTip.invalidUrl")}):u({blockletCommunity:""}),d({blockletCommunity:$.target.value})},error:!!n.blockletCommunity,helperText:n.blockletCommunity||"",sx:{mt:3}}),e.jsx(oe,{disabled:s||o,label:`Blocklet ${f("common.support")}`,placeholder:`Blocklet ${f("common.support")}`,InputProps:{"data-cy":"blocklet-support",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletSupport||"",onChange:$=>{$.target.value&&!/^(http|https):\/\//.test($.target.value)&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test($.target.value)?u({blockletSupport:f("blocklet.publish.errorTip.invalidUrlOrEmail")}):u({blockletSupport:""}),d({blockletSupport:$.target.value})},error:!!n.blockletSupport,helperText:n.blockletSupport||"",sx:{mt:3}}),e.jsx(oe,{disabled:s||o,label:`Blocklet ${f("common.repository")}`,placeholder:`Blocklet ${f("common.repository")}`,InputProps:{"data-cy":"blocklet-repository",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletRepository||"",onChange:$=>{$.target.value&&!/^(git|https|svn)/.test($.target.value)?u({blockletRepository:f("blocklet.publish.errorTip.invalidUrl")}):u({blockletRepository:""}),d({blockletRepository:$.target.value})},error:!!n.blockletRepository,helperText:n.blockletRepository||"",sx:{mt:3}})]})}),e.jsx(c,{display:"flex",mt:3,className:"section full-width",children:e.jsxs(c,{flex:1,overflow:"hidden",children:[e.jsxs(c,{display:"flex",flexDirection:"row",flexWrap:"wrap",children:[e.jsxs(Se,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(N,{variant:"subtitle1",sx:{fontWeight:"bold"},children:f("common.logo")}),e.jsxs(Se,{direction:"column",alignItems:"flex-start",spacing:1,sx:{opacity:.8,fontSize:"12px"},children:[e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.type"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"png, jpg, webp, svg"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.ratio"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"256x256"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.size"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"<500Kb"})]})})]})]}),e.jsx(c,{sx:{flex:1,cursor:o?"default":"pointer",display:"flex",alignItems:"flex-end"},children:e.jsx(vo,{variant:"square",sx:{width:80,height:80},alt:"Blocklet Logo",src:S||W,onClick:()=>{var $;K()&&(($=D.current)==null||$.open())}})})]}),U&&e.jsx(xt,{errors:g,storeList:J,mt:3}),e.jsxs(c,{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap",children:[e.jsxs(Se,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(N,{variant:"subtitle1",sx:{fontWeight:"bold"},children:f("common.screenshot")}),e.jsxs(Se,{direction:"column",alignItems:"flex-start",spacing:1,sx:{opacity:.8,fontSize:"12px"},children:[e.jsx(c,{sx:{border:"none"},variant:"outlined",size:"small",children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.ratio"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"16 / 9"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.count"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"1~5"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.size"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"<5MB"})]})}),!o&&e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.order"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:f("studio.orderTip")})]})})]})]}),e.jsx(ao,{onDragEnd:o?void 0:ee,children:e.jsx(uo,{droppableId:"screenshots",direction:"horizontal",isDropDisabled:o,children:($,V)=>e.jsxs(c,{display:"flex",alignItems:"center",sx:{flex:1,flexWrap:"wrap",minHeight:160,background:V.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:V.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},ref:$.innerRef,...$.droppableProps,children:[b.map((F,Q)=>e.jsx(po,{draggableId:F,index:Q,isDragDisabled:o,children:(X,ie)=>e.jsxs(c,{ref:X.innerRef,...X.draggableProps,className:"screenshot",sx:{transform:ie.isDragging?"scale(1.05)":"none",boxShadow:ie.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx("img",{alt:"screenshot",src:F}),!o&&e.jsx(ce,{...X.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(bt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{d(Y=>{const de=[...Y.blockletScreenshots];return de.splice(Q,1),{...Y,blockletScreenshots:de}})},children:e.jsx(co,{})})]})},F)),$.placeholder,b.length<5&&e.jsx(c,{sx:{width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,onClick:()=>{var F;K()&&((F=k.current)==null||F.open())},children:"+"})]})})})]}),re&&e.jsx(xt,{errors:_,storeList:J}),e.jsxs(c,{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap",children:[e.jsxs(Se,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(N,{variant:"subtitle1",sx:{fontWeight:"bold"},children:f("studio.video")}),e.jsxs(Se,{direction:"column",alignItems:"flex-start",spacing:1,sx:{opacity:.8,fontSize:"12px"},children:[e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.videoType"),":"," "]}),e.jsxs(c,{component:"span",sx:{color:"#007ec6"},children:[e.jsx("a",{href:"https://www.youtube.com/",target:"_blank",rel:"noreferrer",children:"Youtube"}),","," ",e.jsx("a",{href:"https://vimeo.com/",target:"_blank",rel:"noreferrer",children:"Vimeo"})]})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.count"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"1~3"})]})}),!o&&e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.order"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:f("studio.orderTip")})]})})]})]}),e.jsx(ao,{onDragEnd:o?void 0:Be,children:e.jsx(uo,{droppableId:"videos",direction:"horizontal",isDropDisabled:o,children:($,V)=>e.jsxs(c,{display:"flex",alignItems:"center",sx:{flex:1,flexWrap:"wrap",minHeight:160,background:V.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:V.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},ref:$.innerRef,...$.droppableProps,children:[l.blockletVideos.map((F,Q)=>e.jsx(po,{draggableId:F,index:Q,isDragDisabled:o,children:(X,ie)=>e.jsxs(c,{ref:X.innerRef,...X.draggableProps,className:"screenshot",sx:{transform:ie.isDragging?"scale(1.05)":"none",boxShadow:ie.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx(st,{url:F,style:{pointerEvents:ie.isDragging?"none":"auto"}}),!o&&e.jsx(ce,{...X.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(bt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{d(Y=>{const de=[...Y.blockletVideos];return de.splice(Q,1),{...Y,blockletVideos:de}})},children:e.jsx(co,{})})]})},F)),$.placeholder,l.blockletVideos.length<3&&e.jsx(c,{sx:{width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,onClick:()=>{K()&&B(!0)},children:"+"})]})})})]})]})}),e.jsxs(x.Suspense,{fallback:e.jsx(Fe,{}),children:[e.jsx(mo,{ref:D,locale:R,popup:!0,onUploadFinish:$=>{var V;d({blockletLogo:$.data.filename}),y(""),(V=D.current)==null||V.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:w,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/png","image/jpeg","image/webp","application/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"),z&&e.jsx(Ko,{onClose:()=>B(!1),params:l,setParams:d}),e.jsx(mo,{ref:k,popup:!0,onUploadFinish:$=>{var V;d(F=>{var X;const Q=F.blockletScreenshots||[];return Q.push((X=$.data)==null?void 0:X.filename),{...F,blockletScreenshots:Q}}),(V=k.current)==null||V.close()},installerProps:{disabled:!0},plugins:["ImageEditor"],apiPathProps:{uploader:q,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/*","application/svg+xml"],maxFileSize:1024*1024*5,maxNumberOfFiles:5-b.length}},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,autoCropArea:1,aspectRatio:16/9,initialAspectRatio:16/9,croppedCanvasOptions:{minWidth:1280,minHeight:720,maxWidth:1280*2,maxHeight:720*2}}}},"uploader-screenshot")]})]})}es.propTypes={projectId:r.string.isRequired,readOnly:r.bool.isRequired,params:r.object.isRequired,setParams:r.func.isRequired,paramsErrTip:r.object.isRequired,setParamsErrTip:r.func.isRequired,warning:r.object.isRequired,loading:r.bool.isRequired,blocklet:r.object.isRequired,setLoading:r.func.isRequired,initUrl:r.object.isRequired,componentDid:r.isRequired,initLogoUrl:r.string.isRequired,setInitLogoUrl:r.func.isRequired};const Xn=ge.div`
|
|
124
|
+
`;var Mt={},En=ke;Object.defineProperty(Mt,"__esModule",{value:!0});var bt=Mt.default=void 0,Wn=En(Re()),On=e;bt=Mt.default=(0,Wn.default)((0,On.jsx)("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"DragIndicator");const xo="lastWantToConnectStoreId";function Mn(t){var u,a;const[o,s]=x.useState(null),{session:i}=Ue(),l=x.useCallback(h=>{s(h),localStorage.setItem(xo,h==null?void 0:h.id)},[s]),d=x.useMemo(()=>{var y,p,f,R;const h=localStorage.getItem(xo),m=h?(((y=t==null?void 0:t.settings)==null?void 0:y.storeList)||[]).find(I=>I.id===h):null;if(m)return m;let S=(((p=t==null?void 0:t.settings)==null?void 0:p.storeList)||[]).find(I=>{var j;return!(I.id!==G.BLOCKLET_STORE.id||I.scope&&I.scope!=="studio"&&I.scope!==((j=i==null?void 0:i.user)==null?void 0:j.did))});return S||(S=(R=(f=t==null?void 0:t.settings)==null?void 0:f.storeList)==null?void 0:R[0]),S},[(u=t==null?void 0:t.settings)==null?void 0:u.storeList,(a=i==null?void 0:i.user)==null?void 0:a.did]);return[o||d||{},l]}const pt={};async function Qo(t,{interval:o=1e3,maxDuration:s=120*1e3,intervalFirst:i=4e3,timerKey:l=""}){pt[l]&&clearTimeout(pt[l]),await new Promise(u=>setTimeout(u,i));const d=Date.now(),n=async(u,a)=>{try{const h=await t();u(h)}catch(h){Date.now()-d>s?a(h):l?pt[l]=setTimeout(()=>n(u,a),o):setTimeout(()=>n(u,a),o)}};return new Promise(n)}function Vn(){return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)+`${Date.now()}`.slice(-6)}function Un(t,{did:o,projectId:s,messageId:i}){return Qo(async()=>{var d;const l=await t.getProject({input:{did:o,projectId:s,messageId:i}});if(!((d=l==null?void 0:l.project)!=null&&d.blockletDid))throw new Error("Connected store not found");return l.project.blockletDid},{timerKey:"connect-studio"})}function Fn(t,{did:o,projectId:s,storeId:i}){return Qo(async()=>{var n,u;const l=await t.getProject({input:{did:o,projectId:s,messageId:""}});if(!((u=(n=l==null?void 0:l.project)==null?void 0:n.connectedStores)!=null&&u.length))throw new Error("Connected store not found");if(!l.project.connectedStores.find(a=>a.storeId===i))throw new Error("Connected store not found")},{timerKey:`connect-store-${i}`})}const Hn=({fromBlocklet:t,nodeInfo:o,blocklet:s,userDid:i})=>{var n,u;const l=t?(n=s==null?void 0:s.meta)==null?void 0:n.did:o==null?void 0:o.did;let d=t?((u=s==null?void 0:s.settings)==null?void 0:u.storeList)||[]:(o==null?void 0:o.blockletRegistryList)||[];return Array.isArray(d)||(d=[]),d=d.filter(a=>a.protected||!a.scope||a.scope==="studio"||a.scope===i),{teamDid:l,storeList:d}},Vt=Hn;function Ut({blocklet:t,store:o={},onChangeStore:s,onClick:i,disabled:l,loading:d,componentDid:n}){var b,w,q;const{t:u}=te(),{session:a}=Ue(),{api:h,info:m,inService:S}=ye(),y=ze(),[p,f]=x.useState(!1),R=x.useRef(null),[I,j]=x.useState(!1),[D,k]=x.useState(null),T=g=>{s(g),f(!1)},L=()=>{f(!p)},z=g=>{R.current&&R.current.contains(g.target)||f(!1)},B=()=>{j(!0)},v=()=>{j(!1)},C=async()=>{var g;if(D)try{await h.deleteBlockletStore({input:{teamDid:t.meta.did,url:D.url,projectId:"",scope:D.scope||"studio"}}),await((g=y==null?void 0:y.actions)==null?void 0:g.refreshBlocklet())}catch(_){M.error(`Remove Blocklet Store Error: ${Ne(_)}`)}finally{k(null)}},{storeList:H}=Vt({fromBlocklet:S,blocklet:t,nodeInfo:m,componentDid:n,userDid:(b=a==null?void 0:a.user)==null?void 0:b.did}),W=(w=t==null?void 0:t.meta)==null?void 0:w.did;return e.jsxs(e.Fragment,{children:[e.jsxs(ht,{disabled:l,ref:R,variant:"contained",color:"primary","aria-label":"Button group with connect store",children:[e.jsxs(se,{onClick:i,children:[d&&e.jsx(Ye,{size:14,sx:{mr:.5}}),`${u("common.connect")} ${o.name||""}`]}),e.jsx(se,{size:"small","aria-controls":p?"split-button-menu":void 0,"aria-expanded":p?"true":void 0,"aria-label":"select merge strategy","aria-haspopup":"menu",onClick:L,children:e.jsx(an,{})})]}),e.jsx(So,{sx:{zIndex:10},open:p,anchorEl:R.current,placement:"bottom-end",role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:g})=>e.jsx(Io,{...g,style:{transformOrigin:"center top"},children:e.jsx(jt,{children:e.jsx(Do,{onClickAway:z,children:e.jsxs(To,{id:"split-button-menu",autoFocusItem:!0,sx:{maxHeight:300,overflowY:"auto",zIndex:10},children:[H==null?void 0:H.map(_=>{var J;return e.jsxs(fe,{selected:_.id===(o==null?void 0:o.id),sx:{height:56},onClick:()=>T(_),children:[e.jsxs(c,{children:[e.jsx(je,{sx:{fontSize:"16px"},maxLength:24,children:_.name}),e.jsx(je,{sx:{fontSize:"13px",opacity:.6},maxLength:30,children:_.url})]}),en({store:_,userDid:(J=a==null?void 0:a.user)==null?void 0:J.did})&&e.jsx(ce,{sx:{ml:1},onClick:U=>{U.preventDefault(),U.stopPropagation(),k(_)},children:e.jsx(ae,{icon:"ic:outline-delete"})})]},_.url)}),e.jsx(Rs,{}),e.jsxs(fe,{onClick:B,children:[e.jsx(Rt,{font:!0}),e.jsx(N,{variant:"inherit",children:u("store.blockletRegistry.addRegistry")})]})]})})})})}),I&&e.jsx(Wo,{hiddenChildren:!0,open:!0,onClose:v,teamDid:W,storeList:H,scope:"studio",onAdd:(q=y==null?void 0:y.actions)==null?void 0:q.refreshBlocklet}),D&&e.jsx(vt,{displayError:!0,title:`${u("common.delete")} ${D.name}`,description:u("blocklet.publish.deleteStoreTip",{name:D.name}),confirm:u("common.confirm"),onConfirm:C,onCancel:()=>k(null)})]})}Ut.propTypes={store:r.object,blocklet:r.object,onChangeStore:r.func.isRequired,onClick:r.func.isRequired,loading:r.bool.isRequired,disabled:r.bool.isRequired,componentDid:r.string.isRequired,projectType:r.string.isRequired,getData:r.func.isRequired};Ut.defaultProps={store:null,blocklet:null};const Gn=(t,o,s)=>{const i=`${G.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/logo/upload`,l=`${G.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/screenshot/upload`,d=t!=null&&t.blockletLogo?`${i}/${t.blockletLogo}`:`${G.WELLKNOWN_SERVICE_PATH_PREFIX}/static/images/logo.png`,n=((t==null?void 0:t.blockletScreenshots)||[]).filter(Boolean).map(u=>`${l}/${u}`);return{logoUrl:d,screenshotUrls:n,uploadLogoPrefix:i,uploadScreenshotPrefix:l}},Zo=Gn,Jn=t=>{const o=t.includes("youtube.com")||t.includes("youtu.be"),s=t.includes("vimeo.com");return o||s};function st({url:t,style:o,controls:s,modestbranding:i}){var u;const{t:l}=te(),d=t.includes("youtube.com")||t.includes("youtu.be"),n=t.includes("vimeo.com");if(d){const a=((u=t.split("v=")[1])==null?void 0:u.split("&")[0])||t.split("/").pop();return e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",pointerEvents:(o==null?void 0:o.pointerEvents)||"auto"},children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${a}?modestbranding=${i}&controls=${s}&rel=0`,title:"YouTube video player",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",...o},allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}if(n){const a=t.split("/").pop();return e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",pointerEvents:o.pointerEvents||"auto"},children:e.jsx("iframe",{src:`https://player.vimeo.com/video/${a}`,title:"Vimeo video player",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",...o},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})})}return e.jsx(c,{style:{position:"relative",width:"100%",paddingTop:"56.25%"},children:e.jsxs(c,{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",backgroundColor:"rgba(0, 0, 0, 0.04)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",...o},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,children:[e.jsx(ae,{icon:"carbon:video-off",style:{fontSize:40,marginBottom:"10px",opacity:.5}}),e.jsx(N,{variant:"body1",sx:{opacity:.5},children:l("studio.videoDialogNoSrc")})]})})}st.propTypes={url:r.string.isRequired,style:r.object,controls:r.number,modestbranding:r.number};st.defaultProps={style:{},controls:1,modestbranding:1};function Ko({setParams:t,onClose:o,params:s}){const{t:i}=te(),[l,d]=x.useState(""),n=l&&s.blockletVideos.includes(l),u=Jn(l),a=()=>{t(h=>{const m=[...h.blockletVideos];return m.push(l),{...h,blockletVideos:m}}),o()};return e.jsxs(ot,{open:!0,fullWidth:!0,maxWidth:"sm",children:[e.jsx(_o,{children:i("studio.videoDialogTitle")}),e.jsxs(Po,{children:[e.jsx(vs,{fullWidth:!0,value:l,onChange:h=>d(h.target.value),placeholder:i("studio.videoInputLabel"),endAdornment:l?e.jsx(Ve,{position:"end",children:e.jsx(ce,{onClick:()=>d(""),children:e.jsx(Os,{})})}):null,error:n}),n&&e.jsx(N,{variant:"body2",color:"error",children:i("studio.duplicateVideo")}),e.jsx(st,{url:l,style:{marginTop:"20px",borderRadius:"4px"}})]}),e.jsxs(qo,{children:[e.jsx(se,{onClick:()=>o(),children:i("studio.cancel")}),e.jsx(se,{disabled:!u||n,onClick:a,children:i("studio.confirm")})]})]})}Ko.propTypes={onClose:r.func.isRequired,params:r.object.isRequired,setParams:r.func.isRequired};function xt({errors:t,storeList:o,...s}){const{t:i}=te();return e.jsxs(c,{...s,color:"warning.main",fontSize:"14px",sx:{border:"1px solid rgba(214, 164, 64, 0.34)",borderRadius:"4px",py:2,px:1.5,position:"relative"},children:[e.jsx(N,{variant:"caption",sx:{fontWeight:"bold",position:"absolute",top:-10,left:12,backgroundColor:"white",px:1,width:"fit-content"},children:i("blocklet.publish.storeRule.warning")}),t&&Object.entries(t).map(([l,d])=>{const n=Object.values(d),u=o.find(a=>a.url===l);return n.length>0&&e.jsxs(c,{children:[e.jsx(me,{title:l,children:e.jsx(c,{component:"span",sx:{cursor:"pointer"},children:u.name})}),n.map(a=>e.jsx(c,{component:"li",ml:2,breakWords:!0,children:a},a))]},l)})]})}xt.propTypes={errors:r.object.isRequired,storeList:r.array.isRequired};const mo=x.lazy(()=>zo(()=>import("./index-Dja0MgHa.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(t=>({default:t.Uploader})));function es({projectId:t,readOnly:o,loading:s,blocklet:i,params:l,setParams:d,paramsErrTip:n,setParamsErrTip:u,warning:a,setLoading:h,initUrl:m,initLogoUrl:S,setInitLogoUrl:y,componentDid:p}){const{t:f,locale:R}=te(),{api:I}=ye(),j=gt(),D=x.useRef(null),k=x.useRef(null),[T,L]=Mn(i),[z,B]=x.useState(!1),v=tn({messageType:"connect-store-message",onOpen:()=>h(!0),onClose:()=>h(!1)}),C=async $=>{const V=setTimeout(()=>{h(!1)},2e4),F=await Un(I,$);h(!1),clearTimeout(V),window.parent.postMessage({event:"studioDialog.connected",componentDid:p},"*"),j(window.location.pathname.replace(`${G.UNOWNED_DID}/create`,`${F}/create`),{replace:!0})},H=()=>{if(!l.blockletTitle){M.error(f("blocklet.publish.errorTip.noTitle"));return}if(!(T!=null&&T.url)){M.error(f("blocklet.publish.noStoreSelected"));return}const $=Vn();v(async(V,F)=>{var Q,X,ie;try{const Y=await I.connectByStudio({input:{did:(Q=i==null?void 0:i.meta)==null?void 0:Q.did,blockletTitle:l==null?void 0:l.blockletTitle,storeUrl:T.url,storeId:T.id,storeName:T.name,type:((X=l==null?void 0:l.blockletComponents)==null?void 0:X.length)>0?"pack":"resource",componentDid:p,messageId:$,tenantScope:(m==null?void 0:m.searchParams.get("tenantScope"))||""}});if(!(Y!=null&&Y.url)){M.error("failed to connect to store");return}F(Y.url),C({did:(ie=i==null?void 0:i.meta)==null?void 0:ie.did,projectId:"",messageId:$})}catch(Y){const de=Ne(Y);M.error(de),h(!1)}})},{logoUrl:W,screenshotUrls:b,uploadLogoPrefix:w,uploadScreenshotPrefix:q}=Zo(l,i,t),{logoErrors:g,screenshotErrors:_,storeList:J,hasLogoWarning:U,hasScreenshotWarning:re}=a,K=()=>o?!1:!t||t===G.UNOWNED_DID?(M.error(f("blocklet.publish.errorTip.noFirstDid")),!1):!0,ee=$=>{if(!$.destination)return;const V=Array.from(l.blockletScreenshots),[F]=V.splice($.source.index,1);V.splice($.destination.index,0,F),d(Q=>({...Q,blockletScreenshots:V}))},Be=$=>{if(!$.destination)return;const V=Array.from(l.blockletVideos),[F]=V.splice($.source.index,1);V.splice($.destination.index,0,F),d(Q=>({...Q,blockletVideos:V}))};return e.jsxs(Xn,{children:[e.jsx(c,{display:"flex",className:"section",children:e.jsxs(c,{sx:{flex:1},children:[e.jsx(oe,{disabled:s||o,label:`Blocklet ${f("common.title")}`,placeholder:`Blocklet ${f("common.title")}`,InputProps:{"data-cy":"blocklet-title",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,required:!0,value:l.blockletTitle||"",onChange:$=>{u({blockletTitle:""}),d({blockletTitle:$.target.value})},error:!!n.blockletTitle,helperText:n.blockletTitle||""}),e.jsx(oe,{required:!0,label:"Blocklet DID",fullWidth:!0,readonly:!0,disabled:!0,autoComplete:"off",variant:"outlined",InputProps:{"data-cy":"export-blocklet-did",endAdornment:t===G.UNOWNED_DID&&e.jsx(Ve,{position:"end",children:e.jsx(Ut,{blocklet:i,store:T,componentDid:p,onChangeStore:L,disabled:!l.blockletTitle||o||s,loading:s,onClick:H})})},error:!!n.projectId,helperText:n.projectId||"",value:t===G.UNOWNED_DID?"":`did:abt:${t}`,sx:{mt:3}}),e.jsx(oe,{disabled:s||o,label:`Blocklet ${f("common.description")}`,placeholder:`Blocklet ${f("common.description")}`,InputProps:{"data-cy":"blocklet-description",readOnly:o},required:!0,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletDescription||"",onChange:$=>{u({blockletDescription:""}),d({blockletDescription:$.target.value})},error:!!n.blockletDescription,helperText:n.blockletDescription||"",sx:{mt:3}}),e.jsx(oe,{disabled:s||o,label:`Blocklet ${f("common.homepageTip")}`,placeholder:`Blocklet ${f("common.homepageTip")}`,InputProps:{"data-cy":"blocklet-homepage",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletHomepage||"",onChange:$=>{$.target.value&&!/^(http|https):\/\//.test($.target.value)?u({blockletHomepage:f("blocklet.publish.errorTip.invalidUrl")}):u({blockletHomepage:""}),d({blockletHomepage:$.target.value})},error:!!n.blockletHomepage,helperText:n.blockletHomepage||"",sx:{mt:3}}),e.jsx(oe,{disabled:s||o,label:`Blocklet ${f("common.community")}`,placeholder:`Blocklet ${f("common.community")}`,InputProps:{"data-cy":"blocklet-community",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletCommunity||"",onChange:$=>{$.target.value&&!/^(http|https):\/\//.test($.target.value)?u({blockletCommunity:f("blocklet.publish.errorTip.invalidUrl")}):u({blockletCommunity:""}),d({blockletCommunity:$.target.value})},error:!!n.blockletCommunity,helperText:n.blockletCommunity||"",sx:{mt:3}}),e.jsx(oe,{disabled:s||o,label:`Blocklet ${f("common.support")}`,placeholder:`Blocklet ${f("common.support")}`,InputProps:{"data-cy":"blocklet-support",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletSupport||"",onChange:$=>{$.target.value&&!/^(http|https):\/\//.test($.target.value)&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test($.target.value)?u({blockletSupport:f("blocklet.publish.errorTip.invalidUrlOrEmail")}):u({blockletSupport:""}),d({blockletSupport:$.target.value})},error:!!n.blockletSupport,helperText:n.blockletSupport||"",sx:{mt:3}}),e.jsx(oe,{disabled:s||o,label:`Blocklet ${f("common.repository")}`,placeholder:`Blocklet ${f("common.repository")}`,InputProps:{"data-cy":"blocklet-repository",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletRepository||"",onChange:$=>{$.target.value&&!/^(git|https|svn)/.test($.target.value)?u({blockletRepository:f("blocklet.publish.errorTip.invalidUrl")}):u({blockletRepository:""}),d({blockletRepository:$.target.value})},error:!!n.blockletRepository,helperText:n.blockletRepository||"",sx:{mt:3}})]})}),e.jsx(c,{display:"flex",mt:3,className:"section full-width",children:e.jsxs(c,{flex:1,overflow:"hidden",children:[e.jsxs(c,{display:"flex",flexDirection:"row",flexWrap:"wrap",children:[e.jsxs(Se,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(N,{variant:"subtitle1",sx:{fontWeight:"bold"},children:f("common.logo")}),e.jsxs(Se,{direction:"column",alignItems:"flex-start",spacing:1,sx:{opacity:.8,fontSize:"12px"},children:[e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.type"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"png, jpg, webp, svg"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.ratio"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"256x256"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.size"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"<500Kb"})]})})]})]}),e.jsx(c,{sx:{flex:1,cursor:o?"default":"pointer",display:"flex",alignItems:"flex-end"},children:e.jsx(vo,{variant:"square",sx:{width:80,height:80},alt:"Blocklet Logo",src:S||W,onClick:()=>{var $;K()&&(($=D.current)==null||$.open())}})})]}),U&&e.jsx(xt,{errors:g,storeList:J,mt:3}),e.jsxs(c,{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap",children:[e.jsxs(Se,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(N,{variant:"subtitle1",sx:{fontWeight:"bold"},children:f("common.screenshot")}),e.jsxs(Se,{direction:"column",alignItems:"flex-start",spacing:1,sx:{opacity:.8,fontSize:"12px"},children:[e.jsx(c,{sx:{border:"none"},variant:"outlined",size:"small",children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.ratio"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"16 / 9"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.count"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"1~5"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.size"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"<5MB"})]})}),!o&&e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.order"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:f("studio.orderTip")})]})})]})]}),e.jsx(ao,{onDragEnd:o?void 0:ee,children:e.jsx(uo,{droppableId:"screenshots",direction:"horizontal",isDropDisabled:o,children:($,V)=>e.jsxs(c,{display:"flex",alignItems:"center",sx:{flex:1,flexWrap:"wrap",minHeight:160,background:V.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:V.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},ref:$.innerRef,...$.droppableProps,children:[b.map((F,Q)=>e.jsx(po,{draggableId:F,index:Q,isDragDisabled:o,children:(X,ie)=>e.jsxs(c,{ref:X.innerRef,...X.draggableProps,className:"screenshot",sx:{transform:ie.isDragging?"scale(1.05)":"none",boxShadow:ie.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx("img",{alt:"screenshot",src:F}),!o&&e.jsx(ce,{...X.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(bt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{d(Y=>{const de=[...Y.blockletScreenshots];return de.splice(Q,1),{...Y,blockletScreenshots:de}})},children:e.jsx(co,{})})]})},F)),$.placeholder,b.length<5&&e.jsx(c,{sx:{width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,onClick:()=>{var F;K()&&((F=k.current)==null||F.open())},children:"+"})]})})})]}),re&&e.jsx(xt,{errors:_,storeList:J}),e.jsxs(c,{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap",children:[e.jsxs(Se,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(N,{variant:"subtitle1",sx:{fontWeight:"bold"},children:f("studio.video")}),e.jsxs(Se,{direction:"column",alignItems:"flex-start",spacing:1,sx:{opacity:.8,fontSize:"12px"},children:[e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.videoType"),":"," "]}),e.jsxs(c,{component:"span",sx:{color:"#007ec6"},children:[e.jsx("a",{href:"https://www.youtube.com/",target:"_blank",rel:"noreferrer",children:"Youtube"}),","," ",e.jsx("a",{href:"https://vimeo.com/",target:"_blank",rel:"noreferrer",children:"Vimeo"})]})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.count"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"1~3"})]})}),!o&&e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[f("studio.order"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:f("studio.orderTip")})]})})]})]}),e.jsx(ao,{onDragEnd:o?void 0:Be,children:e.jsx(uo,{droppableId:"videos",direction:"horizontal",isDropDisabled:o,children:($,V)=>e.jsxs(c,{display:"flex",alignItems:"center",sx:{flex:1,flexWrap:"wrap",minHeight:160,background:V.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:V.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},ref:$.innerRef,...$.droppableProps,children:[l.blockletVideos.map((F,Q)=>e.jsx(po,{draggableId:F,index:Q,isDragDisabled:o,children:(X,ie)=>e.jsxs(c,{ref:X.innerRef,...X.draggableProps,className:"screenshot",sx:{transform:ie.isDragging?"scale(1.05)":"none",boxShadow:ie.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx(st,{url:F,style:{pointerEvents:ie.isDragging?"none":"auto"}}),!o&&e.jsx(ce,{...X.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(bt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{d(Y=>{const de=[...Y.blockletVideos];return de.splice(Q,1),{...Y,blockletVideos:de}})},children:e.jsx(co,{})})]})},F)),$.placeholder,l.blockletVideos.length<3&&e.jsx(c,{sx:{width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,onClick:()=>{K()&&B(!0)},children:"+"})]})})})]})]})}),e.jsxs(x.Suspense,{fallback:e.jsx(Fe,{}),children:[e.jsx(mo,{ref:D,locale:R,popup:!0,onUploadFinish:$=>{var V;d({blockletLogo:$.data.filename}),y(""),(V=D.current)==null||V.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:w,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/png","image/jpeg","image/webp","application/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"),z&&e.jsx(Ko,{onClose:()=>B(!1),params:l,setParams:d}),e.jsx(mo,{ref:k,popup:!0,onUploadFinish:$=>{var V;d(F=>{var X;const Q=F.blockletScreenshots||[];return Q.push((X=$.data)==null?void 0:X.filename),{...F,blockletScreenshots:Q}}),(V=k.current)==null||V.close()},installerProps:{disabled:!0},plugins:["ImageEditor"],apiPathProps:{uploader:q,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/*","application/svg+xml"],maxFileSize:1024*1024*5,maxNumberOfFiles:5-b.length}},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,autoCropArea:1,aspectRatio:16/9,initialAspectRatio:16/9,croppedCanvasOptions:{minWidth:1280,minHeight:720,maxWidth:1280*2,maxHeight:720*2}}}},"uploader-screenshot")]})]})}es.propTypes={projectId:r.string.isRequired,readOnly:r.bool.isRequired,params:r.object.isRequired,setParams:r.func.isRequired,paramsErrTip:r.object.isRequired,setParamsErrTip:r.func.isRequired,warning:r.object.isRequired,loading:r.bool.isRequired,blocklet:r.object.isRequired,setLoading:r.func.isRequired,initUrl:r.object.isRequired,componentDid:r.isRequired,initLogoUrl:r.string.isRequired,setInitLogoUrl:r.func.isRequired};const Xn=ge.div`
|
|
125
125
|
margin-top: 24px;
|
|
126
126
|
.screenshot {
|
|
127
127
|
margin-bottom: 16px;
|
|
@@ -169,7 +169,7 @@ import{r as x,k as gt,l as tt,L as xe,u as js,h as ks,i as ct}from"./vendor-reac
|
|
|
169
169
|
padding-bottom: 12px;
|
|
170
170
|
border-bottom: ${({theme:t})=>`1px solid ${t.palette.divider}`};
|
|
171
171
|
}
|
|
172
|
-
`;function rs({text:t}){return t?e.jsx(un,{wrapperElement:{"data-color-mode":"light"},source:Fs.sanitize(t),rehypePlugins:[[pn,{target:"_blank"}]]}):e.jsx(Ae,{Icon:Dt})}rs.propTypes={text:r.string.isRequired};function is({params:t,setParams:o,paramsErrTip:s,loading:i,setParamsErrTip:l,readOnly:d}){var m;const{t:n}=te(),[u,a]=x.useState(d?"preview":"write"),h=(S,y)=>{a(y)};return e.jsxs(c,{sx:{border:"1px solid #fff",width:"100%",borderRadius:2},children:[e.jsxs(c,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(N,{variant:"h6",fontWeight:"bold",sx:{},children:n("common.introduction")}),e.jsxs($o,{value:u,onChange:h,"aria-label":"wrapped label tabs example",children:[e.jsx(Qe,{value:"write",label:"Write"}),e.jsx(Qe,{value:"preview",label:"Preview"})]})]}),e.jsx(c,{display:u==="write"?"block":"none",sx:{width:"100%",marginTop:3},children:e.jsx(oe,{disabled:i||d,sx:{border:"none"},placeholder:`Blocklet ${n("common.introduction")}`,InputProps:{"data-cy":"export-blocklet-introduction",readOnly:d,endAdornment:e.jsxs(Ve,{position:"end",children:[((m=t==null?void 0:t.blockletIntroduction)==null?void 0:m.length)||0," / ",ue.PROJECT.MAX_INTRO_LENGTH]})},autoComplete:"off",variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,value:t.blockletIntroduction||"",onChange:S=>{l({blockletIntroduction:""}),o({blockletIntroduction:S.target.value.slice(0,ue.PROJECT.MAX_INTRO_LENGTH)})},error:!!s.blockletIntroduction,helperText:s.blockletIntroduction||""})}),e.jsx(c,{display:u==="preview"?"block":"none",mt:3,children:e.jsx(rs,{text:t.blockletIntroduction||""})})]})}is.propTypes={params:r.object.isRequired,setParams:r.func.isRequired,paramsErrTip:r.object.isRequired,setParamsErrTip:r.func.isRequired,readOnly:r.bool.isRequired,loading:r.bool.isRequired};var Gt={},ll=ke;Object.defineProperty(Gt,"__esModule",{value:!0});var mt=Gt.default=void 0,rl=ll(Re()),jo=e;mt=Gt.default=(0,rl.default)([(0,jo.jsx)("circle",{cx:"12",cy:"19",r:"2"},"0"),(0,jo.jsx)("path",{d:"M10 3h4v12h-4z"},"1")],"PriorityHigh");function Jt({step:t,ok:o,active:s,error:i,warning:l}){let d="grey.500",n=t+1;return o&&(n=e.jsx(hn,{sx:{fontSize:18,margin:0},color:"white"})),i||!o&&s>t?(d="error.main",n=e.jsx(mt,{sx:{fontSize:18,margin:0},color:"white"})):l?(d="warning.main",n=e.jsx(mt,{sx:{fontSize:18,margin:0},color:"white"})):s>=t&&(d="primary.main"),e.jsx(c,{width:24,height:24,bgcolor:d,borderRadius:"100%",color:"white",display:"flex",justifyContent:"center",fontWeight:"bold",fontSize:14,alignItems:"center",children:n})}Jt.propTypes={step:r.number,ok:r.bool,active:r.number,error:r.string,warning:r.bool};Jt.defaultProps={step:0,ok:!1,active:0,error:"",warning:!1};function cs({steps:t,activeStep:o,setActiveStep:s,hasSelectedResources:i,params:l,loading:d,paramsErrTip:n,warning:u,viewMode:a,projectId:h}){const{t:m}=te(),S=()=>{s(R=>R+1)},y=()=>{s(R=>R-1)},p=R=>R===0?(n==null?void 0:n.blockletTitle)||(n==null?void 0:n.projectId)||(n==null?void 0:n.blockletDescription)||(n==null?void 0:n.blockletHomepage)||(n==null?void 0:n.blockletSupport)||(n==null?void 0:n.blockletCommunity)||(n==null?void 0:n.blockletRepository):R===2?(n==null?void 0:n.blockletResource)||(n==null?void 0:n.blockletDocker)||(n==null?void 0:n.dockerImageName):R>=4?(n==null?void 0:n.blockletVersion)||(n==null?void 0:n.note):"",f=a||os({hasSelectedResources:i,params:l,projectId:h,t:m})===null;return e.jsxs(c,{sx:{width:300,maxWidth:300,minWidth:300,padding:2,border:"1px solid #ccc",borderRadius:2},children:[e.jsx(Ds,{activeStep:o,orientation:"vertical",children:t.map((R,I)=>{const j={},D=d||!sl({hasSelectedResources:i,params:l,projectId:h,step:I,t:m}),k=d?"":p(I);return k&&(j.optional=e.jsx(N,{variant:"caption",color:"error",children:k}),j.error=!0),e.jsxs(Ts,{children:[e.jsx(_s,{icon:e.jsx(Jt,{error:k,warning:I===0?u.hasWarning:!1,active:f?99:o,step:I,ok:D}),sx:{cursor:"pointer",color:k?"error.main":"inherit"},disabled:!1,onClick:()=>s(I),...j,children:e.jsx(N,{fontSize:"14px",fontWeight:"500",color:k||!D&&o>I?"error.main":"inherit",children:R.label})}),e.jsxs(Ps,{children:[e.jsx(N,{fontSize:12,children:R.description}),!f&&e.jsx(c,{sx:{mb:2},children:e.jsxs("div",{children:[I<t.length-1&&e.jsx(se,{variant:"contained",onClick:S,sx:{mt:1,mr:1},disabled:k||!D,children:m("common.continue")}),I>0&&e.jsx(se,{disabled:I===0,onClick:y,sx:{mt:1,mr:1},children:m("common.back")})]})})]})]},R.label)})}),o>=t.length-1&&e.jsx(jt,{square:!0,elevation:0,sx:{p:3},children:e.jsx(N,{fontSize:12,sx:{opacity:.5},children:"Click right top button to release"})})]})}cs.propTypes={steps:r.array.isRequired,activeStep:r.number.isRequired,setActiveStep:r.func.isRequired,params:r.object.isRequired,viewMode:r.string.isRequired,loading:r.bool.isRequired,projectId:r.string.isRequired,hasSelectedResources:r.bool.isRequired,warning:r.object.isRequired,paramsErrTip:r.shape({projectId:r.string,blockletVersion:r.string,blockletTitle:r.string,blockletDescription:r.string,note:r.string,blockletResource:r.string,blockletHomepage:r.string,blockletSupport:r.string,blockletCommunity:r.string,blockletRepository:r.string,blockletDocker:r.object,dockerImageName:r.string}).isRequired};const il=[".zip",".gz"],cl=1024*1024*100,al=x.lazy(()=>zo(()=>import("./index-BAphTUTz.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(t=>({default:t.Uploader})));function Xt({app:t,projectId:o,readOnly:s,params:i,setParams:l,setParamsErrTip:d,error:n}){const{t:u,locale:a}=te(),h=x.useRef(null),m=()=>s?!1:!o||o===G.UNOWNED_DID?(M.error(u("blocklet.publish.errorTip.noFirstDid")),!1):!0,S=`${G.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t.meta.did}/${o}/resource/upload`;return e.jsxs(c,{sx:{mt:3},children:[e.jsx(N,{gutterBottom:!0,children:u("blocklet.publish.resourceUpload")}),e.jsxs(Se,{direction:"row",alignItems:"center",spacing:1,sx:{flex:1,cursor:s?"default":"pointer"},children:[!!i.uploadedResource&&e.jsx(N,{component:"a",href:`${S}/params.uploadedResource`,children:i.uploadedResource}),!s&&e.jsx(se,{variant:"outlined",size:"small",onClick:()=>{var y;m()&&((y=h.current)==null||y.open())},children:i.uploadedResource?u("common.change"):u("common.upload")})]}),e.jsx(x.Suspense,{fallback:e.jsx(Fe,{}),children:e.jsx(al,{ref:h,locale:a,popup:!0,onUploadFinish:y=>{var p;l({uploadedResource:y.data.filename}),d({blockletResource:""}),(p=h.current)==null||p.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:S,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileExts:il,maxFileSize:cl,maxNumberOfFiles:1}}},"uploader-resource")}),!!n&&e.jsx(c,{color:"error.main",mt:1,fontSize:14,children:n})]})}Xt.propTypes={app:r.object.isRequired,projectId:r.string.isRequired,readOnly:r.bool.isRequired,params:r.object.isRequired,setParams:r.func.isRequired,error:r.string.isRequired,setParamsErrTip:r.func.isRequired};Xt.defaultProps={};function Ke({readOnly:t,params:o,setParams:s,paramsErrTip:i,setParamsErrTip:l,loading:d}){var u;const{t:n}=te();return e.jsx(c,{display:"flex",mt:3,className:"section",children:e.jsxs(c,{sx:{flex:1},children:[e.jsx(oe,{required:!0,disabled:d||t,label:`Blocklet ${n("common.version")}`,placeholder:`Blocklet ${n("common.version")}`,InputProps:{"data-cy":"blocklet-version",readOnly:t},autoComplete:"off",variant:"outlined",fullWidth:!0,value:o.blockletVersion||"",onChange:a=>{l({blockletVersion:""}),s({blockletVersion:a.target.value})},error:!!i.blockletVersion,helperText:i.blockletVersion||""}),e.jsx(oe,{label:n("blocklet.publish.releaseNote"),autoComplete:"off",disabled:d||t,variant:"outlined",InputProps:{"data-cy":"release-note",readOnly:t,endAdornment:e.jsxs(Ve,{position:"end",children:[((u=o==null?void 0:o.note)==null?void 0:u.length)||0," / ",ue.PROJECT.MAX_NOTE_LENGTH]})},fullWidth:!0,multiline:!0,minRows:4,required:!0,value:o.note||"",onChange:a=>{l({note:""}),s({note:a.target.value.slice(0,ue.PROJECT.MAX_NOTE_LENGTH)})},error:!!i.note,helperText:i.note||"",sx:{mt:3}})]})})}Ke.propTypes={readOnly:r.bool.isRequired,params:r.object.isRequired,setParams:r.func.isRequired,paramsErrTip:r.object.isRequired,setParamsErrTip:r.func.isRequired,loading:r.bool.isRequired};Ke.defaultProps={};function as(t){for(const o in t)typeof t[o]=="string"?t[o]=t[o].replace(/\\\\/g,"\\"):typeof t[o]=="object"&&t[o]!==null&&as(t[o]);return t}function et({index:t,item:o,dockerParams:s,setDockerParams:i,dataKey:l,t:d,readOnly:n}){const u=(o==null?void 0:o.value)||"",[a,h]=x.useState(!1),m=()=>{var W;(W=s[l])==null||W.splice(t,1),i({...s,[l]:[...s[l]]})},S=(W,b)=>{var w;(w=s[l])!=null&&w[t]&&(b?(s[l][t].custom=s[l][t].value,s[l][t].value=`$${dt(o.key)}`):(s[l][t].value=s[l][t].custom||"",s[l][t].custom="")),i({...s,[l]:[...s[l]]})},y=(W,b)=>{var q;const w=((q=s[l][t])==null?void 0:q.value)||"";s[l][t]={...s[l][t],secure:b,value:b&&w===ue.BLOCKLET_AUTOMATIC_ENV_VALUE?"":w},i({...s,[l]:[...s[l]]})},p=(W,b)=>{s[l][t]={...s[l][t],shared:b},i({...s,[l]:[...s[l]]})},f=(W,b)=>{var q;const w=((q=s[l][t])==null?void 0:q.value)||"";s[l][t]={...s[l][t],required:b,value:b&&w===ue.BLOCKLET_AUTOMATIC_ENV_VALUE?"":w},i({...s,[l]:[...s[l]]})},R=(W,b)=>{s[l][t]={...s[l][t],value:b?ue.BLOCKLET_AUTOMATIC_ENV_VALUE:"",secure:!1,required:!1},i({...s,[l]:[...s[l]]})},I=W=>{s[l][t]={...s[l][t],description:W.target.value},i({...s,[l]:[...s[l]]})},j=W=>{const b=W.target.value==="web"?"web":"docker";b==="web"&&s.dockerArgs.forEach(g=>{g.type="docker"});const q=`/${s.dockerImage.replace(/\W/g,"-")}-${t}`;s.dockerArgs[t]={...s.dockerArgs[t],type:b,path:b==="docker"?q:"/",protocol:"http",prefix:b==="docker"?q:"/",name:"publicUrl",port:"BLOCKLET_PORT"},i({...s,dockerArgs:[...s.dockerArgs]})},D=W=>{s.dockerArgs[t]={...s.dockerArgs[t],proxyBehavior:W.target.value==="direct"?"direct":"service"},i({...s,dockerArgs:[...s.dockerArgs]})},k=W=>{const b=W.target.value;s[l][t]={...s[l][t],prefix:b,path:b==="*"?"/":b},i({...s,[l]:[...s[l]]})},T=W=>{var b;(b=s[l])!=null&&b[t]&&(s[l][t].value=W.target.value),i({...s,[l]:[...s[l]]})},L=u===`$${dt(o.key)}`||o.custom,z=l==="dockerArgs"&&!Oo[o.key],B=nn[o.key],v=l==="dockerEnvs",C=o.key==="--publish";let H=o.key;return C&&o.type==="web"?H="--publish (Web)":v&&(H=`--env ${o.key}`),e.jsxs(c,{sx:{display:"flex",flexDirection:"row",gap:2,alignItems:"center"},children:[e.jsx(c,{sx:{width:250},children:e.jsx(N,{sx:{textOverflow:"ellipsis",width:"100%",overflow:"hidden"},children:H})}),e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:1,flex:1},children:[e.jsx(oe,{disabled:n||L||z||o.value===ue.BLOCKLET_AUTOMATIC_ENV_VALUE,placeholder:"",value:L?`$${dt(o.key)}`:u,sx:{flex:1},InputProps:{endAdornment:e.jsxs(Ve,{position:"end",sx:{zoom:.9},children:[(!(B||z)||v||C)&&e.jsx(ce,{onClick:()=>h(!0),children:e.jsx(ae,{icon:"icon-park-outline:setting-config"})}),!n&&e.jsx(ce,{onClick:m,color:z?"error":"default",children:e.jsx(ae,{icon:"ic:round-delete"})})]})},error:z,onChange:T}),z&&e.jsx(N,{variant:"caption",color:"error",children:d("blocklet.publish.docker.noAllowTheArg")}),o.key==="--publish"&&e.jsx(N,{variant:"caption",color:"text.secondary",children:d("blocklet.publish.docker.publishTips")}),o.key==="--volume"&&ln[o.key](u)&&e.jsx(N,{variant:"caption",color:"error",children:d("blocklet.publish.docker.volumeTips")})]}),a&&e.jsx(yt,{open:!0,fullWidth:!0,maxWidth:"sm",PaperProps:{style:{minHeight:0}},title:d(v?"blocklet.publish.docker.modifyEnv":"blocklet.publish.docker.modifyParam"),onClose:()=>h(!1),children:e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:1,paddingBottom:2},children:[B||z||v?null:e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{children:d("blocklet.publish.docker.needCustomInput")}),e.jsx(De,{disabled:n,checked:L,onChange:S,sx:{zoom:.9}})]}),v&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{children:d("blocklet.publish.docker.shared")}),e.jsx(De,{disabled:n,checked:o.shared,onChange:p,sx:{zoom:.9}})]}),v&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{children:d("blocklet.publish.docker.required")}),e.jsx(De,{disabled:n,checked:o.required,onChange:f,sx:{zoom:.9}})]}),v&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{children:d("blocklet.publish.docker.secure")}),e.jsx(De,{disabled:n,checked:o.secure,onChange:y,sx:{zoom:.9}})]}),v&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{children:d("blocklet.publish.docker.autoGenerated")}),e.jsx(De,{disabled:n,checked:o.value===ue.BLOCKLET_AUTOMATIC_ENV_VALUE,onChange:R,sx:{zoom:.9}})]}),v&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{sx:{flex:1},children:d("blocklet.publish.docker.description")}),e.jsx(oe,{disabled:n,value:o.description,onChange:I,sx:{flex:1},label:d("blocklet.publish.docker.description")})]}),C&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{sx:{flex:1},children:d("blocklet.publish.docker.portType")}),e.jsxs(ft,{value:o.type||"docker",onChange:j,children:[e.jsx(fe,{value:"docker",children:"Docker"}),e.jsx(fe,{value:"web",children:"Web"})]})]}),C&&o.type==="web"&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{sx:{flex:1},children:d("blocklet.publish.docker.proxyBehavior")}),e.jsxs(ft,{value:o.proxyBehavior||"service",onChange:D,children:[e.jsx(fe,{value:"service",children:d("blocklet.publish.docker.serviceProxy")}),e.jsx(fe,{value:"direct",children:d("blocklet.publish.docker.directProxy")})]})]}),C&&o.type==="web"&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{sx:{flex:1},children:d("blocklet.publish.docker.prefix")}),e.jsx(oe,{disabled:n,value:o.prefix,onChange:k,sx:{flex:1},label:d("blocklet.publish.docker.prefix")})]})]})})]})}et.propTypes={dockerParams:r.object.isRequired,setDockerParams:r.func.isRequired,dataKey:r.string.isRequired,item:r.object.isRequired,t:r.func.isRequired,readOnly:r.bool.isRequired,index:r.number.isRequired};et.defaultProps={};const dl=`
|
|
172
|
+
`;function rs({text:t}){return t?e.jsx(un,{wrapperElement:{"data-color-mode":"light"},source:Fs.sanitize(t),rehypePlugins:[[pn,{target:"_blank"}]]}):e.jsx(Ae,{Icon:Dt})}rs.propTypes={text:r.string.isRequired};function is({params:t,setParams:o,paramsErrTip:s,loading:i,setParamsErrTip:l,readOnly:d}){var m;const{t:n}=te(),[u,a]=x.useState(d?"preview":"write"),h=(S,y)=>{a(y)};return e.jsxs(c,{sx:{border:"1px solid #fff",width:"100%",borderRadius:2},children:[e.jsxs(c,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(N,{variant:"h6",fontWeight:"bold",sx:{},children:n("common.introduction")}),e.jsxs($o,{value:u,onChange:h,"aria-label":"wrapped label tabs example",children:[e.jsx(Qe,{value:"write",label:"Write"}),e.jsx(Qe,{value:"preview",label:"Preview"})]})]}),e.jsx(c,{display:u==="write"?"block":"none",sx:{width:"100%",marginTop:3},children:e.jsx(oe,{disabled:i||d,sx:{border:"none"},placeholder:`Blocklet ${n("common.introduction")}`,InputProps:{"data-cy":"export-blocklet-introduction",readOnly:d,endAdornment:e.jsxs(Ve,{position:"end",children:[((m=t==null?void 0:t.blockletIntroduction)==null?void 0:m.length)||0," / ",ue.PROJECT.MAX_INTRO_LENGTH]})},autoComplete:"off",variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,value:t.blockletIntroduction||"",onChange:S=>{l({blockletIntroduction:""}),o({blockletIntroduction:S.target.value.slice(0,ue.PROJECT.MAX_INTRO_LENGTH)})},error:!!s.blockletIntroduction,helperText:s.blockletIntroduction||""})}),e.jsx(c,{display:u==="preview"?"block":"none",mt:3,children:e.jsx(rs,{text:t.blockletIntroduction||""})})]})}is.propTypes={params:r.object.isRequired,setParams:r.func.isRequired,paramsErrTip:r.object.isRequired,setParamsErrTip:r.func.isRequired,readOnly:r.bool.isRequired,loading:r.bool.isRequired};var Gt={},ll=ke;Object.defineProperty(Gt,"__esModule",{value:!0});var mt=Gt.default=void 0,rl=ll(Re()),jo=e;mt=Gt.default=(0,rl.default)([(0,jo.jsx)("circle",{cx:"12",cy:"19",r:"2"},"0"),(0,jo.jsx)("path",{d:"M10 3h4v12h-4z"},"1")],"PriorityHigh");function Jt({step:t,ok:o,active:s,error:i,warning:l}){let d="grey.500",n=t+1;return o&&(n=e.jsx(hn,{sx:{fontSize:18,margin:0},color:"white"})),i||!o&&s>t?(d="error.main",n=e.jsx(mt,{sx:{fontSize:18,margin:0},color:"white"})):l?(d="warning.main",n=e.jsx(mt,{sx:{fontSize:18,margin:0},color:"white"})):s>=t&&(d="primary.main"),e.jsx(c,{width:24,height:24,bgcolor:d,borderRadius:"100%",color:"white",display:"flex",justifyContent:"center",fontWeight:"bold",fontSize:14,alignItems:"center",children:n})}Jt.propTypes={step:r.number,ok:r.bool,active:r.number,error:r.string,warning:r.bool};Jt.defaultProps={step:0,ok:!1,active:0,error:"",warning:!1};function cs({steps:t,activeStep:o,setActiveStep:s,hasSelectedResources:i,params:l,loading:d,paramsErrTip:n,warning:u,viewMode:a,projectId:h}){const{t:m}=te(),S=()=>{s(R=>R+1)},y=()=>{s(R=>R-1)},p=R=>R===0?(n==null?void 0:n.blockletTitle)||(n==null?void 0:n.projectId)||(n==null?void 0:n.blockletDescription)||(n==null?void 0:n.blockletHomepage)||(n==null?void 0:n.blockletSupport)||(n==null?void 0:n.blockletCommunity)||(n==null?void 0:n.blockletRepository):R===2?(n==null?void 0:n.blockletResource)||(n==null?void 0:n.blockletDocker)||(n==null?void 0:n.dockerImageName):R>=4?(n==null?void 0:n.blockletVersion)||(n==null?void 0:n.note):"",f=a||os({hasSelectedResources:i,params:l,projectId:h,t:m})===null;return e.jsxs(c,{sx:{width:300,maxWidth:300,minWidth:300,padding:2,border:"1px solid #ccc",borderRadius:2},children:[e.jsx(Ds,{activeStep:o,orientation:"vertical",children:t.map((R,I)=>{const j={},D=d||!sl({hasSelectedResources:i,params:l,projectId:h,step:I,t:m}),k=d?"":p(I);return k&&(j.optional=e.jsx(N,{variant:"caption",color:"error",children:k}),j.error=!0),e.jsxs(Ts,{children:[e.jsx(_s,{icon:e.jsx(Jt,{error:k,warning:I===0?u.hasWarning:!1,active:f?99:o,step:I,ok:D}),sx:{cursor:"pointer",color:k?"error.main":"inherit"},disabled:!1,onClick:()=>s(I),...j,children:e.jsx(N,{fontSize:"14px",fontWeight:"500",color:k||!D&&o>I?"error.main":"inherit",children:R.label})}),e.jsxs(Ps,{children:[e.jsx(N,{fontSize:12,children:R.description}),!f&&e.jsx(c,{sx:{mb:2},children:e.jsxs("div",{children:[I<t.length-1&&e.jsx(se,{variant:"contained",onClick:S,sx:{mt:1,mr:1},disabled:k||!D,children:m("common.continue")}),I>0&&e.jsx(se,{disabled:I===0,onClick:y,sx:{mt:1,mr:1},children:m("common.back")})]})})]})]},R.label)})}),o>=t.length-1&&e.jsx(jt,{square:!0,elevation:0,sx:{p:3},children:e.jsx(N,{fontSize:12,sx:{opacity:.5},children:"Click right top button to release"})})]})}cs.propTypes={steps:r.array.isRequired,activeStep:r.number.isRequired,setActiveStep:r.func.isRequired,params:r.object.isRequired,viewMode:r.string.isRequired,loading:r.bool.isRequired,projectId:r.string.isRequired,hasSelectedResources:r.bool.isRequired,warning:r.object.isRequired,paramsErrTip:r.shape({projectId:r.string,blockletVersion:r.string,blockletTitle:r.string,blockletDescription:r.string,note:r.string,blockletResource:r.string,blockletHomepage:r.string,blockletSupport:r.string,blockletCommunity:r.string,blockletRepository:r.string,blockletDocker:r.object,dockerImageName:r.string}).isRequired};const il=[".zip",".gz"],cl=1024*1024*100,al=x.lazy(()=>zo(()=>import("./index-Dja0MgHa.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(t=>({default:t.Uploader})));function Xt({app:t,projectId:o,readOnly:s,params:i,setParams:l,setParamsErrTip:d,error:n}){const{t:u,locale:a}=te(),h=x.useRef(null),m=()=>s?!1:!o||o===G.UNOWNED_DID?(M.error(u("blocklet.publish.errorTip.noFirstDid")),!1):!0,S=`${G.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t.meta.did}/${o}/resource/upload`;return e.jsxs(c,{sx:{mt:3},children:[e.jsx(N,{gutterBottom:!0,children:u("blocklet.publish.resourceUpload")}),e.jsxs(Se,{direction:"row",alignItems:"center",spacing:1,sx:{flex:1,cursor:s?"default":"pointer"},children:[!!i.uploadedResource&&e.jsx(N,{component:"a",href:`${S}/params.uploadedResource`,children:i.uploadedResource}),!s&&e.jsx(se,{variant:"outlined",size:"small",onClick:()=>{var y;m()&&((y=h.current)==null||y.open())},children:i.uploadedResource?u("common.change"):u("common.upload")})]}),e.jsx(x.Suspense,{fallback:e.jsx(Fe,{}),children:e.jsx(al,{ref:h,locale:a,popup:!0,onUploadFinish:y=>{var p;l({uploadedResource:y.data.filename}),d({blockletResource:""}),(p=h.current)==null||p.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:S,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileExts:il,maxFileSize:cl,maxNumberOfFiles:1}}},"uploader-resource")}),!!n&&e.jsx(c,{color:"error.main",mt:1,fontSize:14,children:n})]})}Xt.propTypes={app:r.object.isRequired,projectId:r.string.isRequired,readOnly:r.bool.isRequired,params:r.object.isRequired,setParams:r.func.isRequired,error:r.string.isRequired,setParamsErrTip:r.func.isRequired};Xt.defaultProps={};function Ke({readOnly:t,params:o,setParams:s,paramsErrTip:i,setParamsErrTip:l,loading:d}){var u;const{t:n}=te();return e.jsx(c,{display:"flex",mt:3,className:"section",children:e.jsxs(c,{sx:{flex:1},children:[e.jsx(oe,{required:!0,disabled:d||t,label:`Blocklet ${n("common.version")}`,placeholder:`Blocklet ${n("common.version")}`,InputProps:{"data-cy":"blocklet-version",readOnly:t},autoComplete:"off",variant:"outlined",fullWidth:!0,value:o.blockletVersion||"",onChange:a=>{l({blockletVersion:""}),s({blockletVersion:a.target.value})},error:!!i.blockletVersion,helperText:i.blockletVersion||""}),e.jsx(oe,{label:n("blocklet.publish.releaseNote"),autoComplete:"off",disabled:d||t,variant:"outlined",InputProps:{"data-cy":"release-note",readOnly:t,endAdornment:e.jsxs(Ve,{position:"end",children:[((u=o==null?void 0:o.note)==null?void 0:u.length)||0," / ",ue.PROJECT.MAX_NOTE_LENGTH]})},fullWidth:!0,multiline:!0,minRows:4,required:!0,value:o.note||"",onChange:a=>{l({note:""}),s({note:a.target.value.slice(0,ue.PROJECT.MAX_NOTE_LENGTH)})},error:!!i.note,helperText:i.note||"",sx:{mt:3}})]})})}Ke.propTypes={readOnly:r.bool.isRequired,params:r.object.isRequired,setParams:r.func.isRequired,paramsErrTip:r.object.isRequired,setParamsErrTip:r.func.isRequired,loading:r.bool.isRequired};Ke.defaultProps={};function as(t){for(const o in t)typeof t[o]=="string"?t[o]=t[o].replace(/\\\\/g,"\\"):typeof t[o]=="object"&&t[o]!==null&&as(t[o]);return t}function et({index:t,item:o,dockerParams:s,setDockerParams:i,dataKey:l,t:d,readOnly:n}){const u=(o==null?void 0:o.value)||"",[a,h]=x.useState(!1),m=()=>{var W;(W=s[l])==null||W.splice(t,1),i({...s,[l]:[...s[l]]})},S=(W,b)=>{var w;(w=s[l])!=null&&w[t]&&(b?(s[l][t].custom=s[l][t].value,s[l][t].value=`$${dt(o.key)}`):(s[l][t].value=s[l][t].custom||"",s[l][t].custom="")),i({...s,[l]:[...s[l]]})},y=(W,b)=>{var q;const w=((q=s[l][t])==null?void 0:q.value)||"";s[l][t]={...s[l][t],secure:b,value:b&&w===ue.BLOCKLET_AUTOMATIC_ENV_VALUE?"":w},i({...s,[l]:[...s[l]]})},p=(W,b)=>{s[l][t]={...s[l][t],shared:b},i({...s,[l]:[...s[l]]})},f=(W,b)=>{var q;const w=((q=s[l][t])==null?void 0:q.value)||"";s[l][t]={...s[l][t],required:b,value:b&&w===ue.BLOCKLET_AUTOMATIC_ENV_VALUE?"":w},i({...s,[l]:[...s[l]]})},R=(W,b)=>{s[l][t]={...s[l][t],value:b?ue.BLOCKLET_AUTOMATIC_ENV_VALUE:"",secure:!1,required:!1},i({...s,[l]:[...s[l]]})},I=W=>{s[l][t]={...s[l][t],description:W.target.value},i({...s,[l]:[...s[l]]})},j=W=>{const b=W.target.value==="web"?"web":"docker";b==="web"&&s.dockerArgs.forEach(g=>{g.type="docker"});const q=`/${s.dockerImage.replace(/\W/g,"-")}-${t}`;s.dockerArgs[t]={...s.dockerArgs[t],type:b,path:b==="docker"?q:"/",protocol:"http",prefix:b==="docker"?q:"/",name:"publicUrl",port:"BLOCKLET_PORT"},i({...s,dockerArgs:[...s.dockerArgs]})},D=W=>{s.dockerArgs[t]={...s.dockerArgs[t],proxyBehavior:W.target.value==="direct"?"direct":"service"},i({...s,dockerArgs:[...s.dockerArgs]})},k=W=>{const b=W.target.value;s[l][t]={...s[l][t],prefix:b,path:b==="*"?"/":b},i({...s,[l]:[...s[l]]})},T=W=>{var b;(b=s[l])!=null&&b[t]&&(s[l][t].value=W.target.value),i({...s,[l]:[...s[l]]})},L=u===`$${dt(o.key)}`||o.custom,z=l==="dockerArgs"&&!Oo[o.key],B=nn[o.key],v=l==="dockerEnvs",C=o.key==="--publish";let H=o.key;return C&&o.type==="web"?H="--publish (Web)":v&&(H=`--env ${o.key}`),e.jsxs(c,{sx:{display:"flex",flexDirection:"row",gap:2,alignItems:"center"},children:[e.jsx(c,{sx:{width:250},children:e.jsx(N,{sx:{textOverflow:"ellipsis",width:"100%",overflow:"hidden"},children:H})}),e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:1,flex:1},children:[e.jsx(oe,{disabled:n||L||z||o.value===ue.BLOCKLET_AUTOMATIC_ENV_VALUE,placeholder:"",value:L?`$${dt(o.key)}`:u,sx:{flex:1},InputProps:{endAdornment:e.jsxs(Ve,{position:"end",sx:{zoom:.9},children:[(!(B||z)||v||C)&&e.jsx(ce,{onClick:()=>h(!0),children:e.jsx(ae,{icon:"icon-park-outline:setting-config"})}),!n&&e.jsx(ce,{onClick:m,color:z?"error":"default",children:e.jsx(ae,{icon:"ic:round-delete"})})]})},error:z,onChange:T}),z&&e.jsx(N,{variant:"caption",color:"error",children:d("blocklet.publish.docker.noAllowTheArg")}),o.key==="--publish"&&e.jsx(N,{variant:"caption",color:"text.secondary",children:d("blocklet.publish.docker.publishTips")}),o.key==="--volume"&&ln[o.key](u)&&e.jsx(N,{variant:"caption",color:"error",children:d("blocklet.publish.docker.volumeTips")})]}),a&&e.jsx(yt,{open:!0,fullWidth:!0,maxWidth:"sm",PaperProps:{style:{minHeight:0}},title:d(v?"blocklet.publish.docker.modifyEnv":"blocklet.publish.docker.modifyParam"),onClose:()=>h(!1),children:e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:1,paddingBottom:2},children:[B||z||v?null:e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{children:d("blocklet.publish.docker.needCustomInput")}),e.jsx(De,{disabled:n,checked:L,onChange:S,sx:{zoom:.9}})]}),v&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{children:d("blocklet.publish.docker.shared")}),e.jsx(De,{disabled:n,checked:o.shared,onChange:p,sx:{zoom:.9}})]}),v&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{children:d("blocklet.publish.docker.required")}),e.jsx(De,{disabled:n,checked:o.required,onChange:f,sx:{zoom:.9}})]}),v&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{children:d("blocklet.publish.docker.secure")}),e.jsx(De,{disabled:n,checked:o.secure,onChange:y,sx:{zoom:.9}})]}),v&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{children:d("blocklet.publish.docker.autoGenerated")}),e.jsx(De,{disabled:n,checked:o.value===ue.BLOCKLET_AUTOMATIC_ENV_VALUE,onChange:R,sx:{zoom:.9}})]}),v&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{sx:{flex:1},children:d("blocklet.publish.docker.description")}),e.jsx(oe,{disabled:n,value:o.description,onChange:I,sx:{flex:1},label:d("blocklet.publish.docker.description")})]}),C&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{sx:{flex:1},children:d("blocklet.publish.docker.portType")}),e.jsxs(ft,{value:o.type||"docker",onChange:j,children:[e.jsx(fe,{value:"docker",children:"Docker"}),e.jsx(fe,{value:"web",children:"Web"})]})]}),C&&o.type==="web"&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{sx:{flex:1},children:d("blocklet.publish.docker.proxyBehavior")}),e.jsxs(ft,{value:o.proxyBehavior||"service",onChange:D,children:[e.jsx(fe,{value:"service",children:d("blocklet.publish.docker.serviceProxy")}),e.jsx(fe,{value:"direct",children:d("blocklet.publish.docker.directProxy")})]})]}),C&&o.type==="web"&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(N,{sx:{flex:1},children:d("blocklet.publish.docker.prefix")}),e.jsx(oe,{disabled:n,value:o.prefix,onChange:k,sx:{flex:1},label:d("blocklet.publish.docker.prefix")})]})]})})]})}et.propTypes={dockerParams:r.object.isRequired,setDockerParams:r.func.isRequired,dataKey:r.string.isRequired,item:r.object.isRequired,t:r.func.isRequired,readOnly:r.bool.isRequired,index:r.number.isRequired};et.defaultProps={};const dl=`
|
|
173
173
|
docker run --name postgrest
|
|
174
174
|
-p 3000:3000
|
|
175
175
|
-e PGRST_DB_URI="postgres://username:password@host:port/database"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o,a4 as r,E as i,T as n}from"./vendor-mui-core-C-PhacC8.js";import{L as f,r as g}from"./vendor-react-DoD83n6N.js";import"./index
|
|
1
|
+
import{j as o,a4 as r,E as i,T as n}from"./vendor-mui-core-C-PhacC8.js";import{L as f,r as g}from"./vendor-react-DoD83n6N.js";import"./index--QvOAcHK.js";import"./vendor-arcblock-D8eCUoJY.js";import"./vendor-ux-did-connect-BQ3cvv_1.js";import"./vendor-utils-CRBr0QUY.js";import"./vendor-hooks-DtYI0-rF.js";import"./lottie-web-B6s7dDoL.js";const l=(e,t)=>[e,...Array.isArray(t)?t:[t]],a=(e=2)=>({overflow:"hidden",textOverflow:"ellipsis",wordBreak:"break-word",display:"-webkit-box",WebkitLineClamp:e,WebkitBoxOrient:"vertical"});function c({sx:e,...t}){const s=l({display:"flex",flexWrap:"wrap",mx:-1},e);return o.jsx(r,{sx:s,...t})}c.propTypes={sx:i.object};c.defaultProps={sx:{}};function p({icon:e}){const[t,s]=g.useState(!1);return!e||t?null:typeof e=="string"?o.jsx(r,{component:"img",src:e,alt:"",sx:{width:1,height:1},onError:()=>s(!0)}):e}p.propTypes={icon:i.oneOfType([i.string,i.node]).isRequired};function w({title:e,desc:t,extra:s,cover:b,icon:d,to:x,sx:h}){const m=l({position:"relative",flexBasis:{xs:"100%",sm:"50%",md:"33.33%",lg:"25%"},maxWidth:{xs:"100%",sm:"50%",md:"33.33%",lg:"25%"},mb:{xs:2,md:6},px:1},h);return o.jsx(r,{sx:m,children:o.jsx(r,{component:f,to:x,target:"_blank",sx:{display:"flex",flexDirection:"column",gap:1,height:1,pt:0,color:"inherit",textDecoration:"none",borderRadius:1,cursor:"pointer"},children:o.jsxs(r,{children:[o.jsxs(r,{sx:{position:"relative"},children:[b,d&&o.jsx(r,{sx:{position:"absolute",top:44,left:16,zIndex:1,width:56,height:56},children:o.jsx(p,{icon:d})})]}),o.jsx(n,{sx:{mt:1,fontSize:"1.25rem",fontWeight:600,...a()},children:e}),t&&o.jsx(n,{variant:"body2",sx:{my:1,...a(),color:"text.secondary"},children:t}),s]})})})}w.propTypes={title:i.string.isRequired,desc:i.string.isRequired,extra:i.node.isRequired,cover:i.string.isRequired,icon:i.string.isRequired,to:i.string.isRequired,sx:i.object.isRequired};const k="/.well-known/service/static/assets/doc-board-bg-DWZHV9Ng.png";function u({board:e,sx:t,...s}){return o.jsx(w,{date:e.createdAt,sx:t,to:e.link,title:e.title,desc:e.desc,cover:o.jsx(r,{sx:{position:"relative",paddingTop:`${9/16*100}%`,border:1,borderColor:"divider",borderRadius:1,overflow:"hidden"},children:o.jsx(r,{component:"img",src:k,alt:"",sx:{position:"absolute",top:0,left:0,width:1}})}),icon:e.icon,...s})}u.propTypes={board:i.object.isRequired,sx:i.object.isRequired};function C(){const e=[{id:"1",title:"Blocklet Platform",desc:"Guide to understand and build on our blocklet platform",icon:"https://www.arcblock.io/favicon.ico",link:"https://www.arcblock.io/docs/blocklet-developer/en/getting-started"},{id:"2",title:"Create Blocklet",desc:"Build blocklet with just one command line.",icon:"https://www.arcblock.io/favicon.ico",link:"https://www.arcblock.io/docs/createblocklet/en/quick-start"},{id:"3",title:"Blocklet Launcher",desc:"Streamlining Blocklet Launching.",icon:"https://www.arcblock.io/docs/uploads/5a4f4716bc8061532a535fe816a9169c.png",link:"https://www.arcblock.io/docs/launcher/en/launcher-welcome"},{id:"4",title:"DID Spaces",desc:"Digital Spaces for Decentralized Identity (DID)",icon:"https://www.arcblock.io/docs/uploads/3a8b142d7c940c57eced71eddba2ff19.png",link:"https://www.arcblock.io/docs/did-spaces/en/did-spaces-getting-started"},{id:"5",title:"DID Wallet",desc:"DID Wallet Support docs",icon:"https://www.arcblock.io/docs/uploads/59ddb28f405ee670428e5fe1ff12d104.png",link:"https://www.arcblock.io/docs/did-wallet/en/get-started"},{id:"6",title:"DID Names",desc:"Naming Service based on NFT and verifiable credentials",icon:"https://www.didnames.io/favicon.ico?imageFilter=resize&w=32",link:"https://www.arcblock.io/docs/did-domain/en/did-domain-faq"},{id:"7",title:"Blockchain",desc:"The ledger for ArcBlock ecosystem",icon:"https://www.arcblock.io/docs/uploads/4a20c152faae0f104ed0815ff3b8b48b.png",link:"https://www.arcblock.io/docs/blockchain/en/blockchain-how-to-guides"},{id:"8",title:"DID Connect",desc:"The open protocol and development kit for connecting users and dapps",icon:"https://www.arcblock.io/docs/uploads/d189118f89b56e9d5b03ad5a0212a4ab.png",link:"https://www.arcblock.io/docs/did-connect/en/developer-guides"}];return o.jsx(c,{children:e.map(t=>o.jsx(u,{board:t},t.id))})}export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,aa as r}from"./vendor-mui-core-C-PhacC8.js";import{r as s}from"./vendor-react-DoD83n6N.js";import{aZ as a}from"./vendor-ux-did-connect-
|
|
1
|
+
import{j as t,aa as r}from"./vendor-mui-core-C-PhacC8.js";import{r as s}from"./vendor-react-DoD83n6N.js";import{aZ as a}from"./vendor-ux-did-connect-BQ3cvv_1.js";import{R as e}from"./vendor-arcblock-D8eCUoJY.js";import"./vendor-utils-CRBr0QUY.js";import"./vendor-hooks-DtYI0-rF.js";import"./lottie-web-B6s7dDoL.js";function x(){const{t:o}=s.useContext(a);return t.jsx(n,{style:{paddingTop:"25vh"},children:t.jsx(e,{status:"404",description:o("noMatch.desc"),style:{backgroundColor:"transparent"}})})}const n=r.main``;export{x as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as te,V as W,bU as Ae,bV as Oe,h as ae,g as J,bQ as Ee,bR as Ue,a7 as We,a8 as Me,a6 as _e,bW as ze,a$ as Ie,m as me,r as Ve,aZ as Y,bX as pe,aj as ge,B as E,bH as $e,a1 as Ne,bY as He,a2 as Je,_ as Ke,X as Ze,ap as Le}from"./vendor-ux-did-connect-BihFfRkM.js";import{u as m,a as ne,f as ee,c as Ge}from"./vendor-hooks-DtYI0-rF.js";import{r as R}from"./vendor-react-DoD83n6N.js";import{j as e,a4 as v,bp as P,bl as U,M as A,x as z,E as N,T as he,I as re,ae as $,cv as Ye,a2 as Xe,e as xe,a3 as fe,$ as Fe,a5 as Qe,al as et,aa as tt}from"./vendor-mui-core-C-PhacC8.js";import{H as G,a0 as nt,b as Ce,C as ot,n as Z,aD as at,y as rt,z as st}from"./vendor-utils-CRBr0QUY.js";import{a as oe,C as L,e as De}from"./dashboard-CFCEDlP-.js";import{A as H,D as V,h as it}from"./index-D4WK9Fpj.js";import{S as se}from"./switch-control-CHr40nyS.js";import{K as lt}from"./keyboard-arrow-down-rounded-DadBVmpO.js";import{t as qe,y as ct}from"./vendor-arcblock-DV12D9BN.js";import{I as dt}from"./index-nHbtopN7.js";import{b as ut}from"./base32-CHVLLVvB.js";import{u as mt}from"./use-mobile-B_Gqv6b6.js";import"./lottie-web-B6s7dDoL.js";import"./useLocalStorage-Bip9kD-Q.js";import"./confirm-B2IOP2M3.js";import"./format-error-LAoTjvJe.js";import"./PlayArrow-CTZ2QlWx.js";import"./get-safe-url-B0p0Sl-_.js";import"./index-CY-SffSN.js";import"./session-D21Dok5b.js";import"./useAsyncRetry-BAg_7Lam.js";import"./useAsync-CX7JRRJM.js";import"./InfoOutlined-Cga_EIiY.js";import"./useSetState-BL3ktMon.js";import"./use-mobile-DudfIz3d.js";const ie={enabled:!1,domain:"",clientId:"",clientSecret:""};function pt(){var b,y,i;const{api:k}=H(),{blocklet:s}=V(),{t:a}=te(),n=(b=s==null?void 0:s.meta)==null?void 0:b.did,S=Object.assign({...ie},((i=(y=s==null?void 0:s.settings)==null?void 0:y.oauth)==null?void 0:i.auth0)||{}),{handleSubmit:t,control:f,formState:c,watch:p,reset:l}=oe({defaultValues:G(S,Object.keys(ie))}),d=p("enabled"),T=m(async r=>{var w,o;try{const{blocklet:x}=await k.configOAuth({input:{did:n,oauth:JSON.stringify({auth0:r})}}),u=Object.assign({...ie},((o=(w=x==null?void 0:x.settings)==null?void 0:w.oauth)==null?void 0:o.auth0)||{});l(u),W.success(a("oauth.saveSuccess"))}catch(x){W.error(x.message||a("oauth.saveFailed"))}}),I=m(r=>r!=null&&r.trim()?!0:a("oauth.auth0.domainDescription")),h=m(r=>r!=null&&r.trim()?!0:a("oauth.auth0.clientIdDescription")),g=m(r=>r!=null&&r.trim()?!0:a("oauth.auth0.clientSecretDescription")),j=m(()=>!0);return e.jsx(v,{children:e.jsxs("form",{onSubmit:t(T),disabled:!0,children:[e.jsx(L,{name:"enabled",control:f,render:({field:r})=>e.jsx(P,{control:e.jsx(se,{checked:r.value,style:{marginRight:"6px"},...r}),label:a("oauth.auth0.enable"),sx:{marginBottom:2,ml:1}})}),e.jsx(L,{name:"domain",control:f,rules:{validate:d?I:j},render:({field:r})=>{var w;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...r,label:a("oauth.auth0.domain"),error:!!c.errors[r.name],helperText:((w=c.errors[r.name])==null?void 0:w.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"clientId",control:f,rules:{validate:d?h:j},render:({field:r})=>{var w;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...r,error:!!c.errors[r.name],label:a("oauth.auth0.clientId"),helperText:((w=c.errors[r.name])==null?void 0:w.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"clientSecret",control:f,rules:{validate:d?g:j},render:({field:r})=>{var w;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...r,type:"password",error:!!c.errors[r.name],label:a("oauth.auth0.clientSecret"),helperText:((w=c.errors[r.name])==null?void 0:w.message)||" ",disabled:!d})})}}),e.jsx(z,{type:"submit",variant:"contained",onSubmit:t(T),disabled:!c.isDirty,children:a("oauth.save")})]})})}const le={enabled:!1,clientId:"",clientSecret:""};function ht(){var j,b,y;const{api:k}=H(),{blocklet:s}=V(),{t:a}=te(),n=(j=s==null?void 0:s.meta)==null?void 0:j.did,S=Object.assign({...le},((y=(b=s==null?void 0:s.settings)==null?void 0:b.oauth)==null?void 0:y.github)||{}),{handleSubmit:t,control:f,formState:c,watch:p,reset:l}=oe({defaultValues:G(S,Object.keys(le))}),d=p("enabled"),T=m(async i=>{var r,w;try{const{blocklet:o}=await k.configOAuth({input:{did:n,oauth:JSON.stringify({github:i})}}),x=Object.assign({...le},((w=(r=o==null?void 0:o.settings)==null?void 0:r.oauth)==null?void 0:w.github)||{});l(x),W.success(a("oauth.saveSuccess"))}catch(o){W.error(o.message||a("oauth.saveFailed"))}}),I=m(i=>i!=null&&i.trim()?!0:a("oauth.github.clientIdDescription")),h=m(i=>i!=null&&i.trim()?!0:a("oauth.github.clientSecretDescription")),g=m(()=>!0);return e.jsx(v,{children:e.jsxs("form",{onSubmit:t(T),disabled:!0,children:[e.jsx(L,{name:"enabled",control:f,render:({field:i})=>e.jsx(P,{control:e.jsx(se,{checked:i.value,style:{marginRight:"6px"},...i}),label:a("oauth.github.enable"),sx:{marginBottom:2,ml:1}})}),e.jsx(L,{name:"clientId",control:f,rules:{validate:d?I:g},render:({field:i})=>{var r;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...i,error:!!c.errors[i.name],label:a("oauth.github.clientId"),helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"clientSecret",control:f,rules:{validate:d?h:g},render:({field:i})=>{var r;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...i,type:"password",label:a("oauth.github.clientSecret"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}}),e.jsx(z,{type:"submit",variant:"contained",onSubmit:t(T),disabled:!c.isDirty,children:a("oauth.save")})]})})}const ce={enabled:!1,clientId:"",clientSecret:""};function ft(){var j,b,y;const{api:k}=H(),{blocklet:s}=V(),{t:a}=te(),n=(j=s==null?void 0:s.meta)==null?void 0:j.did,S=Object.assign({...ce},((y=(b=s==null?void 0:s.settings)==null?void 0:b.oauth)==null?void 0:y.google)||{}),{handleSubmit:t,control:f,formState:c,watch:p,reset:l}=oe({defaultValues:G(S,Object.keys(ce))}),d=p("enabled"),T=m(async i=>{var r,w;try{const{blocklet:o}=await k.configOAuth({input:{did:n,oauth:JSON.stringify({google:i})}}),x=Object.assign({...ce},((w=(r=o==null?void 0:o.settings)==null?void 0:r.oauth)==null?void 0:w.google)||{});l(x),W.success(a("oauth.saveSuccess"))}catch(o){W.error(o.message||a("oauth.saveFailed"))}}),I=m(i=>i!=null&&i.trim()?!0:a("oauth.google.clientIdDescription")),h=m(i=>i!=null&&i.trim()?!0:a("oauth.google.clientSecretDescription")),g=m(()=>!0);return e.jsx(v,{children:e.jsxs("form",{onSubmit:t(T),disabled:!0,children:[e.jsx(L,{name:"enabled",control:f,render:({field:i})=>e.jsx(P,{control:e.jsx(se,{checked:i.value,style:{marginRight:"6px"},...i}),label:a("oauth.google.enable"),sx:{marginBottom:2,ml:1}})}),e.jsx(L,{name:"clientId",control:f,rules:{validate:d?I:g},render:({field:i})=>{var r;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...i,error:!!c.errors[i.name],label:a("oauth.google.clientId"),helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"clientSecret",control:f,rules:{validate:d?h:g},render:({field:i})=>{var r;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...i,type:"password",label:a("oauth.google.clientSecret"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}}),e.jsx(z,{type:"submit",variant:"contained",onSubmit:t(T),disabled:!c.isDirty,children:a("oauth.save")})]})})}const de={enabled:!1,teamId:"",serviceId:"",keyId:"",authKey:"",bundleId:""};function gt(){var i,r,w;const{api:k}=H(),{blocklet:s}=V(),{t:a}=te(),n=(i=s==null?void 0:s.meta)==null?void 0:i.did,S=Object.assign({...de},((w=(r=s==null?void 0:s.settings)==null?void 0:r.oauth)==null?void 0:w.apple)||{}),{handleSubmit:t,control:f,formState:c,watch:p,reset:l}=oe({defaultValues:G(S,Object.keys(de))}),d=p("enabled"),T=m(async o=>{var x,u;try{const{blocklet:F}=await k.configOAuth({input:{did:n,oauth:JSON.stringify({apple:o})}}),B=Object.assign({...de},((u=(x=F==null?void 0:F.settings)==null?void 0:x.oauth)==null?void 0:u.apple)||{});l(B),W.success(a("oauth.saveSuccess"))}catch(F){W.error(F.message||a("oauth.saveFailed"))}}),I=m(o=>o!=null&&o.trim()?!0:a("oauth.apple.teamIdDescription")),h=m(o=>o!=null&&o.trim()?!0:a("oauth.apple.serviceIdDescription")),g=m(o=>o!=null&&o.trim()?!0:a("oauth.apple.keyIdDescription")),j=m(o=>o!=null&&o.trim()?!0:a("oauth.apple.authKeyDescription")),b=m(o=>o!=null&&o.trim()?!0:a("oauth.apple.bundleIdDescription")),y=m(()=>!0);return e.jsx(v,{children:e.jsxs("form",{onSubmit:t(T),disabled:!0,children:[e.jsx(L,{name:"enabled",control:f,render:({field:o})=>e.jsx(P,{control:e.jsx(se,{checked:o.value,style:{marginRight:"6px"},...o}),label:a("oauth.apple.enable"),sx:{marginBottom:2,ml:1}})}),e.jsx(L,{name:"teamId",control:f,rules:{validate:d?I:y},render:({field:o})=>{var x;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...o,error:!!c.errors[o.name],label:a("oauth.apple.teamId"),helperText:((x=c.errors[o.name])==null?void 0:x.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"bundleId",control:f,rules:{validate:d?b:y},render:({field:o})=>{var x;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...o,error:!!c.errors[o.name],label:a("oauth.apple.bundleId"),helperText:((x=c.errors[o.name])==null?void 0:x.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"serviceId",control:f,rules:{validate:d?h:y},render:({field:o})=>{var x;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...o,error:!!c.errors[o.name],label:a("oauth.apple.serviceId"),helperText:((x=c.errors[o.name])==null?void 0:x.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"keyId",control:f,rules:{validate:d?g:y},render:({field:o})=>{var x;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...o,error:!!c.errors[o.name],label:a("oauth.apple.keyId"),helperText:((x=c.errors[o.name])==null?void 0:x.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"authKey",control:f,rules:{validate:d?j:y},render:({field:o})=>{var x;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...o,type:"password",multiline:!0,rows:4,label:a("oauth.apple.authKey"),error:!!c.errors[o.name],helperText:((x=c.errors[o.name])==null?void 0:x.message)||" ",disabled:!d})})}}),e.jsx(z,{type:"submit",variant:"contained",onSubmit:t(T),disabled:!c.isDirty,children:a("oauth.save")})]})})}const xt={width:24,height:24,body:'<path fill="currentColor" d="M9 20q-.825 0-1.413-.588T7 18q0-.825.588-1.413T9 16q.825 0 1.413.588T11 18q0 .825-.588 1.413T9 20Zm6 0q-.825 0-1.413-.588T13 18q0-.825.588-1.413T15 16q.825 0 1.413.588T17 18q0 .825-.588 1.413T15 20Zm-6-6q-.825 0-1.413-.588T7 12q0-.825.588-1.413T9 10q.825 0 1.413.588T11 12q0 .825-.588 1.413T9 14Zm6 0q-.825 0-1.413-.588T13 12q0-.825.588-1.413T15 10q.825 0 1.413.588T17 12q0 .825-.588 1.413T15 14ZM9 8q-.825 0-1.413-.588T7 6q0-.825.588-1.413T9 4q.825 0 1.413.588T11 6q0 .825-.588 1.413T9 8Zm6 0q-.825 0-1.413-.588T13 6q0-.825.588-1.413T15 4q.825 0 1.413.588T17 6q0 .825-.588 1.413T15 8Z"/>'};function be({title:k,id:s,children:a,index:n,onMove:S,defaultExpand:t,onEnd:f}){const[c,p]=R.useState(t),l=R.useRef(null),d=R.useRef(null),[{handlerId:T},I]=Ae({accept:"dragItem",collect(y){return{handlerId:y.getHandlerId()}},hover(y,i){var _,X;if(!l.current)return;const r=y.index,w=n;if(r===w)return;const o=(_=l.current)==null?void 0:_.getBoundingClientRect(),x=(X=d.current)==null?void 0:X.getBoundingClientRect(),u=(x.bottom-x.top)/2,B=i.getClientOffset().y-o.top;r<w&&B<u||r>w&&B>u||(S(r,w),y.index=w)}}),[{isDragging:h},g]=Oe({item:{index:n,type:"dragItem"},collect:y=>({isDragging:y.isDragging()}),end:f});g(d),I(l);const j=h?.5:1,b=m(y=>{y.preventDefault(),y.stopPropagation(),p(!c)});return e.jsxs(v,{ref:l,sx:{borderBottom:`1px solid ${ae.lineBorderStrong}`},children:[e.jsx(v,{sx:{cursor:"pointer","&:hover":{backgroundColor:ae.backgroundsBgSubtileHover},borderRadius:2},ref:d,"data-handler-id":T,children:e.jsxs(v,{sx:{py:1.5,px:1,opacity:j,display:"flex",alignItems:"center",gap:.5},draggable:!1,onClick:b,children:[e.jsx(v,{sx:{pointerEvents:"auto",cursor:"grab","&:active":{cursor:"grabbing"},fontSize:0,color:ae.textMuted,"&:hover":{color:ae.textSubtitle}},children:e.jsx(J,{fontSize:20,icon:xt})}),e.jsx(he,{sx:{flex:1},children:k}),e.jsx(re,{size:"small",sx:{pointerEvents:"auto",transform:c?"":"rotate(180deg)",transition:"transform 0.3s ease"},children:e.jsx(J,{icon:lt,style:{transform:"scale(1.5)"}})})]})}),e.jsx(v,{sx:{pl:4,py:1,display:c?"block":"none"},children:a})]})}be.propTypes={title:N.string.isRequired,id:N.string.isRequired,children:N.node.isRequired,index:N.number.isRequired,onMove:N.func.isRequired,onEnd:N.func.isRequired,defaultExpand:N.bool};be.defaultProps={defaultExpand:!0};const bt=[{name:"github",title:"GitHub",icon:e.jsx(J,{icon:We}),component:e.jsx(ht,{})},{name:"google",title:"Google",icon:e.jsx(J,{icon:Me}),component:e.jsx(ft,{})},{name:"apple",title:"Apple",icon:e.jsx(J,{icon:_e}),component:e.jsx(gt,{})},{name:"auth0",title:"Auth0",icon:e.jsx(J,{icon:ze}),component:e.jsx(pt,{})}],jt=["github","google","apple","auth0"];function vt(){var T,I;const{api:k}=H(),{blocklet:s}=V(),a=(T=s==null?void 0:s.meta)==null?void 0:T.did,n=((I=s==null?void 0:s.settings)==null?void 0:I.oauth)||{},S=Object.keys(n).sort((h,g)=>{var j,b,y;return((j=n[h])==null?void 0:j.order)!==void 0&&((b=n[g])==null?void 0:b.order)!==void 0?n[h].order-n[g].order:((y=n[h])==null?void 0:y.order)!==void 0?-1:1});for(const h of jt)S.includes(h)||S.push(h);const t=ne(S.reduce((h,g,j)=>Object.assign(h,{[g]:j}),{})),f=ee(()=>{const h=[...bt];return h.sort((g,j)=>t[g.name]-t[j.name]),h},[t.auth0,t.github,t.google]),c={};typeof window<"u"&&(c.context=window);const p=m(async h=>{const g={};Object.keys(h).forEach(j=>{g[j]={order:h[j]}}),await k.configOAuth({input:{did:a,oauth:JSON.stringify(g)}})}),l=m((h,g)=>{const j=f[h],b=f[g];t[j.name]=g,t[b.name]=h}),d=m(async()=>{await p(t)});return e.jsx(v,{children:e.jsx(Ee,{backend:Ue,...c,children:f.map((h,g)=>e.jsx(be,{index:g,id:h.name,title:h.title,icon:h.icon,onMove:l,onEnd:d,defaultExpand:h.enabled,children:h.component},h.name))})})}const K={ttl:me.SESSION_TTL,cacheTtl:me.SESSION_CACHE_TTL,email:{enabled:!1,requireVerified:!1,requireUnique:!1,trustOauthProviders:!1,trustedIssuers:[],enableDomainBlackList:!1,domainBlackList:[],enableDomainWhiteList:!1,domainWhiteList:[]},phone:{enabled:!1,requireVerified:!1,requireUnique:!1,regionBlackList:[],trustedIssuers:[]}};function M(k){return e.jsx(ct,{...k,sx:{marginLeft:1,marginRight:.5,transform:"scale(0.75)"}})}function ue(k,s=!1){const a=s?k.ttl*86400:k.ttl/86400;return{...k,ttl:a}}function yt(){var o,x;const{api:k}=H(),{blocklet:s}=V(),a=(o=s==null?void 0:s.meta)==null?void 0:o.did,n=nt({},K,((x=s==null?void 0:s.settings)==null?void 0:x.session)||{});Ce(n.ttl)&&(n.ttl=K.ttl),Ce(n.cacheTtl)&&(n.cacheTtl=K.cacheTtl),n.phone||(n.phone=K.phone),n.email||(n.email=K.email);const{handleSubmit:S,control:t,formState:f,reset:c,watch:p}=oe({defaultValues:G(ue(n),["ttl","cacheTtl","email","phone"])}),{t:l}=te(),d=p("email.enabled"),T=p("phone.enabled"),I=p("email.enableDomainBlackList"),h=p("email.enableDomainWhiteList"),{fields:g,append:j,remove:b}=De({control:t,name:"email.domainBlackList"}),{fields:y,append:i,remove:r}=De({control:t,name:"email.domainWhiteList"}),w=m(async u=>{var F;try{const{blocklet:B}=await k.updateAppSessionConfig({input:{did:a,config:ot(ue(u,!0),["phone"])}}),_=Object.assign({},K,G(((F=B==null?void 0:B.settings)==null?void 0:F.session)||{},["ttl","cacheTtl","email","phone"]));c(ue(_)),W.success(l("common.configSuccess"))}catch(B){W.error(B.message)}});return e.jsx("form",{onSubmit:S(w),children:e.jsxs($,{direction:"column",spacing:4,children:[e.jsxs($,{direction:"column",children:[e.jsx(he,{variant:"body1",mb:1,children:l("blocklet.config.session.profile")}),e.jsx(P,{disabled:!0,control:e.jsx(M,{size:"small",checked:!0}),label:l("blocklet.config.session.fullNameEnabled")}),e.jsx(P,{disabled:!0,control:e.jsx(M,{checked:!0}),label:l("blocklet.config.session.avatarEnabled")}),e.jsx(L,{name:"email.enabled",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.emailEnabled")})}),d&&e.jsxs($,{direction:"column",ml:2,children:[e.jsx(L,{name:"email.requireVerified",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.emailRequireVerified")})}),e.jsx(L,{name:"email.requireUnique",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.emailRequireUnique")})}),e.jsx(L,{name:"email.trustOauthProviders",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.emailTrustOauthProviders")})}),e.jsx(L,{name:"email.enableDomainBlackList",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.enableDomainBlackList")})}),I&&e.jsxs(v,{ml:2,children:[g.map((u,F)=>e.jsxs($,{direction:"row",alignItems:"center",my:1,maxWidth:"720px",children:[e.jsx(L,{name:`email.domainBlackList.${F}`,control:t,render:B=>e.jsx(A,{...B.field,size:"small",fullWidth:!0})}),e.jsx(re,{onClick:()=>b(F),children:e.jsx(Ie,{})})]},u.id)),e.jsx(z,{startIcon:e.jsx(qe,{}),onClick:()=>j(""),children:l("blocklet.config.session.addDomain")})]}),e.jsx(L,{name:"email.enableDomainWhiteList",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.enableDomainWhiteList")})}),h&&e.jsxs(v,{ml:2,children:[y.map((u,F)=>e.jsxs($,{direction:"row",alignItems:"center",my:1,maxWidth:"720px",children:[e.jsx(L,{name:`email.domainWhiteList.${F}`,control:t,render:B=>e.jsx(A,{...B.field,size:"small",fullWidth:!0})}),e.jsx(re,{onClick:()=>r(F),children:e.jsx(Ie,{})})]},u.id)),e.jsx(z,{startIcon:e.jsx(qe,{}),onClick:()=>i(""),children:l("blocklet.config.session.addDomain")})]})]}),e.jsxs(v,{sx:{display:"none"},children:[e.jsx(L,{name:"phone.enabled",control:t,disabled:!0,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.phoneEnabled")})}),T&&e.jsxs($,{direction:"column",ml:2,children:[e.jsx(L,{name:"phone.requireVerified",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.phoneRequireVerified")})}),e.jsx(L,{name:"phone.requireUnique",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.phoneRequireUnique")})})]})]})]}),e.jsxs($,{direction:"column",spacing:2,children:[e.jsx(he,{variant:"body1",children:l("blocklet.config.session.period")}),e.jsx(L,{name:"ttl",control:t,rules:{min:1,max:30},render:({field:u})=>e.jsx(U,{fullWidth:!0,sx:{mb:2},children:e.jsxs($,{px:3,children:[e.jsx(v,{mx:-3,children:l("blocklet.config.session.ttl",{day:u.value})}),e.jsx(Ye,{...u,defaultValue:7,step:1,marks:[{value:1,label:l("blocklet.config.session.day",{day:1})},{value:7,label:l("blocklet.config.session.days",{day:7})},{value:14,label:l("blocklet.config.session.days",{day:14})},{value:21,label:l("blocklet.config.session.days",{day:21})},{value:30,label:l("blocklet.config.session.days",{day:30})}],min:1,max:30,valueLabelDisplay:"auto",style:{maxWidth:"360px"}})]})})})]}),e.jsx(v,{children:e.jsx(z,{type:"submit",variant:"contained",disabled:!f.isDirty,children:l("oauth.save")})})]})})}var je={},St=Xe;Object.defineProperty(je,"__esModule",{value:!0});var ve=je.default=void 0,kt=St(Ve()),Tt=e;ve=je.default=(0,kt.default)((0,Tt.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2m4.24 16L12 15.45 7.77 18l1.12-4.81-3.73-3.23 4.92-.42L12 5l1.92 4.53 4.92.42-3.73 3.23z"}),"Stars");const wt={width:24,height:24,body:'<path fill="currentColor" d="M6 12.05q0 1.125.425 2.188T7.75 16.2l.25.25V15q0-.425.288-.713T9 14q.425 0 .713.288T10 15v4q0 .425-.288.713T9 20H5q-.425 0-.713-.288T4 19q0-.425.288-.713T5 18h1.75l-.4-.35q-1.3-1.15-1.825-2.625T4 12.05Q4 9.7 5.2 7.787T8.425 4.85q.35-.2.738-.025t.512.575q.125.375-.013.75t-.487.575q-1.45.8-2.313 2.213T6 12.05Zm12-.1q0-1.125-.425-2.187T16.25 7.8L16 7.55V9q0 .425-.288.713T15 10q-.425 0-.713-.288T14 9V5q0-.425.288-.713T15 4h4q.425 0 .713.288T20 5q0 .425-.288.713T19 6h-1.75l.4.35q1.225 1.225 1.788 2.663T20 11.95q0 2.35-1.2 4.263t-3.225 2.937q-.35.2-.737.025t-.513-.575q-.125-.375.013-.75t.487-.575q1.45-.8 2.313-2.212T18 11.95Z"/>'},{DEFAULT_IP_DOMAIN_SUFFIX:It,SLOT_FOR_IP_DNS_SITE:Lt,DEFAULT_DID_DOMAIN:Ct}=me,{encode:Re}=ut,Dt=k=>`${Re(k.meta.did)}-${Lt}.${It}`,qt=({did:k,didDomain:s=Ct})=>`${Re(k)}.${s}`;var Ft={getIpDnsDomainForBlocklet:Dt,getDidDomainForBlocklet:qt};const Rt=R.forwardRef((k,s)=>{var b,y;const{t:a}=R.useContext(Y),{blocklet:n}=V(),{api:S}=H(),t=ne({loadingReject:!1,loadingApprove:!1,mode:"view",show:!1,data:{},callback:Z}),f=xe(),c=((y=(b=f==null?void 0:f.transitions)==null?void 0:b.duration)==null?void 0:y.leavingScreen)||300,p=m(()=>{t.mode="view",t.data={},t.callback=Z}),l=m(()=>{t.show=!1,setTimeout(()=>{p()},c)}),d=m(i=>{t.mode="view",t.show=!0,t.data=i}),T=m((i,r=Z)=>{t.mode="approve",t.show=!0,t.data=i,t.callback=r});R.useImperativeHandle(s,()=>({open:d,close:l,approve:T}),[d,l,T]);const I=ee(()=>{if(!t.show)return[];t.data.migratedFrom=[t.data.appId,t.data.appPid];const i=["appName","appLogo","appId","appPid","migratedFrom","appDescription","appUrl","version","appliedAt","status","serverId","serverVersion"];return t.data.isMaster!==!1&&at(i,"appliedAt","status"),i.map(r=>{const w=a(`federated.info.${r}`);let o=t.data[r];if(r==="appName"&&t.data.isMaster&&(o=e.jsxs(v,{children:[e.jsx(Fe,{component:ve}),o]})),["appId","appPid","serverId"].includes(r)&&(o=e.jsx(pe,{children:o})),["appUrl"].includes(r)&&(o=e.jsx(v,{component:"a",href:o,target:"_blank",children:o})),["appLogo"].includes(r)){const x=rt(`https://${Ft.getDidDomainForBlocklet({did:t.data.appPid})}`,"/.well-known/service/blocklet/logo");try{const u=new URL(x);u.searchParams.set("imageFilter","resize"),u.searchParams.set("w","80"),u.searchParams.set("h","80"),o=e.jsx("img",{src:u.href,width:"60",height:"60",alt:t.data.appName})}catch{o=e.jsx("img",{src:x,width:"60",height:"60",alt:t.data.appName})}}return r==="status"&&(o=o&&a(`federated.status.${o}`)),r==="migratedFrom"&&(o=(t.data.migratedFrom||[]).filter(F=>![t.data.appId,t.data.appPid].includes(F)).map(F=>e.jsx(pe,{children:F}))),st(o)&&(o="-"),{name:w,value:o}})},[t.data]),h=t.mode==="approve",g=m(async()=>{try{t.loadingReject=!0,await S.auditFederatedLogin({input:{memberPid:t.data.appPid,did:n.appPid,status:"rejected"}}),l(),t==null||t.callback(!1)}finally{t.loadingReject=!1}}),j=m(async()=>{try{t.loadingApprove=!0,await S.auditFederatedLogin({input:{memberPid:t.data.appPid,did:n.appPid,status:"approved"}}),l(),t==null||t.callback(!0)}finally{t.loadingApprove=!1}});return e.jsx(ge,{open:t.show,title:a(h?"federated.approveToJoinLogin":"federated.siteDetail"),onClose:l,actions:h?e.jsxs(e.Fragment,{children:[e.jsxs(z,{color:"error",variant:"contained",onClick:g,disabled:t.loadingReject,children:[t.loadingReject?e.jsx(fe,{size:16,color:"grey"}):null,a("common.reject")]}),e.jsxs(z,{variant:"contained",onClick:j,disabled:t.loadingApprove,children:[t.loadingApprove?e.jsx(fe,{size:16,color:"grey"}):null,a("common.approve")]})]}):e.jsx(z,{variant:"outlined",onClick:l,children:a("common.close")}),children:I.map(i=>e.jsx(dt,{style:{alignItems:"flex-start"},valueComponent:"div",nameWidth:180,name:i.name,children:i.value},i.name))})}),Be=R.forwardRef((k,s)=>{var d,T;const a=xe(),n=((T=(d=a==null?void 0:a.transitions)==null?void 0:d.duration)==null?void 0:T.leavingScreen)||300,{t:S}=R.useContext(Y),t=ne({show:!1,data:{link:""}}),f=m(()=>{t.data.link=""}),c=m(()=>{t.show=!1,setTimeout(()=>{f()},n)}),p=m(({link:I})=>{t.show=!0,t.data.link=I});R.useImperativeHandle(s,()=>({open:p,close:c}),[p,c]);const l=m(()=>{Ge(t.data.link),c()});return e.jsxs(ge,{open:t.show,title:S("federated.joinFederatedLogin"),onClose:c,PaperProps:{style:{minHeight:"unset"}},actions:e.jsx(E,{color:"primary",autoFocus:!0,variant:"contained",onClick:l,children:S("common.copyAndClose")}),children:[e.jsx(v,{mb:1,children:S("federated.inviteJoinFederatedLoginDescription")}),e.jsx(v,{sx:{"& .copy-button":{display:"none !important"}},children:e.jsx($e,{language:"shell",style:{marginBottom:0},children:t.data.link})})]})});function ye({mode:k}){var X,Se,ke,Te,we;const s=R.useRef(null),a=R.useRef(null),{t:n,locale:S}=R.useContext(Y),{blocklet:t,actions:{refreshBlocklet:f}}=V(),{confirmApi:c,confirmHolder:p}=Ne(),{api:l}=H(),d=((X=t.settings.federated)==null?void 0:X.sites)||[],T=((Se=t.settings.federated)==null?void 0:Se.config)||{},I=T.isMaster!==!1,h=d.find(C=>C.appPid===t.appPid),g=ne({loadingSync:!1}),j=m(C=>{var D;(D=a.current)==null||D.open(C)}),b=m(C=>{var D;(D=a.current)==null||D.approve(C,f)}),y=m(C=>{c.open({title:n("federated.removeFederatedLogin"),content:n("federated.removeFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(D){await l.quitFederatedLogin({input:{did:t.appPid,targetDid:C.appPid}}),D()}})}),i=m(C=>{c.open({title:n("federated.disableFederatedLogin"),content:n("federated.disableFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(D){await l.auditFederatedLogin({input:{memberPid:C.appPid,did:t.appPid,status:"revoked"}}),D()}})}),r=m(C=>{c.open({title:n("federated.enableFederatedLogin"),content:n("federated.enableFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),async onConfirm(D){await l.auditFederatedLogin({input:{memberPid:C.appPid,did:t.appPid,status:"approved"}}),D()}})}),w=ee(()=>{const C=[{label:n("common.name"),name:"appName",options:{customBodyRenderLite:D=>{const q=d[D],Q=q.isMaster!==!1;return e.jsx(v,{display:"inline-block",children:e.jsxs(v,{component:"a",display:"flex",alignItems:"center",href:q.appUrl,target:"_blank",onClick:O=>{O.stopPropagation()},children:[Q&&e.jsx(Fe,{component:ve,style:{marginRight:"4px"}}),q.appName]})})}}},{label:n("common.did"),name:"appId",options:{customBodyRenderLite:D=>{const q=d[D];return e.jsx(pe,{children:q.appId})}}},{label:n("common.status"),name:"status",options:{customBodyRenderLite:D=>{const q=d[D],Q=q.isMaster!==!1;return e.jsx(v,{children:Q?"-":n(`federated.status.${q.status}`)})}}}];return I&&C.push({label:n("common.actions"),name:"actions",options:{customBodyRenderLite:D=>{const q=d[D],Q=q.isMaster!==!1;return e.jsx(v,{display:"flex",gap:1,children:Q?e.jsxs(e.Fragment,{children:[q.status==="rejected"&&e.jsx(E,{variant:"contained",color:"error",size:"small",onClick:O=>{O.stopPropagation()},children:n("federated.status.rejected")}),q.status==="revoked"&&e.jsx(E,{variant:"contained",color:"secondary",size:"small",onClick:O=>{O.stopPropagation()},children:n("federated.status.revoked")})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"contained",color:"error",size:"small",onClick:O=>{O.stopPropagation(),y(q)},children:n("federated.quitMember")},"quiteSite"),q.status==="pending"&&e.jsx(E,{variant:"contained",color:"primary",size:"small",onClick:O=>{O.stopPropagation(),b(q)},children:n("federated.status.pending")},"auditSite"),q.status==="approved"&&e.jsx(E,{variant:"contained",color:"error",size:"small",onClick:O=>{O.stopPropagation(),i(q)},style:{whiteSpace:"nowrap"},children:n("federated.revoke")},"revokeSite"),q.status==="revoked"&&e.jsx(E,{variant:"contained",color:"warning",size:"small",onClick:O=>{O.stopPropagation(),r(q)},style:{whiteSpace:"nowrap"},children:n("federated.approve")},"approveSite")]})})}}}),C},[T.appId,d,I,n]),o=ee(()=>({sort:!0,download:!1,filter:!1,print:!1,expandableRowsOnClick:!0,onRowClick(C,{dataIndex:D}){const q=d[D];j(q)}}),[]),x=m(()=>{var D;const C=t.environments.find(q=>q.key===it.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_URL);C!=null&&C.value?(D=s.current)==null||D.open({link:C.value}):W.error(n("federated.failedToGetFederatedLoginLink"))},[(we=(Te=(ke=t.site)==null?void 0:ke.domainAliases)==null?void 0:Te[0])==null?void 0:we.href]),u=m(()=>{c.open({title:n("federated.quitFederatedLogin"),content:n("federated.quitFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(C){await l.quitFederatedLogin({input:{did:t.appPid}}),C()}})}),F=m(()=>{c.open({title:n("federated.disbandFederatedLogin"),content:n("federated.disbandFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(C){await l.disbandFederatedLogin({input:{did:t.appPid}}),C()}})}),B=m(async()=>{try{g.loadingSync=!0,await Promise.all([await l.syncFederatedConfig({input:{did:t.appPid}}),He(500)]),W.success(n("common.succeeded"))}finally{g.loadingSync=!1}}),_=[];return h.status!=="pending"&&_.push(e.jsx(Qe,{title:n("federated.syncConfig"),children:e.jsx(re,{size:"small",onClick:B,disabled:g.loadingSync,sx:[{"@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}},g.loadingSync?{animation:"spin 1s linear infinite"}:{}],children:e.jsx(J,{icon:wt,style:{fontSize:24}})},"syncConfig")})),k==="master"?(_.push(e.jsx(E,{size:"small",variant:"contained",onClick:x,sx:{ml:1},children:n("federated.inviteJoinFederatedLogin")},"inviteJoinFederatedLogin")),_.push(e.jsx(E,{color:"error",size:"small",variant:"contained",onClick:F,sx:{ml:1},children:n("federated.disbandFederatedLogin")},"disbandFederatedLogin"))):_.push(e.jsx(E,{size:"small",variant:"contained",color:"error",onClick:u,sx:{ml:1},children:n("federated.quitFederatedLogin")},"quitFederatedLogin")),e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"main-table",locale:S,data:d,columns:w,customButtons:_,title:e.jsx(v,{className:"table-toolbar-left",children:n("oauth.federated")}),options:o}),p,e.jsx(Be,{ref:s}),e.jsx(Rt,{ref:a})]})}ye.propTypes={mode:N.oneOf(["member","master"])};ye.defaultProps={mode:"member"};const Bt=R.forwardRef((k,s)=>{var g,j;const{t:a}=R.useContext(Y),{api:n}=H(),{blocklet:S}=V(),t=S==null?void 0:S.appPid,f=xe(),c=((j=(g=f==null?void 0:f.transitions)==null?void 0:g.duration)==null?void 0:j.leavingScreen)||300,p=ne({loading:!1,show:!1,appUrl:"",appUrlError:"",callback:Z}),l=m(()=>{p.appUrl="",p.appUrlError="",p.callback=Z}),d=m(()=>{p.show=!1,setTimeout(()=>{l()},c)}),T=m((b=Z)=>{p.show=!0,p.callback=b});R.useImperativeHandle(s,()=>({open:T,close:d}),[T,d]);const I=m(b=>{if(!b)throw new Error(a("federated.federatedJoinAppUrlRequired"));if(!Ke(b))throw new Error(a("federated.federatedJoinAppUrlInvalid"))}),h=m(async()=>{try{I(p.appUrl),p.loading=!0;const b=await n.joinFederatedLogin({input:{did:t,appUrl:p.appUrl}});p.show=!1,d(),p==null||p.callback(b)}catch(b){p.appUrlError=b.message}finally{p.loading=!1}});return e.jsxs(ge,{open:p.show,title:a("federated.joinFederatedLogin"),onClose:d,PaperProps:{style:{minHeight:"unset"}},actions:e.jsxs(E,{color:"primary",autoFocus:!0,variant:"contained",onClick:h,disabled:p.loading,children:[p.loading?e.jsx(fe,{size:16,sx:{mr:1},color:"grey"}):null,a("common.confirm")]}),children:[e.jsx(v,{mb:1,children:a("federated.joinFederatedLoginDescription")}),e.jsx(A,{fullWidth:!0,variant:"outlined",margin:"dense",placeholder:a("federated.federatedJoinAppUrl"),label:a("federated.federatedJoinAppUrl"),value:p.appUrl,error:!!p.appUrlError,helperText:p.appUrlError||"eg: https://www.arcblock.io",onChange:b=>{p.appUrl=b.target.value}})]})});function Pt(){var c,p,l,d,T;const k=R.useRef(null),s=R.useRef(null),{t:a}=R.useContext(Y),{blocklet:n,actions:{refreshBlocklet:S}}=V(),t=m(()=>{var h,g,j,b;const I=(j=(g=(h=n.site)==null?void 0:h.domainAliases)==null?void 0:g[0])==null?void 0:j.href;if(I)try{const y=new URL(I);(b=k.current)==null||b.open({link:y.origin})}catch{W.error(a("federated.failedToGetFederatedLoginLink"))}},[(l=(p=(c=n.site)==null?void 0:c.domainAliases)==null?void 0:p[0])==null?void 0:l.href]),f=m(()=>{var I;(I=s.current)==null||I.open(()=>{S()})});if(((d=n.settings.federated)==null?void 0:d.sites.length)>0){const I=((T=n.settings.federated)==null?void 0:T.config.isMaster)!==!1;return e.jsx(ye,{mode:I?"master":"member"})}return e.jsxs(e.Fragment,{children:[e.jsxs(v,{display:"flex",flexDirection:"column",gap:2,justifyContent:"center",alignItems:"center",minHeight:"200px",children:[e.jsx(E,{variant:"contained",onClick:t,children:a("federated.inviteJoinFederatedLogin")}),e.jsx(et,{sx:{width:"150px",color:"rgba(0, 0, 0, 0.3)"},children:"OR"}),e.jsx(E,{variant:"outlined",onClick:f,children:a("federated.joinFederatedLogin")})]}),e.jsx(Be,{ref:k}),e.jsx(Bt,{ref:s})]})}function Pe({orientation:k="horizontal"}){const{t:s}=R.useContext(Y),a=mt({key:"lg"}),n=[{label:e.jsx(v,{textAlign:"center",width:"100%",children:s("oauth.commonSettings")}),value:"settings"},{label:e.jsx(v,{textAlign:"center",width:"100%",children:s("oauth.federated")}),value:"federated"},{label:e.jsx(v,{textAlign:"center",width:"100%",children:s("oauth.oauth")}),value:"oauth"},{label:e.jsx(v,{textAlign:"center",width:"100%",children:s("oauth.moreLogin")}),value:"more"}],[S,t]=R.useState(n[0].value),f=ee(()=>({oauth:e.jsx(vt,{}),federated:e.jsx(Pt,{}),more:e.jsx(v,{children:e.jsx(Ze,{children:s("oauth.comingSoon")})}),settings:e.jsx(v,{children:e.jsx(yt,{})})}),[s]);return k==="vertical"?e.jsx(At,{children:e.jsxs($,{direction:{md:"column",lg:"row"},gap:2,children:[e.jsx(v,{sx:{minWidth:"240px",flexShrink:0},children:e.jsx(Le,{tabs:n,current:S,orientation:a?"horizontal":"vertical",onChange:t,sx:{borderRight:a?0:1,height:"100%",borderColor:"divider"}})}),e.jsx(v,{sx:{flexGrow:1,minWidth:0},children:e.jsx(v,{children:f[S]})})]})}):e.jsxs(v,{children:[e.jsx(Le,{tabs:n,current:S,onChange:t}),e.jsx(v,{marginTop:"10px",children:f[S]})]})}Pe.propTypes={orientation:N.oneOf(["horizontal","vertical"])};Pe.defaultProps={orientation:"horizontal"};const At=tt.div`
|
|
1
|
+
import{u as te,V as W,bU as Ae,bV as Oe,h as ae,g as J,bQ as Ee,bR as Ue,a7 as We,a8 as Me,a6 as _e,bW as ze,a$ as Ie,m as me,r as Ve,aZ as Y,bX as pe,aj as ge,B as E,bH as $e,a1 as Ne,bY as He,a2 as Je,_ as Ke,X as Ze,ap as Le}from"./vendor-ux-did-connect-BQ3cvv_1.js";import{u as m,a as ne,f as ee,c as Ge}from"./vendor-hooks-DtYI0-rF.js";import{r as R}from"./vendor-react-DoD83n6N.js";import{j as e,a4 as v,bp as P,bl as U,M as A,x as z,E as N,T as he,I as re,ae as $,cv as Ye,a2 as Xe,e as xe,a3 as fe,$ as Fe,a5 as Qe,al as et,aa as tt}from"./vendor-mui-core-C-PhacC8.js";import{H as G,a0 as nt,b as Ce,C as ot,n as Z,aD as at,y as rt,z as st}from"./vendor-utils-CRBr0QUY.js";import{a as oe,C as L,e as De}from"./dashboard-D1IAu0pg.js";import{A as H,D as V,h as it}from"./index--QvOAcHK.js";import{S as se}from"./switch-control-DjMziEFc.js";import{K as lt}from"./keyboard-arrow-down-rounded-DadBVmpO.js";import{t as qe,y as ct}from"./vendor-arcblock-D8eCUoJY.js";import{I as dt}from"./index-CqRb1YIC.js";import{b as ut}from"./base32-CEWQZb_G.js";import{u as mt}from"./use-mobile-B_Gqv6b6.js";import"./lottie-web-B6s7dDoL.js";import"./useLocalStorage-C1_Fkr6_.js";import"./confirm-DMfA-cen.js";import"./format-error-LAoTjvJe.js";import"./PlayArrow-BEUAi9Bt.js";import"./get-safe-url-M62JolcK.js";import"./index-Tc7h84RU.js";import"./session-Clq9kJzg.js";import"./useAsyncRetry-CwtLImQi.js";import"./useAsync-BmuLIImU.js";import"./InfoOutlined-DFTm-vVr.js";import"./useSetState-BL3ktMon.js";import"./use-mobile-DudfIz3d.js";const ie={enabled:!1,domain:"",clientId:"",clientSecret:""};function pt(){var b,y,i;const{api:k}=H(),{blocklet:s}=V(),{t:a}=te(),n=(b=s==null?void 0:s.meta)==null?void 0:b.did,S=Object.assign({...ie},((i=(y=s==null?void 0:s.settings)==null?void 0:y.oauth)==null?void 0:i.auth0)||{}),{handleSubmit:t,control:f,formState:c,watch:p,reset:l}=oe({defaultValues:G(S,Object.keys(ie))}),d=p("enabled"),T=m(async r=>{var w,o;try{const{blocklet:x}=await k.configOAuth({input:{did:n,oauth:JSON.stringify({auth0:r})}}),u=Object.assign({...ie},((o=(w=x==null?void 0:x.settings)==null?void 0:w.oauth)==null?void 0:o.auth0)||{});l(u),W.success(a("oauth.saveSuccess"))}catch(x){W.error(x.message||a("oauth.saveFailed"))}}),I=m(r=>r!=null&&r.trim()?!0:a("oauth.auth0.domainDescription")),h=m(r=>r!=null&&r.trim()?!0:a("oauth.auth0.clientIdDescription")),g=m(r=>r!=null&&r.trim()?!0:a("oauth.auth0.clientSecretDescription")),j=m(()=>!0);return e.jsx(v,{children:e.jsxs("form",{onSubmit:t(T),disabled:!0,children:[e.jsx(L,{name:"enabled",control:f,render:({field:r})=>e.jsx(P,{control:e.jsx(se,{checked:r.value,style:{marginRight:"6px"},...r}),label:a("oauth.auth0.enable"),sx:{marginBottom:2,ml:1}})}),e.jsx(L,{name:"domain",control:f,rules:{validate:d?I:j},render:({field:r})=>{var w;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...r,label:a("oauth.auth0.domain"),error:!!c.errors[r.name],helperText:((w=c.errors[r.name])==null?void 0:w.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"clientId",control:f,rules:{validate:d?h:j},render:({field:r})=>{var w;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...r,error:!!c.errors[r.name],label:a("oauth.auth0.clientId"),helperText:((w=c.errors[r.name])==null?void 0:w.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"clientSecret",control:f,rules:{validate:d?g:j},render:({field:r})=>{var w;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...r,type:"password",error:!!c.errors[r.name],label:a("oauth.auth0.clientSecret"),helperText:((w=c.errors[r.name])==null?void 0:w.message)||" ",disabled:!d})})}}),e.jsx(z,{type:"submit",variant:"contained",onSubmit:t(T),disabled:!c.isDirty,children:a("oauth.save")})]})})}const le={enabled:!1,clientId:"",clientSecret:""};function ht(){var j,b,y;const{api:k}=H(),{blocklet:s}=V(),{t:a}=te(),n=(j=s==null?void 0:s.meta)==null?void 0:j.did,S=Object.assign({...le},((y=(b=s==null?void 0:s.settings)==null?void 0:b.oauth)==null?void 0:y.github)||{}),{handleSubmit:t,control:f,formState:c,watch:p,reset:l}=oe({defaultValues:G(S,Object.keys(le))}),d=p("enabled"),T=m(async i=>{var r,w;try{const{blocklet:o}=await k.configOAuth({input:{did:n,oauth:JSON.stringify({github:i})}}),x=Object.assign({...le},((w=(r=o==null?void 0:o.settings)==null?void 0:r.oauth)==null?void 0:w.github)||{});l(x),W.success(a("oauth.saveSuccess"))}catch(o){W.error(o.message||a("oauth.saveFailed"))}}),I=m(i=>i!=null&&i.trim()?!0:a("oauth.github.clientIdDescription")),h=m(i=>i!=null&&i.trim()?!0:a("oauth.github.clientSecretDescription")),g=m(()=>!0);return e.jsx(v,{children:e.jsxs("form",{onSubmit:t(T),disabled:!0,children:[e.jsx(L,{name:"enabled",control:f,render:({field:i})=>e.jsx(P,{control:e.jsx(se,{checked:i.value,style:{marginRight:"6px"},...i}),label:a("oauth.github.enable"),sx:{marginBottom:2,ml:1}})}),e.jsx(L,{name:"clientId",control:f,rules:{validate:d?I:g},render:({field:i})=>{var r;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...i,error:!!c.errors[i.name],label:a("oauth.github.clientId"),helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"clientSecret",control:f,rules:{validate:d?h:g},render:({field:i})=>{var r;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...i,type:"password",label:a("oauth.github.clientSecret"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}}),e.jsx(z,{type:"submit",variant:"contained",onSubmit:t(T),disabled:!c.isDirty,children:a("oauth.save")})]})})}const ce={enabled:!1,clientId:"",clientSecret:""};function ft(){var j,b,y;const{api:k}=H(),{blocklet:s}=V(),{t:a}=te(),n=(j=s==null?void 0:s.meta)==null?void 0:j.did,S=Object.assign({...ce},((y=(b=s==null?void 0:s.settings)==null?void 0:b.oauth)==null?void 0:y.google)||{}),{handleSubmit:t,control:f,formState:c,watch:p,reset:l}=oe({defaultValues:G(S,Object.keys(ce))}),d=p("enabled"),T=m(async i=>{var r,w;try{const{blocklet:o}=await k.configOAuth({input:{did:n,oauth:JSON.stringify({google:i})}}),x=Object.assign({...ce},((w=(r=o==null?void 0:o.settings)==null?void 0:r.oauth)==null?void 0:w.google)||{});l(x),W.success(a("oauth.saveSuccess"))}catch(o){W.error(o.message||a("oauth.saveFailed"))}}),I=m(i=>i!=null&&i.trim()?!0:a("oauth.google.clientIdDescription")),h=m(i=>i!=null&&i.trim()?!0:a("oauth.google.clientSecretDescription")),g=m(()=>!0);return e.jsx(v,{children:e.jsxs("form",{onSubmit:t(T),disabled:!0,children:[e.jsx(L,{name:"enabled",control:f,render:({field:i})=>e.jsx(P,{control:e.jsx(se,{checked:i.value,style:{marginRight:"6px"},...i}),label:a("oauth.google.enable"),sx:{marginBottom:2,ml:1}})}),e.jsx(L,{name:"clientId",control:f,rules:{validate:d?I:g},render:({field:i})=>{var r;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...i,error:!!c.errors[i.name],label:a("oauth.google.clientId"),helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"clientSecret",control:f,rules:{validate:d?h:g},render:({field:i})=>{var r;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...i,type:"password",label:a("oauth.google.clientSecret"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}}),e.jsx(z,{type:"submit",variant:"contained",onSubmit:t(T),disabled:!c.isDirty,children:a("oauth.save")})]})})}const de={enabled:!1,teamId:"",serviceId:"",keyId:"",authKey:"",bundleId:""};function gt(){var i,r,w;const{api:k}=H(),{blocklet:s}=V(),{t:a}=te(),n=(i=s==null?void 0:s.meta)==null?void 0:i.did,S=Object.assign({...de},((w=(r=s==null?void 0:s.settings)==null?void 0:r.oauth)==null?void 0:w.apple)||{}),{handleSubmit:t,control:f,formState:c,watch:p,reset:l}=oe({defaultValues:G(S,Object.keys(de))}),d=p("enabled"),T=m(async o=>{var x,u;try{const{blocklet:F}=await k.configOAuth({input:{did:n,oauth:JSON.stringify({apple:o})}}),B=Object.assign({...de},((u=(x=F==null?void 0:F.settings)==null?void 0:x.oauth)==null?void 0:u.apple)||{});l(B),W.success(a("oauth.saveSuccess"))}catch(F){W.error(F.message||a("oauth.saveFailed"))}}),I=m(o=>o!=null&&o.trim()?!0:a("oauth.apple.teamIdDescription")),h=m(o=>o!=null&&o.trim()?!0:a("oauth.apple.serviceIdDescription")),g=m(o=>o!=null&&o.trim()?!0:a("oauth.apple.keyIdDescription")),j=m(o=>o!=null&&o.trim()?!0:a("oauth.apple.authKeyDescription")),b=m(o=>o!=null&&o.trim()?!0:a("oauth.apple.bundleIdDescription")),y=m(()=>!0);return e.jsx(v,{children:e.jsxs("form",{onSubmit:t(T),disabled:!0,children:[e.jsx(L,{name:"enabled",control:f,render:({field:o})=>e.jsx(P,{control:e.jsx(se,{checked:o.value,style:{marginRight:"6px"},...o}),label:a("oauth.apple.enable"),sx:{marginBottom:2,ml:1}})}),e.jsx(L,{name:"teamId",control:f,rules:{validate:d?I:y},render:({field:o})=>{var x;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...o,error:!!c.errors[o.name],label:a("oauth.apple.teamId"),helperText:((x=c.errors[o.name])==null?void 0:x.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"bundleId",control:f,rules:{validate:d?b:y},render:({field:o})=>{var x;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...o,error:!!c.errors[o.name],label:a("oauth.apple.bundleId"),helperText:((x=c.errors[o.name])==null?void 0:x.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"serviceId",control:f,rules:{validate:d?h:y},render:({field:o})=>{var x;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...o,error:!!c.errors[o.name],label:a("oauth.apple.serviceId"),helperText:((x=c.errors[o.name])==null?void 0:x.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"keyId",control:f,rules:{validate:d?g:y},render:({field:o})=>{var x;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...o,error:!!c.errors[o.name],label:a("oauth.apple.keyId"),helperText:((x=c.errors[o.name])==null?void 0:x.message)||" ",disabled:!d})})}}),e.jsx(L,{name:"authKey",control:f,rules:{validate:d?j:y},render:({field:o})=>{var x;return e.jsx(U,{fullWidth:!0,children:e.jsx(A,{...o,type:"password",multiline:!0,rows:4,label:a("oauth.apple.authKey"),error:!!c.errors[o.name],helperText:((x=c.errors[o.name])==null?void 0:x.message)||" ",disabled:!d})})}}),e.jsx(z,{type:"submit",variant:"contained",onSubmit:t(T),disabled:!c.isDirty,children:a("oauth.save")})]})})}const xt={width:24,height:24,body:'<path fill="currentColor" d="M9 20q-.825 0-1.413-.588T7 18q0-.825.588-1.413T9 16q.825 0 1.413.588T11 18q0 .825-.588 1.413T9 20Zm6 0q-.825 0-1.413-.588T13 18q0-.825.588-1.413T15 16q.825 0 1.413.588T17 18q0 .825-.588 1.413T15 20Zm-6-6q-.825 0-1.413-.588T7 12q0-.825.588-1.413T9 10q.825 0 1.413.588T11 12q0 .825-.588 1.413T9 14Zm6 0q-.825 0-1.413-.588T13 12q0-.825.588-1.413T15 10q.825 0 1.413.588T17 12q0 .825-.588 1.413T15 14ZM9 8q-.825 0-1.413-.588T7 6q0-.825.588-1.413T9 4q.825 0 1.413.588T11 6q0 .825-.588 1.413T9 8Zm6 0q-.825 0-1.413-.588T13 6q0-.825.588-1.413T15 4q.825 0 1.413.588T17 6q0 .825-.588 1.413T15 8Z"/>'};function be({title:k,id:s,children:a,index:n,onMove:S,defaultExpand:t,onEnd:f}){const[c,p]=R.useState(t),l=R.useRef(null),d=R.useRef(null),[{handlerId:T},I]=Ae({accept:"dragItem",collect(y){return{handlerId:y.getHandlerId()}},hover(y,i){var _,X;if(!l.current)return;const r=y.index,w=n;if(r===w)return;const o=(_=l.current)==null?void 0:_.getBoundingClientRect(),x=(X=d.current)==null?void 0:X.getBoundingClientRect(),u=(x.bottom-x.top)/2,B=i.getClientOffset().y-o.top;r<w&&B<u||r>w&&B>u||(S(r,w),y.index=w)}}),[{isDragging:h},g]=Oe({item:{index:n,type:"dragItem"},collect:y=>({isDragging:y.isDragging()}),end:f});g(d),I(l);const j=h?.5:1,b=m(y=>{y.preventDefault(),y.stopPropagation(),p(!c)});return e.jsxs(v,{ref:l,sx:{borderBottom:`1px solid ${ae.lineBorderStrong}`},children:[e.jsx(v,{sx:{cursor:"pointer","&:hover":{backgroundColor:ae.backgroundsBgSubtileHover},borderRadius:2},ref:d,"data-handler-id":T,children:e.jsxs(v,{sx:{py:1.5,px:1,opacity:j,display:"flex",alignItems:"center",gap:.5},draggable:!1,onClick:b,children:[e.jsx(v,{sx:{pointerEvents:"auto",cursor:"grab","&:active":{cursor:"grabbing"},fontSize:0,color:ae.textMuted,"&:hover":{color:ae.textSubtitle}},children:e.jsx(J,{fontSize:20,icon:xt})}),e.jsx(he,{sx:{flex:1},children:k}),e.jsx(re,{size:"small",sx:{pointerEvents:"auto",transform:c?"":"rotate(180deg)",transition:"transform 0.3s ease"},children:e.jsx(J,{icon:lt,style:{transform:"scale(1.5)"}})})]})}),e.jsx(v,{sx:{pl:4,py:1,display:c?"block":"none"},children:a})]})}be.propTypes={title:N.string.isRequired,id:N.string.isRequired,children:N.node.isRequired,index:N.number.isRequired,onMove:N.func.isRequired,onEnd:N.func.isRequired,defaultExpand:N.bool};be.defaultProps={defaultExpand:!0};const bt=[{name:"github",title:"GitHub",icon:e.jsx(J,{icon:We}),component:e.jsx(ht,{})},{name:"google",title:"Google",icon:e.jsx(J,{icon:Me}),component:e.jsx(ft,{})},{name:"apple",title:"Apple",icon:e.jsx(J,{icon:_e}),component:e.jsx(gt,{})},{name:"auth0",title:"Auth0",icon:e.jsx(J,{icon:ze}),component:e.jsx(pt,{})}],jt=["github","google","apple","auth0"];function vt(){var T,I;const{api:k}=H(),{blocklet:s}=V(),a=(T=s==null?void 0:s.meta)==null?void 0:T.did,n=((I=s==null?void 0:s.settings)==null?void 0:I.oauth)||{},S=Object.keys(n).sort((h,g)=>{var j,b,y;return((j=n[h])==null?void 0:j.order)!==void 0&&((b=n[g])==null?void 0:b.order)!==void 0?n[h].order-n[g].order:((y=n[h])==null?void 0:y.order)!==void 0?-1:1});for(const h of jt)S.includes(h)||S.push(h);const t=ne(S.reduce((h,g,j)=>Object.assign(h,{[g]:j}),{})),f=ee(()=>{const h=[...bt];return h.sort((g,j)=>t[g.name]-t[j.name]),h},[t.auth0,t.github,t.google]),c={};typeof window<"u"&&(c.context=window);const p=m(async h=>{const g={};Object.keys(h).forEach(j=>{g[j]={order:h[j]}}),await k.configOAuth({input:{did:a,oauth:JSON.stringify(g)}})}),l=m((h,g)=>{const j=f[h],b=f[g];t[j.name]=g,t[b.name]=h}),d=m(async()=>{await p(t)});return e.jsx(v,{children:e.jsx(Ee,{backend:Ue,...c,children:f.map((h,g)=>e.jsx(be,{index:g,id:h.name,title:h.title,icon:h.icon,onMove:l,onEnd:d,defaultExpand:h.enabled,children:h.component},h.name))})})}const K={ttl:me.SESSION_TTL,cacheTtl:me.SESSION_CACHE_TTL,email:{enabled:!1,requireVerified:!1,requireUnique:!1,trustOauthProviders:!1,trustedIssuers:[],enableDomainBlackList:!1,domainBlackList:[],enableDomainWhiteList:!1,domainWhiteList:[]},phone:{enabled:!1,requireVerified:!1,requireUnique:!1,regionBlackList:[],trustedIssuers:[]}};function M(k){return e.jsx(ct,{...k,sx:{marginLeft:1,marginRight:.5,transform:"scale(0.75)"}})}function ue(k,s=!1){const a=s?k.ttl*86400:k.ttl/86400;return{...k,ttl:a}}function yt(){var o,x;const{api:k}=H(),{blocklet:s}=V(),a=(o=s==null?void 0:s.meta)==null?void 0:o.did,n=nt({},K,((x=s==null?void 0:s.settings)==null?void 0:x.session)||{});Ce(n.ttl)&&(n.ttl=K.ttl),Ce(n.cacheTtl)&&(n.cacheTtl=K.cacheTtl),n.phone||(n.phone=K.phone),n.email||(n.email=K.email);const{handleSubmit:S,control:t,formState:f,reset:c,watch:p}=oe({defaultValues:G(ue(n),["ttl","cacheTtl","email","phone"])}),{t:l}=te(),d=p("email.enabled"),T=p("phone.enabled"),I=p("email.enableDomainBlackList"),h=p("email.enableDomainWhiteList"),{fields:g,append:j,remove:b}=De({control:t,name:"email.domainBlackList"}),{fields:y,append:i,remove:r}=De({control:t,name:"email.domainWhiteList"}),w=m(async u=>{var F;try{const{blocklet:B}=await k.updateAppSessionConfig({input:{did:a,config:ot(ue(u,!0),["phone"])}}),_=Object.assign({},K,G(((F=B==null?void 0:B.settings)==null?void 0:F.session)||{},["ttl","cacheTtl","email","phone"]));c(ue(_)),W.success(l("common.configSuccess"))}catch(B){W.error(B.message)}});return e.jsx("form",{onSubmit:S(w),children:e.jsxs($,{direction:"column",spacing:4,children:[e.jsxs($,{direction:"column",children:[e.jsx(he,{variant:"body1",mb:1,children:l("blocklet.config.session.profile")}),e.jsx(P,{disabled:!0,control:e.jsx(M,{size:"small",checked:!0}),label:l("blocklet.config.session.fullNameEnabled")}),e.jsx(P,{disabled:!0,control:e.jsx(M,{checked:!0}),label:l("blocklet.config.session.avatarEnabled")}),e.jsx(L,{name:"email.enabled",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.emailEnabled")})}),d&&e.jsxs($,{direction:"column",ml:2,children:[e.jsx(L,{name:"email.requireVerified",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.emailRequireVerified")})}),e.jsx(L,{name:"email.requireUnique",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.emailRequireUnique")})}),e.jsx(L,{name:"email.trustOauthProviders",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.emailTrustOauthProviders")})}),e.jsx(L,{name:"email.enableDomainBlackList",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.enableDomainBlackList")})}),I&&e.jsxs(v,{ml:2,children:[g.map((u,F)=>e.jsxs($,{direction:"row",alignItems:"center",my:1,maxWidth:"720px",children:[e.jsx(L,{name:`email.domainBlackList.${F}`,control:t,render:B=>e.jsx(A,{...B.field,size:"small",fullWidth:!0})}),e.jsx(re,{onClick:()=>b(F),children:e.jsx(Ie,{})})]},u.id)),e.jsx(z,{startIcon:e.jsx(qe,{}),onClick:()=>j(""),children:l("blocklet.config.session.addDomain")})]}),e.jsx(L,{name:"email.enableDomainWhiteList",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.enableDomainWhiteList")})}),h&&e.jsxs(v,{ml:2,children:[y.map((u,F)=>e.jsxs($,{direction:"row",alignItems:"center",my:1,maxWidth:"720px",children:[e.jsx(L,{name:`email.domainWhiteList.${F}`,control:t,render:B=>e.jsx(A,{...B.field,size:"small",fullWidth:!0})}),e.jsx(re,{onClick:()=>r(F),children:e.jsx(Ie,{})})]},u.id)),e.jsx(z,{startIcon:e.jsx(qe,{}),onClick:()=>i(""),children:l("blocklet.config.session.addDomain")})]})]}),e.jsxs(v,{sx:{display:"none"},children:[e.jsx(L,{name:"phone.enabled",control:t,disabled:!0,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.phoneEnabled")})}),T&&e.jsxs($,{direction:"column",ml:2,children:[e.jsx(L,{name:"phone.requireVerified",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.phoneRequireVerified")})}),e.jsx(L,{name:"phone.requireUnique",control:t,render:({field:u})=>e.jsx(P,{control:e.jsx(M,{...u,checked:u.value}),label:l("blocklet.config.session.phoneRequireUnique")})})]})]})]}),e.jsxs($,{direction:"column",spacing:2,children:[e.jsx(he,{variant:"body1",children:l("blocklet.config.session.period")}),e.jsx(L,{name:"ttl",control:t,rules:{min:1,max:30},render:({field:u})=>e.jsx(U,{fullWidth:!0,sx:{mb:2},children:e.jsxs($,{px:3,children:[e.jsx(v,{mx:-3,children:l("blocklet.config.session.ttl",{day:u.value})}),e.jsx(Ye,{...u,defaultValue:7,step:1,marks:[{value:1,label:l("blocklet.config.session.day",{day:1})},{value:7,label:l("blocklet.config.session.days",{day:7})},{value:14,label:l("blocklet.config.session.days",{day:14})},{value:21,label:l("blocklet.config.session.days",{day:21})},{value:30,label:l("blocklet.config.session.days",{day:30})}],min:1,max:30,valueLabelDisplay:"auto",style:{maxWidth:"360px"}})]})})})]}),e.jsx(v,{children:e.jsx(z,{type:"submit",variant:"contained",disabled:!f.isDirty,children:l("oauth.save")})})]})})}var je={},St=Xe;Object.defineProperty(je,"__esModule",{value:!0});var ve=je.default=void 0,kt=St(Ve()),Tt=e;ve=je.default=(0,kt.default)((0,Tt.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2m4.24 16L12 15.45 7.77 18l1.12-4.81-3.73-3.23 4.92-.42L12 5l1.92 4.53 4.92.42-3.73 3.23z"}),"Stars");const wt={width:24,height:24,body:'<path fill="currentColor" d="M6 12.05q0 1.125.425 2.188T7.75 16.2l.25.25V15q0-.425.288-.713T9 14q.425 0 .713.288T10 15v4q0 .425-.288.713T9 20H5q-.425 0-.713-.288T4 19q0-.425.288-.713T5 18h1.75l-.4-.35q-1.3-1.15-1.825-2.625T4 12.05Q4 9.7 5.2 7.787T8.425 4.85q.35-.2.738-.025t.512.575q.125.375-.013.75t-.487.575q-1.45.8-2.313 2.213T6 12.05Zm12-.1q0-1.125-.425-2.187T16.25 7.8L16 7.55V9q0 .425-.288.713T15 10q-.425 0-.713-.288T14 9V5q0-.425.288-.713T15 4h4q.425 0 .713.288T20 5q0 .425-.288.713T19 6h-1.75l.4.35q1.225 1.225 1.788 2.663T20 11.95q0 2.35-1.2 4.263t-3.225 2.937q-.35.2-.737.025t-.513-.575q-.125-.375.013-.75t.487-.575q1.45-.8 2.313-2.212T18 11.95Z"/>'},{DEFAULT_IP_DOMAIN_SUFFIX:It,SLOT_FOR_IP_DNS_SITE:Lt,DEFAULT_DID_DOMAIN:Ct}=me,{encode:Re}=ut,Dt=k=>`${Re(k.meta.did)}-${Lt}.${It}`,qt=({did:k,didDomain:s=Ct})=>`${Re(k)}.${s}`;var Ft={getIpDnsDomainForBlocklet:Dt,getDidDomainForBlocklet:qt};const Rt=R.forwardRef((k,s)=>{var b,y;const{t:a}=R.useContext(Y),{blocklet:n}=V(),{api:S}=H(),t=ne({loadingReject:!1,loadingApprove:!1,mode:"view",show:!1,data:{},callback:Z}),f=xe(),c=((y=(b=f==null?void 0:f.transitions)==null?void 0:b.duration)==null?void 0:y.leavingScreen)||300,p=m(()=>{t.mode="view",t.data={},t.callback=Z}),l=m(()=>{t.show=!1,setTimeout(()=>{p()},c)}),d=m(i=>{t.mode="view",t.show=!0,t.data=i}),T=m((i,r=Z)=>{t.mode="approve",t.show=!0,t.data=i,t.callback=r});R.useImperativeHandle(s,()=>({open:d,close:l,approve:T}),[d,l,T]);const I=ee(()=>{if(!t.show)return[];t.data.migratedFrom=[t.data.appId,t.data.appPid];const i=["appName","appLogo","appId","appPid","migratedFrom","appDescription","appUrl","version","appliedAt","status","serverId","serverVersion"];return t.data.isMaster!==!1&&at(i,"appliedAt","status"),i.map(r=>{const w=a(`federated.info.${r}`);let o=t.data[r];if(r==="appName"&&t.data.isMaster&&(o=e.jsxs(v,{children:[e.jsx(Fe,{component:ve}),o]})),["appId","appPid","serverId"].includes(r)&&(o=e.jsx(pe,{children:o})),["appUrl"].includes(r)&&(o=e.jsx(v,{component:"a",href:o,target:"_blank",children:o})),["appLogo"].includes(r)){const x=rt(`https://${Ft.getDidDomainForBlocklet({did:t.data.appPid})}`,"/.well-known/service/blocklet/logo");try{const u=new URL(x);u.searchParams.set("imageFilter","resize"),u.searchParams.set("w","80"),u.searchParams.set("h","80"),o=e.jsx("img",{src:u.href,width:"60",height:"60",alt:t.data.appName})}catch{o=e.jsx("img",{src:x,width:"60",height:"60",alt:t.data.appName})}}return r==="status"&&(o=o&&a(`federated.status.${o}`)),r==="migratedFrom"&&(o=(t.data.migratedFrom||[]).filter(F=>![t.data.appId,t.data.appPid].includes(F)).map(F=>e.jsx(pe,{children:F}))),st(o)&&(o="-"),{name:w,value:o}})},[t.data]),h=t.mode==="approve",g=m(async()=>{try{t.loadingReject=!0,await S.auditFederatedLogin({input:{memberPid:t.data.appPid,did:n.appPid,status:"rejected"}}),l(),t==null||t.callback(!1)}finally{t.loadingReject=!1}}),j=m(async()=>{try{t.loadingApprove=!0,await S.auditFederatedLogin({input:{memberPid:t.data.appPid,did:n.appPid,status:"approved"}}),l(),t==null||t.callback(!0)}finally{t.loadingApprove=!1}});return e.jsx(ge,{open:t.show,title:a(h?"federated.approveToJoinLogin":"federated.siteDetail"),onClose:l,actions:h?e.jsxs(e.Fragment,{children:[e.jsxs(z,{color:"error",variant:"contained",onClick:g,disabled:t.loadingReject,children:[t.loadingReject?e.jsx(fe,{size:16,color:"grey"}):null,a("common.reject")]}),e.jsxs(z,{variant:"contained",onClick:j,disabled:t.loadingApprove,children:[t.loadingApprove?e.jsx(fe,{size:16,color:"grey"}):null,a("common.approve")]})]}):e.jsx(z,{variant:"outlined",onClick:l,children:a("common.close")}),children:I.map(i=>e.jsx(dt,{style:{alignItems:"flex-start"},valueComponent:"div",nameWidth:180,name:i.name,children:i.value},i.name))})}),Be=R.forwardRef((k,s)=>{var d,T;const a=xe(),n=((T=(d=a==null?void 0:a.transitions)==null?void 0:d.duration)==null?void 0:T.leavingScreen)||300,{t:S}=R.useContext(Y),t=ne({show:!1,data:{link:""}}),f=m(()=>{t.data.link=""}),c=m(()=>{t.show=!1,setTimeout(()=>{f()},n)}),p=m(({link:I})=>{t.show=!0,t.data.link=I});R.useImperativeHandle(s,()=>({open:p,close:c}),[p,c]);const l=m(()=>{Ge(t.data.link),c()});return e.jsxs(ge,{open:t.show,title:S("federated.joinFederatedLogin"),onClose:c,PaperProps:{style:{minHeight:"unset"}},actions:e.jsx(E,{color:"primary",autoFocus:!0,variant:"contained",onClick:l,children:S("common.copyAndClose")}),children:[e.jsx(v,{mb:1,children:S("federated.inviteJoinFederatedLoginDescription")}),e.jsx(v,{sx:{"& .copy-button":{display:"none !important"}},children:e.jsx($e,{language:"shell",style:{marginBottom:0},children:t.data.link})})]})});function ye({mode:k}){var X,Se,ke,Te,we;const s=R.useRef(null),a=R.useRef(null),{t:n,locale:S}=R.useContext(Y),{blocklet:t,actions:{refreshBlocklet:f}}=V(),{confirmApi:c,confirmHolder:p}=Ne(),{api:l}=H(),d=((X=t.settings.federated)==null?void 0:X.sites)||[],T=((Se=t.settings.federated)==null?void 0:Se.config)||{},I=T.isMaster!==!1,h=d.find(C=>C.appPid===t.appPid),g=ne({loadingSync:!1}),j=m(C=>{var D;(D=a.current)==null||D.open(C)}),b=m(C=>{var D;(D=a.current)==null||D.approve(C,f)}),y=m(C=>{c.open({title:n("federated.removeFederatedLogin"),content:n("federated.removeFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(D){await l.quitFederatedLogin({input:{did:t.appPid,targetDid:C.appPid}}),D()}})}),i=m(C=>{c.open({title:n("federated.disableFederatedLogin"),content:n("federated.disableFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(D){await l.auditFederatedLogin({input:{memberPid:C.appPid,did:t.appPid,status:"revoked"}}),D()}})}),r=m(C=>{c.open({title:n("federated.enableFederatedLogin"),content:n("federated.enableFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),async onConfirm(D){await l.auditFederatedLogin({input:{memberPid:C.appPid,did:t.appPid,status:"approved"}}),D()}})}),w=ee(()=>{const C=[{label:n("common.name"),name:"appName",options:{customBodyRenderLite:D=>{const q=d[D],Q=q.isMaster!==!1;return e.jsx(v,{display:"inline-block",children:e.jsxs(v,{component:"a",display:"flex",alignItems:"center",href:q.appUrl,target:"_blank",onClick:O=>{O.stopPropagation()},children:[Q&&e.jsx(Fe,{component:ve,style:{marginRight:"4px"}}),q.appName]})})}}},{label:n("common.did"),name:"appId",options:{customBodyRenderLite:D=>{const q=d[D];return e.jsx(pe,{children:q.appId})}}},{label:n("common.status"),name:"status",options:{customBodyRenderLite:D=>{const q=d[D],Q=q.isMaster!==!1;return e.jsx(v,{children:Q?"-":n(`federated.status.${q.status}`)})}}}];return I&&C.push({label:n("common.actions"),name:"actions",options:{customBodyRenderLite:D=>{const q=d[D],Q=q.isMaster!==!1;return e.jsx(v,{display:"flex",gap:1,children:Q?e.jsxs(e.Fragment,{children:[q.status==="rejected"&&e.jsx(E,{variant:"contained",color:"error",size:"small",onClick:O=>{O.stopPropagation()},children:n("federated.status.rejected")}),q.status==="revoked"&&e.jsx(E,{variant:"contained",color:"secondary",size:"small",onClick:O=>{O.stopPropagation()},children:n("federated.status.revoked")})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"contained",color:"error",size:"small",onClick:O=>{O.stopPropagation(),y(q)},children:n("federated.quitMember")},"quiteSite"),q.status==="pending"&&e.jsx(E,{variant:"contained",color:"primary",size:"small",onClick:O=>{O.stopPropagation(),b(q)},children:n("federated.status.pending")},"auditSite"),q.status==="approved"&&e.jsx(E,{variant:"contained",color:"error",size:"small",onClick:O=>{O.stopPropagation(),i(q)},style:{whiteSpace:"nowrap"},children:n("federated.revoke")},"revokeSite"),q.status==="revoked"&&e.jsx(E,{variant:"contained",color:"warning",size:"small",onClick:O=>{O.stopPropagation(),r(q)},style:{whiteSpace:"nowrap"},children:n("federated.approve")},"approveSite")]})})}}}),C},[T.appId,d,I,n]),o=ee(()=>({sort:!0,download:!1,filter:!1,print:!1,expandableRowsOnClick:!0,onRowClick(C,{dataIndex:D}){const q=d[D];j(q)}}),[]),x=m(()=>{var D;const C=t.environments.find(q=>q.key===it.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_URL);C!=null&&C.value?(D=s.current)==null||D.open({link:C.value}):W.error(n("federated.failedToGetFederatedLoginLink"))},[(we=(Te=(ke=t.site)==null?void 0:ke.domainAliases)==null?void 0:Te[0])==null?void 0:we.href]),u=m(()=>{c.open({title:n("federated.quitFederatedLogin"),content:n("federated.quitFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(C){await l.quitFederatedLogin({input:{did:t.appPid}}),C()}})}),F=m(()=>{c.open({title:n("federated.disbandFederatedLogin"),content:n("federated.disbandFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(C){await l.disbandFederatedLogin({input:{did:t.appPid}}),C()}})}),B=m(async()=>{try{g.loadingSync=!0,await Promise.all([await l.syncFederatedConfig({input:{did:t.appPid}}),He(500)]),W.success(n("common.succeeded"))}finally{g.loadingSync=!1}}),_=[];return h.status!=="pending"&&_.push(e.jsx(Qe,{title:n("federated.syncConfig"),children:e.jsx(re,{size:"small",onClick:B,disabled:g.loadingSync,sx:[{"@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}},g.loadingSync?{animation:"spin 1s linear infinite"}:{}],children:e.jsx(J,{icon:wt,style:{fontSize:24}})},"syncConfig")})),k==="master"?(_.push(e.jsx(E,{size:"small",variant:"contained",onClick:x,sx:{ml:1},children:n("federated.inviteJoinFederatedLogin")},"inviteJoinFederatedLogin")),_.push(e.jsx(E,{color:"error",size:"small",variant:"contained",onClick:F,sx:{ml:1},children:n("federated.disbandFederatedLogin")},"disbandFederatedLogin"))):_.push(e.jsx(E,{size:"small",variant:"contained",color:"error",onClick:u,sx:{ml:1},children:n("federated.quitFederatedLogin")},"quitFederatedLogin")),e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"main-table",locale:S,data:d,columns:w,customButtons:_,title:e.jsx(v,{className:"table-toolbar-left",children:n("oauth.federated")}),options:o}),p,e.jsx(Be,{ref:s}),e.jsx(Rt,{ref:a})]})}ye.propTypes={mode:N.oneOf(["member","master"])};ye.defaultProps={mode:"member"};const Bt=R.forwardRef((k,s)=>{var g,j;const{t:a}=R.useContext(Y),{api:n}=H(),{blocklet:S}=V(),t=S==null?void 0:S.appPid,f=xe(),c=((j=(g=f==null?void 0:f.transitions)==null?void 0:g.duration)==null?void 0:j.leavingScreen)||300,p=ne({loading:!1,show:!1,appUrl:"",appUrlError:"",callback:Z}),l=m(()=>{p.appUrl="",p.appUrlError="",p.callback=Z}),d=m(()=>{p.show=!1,setTimeout(()=>{l()},c)}),T=m((b=Z)=>{p.show=!0,p.callback=b});R.useImperativeHandle(s,()=>({open:T,close:d}),[T,d]);const I=m(b=>{if(!b)throw new Error(a("federated.federatedJoinAppUrlRequired"));if(!Ke(b))throw new Error(a("federated.federatedJoinAppUrlInvalid"))}),h=m(async()=>{try{I(p.appUrl),p.loading=!0;const b=await n.joinFederatedLogin({input:{did:t,appUrl:p.appUrl}});p.show=!1,d(),p==null||p.callback(b)}catch(b){p.appUrlError=b.message}finally{p.loading=!1}});return e.jsxs(ge,{open:p.show,title:a("federated.joinFederatedLogin"),onClose:d,PaperProps:{style:{minHeight:"unset"}},actions:e.jsxs(E,{color:"primary",autoFocus:!0,variant:"contained",onClick:h,disabled:p.loading,children:[p.loading?e.jsx(fe,{size:16,sx:{mr:1},color:"grey"}):null,a("common.confirm")]}),children:[e.jsx(v,{mb:1,children:a("federated.joinFederatedLoginDescription")}),e.jsx(A,{fullWidth:!0,variant:"outlined",margin:"dense",placeholder:a("federated.federatedJoinAppUrl"),label:a("federated.federatedJoinAppUrl"),value:p.appUrl,error:!!p.appUrlError,helperText:p.appUrlError||"eg: https://www.arcblock.io",onChange:b=>{p.appUrl=b.target.value}})]})});function Pt(){var c,p,l,d,T;const k=R.useRef(null),s=R.useRef(null),{t:a}=R.useContext(Y),{blocklet:n,actions:{refreshBlocklet:S}}=V(),t=m(()=>{var h,g,j,b;const I=(j=(g=(h=n.site)==null?void 0:h.domainAliases)==null?void 0:g[0])==null?void 0:j.href;if(I)try{const y=new URL(I);(b=k.current)==null||b.open({link:y.origin})}catch{W.error(a("federated.failedToGetFederatedLoginLink"))}},[(l=(p=(c=n.site)==null?void 0:c.domainAliases)==null?void 0:p[0])==null?void 0:l.href]),f=m(()=>{var I;(I=s.current)==null||I.open(()=>{S()})});if(((d=n.settings.federated)==null?void 0:d.sites.length)>0){const I=((T=n.settings.federated)==null?void 0:T.config.isMaster)!==!1;return e.jsx(ye,{mode:I?"master":"member"})}return e.jsxs(e.Fragment,{children:[e.jsxs(v,{display:"flex",flexDirection:"column",gap:2,justifyContent:"center",alignItems:"center",minHeight:"200px",children:[e.jsx(E,{variant:"contained",onClick:t,children:a("federated.inviteJoinFederatedLogin")}),e.jsx(et,{sx:{width:"150px",color:"rgba(0, 0, 0, 0.3)"},children:"OR"}),e.jsx(E,{variant:"outlined",onClick:f,children:a("federated.joinFederatedLogin")})]}),e.jsx(Be,{ref:k}),e.jsx(Bt,{ref:s})]})}function Pe({orientation:k="horizontal"}){const{t:s}=R.useContext(Y),a=mt({key:"lg"}),n=[{label:e.jsx(v,{textAlign:"center",width:"100%",children:s("oauth.commonSettings")}),value:"settings"},{label:e.jsx(v,{textAlign:"center",width:"100%",children:s("oauth.federated")}),value:"federated"},{label:e.jsx(v,{textAlign:"center",width:"100%",children:s("oauth.oauth")}),value:"oauth"},{label:e.jsx(v,{textAlign:"center",width:"100%",children:s("oauth.moreLogin")}),value:"more"}],[S,t]=R.useState(n[0].value),f=ee(()=>({oauth:e.jsx(vt,{}),federated:e.jsx(Pt,{}),more:e.jsx(v,{children:e.jsx(Ze,{children:s("oauth.comingSoon")})}),settings:e.jsx(v,{children:e.jsx(yt,{})})}),[s]);return k==="vertical"?e.jsx(At,{children:e.jsxs($,{direction:{md:"column",lg:"row"},gap:2,children:[e.jsx(v,{sx:{minWidth:"240px",flexShrink:0},children:e.jsx(Le,{tabs:n,current:S,orientation:a?"horizontal":"vertical",onChange:t,sx:{borderRight:a?0:1,height:"100%",borderColor:"divider"}})}),e.jsx(v,{sx:{flexGrow:1,minWidth:0},children:e.jsx(v,{children:f[S]})})]})}):e.jsxs(v,{children:[e.jsx(Le,{tabs:n,current:S,onChange:t}),e.jsx(v,{marginTop:"10px",children:f[S]})]})}Pe.propTypes={orientation:N.oneOf(["horizontal","vertical"])};Pe.defaultProps={orientation:"horizontal"};const At=tt.div`
|
|
2
2
|
.MuiTab-root {
|
|
3
3
|
text-align: left;
|
|
4
4
|
align-items: flex-start;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as d}from"./vendor-react-DoD83n6N.js";import{E as l,j as n,a4 as g,b2 as A,M as G,I as O,a3 as H,bY as U,aa as Z}from"./vendor-mui-core-C-PhacC8.js";import{aZ as J,aI as Q,d as v}from"./vendor-ux-did-connect-
|
|
1
|
+
import{r as d}from"./vendor-react-DoD83n6N.js";import{E as l,j as n,a4 as g,b2 as A,M as G,I as O,a3 as H,bY as U,aa as Z}from"./vendor-mui-core-C-PhacC8.js";import{aZ as J,aI as Q,d as v}from"./vendor-ux-did-connect-BQ3cvv_1.js";import{d as ee}from"./Done-D9sjuoNQ.js";import{C as te}from"./Google-BchHLUIl.js";import{aa as ne,f as re}from"./index--QvOAcHK.js";import{R as oe,F as se,L as ie}from"./logo-uploader-gCM0_9lk.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(J),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"?Q.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=U`
|
|
2
2
|
0%, 100% {
|
|
3
3
|
transform: scale(1) translateX(0);
|
|
4
4
|
}
|