@abtnode/blocklet-services 1.16.46 → 1.16.47-beta-20250710-123505-c50a3bdc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/index.js +11 -0
- package/api/libs/image.js +1 -1
- package/dist/assets/{access-control-CMbWBbA-.js → access-control-D9ajNfrY.js} +1 -1
- package/dist/assets/{add-component-core-C_-47aWH.js → add-component-core-BUbtTpoW.js} +2 -2
- package/dist/assets/{add-resource-CF3PYVap.js → add-resource-CtM0iCKK.js} +1 -1
- package/dist/assets/{addon-BU6EtMS1.js → addon-DCIzT5_Z.js} +1 -1
- package/dist/assets/{advanced-BsXG5Uen.js → advanced-CC1tbROy.js} +1 -1
- package/dist/assets/{appearance-DnQKeY3-.js → appearance-CS0deqWb.js} +1 -1
- package/dist/assets/{arrow-down.svg-CaNNzVmj.js → arrow-down.svg-BykEFw6H.js} +1 -1
- package/dist/assets/{audit-logs-BdTL3Ee_.js → audit-logs-CYNqDQoO.js} +1 -1
- package/dist/assets/{authorize-D3GrNEeY.js → authorize-CXMrv2qg.js} +1 -1
- package/dist/assets/{branding-xOC7tV88.js → branding-BXu_IrWA.js} +2 -2
- package/dist/assets/{branding-DU4A47RN.js → branding-CerBGo3n.js} +1 -1
- package/dist/assets/{bundle-avatar-mX0oF7zo.js → bundle-avatar-BzV5PyCo.js} +1 -1
- package/dist/assets/{complete-DyNDIJOz.js → complete-Derz7Riq.js} +1 -1
- package/dist/assets/{component-DTQzu9Ux.js → component-D_LcLvga.js} +3 -3
- package/dist/assets/{config-DlVTbC3O.js → config-BZak2zrL.js} +1 -1
- package/dist/assets/{config-CLS5JN-Q.js → config-Bzod-0Gd.js} +1 -1
- package/dist/assets/{config-navigation-beAE71Co.js → config-navigation-BIPzVxTz.js} +3 -3
- package/dist/assets/{config-space-p8dvh7nV.js → config-space-bJO1Pq2d.js} +1 -1
- package/dist/assets/{confirm-CCJkd_GP.js → confirm-_x5prMc6.js} +1 -1
- package/dist/assets/{connect-CRMI4vhC.js → connect-DMnnk6Yx.js} +1 -1
- package/dist/assets/{connect-Bscwq6pz.js → connect-Du3HB8Ck.js} +1 -1
- package/dist/assets/{connect-to-DK_UHSXd.js → connect-to-CWHsYUA6.js} +1 -1
- package/dist/assets/{dashboard-EECTIwDT.js → dashboard-e9cJiXmU.js} +3 -3
- package/dist/assets/{delete-confirm-OwSiQs5a.js → delete-confirm-DBhhuh63.js} +1 -1
- package/dist/assets/{domain-Bqb4STve.js → domain-CouGHCP6.js} +1 -1
- package/dist/assets/{domain-action-card-78ZAvOXg.js → domain-action-card-BzjWIWJc.js} +1 -1
- package/dist/assets/{domains-Cc33cE6l.js → domains-BcqusidF.js} +1 -1
- package/dist/assets/{email-CW26NZg4.js → email-BxJbHVNF.js} +1 -1
- package/dist/assets/engine-CbuJOouR.js +1 -0
- package/dist/assets/{exchange-passport-ARTNldc_.js → exchange-passport-D7pdvAln.js} +1 -1
- package/dist/assets/{form-C7DadyRx.js → form-RlCPH3oL.js} +1 -1
- package/dist/assets/{fuel-CdmuLJ5m.js → fuel-BHhjNMAS.js} +1 -1
- package/dist/assets/{gen-access-key-DmGPdafH.js → gen-access-key-Cg9O2Wh7.js} +1 -1
- package/dist/assets/{get-safe-url-CFJ4a0MT.js → get-safe-url-70dNOHyP.js} +1 -1
- package/dist/assets/{home-DSXcBmq0.js → home-BMGT804L.js} +1 -1
- package/dist/assets/{iframe-CTQOWc1h.js → iframe-DnqoUNAW.js} +1 -1
- package/dist/assets/{index-DO3jlY1J.js → index--xoJi0Oj.js} +1 -1
- package/dist/assets/{index-DRCXfYI5.js → index-6xRm42_o.js} +1 -1
- package/dist/assets/{index-DjGGLSgp.js → index-B0stLJYN.js} +1 -1
- package/dist/assets/{index-DaWCw-fb.js → index-BCUaY7ta.js} +1 -1
- package/dist/assets/{index-MvpWBcrT.js → index-BE2l5xAg.js} +1 -1
- package/dist/assets/{index-Bk5yhzGt.js → index-BM8TdfbN.js} +1 -1
- package/dist/assets/{index-waZfnNlB.js → index-BWv4abon.js} +1 -1
- package/dist/assets/{index-Kcu6d0fi.js → index-BfqC3XQE.js} +1 -1
- package/dist/assets/{index-DJhjl40G.js → index-Bqnrq_qv.js} +1 -1
- package/dist/assets/{index-S9T-sBWO.js → index-CDq77s86.js} +4 -4
- package/dist/assets/{index-CzlSSzt5.js → index-CGAgz-tD.js} +1 -1
- package/dist/assets/{index-DMKmqbPb.js → index-CTVZqg23.js} +1 -1
- package/dist/assets/{index-Cs_Iwqc6.js → index-CV2-Ra10.js} +1 -1
- package/dist/assets/{index-n70kyMPo.js → index-Cj5h-Tfb.js} +1 -1
- package/dist/assets/{index-kQLw_ftN.js → index-D830QhSG.js} +1 -1
- package/dist/assets/{index-DYWITQqN.js → index-DAExpjL_.js} +1 -1
- package/dist/assets/{index-DhbrYLsW.js → index-DZZp9n8Q.js} +1 -1
- package/dist/assets/{index-C410XMZO.js → index-Dapt6sZR.js} +1 -1
- package/dist/assets/{index-DKdSMDX6.js → index-DhFdjB1D.js} +1 -1
- package/dist/assets/{index-BuCfItTx.js → index-T7E5JhUh.js} +3 -3
- package/dist/assets/{index-ClY8OPfZ.js → index-ZosxPaRN.js} +1 -1
- package/dist/assets/{index-CnZyhA37.js → index-glbEl-Pn.js} +1 -1
- package/dist/assets/{index-CHgWkvhM.js → index-tnuA-tTl.js} +4 -4
- package/dist/assets/{invitation-S4WXAiey.js → invitation-C6_hcRBi.js} +1 -1
- package/dist/assets/{invite-COY7brfc.js → invite-DLUpRfAh.js} +1 -1
- package/dist/assets/{issue-passport-BSa2KdpC.js → issue-passport-DCSyjcCc.js} +1 -1
- package/dist/assets/{item-C-9-K-dS.js → item-D9OLZ5b9.js} +1 -1
- package/dist/assets/{landing-page-C3ZqUsaQ.js → landing-page-C4ZUBLGU.js} +1 -1
- package/dist/assets/{layout-CFnEKAtz.js → layout-BcCpT3Sj.js} +1 -1
- package/dist/assets/{list-B7ZF5Ul0.js → list-BlDvw1so.js} +1 -1
- package/dist/assets/{list-Dvw6k9Fn.js → list-CJmxDpTz.js} +2 -2
- package/dist/assets/{localization-B4hOUoCq.js → localization-H6VEIn1X.js} +1 -1
- package/dist/assets/{log-CQyBD4pJ.js → log-Bo8H0pew.js} +1 -1
- package/dist/assets/{login-yfGJSAJb.js → login-COCCrN_2.js} +1 -1
- package/dist/assets/{login-oauth-callback-BXAgY8t2.js → login-oauth-callback-BBKbLyu-.js} +1 -1
- package/dist/assets/{logo-uploader-DL_O0r92.js → logo-uploader-CnbjQmUt.js} +2 -2
- package/dist/assets/{lost-passport-BeFjTnh-.js → lost-passport-DsXYEZzf.js} +1 -1
- package/dist/assets/{open-window-PnHF0kAn.js → open-window-LUOmt0hD.js} +1 -1
- package/dist/assets/{over-due-invoice-payment-COY8cvLu.js → over-due-invoice-payment-CuQ5h3hN.js} +1 -1
- package/dist/assets/{overview-Cd-vxOiy.js → overview-Cn9TZC8v.js} +1 -1
- package/dist/assets/{passport-item-DelVKtIt.js → passport-item-DmWZqcWM.js} +1 -1
- package/dist/assets/{permission-B4gBENoO.js → permission-3PNyBKZ2.js} +1 -1
- package/dist/assets/{preferences-CjO06ZIQ.js → preferences-DVGAbEme.js} +1 -1
- package/dist/assets/{profile-embed-BitC6ZoS.js → profile-embed-CI5k42bk.js} +1 -1
- package/dist/assets/{publish-resource-Ck5quuGX.js → publish-resource-EHXQz0a8.js} +1 -1
- package/dist/assets/{runtime-B-Viq2us.js → runtime-WlpSIzes.js} +1 -1
- package/dist/assets/sdk-6bZnDL_f.js +1 -0
- package/dist/assets/{security-J0LBanar.js → security-pXCcg1d2.js} +1 -1
- package/dist/assets/{session-CD-6TrlW.js → session-CvQ97dDY.js} +1 -1
- package/dist/assets/{setup-CpWZbzzi.js → setup-DNMNAWdA.js} +3 -3
- package/dist/assets/{spaces-Jt4I6QVN.js → spaces-DVGE8nur.js} +1 -1
- package/dist/assets/{start-DFxA6tPZ.js → start-CgAXib9j.js} +1 -1
- package/dist/assets/{status-B2xgYwSq.js → status-CxWCFwty.js} +1 -1
- package/dist/assets/{step-actions-BnfP6cxN.js → step-actions-Cmo-e1Kn.js} +1 -1
- package/dist/assets/{studio-CiSsKpFb.js → studio-BoYrF6Kl.js} +1 -1
- package/dist/assets/{traffic-C0Ugjtml.js → traffic-2Q6t1xaL.js} +1 -1
- package/dist/assets/{transfer-BrnC_C-u.js → transfer-B7bfp-Lw.js} +1 -1
- package/dist/assets/{unsubscribe-Df9woQco.js → unsubscribe-B1VOJ7QT.js} +1 -1
- package/dist/assets/{use-blocklet-logo-B1g1jSm8.js → use-blocklet-logo-C7qZcidt.js} +1 -1
- package/dist/assets/{user-center-lZ9ifkcH.js → user-center-BfW2lvH2.js} +3 -3
- package/dist/assets/{user-center-Dicuqlij.js → user-center-Cg8K5HLJ.js} +3 -3
- package/dist/assets/{user-sessions-DmuUfMxJ.js → user-sessions-DEwJRITu.js} +1 -1
- package/dist/assets/{util-Doke8P4Y.js → util-B-cMjJCC.js} +1 -1
- package/dist/assets/{util-BTNHVX94.js → util-CNKleiqU.js} +1 -1
- package/dist/assets/{wrap-locale-CfJqsNLW.js → wrap-locale-Bf1-s-bS.js} +1 -1
- package/dist/assets/{zh-DJzU8mmk.js → zh-CEmPmptr.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/service-worker.js +1 -1
- package/package.json +23 -23
- package/dist/assets/engine-CcVO7RNx.js +0 -1
- package/dist/assets/sdk-Bg2mtU3m.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 k,i as Et,j as nt,L as we,g as go,k as Ns,l as _s,m as bt}from"./vendor-react-x2lQvn4m.js";import{O as Oe,j as e,ak as a,b4 as Pt,$ as r,am as ke,I as ce,dz as Ws,dA as Os,c9 as ko,cf as rt,dB as zs,a_ as Bs,T as A,s as jo,dC as yo,dD as Vs,cP as Us,a1 as lt,at as ve,av as Ms,dE as Fs,C as Ye,aX as it,bs as $t,c6 as Hs,bc as Js,b6 as Ze,cX as Gs,bd as et,V as X,p as Se,c0 as Xs,U as wo,P as vo,S as Lt,ai as Co,v as Ro,M as be,a7 as Ks,bB as So,a3 as To,bv as Ys,H as He,aJ as Zs,W as Do,G as re,b1 as Re,dF as Kt,bR as tt,dG as Io,Z as Eo,X as At,aP as Po,bC as Qs,J as $o,cv as en,aQ as tn,aR as on,cw as sn,cx as nn,bH as Lo,aq as rn,dH as ln,a5 as Ao,a4 as ot,be as Yt,bE as cn,bF as an,dI as dn,dJ as un,bu as Ct,E as pn,F as hn,bm as mn,bn as ft}from"./vendor-mui-core-p6jGoroc.js";import{c as F,_ as ge,Y as De,$ as bn,M as me,c2 as fn,N as xn,f as Zt,c3 as gn,c4 as Qt,an as We,a$ as kn,bA as jn,c5 as yn,c6 as wn,c7 as vn}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-T7E5JhUh.js","assets/index-CDq77s86.js","assets/vendor-mui-core-p6jGoroc.js","assets/vendor-react-x2lQvn4m.js","assets/vendor-ux-TkkDR0Gn.js","assets/vendor-utils-CtD44yV-.js","assets/vendor-hooks-zCCbpt45.js","assets/lottie-web-4koyQiv_.js","assets/vendor-ux-DYcPPYq2.css","assets/vendor-arcblock-BndcJjQO.js","assets/index-DrVXX4fX.css","assets/index-MGxe3V9B.js","assets/index-DRYJ0xIl.js","assets/index-B5LvOF-F.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as k,i as Et,j as nt,L as we,g as go,k as Ns,l as _s,m as bt}from"./vendor-react-x2lQvn4m.js";import{O as Oe,j as e,ak as a,b4 as Pt,$ as r,am as ke,I as ce,dz as Ws,dA as Os,c9 as ko,cf as rt,dB as zs,a_ as Bs,T as A,s as jo,dC as yo,dD as Vs,cP as Us,a1 as lt,at as ve,av as Ms,dE as Fs,C as Ye,aX as it,bs as $t,c6 as Hs,bc as Js,b6 as Ze,cX as Gs,bd as et,V as X,p as Se,c0 as Xs,U as wo,P as vo,S as Lt,ai as Co,v as Ro,M as be,a7 as Ks,bB as So,a3 as To,bv as Ys,H as He,aJ as Zs,W as Do,G as re,b1 as Re,dF as Kt,bR as tt,dG as Io,Z as Eo,X as At,aP as Po,bC as Qs,J as $o,cv as en,aQ as tn,aR as on,cw as sn,cx as nn,bH as Lo,aq as rn,dH as ln,a5 as Ao,a4 as ot,be as Yt,bE as cn,bF as an,dI as dn,dJ as un,bu as Ct,E as pn,F as hn,bm as mn,bn as ft}from"./vendor-mui-core-p6jGoroc.js";import{c as F,_ as ge,Y as De,$ as bn,M as me,c2 as fn,N as xn,f as Zt,c3 as gn,c4 as Qt,an as We,a$ as kn,bA as jn,c5 as yn,c6 as wn,c7 as vn}from"./index-CDq77s86.js";import{T as G,N as qo,q as Cn,n as Le,a0 as No,A as _o,M as Rn,D as qt,H as W,z as Nt,aP as _t,I as ae,_ as Wo,a as ct,j as Oo}from"./vendor-ux-TkkDR0Gn.js";import{C as at}from"./confirm-_x5prMc6.js";import{u as ze}from"./session-CvQ97dDY.js";import{W as Rt}from"./did-address-BdvYNOBf.js";import{E as Je}from"./empty-spinner-CpvmEmwT.js";import{B as Wt}from"./bundle-avatar-BzV5PyCo.js";import{S as Te}from"./shorten-label-OzRq4VRH.js";import{L as Ot}from"./list-header-DZoSW08k.js";import{K as Sn,C as ue,A as zt,D as zo}from"./vendor-utils-CtD44yV-.js";import{C as Bo}from"./click-to-copy-DlFJrA7H.js";import{t as Tn}from"./question-mark-circle.svg-YsMacl4Q.js";import{l as Dn,b as In}from"./vendor-hooks-zCCbpt45.js";import{u as Me}from"./useSetState-BWrXo9eH.js";import{e as En}from"./engine-CbuJOouR.js";import"./api-CpYSt0CS.js";import{T as Pn,S as $n}from"./vendor-mui-x-CkcHHKbJ.js";import{D as eo,C as to,P as oo}from"./react-beautiful-dnd.esm-Cjgywj65.js";import{c as Ln,A as Vo,u as Uo,S as An,U as qn,r as Nn}from"./item-D9OLZ5b9.js";import{f as xe}from"./index-DBs9Ljax.js";import{D as _n}from"./delete-confirm-DBhhuh63.js";import{g as Mo}from"./get-safe-url-70dNOHyP.js";import{u as $e}from"./index-ClQB4tO4.js";import{M as Wn}from"./index-E_Fpmc4w.js";import{r as On}from"./index-BSmqpzfQ.js";import"./vendor-arcblock-BndcJjQO.js";import"./lottie-web-4koyQiv_.js";import"./raf-schd.esm-BZ5FB5HD.js";function Bt({did:t,projectId:o,title:s,logo:n,describe:l}){const i=`${`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t}/${o}/logo/upload`}/${n}`,[d,u]=k.useState(!1),f=Oe(p=>p.breakpoints.down("md"));return e.jsxs(a,{sx:{display:"flex",flexDirection:"row",color:d?"primary.main":"grey.900",gap:1},onPointerEnter:()=>u(!0),onPointerLeave:()=>u(!1),children:[e.jsx(Pt,{sx:{borderRadius:1},src:i}),e.jsxs(a,{children:[e.jsx(Te,{hiddenTip:!0,maxLength:"24",sx:{fontSize:"14px",fontWeight:"500",color:f?"primary.main":""},children:s||"/"}),e.jsx(Te,{hiddenTip:!0,maxLength:"58",sx:{fontSize:"12px",color:f||d?"primary.main":"grey.700"},children:l||"/"})]})]})}Bt.propTypes={projectId:r.string.isRequired,did:r.string.isRequired,title:r.string.isRequired,logo:r.string.isRequired,describe:r.string.isRequired};function Fo({initUrl:t=null}){const o=Et(),s=t?.searchParams.get("tenantScope")||"",{t:n,locale:l}=G(),{api:c}=ge(),{api:i}=ze(),[d,u]=k.useState(!0),{blocklet:f}=De(),[p,m]=k.useState(null),[x,b]=k.useState(!1),h=Oe(E=>E.breakpoints.down("xl")),j=Oe(E=>E.breakpoints.down("md")),{componentDid:v=""}=nt(),[g,C]=k.useState(null),D=`publish-${f.meta.did}`,R=qo(D),[y,T]=k.useState({searchText:R.searchText||"",pageSize:R.rowsPerPage||10,page:1}),O=()=>{c.getProjects({input:{did:f.meta.did,componentDid:v,tenantScope:s}}).then(E=>{const I=E?.projects||[];u(!1),C(I)}).catch(E=>{u(!1),W.error(E.message)})},N=()=>{o(`${F.UNOWNED_DID}/create/none/0.0.0`,{replace:!0})},z=E=>{m(E)},K=()=>{u(!1),b(!0)},P=()=>{b(!1),m(null)},$=E=>{W.error(E.message),b(!1),m(null)},w=E=>{if(!E?.deleted){W.error("Delete project failed");return}O(),b(!1),m(null)};k.useEffect(()=>{O()},[]);const S=k.useMemo(()=>{if(!y.searchText)return g;let E=y.searchText?.trim();return E?(E=Cn.toAddress(E).toLocaleLowerCase(),g.filter(I=>I.blockletTitle.toLowerCase().includes(E)||I.blockletDid.toLowerCase().includes(E))):g},[g,y.searchText]);if(!g&&d)return e.jsx(a,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Je,{})});if(!g)return null;if(!g.length)return e.jsxs(a,{sx:{display:"flex",flexDirection:"column",alignItems:"center",pt:10},children:[e.jsx(a,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:n("blocklet.publish.blockletEmptyTip")}),e.jsx(a,{sx:{fontSize:14,color:"text.secondary",mb:3},children:n("blocklet.publish.createBlockletTip")}),e.jsx(Le,{onClick:N,variant:"contained",children:n("blocklet.publish.createBlocklet")})]});const Z=[{label:"Blocklet",name:"blockletTitle",minWidth:160,options:{customBodyRenderLite:E=>{const I=g[E];return e.jsx(we,{to:`${I.id}`,children:e.jsx(Bt,{did:f.meta.did,projectId:I.id,logo:I.blockletLogo,title:I.blockletTitle,describe:I.blockletDescription})})}}},{label:"Version",name:"blockletVersion",options:{searchable:!1,customBodyRender:E=>E?e.jsx(No,{type:"success",children:E}):""}},{label:"DID",name:"blockletDid",options:{customBodyRender:E=>E?e.jsx(Rt,{size:14,compact:!0,responsive:!1,did:E}):null}},h||v?null:{label:n("common.createdBy"),name:"createdBy",options:{customBodyRender:E=>E?e.jsx(Rt,{onClick:()=>{o(`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/admin/members?did=${E}`)},style:{cursor:"pointer"},size:14,compact:!0,copyable:!1,showQrcode:!1,responsive:!1,did:E}):null}},h||v?null:{label:n("common.scope"),name:"componentDid",options:{customBodyRender:E=>{const I=(f.children||[]).find(V=>V.meta.did===E);return I?e.jsxs(a,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start"},children:[e.jsx(Wt,{size:14,blocklet:I,ancestors:[f]}),e.jsx(a,{sx:{ml:.5,color:"text.primary",fontSize:14},children:I.meta.title})]},E):""}}},h||s?null:{label:n("blocklet.publish.tenantScope"),name:"tenantScope",options:{customBodyRender:E=>e.jsx(a,{sx:{ml:.5,color:"text.primary",fontSize:14},children:e.jsx(Te,{children:E})})}},{label:n("common.updatedAt"),name:"updatedAt",options:{searchable:!1,customBodyRender:E=>e.jsx(_o,{value:Number(E),locale:l})}},{label:n("common.actions"),name:"actions",options:{searchable:!1,customBodyRenderLite:E=>{const I=g[E];return e.jsxs(a,{sx:{display:"flex"},children:[e.jsx(we,{to:`${I.id}/new-release/none/${I.lastReleaseId}`,children:e.jsx(ke,{title:n("blocklet.publish.createRelease"),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"create",children:e.jsx(Ws,{style:{fontSize:18}})})})}),!!I.lastReleaseId&&e.jsx(ke,{title:n("blocklet.publish.viewLastRelease",{name:I.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx(we,{style:{display:"flex"},to:`${I.id}/view/${I.lastReleaseId}/${I.blockletVersion}`,children:e.jsx(Os,{sx:{fontSize:18}})})})}),e.jsx(ke,{title:n("blocklet.publish.delete",{name:I.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>z(I),children:e.jsx(ko,{sx:{fontSize:18}})})})]})}}}].filter(Boolean),H=({page:E,rowsPerPage:I,searchText:V})=>{y.pageSize!==I?T(U=>({...U,searchText:"",pageSize:I,page:1})):y.page!==E+1?T(U=>({...U,searchText:"",page:E+1})):y.searchText!==V&&T(U=>({...U,searchText:V,page:1}))},Q=x?e.jsx(bn,{open:!0,popup:!0,onClose:P,action:"check-has-project-id",locale:l,checkFn:i.get,saveConnect:!1,forceConnected:!1,checkTimeout:5*60*1e3,onSuccess:w,onError:$,extraParams:{projectId:p.id,did:f.meta.did,name:p.blockletTitle},messages:{title:n("blocklet.publish.deleteProject.title",{name:p.blockletTitle}),scan:n("blocklet.publish.deleteProject.scan",{name:p.blockletTitle}),confirm:n("blocklet.publish.deleteProject.confirm"),success:n("blocklet.publish.deleteProject.success")}}):null;return e.jsxs(zn,{children:[e.jsx(Ot,{sx:{mb:2},left:e.jsxs(a,{sx:{display:"flex",flexDirection:"row",alignItems:"center"},children:[e.jsx(a,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:n("common.blockletStudio")}),e.jsx(ke,{title:n("blocklet.publish.createBlockletTip"),arrow:!0,placement:"right",children:e.jsx(zs,{sx:{opacity:.6,fontSize:"1.1em",ml:1}})})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(Rn,{options:{searchPlaceholder:n("blocklet.list.searchPlaceholder"),searchDebounceTime:600,searchAlwaysOpen:j},search:y.searchText,searchText:y.searchText,searchTextUpdate:E=>T(I=>({...I,searchText:E})),searchClose:()=>T(E=>({...E,searchText:""})),onSearchOpen:()=>{}}),e.jsxs(Le,{onClick:N,variant:"contained",children:[e.jsx(rt,{style:{fontSize:"1.3em",marginRight:4}}),n("blocklet.publish.createBlocklet")]})]})}),e.jsx(qt,{className:"main-table",locale:l,data:S,columns:Z,options:{search:!1,sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,searchAlwaysOpen:!0,rowsPerPageOptions:[10,20,50,100]},durable:D,onChange:H}),p&&e.jsx(at,{title:`${n("common.delete")} ${p.blockletTitle}`,description:n("blocklet.publish.deleteProject.description"),confirm:n("common.confirm"),onConfirm:K,onCancel:()=>m(null),children:e.jsx(a,{sx:{marginTop:2},children:[n("blocklet.publish.deleteProject.tip1"),n("blocklet.publish.deleteProject.tip2"),n("blocklet.publish.deleteProject.tip3")].map(E=>e.jsxs(a,{sx:{display:"flex",marginTop:1,flexDirection:"row",alignItems:"flex-start"},children:[e.jsx(Bs,{color:"warning",sx:{marginRight:1,fontSize:20,marginTop:"2px"}}),e.jsx(A,{component:"span",variant:"inherit",sx:{color:"text.secondary"},children:E})]}))})}),Q]})}const zn=jo(a)`
|
|
3
3
|
${({theme:t})=>t.breakpoints.down("md")} {
|
|
4
4
|
.MuiTableRow-root {
|
|
5
5
|
border-color: ${({theme:t})=>t.palette.divider};
|
|
@@ -142,7 +142,7 @@ import{r as k,i as Et,j as nt,L as we,g as go,k as Ns,l as _s,m as bt}from"./ven
|
|
|
142
142
|
background: #fff;
|
|
143
143
|
z-index: 10;
|
|
144
144
|
}
|
|
145
|
-
`,ao="lastWantToConnectStoreId";function or(t){const[o,s]=k.useState(null),{session:n}=ze(),l=k.useCallback(d=>{s(d),localStorage.setItem(ao,d?.id)},[s]),c=k.useMemo(()=>{const d=localStorage.getItem(ao),u=d?(t?.settings?.storeList||[]).find(p=>p.id===d):null;if(u)return u;let f=(t?.settings?.storeList||[]).find(p=>!(p.id!==F.BLOCKLET_STORE.id||p.scope&&p.scope!=="studio"&&p.scope!==n?.user?.did));return f||(f=t?.settings?.storeList?.[0]),f},[t?.settings?.storeList,n?.user?.did]);return[o||c||{},l]}const vt={};async function Vt(t,{interval:o=1e3,maxDuration:s=120*1e3,intervalFirst:n=4e3,timerKey:l=""}){vt[l]&&clearTimeout(vt[l]),await new Promise(d=>setTimeout(d,n));const c=Date.now(),i=async(d,u)=>{try{const f=await t();d(f)}catch(f){Date.now()-c>s?u(f):l?vt[l]=setTimeout(()=>i(d,u),o):setTimeout(()=>i(d,u),o)}};return new Promise(i)}function sr(){return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)+`${Date.now()}`.slice(-6)}function nr(t,{did:o,projectId:s,messageId:n}){return Vt(async()=>{const l=await t.getProject({input:{did:o,projectId:s,messageId:n}});if(!l?.project?.blockletDid)throw new Error("Connected store not found");return l.project.blockletDid},{timerKey:"connect-studio"})}function rr(t,{did:o,projectId:s,storeId:n}){return Vt(async()=>{const l=await t.getProject({input:{did:o,projectId:s,messageId:""}});if(!l?.project?.connectedStores?.length)throw new Error("Connected store not found");if(!l.project.connectedStores.find(i=>i.storeId===n))throw new Error("Connected store not found")},{timerKey:`connect-store-${n}`})}function lr(t,{did:o,projectId:s,endpointId:n}){return Vt(async()=>{const l=await t.getProject({input:{did:o,projectId:s,messageId:""}});if(!l?.project?.connectedEndpoints?.length)throw new Error("Connected endpoint not found");if(!l.project.connectedEndpoints.find(i=>i.endpointId===n))throw new Error("Connected endpoint not found")},{timerKey:`connect-store-${n}`})}const Ut=({fromBlocklet:t,nodeInfo:o,blocklet:s,userDid:n})=>{const l=t?s?.meta?.did:o?.did;let c=t?s?.settings?.storeList||[]:o?.blockletRegistryList||[];return Array.isArray(c)||(c=[]),c=c.filter(i=>i.protected||!i.scope||i.scope==="studio"||i.scope===n),{teamDid:l,storeList:c}};function os({blocklet:t=null,store:o=null,onChangeStore:s,onClick:n,disabled:l,loading:c,componentDid:i}){const{t:d}=G(),{session:u}=ze(),{api:f,info:p,inService:m}=ge(),x=De(),[b,h]=k.useState(!1),j=k.useRef(null),[v,g]=k.useState(!1),[C,D]=k.useState(null),R=$=>{s($),h(!1)},y=()=>{h(!b)},T=$=>{j.current&&j.current.contains($.target)||h(!1)},O=()=>{g(!0)},N=()=>{g(!1)},z=async()=>{if(C)try{await f.deleteBlockletStore({input:{teamDid:t.meta.did,url:C.url,projectId:"",scope:C.scope||"studio"}}),await x?.actions?.refreshBlocklet()}catch($){W.error(`Remove Blocklet Store Error: ${xe($)}`)}finally{D(null)}},{storeList:K}=Ut({fromBlocklet:m,blocklet:t,nodeInfo:p,userDid:u?.user?.did}),P=t?.meta?.did;return e.jsxs(e.Fragment,{children:[e.jsxs(et,{disabled:l,ref:j,variant:"contained",color:"primary","aria-label":"Button group with connect store",children:[e.jsxs(X,{onClick:n,children:[c&&e.jsx(Se,{size:14,sx:{mr:.5}}),`${d("common.connect")} ${o.name||""}`]}),e.jsx(X,{size:"small","aria-controls":b?"split-button-menu":void 0,"aria-expanded":b?"true":void 0,"aria-label":"select merge strategy","aria-haspopup":"menu",onClick:y,children:e.jsx(Xs,{})})]}),e.jsx(wo,{sx:{zIndex:10},open:b,anchorEl:j.current,placement:"bottom-end",role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:$})=>e.jsx(vo,{...$,style:{transformOrigin:"center top"},children:e.jsx(Lt,{children:e.jsx(Co,{onClickAway:T,children:e.jsxs(Ro,{id:"split-button-menu",autoFocusItem:!0,sx:{maxHeight:300,overflowY:"auto",zIndex:10},children:[K?.map(w=>e.jsxs(be,{selected:w.id===o?.id,sx:{height:56},onClick:()=>R(w),children:[e.jsxs(a,{children:[e.jsx(Te,{sx:{fontSize:"16px"},maxLength:24,children:w.name}),e.jsx(Te,{sx:{fontSize:"13px",opacity:.6},maxLength:30,children:w.url})]}),Ln({store:w,userDid:u?.user?.did})&&e.jsx(ce,{sx:{ml:1},onClick:S=>{S.preventDefault(),S.stopPropagation(),D(w)},children:e.jsx(ae,{icon:"ic:outline-delete"})})]},w.url)),e.jsx(Ks,{}),e.jsxs(be,{onClick:O,children:[e.jsx(rt,{font:!0}),e.jsx(A,{variant:"inherit",children:d("store.blockletRegistry.addRegistry")})]})]})})})})}),v&&e.jsx(Vo,{hiddenChildren:!0,open:!0,onClose:N,teamDid:P,storeList:K,scope:"studio",onAdd:x?.actions?.refreshBlocklet}),C&&e.jsx(at,{displayError:!0,title:`${d("common.delete")} ${C.name}`,description:d("blocklet.publish.deleteStoreTip",{name:C.name}),confirm:d("common.confirm"),onConfirm:z,onCancel:()=>D(null)})]})}os.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};const ss=(t,o,s)=>{const n=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/logo/upload`,l=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/screenshot/upload`,c=t?.blockletLogo?`${n}/${t.blockletLogo}`:`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/static/images/logo.png`,i=(t?.blockletScreenshots||[]).filter(Boolean).map(d=>`${l}/${d}`);return{logoUrl:c,screenshotUrls:i,uploadLogoPrefix:n,uploadScreenshotPrefix:l}},ir=t=>{const o=t.includes("youtube.com")||t.includes("youtu.be"),s=t.includes("vimeo.com");return o||s};function Mt({url:t,style:o={},controls:s=1,modestbranding:n=1}){const{t:l}=G(),c=t.includes("youtube.com")||t.includes("youtu.be"),i=t.includes("vimeo.com");if(c){const d=t.split("v=")[1]?.split("&")[0]||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://www.youtube.com/embed/${d}?modestbranding=${n}&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(i){const d=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/${d}`,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(a,{style:{position:"relative",width:"100%",paddingTop:"56.25%"},children:e.jsxs(a,{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(A,{variant:"body1",sx:{opacity:.5},children:l("studio.videoDialogNoSrc")})]})})}Mt.propTypes={url:r.string.isRequired,style:r.object,controls:r.number,modestbranding:r.number};function ns({setParams:t,onClose:o,params:s}){const{t:n}=G(),[l,c]=k.useState(""),i=l&&s.blockletVideos.includes(l),d=ir(l),u=()=>{t(f=>{const p=[...f.blockletVideos];return p.push(l),{...f,blockletVideos:p}}),o()};return e.jsxs(lt,{open:!0,fullWidth:!0,maxWidth:"sm",children:[e.jsx(So,{children:n("studio.videoDialogTitle")}),e.jsxs(To,{children:[e.jsx(Ys,{fullWidth:!0,value:l,onChange:f=>c(f.target.value),placeholder:n("studio.videoInputLabel"),endAdornment:l?e.jsx(He,{position:"end",children:e.jsx(ce,{onClick:()=>c(""),children:e.jsx(Zs,{})})}):null,error:i}),i&&e.jsx(A,{variant:"body2",color:"error",children:n("studio.duplicateVideo")}),e.jsx(Mt,{url:l,style:{marginTop:"20px",borderRadius:"4px"}})]}),e.jsxs(Do,{children:[e.jsx(X,{onClick:()=>o(),children:n("studio.cancel")}),e.jsx(X,{disabled:!d||i,onClick:u,children:n("studio.confirm")})]})]})}ns.propTypes={onClose:r.func.isRequired,params:r.object.isRequired,setParams:r.func.isRequired};function St({errors:t,storeList:o,...s}){const{t:n}=G();return e.jsxs(a,{...s,sx:[{color:"warning.main",fontSize:"14px",border:"1px solid rgba(214, 164, 64, 0.34)",borderRadius:"4px",py:2,px:1.5,position:"relative"},...Array.isArray(s.sx)?s.sx:[s.sx]],children:[e.jsx(A,{variant:"caption",sx:{fontWeight:"bold",position:"absolute",top:-10,left:12,backgroundColor:"white",px:1,width:"fit-content"},children:n("blocklet.publish.storeRule.warning")}),t&&Object.entries(t).map(([l,c])=>{const i=Object.values(c),d=o.find(u=>u.url===l);return i.length>0&&e.jsxs(a,{children:[e.jsx(ke,{title:l,children:e.jsx(a,{component:"span",sx:{cursor:"pointer"},children:d.name})}),i.map(u=>e.jsx(a,{component:"li",sx:{ml:2,wordBreak:!0},children:u},u))]},l)})]})}St.propTypes={errors:r.object.isRequired,storeList:r.array.isRequired};const uo=k.lazy(()=>Wo(()=>import("./index-BuCfItTx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(t=>({default:t.Uploader})));function rs({projectId:t,readOnly:o,loading:s,blocklet:n,params:l,setParams:c,paramsErrTip:i,setParamsErrTip:d,warning:u,setLoading:f,initUrl:p=null,initLogoUrl:m,setInitLogoUrl:x,componentDid:b=""}){const{t:h,locale:j}=G(),{api:v}=ge(),g=Et(),C=k.useRef(null),D=k.useRef(null),[R,y]=or(n),[T,O]=k.useState(!1),N=Uo({messageType:"connect-store-message",onOpen:()=>f(!0),onClose:()=>f(!1)}),z=async q=>{const Y=setTimeout(()=>{f(!1)},2e4),J=await nr(v,q);f(!1),clearTimeout(Y),window.parent.postMessage({event:"studioDialog.connected",componentDid:b},"*"),g(window.location.pathname.replace(`${F.UNOWNED_DID}/create`,`${J}/create`),{replace:!0})},K=()=>{if(!l.blockletTitle){W.error(h("blocklet.publish.errorTip.noTitle"));return}if(!R?.url){W.error(h("blocklet.publish.noStoreSelected"));return}const q=sr();N(async(Y,J)=>{try{const se=await v.connectByStudio({input:{did:n?.meta?.did,blockletTitle:l?.blockletTitle,storeUrl:R.url,storeId:R.id,storeName:R.name,type:l?.blockletComponents?.length>0?"pack":"resource",componentDid:b,messageId:q,tenantScope:p?.searchParams.get("tenantScope")||""}});if(!se?.url){W.error("failed to connect to store");return}J(se.url),z({did:n?.meta?.did,projectId:"",messageId:q})}catch(se){const de=xe(se);W.error(de),f(!1)}})},{logoUrl:P,screenshotUrls:$,uploadLogoPrefix:w,uploadScreenshotPrefix:S}=ss(l,n,t),{logoErrors:Z,screenshotErrors:H,storeList:Q,hasLogoWarning:E,hasScreenshotWarning:I}=u,V=()=>o?!1:!t||t===F.UNOWNED_DID?(W.error(h("blocklet.publish.errorTip.noFirstDid")),!1):!0,U=q=>{if(!q.destination)return;const Y=Array.from(l.blockletScreenshots),[J]=Y.splice(q.source.index,1);Y.splice(q.destination.index,0,J),c(se=>({...se,blockletScreenshots:Y}))},ee=q=>{if(!q.destination)return;const Y=Array.from(l.blockletVideos),[J]=Y.splice(q.source.index,1);Y.splice(q.destination.index,0,J),c(se=>({...se,blockletVideos:Y}))};return e.jsxs(cr,{children:[e.jsx(a,{className:"section",sx:{display:"flex"},children:e.jsxs(a,{sx:{flex:1},children:[e.jsx(re,{disabled:s||o,label:`Blocklet ${h("common.title")}`,placeholder:`Blocklet ${h("common.title")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,required:!0,value:l.blockletTitle||"",onChange:q=>{d({blockletTitle:""}),c({blockletTitle:q.target.value})},error:!!i.blockletTitle,helperText:i.blockletTitle||"",slotProps:{input:{"data-cy":"blocklet-title",readOnly:o}}}),e.jsx(re,{required:!0,label:"Blocklet DID",fullWidth:!0,readonly:!0,disabled:!0,autoComplete:"off",variant:"outlined",error:!!i.projectId,helperText:i.projectId||"",value:t===F.UNOWNED_DID?"":`did:abt:${t}`,sx:{mt:3},slotProps:{input:{"data-cy":"export-blocklet-did",endAdornment:t===F.UNOWNED_DID&&e.jsx(He,{position:"end",children:e.jsx(os,{blocklet:n,store:R,componentDid:b,onChangeStore:y,disabled:!l.blockletTitle||o||s,loading:s,onClick:K})})}}}),e.jsx(re,{disabled:s||o,label:`Blocklet ${h("common.description")}`,placeholder:`Blocklet ${h("common.description")}`,required:!0,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletDescription||"",onChange:q=>{d({blockletDescription:""}),c({blockletDescription:q.target.value.slice(0,159)})},error:!!i.blockletDescription,helperText:i.blockletDescription||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-description",readOnly:o}}}),e.jsx(re,{disabled:s||o,label:`Blocklet ${h("common.homepageTip")}`,placeholder:`Blocklet ${h("common.homepageTip")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletHomepage||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)?d({blockletHomepage:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletHomepage:""}),c({blockletHomepage:q.target.value})},error:!!i.blockletHomepage,helperText:i.blockletHomepage||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-homepage",readOnly:o}}}),e.jsx(re,{disabled:s||o,label:`Blocklet ${h("common.community")}`,placeholder:`Blocklet ${h("common.community")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletCommunity||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)?d({blockletCommunity:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletCommunity:""}),c({blockletCommunity:q.target.value})},error:!!i.blockletCommunity,helperText:i.blockletCommunity||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-community",readOnly:o}}}),e.jsx(re,{disabled:s||o,label:`Blocklet ${h("common.support")}`,placeholder:`Blocklet ${h("common.support")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletSupport||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(q.target.value)?d({blockletSupport:h("blocklet.publish.errorTip.invalidUrlOrEmail")}):d({blockletSupport:""}),c({blockletSupport:q.target.value})},error:!!i.blockletSupport,helperText:i.blockletSupport||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-support",readOnly:o}}}),e.jsx(re,{disabled:s||o,label:`Blocklet ${h("common.repository")}`,placeholder:`Blocklet ${h("common.repository")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletRepository||"",onChange:q=>{q.target.value&&!/^(git|https|svn)/.test(q.target.value)?d({blockletRepository:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletRepository:""}),c({blockletRepository:q.target.value})},error:!!i.blockletRepository,helperText:i.blockletRepository||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-repository",readOnly:o}}})]})}),e.jsx(a,{className:"section full-width",sx:{display:"flex",mt:3},children:e.jsxs(a,{sx:{flex:1,overflow:"hidden"},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.logo")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.type"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"png, jpg, webp, svg"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.ratio"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"256x256"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.size"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"<500Kb"})]})})]})]}),e.jsx(a,{sx:{flex:1,cursor:o?"default":"pointer",display:"flex",alignItems:"flex-end"},children:e.jsx(Pt,{variant:"square",sx:{width:80,height:80},alt:"Blocklet Logo",src:m||P,onClick:()=>{V()&&C.current?.open()}})})]}),E&&e.jsx(St,{errors:Z,storeList:Q,mt:3}),e.jsxs(a,{sx:{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.screenshot")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{sx:{border:"none"},variant:"outlined",size:"small",children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.ratio"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"16 / 9"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.count"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"1~5"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.size"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"<5MB"})]})}),!o&&e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.order"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:h("studio.orderTip")})]})})]})]}),e.jsx(eo,{onDragEnd:o?void 0:U,children:e.jsx(to,{droppableId:"screenshots",direction:"horizontal",isDropDisabled:o,children:(q,Y)=>e.jsxs(a,{ref:q.innerRef,...q.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,flexWrap:"wrap",minHeight:160,background:Y.isDraggingOver?"grey.100":"transparent",transition:"background-color 0.2s ease",border:Y.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[$.map((J,se)=>e.jsx(oo,{draggableId:J,index:se,isDragDisabled:o,children:(de,le)=>e.jsxs(a,{ref:de.innerRef,...de.draggableProps,className:"screenshot",sx:{transform:le.isDragging?"scale(1.05)":"none",boxShadow:le.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:J}),!o&&e.jsx(ce,{...de.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(Kt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{c(pe=>{const he=[...pe.blockletScreenshots];return he.splice(se,1),{...pe,blockletScreenshots:he}})},children:e.jsx(tt,{})})]})},J)),q.placeholder,$.length<5&&e.jsx(a,{onClick:()=>{V()&&D.current?.open()},sx:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},children:"+"})]})})})]}),I&&e.jsx(St,{errors:H,storeList:Q}),e.jsxs(a,{sx:{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("studio.video")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.videoType"),":"," "]}),e.jsxs(a,{component:"span",sx:{color:"secondary.main"},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(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.count"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"1~3"})]})}),!o&&e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.order"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:h("studio.orderTip")})]})})]})]}),e.jsx(eo,{onDragEnd:o?void 0:ee,children:e.jsx(to,{droppableId:"videos",direction:"horizontal",isDropDisabled:o,children:(q,Y)=>e.jsxs(a,{ref:q.innerRef,...q.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,flexWrap:"wrap",minHeight:160,background:Y.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:Y.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[l.blockletVideos.map((J,se)=>e.jsx(oo,{draggableId:J,index:se,isDragDisabled:o,children:(de,le)=>e.jsxs(a,{ref:de.innerRef,...de.draggableProps,className:"screenshot",sx:{transform:le.isDragging?"scale(1.05)":"none",boxShadow:le.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx(Mt,{url:J,style:{pointerEvents:le.isDragging?"none":"auto"}}),!o&&e.jsx(ce,{...de.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(Kt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{c(pe=>{const he=[...pe.blockletVideos];return he.splice(se,1),{...pe,blockletVideos:he}})},children:e.jsx(tt,{})})]})},J)),q.placeholder,l.blockletVideos.length<3&&e.jsx(a,{onClick:()=>{V()&&O(!0)},sx:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},children:"+"})]})})})]})]})}),e.jsxs(k.Suspense,{fallback:e.jsx(Je,{}),children:[e.jsx(uo,{ref:C,locale:j,popup:!0,onUploadFinish:q=>{c({blockletLogo:q.data.filename}),x(""),C.current?.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:w,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/png","image/jpeg","image/webp","image/svg+xml"],maxFileSize:1024*1024*.5,maxNumberOfFiles:1}},dashboardProps:{autoOpen:"imageEditor"},imageEditorProps:{actions:{revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!1,cropWidescreen:!1,cropWidescreenVertical:!1},cropperOptions:{autoCrop:!0,aspectRatio:1,initialAspectRatio:1,autoCropArea:1,croppedCanvasOptions:{minWidth:256,minHeight:256}}}},"uploader-logo"),T&&e.jsx(ns,{onClose:()=>O(!1),params:l,setParams:c}),e.jsx(uo,{ref:D,locale:j,popup:!0,onUploadFinish:q=>{c(Y=>{const J=Y.blockletScreenshots||[];return J.push(q.data?.filename),{...Y,blockletScreenshots:J}}),D.current?.close()},installerProps:{disabled:!0},plugins:["ImageEditor"],apiPathProps:{uploader:S,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/*","image/svg+xml"],maxFileSize:1024*1024*5,maxNumberOfFiles:5-$.length}},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")]})]})}rs.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,componentDid:r.string,initLogoUrl:r.string.isRequired,setInitLogoUrl:r.func.isRequired};const cr=ve.div`
|
|
145
|
+
`,ao="lastWantToConnectStoreId";function or(t){const[o,s]=k.useState(null),{session:n}=ze(),l=k.useCallback(d=>{s(d),localStorage.setItem(ao,d?.id)},[s]),c=k.useMemo(()=>{const d=localStorage.getItem(ao),u=d?(t?.settings?.storeList||[]).find(p=>p.id===d):null;if(u)return u;let f=(t?.settings?.storeList||[]).find(p=>!(p.id!==F.BLOCKLET_STORE.id||p.scope&&p.scope!=="studio"&&p.scope!==n?.user?.did));return f||(f=t?.settings?.storeList?.[0]),f},[t?.settings?.storeList,n?.user?.did]);return[o||c||{},l]}const vt={};async function Vt(t,{interval:o=1e3,maxDuration:s=120*1e3,intervalFirst:n=4e3,timerKey:l=""}){vt[l]&&clearTimeout(vt[l]),await new Promise(d=>setTimeout(d,n));const c=Date.now(),i=async(d,u)=>{try{const f=await t();d(f)}catch(f){Date.now()-c>s?u(f):l?vt[l]=setTimeout(()=>i(d,u),o):setTimeout(()=>i(d,u),o)}};return new Promise(i)}function sr(){return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)+`${Date.now()}`.slice(-6)}function nr(t,{did:o,projectId:s,messageId:n}){return Vt(async()=>{const l=await t.getProject({input:{did:o,projectId:s,messageId:n}});if(!l?.project?.blockletDid)throw new Error("Connected store not found");return l.project.blockletDid},{timerKey:"connect-studio"})}function rr(t,{did:o,projectId:s,storeId:n}){return Vt(async()=>{const l=await t.getProject({input:{did:o,projectId:s,messageId:""}});if(!l?.project?.connectedStores?.length)throw new Error("Connected store not found");if(!l.project.connectedStores.find(i=>i.storeId===n))throw new Error("Connected store not found")},{timerKey:`connect-store-${n}`})}function lr(t,{did:o,projectId:s,endpointId:n}){return Vt(async()=>{const l=await t.getProject({input:{did:o,projectId:s,messageId:""}});if(!l?.project?.connectedEndpoints?.length)throw new Error("Connected endpoint not found");if(!l.project.connectedEndpoints.find(i=>i.endpointId===n))throw new Error("Connected endpoint not found")},{timerKey:`connect-store-${n}`})}const Ut=({fromBlocklet:t,nodeInfo:o,blocklet:s,userDid:n})=>{const l=t?s?.meta?.did:o?.did;let c=t?s?.settings?.storeList||[]:o?.blockletRegistryList||[];return Array.isArray(c)||(c=[]),c=c.filter(i=>i.protected||!i.scope||i.scope==="studio"||i.scope===n),{teamDid:l,storeList:c}};function os({blocklet:t=null,store:o=null,onChangeStore:s,onClick:n,disabled:l,loading:c,componentDid:i}){const{t:d}=G(),{session:u}=ze(),{api:f,info:p,inService:m}=ge(),x=De(),[b,h]=k.useState(!1),j=k.useRef(null),[v,g]=k.useState(!1),[C,D]=k.useState(null),R=$=>{s($),h(!1)},y=()=>{h(!b)},T=$=>{j.current&&j.current.contains($.target)||h(!1)},O=()=>{g(!0)},N=()=>{g(!1)},z=async()=>{if(C)try{await f.deleteBlockletStore({input:{teamDid:t.meta.did,url:C.url,projectId:"",scope:C.scope||"studio"}}),await x?.actions?.refreshBlocklet()}catch($){W.error(`Remove Blocklet Store Error: ${xe($)}`)}finally{D(null)}},{storeList:K}=Ut({fromBlocklet:m,blocklet:t,nodeInfo:p,userDid:u?.user?.did}),P=t?.meta?.did;return e.jsxs(e.Fragment,{children:[e.jsxs(et,{disabled:l,ref:j,variant:"contained",color:"primary","aria-label":"Button group with connect store",children:[e.jsxs(X,{onClick:n,children:[c&&e.jsx(Se,{size:14,sx:{mr:.5}}),`${d("common.connect")} ${o.name||""}`]}),e.jsx(X,{size:"small","aria-controls":b?"split-button-menu":void 0,"aria-expanded":b?"true":void 0,"aria-label":"select merge strategy","aria-haspopup":"menu",onClick:y,children:e.jsx(Xs,{})})]}),e.jsx(wo,{sx:{zIndex:10},open:b,anchorEl:j.current,placement:"bottom-end",role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:$})=>e.jsx(vo,{...$,style:{transformOrigin:"center top"},children:e.jsx(Lt,{children:e.jsx(Co,{onClickAway:T,children:e.jsxs(Ro,{id:"split-button-menu",autoFocusItem:!0,sx:{maxHeight:300,overflowY:"auto",zIndex:10},children:[K?.map(w=>e.jsxs(be,{selected:w.id===o?.id,sx:{height:56},onClick:()=>R(w),children:[e.jsxs(a,{children:[e.jsx(Te,{sx:{fontSize:"16px"},maxLength:24,children:w.name}),e.jsx(Te,{sx:{fontSize:"13px",opacity:.6},maxLength:30,children:w.url})]}),Ln({store:w,userDid:u?.user?.did})&&e.jsx(ce,{sx:{ml:1},onClick:S=>{S.preventDefault(),S.stopPropagation(),D(w)},children:e.jsx(ae,{icon:"ic:outline-delete"})})]},w.url)),e.jsx(Ks,{}),e.jsxs(be,{onClick:O,children:[e.jsx(rt,{font:!0}),e.jsx(A,{variant:"inherit",children:d("store.blockletRegistry.addRegistry")})]})]})})})})}),v&&e.jsx(Vo,{hiddenChildren:!0,open:!0,onClose:N,teamDid:P,storeList:K,scope:"studio",onAdd:x?.actions?.refreshBlocklet}),C&&e.jsx(at,{displayError:!0,title:`${d("common.delete")} ${C.name}`,description:d("blocklet.publish.deleteStoreTip",{name:C.name}),confirm:d("common.confirm"),onConfirm:z,onCancel:()=>D(null)})]})}os.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};const ss=(t,o,s)=>{const n=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/logo/upload`,l=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/screenshot/upload`,c=t?.blockletLogo?`${n}/${t.blockletLogo}`:`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/static/images/logo.png`,i=(t?.blockletScreenshots||[]).filter(Boolean).map(d=>`${l}/${d}`);return{logoUrl:c,screenshotUrls:i,uploadLogoPrefix:n,uploadScreenshotPrefix:l}},ir=t=>{const o=t.includes("youtube.com")||t.includes("youtu.be"),s=t.includes("vimeo.com");return o||s};function Mt({url:t,style:o={},controls:s=1,modestbranding:n=1}){const{t:l}=G(),c=t.includes("youtube.com")||t.includes("youtu.be"),i=t.includes("vimeo.com");if(c){const d=t.split("v=")[1]?.split("&")[0]||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://www.youtube.com/embed/${d}?modestbranding=${n}&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(i){const d=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/${d}`,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(a,{style:{position:"relative",width:"100%",paddingTop:"56.25%"},children:e.jsxs(a,{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(A,{variant:"body1",sx:{opacity:.5},children:l("studio.videoDialogNoSrc")})]})})}Mt.propTypes={url:r.string.isRequired,style:r.object,controls:r.number,modestbranding:r.number};function ns({setParams:t,onClose:o,params:s}){const{t:n}=G(),[l,c]=k.useState(""),i=l&&s.blockletVideos.includes(l),d=ir(l),u=()=>{t(f=>{const p=[...f.blockletVideos];return p.push(l),{...f,blockletVideos:p}}),o()};return e.jsxs(lt,{open:!0,fullWidth:!0,maxWidth:"sm",children:[e.jsx(So,{children:n("studio.videoDialogTitle")}),e.jsxs(To,{children:[e.jsx(Ys,{fullWidth:!0,value:l,onChange:f=>c(f.target.value),placeholder:n("studio.videoInputLabel"),endAdornment:l?e.jsx(He,{position:"end",children:e.jsx(ce,{onClick:()=>c(""),children:e.jsx(Zs,{})})}):null,error:i}),i&&e.jsx(A,{variant:"body2",color:"error",children:n("studio.duplicateVideo")}),e.jsx(Mt,{url:l,style:{marginTop:"20px",borderRadius:"4px"}})]}),e.jsxs(Do,{children:[e.jsx(X,{onClick:()=>o(),children:n("studio.cancel")}),e.jsx(X,{disabled:!d||i,onClick:u,children:n("studio.confirm")})]})]})}ns.propTypes={onClose:r.func.isRequired,params:r.object.isRequired,setParams:r.func.isRequired};function St({errors:t,storeList:o,...s}){const{t:n}=G();return e.jsxs(a,{...s,sx:[{color:"warning.main",fontSize:"14px",border:"1px solid rgba(214, 164, 64, 0.34)",borderRadius:"4px",py:2,px:1.5,position:"relative"},...Array.isArray(s.sx)?s.sx:[s.sx]],children:[e.jsx(A,{variant:"caption",sx:{fontWeight:"bold",position:"absolute",top:-10,left:12,backgroundColor:"white",px:1,width:"fit-content"},children:n("blocklet.publish.storeRule.warning")}),t&&Object.entries(t).map(([l,c])=>{const i=Object.values(c),d=o.find(u=>u.url===l);return i.length>0&&e.jsxs(a,{children:[e.jsx(ke,{title:l,children:e.jsx(a,{component:"span",sx:{cursor:"pointer"},children:d.name})}),i.map(u=>e.jsx(a,{component:"li",sx:{ml:2,wordBreak:!0},children:u},u))]},l)})]})}St.propTypes={errors:r.object.isRequired,storeList:r.array.isRequired};const uo=k.lazy(()=>Wo(()=>import("./index-T7E5JhUh.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(t=>({default:t.Uploader})));function rs({projectId:t,readOnly:o,loading:s,blocklet:n,params:l,setParams:c,paramsErrTip:i,setParamsErrTip:d,warning:u,setLoading:f,initUrl:p=null,initLogoUrl:m,setInitLogoUrl:x,componentDid:b=""}){const{t:h,locale:j}=G(),{api:v}=ge(),g=Et(),C=k.useRef(null),D=k.useRef(null),[R,y]=or(n),[T,O]=k.useState(!1),N=Uo({messageType:"connect-store-message",onOpen:()=>f(!0),onClose:()=>f(!1)}),z=async q=>{const Y=setTimeout(()=>{f(!1)},2e4),J=await nr(v,q);f(!1),clearTimeout(Y),window.parent.postMessage({event:"studioDialog.connected",componentDid:b},"*"),g(window.location.pathname.replace(`${F.UNOWNED_DID}/create`,`${J}/create`),{replace:!0})},K=()=>{if(!l.blockletTitle){W.error(h("blocklet.publish.errorTip.noTitle"));return}if(!R?.url){W.error(h("blocklet.publish.noStoreSelected"));return}const q=sr();N(async(Y,J)=>{try{const se=await v.connectByStudio({input:{did:n?.meta?.did,blockletTitle:l?.blockletTitle,storeUrl:R.url,storeId:R.id,storeName:R.name,type:l?.blockletComponents?.length>0?"pack":"resource",componentDid:b,messageId:q,tenantScope:p?.searchParams.get("tenantScope")||""}});if(!se?.url){W.error("failed to connect to store");return}J(se.url),z({did:n?.meta?.did,projectId:"",messageId:q})}catch(se){const de=xe(se);W.error(de),f(!1)}})},{logoUrl:P,screenshotUrls:$,uploadLogoPrefix:w,uploadScreenshotPrefix:S}=ss(l,n,t),{logoErrors:Z,screenshotErrors:H,storeList:Q,hasLogoWarning:E,hasScreenshotWarning:I}=u,V=()=>o?!1:!t||t===F.UNOWNED_DID?(W.error(h("blocklet.publish.errorTip.noFirstDid")),!1):!0,U=q=>{if(!q.destination)return;const Y=Array.from(l.blockletScreenshots),[J]=Y.splice(q.source.index,1);Y.splice(q.destination.index,0,J),c(se=>({...se,blockletScreenshots:Y}))},ee=q=>{if(!q.destination)return;const Y=Array.from(l.blockletVideos),[J]=Y.splice(q.source.index,1);Y.splice(q.destination.index,0,J),c(se=>({...se,blockletVideos:Y}))};return e.jsxs(cr,{children:[e.jsx(a,{className:"section",sx:{display:"flex"},children:e.jsxs(a,{sx:{flex:1},children:[e.jsx(re,{disabled:s||o,label:`Blocklet ${h("common.title")}`,placeholder:`Blocklet ${h("common.title")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,required:!0,value:l.blockletTitle||"",onChange:q=>{d({blockletTitle:""}),c({blockletTitle:q.target.value})},error:!!i.blockletTitle,helperText:i.blockletTitle||"",slotProps:{input:{"data-cy":"blocklet-title",readOnly:o}}}),e.jsx(re,{required:!0,label:"Blocklet DID",fullWidth:!0,readonly:!0,disabled:!0,autoComplete:"off",variant:"outlined",error:!!i.projectId,helperText:i.projectId||"",value:t===F.UNOWNED_DID?"":`did:abt:${t}`,sx:{mt:3},slotProps:{input:{"data-cy":"export-blocklet-did",endAdornment:t===F.UNOWNED_DID&&e.jsx(He,{position:"end",children:e.jsx(os,{blocklet:n,store:R,componentDid:b,onChangeStore:y,disabled:!l.blockletTitle||o||s,loading:s,onClick:K})})}}}),e.jsx(re,{disabled:s||o,label:`Blocklet ${h("common.description")}`,placeholder:`Blocklet ${h("common.description")}`,required:!0,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletDescription||"",onChange:q=>{d({blockletDescription:""}),c({blockletDescription:q.target.value.slice(0,159)})},error:!!i.blockletDescription,helperText:i.blockletDescription||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-description",readOnly:o}}}),e.jsx(re,{disabled:s||o,label:`Blocklet ${h("common.homepageTip")}`,placeholder:`Blocklet ${h("common.homepageTip")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletHomepage||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)?d({blockletHomepage:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletHomepage:""}),c({blockletHomepage:q.target.value})},error:!!i.blockletHomepage,helperText:i.blockletHomepage||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-homepage",readOnly:o}}}),e.jsx(re,{disabled:s||o,label:`Blocklet ${h("common.community")}`,placeholder:`Blocklet ${h("common.community")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletCommunity||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)?d({blockletCommunity:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletCommunity:""}),c({blockletCommunity:q.target.value})},error:!!i.blockletCommunity,helperText:i.blockletCommunity||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-community",readOnly:o}}}),e.jsx(re,{disabled:s||o,label:`Blocklet ${h("common.support")}`,placeholder:`Blocklet ${h("common.support")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletSupport||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(q.target.value)?d({blockletSupport:h("blocklet.publish.errorTip.invalidUrlOrEmail")}):d({blockletSupport:""}),c({blockletSupport:q.target.value})},error:!!i.blockletSupport,helperText:i.blockletSupport||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-support",readOnly:o}}}),e.jsx(re,{disabled:s||o,label:`Blocklet ${h("common.repository")}`,placeholder:`Blocklet ${h("common.repository")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletRepository||"",onChange:q=>{q.target.value&&!/^(git|https|svn)/.test(q.target.value)?d({blockletRepository:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletRepository:""}),c({blockletRepository:q.target.value})},error:!!i.blockletRepository,helperText:i.blockletRepository||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-repository",readOnly:o}}})]})}),e.jsx(a,{className:"section full-width",sx:{display:"flex",mt:3},children:e.jsxs(a,{sx:{flex:1,overflow:"hidden"},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.logo")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.type"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"png, jpg, webp, svg"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.ratio"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"256x256"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.size"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"<500Kb"})]})})]})]}),e.jsx(a,{sx:{flex:1,cursor:o?"default":"pointer",display:"flex",alignItems:"flex-end"},children:e.jsx(Pt,{variant:"square",sx:{width:80,height:80},alt:"Blocklet Logo",src:m||P,onClick:()=>{V()&&C.current?.open()}})})]}),E&&e.jsx(St,{errors:Z,storeList:Q,mt:3}),e.jsxs(a,{sx:{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.screenshot")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{sx:{border:"none"},variant:"outlined",size:"small",children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.ratio"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"16 / 9"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.count"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"1~5"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.size"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"<5MB"})]})}),!o&&e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.order"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:h("studio.orderTip")})]})})]})]}),e.jsx(eo,{onDragEnd:o?void 0:U,children:e.jsx(to,{droppableId:"screenshots",direction:"horizontal",isDropDisabled:o,children:(q,Y)=>e.jsxs(a,{ref:q.innerRef,...q.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,flexWrap:"wrap",minHeight:160,background:Y.isDraggingOver?"grey.100":"transparent",transition:"background-color 0.2s ease",border:Y.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[$.map((J,se)=>e.jsx(oo,{draggableId:J,index:se,isDragDisabled:o,children:(de,le)=>e.jsxs(a,{ref:de.innerRef,...de.draggableProps,className:"screenshot",sx:{transform:le.isDragging?"scale(1.05)":"none",boxShadow:le.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:J}),!o&&e.jsx(ce,{...de.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(Kt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{c(pe=>{const he=[...pe.blockletScreenshots];return he.splice(se,1),{...pe,blockletScreenshots:he}})},children:e.jsx(tt,{})})]})},J)),q.placeholder,$.length<5&&e.jsx(a,{onClick:()=>{V()&&D.current?.open()},sx:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},children:"+"})]})})})]}),I&&e.jsx(St,{errors:H,storeList:Q}),e.jsxs(a,{sx:{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("studio.video")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.videoType"),":"," "]}),e.jsxs(a,{component:"span",sx:{color:"secondary.main"},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(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.count"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"1~3"})]})}),!o&&e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.order"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:h("studio.orderTip")})]})})]})]}),e.jsx(eo,{onDragEnd:o?void 0:ee,children:e.jsx(to,{droppableId:"videos",direction:"horizontal",isDropDisabled:o,children:(q,Y)=>e.jsxs(a,{ref:q.innerRef,...q.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,flexWrap:"wrap",minHeight:160,background:Y.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:Y.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[l.blockletVideos.map((J,se)=>e.jsx(oo,{draggableId:J,index:se,isDragDisabled:o,children:(de,le)=>e.jsxs(a,{ref:de.innerRef,...de.draggableProps,className:"screenshot",sx:{transform:le.isDragging?"scale(1.05)":"none",boxShadow:le.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx(Mt,{url:J,style:{pointerEvents:le.isDragging?"none":"auto"}}),!o&&e.jsx(ce,{...de.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(Kt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{c(pe=>{const he=[...pe.blockletVideos];return he.splice(se,1),{...pe,blockletVideos:he}})},children:e.jsx(tt,{})})]})},J)),q.placeholder,l.blockletVideos.length<3&&e.jsx(a,{onClick:()=>{V()&&O(!0)},sx:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},children:"+"})]})})})]})]})}),e.jsxs(k.Suspense,{fallback:e.jsx(Je,{}),children:[e.jsx(uo,{ref:C,locale:j,popup:!0,onUploadFinish:q=>{c({blockletLogo:q.data.filename}),x(""),C.current?.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:w,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/png","image/jpeg","image/webp","image/svg+xml"],maxFileSize:1024*1024*.5,maxNumberOfFiles:1}},dashboardProps:{autoOpen:"imageEditor"},imageEditorProps:{actions:{revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!1,cropWidescreen:!1,cropWidescreenVertical:!1},cropperOptions:{autoCrop:!0,aspectRatio:1,initialAspectRatio:1,autoCropArea:1,croppedCanvasOptions:{minWidth:256,minHeight:256}}}},"uploader-logo"),T&&e.jsx(ns,{onClose:()=>O(!1),params:l,setParams:c}),e.jsx(uo,{ref:D,locale:j,popup:!0,onUploadFinish:q=>{c(Y=>{const J=Y.blockletScreenshots||[];return J.push(q.data?.filename),{...Y,blockletScreenshots:J}}),D.current?.close()},installerProps:{disabled:!0},plugins:["ImageEditor"],apiPathProps:{uploader:S,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/*","image/svg+xml"],maxFileSize:1024*1024*5,maxNumberOfFiles:5-$.length}},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")]})]})}rs.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,componentDid:r.string,initLogoUrl:r.string.isRequired,setInitLogoUrl:r.func.isRequired};const cr=ve.div`
|
|
146
146
|
margin-top: 24px;
|
|
147
147
|
.screenshot {
|
|
148
148
|
margin-bottom: 16px;
|
|
@@ -190,7 +190,7 @@ import{r as k,i as Et,j as nt,L as we,g as go,k as Ns,l as _s,m as bt}from"./ven
|
|
|
190
190
|
padding-bottom: 12px;
|
|
191
191
|
border-bottom: ${({theme:t})=>`1px solid ${t.palette.divider}`};
|
|
192
192
|
}
|
|
193
|
-
`;function xs({text:t}){const{palette:o}=$o();return t?e.jsx(Wn,{style:{backgroundColor:o.background.default,color:o.text.primary},wrapperElement:{"data-color-mode":"light"},source:jn.sanitize(t),rehypePlugins:[[On,{target:"_blank"}]]}):e.jsx(Fe,{Icon:_t})}xs.propTypes={text:r.string.isRequired};function gs({params:t,setParams:o,paramsErrTip:s,loading:n,setParamsErrTip:l,readOnly:c}){const{t:i}=G(),[d,u]=k.useState(c?"preview":"write"),f=(p,m)=>{u(m)};return e.jsxs(a,{sx:{border:"1px solid transparent",borderRadius:2},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(A,{variant:"h6",sx:{fontWeight:"bold"},children:i("common.introduction")}),e.jsxs(Ao,{value:d,onChange:f,"aria-label":"wrapped label tabs example",children:[e.jsx(ot,{value:"write",label:"Write"}),e.jsx(ot,{value:"preview",label:"Preview"})]})]}),e.jsx(a,{sx:{display:d==="write"?"block":"none",width:"100%",marginTop:3},children:e.jsx(re,{disabled:n||c,sx:{border:"none"},placeholder:`Blocklet ${i("common.introduction")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,value:t.blockletIntroduction||"",onChange:p=>{l({blockletIntroduction:""}),o({blockletIntroduction:p.target.value.slice(0,me.PROJECT.MAX_INTRO_LENGTH)})},error:!!s.blockletIntroduction,helperText:s.blockletIntroduction||"",slotProps:{input:{"data-cy":"export-blocklet-introduction",readOnly:c,endAdornment:e.jsxs(He,{position:"end",children:[t?.blockletIntroduction?.length||0," / ",me.PROJECT.MAX_INTRO_LENGTH]})}}})}),e.jsx(a,{sx:{display:d==="preview"?"block":"none",mt:3},children:e.jsx(xs,{text:t.blockletIntroduction||""})})]})}gs.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};function ks({step:t=0,ok:o=!1,active:s=0,error:n="",warning:l=!1}){let c="grey.500",i=t+1;return o&&(i=e.jsx(Lo,{sx:{fontSize:18,margin:0},color:"white"})),n||!o&&s>t?(c="error.main",i=e.jsx(Yt,{sx:{fontSize:18,margin:0},color:"white"})):l?(c="warning.main",i=e.jsx(Yt,{sx:{fontSize:18,margin:0},color:"white"})):s>=t&&(c="primary.main"),e.jsx(a,{sx:{width:24,height:24,bgcolor:c,borderRadius:"100%",color:"white",display:"flex",justifyContent:"center",fontWeight:"bold",fontSize:14,alignItems:"center"},children:i})}ks.propTypes={step:r.number,ok:r.bool,active:r.number,error:r.string,warning:r.bool};function js({steps:t,activeStep:o,setActiveStep:s,hasSelectedResources:n=!1,params:l,loading:c,paramsErrTip:i,warning:d,viewMode:u="",projectId:f}){const{t:p}=G(),m=()=>{s(j=>j+1)},x=()=>{s(j=>j-1)},b=j=>j===0?i?.blockletTitle||i?.projectId||i?.blockletDescription||i?.blockletHomepage||i?.blockletSupport||i?.blockletCommunity||i?.blockletRepository:j===2?i?.blockletResource||i?.blockletDocker||i?.dockerImageName:j>=4?i?.blockletVersion||i?.note:"",h=u||ls({params:l,projectId:f,t:p})===null;return e.jsxs(a,{sx:{width:300,maxWidth:300,minWidth:300,padding:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[e.jsx(cn,{activeStep:o,orientation:"vertical",children:t.map((j,v)=>{const g={},C=c||!hr({params:l,projectId:f,step:v,t:p}),D=c?"":b(v);return D&&(g.optional=e.jsx(A,{variant:"caption",color:"error",sx:{wordBreak:"break-word"},children:D}),g.error=!0),e.jsxs(an,{children:[e.jsx(dn,{icon:e.jsx(ks,{error:D,warning:v===0?d.hasWarning:!1,active:h?99:o,step:v,ok:C}),sx:{cursor:"pointer",color:D?"error.main":"inherit"},disabled:!1,onClick:()=>s(v),...g,children:e.jsx(A,{fontSize:"14px",fontWeight:"500",color:D||!C&&o>v?"error.main":"inherit",children:j.label})}),e.jsxs(un,{children:[e.jsx(A,{fontSize:12,children:j.description}),!h&&e.jsx(a,{sx:{mb:2},children:e.jsxs("div",{children:[v<t.length-1&&e.jsx(X,{variant:"contained",onClick:m,sx:{mt:1,mr:1},disabled:D||!C,children:p("common.continue")}),v>0&&e.jsx(X,{disabled:v===0,onClick:x,sx:{mt:1,mr:1},children:p("common.back")})]})})]})]},j.label)})}),o>=t.length-1&&e.jsx(Lt,{square:!0,elevation:0,sx:{p:3},children:e.jsx(A,{fontSize:12,sx:{opacity:.5},children:"Click right top button to release"})})]})}js.propTypes={steps:r.array.isRequired,activeStep:r.number.isRequired,setActiveStep:r.func.isRequired,params:r.object.isRequired,viewMode:r.oneOfType([r.string,r.bool]),loading:r.bool.isRequired,projectId:r.string.isRequired,hasSelectedResources:r.oneOfType([r.string,r.bool]),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 br=[".zip",".gz"],fr=1024*1024*100,xr=k.lazy(()=>Wo(()=>import("./index-BuCfItTx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(t=>({default:t.Uploader})));function ys({app:t,projectId:o,readOnly:s,params:n,setParams:l,setParamsErrTip:c,error:i}){const{t:d,locale:u}=G(),f=k.useRef(null),p=()=>s?!1:!o||o===F.UNOWNED_DID?(W.error(d("blocklet.publish.errorTip.noFirstDid")),!1):!0,m=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t.meta.did}/${o}/resource/upload`;return e.jsxs(a,{sx:{mt:3},children:[e.jsx(A,{gutterBottom:!0,children:d("blocklet.publish.resourceUpload")}),e.jsxs(Re,{direction:"row",spacing:1,sx:{alignItems:"center",flex:1,cursor:s?"default":"pointer"},children:[!!n.uploadedResource&&e.jsx(A,{component:"a",href:`${m}/params.uploadedResource`,children:n.uploadedResource}),!s&&e.jsx(X,{variant:"outlined",size:"small",onClick:()=>{p()&&f.current?.open()},children:n.uploadedResource?d("common.change"):d("common.upload")})]}),e.jsx(k.Suspense,{fallback:e.jsx(Je,{}),children:e.jsx(xr,{ref:f,locale:u,popup:!0,onUploadFinish:x=>{l({uploadedResource:x.data.filename}),c({blockletResource:""}),f.current?.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:m,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileExts:br,maxFileSize:fr,maxNumberOfFiles:1}}},"uploader-resource")}),!!i&&e.jsx(a,{sx:{color:"error.main",mt:1,fontSize:14},children:i})]})}ys.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};function Dt({readOnly:t,params:o,setParams:s,paramsErrTip:n,setParamsErrTip:l,loading:c}){const{t:i}=G();return e.jsx(a,{className:"section",sx:{display:"flex",mt:3},children:e.jsxs(a,{sx:{flex:1},children:[e.jsx(re,{required:!0,disabled:c||t,label:`Blocklet ${i("common.version")}`,placeholder:`Blocklet ${i("common.version")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:o.blockletVersion||"",onChange:d=>{l({blockletVersion:""}),s({blockletVersion:d.target.value})},error:!!n.blockletVersion,helperText:n.blockletVersion||"",slotProps:{input:{"data-cy":"blocklet-version",readOnly:t}}}),e.jsx(re,{label:i("blocklet.publish.releaseNote"),autoComplete:"off",disabled:c||t,variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,required:!0,value:o.note||"",onChange:d=>{l({note:""}),s({note:d.target.value.slice(0,me.PROJECT.MAX_NOTE_LENGTH)})},error:!!n.note,helperText:n.note||"",sx:{mt:3},slotProps:{input:{"data-cy":"release-note",readOnly:t,endAdornment:e.jsxs(He,{position:"end",children:[o?.note?.length||0," / ",me.PROJECT.MAX_NOTE_LENGTH]})}}})]})})}Dt.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};function ws(t){for(const o in t)typeof t[o]=="string"?t[o]=t[o].replace(/\\\\/g,"\\"):typeof t[o]=="object"&&t[o]!==null&&ws(t[o]);return t}var gr=Nn();const oe=go(gr),kr={"-a":"--attach","-d":"--detach","-e":"--env","-h":"--hostname","-i":"--interactive","-it":"-it","-rm":"-rm","-m":"--memory","-p":"--publish","-P":"--publish-all","-l":"--label","-n":"--name","-q":"--quiet","-x":"--x-registry","-t":"--tty","-u":"--user","-v":"--volume","-w":"--workdir","-cgroupns":"--cgroupns","-cpus":"--cpus","-g":"--gpus","-ip6":"--ip6","--read-only":"--read-only","--add-host":"--add-host","--attach":"--attach","--blkio-weight":"--blkio-weight","--blkio-weight-device":"--blkio-weight-device","--cap-add":"--cap-add","--cap-drop":"--cap-drop","--cgroup-parent":"--cgroup-parent","--cidfile":"--cidfile","--cpu-period":"--cpu-period","--cpu-quota":"--cpu-quota","--cpu-rt-period":"--cpu-rt-period","--cpu-rt-runtime":"--cpu-rt-runtime","--cpu-shares":"--cpu-shares","--cpus":"--cpus","--cpuset-cpus":"--cpuset-cpus","--cpuset-mems":"--cpuset-mems","--detach":"--detach","--detach-keys":"--detach-keys","--device":"--device","--device-cgroup-rule":"--device-cgroup-rule","--device-read-bps":"--device-read-bps","--device-read-iops":"--device-read-iops","--device-write-bps":"--device-write-bps","--device-write-iops":"--device-write-iops","--disable-content-trust":"--disable-content-trust","--dns":"--dns","--dns-opt":"--dns-opt","--dns-search":"--dns-search","--domainname":"--domainname","--entrypoint":"--entrypoint","--env":"--env","--env-file":"--env-file","--expose":"--expose","--gpus":"--gpus","--group-add":"--group-add","--health-cmd":"--health-cmd","--health-interval":"--health-interval","--health-retries":"--health-retries","--health-start-period":"--health-start-period","--health-timeout":"--health-timeout","--help":"--help","--hostname":"--hostname","--init":"--init","--interactive":"--interactive","--ip":"--ip","--ip6":"--ip6","--ipc":"--ipc","--isolation":"--isolation","--kernel-memory":"--kernel-memory","--label":"--label","--label-file":"--label-file","--link":"--link","--link-local-ip":"--link-local-ip","--log-driver":"--log-driver","--log-opt":"--log-opt","--mac-address":"--mac-address","--memory":"--memory","--memory-reservation":"--memory-reservation","--memory-swap":"--memory-swap","--memory-swappiness":"--memory-swappiness","--mount":"--mount","--name":"--name","--network":"--network","--network-alias":"--network-alias","--no-healthcheck":"--no-healthcheck","--oom-kill-disable":"--oom-kill-disable","--oom-score-adj":"--oom-score-adj","--pid":"--pid","--pids-limit":"--pids-limit","--platform":"--platform","--privileged":"--privileged","--publish":"--publish","--publish-all":"--publish-all","--pull":"--pull","--restart":"--restart","--rm":"--rm","--runtime":"--runtime","--security-opt":"--security-opt","--shm-size":"--shm-size","--stop-signal":"--stop-signal","--stop-timeout":"--stop-timeout","--storage-opt":"--storage-opt","--sysctl":"--sysctl","--tmpfs":"--tmpfs","--tty":"--tty","--ulimit":"--ulimit","--user":"--user","--userns":"--userns","--uts":"--uts","--volume":"--volume","--volume-driver":"--volume-driver","--volumes-from":"--volumes-from","--workdir":"--workdir"},Ft={"--env":!0,"--publish":!0,"--volume":!0,"--attach":!0,"--quiet":!0,"--entrypoint":!0,"--workdir":!0,"--cidfile":!0,"--detach-keys":!0,"--disable-content-trust":!0,"--domainname":!0,"--expose":!0,"--ip":!0,"--link-local-ip":!0,"--platform":!0},jr={"--volume":!0,"--publish":!0},yr=new Set(["--publish","--volume"]),vs=t=>{const[o]=t.split(":");return o?.startsWith("/")||o?.startsWith("./")||o?.startsWith("../")||o?.startsWith("~")||o?.startsWith("$BLOCKLET")};function wr(t){return t.map(o=>{if(o.key!=="--volume"||o.value.startsWith("$BLOCKLET_APP_DIR/")||o.value.startsWith("$BLOCKLET_DATA_DIR/"))return o;const[s,...n]=o.value.split(":");if(!s||!vs(o.value))return o;const l=s.startsWith("/")?`$BLOCKLET_DATA_DIR${s}`:`$BLOCKLET_DATA_DIR/${s}`;return{...o,value:[l,...n].join(":")}})}function vr(t){let o=!0;return t.find(n=>n.key==="--publish"&&n.type==="web")?t.map(n=>{if(n.key==="--publish"){const l={...n,type:o?"docker":n.type};return o=n.type==="web",l}return n}):t.map(n=>{if(n.key==="--publish"){const l={...n,type:o?"web":"docker"};return o=!1,l}return n})}function mo(t){if(!t)return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};if(t=t.trim(),t.startsWith("$ docker run")&&(t=t.replace("$ docker run","docker run")),!t.startsWith("docker run"))return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};const s=t.replace(/\\\n/g,"").replace(/\n/g," ").trim().match(/(?:[^\s"']+|'[^']*'|"[^"]*")+/g);if(!s)return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};const n=[],l=[];let c=0,i="",d="";const u=[];for(;c<s.length;){const p=s[c];if(!p){c++;continue}if(p==="docker"||p==="run"){c++;continue}if((p==="-e"||p==="--env")&&c+1<s.length){const m=s[c+1]||"",[x,...b]=m.split("=");if(x){const h=b.join("=").replace(/^['"]|['"]$/g,"");l.push({key:x,value:h})}c+=2;continue}if(p.startsWith("-")&&u.length===0){const m=p.indexOf("=");let x=p,b=null;m!==-1&&(x=p.substring(0,m),b=p.substring(m+1).replace(/^['"]|['"]$/g,""));const h=kr[x];if(!h){c+=2;continue}if(h==="--publish"){let j="";if(b)j=b,n.push({key:h,value:j});else if(c+1<s.length&&!(s[c+1]||"").startsWith("-")){j=(s[c+1]||"").replace(/^['"]|['"]$/g,""),n.push({key:h,value:j}),c+=2;continue}else{n.push({key:h,value:"true"}),c++;continue}c++;continue}if(b!==null){n.push({key:h,value:b}),c++;continue}else if(c+1<s.length&&!(s[c+1]||"").startsWith("-")){const j=(s[c+1]||"").replace(/^['"]|['"]$/g,"");n.push({key:h,value:j}),c+=2;continue}else{n.push({key:h,value:"true"}),c++;continue}}u.push(p),c++}i=u[0]||"",d=u.slice(1).join(" ");const f=[];for(const p of n)p.name="",p.path="",p.prefix="",p.protocol="",p.proxyBehavior="service",p.type="docker",!(yr.has(p.key)&&p.value==="true")&&f.push(p);for(const p of l)p.custom="",p.description="",p.secure=!1,p.shared=!1,p.required=!1;return{dockerArgs:vr(wr(f)),dockerEnvs:l,dockerImage:i,dockerCommand:d}}function Cr({dockerArgs:t,dockerEnvs:o,dockerImage:s,dockerCommand:n}){if(t.length===0&&o.length===0&&!s)return"";const l=["docker run \\"],c=new Set(["--publish","--volume","--expose","--device","--mount","--label","--cap-add","--cap-drop","--add-host","--dns","--network-alias","--sysctl","--ulimit","--network"]);for(const i of t){const{key:d,value:u}=i;if(c.has(d))if(u==="true")l.push(` ${d} \\`);else{const f=/[\s"']/g.test(u)?`"${u}"`:u;l.push(` ${d} ${f} \\`)}else if(!l.some(f=>f.startsWith(` ${d}`)))if(u==="true")l.push(` ${d} \\`);else{const f=/[\s"']/g.test(u)?`"${u}"`:u;l.push(` ${d} ${f} \\`)}}for(const i of o){const{key:d,value:u}=i,f=/["']/g.test(u)?u:`"${u}"`;l.push(` -e ${d}=${f} \\`)}return s&&l.push(` ${s} \\`),n&&l.push(` ${n} \\`),l[l.length-1]?.endsWith(" \\")&&(l[l.length-1]=(l[l.length-1]||"").slice(0,-2)),l.join(`
|
|
193
|
+
`;function xs({text:t}){const{palette:o}=$o();return t?e.jsx(Wn,{style:{backgroundColor:o.background.default,color:o.text.primary},wrapperElement:{"data-color-mode":"light"},source:jn.sanitize(t),rehypePlugins:[[On,{target:"_blank"}]]}):e.jsx(Fe,{Icon:_t})}xs.propTypes={text:r.string.isRequired};function gs({params:t,setParams:o,paramsErrTip:s,loading:n,setParamsErrTip:l,readOnly:c}){const{t:i}=G(),[d,u]=k.useState(c?"preview":"write"),f=(p,m)=>{u(m)};return e.jsxs(a,{sx:{border:"1px solid transparent",borderRadius:2},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(A,{variant:"h6",sx:{fontWeight:"bold"},children:i("common.introduction")}),e.jsxs(Ao,{value:d,onChange:f,"aria-label":"wrapped label tabs example",children:[e.jsx(ot,{value:"write",label:"Write"}),e.jsx(ot,{value:"preview",label:"Preview"})]})]}),e.jsx(a,{sx:{display:d==="write"?"block":"none",width:"100%",marginTop:3},children:e.jsx(re,{disabled:n||c,sx:{border:"none"},placeholder:`Blocklet ${i("common.introduction")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,value:t.blockletIntroduction||"",onChange:p=>{l({blockletIntroduction:""}),o({blockletIntroduction:p.target.value.slice(0,me.PROJECT.MAX_INTRO_LENGTH)})},error:!!s.blockletIntroduction,helperText:s.blockletIntroduction||"",slotProps:{input:{"data-cy":"export-blocklet-introduction",readOnly:c,endAdornment:e.jsxs(He,{position:"end",children:[t?.blockletIntroduction?.length||0," / ",me.PROJECT.MAX_INTRO_LENGTH]})}}})}),e.jsx(a,{sx:{display:d==="preview"?"block":"none",mt:3},children:e.jsx(xs,{text:t.blockletIntroduction||""})})]})}gs.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};function ks({step:t=0,ok:o=!1,active:s=0,error:n="",warning:l=!1}){let c="grey.500",i=t+1;return o&&(i=e.jsx(Lo,{sx:{fontSize:18,margin:0},color:"white"})),n||!o&&s>t?(c="error.main",i=e.jsx(Yt,{sx:{fontSize:18,margin:0},color:"white"})):l?(c="warning.main",i=e.jsx(Yt,{sx:{fontSize:18,margin:0},color:"white"})):s>=t&&(c="primary.main"),e.jsx(a,{sx:{width:24,height:24,bgcolor:c,borderRadius:"100%",color:"white",display:"flex",justifyContent:"center",fontWeight:"bold",fontSize:14,alignItems:"center"},children:i})}ks.propTypes={step:r.number,ok:r.bool,active:r.number,error:r.string,warning:r.bool};function js({steps:t,activeStep:o,setActiveStep:s,hasSelectedResources:n=!1,params:l,loading:c,paramsErrTip:i,warning:d,viewMode:u="",projectId:f}){const{t:p}=G(),m=()=>{s(j=>j+1)},x=()=>{s(j=>j-1)},b=j=>j===0?i?.blockletTitle||i?.projectId||i?.blockletDescription||i?.blockletHomepage||i?.blockletSupport||i?.blockletCommunity||i?.blockletRepository:j===2?i?.blockletResource||i?.blockletDocker||i?.dockerImageName:j>=4?i?.blockletVersion||i?.note:"",h=u||ls({params:l,projectId:f,t:p})===null;return e.jsxs(a,{sx:{width:300,maxWidth:300,minWidth:300,padding:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[e.jsx(cn,{activeStep:o,orientation:"vertical",children:t.map((j,v)=>{const g={},C=c||!hr({params:l,projectId:f,step:v,t:p}),D=c?"":b(v);return D&&(g.optional=e.jsx(A,{variant:"caption",color:"error",sx:{wordBreak:"break-word"},children:D}),g.error=!0),e.jsxs(an,{children:[e.jsx(dn,{icon:e.jsx(ks,{error:D,warning:v===0?d.hasWarning:!1,active:h?99:o,step:v,ok:C}),sx:{cursor:"pointer",color:D?"error.main":"inherit"},disabled:!1,onClick:()=>s(v),...g,children:e.jsx(A,{fontSize:"14px",fontWeight:"500",color:D||!C&&o>v?"error.main":"inherit",children:j.label})}),e.jsxs(un,{children:[e.jsx(A,{fontSize:12,children:j.description}),!h&&e.jsx(a,{sx:{mb:2},children:e.jsxs("div",{children:[v<t.length-1&&e.jsx(X,{variant:"contained",onClick:m,sx:{mt:1,mr:1},disabled:D||!C,children:p("common.continue")}),v>0&&e.jsx(X,{disabled:v===0,onClick:x,sx:{mt:1,mr:1},children:p("common.back")})]})})]})]},j.label)})}),o>=t.length-1&&e.jsx(Lt,{square:!0,elevation:0,sx:{p:3},children:e.jsx(A,{fontSize:12,sx:{opacity:.5},children:"Click right top button to release"})})]})}js.propTypes={steps:r.array.isRequired,activeStep:r.number.isRequired,setActiveStep:r.func.isRequired,params:r.object.isRequired,viewMode:r.oneOfType([r.string,r.bool]),loading:r.bool.isRequired,projectId:r.string.isRequired,hasSelectedResources:r.oneOfType([r.string,r.bool]),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 br=[".zip",".gz"],fr=1024*1024*100,xr=k.lazy(()=>Wo(()=>import("./index-T7E5JhUh.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(t=>({default:t.Uploader})));function ys({app:t,projectId:o,readOnly:s,params:n,setParams:l,setParamsErrTip:c,error:i}){const{t:d,locale:u}=G(),f=k.useRef(null),p=()=>s?!1:!o||o===F.UNOWNED_DID?(W.error(d("blocklet.publish.errorTip.noFirstDid")),!1):!0,m=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t.meta.did}/${o}/resource/upload`;return e.jsxs(a,{sx:{mt:3},children:[e.jsx(A,{gutterBottom:!0,children:d("blocklet.publish.resourceUpload")}),e.jsxs(Re,{direction:"row",spacing:1,sx:{alignItems:"center",flex:1,cursor:s?"default":"pointer"},children:[!!n.uploadedResource&&e.jsx(A,{component:"a",href:`${m}/params.uploadedResource`,children:n.uploadedResource}),!s&&e.jsx(X,{variant:"outlined",size:"small",onClick:()=>{p()&&f.current?.open()},children:n.uploadedResource?d("common.change"):d("common.upload")})]}),e.jsx(k.Suspense,{fallback:e.jsx(Je,{}),children:e.jsx(xr,{ref:f,locale:u,popup:!0,onUploadFinish:x=>{l({uploadedResource:x.data.filename}),c({blockletResource:""}),f.current?.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:m,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileExts:br,maxFileSize:fr,maxNumberOfFiles:1}}},"uploader-resource")}),!!i&&e.jsx(a,{sx:{color:"error.main",mt:1,fontSize:14},children:i})]})}ys.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};function Dt({readOnly:t,params:o,setParams:s,paramsErrTip:n,setParamsErrTip:l,loading:c}){const{t:i}=G();return e.jsx(a,{className:"section",sx:{display:"flex",mt:3},children:e.jsxs(a,{sx:{flex:1},children:[e.jsx(re,{required:!0,disabled:c||t,label:`Blocklet ${i("common.version")}`,placeholder:`Blocklet ${i("common.version")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:o.blockletVersion||"",onChange:d=>{l({blockletVersion:""}),s({blockletVersion:d.target.value})},error:!!n.blockletVersion,helperText:n.blockletVersion||"",slotProps:{input:{"data-cy":"blocklet-version",readOnly:t}}}),e.jsx(re,{label:i("blocklet.publish.releaseNote"),autoComplete:"off",disabled:c||t,variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,required:!0,value:o.note||"",onChange:d=>{l({note:""}),s({note:d.target.value.slice(0,me.PROJECT.MAX_NOTE_LENGTH)})},error:!!n.note,helperText:n.note||"",sx:{mt:3},slotProps:{input:{"data-cy":"release-note",readOnly:t,endAdornment:e.jsxs(He,{position:"end",children:[o?.note?.length||0," / ",me.PROJECT.MAX_NOTE_LENGTH]})}}})]})})}Dt.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};function ws(t){for(const o in t)typeof t[o]=="string"?t[o]=t[o].replace(/\\\\/g,"\\"):typeof t[o]=="object"&&t[o]!==null&&ws(t[o]);return t}var gr=Nn();const oe=go(gr),kr={"-a":"--attach","-d":"--detach","-e":"--env","-h":"--hostname","-i":"--interactive","-it":"-it","-rm":"-rm","-m":"--memory","-p":"--publish","-P":"--publish-all","-l":"--label","-n":"--name","-q":"--quiet","-x":"--x-registry","-t":"--tty","-u":"--user","-v":"--volume","-w":"--workdir","-cgroupns":"--cgroupns","-cpus":"--cpus","-g":"--gpus","-ip6":"--ip6","--read-only":"--read-only","--add-host":"--add-host","--attach":"--attach","--blkio-weight":"--blkio-weight","--blkio-weight-device":"--blkio-weight-device","--cap-add":"--cap-add","--cap-drop":"--cap-drop","--cgroup-parent":"--cgroup-parent","--cidfile":"--cidfile","--cpu-period":"--cpu-period","--cpu-quota":"--cpu-quota","--cpu-rt-period":"--cpu-rt-period","--cpu-rt-runtime":"--cpu-rt-runtime","--cpu-shares":"--cpu-shares","--cpus":"--cpus","--cpuset-cpus":"--cpuset-cpus","--cpuset-mems":"--cpuset-mems","--detach":"--detach","--detach-keys":"--detach-keys","--device":"--device","--device-cgroup-rule":"--device-cgroup-rule","--device-read-bps":"--device-read-bps","--device-read-iops":"--device-read-iops","--device-write-bps":"--device-write-bps","--device-write-iops":"--device-write-iops","--disable-content-trust":"--disable-content-trust","--dns":"--dns","--dns-opt":"--dns-opt","--dns-search":"--dns-search","--domainname":"--domainname","--entrypoint":"--entrypoint","--env":"--env","--env-file":"--env-file","--expose":"--expose","--gpus":"--gpus","--group-add":"--group-add","--health-cmd":"--health-cmd","--health-interval":"--health-interval","--health-retries":"--health-retries","--health-start-period":"--health-start-period","--health-timeout":"--health-timeout","--help":"--help","--hostname":"--hostname","--init":"--init","--interactive":"--interactive","--ip":"--ip","--ip6":"--ip6","--ipc":"--ipc","--isolation":"--isolation","--kernel-memory":"--kernel-memory","--label":"--label","--label-file":"--label-file","--link":"--link","--link-local-ip":"--link-local-ip","--log-driver":"--log-driver","--log-opt":"--log-opt","--mac-address":"--mac-address","--memory":"--memory","--memory-reservation":"--memory-reservation","--memory-swap":"--memory-swap","--memory-swappiness":"--memory-swappiness","--mount":"--mount","--name":"--name","--network":"--network","--network-alias":"--network-alias","--no-healthcheck":"--no-healthcheck","--oom-kill-disable":"--oom-kill-disable","--oom-score-adj":"--oom-score-adj","--pid":"--pid","--pids-limit":"--pids-limit","--platform":"--platform","--privileged":"--privileged","--publish":"--publish","--publish-all":"--publish-all","--pull":"--pull","--restart":"--restart","--rm":"--rm","--runtime":"--runtime","--security-opt":"--security-opt","--shm-size":"--shm-size","--stop-signal":"--stop-signal","--stop-timeout":"--stop-timeout","--storage-opt":"--storage-opt","--sysctl":"--sysctl","--tmpfs":"--tmpfs","--tty":"--tty","--ulimit":"--ulimit","--user":"--user","--userns":"--userns","--uts":"--uts","--volume":"--volume","--volume-driver":"--volume-driver","--volumes-from":"--volumes-from","--workdir":"--workdir"},Ft={"--env":!0,"--publish":!0,"--volume":!0,"--attach":!0,"--quiet":!0,"--entrypoint":!0,"--workdir":!0,"--cidfile":!0,"--detach-keys":!0,"--disable-content-trust":!0,"--domainname":!0,"--expose":!0,"--ip":!0,"--link-local-ip":!0,"--platform":!0},jr={"--volume":!0,"--publish":!0},yr=new Set(["--publish","--volume"]),vs=t=>{const[o]=t.split(":");return o?.startsWith("/")||o?.startsWith("./")||o?.startsWith("../")||o?.startsWith("~")||o?.startsWith("$BLOCKLET")};function wr(t){return t.map(o=>{if(o.key!=="--volume"||o.value.startsWith("$BLOCKLET_APP_DIR/")||o.value.startsWith("$BLOCKLET_DATA_DIR/"))return o;const[s,...n]=o.value.split(":");if(!s||!vs(o.value))return o;const l=s.startsWith("/")?`$BLOCKLET_DATA_DIR${s}`:`$BLOCKLET_DATA_DIR/${s}`;return{...o,value:[l,...n].join(":")}})}function vr(t){let o=!0;return t.find(n=>n.key==="--publish"&&n.type==="web")?t.map(n=>{if(n.key==="--publish"){const l={...n,type:o?"docker":n.type};return o=n.type==="web",l}return n}):t.map(n=>{if(n.key==="--publish"){const l={...n,type:o?"web":"docker"};return o=!1,l}return n})}function mo(t){if(!t)return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};if(t=t.trim(),t.startsWith("$ docker run")&&(t=t.replace("$ docker run","docker run")),!t.startsWith("docker run"))return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};const s=t.replace(/\\\n/g,"").replace(/\n/g," ").trim().match(/(?:[^\s"']+|'[^']*'|"[^"]*")+/g);if(!s)return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};const n=[],l=[];let c=0,i="",d="";const u=[];for(;c<s.length;){const p=s[c];if(!p){c++;continue}if(p==="docker"||p==="run"){c++;continue}if((p==="-e"||p==="--env")&&c+1<s.length){const m=s[c+1]||"",[x,...b]=m.split("=");if(x){const h=b.join("=").replace(/^['"]|['"]$/g,"");l.push({key:x,value:h})}c+=2;continue}if(p.startsWith("-")&&u.length===0){const m=p.indexOf("=");let x=p,b=null;m!==-1&&(x=p.substring(0,m),b=p.substring(m+1).replace(/^['"]|['"]$/g,""));const h=kr[x];if(!h){c+=2;continue}if(h==="--publish"){let j="";if(b)j=b,n.push({key:h,value:j});else if(c+1<s.length&&!(s[c+1]||"").startsWith("-")){j=(s[c+1]||"").replace(/^['"]|['"]$/g,""),n.push({key:h,value:j}),c+=2;continue}else{n.push({key:h,value:"true"}),c++;continue}c++;continue}if(b!==null){n.push({key:h,value:b}),c++;continue}else if(c+1<s.length&&!(s[c+1]||"").startsWith("-")){const j=(s[c+1]||"").replace(/^['"]|['"]$/g,"");n.push({key:h,value:j}),c+=2;continue}else{n.push({key:h,value:"true"}),c++;continue}}u.push(p),c++}i=u[0]||"",d=u.slice(1).join(" ");const f=[];for(const p of n)p.name="",p.path="",p.prefix="",p.protocol="",p.proxyBehavior="service",p.type="docker",!(yr.has(p.key)&&p.value==="true")&&f.push(p);for(const p of l)p.custom="",p.description="",p.secure=!1,p.shared=!1,p.required=!1;return{dockerArgs:vr(wr(f)),dockerEnvs:l,dockerImage:i,dockerCommand:d}}function Cr({dockerArgs:t,dockerEnvs:o,dockerImage:s,dockerCommand:n}){if(t.length===0&&o.length===0&&!s)return"";const l=["docker run \\"],c=new Set(["--publish","--volume","--expose","--device","--mount","--label","--cap-add","--cap-drop","--add-host","--dns","--network-alias","--sysctl","--ulimit","--network"]);for(const i of t){const{key:d,value:u}=i;if(c.has(d))if(u==="true")l.push(` ${d} \\`);else{const f=/[\s"']/g.test(u)?`"${u}"`:u;l.push(` ${d} ${f} \\`)}else if(!l.some(f=>f.startsWith(` ${d}`)))if(u==="true")l.push(` ${d} \\`);else{const f=/[\s"']/g.test(u)?`"${u}"`:u;l.push(` ${d} ${f} \\`)}}for(const i of o){const{key:d,value:u}=i,f=/["']/g.test(u)?u:`"${u}"`;l.push(` -e ${d}=${f} \\`)}return s&&l.push(` ${s} \\`),n&&l.push(` ${n} \\`),l[l.length-1]?.endsWith(" \\")&&(l[l.length-1]=(l[l.length-1]||"").slice(0,-2)),l.join(`
|
|
194
194
|
`)}const Cs={"--volume":t=>{const[o]=t.split(":");return o?vs(t)&&!t.startsWith("$BLOCKLET_APP_DIR/")&&!t.startsWith("$BLOCKLET_DATA_DIR/")?"Volume must start with $BLOCKLET_APP_DIR or $BLOCKLET_DATA_DIR":t.indexOf("..")>-1?'Volume cannot contain ".."':"":"Volume must start with key:value"}},Qe=t=>t.replace(/^[-]+/,"").replace(/-([a-z])/g,(n,l)=>l.toUpperCase()),Rr=t=>`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`,Sr=[" -- ","~","&","|",">","<","{","}","[","]",";","$","!","*","%","&&","||",","],Tr=["rm ","sudo "];function Rs(t){if(t==="")return;if(/(\n|\\n|\\\n|\t|\\t|\\\t)/.test(t))throw new Error("Docker CMD is invalid");const s=t.toLocaleLowerCase();if(Tr.some(l=>s.indexOf(l)!==-1))throw new Error("Docker CMD is invalid");if(Sr.some(l=>t.indexOf(l)!==-1))throw new Error("Docker CMD is invalid");if(!/^(?:(?:[a-zA-Z0-9\-_.\/:=\s]+)|(?:\@{1,2}[a-zA-Z_][a-zA-Z0-9_]*))+$/.test(t))throw new Error("Docker CMD is invalid")}const Dr=Array.from(new Set(Object.keys(Ft).map(Qe))),Ir=["publish","volume"];oe.object({workdir:oe.string().trim().optional(),image:oe.string().trim().regex(/^[^\s]+$/).optional(),shell:oe.string().trim().optional(),volumes:oe.array().items(oe.string().trim()).optional(),script:oe.string().trim().optional(),installNodeModules:oe.boolean().optional(),skipWrapDockerfile:oe.boolean().optional(),command:oe.string().allow("").default("").optional().custom((t,o)=>{try{return Rs(t),t}catch(s){return o.error("any.invalid",{message:s.message})}},"Docker CMD validation"),runBaseScript:oe.boolean().optional(),...Dr.reduce((t,o)=>{const s=Cs[Rr(o)];return Ir.includes(o)?(t[o]=oe.array().items(oe.string().trim()).optional(),s?t[o]=oe.array().items(oe.string().trim().custom((n,l)=>{const c=s(n);return c?l.message(c):n})).optional():t[o]=oe.array().items(oe.string().trim()).optional(),t):(s?t[o]=oe.string().trim().custom((n,l)=>{const c=s(n);return c?l.message(c):n}).optional():t[o]=oe.string().trim().optional(),t)},{})}).optional();function It({index:t,item:o,dockerParams:s,setDockerParams:n,dataKey:l,t:c,readOnly:i}){const d=o?.value||"",[u,f]=k.useState(!1),p=()=>{s[l]?.splice(t,1),n({...s,[l]:[...s[l]]})},m=(P,$)=>{s[l]?.[t]&&($?(s[l][t].custom=s[l][t].value,s[l][t].value=`$${Qe(o.key)}`):(s[l][t].value=s[l][t].custom||"",s[l][t].custom="")),n({...s,[l]:[...s[l]]})},x=(P,$)=>{const w=s[l][t]?.value||"";s[l][t]={...s[l][t],secure:$,value:$&&w===me.BLOCKLET_AUTOMATIC_ENV_VALUE?"":w},n({...s,[l]:[...s[l]]})},b=(P,$)=>{s[l][t]={...s[l][t],shared:$},n({...s,[l]:[...s[l]]})},h=(P,$)=>{const w=s[l][t]?.value||"";s[l][t]={...s[l][t],required:$,value:$&&w===me.BLOCKLET_AUTOMATIC_ENV_VALUE?"":w},n({...s,[l]:[...s[l]]})},j=(P,$)=>{s[l][t]={...s[l][t],value:$?me.BLOCKLET_AUTOMATIC_ENV_VALUE:"",secure:!1,required:!1},n({...s,[l]:[...s[l]]})},v=P=>{s[l][t]={...s[l][t],description:P.target.value},n({...s,[l]:[...s[l]]})},g=P=>{const $=P.target.value==="web"?"web":"docker";$==="web"&&s.dockerArgs.forEach(Z=>{Z.type="docker"});const S=`/${s.dockerImage.replace(/\W/g,"-")}-${t}`;s.dockerArgs[t]={...s.dockerArgs[t],type:$,path:$==="docker"?S:"/",protocol:"http",prefix:$==="docker"?S:"/",name:"publicUrl",port:"BLOCKLET_PORT"},n({...s,dockerArgs:[...s.dockerArgs]})},C=P=>{s.dockerArgs[t]={...s.dockerArgs[t],proxyBehavior:P.target.value==="direct"?"direct":"service"},n({...s,dockerArgs:[...s.dockerArgs]})},D=P=>{const $=P.target.value;s[l][t]={...s[l][t],prefix:$,path:$==="*"?"/":$},n({...s,[l]:[...s[l]]})},R=P=>{s[l]?.[t]&&(s[l][t].value=P.target.value),n({...s,[l]:[...s[l]]})},y=d===`$${Qe(o.key)}`||o.custom,T=l==="dockerArgs"&&!Ft[o.key],O=jr[o.key],N=l==="dockerEnvs",z=o.key==="--publish";let K=o.key;return z&&o.type==="web"?K="--publish (Web)":N&&(K=`--env ${o.key}`),e.jsxs(a,{sx:{display:"flex",flexDirection:"row",gap:2,alignItems:"center"},children:[e.jsx(a,{sx:{width:250},children:e.jsx(A,{sx:{textOverflow:"ellipsis",width:"100%",overflow:"hidden"},children:K})}),e.jsxs(a,{sx:{display:"flex",flexDirection:"column",gap:1,flex:1},children:[e.jsx(re,{disabled:i||y||T||o.value===me.BLOCKLET_AUTOMATIC_ENV_VALUE,placeholder:"",value:y?`$${Qe(o.key)}`:d,sx:{flex:1},error:T,onChange:R,slotProps:{input:{endAdornment:e.jsxs(He,{position:"end",sx:{zoom:.9},children:[(!(O||T)||N||z)&&e.jsx(ce,{onClick:()=>f(!0),children:e.jsx(ae,{icon:"icon-park-outline:setting-config"})}),!i&&e.jsx(ce,{onClick:p,color:T?"error":"default",children:e.jsx(ae,{icon:"ic:round-delete"})})]})}}}),T&&e.jsx(A,{variant:"caption",color:"error",children:c("blocklet.publish.docker.noAllowTheArg")}),o.key==="--publish"&&e.jsx(A,{variant:"caption",sx:{color:"text.secondary"},children:c("blocklet.publish.docker.publishTips")}),o.key==="--volume"&&Cs[o.key](d)&&e.jsx(A,{variant:"caption",color:"error",children:c("blocklet.publish.docker.volumeTips")})]}),u&&e.jsx(ct,{open:!0,fullWidth:!0,maxWidth:"sm",PaperProps:{style:{minHeight:0}},title:c(N?"blocklet.publish.docker.modifyEnv":"blocklet.publish.docker.modifyParam"),onClose:()=>f(!1),children:e.jsxs(a,{sx:{display:"flex",flexDirection:"column",gap:1,paddingBottom:2},children:[O||T||N?null:e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{children:c("blocklet.publish.docker.needCustomInput")}),e.jsx($e,{disabled:i,checked:y,onChange:m,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{children:c("blocklet.publish.docker.shared")}),e.jsx($e,{disabled:i,checked:o.shared,onChange:b,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{children:c("blocklet.publish.docker.required")}),e.jsx($e,{disabled:i,checked:o.required,onChange:h,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{children:c("blocklet.publish.docker.secure")}),e.jsx($e,{disabled:i,checked:o.secure,onChange:x,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{children:c("blocklet.publish.docker.autoGenerated")}),e.jsx($e,{disabled:i,checked:o.value===me.BLOCKLET_AUTOMATIC_ENV_VALUE,onChange:j,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{sx:{flex:1},children:c("blocklet.publish.docker.description")}),e.jsx(re,{disabled:i,value:o.description,onChange:v,sx:{flex:1},label:c("blocklet.publish.docker.description")})]}),z&&e.jsxs(a,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{sx:{flex:1},children:c("blocklet.publish.docker.portType")}),e.jsxs(Ct,{value:o.type||"docker",onChange:g,children:[e.jsx(be,{value:"docker",children:"Docker"}),e.jsx(be,{value:"web",children:"Web"})]})]}),z&&o.type==="web"&&e.jsxs(a,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{sx:{flex:1},children:c("blocklet.publish.docker.proxyBehavior")}),e.jsxs(Ct,{value:o.proxyBehavior||"service",onChange:C,children:[e.jsx(be,{value:"service",children:c("blocklet.publish.docker.serviceProxy")}),e.jsx(be,{value:"direct",children:c("blocklet.publish.docker.directProxy")})]})]}),z&&o.type==="web"&&e.jsxs(a,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{sx:{flex:1},children:c("blocklet.publish.docker.prefix")}),e.jsx(re,{disabled:i,value:o.prefix,onChange:D,sx:{flex:1},label:c("blocklet.publish.docker.prefix")})]})]})})]})}It.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};const Er=`
|
|
195
195
|
docker run --name postgrest
|
|
196
196
|
-p 3000:3000
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as i,c3 as $,at as x,$ as s,ak as y,b0 as L,p as T,s as A}from"./vendor-mui-core-p6jGoroc.js";import{g as E,h as M,b as h,k as q}from"./vendor-hooks-zCCbpt45.js";import{ad as D,a6 as U,c as H,az as F,aA as j,aB as b,t as O}from"./index-
|
|
1
|
+
import{j as i,c3 as $,at as x,$ as s,ak as y,b0 as L,p as T,s as A}from"./vendor-mui-core-p6jGoroc.js";import{g as E,h as M,b as h,k as q}from"./vendor-hooks-zCCbpt45.js";import{ad as D,a6 as U,c as H,az as F,aA as j,aB as b,t as O}from"./index-CDq77s86.js";import{r as m}from"./vendor-react-x2lQvn4m.js";import{b as B,a as Y,T as _,$ as V}from"./vendor-ux-TkkDR0Gn.js";import{N as W}from"./index--xoJi0Oj.js";import{a as k}from"./index-CSfHWUfI.js";import{C as J}from"./vendor-utils-CtD44yV-.js";import{u as K}from"./use-passport-id-B-b-_oYF.js";import{u as X}from"./session-CvQ97dDY.js";import{b as G}from"./sdk-6bZnDL_f.js";import{w as Q}from"./wrap-locale-Bf1-s-bS.js";function P({invitation:e,createPassportSvg:a,passportColor:c="auto"}){const[p,n]=m.useState(!1),{t}=m.useContext(B),l=m.useMemo(()=>(e.role.title||e.role.name).toUpperCase(),[e.role.title,e.role.name]),d=m.useMemo(()=>a({title:l,issuer:e.info.name,issuerDid:e.info.appDid,ownerName:"Your Name",ownerDid:e.info.appDid,preferredColor:e.info.passportColor||c,extra:e.passportExpireTime?{key:"Exp",value:D(e.passportExpireTime).format("YYYY-MM-DD HH:mm:ss")}:void 0}),[e,l]),u=m.useCallback(()=>{n(!0)},[]),o=m.useCallback(()=>{n(!1)},[]);return i.jsxs(i.Fragment,{children:[i.jsx(Z,{children:i.jsxs("div",{className:"invite-passport__card",onClick:u,children:[!!e.display&&i.jsx(W,{data:e.display,style:{width:"100%",height:"100%"}}),!e.display&&i.jsx("div",{className:"invite-passport__cover",dangerouslySetInnerHTML:{__html:d}})]})}),i.jsx(Y,{open:p,title:t("invite.viewPermission"),PaperProps:{style:{minHeight:"auto",paddingBottom:"20px"}},onClose:o,children:e.role.permissions&&e.role.permissions.length>0?i.jsx("ul",{style:{listStyle:"circle",padding:"0 20px"},children:e.role.permissions.map(r=>i.jsx("li",{style:{listStyle:"circle"},children:r.description},r.name))}):i.jsxs("div",{style:{color:"#999",textAlign:"center"},children:[i.jsx($,{style:{width:"30px",height:"30px"}}),i.jsx("div",{children:t("invite.emptyPermission")})]})})]})}P.propTypes={invitation:s.object.isRequired,createPassportSvg:s.func.isRequired,passportColor:s.string};const Z=x.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
max-width: 350px;
|
|
4
4
|
margin: 30px auto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as i,ak as l}from"./vendor-mui-core-p6jGoroc.js";import{i as x,r as g}from"./vendor-react-x2lQvn4m.js";import{b as v}from"./vendor-hooks-zCCbpt45.js";import{I as w}from"./invitation-
|
|
1
|
+
import{j as i,ak as l}from"./vendor-mui-core-p6jGoroc.js";import{i as x,r as g}from"./vendor-react-x2lQvn4m.js";import{b as v}from"./vendor-hooks-zCCbpt45.js";import{I as w}from"./invitation-C6_hcRBi.js";import{K as u}from"./landing-page-C4ZUBLGU.js";import{T as I,w as S}from"./vendor-ux-TkkDR0Gn.js";import{a as T,e as k,s as E,b as j,c as P,H as R,d as W}from"./index-CDq77s86.js";import{g as b}from"./get-safe-url-70dNOHyP.js";import"./vendor-utils-CtD44yV-.js";import"./index--xoJi0Oj.js";import"./index-CSfHWUfI.js";import"./use-passport-id-B-b-_oYF.js";import"./session-CvQ97dDY.js";import"./sdk-6bZnDL_f.js";import"./wrap-locale-Bf1-s-bS.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BndcJjQO.js";function y(n){const c=x(),{searchParams:s}=new URL(window.location.href),{api:m,session:p}=T(),{t:d}=I(),r=s.get("inviteId"),a=s.get("redirect"),f=g.useCallback(async()=>{const{data:t}=await k.get("invitation",{params:{inviteId:r}});return t},[r]),h=v(async(t,o=e=>e)=>{t&&(E(o(t.sessionToken)),j(o(t.refreshToken)),t.visitorId&&S(o(t.visitorId))),await p.refresh(),setTimeout(()=>{if(a){const e=decodeURIComponent(a);e.startsWith(P.WELLKNOWN_SERVICE_PATH_PREFIX)?c(e,{replace:!0}):window.location.href=b(e)}else window.location.href=window.env.pathPrefix||"/"},50)});return i.jsxs(u,{did:window.blocklet?.appPid,children:[i.jsx(R,{children:i.jsx("title",{children:d("pageTitle.invite")})}),i.jsx(l,{sx:{width:"560px",maxWidth:"100%",height:"100%"},className:"page-invite",children:i.jsx(w,{...n,getDataFn:f,checkFn:m.get,createPassportSvg:t=>W({...t}),onLoginSuccess:h,inService:!0})})]})}export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,p as x,ak as w}from"./vendor-mui-core-p6jGoroc.js";import{g as v,k as T,b as p}from"./vendor-hooks-zCCbpt45.js";import{I as k}from"./invitation-
|
|
1
|
+
import{j as s,p as x,ak as w}from"./vendor-mui-core-p6jGoroc.js";import{g as v,k as T,b as p}from"./vendor-hooks-zCCbpt45.js";import{I as k}from"./invitation-C6_hcRBi.js";import{K as I}from"./landing-page-C4ZUBLGU.js";import{T as P,w as j}from"./vendor-ux-TkkDR0Gn.js";import{a as R,s as S,b as E,c as W,H as C,d as F}from"./index-CDq77s86.js";import{g as L}from"./get-safe-url-70dNOHyP.js";import{i as N}from"./vendor-react-x2lQvn4m.js";import"./vendor-utils-CtD44yV-.js";import"./index--xoJi0Oj.js";import"./index-CSfHWUfI.js";import"./use-passport-id-B-b-_oYF.js";import"./session-CvQ97dDY.js";import"./sdk-6bZnDL_f.js";import"./wrap-locale-Bf1-s-bS.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BndcJjQO.js";function Q(m){const{searchParams:r}=new URL(window.location.href),{api:a,session:f}=R(),d=N(),{t:h}=P(),n=r.get("id"),c=r.get("redirect"),u=v({state:""}),i=T(async()=>{if(!n)return null;const{data:t}=await a.get("/api/invitation",{params:{inviteId:n,mode:"issue-passport"}});return t}),g=p(()=>{if(i.error)throw i.error;return i?.data}),l=p(async(t,o=e=>e)=>{t&&(t.sessionToken&&S(o(t.sessionToken)),t.refreshToken&&E(o(t.refreshToken)),t.visitorId&&j(o(t.visitorId)),await f.refresh()),setTimeout(()=>{if(c){const e=decodeURIComponent(c);e.startsWith(W.WELLKNOWN_SERVICE_PATH_PREFIX)?d(e,{replace:!0}):window.location.href=L(e)}else window.location.href=window.env.pathPrefix||"/"},50)});return i.loading?s.jsx(x,{}):s.jsxs(I,{did:window.blocklet?.appPid,children:[s.jsx(C,{children:s.jsx("title",{children:h("pageTitle.issuePassport")})}),s.jsx(w,{className:"page-invite",sx:{width:"560px",maxWidth:"100%",height:"100%"},children:s.jsx(k,{...m,action:"issue-passport",getDataFn:g,checkFn:a.get,createPassportSvg:F,onLoginSuccess:l,inService:!0,status:u.state})})]})}export{Q as default};
|